diff --git a/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs b/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs index 0d27a03..68f8f12 100644 --- a/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs +++ b/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs @@ -132,9 +132,12 @@ namespace Infrastructure.Unity // Calculate current floor index based on Y height (inverse logic from Generator) // Note: Generator uses negative offsets: 0, -15, -30. // So Floor 0 is at Y=0. Floor 1 is at Y=-15. - - var heightDist = levelGenerator.Definition.FloorHeightDistance; - var maxFloors = levelGenerator.Definition.FloorCount; + + var def = levelGenerator.Definition; + if (def == null) return; + + var heightDist = def.FloorHeightDistance; + var maxFloors = def.FloorCount; var rawFloor = Mathf.RoundToInt(-playerY / heightDist); _currentPlayerFloorIndex = Mathf.Clamp(rawFloor, 0, maxFloors - 1); diff --git a/Assets/Scripts/Infrastructure/Unity/LevelGenerator.cs b/Assets/Scripts/Infrastructure/Unity/LevelGenerator.cs index bfacd16..dc6c30d 100644 --- a/Assets/Scripts/Infrastructure/Unity/LevelGenerator.cs +++ b/Assets/Scripts/Infrastructure/Unity/LevelGenerator.cs @@ -30,6 +30,13 @@ namespace Infrastructure.Unity public IEnumerator GenerateAsync(SoundManager soundManager, TileRegistry registry, CameraController camera, RumbleManager rumble, Action onComplete) { + if (levelDefinition == null) + { + Debug.LogError("LevelGenerator: levelDefinition is not assigned. Assign a LevelDefinition asset in the Inspector."); + onComplete?.Invoke(); + yield break; + } + _tilePool = new TilePool(tilePrefab, transform); var stopwatch = new Stopwatch();