package iscs_sys import ( "joylink.club/ecs" "joylink.club/ecs/filter" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/entity" "joylink.club/rtsssimulation/repository" ) type LightningArresterSystem struct { query *ecs.Query } func NewLightningArresterSystem() *LightningArresterSystem { return &LightningArresterSystem{ query: ecs.NewQuery(filter.Contains(component.UidType, component.LightningArresterType)), } } func (s *LightningArresterSystem) Update(w ecs.World) { wd := entity.GetWorldData(w) s.query.Each(w, func(entry *ecs.Entry) { s.lightningArresterTransPower(wd, entry) }) } // 避雷器传递电能 func (s *LightningArresterSystem) lightningArresterTransPower(wd *component.WorldData, entry *ecs.Entry) { arresterId := component.UidType.Get(entry).Id closed := true arresterModel := (wd.Repo.FindById(arresterId)).(*repository.LightningArrester) //避雷器A端连接的管线 arresterPortA := arresterModel.PortA //避雷器B端连接的管线 arresterPortB := arresterModel.PortB //传递电能 towPipePortsTransPower(wd, closed, arresterPortA, arresterPortB) }