72 lines
2.7 KiB
Go
72 lines
2.7 KiB
Go
package routers
|
||
|
||
import (
|
||
"context"
|
||
"sync"
|
||
)
|
||
|
||
var _ = sync.Mutex{}
|
||
var _ = context.Background
|
||
|
||
//
|
||
// 服务端自建「红绿灯相位」表 —— 给 GameRouter 的车流提供「这条车道的尽头是不是
|
||
// 一个路口、我是哪个进口道、现在放不放行」。
|
||
// ★ 为什么不用客户端那套(详见 PrivateServerConfig.TrafficSignalEnabled 的注释):
|
||
// 放行关系在客户端专属 blob 里,服务端够不着,只能自己算。
|
||
// ★ 相位模型对齐官方 MassIntersectionPeriodDetail:
|
||
// 一个相位 = 一段时长(PeriodTime)+ 一组放行的车道(VehicleLaneMetas)。
|
||
// 官方由服务端只发 CurrentPeriodIndex / NextPeriodIndex / RailPeriodIndex 三个 byte,
|
||
// 我们这里直接把「相位号 → 放行腿」这件事在服务端查表完成,省掉一次 S2C。
|
||
// 数据表(_gen_junctions.py 生成):
|
||
// data/junctions.csv = id;cx;cz;groupCount;legCount;laneCount
|
||
// data/junction_lanes.csv = laneHandle;junctionId;groupIndex
|
||
//
|
||
type JunctionSignals struct {
|
||
Cache Table `json:"cache"`
|
||
Available bool `json:"available"`
|
||
JunctionCount int32 `json:"junctionCount"`
|
||
LaneCount int32 `json:"laneCount"`
|
||
}
|
||
|
||
const (
|
||
JunctionSignals_JunctionRelativePath string = "Drmk.Server/Drmk.App/data/junctions.csv"
|
||
JunctionSignals_LaneRelativePath string = "Drmk.Server/Drmk.App/data/junction_lanes.csv"
|
||
)
|
||
|
||
func GameRouter_Junctions_TryGet(ctx context.Context, laneHandle int32, line any) bool {
|
||
// Router implementation for GameRouter_Junctions_TryGet
|
||
return true
|
||
}
|
||
|
||
//
|
||
// 现在这条进口道是不是绿灯。
|
||
// 周期 = 组数 × (绿灯 + 全红清空);组内前 greenSec 放行,其余为清空。
|
||
//
|
||
func GameRouter_Junctions_IsGreen(ctx context.Context, line any, nowMs int64, greenSec float32, clearSec float32) bool {
|
||
// Router implementation for GameRouter_Junctions_IsGreen
|
||
return true
|
||
}
|
||
|
||
// 距离下一次本组变绿还有多少毫秒(用于「别在红灯还剩 0.3 秒时刹停」的滞回)。
|
||
func GameRouter_Junctions_MsToNextGreen(ctx context.Context, line any, nowMs int64, greenSec float32, clearSec float32) int64 {
|
||
// Router implementation for GameRouter_Junctions_MsToNextGreen
|
||
return 0
|
||
}
|
||
|
||
func GameRouter_Junctions_Load(ctx context.Context, ) any {
|
||
// Router implementation for GameRouter_Junctions_Load
|
||
var zero any; return zero
|
||
}
|
||
|
||
type StopLine struct {
|
||
// 所属路口 id(仅用于日志/错峰)。
|
||
JunctionId int32 `json:"junctionId"`
|
||
// 本进口道所属的相位组序号。
|
||
GroupIndex byte `json:"groupIndex"`
|
||
// 该路口一共有几个相位组(轮转周期长度)。
|
||
GroupCount byte `json:"groupCount"`
|
||
// 该路口的错峰偏移(毫秒),避免全城同时翻灯。
|
||
OffsetMs int32 `json:"offsetMs"`
|
||
}
|
||
|