From d1bb33be7821db1e0d6bc0e8d84674d9c158c4a2 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 9 Jan 2018 19:50:55 +0200 Subject: [PATCH] Cutting/repairing holes in walls is logged, fixed gaps emitting drip particles even if there's no water in either hull. Closes #139 --- Barotrauma/BarotraumaClient/Source/Map/Gap.cs | 2 +- .../BarotraumaShared/Source/Map/Structure.cs | 30 +++++++++++++++++-- .../StatusEffects/PropertyConditional.cs | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Map/Gap.cs b/Barotrauma/BarotraumaClient/Source/Map/Gap.cs index c4b879fca..f0208ff20 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Gap.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Gap.cs @@ -78,7 +78,7 @@ namespace Barotrauma } //light dripping - if (open < 0.2f) + if (open < 0.2f && LerpedFlowForce.LengthSquared() > 100.0f) { float particlesPerSec = open * 1000.0f; float emitInterval = 1.0f / particlesPerSec; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs index 3f4c24d93..1332b6e76 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs @@ -568,7 +568,7 @@ namespace Barotrauma 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; @@ -689,7 +689,7 @@ namespace Barotrauma 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 (!prefab.Body) return; @@ -701,10 +701,26 @@ namespace Barotrauma 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 (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% sections[sectionIndex].gap.Remove(); sections[sectionIndex].gap = null; @@ -715,8 +731,10 @@ namespace Barotrauma } else { + if (sections[sectionIndex].gap == null) { + Rectangle gapRect = sections[sectionIndex].rect; gapRect.X -= 10; gapRect.Y += 10; @@ -725,6 +743,12 @@ namespace Barotrauma sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal, Submarine); sections[sectionIndex].gap.ConnectedWall = this; //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 (CastShadow) GenerateConvexHull(); #endif @@ -744,7 +768,7 @@ namespace Barotrauma bool hasHole = SectionBodyDisabled(sectionIndex); if (hadHole == hasHole) return; - //if (hasHole) Explosion.ApplyExplosionForces(sections[sectionIndex].gap.WorldPosition, 500.0f, 5.0f, 0.0f, 0.0f); + UpdateSections(); } diff --git a/Barotrauma/BarotraumaShared/Source/StatusEffects/PropertyConditional.cs b/Barotrauma/BarotraumaShared/Source/StatusEffects/PropertyConditional.cs index 5cf6e8038..04f7da66d 100644 --- a/Barotrauma/BarotraumaShared/Source/StatusEffects/PropertyConditional.cs +++ b/Barotrauma/BarotraumaShared/Source/StatusEffects/PropertyConditional.cs @@ -186,7 +186,7 @@ namespace Barotrauma 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; }