Add BreakOnDistance to DoAfterEventArgs (#8902)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user