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

32 lines
772 B
Go
Raw Normal View History

2023-12-27 18:11:27 +08:00
package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
// AirConditionerSystem 空调
type AirConditionerSystem struct {
query *ecs.Query
}
func NewAirConditionerSystem() *AirConditionerSystem {
return &AirConditionerSystem{
2023-12-29 17:00:26 +08:00
query: ecs.NewQuery(filter.Contains(component.UidType, component.MotorType, component.AirConditioningType)),
2023-12-27 18:11:27 +08:00
}
}
func (s *AirConditionerSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
motor := component.MotorType.Get(entry)
air := component.AirConditioningType.Get(entry)
//
air.Running = motor.Speed > 0
2024-01-09 09:39:03 +08:00
//
if entry.HasComponent(component.FluidDriverType) {
fd := component.FluidDriverType.Get(entry)
fd.On = motor.Speed > 0
}
2023-12-27 18:11:27 +08:00
})
}