rts-sim-testing-service/ts/simulation/wayside/memory/wayside_memory_station.go
2023-10-26 17:16:07 +08:00

38 lines
1.1 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"
"joylink.club/rtsssimulation/fi"
)
// 操作IBP按钮
func ChangeEsbButtonState(sim *VerifySimulation, mapId int32, btnId string, pressDown bool) {
uid := QueryUidByMidAndComId(mapId, btnId, &graphicData.EsbButton{})
if pressDown {
fi.PressDownButton(sim.World, uid)
} else {
fi.PressUpButton(sim.World, uid)
}
}
// 获取仿真车站按钮状态,前端推送
func GetMapAllStationButtonState(sim *VerifySimulation, mapId int32) []*state.ButtonState {
// 获取地图上的按钮状态
var btnStateArr []*state.ButtonState
uidMap := QueryMapUidMapByType(mapId, &graphicData.EsbButton{})
for _, u := range uidMap {
entry, ok := entity.GetEntityByUid(sim.World, u.Uid)
if !ok {
continue
}
if entry.HasComponent(component.ButtonTag) { // 按钮
bit := component.BitStateType.Get(entry)
btnStateArr = append(btnStateArr, &state.ButtonState{Id: u.CommonId, Down: bit.Val})
}
}
return btnStateArr
}