27 lines
573 B
Go
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
|
|
|
|
})
|
|
}
|