Better weightless yeeting and movement (#3573)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float PushStrength { get; set; }
|
||||
public float PushStrength { get; set; } = 0.4f;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
|
||||
@@ -6,6 +6,7 @@ using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.Components.Stack;
|
||||
using Content.Server.GameObjects.EntitySystems.Click;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Interfaces;
|
||||
@@ -180,8 +181,17 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
if (direction == Vector2.Zero) return true;
|
||||
|
||||
direction = direction.Normalized * MathF.Min(direction.Length, 8.0f);
|
||||
var yeet = direction * ThrowForce * 15;
|
||||
|
||||
throwEnt.TryThrow(direction * ThrowForce * 15, playerEnt);
|
||||
// Softer yeet in weightlessness
|
||||
if (playerEnt.IsWeightless())
|
||||
{
|
||||
throwEnt.TryThrow(yeet / 4, playerEnt, 10.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
throwEnt.TryThrow(yeet, playerEnt);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Shared.GameObjects.Components.Movement
|
||||
[DataField("grabRange")]
|
||||
private float _grabRange = 0.2f;
|
||||
[DataField("pushStrength")]
|
||||
private float _pushStrength = 600.0f;
|
||||
private float _pushStrength = 0.4f;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public EntityCoordinates LastPosition { get; set; }
|
||||
|
||||
@@ -83,6 +83,11 @@ namespace Content.Shared.Physics.Controllers
|
||||
// Target velocity.
|
||||
var total = (walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed);
|
||||
|
||||
if (weightless)
|
||||
{
|
||||
total *= mobMover.PushStrength;
|
||||
}
|
||||
|
||||
if (total != Vector2.Zero)
|
||||
{
|
||||
// This should have its event run during island solver soooo
|
||||
|
||||
Reference in New Issue
Block a user