using System.Text.Json;
namespace XFEEDToolBox.Core.Navigation;
public sealed partial class NativeSystemFlightControlDriver
{
public const string OriginalDockingService="SessionRecovery0514k";
public async Task<JsonElement> ArmOriginalPersistentThrottleTrialAsync(string trialId,SystemFlightFrame frame,CancellationToken token)
{
if(frame.Mode!=LocalFlightMode.Normal||frame.PlayerOverride||frame.ExternalThreat||selected is null
||frame.Clearance?.Allows(selected,DateTimeOffset.UtcNow)!=true||frame.TargetDistance is <4500 or >7200||frame.Speed>15
||player().CurrentShipId!=5||player().CargoCount!=0||player().CargoCapacity!=192)
throw new InvalidOperationException("Fixed .75 trial requires the empty selected main ship, low speed and original ATC grant.");
await pipe.CallAsync(new{op="local.axes.release",owner,generation},token);
return await OriginalFlightTrialAsync("flight.context.arm",trialId,frame,token);
}
private async Task<JsonElement> OriginalFlightTrialAsync(string op,string trialId,SystemFlightFrame? frame,CancellationToken token,bool preserve=false)
{
if(trialId.Length!=32||trialId.Any(c=>c is not(>='0' and <='9') and not(>='a' and <='f')))throw new ArgumentException("One immutable original trial ID required.");
var native=new NavigationPipeClient(processId,OriginalDockingService);
if(frame is null)return await native.CallAsync(new{op,requestId=trialId,owner,preserveOwnedSeedForReset=preserve},token);
var deadline=frame.ObservedAt.AddMilliseconds(250);var remaining=(int)Math.Floor((deadline-DateTimeOffset.UtcNow).TotalMilliseconds);
if(remaining is <1 or >250)throw new FlightTelemetryUnavailableException("Original Flight trial frame has expired.");
return await native.CallAsync(new{op,requestId=trialId,owner,purpose="after-grant-persistent075",selectionGeneration=generation,
sequence=frame.Sequence,ttlMilliseconds=remaining,expiresAtUnixMilliseconds=deadline.ToUnixTimeMilliseconds()},token);
}
public Task<JsonElement> ReadOriginalPersistentThrottleTrialAsync(string id,CancellationToken token)
=>OriginalFlightTrialAsync("flight.context.status",id,null,token);
public Task<JsonElement> RenewOriginalPersistentThrottleTrialAsync(string id,SystemFlightFrame frame,CancellationToken token)
=>OriginalFlightTrialAsync("flight.context.renew",id,frame,token);
public Task<JsonElement> SeedOriginalPersistentThrottleTrialAsync(string id,CancellationToken token)
=>OriginalFlightTrialAsync("flight.context.seed",id,null,token);
public Task<JsonElement> ReleaseOriginalPersistentThrottleTrialAsync(string id,bool preserveForReset,CancellationToken token)
=>OriginalFlightTrialAsync("flight.context.release",id,null,token,preserveForReset);
}
using System.Text.Json;
namespace XFEEDToolBox.Core.Navigation;
public sealed partial class NativeSystemFlightControlDriver
{
public const string OriginalDockingService="SessionRecovery0514k";
public async Task<JsonElement> ArmOriginalPersistentThrottleTrialAsync(string trialId,SystemFlightFrame frame,CancellationToken token)
{
if(frame.Mode!=LocalFlightMode.Normal||frame.PlayerOverride||frame.ExternalThreat||selected is null
||frame.Clearance?.Allows(selected,DateTimeOffset.UtcNow)!=true||frame.TargetDistance is <4500 or >7200||frame.Speed>15
||player().CurrentShipId!=5||player().CargoCount!=0||player().CargoCapacity!=192)
throw new InvalidOperationException("Fixed .75 trial requires the empty selected main ship, low speed and original ATC grant.");
await pipe.CallAsync(new{op="local.axes.release",owner,generation},token);
return await OriginalFlightTrialAsync("flight.context.arm",trialId,frame,token);
}
private async Task<JsonElement> OriginalFlightTrialAsync(string op,string trialId,SystemFlightFrame? frame,CancellationToken token,bool preserve=false)
{
if(trialId.Length!=32||trialId.Any(c=>c is not(>='0' and <='9') and not(>='a' and <='f')))throw new ArgumentException("One immutable original trial ID required.");
var native=new NavigationPipeClient(processId,OriginalDockingService);
if(frame is null)return await native.CallAsync(new{op,requestId=trialId,owner,preserveOwnedSeedForReset=preserve},token);
var deadline=frame.ObservedAt.AddMilliseconds(250);var remaining=(int)Math.Floor((deadline-DateTimeOffset.UtcNow).TotalMilliseconds);
if(remaining is <1 or >250)throw new FlightTelemetryUnavailableException("Original Flight trial frame has expired.");
return await native.CallAsync(new{op,requestId=trialId,owner,purpose="after-grant-persistent075",selectionGeneration=generation,
sequence=frame.Sequence,ttlMilliseconds=remaining,expiresAtUnixMilliseconds=deadline.ToUnixTimeMilliseconds()},token);
}
public Task<JsonElement> ReadOriginalPersistentThrottleTrialAsync(string id,CancellationToken token)
=>OriginalFlightTrialAsync("flight.context.status",id,null,token);
public Task<JsonElement> RenewOriginalPersistentThrottleTrialAsync(string id,SystemFlightFrame frame,CancellationToken token)
=>OriginalFlightTrialAsync("flight.context.renew",id,frame,token);
public Task<JsonElement> SeedOriginalPersistentThrottleTrialAsync(string id,CancellationToken token)
=>OriginalFlightTrialAsync("flight.context.seed",id,null,token);
public Task<JsonElement> ReleaseOriginalPersistentThrottleTrialAsync(string id,bool preserveForReset,CancellationToken token)
=>OriginalFlightTrialAsync("flight.context.release",id,null,token,preserveForReset);
}