✨ Toggle build
🐛 Fix world gen tiles didn't align with placed ones
This commit is contained in:
@@ -376,14 +376,16 @@ public partial class NaturalResourceGenerator : Node2D
|
||||
return false;
|
||||
}
|
||||
|
||||
var instance = scene.Instantiate() as Node2D;
|
||||
if (instance == null)
|
||||
if (scene.Instantiate() is not Node2D instance)
|
||||
{
|
||||
GD.PrintErr($"{LogPrefix} Failed to instantiate scene for: {tileType}");
|
||||
return false;
|
||||
}
|
||||
|
||||
instance.GlobalPosition = GridUtils.GridToWorld(cell);
|
||||
// Use the same positioning logic as PlacementManager
|
||||
var rotatedSize = building.GetRotatedSize(0f); // 0f for no rotation
|
||||
var offset = GridUtils.GetCenterOffset(rotatedSize, 0f); // 0f for no rotation
|
||||
instance.GlobalPosition = GridUtils.GridToWorld(cell) + offset;
|
||||
instance.ZIndex = (int)building.Layer;
|
||||
AddChild(instance);
|
||||
Grid.OccupyArea(cell, instance, building.Size, 0f, building.Layer);
|
||||
|
Reference in New Issue
Block a user