extract struct to file
This commit is contained in:
		
							parent
							
								
									8d122b650f
								
							
						
					
					
						commit
						0905515c11
					
				
							
								
								
									
										8
									
								
								half-earth/scripts/Tile.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								half-earth/scripts/Tile.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
using Godot;
 | 
			
		||||
 | 
			
		||||
public struct Tile
 | 
			
		||||
{
 | 
			
		||||
    public bool isHighlighted;
 | 
			
		||||
    public float value;
 | 
			
		||||
    public ShaderMaterial material;
 | 
			
		||||
}
 | 
			
		||||
@ -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<Node2D>();
 | 
			
		||||
                this.AddChild(node);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user