using SpaceGame.Api.Universe.Bootstrap; namespace SpaceGame.Api.Universe.Scenario; public sealed class WorldTopologyBuilder( IStaticDataProvider staticData, SystemGenerationService generationService, SpatialBuilder spatialBuilder) { public WorldBuildTopology Build(WorldGenerationOptions worldGenerationOptions) { var systems = generationService.GenerateSystems( generationService.PrepareKnownSystems(staticData.KnownSystems), worldGenerationOptions); return BuildFromDefinitions(systems); } public WorldBuildTopology Build(IReadOnlyList systems) { if (systems.Count == 0) { throw new InvalidOperationException("Scenario-defined systems cannot be empty."); } // Temporary QA-only path for fixed-topology scenarios such as "minimal". return BuildFromDefinitions(systems); } private WorldBuildTopology BuildFromDefinitions(IReadOnlyList systems) { var systemRuntimes = systems .Select(definition => new SystemRuntime { Definition = definition, Position = LoaderSupport.ToVector(definition.Position), }) .ToList(); var systemsById = systemRuntimes.ToDictionary(system => system.Definition.Id, StringComparer.Ordinal); var spatialLayout = spatialBuilder.BuildLayout(systemRuntimes); return new WorldBuildTopology(systems, systemRuntimes, systemsById, spatialLayout); } }