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);
|
||||
|
||||
Reference in New Issue
Block a user