Refactor world bootstrap and allow empty startup worlds
This commit is contained in:
@@ -16,8 +16,8 @@ internal sealed class PlayerFactionService
|
||||
return world.PlayerFaction;
|
||||
}
|
||||
|
||||
var sovereignFaction = world.Factions.FirstOrDefault(faction => string.Equals(faction.Id, LoaderSupport.DefaultFactionId, StringComparison.Ordinal))
|
||||
?? world.Factions.OrderBy(faction => faction.Id, StringComparer.Ordinal).First();
|
||||
var sovereignFaction = world.Factions.OrderBy(faction => faction.Id, StringComparer.Ordinal).FirstOrDefault()
|
||||
?? throw new InvalidOperationException("Cannot create a player faction domain without any factions in the world.");
|
||||
|
||||
world.PlayerFaction = new PlayerFactionRuntime
|
||||
{
|
||||
@@ -35,6 +35,11 @@ internal sealed class PlayerFactionService
|
||||
|
||||
internal void Update(SimulationWorld world, float _deltaSeconds, ICollection<SimulationEventRecord> events)
|
||||
{
|
||||
if (world.PlayerFaction is null && world.Factions.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var player = EnsureDomain(world);
|
||||
EnsureBaseStructures(world, player);
|
||||
SyncRegistry(world, player);
|
||||
|
||||
Reference in New Issue
Block a user