66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package fi
|
||
|
||
import (
|
||
"joylink.club/ecs"
|
||
"joylink.club/rtsssimulation/component"
|
||
"joylink.club/rtsssimulation/entity"
|
||
)
|
||
|
||
// signal 3xh1 接口:点灯操作、开通列车信号、开通引导信号、开通禁止信号
|
||
|
||
// DriveSignal3XH1Dd 点灯操作
|
||
// dd : true-物理点灯;false-物理灭灯
|
||
func DriveSignal3XH1Dd(w ecs.World, signalId string, dd bool) {
|
||
w.Execute(func() {
|
||
wd := entity.GetWorldData(w)
|
||
signalEntry, ok := wd.EntityMap[signalId]
|
||
if ok {
|
||
lsq := component.Signal3XH1LsqType.Get(signalEntry)
|
||
lsq.Z3XH1_DDJ_Q = !dd
|
||
}
|
||
})
|
||
}
|
||
|
||
// DriveSignal3XH1Lx 开通列车信号(直向通过则亮绿灯;侧向通过则亮黄灯)
|
||
// xz : true-直向通过,false-侧向通过
|
||
func DriveSignal3XH1Lx(w ecs.World, signalId string, zx bool) {
|
||
w.Execute(func() {
|
||
wd := entity.GetWorldData(w)
|
||
signalEntry, ok := wd.EntityMap[signalId]
|
||
if ok {
|
||
lsq := component.Signal3XH1LsqType.Get(signalEntry)
|
||
lsq.Z3XH1_LXJ_Q = true
|
||
lsq.Z3XH1_ZXJ_Q = zx
|
||
lsq.Z3XH1_YXJ_Q = false
|
||
}
|
||
})
|
||
}
|
||
|
||
// DriveSignal3XH1Yx 开通引导信号(红灯亮且黄灯亮)
|
||
func DriveSignal3XH1Yx(w ecs.World, signalId string) {
|
||
w.Execute(func() {
|
||
wd := entity.GetWorldData(w)
|
||
signalEntry, ok := wd.EntityMap[signalId]
|
||
if ok {
|
||
lsq := component.Signal3XH1LsqType.Get(signalEntry)
|
||
lsq.Z3XH1_LXJ_Q = false
|
||
lsq.Z3XH1_ZXJ_Q = false
|
||
lsq.Z3XH1_YXJ_Q = true
|
||
}
|
||
})
|
||
}
|
||
|
||
// DriveSignal3XH1Non 开通禁止信号(红灯亮)
|
||
func DriveSignal3XH1Non(w ecs.World, signalId string) {
|
||
w.Execute(func() {
|
||
wd := entity.GetWorldData(w)
|
||
signalEntry, ok := wd.EntityMap[signalId]
|
||
if ok {
|
||
lsq := component.Signal3XH1LsqType.Get(signalEntry)
|
||
lsq.Z3XH1_LXJ_Q = false
|
||
lsq.Z3XH1_ZXJ_Q = false
|
||
lsq.Z3XH1_YXJ_Q = false
|
||
}
|
||
})
|
||
}
|