35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package entity
|
|
|
|
import (
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/component"
|
|
"joylink.club/rtsssimulation/repository"
|
|
"unsafe"
|
|
)
|
|
|
|
var AxleSectionBaseComponentTypes = []ecs.IComponentType{component.UidType, component.AxleSectionTag, component.AxleManagerType}
|
|
|
|
// LoadAxlePhysicalSections 加载计轴区段
|
|
func LoadAxlePhysicalSections(w ecs.World) error {
|
|
wd := GetWorldData(w)
|
|
sections := wd.Repo.PhysicalSectionList()
|
|
for _, section := range sections {
|
|
if is, err := section.IsAxleSection(); err == nil && is {
|
|
entry := w.Entry(w.Create(AxleSectionBaseComponentTypes...))
|
|
component.UidType.SetValue(entry, component.Uid{Id: section.Id()})
|
|
for _, group := range section.ComponentGroups() {
|
|
for _, ec := range group.Components() {
|
|
if ec.Code() == "GJ" {
|
|
relay := ec.(*repository.Relay)
|
|
gjEntry := NewRelayEntity(w, relay, wd.EntityMap)
|
|
circuit := &component.AxleSectionCircuit{GJ: gjEntry}
|
|
entry.AddComponent(component.AxleSectionCircuitType, unsafe.Pointer(circuit))
|
|
}
|
|
}
|
|
}
|
|
wd.EntityMap[section.Id()] = entry
|
|
}
|
|
}
|
|
return nil
|
|
}
|