Better weightless yeeting and movement (#3573)

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2021-03-08 12:10:56 +11:00
committed by GitHub
parent fcb3498bba
commit 6f3860201c
5 changed files with 26 additions and 4 deletions

View File

@@ -17,7 +17,9 @@ namespace Content.Server.GameObjects.Components.Items
/// </summary>
/// <param name="entity"></param>
/// <param name="direction">Will use the vector's magnitude as the strength of the impulse</param>
internal static void TryThrow(this IEntity entity, Vector2 direction, IEntity? user = null)
/// <param name="user"></param>
/// <param name="pushbackRatio">The ratio of impulse applied to the thrower</param>
internal static void TryThrow(this IEntity entity, Vector2 direction, IEntity? user = null, float pushbackRatio = 1.0f)
{
if (direction == Vector2.Zero || !entity.TryGetComponent(out PhysicsComponent? physicsComponent))
{
@@ -45,6 +47,11 @@ namespace Content.Server.GameObjects.Components.Items
}
physicsComponent.ApplyLinearImpulse(direction);
// Give thrower an impulse in the other direction
if (user != null && pushbackRatio > 0.0f && user.TryGetComponent(out IPhysBody? body))
{
body.ApplyLinearImpulse(-direction * pushbackRatio);
}
}
}
}