A failed start is decided in RunStart.Launch; the scene steps nothing without a live run

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Nibu 2026-11-13 13:32:34 +00:00
commit f7d5a7d2a8
3 changed files with 68 additions and 14 deletions

View file

@ -854,21 +854,12 @@ public class ActionGameManager : MonoBehaviour
var scenario = PendingScenario;
PendingScenario = null;
var failures = new List<string>();
RunStart.Staged staged = null;
try
var staged = RunStart.Launch(() => RunSave.Replace(CultCache, () =>
{
staged = RunSave.Replace(CultCache, () =>
{
RunStart.GenerateArena(ItemManager, Settings.ZoneSettings, Settings.PlanetSettings, CurrentGalaxy, scenario);
PopulateLevel(CurrentGalaxy.Entrance);
return RunStart.Stage(ItemManager, Zone, scenario, Settings.StartingHullName, Settings.TutorialGenerationSettings, failures);
});
}
catch (Exception exception)
{
Debug.LogException(exception);
failures.Add(exception.Message);
}
RunStart.GenerateArena(ItemManager, Settings.ZoneSettings, Settings.PlanetSettings, CurrentGalaxy, scenario);
PopulateLevel(CurrentGalaxy.Entrance);
return RunStart.Stage(ItemManager, Zone, scenario, Settings.StartingHullName, Settings.TutorialGenerationSettings, failures);
}), failures, Debug.LogException);
if (staged == null)
{
@ -1348,6 +1339,8 @@ public class ActionGameManager : MonoBehaviour
void Update()
{
// No live run (a start that failed, a run that ended): the main menu is up, and nothing steps a zone or reads a player.
if (CurrentGalaxy == null) return;
if(!_paused)
{
_time += Time.deltaTime;

View file

@ -30,6 +30,21 @@ public static class RunStart
itemManager, zoneSettings, planetSettings, galaxy, galaxy.Entrance, galaxy.IsPrelude, scenario.Ambient);
}
// Runs a start and answers whether it produced a run: null, with the reason in `failures`, when `start` throws or
// returns nothing. The caller shows the failure and clears its run; nothing past a null may run the game.
public static Staged Launch(Func<Staged> start, List<string> failures, Action<Exception> log = null)
{
Staged staged = null;
try { staged = start(); }
catch (Exception exception)
{
log?.Invoke(exception);
failures.Add(exception.Message);
}
if (staged == null && failures.Count == 0) failures.Add("the start produced no run");
return staged;
}
// Runs the scenario's Stage, then admits its player and everything it placed: each entity's stance set both ways
// with the player, a pilot for each piloted one. Returns null, with every failure listed and the arena unchanged,
// unless the whole scenario staged.