namespace SpaceGame.Api.Factions.Runtime; public sealed class FactionRuntime { public required string Id { get; init; } public required string Label { get; init; } public required string Color { get; init; } public float Credits { get; set; } public float PopulationTotal { get; set; } public float OreMined { get; set; } public float GoodsProduced { get; set; } public int ShipsBuilt { get; set; } public int ShipsLost { get; set; } public HashSet CommanderIds { get; } = new(StringComparer.Ordinal); public string? DefaultPolicySetId { get; set; } public string LastDeltaSignature { get; set; } = string.Empty; } public sealed class CommanderRuntime { public required string Id { get; init; } public required string Kind { get; set; } public required string FactionId { get; init; } public string? ParentCommanderId { get; set; } public string? ControlledEntityId { get; set; } public string? PolicySetId { get; set; } public string? Doctrine { get; set; } public List Goals { get; } = []; public string? ActiveGoalName { get; set; } public string? ActiveActionName { get; set; } public float ReplanTimer { get; set; } public bool NeedsReplan { get; set; } = true; public CommanderBehaviorRuntime? ActiveBehavior { get; set; } public CommanderOrderRuntime? ActiveOrder { get; set; } public CommanderTaskRuntime? ActiveTask { get; set; } public HashSet SubordinateCommanderIds { get; } = new(StringComparer.Ordinal); public bool IsAlive { get; set; } = true; public FactionPlanningState? LastStrategicAssessment { get; set; } public IReadOnlyList<(string Name, float Priority)>? LastStrategicPriorities { get; set; } public FactionBlackboardRuntime? FactionBlackboard { get; set; } public List Objectives { get; } = []; public List IssuedTasks { get; } = []; public int PlanningCycle { get; set; } } public enum FactionObjectiveKind { DestroyFaction, BootstrapWarIndustry, BuildShipyard, BuildAttackFleet, EnsureCommoditySupply, EnsureWaterSecurity, EnsureMiningCapacity, EnsureConstructionCapacity, EnsureTransportCapacity, } public enum FactionObjectiveState { Planned, Active, Blocked, Complete, Failed, Cancelled, } public enum FactionPlanStepKind { EnsureCommodityProduction, EnsureShipyardSite, ProduceFleet, AttackFactionAssets, EnsureWaterSupply, EnsureMiningCapacity, EnsureConstructionCapacity, EnsureTransportCapacity, MonitorExpansionProject, } public enum FactionPlanStepStatus { Planned, Ready, Running, Blocked, Complete, Failed, Cancelled, } public enum FactionIssuedTaskKind { ExpandIndustry, ProduceShips, AttackFactionAssets, SustainWarIndustry, } public enum FactionIssuedTaskState { Planned, Active, Blocked, Complete, Cancelled, } public sealed class FactionObjectiveRuntime { public required string Id { get; init; } public required string MergeKey { get; init; } public required FactionObjectiveKind Kind { get; init; } public FactionObjectiveState State { get; set; } = FactionObjectiveState.Planned; public float Priority { get; set; } public string? ParentObjectiveId { get; set; } public string? TargetFactionId { get; set; } public string? TargetSystemId { get; set; } public string? TargetSiteId { get; set; } public string? TargetRegionId { get; set; } public string? CommodityId { get; set; } public string? ModuleId { get; set; } public int BudgetWeight { get; set; } public int SlotCost { get; set; } = 1; public int CreatedAtCycle { get; init; } public int UpdatedAtCycle { get; set; } public string? InvalidationReason { get; set; } public string? BlockingReason { get; set; } public HashSet PrerequisiteObjectiveIds { get; } = new(StringComparer.Ordinal); public HashSet AssignedAssetIds { get; } = new(StringComparer.Ordinal); public List Steps { get; } = []; } public sealed class FactionPlanStepRuntime { public required string Id { get; init; } public required string ObjectiveId { get; init; } public required FactionPlanStepKind Kind { get; init; } public FactionPlanStepStatus Status { get; set; } = FactionPlanStepStatus.Planned; public float Priority { get; set; } public string? CommodityId { get; set; } public string? ModuleId { get; set; } public string? TargetFactionId { get; set; } public string? TargetSiteId { get; set; } public string? StatusReason { get; set; } public string? ExecutionBindingKind { get; set; } public string? ExecutionBindingTargetId { get; set; } public string? ExecutionBindingSummary { get; set; } public string? BlockingReason { get; set; } public string? Notes { get; set; } public int LastEvaluatedCycle { get; set; } public HashSet DependencyStepIds { get; } = new(StringComparer.Ordinal); public HashSet RequiredFacts { get; } = new(StringComparer.Ordinal); public HashSet ProducedFacts { get; } = new(StringComparer.Ordinal); public HashSet AssignedAssetIds { get; } = new(StringComparer.Ordinal); public HashSet IssuedTaskIds { get; } = new(StringComparer.Ordinal); } public sealed class FactionIssuedTaskRuntime { public required string Id { get; init; } public required string MergeKey { get; init; } public required FactionIssuedTaskKind Kind { get; init; } public required string ObjectiveId { get; init; } public required string StepId { get; init; } public FactionIssuedTaskState State { get; set; } = FactionIssuedTaskState.Planned; public float Priority { get; set; } public string? ShipRole { get; set; } public string? CommodityId { get; set; } public string? ModuleId { get; set; } public string? TargetFactionId { get; set; } public string? TargetSystemId { get; set; } public string? TargetSiteId { get; set; } public int CreatedAtCycle { get; init; } public int UpdatedAtCycle { get; set; } public string? BlockingReason { get; set; } public string? Notes { get; set; } public HashSet AssignedAssetIds { get; } = new(StringComparer.Ordinal); } public sealed class FactionBlackboardRuntime { public int PlanCycle { get; set; } public DateTimeOffset UpdatedAtUtc { get; set; } public int TargetWarshipCount { get; set; } public bool HasWarIndustrySupplyChain { get; set; } public bool HasShipyard { get; set; } public bool HasActiveExpansionProject { get; set; } public string? ActiveExpansionCommodityId { get; set; } public string? ActiveExpansionModuleId { get; set; } public string? ActiveExpansionSiteId { get; set; } public string? ActiveExpansionSystemId { get; set; } public int EnemyFactionCount { get; set; } public int EnemyShipCount { get; set; } public int EnemyStationCount { get; set; } public int MilitaryShipCount { get; set; } public int MinerShipCount { get; set; } public int TransportShipCount { get; set; } public int ConstructorShipCount { get; set; } public int ControlledSystemCount { get; set; } public List CommoditySignals { get; } = []; public List ThreatSignals { get; } = []; public HashSet AvailableShipIds { get; } = new(StringComparer.Ordinal); } public sealed class FactionCommoditySignalRuntime { public required string ItemId { get; init; } public float AvailableStock { get; set; } public float OnHand { get; set; } public float ProductionRatePerSecond { get; set; } public float CommittedProductionRatePerSecond { get; set; } public float UsageRatePerSecond { get; set; } public float NetRatePerSecond { get; set; } public float ProjectedNetRatePerSecond { get; set; } public float LevelSeconds { get; set; } public string Level { get; set; } = "unknown"; public float ProjectedProductionRatePerSecond { get; set; } public float BuyBacklog { get; set; } public float ReservedForConstruction { get; set; } } public sealed class FactionThreatSignalRuntime { public required string ScopeId { get; init; } public required string ScopeKind { get; init; } public int EnemyShipCount { get; set; } public int EnemyStationCount { get; set; } } public sealed class CommanderBehaviorRuntime { public required string Kind { get; set; } public string? Phase { get; set; } public string? TargetEntityId { get; set; } public string? ItemId { get; set; } public string? NodeId { get; set; } public string? StationId { get; set; } public string? ModuleId { get; set; } public string? AreaSystemId { get; set; } public int PatrolIndex { get; set; } } public sealed class CommanderOrderRuntime { public required string Kind { get; init; } public OrderStatus Status { get; set; } = OrderStatus.Accepted; public string? TargetEntityId { get; set; } public string? DestinationNodeId { get; set; } public required string DestinationSystemId { get; init; } public required Vector3 DestinationPosition { get; init; } } public sealed class CommanderTaskRuntime { public required string Kind { get; set; } public WorkStatus Status { get; set; } = WorkStatus.Pending; public string? TargetEntityId { get; set; } public string? TargetSystemId { get; set; } public string? TargetNodeId { get; set; } public Vector3? TargetPosition { get; set; } public float Threshold { get; set; } }