Deprecate IActionBlocker in favour of cancellable events (#4193)

* Deprecate IActionBlocker in favour of cancellable events

* Bring back old speech/emoting component restrictions

* Rename action blocker listener methods

* Use Entity System public methods instead of extension methods

Co-authored-by: Vera Aguilera Puerto <gradientvera@outlook.com>
This commit is contained in:
DrSmugleaf
2021-06-19 10:03:24 +02:00
committed by GitHub
parent e1e54e9cb1
commit 9b8185db23
98 changed files with 673 additions and 365 deletions

View File

@@ -11,8 +11,8 @@ using Content.Shared.Actions.Behaviors;
using Content.Shared.Actions.Components;
using Content.Shared.Audio;
using Content.Shared.Cooldown;
using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -57,7 +57,7 @@ namespace Content.Server.Actions.Actions
}
if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return;
if (args.Target == args.Performer || !args.Performer.CanAttack()) return;
if (args.Target == args.Performer || !EntitySystem.Get<ActionBlockerSystem>().CanAttack(args.Performer)) return;
var random = IoCManager.Resolve<IRobustRandom>();
var audio = EntitySystem.Get<AudioSystem>();

View File

@@ -8,8 +8,10 @@ using Content.Shared.Actions.Components;
using Content.Shared.Audio;
using Content.Shared.CharacterAppearance;
using Content.Shared.Cooldown;
using Content.Shared.Speech;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Player;
using Robust.Shared.Random;
@@ -40,7 +42,7 @@ namespace Content.Server.Actions.Actions
public void DoInstantAction(InstantActionEventArgs args)
{
if (!ActionBlockerSystem.CanSpeak(args.Performer)) return;
if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(args.Performer)) return;
if (!args.Performer.TryGetComponent<HumanoidAppearanceComponent>(out var humanoid)) return;
if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return;

View File

@@ -4,6 +4,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Actions;
using Content.Shared.Actions.Components;
using Content.Shared.Actions.Prototypes;
using Content.Shared.Interaction.Events;
using Robust.Server.GameObjects;
using Robust.Server.GameStates;
using Robust.Shared.GameObjects;
@@ -186,7 +187,7 @@ namespace Content.Server.Actions
return false;
}
if (!ActionBlockerSystem.CanChangeDirection(player)) return true;
if (!EntitySystem.Get<ActionBlockerSystem>().CanChangeDirection(player)) return true;
// don't set facing unless they clicked far enough away
var diff = targetWorldPos - player.Transform.WorldPosition;