✨ Building duartion
This commit is contained in:
@@ -31,7 +31,7 @@ public partial class PlacementManager : Node2D
|
||||
|
||||
if (_ghostBuilding == null)
|
||||
{
|
||||
var scene = Registry.GetScene(_currentBuildingId);
|
||||
var scene = Registry.GetBuilding(_currentBuildingId)?.Scene;
|
||||
if (scene == null) return;
|
||||
|
||||
_ghostBuilding = (BaseTile)scene.Instantiate();
|
||||
@@ -61,12 +61,17 @@ public partial class PlacementManager : Node2D
|
||||
// Left click to place
|
||||
if (Input.IsActionPressed("build_tile") && canPlace)
|
||||
{
|
||||
var scene = Registry.GetScene(_currentBuildingId);
|
||||
var scene = Registry.GetBuilding(_currentBuildingId)?.Scene;
|
||||
if (scene == null) return;
|
||||
|
||||
_ghostBuilding.FinalizePlacement();
|
||||
|
||||
var buildingData = Registry.GetBuilding(_currentBuildingId);
|
||||
Grid.OccupyCell(_hoveredCell, _ghostBuilding);
|
||||
|
||||
if (buildingData is { BuildTime: > 0f })
|
||||
_ghostBuilding.StartConstruction(buildingData.BuildTime);
|
||||
|
||||
_ghostBuilding = (BaseTile)scene.Instantiate();
|
||||
_ghostBuilding.SetGhostMode(true);
|
||||
AddChild(_ghostBuilding);
|
||||
|
Reference in New Issue
Block a user