2023-10-31 11:30:17 +08:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
"joylink.club/rtsssimulation/repository"
|
2024-06-21 15:53:16 +08:00
|
|
|
"unsafe"
|
2023-10-31 11:30:17 +08:00
|
|
|
)
|
|
|
|
|
2024-07-31 17:08:53 +08:00
|
|
|
var AxleSectionBaseComponentTypes = []ecs.IComponentType{component.UidType, component.AxleSectionTag, component.AxleManagerType}
|
2023-11-06 14:35:32 +08:00
|
|
|
|
2023-10-31 15:55:16 +08:00
|
|
|
// LoadAxlePhysicalSections 加载计轴区段
|
|
|
|
func LoadAxlePhysicalSections(w ecs.World) error {
|
2024-07-31 17:08:53 +08:00
|
|
|
wd := GetWorldData(w)
|
|
|
|
sections := wd.Repo.PhysicalSectionList()
|
2023-10-31 15:55:16 +08:00
|
|
|
for _, section := range sections {
|
2024-07-31 17:08:53 +08:00
|
|
|
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))
|
|
|
|
}
|
2024-06-21 15:53:16 +08:00
|
|
|
}
|
|
|
|
}
|
2024-07-31 17:08:53 +08:00
|
|
|
wd.EntityMap[section.Id()] = entry
|
2024-06-21 15:53:16 +08:00
|
|
|
}
|
2023-10-31 11:30:17 +08:00
|
|
|
}
|
2024-07-31 17:08:53 +08:00
|
|
|
return nil
|
2023-10-31 11:30:17 +08:00
|
|
|
}
|