From 3e972b501a70882a7f3758e4ba009201e1289b12 Mon Sep 17 00:00:00 2001 From: moneyl <8206401+Moneyl@users.noreply.github.com> Date: Tue, 24 Sep 2019 03:54:24 -0400 Subject: [PATCH] Fix explosives (#361) Currently explosives do no damage to tiles or damage the wrong area of the map. This is because `Owner.Delete` is called before the adjacent tiles / entities are damaged. This results in the explosives grid always being 0, and it's position always being (0, 0), meaning that the tiles in range of the explosive are not properly calculated. This fixes that (Issue #358). --- .../GameObjects/Components/Explosion/ExplosiveComponent.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs b/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs index d1f6f0e1f3..f091f32246 100644 --- a/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs +++ b/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs @@ -38,6 +38,7 @@ namespace Content.Server.GameObjects.Components.Explosive public int LightImpactRange = 0; public int FlashRange = 0; + private bool _beingExploded = false; public override void ExposeData(ObjectSerializer serializer) { @@ -51,13 +52,16 @@ namespace Content.Server.GameObjects.Components.Explosive private bool Explosion() { + //Prevent adjacent explosives from infinitely blowing each other up. + if (_beingExploded) return true; + _beingExploded = true; + var maxRange = MathHelper.Max(DevastationRange, HeavyImpactRange, LightImpactRange, 0f); //Entity damage calculation var entitiesAll = _serverEntityManager.GetEntitiesInRange(Owner.Transform.GridPosition, maxRange).ToList(); foreach (var entity in entitiesAll) { - Owner.Delete(); if (entity == Owner) continue; if (!entity.Transform.IsMapTransform) @@ -162,6 +166,7 @@ namespace Content.Server.GameObjects.Components.Explosive } } + Owner.Delete(); return true; }