56 lines
1.9 KiB
Go
56 lines
1.9 KiB
Go
package routers
|
||
|
||
import (
|
||
"context"
|
||
"sync"
|
||
)
|
||
|
||
var _ = sync.Mutex{}
|
||
var _ = context.Background
|
||
|
||
//
|
||
// 普通自动驾驶巡航速度的独立设置(2026-09-30)。
|
||
// ★★ 为什么单独一个 JSON 而不写进 private-server.json:
|
||
// ① GM 面板的 /api/settings 是整份回写,两个写者容易互相覆盖;
|
||
// ② 主配置改完要走 /api/reload-config,而调速希望「保存即可用」;
|
||
// ③ 回滚只要删这一个文件,不动任何别的开关。
|
||
// ⇒ 本类绝不改写 private-server.json。
|
||
// 单位:对外(GM / JSON)统一 km/h;服务端下发的 Cruise 参数是 m/s,
|
||
// 换算在 GameRouter.VehicleNav.cs 的 EffectiveCruiseSpeedMs 里做,别在这里除。
|
||
// 默认 43.2 km/h = 12 m/s,与 gameplay.vehicleNavigation.cruiseSpeed 的默认值一致。
|
||
//
|
||
type AutonomousDriveSpeedSettings struct {
|
||
Gate any `json:"gate"`
|
||
FilePath string `json:"filePath"`
|
||
}
|
||
|
||
const (
|
||
AutonomousDriveSpeedSettings_DefaultKmh float32 = 43.2
|
||
AutonomousDriveSpeedSettings_MinKmh float32 = 10
|
||
AutonomousDriveSpeedSettings_MaxKmh float32 = 120
|
||
)
|
||
|
||
func AutonomousDriveSpeedSettings_Valid(ctx context.Context, kmh float32) bool {
|
||
// Router implementation for AutonomousDriveSpeedSettings_Valid
|
||
return true
|
||
}
|
||
|
||
// 读取当前速度(km/h)。文件不存在 = 用默认值。
|
||
func AutonomousDriveSpeedSettings_Read(ctx context.Context, ) float32 {
|
||
// Router implementation for AutonomousDriveSpeedSettings_Read
|
||
return 0
|
||
}
|
||
|
||
// 保存速度(km/h),原子写(临时文件 + move),返回实际落盘值。
|
||
func AutonomousDriveSpeedSettings_Save(ctx context.Context, kmh float32) float32 {
|
||
// Router implementation for AutonomousDriveSpeedSettings_Save
|
||
return 0
|
||
}
|
||
|
||
// ⛑ 用最朴素的可序列化形状(internal 类 + public 无参构造 + 可写属性),
|
||
// 不用私有嵌套 record:后者要靠参数化构造绑定,出了问题是运行时才炸。
|
||
type Settings struct {
|
||
SpeedKmh float32 `json:"speedKmh"`
|
||
}
|
||
|