XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
namespace XFEEDToolBox.Core.Navigation;

// Current GMRouteSettingsComponent: economical=0, fastest=1, boost=2.
public enum GameRoutePlotMode { Economical,Fastest,FsdBoost }

/// <summary>Explicit overrides for the original planner. Null preserves the current game value.</summary>
public sealed record GameRoutePlotOptions
{
    public GameRoutePlotMode? Mode {get;init;}
    public bool? UseJetConeBoost {get;init;}
    public int? FsdBoostLevel {get;init;}
    public double? VirtualCargoMass {get;init;}
    public GameRouteStarClassFilter? StarClassFilter {get;init;}
    public GameRouteMapFilter? MapFilter {get;init;}
    public bool HasOverrides=>Mode is not null||UseJetConeBoost is not null||FsdBoostLevel is not null||VirtualCargoMass is not null||StarClassFilter is not null||MapFilter is not null;
    public void Validate(int? cargoCapacity=null)
    {
        StarClassFilter?.Validate();
        MapFilter?.Validate();
        if(Mode is{} mode&&!Enum.IsDefined(mode))throw new ArgumentOutOfRangeException(nameof(Mode),"原航线模式无效。");
        if(FsdBoostLevel is <0 or >3)throw new ArgumentOutOfRangeException(nameof(FsdBoostLevel),"FSD 增益等级需为 0–3。");
        if(FsdBoostLevel is not null&&Mode is not GameRoutePlotMode.FsdBoost)
            throw new ArgumentException("选择 FSD 增益模式后才能设置增益等级。");
        if(VirtualCargoMass is{} mass&&(!double.IsFinite(mass)||mass is <0 or >2048))
            throw new ArgumentOutOfRangeException(nameof(VirtualCargoMass),"规划货重需为 0–2048 t。");
        if(VirtualCargoMass is{} selected&&cargoCapacity is{} maximum&&selected>Math.Max(0,maximum))
            throw new ArgumentOutOfRangeException(nameof(VirtualCargoMass),"规划货重超过当前飞船已确认的货舱容量。");
    }
}

public interface IGameRouteOptionsPlanningDriver:IGameRoutePlanningDriver
{
    bool SupportsGameRouteOptions {get;}
    bool SupportsRouteStarClassFilter=>false;
    bool SupportsRouteMapFilters=>false;
    Task<long> RequestGameRouteAsync(NavWaypoint destination,GameRoutePlotOptions options,CancellationToken token);
}