rts-sim-module/entity/train.go

25 lines
857 B
Go
Raw Normal View History

2023-11-09 14:59:18 +08:00
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
}
2023-11-23 15:12:16 +08:00
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{})
2023-11-29 13:03:59 +08:00
component.TrainBtmType.Set(te, component.NewTrainBtm())
2023-11-23 15:12:16 +08:00
data.EntityMap[trainId] = te
return te
}