36 lines
998 B
Go
36 lines
998 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 DisconnectorSystem struct {
|
|
query *ecs.Query
|
|
}
|
|
|
|
func NewDisconnectorSystem() *DisconnectorSystem {
|
|
return &DisconnectorSystem{
|
|
query: ecs.NewQuery(filter.Contains(component.UidType, component.DisconnectorType)),
|
|
}
|
|
}
|
|
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)
|
|
})
|
|
}
|