This commit is contained in:
xzb 2023-09-27 13:18:58 +08:00
commit e7228ec0ff

View File

@ -12,6 +12,12 @@ import (
type Position int
type TurnoutState struct {
Normal bool
Reverse bool
Turning bool
}
const (
SK Position = iota //四开(不会起名字)
D //定位
@ -70,22 +76,20 @@ func TurnToReverse(worldId ecs.WorldId, turnoutId string) {
}()
}
func GetState(worldId ecs.WorldId, turnoutId string) Position {
func GetState(worldId ecs.WorldId, turnoutId string) *TurnoutState {
sim := simulation.FindSimulation(worldId)
query := ecs.NewQuery(filter.Contains(system.EntityIdentityComponent, system.Switch2jZdj9StateComponent))
var position Position
var turnoutState *TurnoutState
// 查找道岔位置
query.Each(sim.World(), func(e *ecs.Entry) {
if turnoutId == system.EntityIdentityComponent.Get(e).Id {
state := system.Switch2jZdj9StateComponent.Get(e)
if state.J1_DB_K9 {
position = D
} else if state.J1_FB_K10 {
position = F
} else {
position = SK
turnoutState = &TurnoutState{
Normal: state.IsNormal(),
Reverse: state.IsReverse(),
Turning: state.IsTurning(),
}
}
})
return position
return turnoutState
}