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
This commit is contained in:
wrexbe
2021-11-26 03:32:22 -08:00
committed by GitHub
parent 85ea135ad4
commit 5f02daec4e

View File

@@ -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
{