Compare commits
No commits in common. "62416307ef93daa9958f119e6fbd63bf1467c8ca" and "b65ce586842ceeb8e5e86598b993aa4f3e076a3c" have entirely different histories.
62416307ef
...
b65ce58684
|
@ -1,6 +0,0 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/overlays/HeatOverlay.cs" type="Script" id=1]
|
||||
|
||||
[node name="Heat Overlay" type="Node"]
|
||||
script = ExtResource( 1 )
|
|
@ -8,4 +8,3 @@ Name = "Developed"
|
|||
BuildLabel = "[D]eveloped"
|
||||
Key = 68
|
||||
Color = Color( 0.372549, 0.372549, 0.372549, 1 )
|
||||
HeatGeneration = 0.1
|
||||
|
|
|
@ -8,4 +8,3 @@ Name = "Wild"
|
|||
BuildLabel = "[W]ild"
|
||||
Key = 87
|
||||
Color = Color( 0, 0.545098, 0.0196078, 1 )
|
||||
HeatGeneration = -0.025
|
||||
|
|
|
@ -40,7 +40,7 @@ public class WorldGrid : Node2D
|
|||
{
|
||||
var tile = _tiles[x, y];
|
||||
var material = tile.material;
|
||||
material.SetShaderParam("t", tile.temperature);
|
||||
material.SetShaderParam("t", tile.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class WorldGrid : Node2D
|
|||
{
|
||||
var tile = new Tile();
|
||||
tile.isHighlighted = false;
|
||||
tile.temperature = 0.0f;
|
||||
tile.value = 0.0f;
|
||||
tile.type = _startTileType;
|
||||
|
||||
var node = TileScene.Instance<Node2D>();
|
||||
|
@ -122,7 +122,6 @@ public class WorldGrid : Node2D
|
|||
|
||||
public void _on_Clock_OnTick(int ticks)
|
||||
{
|
||||
GenerateHeat();
|
||||
Diffuse();
|
||||
}
|
||||
|
||||
|
@ -136,27 +135,13 @@ public class WorldGrid : Node2D
|
|||
private void GetNeighbourTemperatures(int x, int y, out float nx, out float ny, out float px, out float py)
|
||||
{
|
||||
// default value
|
||||
var t = _tiles[x, y].temperature;
|
||||
var t = _tiles[x, y].value;
|
||||
|
||||
nx = x > 0 ? _tiles[x - 1, y].temperature : t;
|
||||
px = x < Size - 1 ? _tiles[x + 1, y].temperature : t;
|
||||
nx = x > 0 ? _tiles[x - 1, y].value : t;
|
||||
px = x < Size - 1 ? _tiles[x + 1, y].value : t;
|
||||
|
||||
ny = y > 0 ? _tiles[x, y - 1].temperature : t;
|
||||
py = y < Size - 1 ? _tiles[x, y + 1].temperature : t;
|
||||
}
|
||||
|
||||
private void GenerateHeat()
|
||||
{
|
||||
for (int x = 0; x < Size; x++)
|
||||
{
|
||||
for (int y = 0; y < Size; y++)
|
||||
{
|
||||
var tile = _tiles[x, y];
|
||||
var type = tile.type;
|
||||
tile.temperature += type.HeatGeneration;
|
||||
_tiles[x, y] = tile;
|
||||
}
|
||||
}
|
||||
ny = y > 0 ? _tiles[x, y - 1].value : t;
|
||||
py = y < Size - 1 ? _tiles[x, y + 1].value : t;
|
||||
}
|
||||
|
||||
private void Diffuse()
|
||||
|
@ -165,7 +150,7 @@ public class WorldGrid : Node2D
|
|||
{
|
||||
for (int y = 0; y < Size; y++)
|
||||
{
|
||||
float t = _tiles[x, y].temperature;
|
||||
float t = _tiles[x, y].value;
|
||||
var D = DiffusionCoefficient;
|
||||
|
||||
GetNeighbourTemperatures(
|
||||
|
@ -176,10 +161,7 @@ public class WorldGrid : Node2D
|
|||
out var py);
|
||||
|
||||
// current value
|
||||
var temperature = TransferHeat(t, D, nx, ny, px, py);
|
||||
// TODO: what if it's really really cold out?
|
||||
temperature = Mathf.Max(0, temperature);
|
||||
_nextValues[x, y] = temperature;
|
||||
_nextValues[x, y] = TransferHeat(t, D, nx, ny, px, py);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +169,7 @@ public class WorldGrid : Node2D
|
|||
{
|
||||
for (int y = 0; y < Size; y++)
|
||||
{
|
||||
_tiles[x, y].temperature = _nextValues[x, y];
|
||||
_tiles[x, y].value = _nextValues[x, y];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public class HeatOverlay : Node
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
using Godot;
|
||||
|
||||
public class NoOverlay : Node
|
||||
{
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public class Overlays : Node
|
||||
{
|
||||
[Export]
|
||||
private KeyList _cycleOverlayKey;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
base._Input(@event);
|
||||
|
||||
if (!(@event is InputEventKey keyEvent))
|
||||
return;
|
||||
|
||||
if (!(keyEvent.Pressed))
|
||||
return;
|
||||
|
||||
if ((KeyList)keyEvent.Scancode != _cycleOverlayKey)
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void CycleOverlay()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ using Godot;
|
|||
public struct Tile
|
||||
{
|
||||
public bool isHighlighted;
|
||||
public float temperature;
|
||||
public float value;
|
||||
public ShaderMaterial material;
|
||||
public TileType type;
|
||||
}
|
|
@ -14,9 +14,6 @@ public class TileType : Resource
|
|||
[Export]
|
||||
public Color Color { get; private set; }
|
||||
|
||||
[Export]
|
||||
public float HeatGeneration { get; private set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
|
|
Loading…
Reference in New Issue