diff --git a/Content.Server/Throwing/ThrowHelper.cs b/Content.Server/Throwing/ThrowHelper.cs index c188b41aba..52145f357b 100644 --- a/Content.Server/Throwing/ThrowHelper.cs +++ b/Content.Server/Throwing/ThrowHelper.cs @@ -54,7 +54,13 @@ namespace Content.Server.Throwing // Give thrower an impulse in the other direction if (user != null && pushbackRatio > 0.0f && user.TryGetComponent(out IPhysBody? body)) { - body.ApplyLinearImpulse(-direction * pushbackRatio); + var msg = new ThrowPushbackAttemptEvent(); + body.Owner.EntityManager.EventBus.RaiseLocalEvent(body.Owner.Uid, msg); + + if (!msg.Cancelled) + { + body.ApplyLinearImpulse(-direction * pushbackRatio); + } } } } diff --git a/Content.Shared/Buckle/SharedBuckleSystem.cs b/Content.Shared/Buckle/SharedBuckleSystem.cs index 2072ca2d2d..2363b2b196 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.cs @@ -1,5 +1,6 @@ using Content.Shared.Buckle.Components; using Content.Shared.Standing; +using Content.Shared.Throwing; using Robust.Shared.GameObjects; using Robust.Shared.Physics.Dynamics; @@ -13,6 +14,7 @@ namespace Content.Shared.Buckle SubscribeLocalEvent(PreventCollision); SubscribeLocalEvent(HandleDown); SubscribeLocalEvent(HandleStand); + SubscribeLocalEvent(HandleThrowPushback); } 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) { if (args.BodyB.Owner.Uid != component.LastEntityBuckledTo) return; diff --git a/Content.Shared/Throwing/ThrowAttemptEvent.cs b/Content.Shared/Throwing/ThrowAttemptEvent.cs index a862a8a82e..ba17ab4789 100644 --- a/Content.Shared/Throwing/ThrowAttemptEvent.cs +++ b/Content.Shared/Throwing/ThrowAttemptEvent.cs @@ -11,4 +11,9 @@ namespace Content.Shared.Throwing public IEntity Entity { get; } } + + /// + /// Raised when we try to pushback an entity from throwing + /// + public sealed class ThrowPushbackAttemptEvent : CancellableEntityEventArgs {} }