public override void _Process(float delta) { if (_currentlyPlacingBuilding == null) { return; } var canPlace = CanPlace(_currentlyPlacingBuilding); if (canPlace) { _placementMarker.SetAllow(); } else { _placementMarker.SetDeny(); } if (Input.IsActionJustPressed("accept_build") && canPlace) { _placementMarker.QueueFree(); _placementMarker = null; AddBuilding(_currentlyPlacingBuilding); _currentlyPlacingBuilding.Build(); SetBuildPlaceHolder(_currentlyPlacingBuilding.BuildingType); } }
public void StopPlaceBuildings() { _placementMarker.QueueFree(); _placementMarker = null; ((Node)_currentlyPlacingBuilding).QueueFree(); _currentlyPlacingBuilding = null; }
private void SetBuildPlaceHolder(BuildingType buildingType) { _currentlyPlacingBuilding = (IBuilding)FarmerHouseScene.Instance(); _placementMarker = (PlacementMarker)PlacementMarkerScene.Instance(); _placementMarker.AttachTo(_currentlyPlacingBuilding); var asNode = (Node)_currentlyPlacingBuilding; asNode.AddChild(_placementMarker); _buildingsParent.AddChild(asNode); }