2023-09-20 18:07:47 +08:00
|
|
|
package entities
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/yohamta/donburi"
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/system"
|
|
|
|
"joylink.club/rtsssimulation/umi"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CreateStationPsdsCircuitEntity 创建车站屏蔽门电路实体
|
|
|
|
func CreateStationPsdsCircuitEntity(w ecs.World, stationId string, psds []umi.IPsdModel) *ecs.Entry {
|
|
|
|
circuit := w.Create(system.EntityIdentityComponent, system.StationPsdsCircuitStateComponent, system.PsdTagHandlerComponent)
|
|
|
|
system.EntityIdentityComponent.Set(circuit, &system.EntityIdentity{Id: stationId})
|
|
|
|
system.StationPsdsCircuitStateComponent.Set(circuit, system.NewStationPsdsCircuitState())
|
|
|
|
system.PsdTagHandlerComponent.Set(circuit, system.NewPsdTagHandler())
|
|
|
|
tags := system.PsdTagHandlerComponent.Get(circuit)
|
|
|
|
//
|
|
|
|
for _, psd := range psds {
|
|
|
|
cc := make([]donburi.IComponentType, 6)
|
|
|
|
cc = append(cc, system.EntityIdentityComponent)
|
|
|
|
cc = append(cc, system.PsdStateComponent)
|
2023-09-21 15:22:22 +08:00
|
|
|
cc = append(cc, system.PercentageDeviceStateComponent)
|
2023-09-20 18:07:47 +08:00
|
|
|
if psd.IsS() {
|
|
|
|
cc = append(cc, tags.STag)
|
|
|
|
}
|
|
|
|
if psd.IsS4() {
|
|
|
|
cc = append(cc, tags.S4Tag)
|
|
|
|
}
|
|
|
|
if psd.IsS8() {
|
|
|
|
cc = append(cc, tags.S8Tag)
|
|
|
|
}
|
|
|
|
if psd.IsX() {
|
|
|
|
cc = append(cc, tags.XTag)
|
|
|
|
}
|
|
|
|
if psd.IsX4() {
|
|
|
|
cc = append(cc, tags.X4Tag)
|
|
|
|
}
|
|
|
|
if psd.IsX8() {
|
|
|
|
cc = append(cc, tags.X8Tag)
|
|
|
|
}
|
|
|
|
psdEntry := w.Create(cc...)
|
|
|
|
//
|
|
|
|
psdId := psd.(umi.IDeviceModel).GetId()
|
|
|
|
system.EntityIdentityComponent.Set(psdEntry, &system.EntityIdentity{Id: psdId})
|
|
|
|
system.PsdStateComponent.Set(psdEntry, system.NewPsdState())
|
2023-09-21 15:22:22 +08:00
|
|
|
system.PercentageDeviceStateComponent.Set(psdEntry, system.NewPercentageDeviceStateL())
|
2023-09-20 18:07:47 +08:00
|
|
|
}
|
|
|
|
//
|
|
|
|
return circuit
|
|
|
|
}
|