ActionBlocker CanSpeak uses EntityUid exclusively

This commit is contained in:
Vera Aguilera Puerto
2021-11-09 13:21:52 +01:00
parent c68c3219f8
commit 190612a350
4 changed files with 10 additions and 15 deletions

View File

@@ -41,7 +41,7 @@ namespace Content.Server.Actions.Actions
public void DoInstantAction(InstantActionEventArgs args) public void DoInstantAction(InstantActionEventArgs args)
{ {
if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(args.Performer)) return; if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(args.Performer.Uid)) return;
if (!args.Performer.TryGetComponent<HumanoidAppearanceComponent>(out var humanoid)) return; if (!args.Performer.TryGetComponent<HumanoidAppearanceComponent>(out var humanoid)) return;
if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return; if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return;

View File

@@ -110,7 +110,7 @@ namespace Content.Server.Chat.Managers
public void EntitySay(IEntity source, string message) public void EntitySay(IEntity source, string message)
{ {
if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(source)) if (!EntitySystem.Get<ActionBlockerSystem>().CanSpeak(source.Uid))
{ {
return; return;
} }

View File

@@ -60,18 +60,13 @@ namespace Content.Shared.ActionBlocker
return !ev.Cancelled; 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) 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) public bool CanDrop(IEntity entity)

View File

@@ -4,11 +4,11 @@ namespace Content.Shared.Speech
{ {
public class SpeakAttemptEvent : CancellableEntityEventArgs public class SpeakAttemptEvent : CancellableEntityEventArgs
{ {
public SpeakAttemptEvent(IEntity entity) public SpeakAttemptEvent(EntityUid uid)
{ {
Entity = entity; Uid = uid;
} }
public IEntity Entity { get; } public EntityUid Uid { get; }
} }
} }