Refine ship orders and viewer controls
This commit is contained in:
@@ -201,8 +201,6 @@ internal sealed class SimulationProjectionService
|
||||
ship.DefaultBehavior,
|
||||
ship.Assignment,
|
||||
ship.Skills,
|
||||
ship.ActivePlan,
|
||||
ship.CurrentStepId,
|
||||
ship.ActiveSubTasks,
|
||||
ship.ControlSourceKind,
|
||||
ship.ControlSourceId,
|
||||
@@ -569,9 +567,6 @@ internal sealed class SimulationProjectionService
|
||||
ship.TargetPosition.Z.ToString("0.###"),
|
||||
ship.State.ToContractValue(),
|
||||
string.Join(",", ship.OrderQueue
|
||||
.OrderByDescending(GetOrderSourcePriority)
|
||||
.ThenByDescending(order => order.Priority)
|
||||
.ThenBy(order => order.CreatedAtUtc)
|
||||
.Select(order => $"{order.Id}:{order.Kind}:{order.SourceKind.ToContractValue()}:{order.SourceId}:{order.Status.ToContractValue()}:{order.Priority}:{order.TargetEntityId}:{order.TargetSystemId}:{order.ItemId}:{order.WaitSeconds:0.###}:{order.Radius:0.###}:{order.MaxSystemRange?.ToString(CultureInfo.InvariantCulture) ?? "none"}:{order.KnownStationsOnly}")),
|
||||
ship.DefaultBehavior.Kind,
|
||||
ship.DefaultBehavior.TargetEntityId ?? "none",
|
||||
@@ -595,9 +590,6 @@ internal sealed class SimulationProjectionService
|
||||
ship.CommanderId is not null && world.Commanders.FirstOrDefault(candidate => candidate.Id == ship.CommanderId)?.Assignment is { } assignment
|
||||
? $"{assignment.ObjectiveId}:{assignment.Kind}:{assignment.BehaviorKind}:{assignment.Status}:{assignment.CampaignId}:{assignment.TheaterId}:{assignment.TargetSystemId}:{assignment.TargetEntityId}:{assignment.ItemId}:{assignment.Priority:0.###}:{assignment.UpdatedAtUtc.UtcTicks}"
|
||||
: "no-assignment",
|
||||
ship.ActivePlan?.Kind ?? "none",
|
||||
ship.ActivePlan?.Status.ToContractValue() ?? "none",
|
||||
ship.ActivePlan?.CurrentStepIndex.ToString(CultureInfo.InvariantCulture) ?? "-1",
|
||||
string.Join(",",
|
||||
ToActiveSubTaskSnapshots(ship).Select(subTask =>
|
||||
$"{subTask.Id}:{subTask.Kind}:{subTask.Status}:{subTask.Progress:0.###}:{subTask.ElapsedSeconds:0.###}:{subTask.BlockingReason ?? "none"}")),
|
||||
@@ -620,7 +612,9 @@ internal sealed class SimulationProjectionService
|
||||
ship.Skills.Combat.ToString(CultureInfo.InvariantCulture),
|
||||
ship.Skills.Construction.ToString(CultureInfo.InvariantCulture),
|
||||
ship.Health.ToString("0.###"),
|
||||
GetCurrentShipStep(ship)?.Id ?? "none");
|
||||
ship.ActiveSubTaskIndex >= 0 && ship.ActiveSubTaskIndex < ship.ActiveSubTasks.Count
|
||||
? ship.ActiveSubTasks[ship.ActiveSubTaskIndex].Id
|
||||
: "none");
|
||||
|
||||
private static string BuildInventorySignature(IReadOnlyDictionary<string, float> inventory) =>
|
||||
string.Join(",",
|
||||
@@ -889,8 +883,6 @@ internal sealed class SimulationProjectionService
|
||||
ToDefaultBehaviorSnapshot(ship.DefaultBehavior),
|
||||
ToShipAssignmentSnapshot(commander),
|
||||
new ShipSkillProfileSnapshot(ship.Skills.Navigation, ship.Skills.Trade, ship.Skills.Mining, ship.Skills.Combat, ship.Skills.Construction),
|
||||
ToShipPlanSnapshot(ship.ActivePlan),
|
||||
GetCurrentShipStep(ship)?.Id,
|
||||
ToActiveSubTaskSnapshots(ship),
|
||||
ship.ControlSourceKind,
|
||||
ship.ControlSourceId,
|
||||
@@ -923,7 +915,7 @@ internal sealed class SimulationProjectionService
|
||||
{
|
||||
MovementRegimeKind.FtlTransit => (ship.State == ShipState.Ftl ? ship.Definition.FtlSpeed : 0f, "ly/s"),
|
||||
MovementRegimeKind.Warp => (ship.State == ShipState.Warping ? ship.Definition.WarpSpeed : 0f, "AU/s"),
|
||||
_ => (MathF.Sqrt(MathF.Max(0f, ship.Velocity.LengthSquared())) * SimulationUnits.MetersPerKilometer, "m/s"),
|
||||
_ => (MathF.Sqrt(MathF.Max(0f, ship.Velocity.LengthSquared())), "m/s"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -936,9 +928,6 @@ internal sealed class SimulationProjectionService
|
||||
|
||||
private static IReadOnlyList<ShipOrderSnapshot> ToShipOrderSnapshots(ShipRuntime ship) =>
|
||||
ship.OrderQueue
|
||||
.OrderByDescending(GetOrderSourcePriority)
|
||||
.ThenByDescending(order => order.Priority)
|
||||
.ThenBy(order => order.CreatedAtUtc)
|
||||
.Select(order => new ShipOrderSnapshot(
|
||||
order.Id,
|
||||
order.Kind,
|
||||
@@ -965,14 +954,6 @@ internal sealed class SimulationProjectionService
|
||||
order.FailureReason))
|
||||
.ToList();
|
||||
|
||||
private static int GetOrderSourcePriority(ShipOrderRuntime order) => order.SourceKind switch
|
||||
{
|
||||
ShipOrderSourceKind.Player => 300,
|
||||
ShipOrderSourceKind.Commander => 200,
|
||||
ShipOrderSourceKind.Behavior => 100,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
private static DefaultBehaviorSnapshot ToDefaultBehaviorSnapshot(DefaultBehaviorRuntime behavior) =>
|
||||
new(
|
||||
behavior.Kind,
|
||||
@@ -1039,38 +1020,6 @@ internal sealed class SimulationProjectionService
|
||||
assignment.UpdatedAtUtc);
|
||||
}
|
||||
|
||||
private static ShipPlanSnapshot? ToShipPlanSnapshot(ShipPlanRuntime? plan)
|
||||
{
|
||||
if (plan is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ShipPlanSnapshot(
|
||||
plan.Id,
|
||||
plan.SourceKind.ToContractValue(),
|
||||
plan.SourceId,
|
||||
plan.Kind,
|
||||
plan.Status.ToContractValue(),
|
||||
plan.Summary,
|
||||
plan.CurrentStepIndex,
|
||||
plan.CreatedAtUtc,
|
||||
plan.UpdatedAtUtc,
|
||||
plan.InterruptReason,
|
||||
plan.FailureReason,
|
||||
plan.Steps.Select(ToShipPlanStepSnapshot).ToList());
|
||||
}
|
||||
|
||||
private static ShipPlanStepSnapshot ToShipPlanStepSnapshot(ShipPlanStepRuntime step) =>
|
||||
new(
|
||||
step.Id,
|
||||
step.Kind,
|
||||
step.Status.ToContractValue(),
|
||||
step.Summary,
|
||||
step.BlockingReason,
|
||||
step.CurrentSubTaskIndex,
|
||||
step.SubTasks.Select(ToShipSubTaskSnapshot).ToList());
|
||||
|
||||
private static ShipSubTaskSnapshot ToShipSubTaskSnapshot(ShipSubTaskRuntime subTask) =>
|
||||
new(
|
||||
subTask.Id,
|
||||
@@ -1094,23 +1043,12 @@ internal sealed class SimulationProjectionService
|
||||
|
||||
private static IReadOnlyList<ShipSubTaskSnapshot> ToActiveSubTaskSnapshots(ShipRuntime ship)
|
||||
{
|
||||
var step = GetCurrentShipStep(ship);
|
||||
if (step is null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
return step.SubTasks
|
||||
return ship.ActiveSubTasks
|
||||
.Where(subTask => subTask.Status is WorkStatus.Pending or WorkStatus.Active or WorkStatus.Blocked)
|
||||
.Select(ToShipSubTaskSnapshot)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static ShipPlanStepRuntime? GetCurrentShipStep(ShipRuntime ship) =>
|
||||
ship.ActivePlan is null || ship.ActivePlan.CurrentStepIndex >= ship.ActivePlan.Steps.Count
|
||||
? null
|
||||
: ship.ActivePlan.Steps[ship.ActivePlan.CurrentStepIndex];
|
||||
|
||||
private static CommanderAssignmentSnapshot ToCommanderAssignmentSnapshot(CommanderRuntime commander)
|
||||
{
|
||||
var assignment = commander.Assignment;
|
||||
|
||||
Reference in New Issue
Block a user