From 190612a350ab103a6e90d32414df70aa6ef3731e Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Tue, 9 Nov 2021 13:21:52 +0100 Subject: [PATCH] ActionBlocker CanSpeak uses EntityUid exclusively --- Content.Server/Actions/Actions/ScreamAction.cs | 2 +- Content.Server/Chat/Managers/ChatManager.cs | 2 +- .../ActionBlocker/ActionBlockerSystem.cs | 15 +++++---------- Content.Shared/Speech/SpeakAttemptEvent.cs | 6 +++--- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Content.Server/Actions/Actions/ScreamAction.cs b/Content.Server/Actions/Actions/ScreamAction.cs index 3a18731d17..ee3e6952e8 100644 --- a/Content.Server/Actions/Actions/ScreamAction.cs +++ b/Content.Server/Actions/Actions/ScreamAction.cs @@ -41,7 +41,7 @@ namespace Content.Server.Actions.Actions public void DoInstantAction(InstantActionEventArgs args) { - if (!EntitySystem.Get().CanSpeak(args.Performer)) return; + if (!EntitySystem.Get().CanSpeak(args.Performer.Uid)) return; if (!args.Performer.TryGetComponent(out var humanoid)) return; if (!args.Performer.TryGetComponent(out var actions)) return; diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 917a27213b..1e297cfca8 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -110,7 +110,7 @@ namespace Content.Server.Chat.Managers public void EntitySay(IEntity source, string message) { - if (!EntitySystem.Get().CanSpeak(source)) + if (!EntitySystem.Get().CanSpeak(source.Uid)) { return; } diff --git a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs index f9c9858ec8..24b174f0a4 100644 --- a/Content.Shared/ActionBlocker/ActionBlockerSystem.cs +++ b/Content.Shared/ActionBlocker/ActionBlockerSystem.cs @@ -60,18 +60,13 @@ namespace Content.Shared.ActionBlocker return !ev.Cancelled; } - public bool CanSpeak(IEntity entity) - { - var ev = new SpeakAttemptEvent(entity); - - RaiseLocalEvent(entity.Uid, ev); - - return !ev.Cancelled; - } - public bool CanSpeak(EntityUid uid) { - return CanSpeak(EntityManager.GetEntity(uid)); + var ev = new SpeakAttemptEvent(uid); + + RaiseLocalEvent(uid, ev); + + return !ev.Cancelled; } public bool CanDrop(IEntity entity) diff --git a/Content.Shared/Speech/SpeakAttemptEvent.cs b/Content.Shared/Speech/SpeakAttemptEvent.cs index 7863781c1f..b710a2ec6e 100644 --- a/Content.Shared/Speech/SpeakAttemptEvent.cs +++ b/Content.Shared/Speech/SpeakAttemptEvent.cs @@ -4,11 +4,11 @@ namespace Content.Shared.Speech { public class SpeakAttemptEvent : CancellableEntityEventArgs { - public SpeakAttemptEvent(IEntity entity) + public SpeakAttemptEvent(EntityUid uid) { - Entity = entity; + Uid = uid; } - public IEntity Entity { get; } + public EntityUid Uid { get; } } }