51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
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)
|
|
cc = append(cc, system.PercentageDeviceStateComponent)
|
|
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())
|
|
system.PercentageDeviceStateComponent.Set(psdEntry, system.NewPercentageDeviceStateL())
|
|
}
|
|
//
|
|
return circuit
|
|
}
|