From 4b22cd1a4217ff4d358f276d77b4aab0ad6367da Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 26 Sep 2023 13:45:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9E=84=E5=BB=BAprotoReposi?= =?UTF-8?q?tory=20bug=EF=BC=9B=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=81=93=E5=B2=94=E7=8A=B6=E6=80=81=E7=9A=84=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entities/switch_entity.go | 21 +++++++++++++++++++++ repository/repository_manager.go | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/entities/switch_entity.go b/entities/switch_entity.go index f83c6d2..3b20f99 100644 --- a/entities/switch_entity.go +++ b/entities/switch_entity.go @@ -8,6 +8,14 @@ import ( "joylink.club/rtsssimulation/system" ) +type Position int + +const ( + SK Position = iota //四开(不会起名字) + D //定位 + F //反位 +) + // CreateSwitch2jzdj9Entity 双机zdj9 // 默认定位 func CreateSwitch2jzdj9Entity(w ecs.World, switchId string) *ecs.Entry { @@ -59,3 +67,16 @@ func TurnToReverse(worldId ecs.WorldId, turnoutId string) { state.YCJ = true state.FCJ = true } + +func GetState(worldId ecs.WorldId, turnoutId string) Position { + sim := simulation.FindSimulation(worldId) + turnoutEntry := system.FindEntityById(sim.World(), turnoutId) + state := system.Switch2jZdj9StateComponent.Get(turnoutEntry) + if state.ZDBJ { + return D + } else if state.ZFBJ { + return F + } else { + return SK + } +} diff --git a/repository/repository_manager.go b/repository/repository_manager.go index 6df99b3..8a4a9a1 100644 --- a/repository/repository_manager.go +++ b/repository/repository_manager.go @@ -259,7 +259,10 @@ func buildTurnoutRelationShip(source *proto.Repository, repo *Repository) error for _, group := range protoData.RelayGroups { var relays []*Relay for _, id := range group.RelayIds { - relays = append(relays, repo.relayMap[id]) + relay := repo.relayMap[id] + if relay != nil { + relays = append(relays, relay) + } } turnout.relayGroups = append(turnout.relayGroups, &RelayGroup{ code: group.Code,