✨ Switchable tiles
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using AceFieldNewHorizon.Scripts.Tiles; | ||||
| using Godot; | ||||
| using System.Linq; | ||||
| @@ -10,6 +11,8 @@ public partial class PlacementManager : Node2D | ||||
|     [Export] public GridManager Grid { get; set; } | ||||
|     [Export] public BuildingRegistry Registry { get; set; } | ||||
|  | ||||
|     private static readonly List<string> BuildableTiles = ["wall", "miner"]; | ||||
|  | ||||
|     private string _currentBuildingId = "wall"; | ||||
|     private Vector2I _hoveredCell; | ||||
|     private BaseTile _ghostBuilding; | ||||
| @@ -144,6 +147,13 @@ public partial class PlacementManager : Node2D | ||||
|             building.QueueFree(); | ||||
|             Grid.FreeArea(buildingInfo.Value.Position, buildingInfo.Value.Size, buildingInfo.Value.Rotation); | ||||
|         } | ||||
|  | ||||
|         if (Input.IsActionJustPressed("switch_tile")) | ||||
|         { | ||||
|             var currentIdx = BuildableTiles.IndexOf(_currentBuildingId); | ||||
|             var nextIdx = (currentIdx + 1) % BuildableTiles.Count; | ||||
|             SetCurrentBuilding(BuildableTiles[nextIdx]); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private bool CanPlaceBuilding() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user