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 DisconnectorSystem struct {
|
|
|
|
query *ecs.Query
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDisconnectorSystem() *DisconnectorSystem {
|
|
|
|
return &DisconnectorSystem{
|
2023-12-22 09:46:11 +08:00
|
|
|
query: ecs.NewQuery(filter.Contains(component.UidType, component.DisconnectorType)),
|
2023-12-21 16:14:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
func (s *DisconnectorSystem) Update(w ecs.World) {
|
|
|
|
s.disconnectorTransPower(w)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 隔离开关传递电能
|
|
|
|
func (s *DisconnectorSystem) disconnectorTransPower(w ecs.World) {
|
|
|
|
wd := entity.GetWorldData(w)
|
|
|
|
s.query.Each(w, func(entry *ecs.Entry) {
|
|
|
|
breakerId := component.UidType.Get(entry).Id
|
|
|
|
closed := component.DisconnectorType.Get(entry).Closed
|
|
|
|
breakerModel := (wd.Repo.FindById(breakerId)).(*repository.Disconnector)
|
|
|
|
breakerPortA := breakerModel.PortA
|
|
|
|
breakerPortB := breakerModel.PortB
|
|
|
|
towPipePortsTransPower(wd, closed, breakerPortA, breakerPortB)
|
|
|
|
})
|
|
|
|
}
|