From 944ca8c3f21a1eda669a88ce2c25ebcf71276c36 Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Tue, 6 Dec 2022 19:29:01 +0000 Subject: [PATCH] extract struct to file --- half-earth/scripts/Tile.cs | 8 ++++++++ half-earth/scripts/WorldGrid.cs | 11 ++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 half-earth/scripts/Tile.cs diff --git a/half-earth/scripts/Tile.cs b/half-earth/scripts/Tile.cs new file mode 100644 index 0000000..f46e5ee --- /dev/null +++ b/half-earth/scripts/Tile.cs @@ -0,0 +1,8 @@ +using Godot; + +public struct Tile +{ + public bool isHighlighted; + public float value; + public ShaderMaterial material; +} \ No newline at end of file diff --git a/half-earth/scripts/WorldGrid.cs b/half-earth/scripts/WorldGrid.cs index a59855d..7f55d6c 100644 --- a/half-earth/scripts/WorldGrid.cs +++ b/half-earth/scripts/WorldGrid.cs @@ -12,11 +12,6 @@ public class WorldGrid : Node2D [Export] public int CellSize { get; set; } - private struct Tile - { - public bool isHighlighted; - public ShaderMaterial material; - } private Tile[,] _tiles; // Called when the node enters the scene tree for the first time. @@ -52,6 +47,11 @@ public class WorldGrid : Node2D _tiles[x, y].isHighlighted ^= true; } + + public void SetTileValue(int x, int y, float value) + { + _tiles[x, y].value = value; + } public void GetGridPos(Vector2 position, out int x, out int y) { @@ -84,6 +84,7 @@ public class WorldGrid : Node2D { var tile = new Tile(); tile.isHighlighted = false; + tile.value = 0.0f; var node = TileScene.Instance(); this.AddChild(node);