Refactor backend into domain-first slices

This commit is contained in:
2026-03-19 18:15:44 -04:00
parent 07a3142316
commit 9a5040cf1f
53 changed files with 94 additions and 140 deletions

View File

@@ -1,6 +1,6 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace SpaceGame.Api.Data; namespace SpaceGame.Api.Definitions;
public sealed class ConstructionDefinition public sealed class ConstructionDefinition
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Contracts; namespace SpaceGame.Api.Economy.Contracts;
public sealed record MarketOrderSnapshot( public sealed record MarketOrderSnapshot(
string Id, string Id,

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Economy.Runtime;
public sealed class MarketOrderRuntime public sealed class MarketOrderRuntime
{ {

View File

@@ -1,10 +1,6 @@
using SpaceGame.Api.Contracts; using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
using SpaceGame.Api.Simulation.AI;
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.Support.SimulationRuntimeSupport;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Factions.AI;
internal sealed class CommanderPlanningService internal sealed class CommanderPlanningService
{ {

View File

@@ -1,7 +1,5 @@
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation.AI; namespace SpaceGame.Api.Factions.AI;
// ─── Planning State ──────────────────────────────────────────────────────────── // ─── Planning State ────────────────────────────────────────────────────────────

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Contracts; namespace SpaceGame.Api.Factions.Contracts;
public sealed record FactionGoapStateSnapshot( public sealed record FactionGoapStateSnapshot(
int MilitaryShipCount, int MilitaryShipCount,

View File

@@ -1,6 +1,5 @@
using SpaceGame.Api.Simulation.AI;
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Factions.Runtime;
public sealed class FactionRuntime public sealed class FactionRuntime
{ {

View File

@@ -0,0 +1,21 @@
global using SpaceGame.Api.Definitions;
global using SpaceGame.Api.Economy.Contracts;
global using SpaceGame.Api.Economy.Runtime;
global using SpaceGame.Api.Factions.AI;
global using SpaceGame.Api.Factions.Contracts;
global using SpaceGame.Api.Factions.Runtime;
global using SpaceGame.Api.Shared.AI;
global using SpaceGame.Api.Shared.Contracts;
global using SpaceGame.Api.Shared.Runtime;
global using SpaceGame.Api.Ships.AI;
global using SpaceGame.Api.Ships.Contracts;
global using SpaceGame.Api.Ships.Runtime;
global using SpaceGame.Api.Ships.Simulation;
global using SpaceGame.Api.Simulation.Core;
global using SpaceGame.Api.Stations.Contracts;
global using SpaceGame.Api.Stations.Runtime;
global using SpaceGame.Api.Stations.Simulation;
global using SpaceGame.Api.Universe.Contracts;
global using SpaceGame.Api.Universe.Runtime;
global using SpaceGame.Api.Universe.Scenario;
global using SpaceGame.Api.Universe.Simulation;

View File

@@ -1,5 +1,5 @@
using FastEndpoints; using FastEndpoints;
using SpaceGame.Api.Simulation; using SpaceGame.Api.Universe.Simulation;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);

View File

@@ -1,7 +1,5 @@
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation.AI; namespace SpaceGame.Api.Shared.AI;
public abstract class GoapAction<TState> public abstract class GoapAction<TState>
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Contracts; namespace SpaceGame.Api.Shared.Contracts;
public sealed record Vector3Dto(float X, float Y, float Z); public sealed record Vector3Dto(float X, float Y, float Z);

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Shared.Runtime;
public enum SpatialNodeKind public enum SpatialNodeKind
{ {

View File

@@ -1,7 +1,5 @@
using SpaceGame.Api.Data;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation.Support; namespace SpaceGame.Api.Shared.Runtime;
internal static class SimulationRuntimeSupport internal static class SimulationRuntimeSupport
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Shared.Runtime;
public static class SimulationUnits public static class SimulationUnits
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Shared.Runtime;
public readonly record struct Vector3(float X, float Y, float Z) public readonly record struct Vector3(float X, float Y, float Z)
{ {

View File

@@ -1,7 +1,5 @@
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation.AI; namespace SpaceGame.Api.Ships.AI;
internal interface IShipBehaviorState internal interface IShipBehaviorState
{ {

View File

@@ -1,7 +1,5 @@
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation.AI; namespace SpaceGame.Api.Ships.AI;
internal sealed class ShipBehaviorStateMachine internal sealed class ShipBehaviorStateMachine
{ {

View File

@@ -1,7 +1,5 @@
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation.AI; namespace SpaceGame.Api.Ships.AI;
internal sealed class IdleShipBehaviorState : IShipBehaviorState internal sealed class IdleShipBehaviorState : IShipBehaviorState
{ {

View File

@@ -1,7 +1,5 @@
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation.AI; namespace SpaceGame.Api.Ships.AI;
// ─── Planning State ──────────────────────────────────────────────────────────── // ─── Planning State ────────────────────────────────────────────────────────────

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Contracts; namespace SpaceGame.Api.Ships.Contracts;
public sealed record ShipSnapshot( public sealed record ShipSnapshot(
string Id, string Id,

View File

@@ -1,6 +1,5 @@
using SpaceGame.Api.Data;
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Ships.Runtime;
public sealed class ShipRuntime public sealed class ShipRuntime
{ {

View File

@@ -1,11 +1,7 @@
using SpaceGame.Api.Contracts; using static SpaceGame.Api.Stations.Simulation.InfrastructureSimulationService;
using SpaceGame.Api.Simulation.AI; using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.Systems.InfrastructureSimulationService;
using static SpaceGame.Api.Simulation.Support.SimulationRuntimeSupport;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Ships.Simulation;
internal sealed class ShipControlService internal sealed class ShipControlService
{ {

View File

@@ -1,9 +1,7 @@
using SpaceGame.Api.Simulation.Model; using static SpaceGame.Api.Stations.Simulation.InfrastructureSimulationService;
using SpaceGame.Api.Simulation.Support; using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
using static SpaceGame.Api.Simulation.Systems.InfrastructureSimulationService;
using static SpaceGame.Api.Simulation.Support.SimulationRuntimeSupport;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Ships.Simulation;
internal sealed partial class ShipTaskExecutionService internal sealed partial class ShipTaskExecutionService
{ {

View File

@@ -1,8 +1,7 @@
using SpaceGame.Api.Simulation.Model; using static SpaceGame.Api.Stations.Simulation.InfrastructureSimulationService;
using static SpaceGame.Api.Simulation.Systems.InfrastructureSimulationService; using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
using static SpaceGame.Api.Simulation.Support.SimulationRuntimeSupport;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Ships.Simulation;
internal sealed partial class ShipTaskExecutionService internal sealed partial class ShipTaskExecutionService
{ {

View File

@@ -1,9 +1,5 @@
using SpaceGame.Api.Contracts;
using SpaceGame.Api.Simulation.Model;
using SpaceGame.Api.Simulation.Support;
using SpaceGame.Api.Simulation.Systems;
namespace SpaceGame.Api.Simulation.Engine; namespace SpaceGame.Api.Simulation.Core;
public sealed class SimulationEngine public sealed class SimulationEngine
{ {

View File

@@ -1,10 +1,8 @@
using SpaceGame.Api.Contracts; using static SpaceGame.Api.Stations.Simulation.InfrastructureSimulationService;
using SpaceGame.Api.Simulation.Model; using static SpaceGame.Api.Stations.Simulation.StationSimulationService;
using static SpaceGame.Api.Simulation.Systems.InfrastructureSimulationService; using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
using static SpaceGame.Api.Simulation.Systems.StationSimulationService;
using static SpaceGame.Api.Simulation.Support.SimulationRuntimeSupport;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Simulation.Core;
internal sealed class SimulationProjectionService internal sealed class SimulationProjectionService
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Contracts; namespace SpaceGame.Api.Stations.Contracts;
public sealed record InventoryEntry( public sealed record InventoryEntry(
string ItemId, string ItemId,

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Stations.Runtime;
public sealed class ClaimRuntime public sealed class ClaimRuntime
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Stations.Runtime;
public sealed class StationRuntime public sealed class StationRuntime
{ {

View File

@@ -1,9 +1,6 @@
using SpaceGame.Api.Contracts; using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
using SpaceGame.Api.Data;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.Support.SimulationRuntimeSupport;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Stations.Simulation;
internal sealed class InfrastructureSimulationService internal sealed class InfrastructureSimulationService
{ {

View File

@@ -1,10 +1,7 @@
using SpaceGame.Api.Data; using static SpaceGame.Api.Ships.Simulation.ShipControlService;
using SpaceGame.Api.Contracts; using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.Systems.ShipControlService;
using static SpaceGame.Api.Simulation.Support.SimulationRuntimeSupport;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Stations.Simulation;
internal sealed class StationLifecycleService internal sealed class StationLifecycleService
{ {

View File

@@ -1,10 +1,7 @@
using SpaceGame.Api.Data; using static SpaceGame.Api.Factions.AI.CommanderPlanningService;
using SpaceGame.Api.Contracts; using static SpaceGame.Api.Shared.Runtime.SimulationRuntimeSupport;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.Systems.CommanderPlanningService;
using static SpaceGame.Api.Simulation.Support.SimulationRuntimeSupport;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Stations.Simulation;
internal sealed class StationSimulationService internal sealed class StationSimulationService
{ {

View File

@@ -1,7 +1,6 @@
using FastEndpoints; using FastEndpoints;
using SpaceGame.Api.Simulation;
namespace SpaceGame.Api.Handlers; namespace SpaceGame.Api.Universe.Api;
public sealed class GetWorldHandler(WorldService worldService) : EndpointWithoutRequest public sealed class GetWorldHandler(WorldService worldService) : EndpointWithoutRequest
{ {

View File

@@ -1,7 +1,6 @@
using FastEndpoints; using FastEndpoints;
using SpaceGame.Api.Simulation;
namespace SpaceGame.Api.Handlers; namespace SpaceGame.Api.Universe.Api;
public sealed class GetWorldHealthHandler(WorldService worldService) : EndpointWithoutRequest public sealed class GetWorldHealthHandler(WorldService worldService) : EndpointWithoutRequest
{ {

View File

@@ -1,7 +1,6 @@
using FastEndpoints; using FastEndpoints;
using SpaceGame.Api.Simulation;
namespace SpaceGame.Api.Handlers; namespace SpaceGame.Api.Universe.Api;
public sealed class ResetWorldHandler(WorldService worldService) : EndpointWithoutRequest public sealed class ResetWorldHandler(WorldService worldService) : EndpointWithoutRequest
{ {

View File

@@ -1,6 +1,6 @@
using FastEndpoints; using FastEndpoints;
namespace SpaceGame.Api.Handlers; namespace SpaceGame.Api.Universe.Api;
public sealed class RootRedirectHandler : EndpointWithoutRequest public sealed class RootRedirectHandler : EndpointWithoutRequest
{ {

View File

@@ -1,9 +1,7 @@
using System.Text.Json; using System.Text.Json;
using FastEndpoints; using FastEndpoints;
using SpaceGame.Api.Contracts;
using SpaceGame.Api.Simulation;
namespace SpaceGame.Api.Handlers; namespace SpaceGame.Api.Universe.Api;
public sealed class StreamWorldHandler(WorldService worldService) : EndpointWithoutRequest public sealed class StreamWorldHandler(WorldService worldService) : EndpointWithoutRequest
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Contracts; namespace SpaceGame.Api.Universe.Contracts;
public sealed record StarSnapshot( public sealed record StarSnapshot(
string Kind, string Kind,

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Contracts; namespace SpaceGame.Api.Universe.Contracts;
public sealed record WorldSnapshot( public sealed record WorldSnapshot(
string Label, string Label,

View File

@@ -1,6 +1,5 @@
using SpaceGame.Api.Data;
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Universe.Runtime;
public sealed class SimulationWorld public sealed class SimulationWorld
{ {

View File

@@ -1,6 +1,5 @@
using SpaceGame.Api.Data;
namespace SpaceGame.Api.Simulation.Model; namespace SpaceGame.Api.Universe.Runtime;
public sealed class SystemRuntime public sealed class SystemRuntime
{ {

View File

@@ -1,9 +1,7 @@
using System.Text.Json; using System.Text.Json;
using SpaceGame.Api.Data; using static SpaceGame.Api.Universe.Scenario.LoaderSupport;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.LoaderSupport;
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Scenario;
internal sealed class DataCatalogLoader(string dataRoot) internal sealed class DataCatalogLoader(string dataRoot)
{ {

View File

@@ -1,7 +1,5 @@
using SpaceGame.Api.Data;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Scenario;
internal static class LoaderSupport internal static class LoaderSupport
{ {

View File

@@ -1,6 +1,5 @@
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Scenario;
public sealed class ScenarioLoader public sealed class ScenarioLoader
{ {

View File

@@ -1,8 +1,6 @@
using SpaceGame.Api.Data; using static SpaceGame.Api.Universe.Scenario.LoaderSupport;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.LoaderSupport;
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Scenario;
internal sealed class SpatialBuilder internal sealed class SpatialBuilder
{ {

View File

@@ -1,8 +1,6 @@
using SpaceGame.Api.Data; using static SpaceGame.Api.Universe.Scenario.LoaderSupport;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.LoaderSupport;
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Scenario;
internal sealed class SystemGenerationService internal sealed class SystemGenerationService
{ {

View File

@@ -1,8 +1,6 @@
using SpaceGame.Api.Data; using static SpaceGame.Api.Universe.Scenario.LoaderSupport;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.LoaderSupport;
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Scenario;
internal sealed class WorldBuilder( internal sealed class WorldBuilder(
WorldGenerationOptions worldGeneration, WorldGenerationOptions worldGeneration,

View File

@@ -1,8 +1,6 @@
using SpaceGame.Api.Data; using static SpaceGame.Api.Universe.Scenario.LoaderSupport;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.LoaderSupport;
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Scenario;
internal sealed class WorldSeedingService internal sealed class WorldSeedingService
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Simulation;
public sealed class OrbitalSimulationOptions public sealed class OrbitalSimulationOptions
{ {

View File

@@ -1,8 +1,6 @@
using SpaceGame.Api.Data; using static SpaceGame.Api.Stations.Simulation.InfrastructureSimulationService;
using SpaceGame.Api.Simulation.Model;
using static SpaceGame.Api.Simulation.Systems.InfrastructureSimulationService;
namespace SpaceGame.Api.Simulation.Systems; namespace SpaceGame.Api.Universe.Simulation;
internal sealed class OrbitalStateUpdater internal sealed class OrbitalStateUpdater
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Simulation;
public sealed class SimulationHostedService(WorldService worldService) : BackgroundService public sealed class SimulationHostedService(WorldService worldService) : BackgroundService
{ {

View File

@@ -1,4 +1,4 @@
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Simulation;
public sealed class WorldGenerationOptions public sealed class WorldGenerationOptions
{ {

View File

@@ -1,10 +1,7 @@
using System.Threading.Channels; using System.Threading.Channels;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using SpaceGame.Api.Contracts;
using SpaceGame.Api.Simulation.Engine;
using SpaceGame.Api.Simulation.Model;
namespace SpaceGame.Api.Simulation; namespace SpaceGame.Api.Universe.Simulation;
public sealed class WorldService( public sealed class WorldService(
IWebHostEnvironment environment, IWebHostEnvironment environment,