rts-sim-module/fi/signal_2xh1.go

47 lines
1.1 KiB
Go
Raw Normal View History

2023-10-09 14:19:57 +08:00
package fi
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
2023-10-09 16:22:29 +08:00
// signal 2xh1 接口:点灯操作、开通列车信号、开通禁止信号
2023-10-09 14:19:57 +08:00
2023-10-09 17:58:29 +08:00
// DriveSignal2XH1Dd 点灯操作
2023-10-09 15:13:24 +08:00
// dd : true-物理点灯false-物理灭灯
2023-10-09 17:58:29 +08:00
func DriveSignal2XH1Dd(w ecs.World, signalId string, dd bool) {
2023-10-09 14:19:57 +08:00
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
2023-10-12 10:07:40 +08:00
lsq := component.Signal2XH1LsqType.Get(signalEntry)
lsq.Z2XH1_DDJ_Q = !dd
2023-10-09 14:19:57 +08:00
}
})
}
2023-10-09 17:58:29 +08:00
// DriveSignal2XH1Lx 开通列车信号(绿灯亮)
func DriveSignal2XH1Lx(w ecs.World, signalId string) {
2023-10-09 14:19:57 +08:00
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
2023-10-12 10:07:40 +08:00
lsq := component.Signal2XH1LsqType.Get(signalEntry)
lsq.Z2XH1_LXJ_Q = true
2023-10-09 15:13:24 +08:00
}
})
}
2023-10-09 17:58:29 +08:00
// DriveSignal2XH1Non 开通禁止信号(红灯亮)
func DriveSignal2XH1Non(w ecs.World, signalId string) {
2023-10-09 15:13:24 +08:00
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
2023-10-12 10:07:40 +08:00
lsq := component.Signal2XH1LsqType.Get(signalEntry)
lsq.Z2XH1_LXJ_Q = false
2023-10-09 14:19:57 +08:00
}
})
}