rts-sim-module/fi/signal_3xh4.go

50 lines
1.3 KiB
Go
Raw Permalink Normal View History

2023-10-09 16:42:16 +08:00
package fi
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// signal 3xh4 接口:点灯操作、开通列车信号、开通禁止信号
2023-10-09 17:58:29 +08:00
// DriveSignal3XH4Dd 点灯操作
2023-10-09 16:42:16 +08:00
// dd : true-物理点灯false-物理灭灯
2023-10-09 17:58:29 +08:00
func DriveSignal3XH4Dd(w ecs.World, signalId string, dd bool) {
2023-10-09 16:42:16 +08:00
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
2023-10-12 16:13:56 +08:00
lsq := component.Signal3XH4LsqType.Get(signalEntry)
lsq.Z3XH4_DDJ_Q = !dd
2023-10-09 16:42:16 +08:00
}
})
}
2023-10-09 17:58:29 +08:00
// DriveSignal3XH4Lx 开通列车信号(直向通过亮绿灯,侧向通过亮黄灯)
2023-10-09 16:42:16 +08:00
// zx : true-直向通过false-侧向通过
2023-10-09 17:58:29 +08:00
func DriveSignal3XH4Lx(w ecs.World, signalId string, zx bool) {
2023-10-09 16:42:16 +08:00
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
2023-10-12 16:13:56 +08:00
lsq := component.Signal3XH4LsqType.Get(signalEntry)
lsq.Z3XH4_LXJ_Q = true
lsq.Z3XH4_ZXJ_Q = zx
2023-10-09 16:42:16 +08:00
}
})
}
2023-10-09 17:58:29 +08:00
// DriveSignal3XH4Non 开通禁止信号(亮红灯)
func DriveSignal3XH4Non(w ecs.World, signalId string) {
2023-10-09 16:42:16 +08:00
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
2023-10-12 16:13:56 +08:00
lsq := component.Signal3XH4LsqType.Get(signalEntry)
lsq.Z3XH4_LXJ_Q = false
lsq.Z3XH4_ZXJ_Q = false
2023-10-09 16:42:16 +08:00
}
})
}