Applied fire extinguisher changes from the command-improvement branch: the repair tool steps through the ray that's used to find firesources in range and collects all firesources along the way instead of just checking the start and end positions of the ray (-> fires are much easier to extinguish now). Closes #274
This commit is contained in:
@@ -60,7 +60,7 @@ namespace Barotrauma
|
||||
|
||||
public float DamageRange
|
||||
{
|
||||
get { return (float)Math.Sqrt(size.X) * 20.0f; }
|
||||
get { return (float)Math.Sqrt(size.X) * 20.0f; }
|
||||
}
|
||||
|
||||
public Hull Hull
|
||||
@@ -181,7 +181,7 @@ namespace Barotrauma
|
||||
|
||||
private void OnChangeHull(Vector2 pos, Hull particleHull)
|
||||
{
|
||||
if (particleHull == hull || particleHull==null) return;
|
||||
if (particleHull == hull || particleHull == null) return;
|
||||
|
||||
//hull already has a firesource roughly at the particles position -> don't create a new one
|
||||
if (particleHull.FireSources.Find(fs => pos.X > fs.position.X - 100.0f && pos.X < fs.position.X + fs.size.X + 100.0f) != null) return;
|
||||
@@ -198,9 +198,7 @@ namespace Barotrauma
|
||||
Character c = Character.CharacterList[i];
|
||||
if (c.AnimController.CurrentHull == null || c.IsDead) continue;
|
||||
|
||||
float range = DamageRange;
|
||||
if (c.Position.X < position.X - range || c.Position.X > position.X + size.X + range) continue;
|
||||
if (c.Position.Y < position.Y - size.Y || c.Position.Y > hull.Rect.Y) continue;
|
||||
if (!IsInDamageRange(c, DamageRange)) continue;
|
||||
|
||||
float dmg = (float)Math.Sqrt(size.X) * deltaTime / c.AnimController.Limbs.Length;
|
||||
foreach (Limb limb in c.AnimController.Limbs)
|
||||
@@ -210,6 +208,22 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInDamageRange(Character c, float damageRange)
|
||||
{
|
||||
if (c.Position.X < position.X - damageRange || c.Position.X > position.X + size.X + damageRange) return false;
|
||||
if (c.Position.Y < position.Y - size.Y || c.Position.Y > hull.Rect.Y) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsInDamageRange(Vector2 worldPosition, float damageRange)
|
||||
{
|
||||
if (worldPosition.X < WorldPosition.X - damageRange || worldPosition.X > WorldPosition.X + size.X + damageRange) return false;
|
||||
if (worldPosition.Y < WorldPosition.Y - size.Y || worldPosition.Y > hull.WorldRect.Y) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DamageItems(float deltaTime)
|
||||
{
|
||||
if (size.X <= 0.0f || GameMain.Client != null) return;
|
||||
@@ -251,7 +265,7 @@ namespace Barotrauma
|
||||
for (int i = 0; i < steamCount; i++)
|
||||
{
|
||||
Vector2 spawnPos = new Vector2(
|
||||
WorldPosition.X + Rand.Range(0.0f, size.X),
|
||||
WorldPosition.X + Rand.Range(0.0f, size.X),
|
||||
WorldPosition.Y + 10.0f);
|
||||
|
||||
Vector2 speed = new Vector2((spawnPos.X - (WorldPosition.X + size.X / 2.0f)), (float)Math.Sqrt(size.X) * Rand.Range(20.0f, 25.0f));
|
||||
@@ -270,26 +284,21 @@ namespace Barotrauma
|
||||
|
||||
//evaporate some of the water
|
||||
hull.WaterVolume -= extinquishAmount;
|
||||
|
||||
|
||||
if (GameMain.Client != null) return;
|
||||
|
||||
if (size.X < 1.0f) Remove();
|
||||
}
|
||||
|
||||
public void Extinguish(float deltaTime, float amount, Vector2 pos)
|
||||
public void Extinguish(float deltaTime, float amount)
|
||||
{
|
||||
float range = 100.0f;
|
||||
|
||||
if (pos.X < WorldPosition.X - range || pos.X > WorldPosition.X + size.X + range) return;
|
||||
if (pos.Y < WorldPosition.Y - range || pos.Y > WorldPosition.Y + 500.0f) return;
|
||||
|
||||
float extinquishAmount = amount * deltaTime;
|
||||
|
||||
#if CLIENT
|
||||
float steamCount = Rand.Range(-5.0f, (float)Math.Sqrt(amount));
|
||||
for (int i = 0; i < steamCount; i++)
|
||||
{
|
||||
Vector2 spawnPos = new Vector2(pos.X + Rand.Range(-5.0f, 5.0f), Rand.Range(position.Y - size.Y, position.Y) + 10.0f);
|
||||
Vector2 spawnPos = new Vector2(Rand.Range(position.X, position.X + size.X), Rand.Range(position.Y - size.Y, position.Y) + 10.0f);
|
||||
|
||||
Vector2 speed = new Vector2((spawnPos.X - (position.X + size.X / 2.0f)), (float)Math.Sqrt(size.X) * Rand.Range(20.0f, 25.0f));
|
||||
|
||||
@@ -312,6 +321,11 @@ namespace Barotrauma
|
||||
if (size.X < 1.0f) Remove();
|
||||
}
|
||||
|
||||
public void Extinguish(float deltaTime, float amount, Vector2 worldPosition)
|
||||
{
|
||||
if (IsInDamageRange(worldPosition, 100.0f)) Extinguish(deltaTime, amount);
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
#if CLIENT
|
||||
@@ -331,7 +345,7 @@ namespace Barotrauma
|
||||
foreach (Decal d in burnDecals)
|
||||
{
|
||||
d.StopFadeIn();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
hull.RemoveFire(this);
|
||||
|
||||
Reference in New Issue
Block a user