33 lines
835 B
Go
33 lines
835 B
Go
package entity
|
|
|
|
import (
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/component"
|
|
)
|
|
|
|
func LoadStations(w ecs.World) error {
|
|
data := GetWorldData(w)
|
|
stations := data.Repo.StationList()
|
|
for _, station := range stations {
|
|
entry := NewStationEntity(w, station.Id(), data)
|
|
if station.GetIbpSpk() != nil { // 人员防护
|
|
LoadSPKEntity(w, entry, station.GetIbpSpk(), data)
|
|
}
|
|
if station.GetIbpEmp() != nil { // 紧急停车
|
|
LoadEMPEntity(w, entry, station.GetIbpEmp(), data)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// 新建车站实体
|
|
func NewStationEntity(w ecs.World, uid string, worldData *component.WorldData) *ecs.Entry {
|
|
entry, ok := worldData.EntityMap[uid]
|
|
if !ok {
|
|
entry = w.Entry(w.Create(component.UidType))
|
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
|
worldData.EntityMap[uid] = entry
|
|
}
|
|
return entry
|
|
}
|