25 lines
855 B
Go
25 lines
855 B
Go
package entity
|
|
|
|
import (
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/component"
|
|
)
|
|
|
|
func NewTrainEntity(w ecs.World, trainId string) *ecs.Entry {
|
|
data := GetWorldData(w)
|
|
te := w.Entry(w.Create(component.UidType, component.TrainPositionInfoType))
|
|
component.UidType.SetValue(te, component.Uid{Id: trainId})
|
|
component.TrainPositionInfoType.Set(te, &component.TrainPositionInfo{})
|
|
data.EntityMap[trainId] = te
|
|
return te
|
|
}
|
|
func NewTrainWithBtmEntity(w ecs.World, trainId string) *ecs.Entry {
|
|
data := GetWorldData(w)
|
|
te := w.Entry(w.Create(component.UidType, component.TrainPositionInfoType, component.TrainBtmType))
|
|
component.UidType.SetValue(te, component.Uid{Id: trainId})
|
|
component.TrainPositionInfoType.Set(te, &component.TrainPositionInfo{})
|
|
component.TrainBtmType.Set(te, &component.TrainBtm{})
|
|
data.EntityMap[trainId] = te
|
|
return te
|
|
}
|