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

36 lines
990 B
Go

package iscs_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/repository"
)
type HandcartSystem struct {
query *ecs.Query
}
func NewHandcartSystem() *HandcartSystem {
return &HandcartSystem{
query: ecs.NewQuery(filter.Contains(component.UidType, component.HandcartSwitchType)),
}
}
func (s *HandcartSystem) Update(w ecs.World) {
s.handcartTransPower(w)
}
// 手车传递电能
func (s *HandcartSystem) handcartTransPower(w ecs.World) {
wd := entity.GetWorldData(w)
s.query.Each(w, func(entry *ecs.Entry) {
breakerId := component.UidType.Get(entry).Id
closed := component.HandcartSwitchType.Get(entry).Position == component.HpClosed
breakerModel := (wd.Repo.FindById(breakerId)).(*repository.HandcartSwitch)
breakerPortA := breakerModel.PortA
breakerPortB := breakerModel.PortB
towPipePortsTransPower(wd, closed, breakerPortA, breakerPortB)
})
}