Don't pushback when throwing while buckled (#4232)
* Don't pushback when throwing while buckled * Address reviews * Fix
This commit is contained in:
@@ -53,9 +53,15 @@ namespace Content.Server.Throwing
|
|||||||
physicsComponent.ApplyLinearImpulse(direction);
|
physicsComponent.ApplyLinearImpulse(direction);
|
||||||
// Give thrower an impulse in the other direction
|
// Give thrower an impulse in the other direction
|
||||||
if (user != null && pushbackRatio > 0.0f && user.TryGetComponent(out IPhysBody? body))
|
if (user != null && pushbackRatio > 0.0f && user.TryGetComponent(out IPhysBody? body))
|
||||||
|
{
|
||||||
|
var msg = new ThrowPushbackAttemptEvent();
|
||||||
|
body.Owner.EntityManager.EventBus.RaiseLocalEvent(body.Owner.Uid, msg);
|
||||||
|
|
||||||
|
if (!msg.Cancelled)
|
||||||
{
|
{
|
||||||
body.ApplyLinearImpulse(-direction * pushbackRatio);
|
body.ApplyLinearImpulse(-direction * pushbackRatio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
using Content.Shared.Standing;
|
using Content.Shared.Standing;
|
||||||
|
using Content.Shared.Throwing;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics.Dynamics;
|
using Robust.Shared.Physics.Dynamics;
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ namespace Content.Shared.Buckle
|
|||||||
SubscribeLocalEvent<SharedBuckleComponent, PreventCollideEvent>(PreventCollision);
|
SubscribeLocalEvent<SharedBuckleComponent, PreventCollideEvent>(PreventCollision);
|
||||||
SubscribeLocalEvent<SharedBuckleComponent, DownAttemptEvent>(HandleDown);
|
SubscribeLocalEvent<SharedBuckleComponent, DownAttemptEvent>(HandleDown);
|
||||||
SubscribeLocalEvent<SharedBuckleComponent, StandAttemptEvent>(HandleStand);
|
SubscribeLocalEvent<SharedBuckleComponent, StandAttemptEvent>(HandleStand);
|
||||||
|
SubscribeLocalEvent<SharedBuckleComponent, ThrowPushbackAttemptEvent>(HandleThrowPushback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleStand(EntityUid uid, SharedBuckleComponent component, StandAttemptEvent args)
|
private void HandleStand(EntityUid uid, SharedBuckleComponent component, StandAttemptEvent args)
|
||||||
@@ -31,6 +33,12 @@ namespace Content.Shared.Buckle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleThrowPushback(EntityUid uid, SharedBuckleComponent component, ThrowPushbackAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (!component.Buckled) return;
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
private void PreventCollision(EntityUid uid, SharedBuckleComponent component, PreventCollideEvent args)
|
private void PreventCollision(EntityUid uid, SharedBuckleComponent component, PreventCollideEvent args)
|
||||||
{
|
{
|
||||||
if (args.BodyB.Owner.Uid != component.LastEntityBuckledTo) return;
|
if (args.BodyB.Owner.Uid != component.LastEntityBuckledTo) return;
|
||||||
|
|||||||
@@ -11,4 +11,9 @@ namespace Content.Shared.Throwing
|
|||||||
|
|
||||||
public IEntity Entity { get; }
|
public IEntity Entity { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised when we try to pushback an entity from throwing
|
||||||
|
/// </summary>
|
||||||
|
public sealed class ThrowPushbackAttemptEvent : CancellableEntityEventArgs {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user