wip healing

This commit is contained in:
ktyl 2022-12-21 22:12:01 +00:00
parent ece699b68e
commit f13fe16317
1 changed files with 43 additions and 6 deletions

View File

@ -55,15 +55,52 @@ public class EnvironmentSystem
if (!(tile.type is IDamageable damageable)) if (!(tile.type is IDamageable damageable))
return; return;
var surplus = tile.temperature - damageable.Threshold; var delta = tile.temperature - damageable.Threshold;
if (surplus < 0) if (delta < 0)
return; {
// we want to heal based on how many wild tiles surround us
float healRate = 0.01f;
// count neighbours
}
else
{
// take damage
// TODO: parameterised balancing // TODO: parameterised balancing
tile.currentHealth -= surplus; tile.currentHealth -= delta;
tile.currentHealth = Mathf.Clamp(tile.currentHealth, 0, 1); 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() private void Diffuse()
{ {
var D = _diffusionCoefficient; var D = _diffusionCoefficient;