namespace SpaceGame.Api.Ships.Contracts;

public sealed record ShipSkillProfileSnapshot(
  int Navigation,
  int Trade,
  int Mining,
  int Combat,
  int Construction);

public sealed record ShipOrderSnapshot(
  string Id,
  string Kind,
  string SourceKind,
  string SourceId,
  string Status,
  int Priority,
  bool InterruptCurrentPlan,
  DateTimeOffset CreatedAtUtc,
  string? Label,
  string? TargetEntityId,
  string? TargetSystemId,
  Vector3Dto? TargetPosition,
  string? SourceStationId,
  string? DestinationStationId,
  string? ItemId,
  string? NodeId,
  string? ConstructionSiteId,
  string? ModuleId,
  float WaitSeconds,
  float Radius,
  int? MaxSystemRange,
  bool KnownStationsOnly,
  string? FailureReason);

public sealed record ShipOrderTemplateSnapshot(
  string Kind,
  string? Label,
  string? TargetEntityId,
  string? TargetSystemId,
  Vector3Dto? TargetPosition,
  string? SourceStationId,
  string? DestinationStationId,
  string? ItemId,
  string? NodeId,
  string? ConstructionSiteId,
  string? ModuleId,
  float WaitSeconds,
  float Radius,
  int? MaxSystemRange,
  bool KnownStationsOnly);

public sealed record DefaultBehaviorSnapshot(
  string Kind,
  string? HomeSystemId,
  string? HomeStationId,
  string? AreaSystemId,
  string? TargetEntityId,
  string? ItemId,
  string? PreferredNodeId,
  string? PreferredConstructionSiteId,
  string? PreferredModuleId,
  Vector3Dto? TargetPosition,
  float WaitSeconds,
  float Radius,
  int MaxSystemRange,
  bool KnownStationsOnly,
  IReadOnlyList<Vector3Dto> PatrolPoints,
  int PatrolIndex,
  IReadOnlyList<ShipOrderTemplateSnapshot> RepeatOrders,
  int RepeatIndex);

public sealed record ShipAssignmentSnapshot(
  string CommanderId,
  string? ParentCommanderId,
  string Kind,
  string BehaviorKind,
  string Status,
  string? ObjectiveId,
  string? CampaignId,
  string? TheaterId,
  float Priority,
  string? HomeSystemId,
  string? HomeStationId,
  string? TargetSystemId,
  string? TargetEntityId,
  Vector3Dto? TargetPosition,
  string? ItemId,
  string? Notes,
  DateTimeOffset? UpdatedAtUtc);

public sealed record ShipSubTaskSnapshot(
  string Id,
  string Kind,
  string Status,
  string Summary,
  string? TargetEntityId,
  string? TargetSystemId,
  string? TargetNodeId,
  Vector3Dto? TargetPosition,
  string? ItemId,
  string? ModuleId,
  float Threshold,
  float Amount,
  float Progress,
  float ElapsedSeconds,
  float TotalSeconds,
  string? BlockingReason);

public sealed record ShipPlanStepSnapshot(
  string Id,
  string Kind,
  string Status,
  string Summary,
  string? BlockingReason,
  int CurrentSubTaskIndex,
  IReadOnlyList<ShipSubTaskSnapshot> SubTasks);

public sealed record ShipPlanSnapshot(
  string Id,
  string SourceKind,
  string SourceId,
  string Kind,
  string Status,
  string Summary,
  int CurrentStepIndex,
  DateTimeOffset CreatedAtUtc,
  DateTimeOffset UpdatedAtUtc,
  string? InterruptReason,
  string? FailureReason,
  IReadOnlyList<ShipPlanStepSnapshot> Steps);

public sealed record ShipSnapshot(
  string Id,
  string Name,
  string Purpose,
  string Type,
  string SystemId,
  Vector3Dto LocalPosition,
  Vector3Dto LocalVelocity,
  Vector3Dto TargetLocalPosition,
  string State,
  IReadOnlyList<ShipOrderSnapshot> OrderQueue,
  DefaultBehaviorSnapshot DefaultBehavior,
  ShipAssignmentSnapshot? Assignment,
  ShipSkillProfileSnapshot Skills,
  ShipPlanSnapshot? ActivePlan,
  string? CurrentStepId,
  IReadOnlyList<ShipSubTaskSnapshot> ActiveSubTasks,
  string ControlSourceKind,
  string? ControlSourceId,
  string? ControlReason,
  string? LastReplanReason,
  string? LastAccessFailureReason,
  string? CelestialId,
  string? DockedStationId,
  string? CommanderId,
  string? PolicySetId,
  float CargoCapacity,
  float TravelSpeed,
  string TravelSpeedUnit,
  IReadOnlyList<InventoryEntry> Inventory,
  string FactionId,
  float Health,
  IReadOnlyList<string> History,
  ShipSpatialStateSnapshot SpatialState);

public sealed record ShipDelta(
  string Id,
  string Name,
  string Purpose,
  string Type,
  string SystemId,
  Vector3Dto LocalPosition,
  Vector3Dto LocalVelocity,
  Vector3Dto TargetLocalPosition,
  string State,
  IReadOnlyList<ShipOrderSnapshot> OrderQueue,
  DefaultBehaviorSnapshot DefaultBehavior,
  ShipAssignmentSnapshot? Assignment,
  ShipSkillProfileSnapshot Skills,
  ShipPlanSnapshot? ActivePlan,
  string? CurrentStepId,
  IReadOnlyList<ShipSubTaskSnapshot> ActiveSubTasks,
  string ControlSourceKind,
  string? ControlSourceId,
  string? ControlReason,
  string? LastReplanReason,
  string? LastAccessFailureReason,
  string? CelestialId,
  string? DockedStationId,
  string? CommanderId,
  string? PolicySetId,
  float CargoCapacity,
  float TravelSpeed,
  string TravelSpeedUnit,
  IReadOnlyList<InventoryEntry> Inventory,
  string FactionId,
  float Health,
  IReadOnlyList<string> History,
  ShipSpatialStateSnapshot SpatialState);

public sealed record ShipSpatialStateSnapshot(
  string SpaceLayer,
  string CurrentSystemId,
  string? CurrentCelestialId,
  Vector3Dto? LocalPosition,
  Vector3Dto? SystemPosition,
  string MovementRegime,
  string? DestinationNodeId,
  ShipTransitSnapshot? Transit);

public sealed record ShipTransitSnapshot(
  string Regime,
  string? OriginNodeId,
  string? DestinationNodeId,
  DateTimeOffset? StartedAtUtc,
  DateTimeOffset? ArrivalDueAtUtc,
  float Progress);
