rewilding #20

Open
ktyl wants to merge 8 commits from rewilding into main
1 changed files with 43 additions and 6 deletions
Showing only changes of commit f13fe16317 - Show all commits

View File

@ -55,15 +55,52 @@ public class EnvironmentSystem
if (!(tile.type is IDamageable damageable))
return;
var surplus = tile.temperature - damageable.Threshold;
if (surplus < 0)
return;
var delta = tile.temperature - damageable.Threshold;
if (delta < 0)
{
// we want to heal based on how many wild tiles surround us
float healRate = 0.01f;
// count neighbours
}
else
{
// take damage
// TODO: parameterised balancing
tile.currentHealth -= surplus;
tile.currentHealth -= delta;
tile.currentHealth = Mathf.Clamp(tile.currentHealth, 0, 1);
}
}
public int GetNeighbourCount<T>(int x, int y) where T : TileType
{
int count = 0;
for (int i = -1; i < 1; i += 2)
{
for (int j = -1; j < 1; j += 2)
{
int xi = x + 1;
int yj = y + 1;
// assume tiles out side of bounds are the same type as this one
if (!_tiles.IsInBounds(xi, yj))
{
count += 1;
continue;
}
if (!(_tiles[xi, yj] is T))
continue;
count++;
}
}
return count;
}
private void Diffuse()
{
var D = _diffusionCoefficient;