From 5f02daec4e3344553a035418414025e603440322 Mon Sep 17 00:00:00 2001 From: wrexbe <81056464+wrexbe@users.noreply.github.com> Date: Fri, 26 Nov 2021 03:32:22 -0800 Subject: [PATCH] Fix explosions with same source, and target pos (#5530) * Fix explosions with same source, and target pos * Using for Robust.Shared.Maths, Removed whitespace * Don't throw in explosion if the offset is zero --- .../Explosion/Components/ExplosionLaunchedComponent.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Content.Server/Explosion/Components/ExplosionLaunchedComponent.cs b/Content.Server/Explosion/Components/ExplosionLaunchedComponent.cs index 3164e8f856..d71ccba148 100644 --- a/Content.Server/Explosion/Components/ExplosionLaunchedComponent.cs +++ b/Content.Server/Explosion/Components/ExplosionLaunchedComponent.cs @@ -1,6 +1,7 @@ using Content.Server.Throwing; using Content.Shared.Acts; using Robust.Shared.GameObjects; +using Robust.Shared.Maths; namespace Content.Server.Explosion.Components { @@ -19,7 +20,12 @@ namespace Content.Server.Explosion.Components if (sourceLocation.Equals(targetLocation)) return; - var direction = (targetLocation.ToMapPos(Owner.EntityManager) - sourceLocation.ToMapPos(Owner.EntityManager)).Normalized; + var offset = (targetLocation.ToMapPos(Owner.EntityManager) - sourceLocation.ToMapPos(Owner.EntityManager)); + + //Don't throw if the direction is center (0,0) + if (offset == Vector2.Zero) return; + + var direction = offset.Normalized; var throwForce = eventArgs.Severity switch {