rts-sim-module/sys/device_sys/alarm.go

27 lines
573 B
Go
Raw Normal View History

2023-10-12 17:46:43 +08:00
package device_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// FMQSys 蜂鸣系统
type AlarmSys struct {
query *ecs.Query
}
func NewAlarmSys() *AlarmSys {
return &AlarmSys{query: ecs.NewQuery(filter.Contains(component.AlarmDriveType, component.BitStateType))}
}
func (alarm *AlarmSys) Update(w ecs.World) {
alarm.query.Each(w, func(entry *ecs.Entry) {
drive := component.AlarmDriveType.Get(entry)
state := component.BitStateType.Get(entry)
if drive.Td != state.Val {
state.Val = drive.Td
}
})
}