Actionblocker cleanup (#11371)

Doesn't fix the CanInteract shenanigans but fixed an unnecessary cast + removed a bunch of broadcasts.
This commit is contained in:
metalgearsloth
2022-09-17 15:29:01 +10:00
committed by GitHub
parent c380577156
commit 6ac4c38263

View File

@@ -43,8 +43,8 @@ namespace Content.Shared.ActionBlocker
var ev = new UpdateCanMoveEvent(uid);
RaiseLocalEvent(uid, ev);
if (component.CanMove == ev.Cancelled && component is Component comp)
Dirty(comp);
if (component.CanMove == ev.Cancelled)
Dirty(component);
component.CanMove = !ev.Cancelled;
return !ev.Cancelled;
@@ -64,7 +64,7 @@ namespace Content.Shared.ActionBlocker
public bool CanInteract(EntityUid user, EntityUid? target)
{
var ev = new InteractionAttemptEvent(user, target);
RaiseLocalEvent(user, ev, true);
RaiseLocalEvent(user, ev);
if (ev.Cancelled)
return false;
@@ -73,7 +73,7 @@ namespace Content.Shared.ActionBlocker
return true;
var targetEv = new GettingInteractedWithAttemptEvent(user, target);
RaiseLocalEvent(target.Value, targetEv, true);
RaiseLocalEvent(target.Value, targetEv);
if (!targetEv.Cancelled)
InteractWithItem(user, target.Value);
@@ -92,7 +92,7 @@ namespace Content.Shared.ActionBlocker
public bool CanUseHeldEntity(EntityUid user)
{
var ev = new UseAttemptEvent(user);
RaiseLocalEvent(user, ev, true);
RaiseLocalEvent(user, ev);
return !ev.Cancelled;
}
@@ -100,13 +100,14 @@ namespace Content.Shared.ActionBlocker
public bool CanThrow(EntityUid user, EntityUid itemUid)
{
var ev = new ThrowAttemptEvent(user, itemUid);
RaiseLocalEvent(user, ev, true);
RaiseLocalEvent(user, ev);
return !ev.Cancelled;
}
public bool CanSpeak(EntityUid uid)
{
// This one is used as broadcast
var ev = new SpeakAttemptEvent(uid);
RaiseLocalEvent(uid, ev, true);
@@ -116,7 +117,7 @@ namespace Content.Shared.ActionBlocker
public bool CanDrop(EntityUid uid)
{
var ev = new DropAttemptEvent(uid);
RaiseLocalEvent(uid, ev, true);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
}
@@ -124,13 +125,13 @@ namespace Content.Shared.ActionBlocker
public bool CanPickup(EntityUid user, EntityUid item)
{
var userEv = new PickupAttemptEvent(user, item);
RaiseLocalEvent(user, userEv, false);
RaiseLocalEvent(user, userEv);
if (userEv.Cancelled)
return false;
var itemEv = new GettingPickedUpAttemptEvent(user, item);
RaiseLocalEvent(item, itemEv, false);
RaiseLocalEvent(item, itemEv);
if (!itemEv.Cancelled)
InteractWithItem(user, item);
@@ -141,6 +142,7 @@ namespace Content.Shared.ActionBlocker
public bool CanEmote(EntityUid uid)
{
// This one is used as broadcast
var ev = new EmoteAttemptEvent(uid);
RaiseLocalEvent(uid, ev, true);
@@ -150,7 +152,7 @@ namespace Content.Shared.ActionBlocker
public bool CanAttack(EntityUid uid, EntityUid? target = null)
{
var ev = new AttackAttemptEvent(uid, target);
RaiseLocalEvent(uid, ev, true);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
}
@@ -158,7 +160,7 @@ namespace Content.Shared.ActionBlocker
public bool CanChangeDirection(EntityUid uid)
{
var ev = new ChangeDirectionAttemptEvent(uid);
RaiseLocalEvent(uid, ev, true);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
}
@@ -166,7 +168,7 @@ namespace Content.Shared.ActionBlocker
public bool CanShiver(EntityUid uid)
{
var ev = new ShiverAttemptEvent(uid);
RaiseLocalEvent(uid, ev, true);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
}
@@ -174,7 +176,7 @@ namespace Content.Shared.ActionBlocker
public bool CanSweat(EntityUid uid)
{
var ev = new SweatAttemptEvent(uid);
RaiseLocalEvent(uid, ev, true);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
}