Refactor world bootstrap and allow empty startup worlds

This commit is contained in:
2026-03-29 13:22:48 -04:00
parent 640e147ea8
commit 0bb72bee35
79 changed files with 173146 additions and 9235 deletions

View File

@@ -0,0 +1,29 @@
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);
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);
}
}