计轴区段操作

This commit is contained in:
xzb 2023-10-24 10:19:50 +08:00
parent 3c65650745
commit e8cdb1c3c2

55
fi/section.go Normal file
View File

@ -0,0 +1,55 @@
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.Count = 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.Count = 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
}
})
}