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 PhysicalSectionBaseComponentTypes = []ecs.IComponentType{component.UidType, component.PhysicalSectionTag, component.PhysicalSectionManagerType}
|
|
|
|
// LoadPhysicalSections 加载计轴区段
|
|
func LoadPhysicalSections(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(PhysicalSectionBaseComponentTypes...))
|
|
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.PhysicalSectionCircuit{GJ: gjEntry}
|
|
entry.AddComponent(component.PhysicalSectionCircuitType, unsafe.Pointer(circuit))
|
|
}
|
|
}
|
|
}
|
|
wd.EntityMap[section.Id()] = entry
|
|
}
|
|
}
|
|
return nil
|
|
}
|