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

27 lines
573 B
Go
Raw Normal View History

2023-12-25 17:37:41 +08:00
package iscs_sys
2023-12-26 17:52:28 +08:00
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// ValveSystem 阀门
type ValveSystem struct {
query *ecs.Query
}
func NewValveSystem() *ValveSystem {
return &ValveSystem{
query: ecs.NewQuery(filter.Contains(component.UidType, component.ValveType, component.DeviceExceptionType)),
}
}
func (s *ValveSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
valve := component.ValveType.Get(entry)
valve.Closed = valve.OpenRate == 0
valve.Opened = valve.OpenRate == 100
})
}