【删除无用系统】
This commit is contained in:
parent
c166adfaa1
commit
f1897c75d8
@ -42,7 +42,7 @@ const (
|
||||
|
||||
// 占用状态
|
||||
type OccupiedStatus struct {
|
||||
Type OccupiedType
|
||||
Types []OccupiedType // 占用状态
|
||||
}
|
||||
|
||||
var OccupiedStatusType = ecs.NewComponentType[OccupiedStatus]() // 占用状态组件
|
||||
@ -69,9 +69,8 @@ var BlockadeStatusType = ecs.NewComponentType[BlockadeStatus]() // 封锁状态
|
||||
|
||||
// 解锁状态
|
||||
type UnLockStatus struct {
|
||||
Delay bool // 延迟状态
|
||||
DelayTime time.Duration // 延迟解锁时间
|
||||
TriggerDevice *ecs.Entry // 触发解锁设备
|
||||
Delay bool // 延迟状态
|
||||
DelayTime time.Duration // 延迟解锁时间
|
||||
}
|
||||
|
||||
var UnLockStatusType = ecs.NewComponentType[UnLockStatus]() // 解锁状态组件
|
||||
@ -118,6 +117,7 @@ type RouteStatus struct {
|
||||
AtsControl bool // ats自动控制
|
||||
Setting bool // 进路是否排列中
|
||||
Lock bool // 已锁闭
|
||||
Setable bool // 是否可排列
|
||||
}
|
||||
|
||||
var RouteStatusType = ecs.NewComponentType[RouteStatus]() // 进路状态组件
|
||||
@ -145,26 +145,7 @@ const (
|
||||
type DevicePosition struct {
|
||||
Device *ecs.Entry // 设备
|
||||
Offset int64 // 在设备上的相对a位置偏移
|
||||
Direction bool // 从a到b为true;从b到a为false
|
||||
Direction bool // 上下行
|
||||
}
|
||||
|
||||
var DevicePositionType = ecs.NewComponentType[DevicePosition]()
|
||||
|
||||
// 列车运行状态
|
||||
type TrainRunStatus struct {
|
||||
RunLevel TrainRunLevel // 列车运行级别
|
||||
DriveMode DriveMode // 驾驶模式
|
||||
Speed float32 // 运行速度
|
||||
SpeedMax float32 // 最大速度
|
||||
HeadPosition *DevicePosition // 车头位置
|
||||
TailPosition *DevicePosition // 车尾位置
|
||||
Hold bool // 扣车
|
||||
Skip bool // 跳停
|
||||
Park bool // 停靠
|
||||
}
|
||||
|
||||
var TrainRunStatusType = ecs.NewComponentType[TrainRunStatus]() // 列车位置状态组件
|
||||
|
||||
var (
|
||||
TrainSpeedMax float32 = 80 / 3.6
|
||||
)
|
||||
|
@ -1,59 +0,0 @@
|
||||
package cbtc_sys
|
||||
|
||||
import (
|
||||
"github.com/yohamta/donburi"
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
)
|
||||
|
||||
// 列车运行控制组件,给列车增加限制组件
|
||||
type TrainRunControlSys struct {
|
||||
trainQuery *ecs.Query
|
||||
}
|
||||
|
||||
func NewTrainRunControlSys() *TrainRunControlSys {
|
||||
return &TrainRunControlSys{
|
||||
trainQuery: ecs.NewQuery(filter.Contains(component.TrainRunStatusType)),
|
||||
}
|
||||
}
|
||||
|
||||
func (sls *TrainRunControlSys) Update(w ecs.World) {
|
||||
sls.trainQuery.Each(w, func(e *donburi.Entry) {
|
||||
runStatus := component.TrainRunStatusType.Get(e)
|
||||
headDevice := runStatus.HeadPosition.Device
|
||||
// 限速赋值
|
||||
if headDevice.HasComponent(component.SpeedLimitType) { // 车头所在设备有限速组件
|
||||
speedLimit := component.SpeedLimitType.Get(headDevice)
|
||||
runStatus.SpeedMax = speedLimit.Val
|
||||
} else {
|
||||
runStatus.SpeedMax = component.TrainSpeedMax
|
||||
}
|
||||
// 检测扣车、跳停
|
||||
worldData := entity.GetWorldData(w)
|
||||
uid := component.UidType.Get(headDevice)
|
||||
section := worldData.Repo.FindPhysicalSection(uid.Id)
|
||||
platform := section.Platform()
|
||||
if platform != nil { // 是站台轨
|
||||
pe := worldData.EntityMap[platform.Id()]
|
||||
// 扣车
|
||||
runStatus.Hold = pe.HasComponent(component.PlatformHoldStatusType)
|
||||
// 跳停
|
||||
skip := pe.HasComponent(component.PlatformSkipStatusType)
|
||||
if pe.HasComponent(component.PlatformSkipStatusType) {
|
||||
st := component.PlatformSkipStatusType.Get(pe)
|
||||
skip = st.AllSkip
|
||||
if !skip {
|
||||
for _, t := range st.Trains {
|
||||
if t.Id() == e.Id() {
|
||||
skip = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
runStatus.Skip = skip
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user