using Godot; using System; public partial class TestMap : TileMapLayer { /// /// The last cell that was highlighted. Used to avoid unnecessary updates. /// private Vector2I lastHighlightCell; private readonly Vector2I highlightTileCoord = new(0, 5); private readonly Vector2I vector2INegOne = new(-1, -1); // Called when the node enters the scene tree for the first time. public override void _Ready() { lastHighlightCell = vector2INegOne; } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { Vector2 mousePos = GetLocalMousePosition(); Vector2I cell = LocalToMap(mousePos); if (cell != lastHighlightCell) { if (lastHighlightCell != vector2INegOne) { EraseCell(lastHighlightCell); } lastHighlightCell = cell; SetCell(cell, 0, highlightTileCoord); GD.Print("Mouse is over cell: ", cell); } } }