Building duartion

This commit is contained in:
2025-08-27 02:42:13 +08:00
parent 3d11cecd5e
commit e9b070ff35
6 changed files with 178 additions and 48 deletions

View File

@@ -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);