diff --git a/Content.Server/Alert/Click/StopBeingPulled.cs b/Content.Server/Alert/Click/StopBeingPulled.cs new file mode 100644 index 0000000000..1daa7e4697 --- /dev/null +++ b/Content.Server/Alert/Click/StopBeingPulled.cs @@ -0,0 +1,20 @@ +using Content.Shared.Alert; +using Content.Shared.GameObjects.Components.Pulling; +using JetBrains.Annotations; +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Server.Alert.Click +{ + /// + /// Stop pulling something + /// + [UsedImplicitly] + [DataDefinition] + public class StopBeingPulled : IAlertClick + { + public void AlertClicked(ClickAlertEventArgs args) + { + args.Player.GetComponentOrNull()?.TryStopPull(); + } + } +} diff --git a/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs b/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs index ceaf4ae20e..ab7b9b69ac 100644 --- a/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs +++ b/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs @@ -2,7 +2,9 @@ using System; using Content.Shared.Alert; using Content.Shared.GameObjects.Components.Mobs; +using Content.Shared.GameObjects.Components.Movement; using Content.Shared.GameObjects.EntitySystems; +using Content.Shared.GameObjects.EntitySystems.ActionBlocker; using Content.Shared.Physics; using Content.Shared.Physics.Pull; using Robust.Shared.Containers; @@ -16,7 +18,7 @@ using Robust.Shared.Serialization; namespace Content.Shared.GameObjects.Components.Pulling { - public abstract class SharedPullableComponent : Component, ICollideSpecial + public abstract class SharedPullableComponent : Component, ICollideSpecial, IRelayMoveInput { public override string Name => "Pullable"; public override uint? NetID => ContentNetIDs.PULLABLE; @@ -331,15 +333,6 @@ namespace Content.Shared.GameObjects.Components.Pulling } } - private void OnClickAlert(ClickAlertEventArgs args) - { - EntitySystem - .Get() - .GetPulled(args.Player)? - .GetComponentOrNull()? - .TryStopPull(); - } - public override void OnRemove() { TryStopPull(); @@ -356,6 +349,14 @@ namespace Content.Shared.GameObjects.Components.Pulling return (_physics.CollisionLayer & collidedWith.CollisionMask) == (int) CollisionGroup.MobImpassable; } + + // TODO: Need a component bus relay so all entities can use this and not just players + void IRelayMoveInput.MoveInputPressed(ICommonSession session) + { + var entity = session.AttachedEntity; + if (entity == null || !ActionBlockerSystem.CanMove(entity)) return; + TryStopPull(); + } } [Serializable, NetSerializable] diff --git a/Content.Shared/GameObjects/Components/Pulling/SharedPullerComponent.cs b/Content.Shared/GameObjects/Components/Pulling/SharedPullerComponent.cs index 3be78d4400..54a086c493 100644 --- a/Content.Shared/GameObjects/Components/Pulling/SharedPullerComponent.cs +++ b/Content.Shared/GameObjects/Components/Pulling/SharedPullerComponent.cs @@ -74,14 +74,5 @@ namespace Content.Shared.GameObjects.Components.Pulling break; } } - - private void OnClickAlert(ClickAlertEventArgs args) - { - EntitySystem - .Get() - .GetPulled(args.Player)? - .GetComponentOrNull()? - .TryStopPull(); - } } } diff --git a/Resources/Prototypes/Alerts/alerts.yml b/Resources/Prototypes/Alerts/alerts.yml index 402b232231..7729cc82a7 100644 --- a/Resources/Prototypes/Alerts/alerts.yml +++ b/Resources/Prototypes/Alerts/alerts.yml @@ -185,6 +185,7 @@ - type: alert alertType: Pulled icon: /Textures/Interface/Alerts/Pull/pulled.png + onClick: !type:StopBeingPulled { } name: Pulled description: You're being pulled. Move to break free.