rts-sim-module/sys/iscs_sys/iscs_bas_water_closed_container.go

35 lines
1022 B
Go

package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/consts"
)
// WaterClosedContainerSystem 封闭冷却塔、水处理器
type WaterClosedContainerSystem struct {
query *ecs.Query
}
func NewWaterClosedContainerSystem() *WaterClosedContainerSystem {
return &WaterClosedContainerSystem{
query: ecs.NewQuery(filter.Contains(component.WaterClosedContainerType)),
}
}
func (s *WaterClosedContainerSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
container := component.WaterClosedContainerType.Get(entry)
container.Exception = consts.DeviceExceptionNon
if entry.HasComponent(component.DeviceFaultTag) {
container.Exception = consts.DeviceFault
}
if entry.HasComponent(component.DeviceAbnormalTag) {
container.Exception = consts.DeviceAbnormal
}
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
container.Exception = consts.DeviceCommunicationInterrupt
}
})
}