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

@@ -7,6 +7,7 @@ using Content.Server.UserInterface;
using Content.Shared.ActionBlocker;
using Content.Shared.Arcade;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.NetIDs;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -49,15 +50,11 @@ namespace Content.Server.Arcade.Components
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if(!eventArgs.User.TryGetComponent(out ActorComponent? actor))
{
if(!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor))
return;
}
if (!Powered)
{
if(!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User))
return;
}
if(!ActionBlockerSystem.CanInteract(actor.PlayerSession.AttachedEntity)) return;
UserInterface?.Toggle(actor.PlayerSession);
RegisterPlayerSession(actor.PlayerSession);
@@ -134,7 +131,8 @@ namespace Content.Server.Arcade.Components
case BlockGameMessages.BlockGamePlayerActionMessage playerActionMessage:
if (obj.Session != _player) break;
if (!ActionBlockerSystem.CanInteract(Owner))
// TODO: Should this check if the Owner can interact...?
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(Owner))
{
DeactivePlayer(obj.Session);
break;

View File

@@ -7,6 +7,7 @@ using Content.Server.Wires.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Arcade;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Wires;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -58,15 +59,11 @@ namespace Content.Server.Arcade.Components
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if(!eventArgs.User.TryGetComponent(out ActorComponent? actor))
{
if(!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor))
return;
}
if (!Powered)
{
if(!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User))
return;
}
if(!ActionBlockerSystem.CanInteract(actor.PlayerSession.AttachedEntity)) return;
_game ??= new SpaceVillainGame(this);