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

@@ -12,16 +12,16 @@ public sealed class ScenarioLoader(IOptions<StaticDataOptions> staticDataOptions
PropertyNameCaseInsensitive = true,
};
public ScenarioDefinition? Load()
public ScenarioDefinition Load(string relativePath)
{
var scenarioPath = Path.Combine(staticDataOptions.Value.DataRoot, "scenario.json");
var scenarioPath = Path.Combine(staticDataOptions.Value.DataRoot, relativePath);
if (!File.Exists(scenarioPath))
{
return null;
throw new FileNotFoundException($"Scenario file was not found: {relativePath}", scenarioPath);
}
var json = File.ReadAllText(scenarioPath);
return JsonSerializer.Deserialize<ScenarioDefinition>(json, _jsonOptions)
?? throw new InvalidOperationException("Unable to read scenario.json.");
?? throw new InvalidOperationException($"Unable to read {relativePath}.");
}
}