Fix magboot mispredict (#7385)

This commit is contained in:
Leon Friedrich
2022-04-02 16:08:39 +13:00
committed by GitHub
parent 37ccf590d6
commit 971eb5b87e
3 changed files with 27 additions and 30 deletions

View File

@@ -1,5 +1,7 @@
using Content.Shared.Actions;
using Content.Shared.Slippery;
using Content.Shared.Toggleable;
using Content.Shared.Verbs;
namespace Content.Shared.Clothing;
@@ -9,10 +11,30 @@ public abstract class SharedMagbootsSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<SharedMagbootsComponent, GetVerbsEvent<ActivationVerb>>(AddToggleVerb);
SubscribeLocalEvent<SharedMagbootsComponent, SlipAttemptEvent>(OnSlipAttempt);
SubscribeLocalEvent<SharedMagbootsComponent, GetActionsEvent>(OnGetActions);
SubscribeLocalEvent<SharedMagbootsComponent, ToggleActionEvent>(OnToggleAction);
}
private void AddToggleVerb(EntityUid uid, SharedMagbootsComponent component, GetVerbsEvent<ActivationVerb> args)
{
if (!args.CanAccess || !args.CanInteract)
return;
ActivationVerb verb = new();
verb.Text = Loc.GetString("toggle-magboots-verb-get-data-text");
verb.Act = () => component.On = !component.On;
// TODO VERB ICON add toggle icon? maybe a computer on/off symbol?
args.Verbs.Add(verb);
}
private void OnSlipAttempt(EntityUid uid, SharedMagbootsComponent component, SlipAttemptEvent args)
{
if (component.On)
args.Cancel();
}
private void OnGetActions(EntityUid uid, SharedMagbootsComponent component, GetActionsEvent args)
{
args.Actions.Add(component.ToggleAction);