Switchable tiles

This commit is contained in:
2025-08-28 02:15:19 +08:00
parent 6d91d4efb8
commit 19f7243101
7 changed files with 20 additions and 12 deletions

View File

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