rewilding #20
|
@ -1,13 +1,13 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
public class HeatSystem
|
public class EnvironmentSystem
|
||||||
{
|
{
|
||||||
private readonly TileGrid _tiles;
|
private readonly TileGrid _tiles;
|
||||||
private readonly float _diffusionCoefficient;
|
private readonly float _diffusionCoefficient;
|
||||||
|
|
||||||
private float[] _nextTemperatures = null;
|
private float[] _nextTemperatures = null;
|
||||||
|
|
||||||
public HeatSystem(TileGrid tiles, float diffusionCoefficient)
|
public EnvironmentSystem(TileGrid tiles, float diffusionCoefficient)
|
||||||
{
|
{
|
||||||
_tiles = tiles;
|
_tiles = tiles;
|
||||||
_diffusionCoefficient = diffusionCoefficient;
|
_diffusionCoefficient = diffusionCoefficient;
|
||||||
|
@ -20,7 +20,6 @@ public class HeatSystem
|
||||||
Diffuse();
|
Diffuse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private float TransferHeat(float t0, float alpha, float nx, float ny, float px, float py)
|
private float TransferHeat(float t0, float alpha, float nx, float ny, float px, float py)
|
||||||
{
|
{
|
||||||
float d2tdx2 = nx - 2 * t0 + px;
|
float d2tdx2 = nx - 2 * t0 + px;
|
||||||
|
@ -96,5 +95,4 @@ public class HeatSystem
|
||||||
_tiles[i] = tile;
|
_tiles[i] = tile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ public class WorldGrid : Node2D
|
||||||
public ShaderMaterial material;
|
public ShaderMaterial material;
|
||||||
}
|
}
|
||||||
private TileView[] _tileViews;
|
private TileView[] _tileViews;
|
||||||
private HeatSystem _heat;
|
private EnvironmentSystem _environment;
|
||||||
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
|
@ -30,7 +30,7 @@ public class WorldGrid : Node2D
|
||||||
|
|
||||||
GenerateCanvasItems(_tileGrid);
|
GenerateCanvasItems(_tileGrid);
|
||||||
|
|
||||||
_heat = new HeatSystem(_tileGrid, DiffusionCoefficient);
|
_environment = new EnvironmentSystem(_tileGrid, DiffusionCoefficient);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Positioning
|
#region Positioning
|
||||||
|
@ -101,5 +101,5 @@ public class WorldGrid : Node2D
|
||||||
|
|
||||||
public ShaderMaterial GetTileMaterial(int idx) => _tileViews[idx].material;
|
public ShaderMaterial GetTileMaterial(int idx) => _tileViews[idx].material;
|
||||||
|
|
||||||
public void _on_Clock_OnTick(int ticks) => _heat.Process();
|
public void _on_Clock_OnTick(int ticks) => _environment.Process();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue