From f527154e265651d65f8fb84e8727f3bce0a26d83 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 12:33:04 +0200 Subject: [PATCH] Scenarios Cut 1: StartGame stages through RunStart; the game's joins admit StartGame's new-run branch no longer generates, unpacks or admits the player: RunStart generates the arena and stages the run, and StartGame enters the zone and binds the returned player (docs/scenarios-cut.md, 2.2, deletion line). PopulateLevel's warp arrival and the spawnturret console command admit through Zone.Admit, unpiloted. The console commands stay (Q4); give's hull route moors a ship at the docked entity and joins a zone only through Entity.TryUndock, which already admits. Needs the Unity batchmode compile; Assembly-CSharp is not built headless. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/Gameplay/ActionGameManager.cs | 25 +++++++------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index c62d980e4..41165eae2 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -583,9 +583,7 @@ public class ActionGameManager : MonoBehaviour var turret = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateTurretLoadout()); turret.Position.xz = _currentEntity.Position.xz + ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500); - turret.Zone = Zone; - Zone.Entities.Add(turret); - turret.Activate(); + Zone.Admit(turret, piloted: false); }); //Temporary, or not ConsoleController.AddCommand("tow", _ => TowShip()); @@ -732,8 +730,7 @@ public class ActionGameManager : MonoBehaviour CurrentEntity.Deactivate(); CurrentEntity.Zone.Entities.Remove(CurrentEntity); CurrentEntity.Zone = Zone; - Zone.Entities.Add(CurrentEntity); - CurrentEntity.Activate(); + Zone.Admit(CurrentEntity, piloted: false); } ZoneRenderer.LoadZone(Zone); @@ -801,18 +798,14 @@ public class ActionGameManager : MonoBehaviour if (saved == null) { SectorMap.QueueZoneReveal(CurrentGalaxy.Entrance.AdjacentZones.Prepend(CurrentGalaxy.Entrance)); + // RunStart owns what a new run starts with (docs/scenarios-cut.md, 2.2); this only enters and binds. + RunStart.GenerateArena(ItemManager, Settings.ZoneSettings, CurrentGalaxy, null); PopulateLevel(CurrentGalaxy.Entrance); - var loadoutGenerator = new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentGalaxy, Zone.GalaxyZone, IsTutorial ? CurrentGalaxy.ResolveFaction(Settings.TutorialGenerationSettings.ProtagonistFaction) : null, 2); - var ship = EntitySerializer.Unpack( - ItemManager, - Zone, - loadoutGenerator.GenerateShipLoadout(data => string.IsNullOrEmpty(Settings.StartingHullName) || data.Name==Settings.StartingHullName )); - ((Ship) ship).IsPlayerShip = true; - ship.Position = float3.zero; - ship.Zone = Zone; - Zone.Entities.Add(ship); - ship.Activate(); - BindToEntity(ship); + var failures = new List(); + var staged = RunStart.Stage(ItemManager, Zone, null, Settings.StartingHullName, + IsTutorial ? CurrentGalaxy.ResolveFaction(Settings.TutorialGenerationSettings.ProtagonistFaction) : null, failures) + ?? throw new InvalidOperationException($"The new run could not stage: {string.Join("; ", failures)}"); + BindToEntity(staged.Player); } else {