using Content.Shared.ActionBlocker; using Content.Shared.Movement.Events; using Content.Shared.Movement.Pulling.Components; using Content.Shared.Movement.Pulling.Events; using Content.Shared.StatusEffectNew.Components; using Content.Shared.StatusEffectNew; namespace Content.Shared._Offbrand.StatusEffects; public sealed class BlockMovementWhenPulledStatusEffectSystem : EntitySystem { [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnStatusEffectApplied); SubscribeLocalEvent(OnStatusEffectRemoved); SubscribeLocalEvent>(OnUpdateCanMove); SubscribeLocalEvent>(OnPullMessage); SubscribeLocalEvent>(OnPullMessage); } private void OnStatusEffectApplied(Entity ent, ref StatusEffectAppliedEvent args) { _actionBlocker.UpdateCanMove(args.Target); } private void OnStatusEffectRemoved(Entity ent, ref StatusEffectRemovedEvent args) { _actionBlocker.UpdateCanMove(args.Target); } private void OnPullMessage(Entity ent, ref StatusEffectRelayedEvent args) { if (Comp(ent).AppliedTo is not { } target) return; _actionBlocker.UpdateCanMove(target); } private void OnUpdateCanMove(Entity ent, ref StatusEffectRelayedEvent args) { if (Comp(ent).AppliedTo is not { } target) return; if (!TryComp(target, out var pullable) || !pullable.BeingPulled) return; args.Args.Cancel(); } }