From 86b8739982e421adf90b65c43c9188359b8797af Mon Sep 17 00:00:00 2001 From: ktyl Date: Mon, 12 Dec 2022 22:03:34 +0000 Subject: [PATCH] update overlays every frame #5 --- half-earth/nodes/game.tscn | 4 +--- half-earth/nodes/grid.tscn | 5 +++-- half-earth/resources/tiles/tile_types/developed.tres | 2 +- half-earth/resources/tiles/tile_types/wild.tres | 2 +- half-earth/scripts/overlays/HeatOverlay.cs | 6 +----- half-earth/scripts/overlays/NoOverlay.cs | 7 +------ half-earth/scripts/overlays/Overlay.cs | 3 +-- half-earth/scripts/overlays/Overlays.cs | 10 +--------- 8 files changed, 10 insertions(+), 29 deletions(-) diff --git a/half-earth/nodes/game.tscn b/half-earth/nodes/game.tscn index bde9c19..15ee3c2 100644 --- a/half-earth/nodes/game.tscn +++ b/half-earth/nodes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://nodes/grid.tscn" type="PackedScene" id=1] [ext_resource path="res://nodes/grid_cursor.tscn" type="PackedScene" id=2] @@ -7,7 +7,6 @@ [ext_resource path="res://nodes/interaction_modes/interaction_mode.tscn" type="PackedScene" id=5] [ext_resource path="res://nodes/ui/build_mode_ui.tscn" type="PackedScene" id=6] [ext_resource path="res://nodes/interaction_modes/build_mode.tscn" type="PackedScene" id=7] -[ext_resource path="res://resources/tiles/tiles.tres" type="Resource" id=8] [ext_resource path="res://nodes/ui/mode_selection_ui.tscn" type="PackedScene" id=9] [ext_resource path="res://nodes/overlays.tscn" type="PackedScene" id=10] @@ -21,7 +20,6 @@ _autoTick = true [node name="World Grid" parent="." instance=ExtResource( 1 )] DiffusionCoefficient = 0.1 -_tileGridResource = ExtResource( 8 ) [node name="Cursor" parent="." instance=ExtResource( 2 )] Grid = NodePath("../World Grid") diff --git a/half-earth/nodes/grid.tscn b/half-earth/nodes/grid.tscn index 3a19d57..3a7f10f 100644 --- a/half-earth/nodes/grid.tscn +++ b/half-earth/nodes/grid.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://scripts/WorldGrid.cs" type="Script" id=1] [ext_resource path="res://nodes/tile.tscn" type="PackedScene" id=2] +[ext_resource path="res://resources/tiles/tiles.tres" type="Resource" id=3] [node name="Grid" type="Node2D"] script = ExtResource( 1 ) TileScene = ExtResource( 2 ) -Size = 10 CellSize = 64 +_tileGridResource = ExtResource( 3 ) diff --git a/half-earth/resources/tiles/tile_types/developed.tres b/half-earth/resources/tiles/tile_types/developed.tres index 70a9358..9847d30 100644 --- a/half-earth/resources/tiles/tile_types/developed.tres +++ b/half-earth/resources/tiles/tile_types/developed.tres @@ -8,4 +8,4 @@ Name = "Developed" BuildLabel = "[D]eveloped" Key = 68 Color = Color( 0.372549, 0.372549, 0.372549, 1 ) -HeatGeneration = 0.1 +HeatGeneration = 0.4 diff --git a/half-earth/resources/tiles/tile_types/wild.tres b/half-earth/resources/tiles/tile_types/wild.tres index eae570c..4e5b1d7 100644 --- a/half-earth/resources/tiles/tile_types/wild.tres +++ b/half-earth/resources/tiles/tile_types/wild.tres @@ -8,4 +8,4 @@ Name = "Wild" BuildLabel = "[W]ild" Key = 87 Color = Color( 0, 0.545098, 0.0196078, 1 ) -HeatGeneration = -0.025 +HeatGeneration = -0.2 diff --git a/half-earth/scripts/overlays/HeatOverlay.cs b/half-earth/scripts/overlays/HeatOverlay.cs index 42d1ca4..671fdca 100644 --- a/half-earth/scripts/overlays/HeatOverlay.cs +++ b/half-earth/scripts/overlays/HeatOverlay.cs @@ -9,14 +9,10 @@ public class HeatOverlay : Overlay [Export] private Color _hotColor; - public override void Initialise(Tile tile, ShaderMaterial material) + public override void Apply(Tile tile, ShaderMaterial material) { material.SetShaderParam("lowColor", _coldColor); material.SetShaderParam("highColor", _hotColor); - } - - public override void Process(Tile tile, ShaderMaterial material) - { material.SetShaderParam("t", tile.temperature); } } diff --git a/half-earth/scripts/overlays/NoOverlay.cs b/half-earth/scripts/overlays/NoOverlay.cs index f92d2de..49f8b1b 100644 --- a/half-earth/scripts/overlays/NoOverlay.cs +++ b/half-earth/scripts/overlays/NoOverlay.cs @@ -3,15 +3,10 @@ using Godot; public class NoOverlay : Overlay { // in this view we want to draw tiles with their normal colour - - public override void Initialise(Tile tile, ShaderMaterial material) + public override void Apply(Tile tile, ShaderMaterial material) { var type = tile.type; material.SetShaderParam("lowColor", type.Color); material.SetShaderParam("t", 0); } - - public override void Process(Tile tile, ShaderMaterial material) - { - } } \ No newline at end of file diff --git a/half-earth/scripts/overlays/Overlay.cs b/half-earth/scripts/overlays/Overlay.cs index d395c09..ef65c38 100644 --- a/half-earth/scripts/overlays/Overlay.cs +++ b/half-earth/scripts/overlays/Overlay.cs @@ -2,6 +2,5 @@ using Godot; public abstract class Overlay : Resource { - public abstract void Initialise(Tile tile, ShaderMaterial material); - public abstract void Process(Tile tile, ShaderMaterial material); + public abstract void Apply(Tile tile, ShaderMaterial material); } \ No newline at end of file diff --git a/half-earth/scripts/overlays/Overlays.cs b/half-earth/scripts/overlays/Overlays.cs index 85c844d..b9706a8 100644 --- a/half-earth/scripts/overlays/Overlays.cs +++ b/half-earth/scripts/overlays/Overlays.cs @@ -56,7 +56,7 @@ public class Overlays : Node var tile = _tileGrid[i]; var material = _worldGrid.GetTileMaterial(i); - Current.Process(tile, material); + Current.Apply(tile, material); } } @@ -64,13 +64,5 @@ public class Overlays : Node { _overlayIdx++; _overlayIdx %= _overlays.Length; - - for (int i = 0; i < _tileGrid.Count; i++) - { - var tile = _tileGrid[i]; - var material = _worldGrid.GetTileMaterial(i); - - Current.Initialise(tile, material); - } } }