rts-sim-module/fi/section.go

56 lines
1.5 KiB
Go
Raw Normal View History

2023-10-24 10:19:50 +08:00
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)
2023-10-24 13:20:35 +08:00
rt.UpdateCountAndPulse(1)
2023-10-24 10:19:50 +08:00
}
})
}
// 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)
2023-10-24 13:20:35 +08:00
rt.UpdateCountAndPulse(0)
2023-10-24 10:19:50 +08:00
}
})
}
// 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
}
})
}