rts-sim-module/sys/iscs_sys/iscs_bas_air_conditioner.go
2023-12-29 17:00:26 +08:00

27 lines
637 B
Go

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{
query: ecs.NewQuery(filter.Contains(component.UidType, component.MotorType, component.AirConditioningType)),
}
}
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
})
}