rts-sim-module/sys/device_sys/fmq.go
2023-10-11 15:43:48 +08:00

27 lines
555 B
Go

package device_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// FMQSys 蜂鸣系统
type FMQSys struct {
query *ecs.Query
}
func NewFMQSys() *FMQSys {
return &FMQSys{query: ecs.NewQuery(filter.Contains(component.FMQDriveType, component.BitStateType))}
}
func (fmq *FMQSys) Update(w ecs.World) {
fmq.query.Each(w, func(entry *ecs.Entry) {
drive := component.FMQDriveType.Get(entry)
state := component.BitStateType.Get(entry)
if drive.Td != state.Val {
state.Val = drive.Td
}
})
}