From 8d122b650f3b3cf15433f5af84ab392489843e40 Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Tue, 6 Dec 2022 19:50:53 +0000 Subject: [PATCH] add cursor bounds check #3 --- half-earth/scripts/WorldGrid.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/half-earth/scripts/WorldGrid.cs b/half-earth/scripts/WorldGrid.cs index 5a06ef9..a59855d 100644 --- a/half-earth/scripts/WorldGrid.cs +++ b/half-earth/scripts/WorldGrid.cs @@ -47,6 +47,9 @@ public class WorldGrid : Node2D public void ToggleTileHighlight(int x, int y) { + if (!IsInBounds(x, y)) + return; + _tiles[x, y].isHighlighted ^= true; }