✨ Tiles able to deconstruct
This commit is contained in:
@@ -44,13 +44,23 @@ public partial class PlacementManager : Node2D
|
||||
_ghostBuilding.SetGhostMode(canPlace);
|
||||
|
||||
// Left click to place
|
||||
if (!Input.IsActionPressed("build_tile") || !canPlace) return;
|
||||
if (Input.IsActionPressed("build_tile") && canPlace)
|
||||
{
|
||||
_ghostBuilding.FinalizePlacement();
|
||||
Grid.OccupyCell(_hoveredCell, _ghostBuilding);
|
||||
|
||||
_ghostBuilding.FinalizePlacement();
|
||||
Grid.OccupyCell(_hoveredCell, _ghostBuilding);
|
||||
_ghostBuilding = (BaseTile)BuildingScene.Instantiate();
|
||||
_ghostBuilding.SetGhostMode(true);
|
||||
AddChild(_ghostBuilding);
|
||||
}
|
||||
|
||||
_ghostBuilding = (BaseTile)BuildingScene.Instantiate();
|
||||
_ghostBuilding.SetGhostMode(true);
|
||||
AddChild(_ghostBuilding);
|
||||
if (Input.IsActionPressed("destroy_tile") && !Grid.IsCellFree(_hoveredCell))
|
||||
{
|
||||
// Right click to destroy
|
||||
var building = Grid.GetBuildingAtCell(_hoveredCell);
|
||||
if (building == null) return;
|
||||
building.QueueFree();
|
||||
Grid.FreeCell(_hoveredCell);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user