38 lines
1016 B
Go
38 lines
1016 B
Go
|
package iscs_sys
|
||
|
|
||
|
import (
|
||
|
"joylink.club/ecs"
|
||
|
"joylink.club/ecs/filter"
|
||
|
"joylink.club/rtsssimulation/component"
|
||
|
"joylink.club/rtsssimulation/consts"
|
||
|
)
|
||
|
|
||
|
type IscsDoorSystem struct {
|
||
|
queryCivilDefenseDoor *ecs.Query
|
||
|
}
|
||
|
|
||
|
func NewIscsDoorSystem() *IscsDoorSystem {
|
||
|
return &IscsDoorSystem{
|
||
|
queryCivilDefenseDoor: ecs.NewQuery(filter.Contains(component.CivilDefenseDoorType)),
|
||
|
}
|
||
|
}
|
||
|
func (s *IscsDoorSystem) Update(w ecs.World) {
|
||
|
s.queryCivilDefenseDoor.Each(w, func(entry *ecs.Entry) {
|
||
|
door := component.CivilDefenseDoorType.Get(entry)
|
||
|
//
|
||
|
door.Exception = consts.DeviceExceptionNon
|
||
|
if entry.HasComponent(component.DeviceFaultTag) {
|
||
|
door.Exception = consts.DeviceFault
|
||
|
}
|
||
|
if entry.HasComponent(component.DeviceAlarmTag) {
|
||
|
door.Exception = consts.DeviceAlarm
|
||
|
}
|
||
|
if entry.HasComponent(component.DeviceAbnormalTag) {
|
||
|
door.Exception = consts.DeviceAbnormal
|
||
|
}
|
||
|
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
|
||
|
door.Exception = consts.DeviceCommunicationInterrupt
|
||
|
}
|
||
|
})
|
||
|
}
|