wip healing
This commit is contained in:
parent
ece699b68e
commit
f13fe16317
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue