39 lines
986 B
Go
39 lines
986 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 := perfectPipeElectricity(edPipeEntry)
|
|
ed.Voltage = edPipe.U
|
|
} else {
|
|
ed.Voltage = 0 //零电压
|
|
}
|
|
})
|
|
}
|