2023-10-19 17:09:57 +08:00
|
|
|
package memory
|
|
|
|
|
|
|
|
import (
|
2023-10-26 17:16:07 +08:00
|
|
|
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
|
|
|
"joylink.club/bj-rtsts-server/ts/protos/state"
|
2023-10-19 17:31:27 +08:00
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
"joylink.club/rtsssimulation/entity"
|
2023-10-19 17:09:57 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// 获取所有的列车信息
|
2023-10-19 17:31:27 +08:00
|
|
|
func GetMapAllPsdState(vs *VerifySimulation, mapId int32) []*state.PsdState {
|
|
|
|
world := vs.GetSimulationWorld()
|
|
|
|
uidStructure := queryUidStructure[*stationUidStructure](mapId)
|
|
|
|
data := QueryGiData[*graphicData.RtssGraphicStorage](mapId)
|
|
|
|
var psdStateArr []*state.PsdState
|
|
|
|
for _, door := range data.ScreenDoors {
|
|
|
|
uid := uidStructure.PsdIds[door.Common.Id].Uid
|
|
|
|
psdEntry, ok := entity.GetEntityByUid(world, uid)
|
|
|
|
if ok {
|
|
|
|
var amount int32
|
|
|
|
psdState := component.PsdStateType.Get(psdEntry)
|
|
|
|
if psdState.Km8 {
|
|
|
|
amount = 8
|
|
|
|
} else if psdState.Km4 {
|
|
|
|
amount = 4
|
|
|
|
} else {
|
|
|
|
amount = 0
|
|
|
|
}
|
|
|
|
start, end := getStartEndCodeByGroup(door, amount)
|
|
|
|
var openSubDoor []int32
|
|
|
|
for i := start; i <= end; i++ {
|
|
|
|
openSubDoor = append(openSubDoor, i)
|
|
|
|
}
|
|
|
|
psdStateArr = append(psdStateArr, &state.PsdState{
|
|
|
|
Id: door.Common.Id,
|
|
|
|
OpenDoorCodes: openSubDoor,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return psdStateArr
|
|
|
|
}
|
|
|
|
|
|
|
|
func getStartEndCodeByGroup(door *graphicData.ScreenDoor, groupAmount int32) (int32, int32) {
|
|
|
|
for _, group := range door.ScreenDoorGroupList {
|
|
|
|
if group.TrainGroupAmount == groupAmount {
|
|
|
|
return group.StartSmallDoor, group.EndSmallDoor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0, -1
|
2023-10-19 17:09:57 +08:00
|
|
|
}
|