diff --git a/Content.Client/MobState/MobStateComponent.cs b/Content.Client/MobState/MobStateComponent.cs index caa215c0c1..55d67780ef 100644 --- a/Content.Client/MobState/MobStateComponent.cs +++ b/Content.Client/MobState/MobStateComponent.cs @@ -1,4 +1,5 @@ using Content.Shared.MobState; +using Content.Shared.MobState.Components; using Content.Shared.MobState.State; using Robust.Shared.GameObjects; diff --git a/Content.Server/MobState/States/MobStateManager.cs b/Content.Server/MobState/States/MobStateManager.cs index 3e607b46e2..ac15fba39a 100644 --- a/Content.Server/MobState/States/MobStateManager.cs +++ b/Content.Server/MobState/States/MobStateManager.cs @@ -1,4 +1,5 @@ using Content.Shared.MobState; +using Content.Shared.MobState.Components; using Content.Shared.MobState.State; using Robust.Shared.GameObjects; diff --git a/Content.Shared/MobState/State/SharedMobStateComponent.cs b/Content.Shared/MobState/Components/SharedMobStateComponent.cs similarity index 99% rename from Content.Shared/MobState/State/SharedMobStateComponent.cs rename to Content.Shared/MobState/Components/SharedMobStateComponent.cs index c9bfe76b69..ffc8112549 100644 --- a/Content.Shared/MobState/State/SharedMobStateComponent.cs +++ b/Content.Shared/MobState/Components/SharedMobStateComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Alert; using Content.Shared.Damage; using Content.Shared.Damage.Components; +using Content.Shared.MobState.State; using Content.Shared.NetIDs; using Robust.Shared.GameObjects; using Robust.Shared.Players; @@ -14,7 +15,7 @@ using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; -namespace Content.Shared.MobState.State +namespace Content.Shared.MobState.Components { /// /// When attached to an , diff --git a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs new file mode 100644 index 0000000000..6db4899389 --- /dev/null +++ b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs @@ -0,0 +1,22 @@ +using Content.Shared.MobState.Components; +using Content.Shared.Pulling.Events; +using Robust.Shared.GameObjects; + +namespace Content.Shared.MobState.EntitySystems +{ + public class SharedMobStateSystem : EntitySystem + { + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnStartPullAttempt); + } + + private void OnStartPullAttempt(EntityUid uid, SharedMobStateComponent component, StartPullAttemptEvent args) + { + if(component.IsIncapacitated()) + args.Cancel(); + } + } +} diff --git a/Content.Shared/Pulling/Components/SharedPullableComponent.cs b/Content.Shared/Pulling/Components/SharedPullableComponent.cs index 0ed2464601..d5c7c9e066 100644 --- a/Content.Shared/Pulling/Components/SharedPullableComponent.cs +++ b/Content.Shared/Pulling/Components/SharedPullableComponent.cs @@ -204,6 +204,11 @@ namespace Content.Shared.Pulling.Components return false; } + if (!EntitySystem.Get().CanPull(puller, Owner)) + { + return false; + } + if (_physics == null) { return false; diff --git a/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs b/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs new file mode 100644 index 0000000000..a45e289b7a --- /dev/null +++ b/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs @@ -0,0 +1,19 @@ +using Robust.Shared.GameObjects; + +namespace Content.Shared.Pulling.Events +{ + /// + /// Directed event raised on the puller to see if it can start pulling something. + /// + public class StartPullAttemptEvent : CancellableEntityEventArgs + { + public StartPullAttemptEvent(IEntity puller, IEntity pulled) + { + Puller = puller; + Pulled = pulled; + } + + public IEntity Puller { get; } + public IEntity Pulled { get; } + } +} diff --git a/Content.Shared/Pulling/SharedPullingSystem.cs b/Content.Shared/Pulling/SharedPullingSystem.cs index 40374f3756..efe4d2b1d5 100644 --- a/Content.Shared/Pulling/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/SharedPullingSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.GameTicking; using Content.Shared.Input; using Content.Shared.Physics.Pull; using Content.Shared.Pulling.Components; +using Content.Shared.Pulling.Events; using Content.Shared.Rotatable; using JetBrains.Annotations; using Robust.Shared.Containers; @@ -237,5 +238,12 @@ namespace Content.Shared.Pulling pulled.Transform.WorldRotation = newAngle; } } + + public bool CanPull(IEntity puller, IEntity pulled) + { + var startPull = new StartPullAttemptEvent(puller, pulled); + RaiseLocalEvent(puller.Uid, startPull); + return !startPull.Cancelled; + } } }