2023-12-21 16:14:02 +08:00
|
|
|
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{
|
2023-12-22 09:46:11 +08:00
|
|
|
query: ecs.NewQuery(filter.Contains(component.UidType, component.HandcartSwitchType)),
|
2023-12-21 16:14:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
2023-12-22 15:00:34 +08:00
|
|
|
closed := component.HandcartSwitchType.Get(entry).Position.Closed()
|
2023-12-21 16:14:02 +08:00
|
|
|
breakerModel := (wd.Repo.FindById(breakerId)).(*repository.HandcartSwitch)
|
|
|
|
breakerPortA := breakerModel.PortA
|
|
|
|
breakerPortB := breakerModel.PortB
|
|
|
|
towPipePortsTransPower(wd, closed, breakerPortA, breakerPortB)
|
|
|
|
})
|
|
|
|
}
|