Fix some action-blocker bugs (#6050)

This commit is contained in:
Leon Friedrich
2022-01-08 00:57:20 +13:00
committed by GitHub
parent c29489ff4d
commit 2f3b6fb28e
3 changed files with 23 additions and 10 deletions

View File

@@ -8,13 +8,13 @@ namespace Content.Shared.Emoting
{
base.Initialize();
SubscribeLocalEvent<SharedEmotingComponent, EmoteAttemptEvent>(OnEmoteAttempt);
SubscribeLocalEvent<EmoteAttemptEvent>(OnEmoteAttempt);
}
private void OnEmoteAttempt(EntityUid entity, SharedEmotingComponent component, EmoteAttemptEvent ev)
private void OnEmoteAttempt(EmoteAttemptEvent args)
{
if (!component.Enabled)
ev.Cancel();
if (!TryComp(args.Uid, out SharedEmotingComponent? emote) || !emote.Enabled)
args.Cancel();
}
}
}

View File

@@ -1,12 +1,10 @@
using System;
using Content.Shared.DragDrop;
using Content.Shared.Emoting;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Movement;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Shared.PAI
{
@@ -29,6 +27,21 @@ namespace Content.Shared.PAI
SubscribeLocalEvent<PAIComponent, AttackAttemptEvent>(OnAttackAttempt);
SubscribeLocalEvent<PAIComponent, DropAttemptEvent>(OnDropAttempt);
SubscribeLocalEvent<PAIComponent, PickupAttemptEvent>(OnPickupAttempt);
SubscribeLocalEvent<PAIComponent, MovementAttemptEvent>(OnMoveAttempt);
SubscribeLocalEvent<PAIComponent, ChangeDirectionAttemptEvent>(OnChangeDirectionAttempt);
}
private void OnMoveAttempt(EntityUid uid, PAIComponent component, MovementAttemptEvent args)
{
args.Cancel(); // no more scurrying around on lil robot legs.
}
private void OnChangeDirectionAttempt(EntityUid uid, PAIComponent component, ChangeDirectionAttemptEvent args)
{
// PAIs can't rotate, but decapitated heads and sentient crowbars can, life isn't fair. Seriously though, why
// tf does this have to be actively blocked, surely this should just not be blanket enabled for any player
// controlled entity. Same goes for moving really.
args.Cancel();
}
private void OnUseAttempt(EntityUid uid, PAIComponent component, UseAttemptEvent args)

View File

@@ -8,12 +8,12 @@ namespace Content.Shared.Speech
{
base.Initialize();
SubscribeLocalEvent<SharedSpeechComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<SpeakAttemptEvent>(OnSpeakAttempt);
}
private void OnSpeakAttempt(EntityUid uid, SharedSpeechComponent component, SpeakAttemptEvent args)
private void OnSpeakAttempt(SpeakAttemptEvent args)
{
if (!component.Enabled)
if (!TryComp(args.Uid, out SharedSpeechComponent? speech) || !speech.Enabled)
args.Cancel();
}
}