rts-sim-module/fi/section.go
2023-10-24 13:20:35 +08:00

56 lines
1.5 KiB
Go

package fi
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// DriveAxleSectionTrainIn 测试:计轴区段中车轴进入
func DriveAxleSectionTrainIn(w ecs.World, axleSectionId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
sectionEntry, ok := wd.EntityMap[axleSectionId]
if ok {
rt := component.AxleSectionRuntimeType.Get(sectionEntry)
rt.UpdateCountAndPulse(1)
}
})
}
// DriveAxleSectionTrainOut 测试:计轴区段中车轴离开
func DriveAxleSectionTrainOut(w ecs.World, axleSectionId string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
sectionEntry, ok := wd.EntityMap[axleSectionId]
if ok {
rt := component.AxleSectionRuntimeType.Get(sectionEntry)
rt.UpdateCountAndPulse(0)
}
})
}
// DriveAxleSectionDrst 测试:设置计轴区段直接复位
func DriveAxleSectionDrst(w ecs.World, axleSectionId string, drst bool) {
w.Execute(func() {
wd := entity.GetWorldData(w)
sectionEntry, ok := wd.EntityMap[axleSectionId]
if ok {
device := component.AxleSectionDeviceType.Get(sectionEntry)
device.Drst = drst
}
})
}
// DriveAxleSectionPdrst 测试:设置计轴区段预复位
func DriveAxleSectionPdrst(w ecs.World, axleSectionId string, pdrst bool) {
w.Execute(func() {
wd := entity.GetWorldData(w)
sectionEntry, ok := wd.EntityMap[axleSectionId]
if ok {
device := component.AxleSectionDeviceType.Get(sectionEntry)
device.Pdrst = pdrst
}
})
}