rts-sim-module/sys/iscs_sys/iscs_bas_valve.go
2023-12-26 17:52:28 +08:00

27 lines
573 B
Go

package iscs_sys
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
})
}