Cutting/repairing holes in walls is logged, fixed gaps emitting drip particles even if there's no water in either hull. Closes #139

This commit is contained in:
Joonas Rikkonen
2018-01-09 19:50:55 +02:00
parent 6fff303d30
commit d1bb33be78
3 changed files with 29 additions and 5 deletions
@@ -78,7 +78,7 @@ namespace Barotrauma
} }
//light dripping //light dripping
if (open < 0.2f) if (open < 0.2f && LerpedFlowForce.LengthSquared() > 100.0f)
{ {
float particlesPerSec = open * 1000.0f; float particlesPerSec = open * 1000.0f;
float emitInterval = 1.0f / particlesPerSec; float emitInterval = 1.0f / particlesPerSec;
@@ -568,7 +568,7 @@ namespace Barotrauma
return (isHorizontal ? sections[sectionIndex].rect.Width : sections[sectionIndex].rect.Height); return (isHorizontal ? sections[sectionIndex].rect.Width : sections[sectionIndex].rect.Height);
} }
public void AddDamage(int sectionIndex, float damage, IDamageable attacker=null) public void AddDamage(int sectionIndex, float damage, Character attacker = null)
{ {
if (!prefab.Body || prefab.Platform) return; if (!prefab.Body || prefab.Platform) return;
@@ -689,7 +689,7 @@ namespace Barotrauma
return new AttackResult(damageAmount, 0.0f); return new AttackResult(damageAmount, 0.0f);
} }
private void SetDamage(int sectionIndex, float damage, IDamageable attacker=null) private void SetDamage(int sectionIndex, float damage, Character attacker = null)
{ {
if (Submarine != null && Submarine.GodMode) return; if (Submarine != null && Submarine.GodMode) return;
if (!prefab.Body) return; if (!prefab.Body) return;
@@ -701,10 +701,26 @@ namespace Barotrauma
GameMain.Server.CreateEntityEvent(this); GameMain.Server.CreateEntityEvent(this);
} }
bool noGaps = true;
for (int i = 0; i < sections.Length; i++)
{
if (i != sectionIndex && SectionIsLeaking(i))
{
noGaps = false;
break;
}
}
if (damage < prefab.Health * LeakThreshold) if (damage < prefab.Health * LeakThreshold)
{ {
if (sections[sectionIndex].gap != null) if (sections[sectionIndex].gap != null)
{ {
//the structure doesn't have any other gap, log the structure being fixed
if (noGaps && attacker != null)
{
GameServer.Log((sections[sectionIndex].gap.IsRoomToRoom ? "Inner" : "Outer") + " wall repaired by " + attacker.Name, ServerLog.MessageType.ItemInteraction);
}
//remove existing gap if damage is below 50% //remove existing gap if damage is below 50%
sections[sectionIndex].gap.Remove(); sections[sectionIndex].gap.Remove();
sections[sectionIndex].gap = null; sections[sectionIndex].gap = null;
@@ -715,8 +731,10 @@ namespace Barotrauma
} }
else else
{ {
if (sections[sectionIndex].gap == null) if (sections[sectionIndex].gap == null)
{ {
Rectangle gapRect = sections[sectionIndex].rect; Rectangle gapRect = sections[sectionIndex].rect;
gapRect.X -= 10; gapRect.X -= 10;
gapRect.Y += 10; gapRect.Y += 10;
@@ -725,6 +743,12 @@ namespace Barotrauma
sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal, Submarine); sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal, Submarine);
sections[sectionIndex].gap.ConnectedWall = this; sections[sectionIndex].gap.ConnectedWall = this;
//AdjustKarma(attacker, 300); //AdjustKarma(attacker, 300);
//the structure didn't have any other gaps yet, log the breach
if (noGaps && attacker != null)
{
GameServer.Log((sections[sectionIndex].gap.IsRoomToRoom ? "Inner" : "Outer") + " wall breached by " + attacker.Name, ServerLog.MessageType.ItemInteraction);
}
#if CLIENT #if CLIENT
if (CastShadow) GenerateConvexHull(); if (CastShadow) GenerateConvexHull();
#endif #endif
@@ -744,7 +768,7 @@ namespace Barotrauma
bool hasHole = SectionBodyDisabled(sectionIndex); bool hasHole = SectionBodyDisabled(sectionIndex);
if (hadHole == hasHole) return; if (hadHole == hasHole) return;
//if (hasHole) Explosion.ApplyExplosionForces(sections[sectionIndex].gap.WorldPosition, 500.0f, 5.0f, 0.0f, 0.0f);
UpdateSections(); UpdateSections();
} }
@@ -186,7 +186,7 @@ namespace Barotrauma
if (propertyValue == null) if (propertyValue == null)
{ {
DebugConsole.ThrowError("Couldn't compare " + Value.ToString() + " (" + Value.GetType() + ") to property \"" + property.Name + "- property.GetValue() returns null!!"); DebugConsole.ThrowError("Couldn't compare " + Value.ToString() + " (" + Value.GetType() + ") to property \"" + property.Name + "\" - property.GetValue() returns null!");
return false; return false;
} }