From 36be4bc4c8c54a0608d7f97ee95f8501732d2244 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Wed, 1 Nov 2023 16:02:39 +0100 Subject: [PATCH] Refactored map generation and masking. World now has textures for height and tile types. --- scenes/Game.cs | 179 +++++---- scenes/Game.tscn | 34 +- .../{WorldView.cs => TileInstanceManager.cs} | 41 +-- scenes/World.cs | 344 +++++++++++------- scenes/WorldChunk.cs | 217 ++++++----- scenes/WorldChunk.tscn | 52 +-- 6 files changed, 464 insertions(+), 403 deletions(-) rename scenes/{WorldView.cs => TileInstanceManager.cs} (75%) diff --git a/scenes/Game.cs b/scenes/Game.cs index 4b6026a..00e9925 100644 --- a/scenes/Game.cs +++ b/scenes/Game.cs @@ -1,55 +1,55 @@ -using Godot; using System.Diagnostics; -using System.Linq; -using Array = Godot.Collections.Array; +using Godot; public class Game : Spatial { + private ImageTexture _blackWhitePatternTexture; + private Camera _camera; + private Vector3 _cameraOffset; + private Label _centerLabel; + + private HexCell _currentTile; + // ui elements private Label _framesPerSecondLabel; - private Label _centerLabel; - private Label _tileOffsetLabel; - private Label _numTilesLabel; - private Label _mouseWorldLabel; - private Label _mouseTileOffsetLabel; - private Label _mouseTileCubeLabel; - private Label _numCoordsAddedLabel; - private Label _numCoordsRemovedLabel; - private TextureRect _worldTextureRect; - private TextureRect _heightTextureRect; - private Button _generateWorldButton; private Control _gameUi; + private Button _generateWorldButton; private Label _goldCountLabel; - - // scene nodes - private Spatial _tileHighlight; - private Spatial _mouseTileHighlight; - private StreamContainer _streamContainer; - private Area _streamContainerArea; - private Spatial _streamContainerActiveTiles; - private Player _player; - private TileWorld _tileWorld; - private Camera _camera; - private World _world; - private WorldView _worldView; - - // Resources - private PackedScene _tileHighlightScene; - private ShaderMaterial _tileMaterial; + private TextureRect _heightTextureRect; // other members private HexGrid _hexGrid; - private HexCell _lastTile; - private HexCell _currentTile; - private Vector3 _cameraOffset; - private ImageTexture _blackWhitePatternTexture; private InteractionSystem _interactionSystem; + private HexCell _lastTile; + private Label _mouseTileCubeLabel; + private Spatial _mouseTileHighlight; + private Label _mouseTileOffsetLabel; + private Label _mouseWorldLabel; + private Label _numCoordsAddedLabel; + private Label _numCoordsRemovedLabel; + private Label _numTilesLabel; + private Player _player; + private StreamContainer _streamContainer; + private Spatial _streamContainerActiveTiles; + private Area _streamContainerArea; + + // scene nodes + private Spatial _tileHighlight; + + // Resources + private PackedScene _tileHighlightScene; + private TileInstanceManager _tileInstanceManager; + private ShaderMaterial _tileMaterial; + private Label _tileOffsetLabel; + private TileWorld _tileWorld; + private World _world; + private TextureRect _worldTextureRect; // Called when the node enters the scene tree for the first time. public override void _Ready() { // debugStatsContainer - Container debugStatsContainer = (Container)FindNode("DebugStatsContainer"); + var debugStatsContainer = (Container)FindNode("DebugStatsContainer"); _framesPerSecondLabel = debugStatsContainer.GetNode