rts-sim-module/fi/signal_2xh1.go
2023-10-12 10:07:40 +08:00

47 lines
1.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package fi
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// signal 2xh1 接口:点灯操作、开通列车信号、开通禁止信号
// DriveSignal2XH1Dd 点灯操作
// dd : true-物理点灯false-物理灭灯
func DriveSignal2XH1Dd(w ecs.World, signalId string, dd bool) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
lsq := component.Signal2XH1LsqType.Get(signalEntry)
lsq.Z2XH1_DDJ_Q = !dd
}
})
}
// DriveSignal2XH1Lx 开通列车信号(绿灯亮)
func DriveSignal2XH1Lx(w ecs.World, signalId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
lsq := component.Signal2XH1LsqType.Get(signalEntry)
lsq.Z2XH1_LXJ_Q = true
}
})
}
// DriveSignal2XH1Non 开通禁止信号(红灯亮)
func DriveSignal2XH1Non(w ecs.World, signalId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
signalEntry, ok := wd.EntityMap[signalId]
if ok {
lsq := component.Signal2XH1LsqType.Get(signalEntry)
lsq.Z2XH1_LXJ_Q = false
}
})
}