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

XFEEDToolBox

【WinUI】XFE精英危险工具箱

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

/// <summary>
/// Destinations whose complete arrival contract is available to the interactive
/// system map. Basic flight capability alone does not prove a safe endpoint.
/// This does not change the lower-level control/research capability contract.
/// </summary>
public static class SystemDestinationPolicy
{
    public static string? UnsupportedReason(CurrentSystemSnapshot snapshot,SystemLocation location,SystemNavigationCapabilities capabilities,NavigationAssists assists)
    {
        if(snapshot.DisplayOnly)return "公开目录仅供浏览;到达星系后须重新读取游戏中的目标身份与坐标。";
        if(snapshot.SystemAddress<=0||location.WorldAddress==0||NativeFrameProjector.SystemAddressFromBody(location.WorldAddress)!=snapshot.SystemAddress
            ||location.Key<0||location.NativeKind<=0||string.IsNullOrWhiteSpace(location.Name)||location.Identity.Length!=64||!location.Identity.All(Uri.IsHexDigit))
            return "地点缺少当前游戏目录中的完整身份,暂不能自动前往。";
        var current=snapshot.Locations.FirstOrDefault(value=>value.Key==location.Key&&value.WorldAddress==location.WorldAddress&&value.NativeKind==location.NativeKind
            &&value.Category==location.Category&&value.MarketId==location.MarketId&&value.Identity==location.Identity&&value.Name==location.Name);
        if(current is null)return "地点身份已变化,请在最新目录中重新选择。";
        if(location.Position is not {Finite:true}||current.Position is not {Finite:true})return "地点坐标尚未确认,暂不能自动前往。";
        if(location.Category is not (SystemLocationCategory.Station or SystemLocationCategory.Carrier))
            return location.Category switch
            {
                SystemLocationCategory.Star=>"恒星的安全抵达终点尚未验证,暂不能自动前往。",
                SystemLocationCategory.Planet or SystemLocationCategory.LandablePlanet=>"行星与卫星的安全抵达终点尚未验证,暂不能自动前往。",
                SystemLocationCategory.Asteroid=>"小行星带的安全退出与抵达终点尚未验证,暂不能自动前往。",
                SystemLocationCategory.Settlement=>"地表进近与安全抵达尚未验证,暂不能自动前往据点。",
                SystemLocationCategory.Signal=>"信号源的安全退出与抵达终点尚未验证,暂不能自动前往。",
                SystemLocationCategory.PointOfInterest=>"兴趣点的安全退出与抵达终点尚未验证,暂不能自动前往。",
                _=>"此类地点的安全抵达终点尚未验证,暂不能自动前往。"
            };
        if(location.MarketId is not >0)return "停靠目标缺少已确认的空间站编号,暂不能自动前往。";
        if(!capabilities.TelemetryReady)return capabilities.TelemetryIssue??"等待最新飞船姿态与热量遥测,暂不能启动驾驶。";
        var target=new SystemNavigationTarget(snapshot.SystemAddress,location.WorldAddress,location.Name,SystemTargetKind.Station,location.MarketId)
            {NativeKey=location.Key,NativeKind=location.NativeKind,NativeIdentity=location.Identity};
        if(capabilities.UnsupportedReason(target,assists) is {} reason)return reason;
        if(assists.AutoDock&&!capabilities.OriginalDockingConfigured)return "原游戏独立停靠扩展尚未连接,暂不能自动前往并停靠。";
        return null;
    }
}