添加获取对象实体方法
This commit is contained in:
parent
fb39939e3b
commit
33aca5ef48
@ -22,13 +22,20 @@ func LoadWorldData(w ecs.World, repo *repository.Repository) {
|
||||
})
|
||||
}
|
||||
|
||||
var query = ecs.NewQuery(filter.Contains(component.WorldDataType))
|
||||
var worldDataQuery = ecs.NewQuery(filter.Contains(component.WorldDataType))
|
||||
|
||||
// 获取世界数据
|
||||
func GetWorldData(w ecs.World) *component.WorldData {
|
||||
entry, ok := query.First(w)
|
||||
entry, ok := worldDataQuery.First(w)
|
||||
if ok {
|
||||
return component.WorldDataType.Get(entry)
|
||||
}
|
||||
panic("世界数据不存在")
|
||||
}
|
||||
|
||||
// 根据uid获取对象实体
|
||||
func GetEntityByUid(w ecs.World, uid string) (entry *ecs.Entry, ok bool) {
|
||||
wd := GetWorldData(w)
|
||||
entry, ok = wd.EntityMap[uid]
|
||||
return
|
||||
}
|
||||
|
@ -46,20 +46,20 @@ func driveTurnoutZzj(w ecs.World, id string, dc bool, on bool) {
|
||||
|
||||
// 驱动道岔转辙机定操启动
|
||||
func DriveTurnoutDCOn(w ecs.World, id string) {
|
||||
driveTurnoutZzj(w, id, true, true)
|
||||
driveTurnoutZzj(w, id, true /* dc */, true /* on */)
|
||||
}
|
||||
|
||||
// 驱动道岔转辙机定操停止
|
||||
func DriveTurnoutDCOff(w ecs.World, id string) {
|
||||
driveTurnoutZzj(w, id, true, false)
|
||||
driveTurnoutZzj(w, id, true /* dc */, false /* on */)
|
||||
}
|
||||
|
||||
// 驱动道岔转辙机反操启动
|
||||
func DriveTurnoutFCOn(w ecs.World, id string) {
|
||||
driveTurnoutZzj(w, id, false, true)
|
||||
driveTurnoutZzj(w, id, false /* dc */, true /* on */)
|
||||
}
|
||||
|
||||
// 驱动道岔转辙机反操停止
|
||||
func DriveTurnoutFCOff(w ecs.World, id string) {
|
||||
driveTurnoutZzj(w, id, false, false)
|
||||
driveTurnoutZzj(w, id, false /* dc */, false /* on */)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user