Add BreakOnDistance to DoAfterEventArgs (#8902)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
themias
2022-07-04 02:56:31 -04:00
committed by GitHub
parent a12245c50e
commit a32c5e543b
3 changed files with 39 additions and 2 deletions

View File

@@ -162,6 +162,30 @@ namespace Content.Server.DoAfter
}
}
if (EventArgs.DistanceThreshold != null)
{
var xformQuery = entityManager.GetEntityQuery<TransformComponent>();
TransformComponent? userXform = null;
// Check user distance to target AND used entities.
if (EventArgs.Target != null && !EventArgs.User.Equals(EventArgs.Target))
{
//recalculate Target location in case Target has also moved
var targetCoordinates = xformQuery.GetComponent(EventArgs.Target.Value).Coordinates;
userXform ??= xformQuery.GetComponent(EventArgs.User);
if (userXform.Coordinates.InRange(entityManager, targetCoordinates, EventArgs.DistanceThreshold.Value))
return true;
}
if (EventArgs.Used != null)
{
var targetCoordinates = xformQuery.GetComponent(EventArgs.Used.Value).Coordinates;
userXform ??= xformQuery.GetComponent(EventArgs.User);
if (!userXform.Coordinates.InRange(entityManager, targetCoordinates, EventArgs.DistanceThreshold.Value))
return true;
}
}
return false;
}