fix: null guard for unassigned LevelDefinition
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user