51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package memory
|
|
|
|
import (
|
|
"joylink.club/bj-rtsts-server/ts/protos/graphicData"
|
|
"joylink.club/bj-rtsts-server/ts/protos/state"
|
|
"joylink.club/rtsssimulation/component"
|
|
"joylink.club/rtsssimulation/entity"
|
|
)
|
|
|
|
// 获取所有的列车信息
|
|
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
|
|
}
|