38 lines
987 B
Go
38 lines
987 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 EarthingDeviceSystem struct {
|
|
query *ecs.Query
|
|
}
|
|
|
|
func NewEarthingDeviceSystem() *EarthingDeviceSystem {
|
|
return &EarthingDeviceSystem{
|
|
query: ecs.NewQuery(filter.Contains(component.UidType, component.EarthingDeviceType)),
|
|
}
|
|
}
|
|
|
|
// Update 接地装置传递异常电能
|
|
func (s *EarthingDeviceSystem) Update(w ecs.World) {
|
|
wd := entity.GetWorldData(w)
|
|
s.query.Each(w, func(entry *ecs.Entry) {
|
|
edId := component.UidType.Get(entry).Id
|
|
ed := component.EarthingDeviceType.Get(entry)
|
|
//
|
|
edModel := (wd.Repo.FindById(edId)).(*repository.EarthingDevice)
|
|
if edModel.PortA != nil {
|
|
edPipeEntry := wd.EntityMap[edModel.PortA.Device().Id()]
|
|
edPipe := component.PowerPipeType.Get(edPipeEntry)
|
|
ed.Voltage = edPipe.Voltage
|
|
} else {
|
|
ed.Voltage = 1 //零电压
|
|
}
|
|
})
|
|
}
|