using Godot; namespace CodingLand.Scripts; public partial class TilesManager : Node2D { [Export] public float TileSize = 51.2f; [Rpc(CallLocal = true)] public void AddTile(Vector2 pos) { if (GetTileByPosition(pos) == null) { var tileVec = new Vector2(TileSize, TileSize); // TODO Replace the brick to player selection var blueprint = GD.Load("res://Scenes/Tiles/Brick.tscn"); var instance = blueprint.Instantiate(); instance.Position = pos.Snapped(tileVec); AddChild(instance); } } public T GetTileByPosition(Vector2 position) where T : Node2D { foreach (var item in GetChildren()) { if (item is T tile && tile.Position == position) { return tile; } } return null; } }