2022-02-26 18:24:08 +13:00
|
|
|
using Content.Shared.Actions;
|
2022-04-02 16:08:39 +13:00
|
|
|
using Content.Shared.Slippery;
|
2022-02-26 18:24:08 +13:00
|
|
|
using Content.Shared.Toggleable;
|
2022-04-02 16:08:39 +13:00
|
|
|
using Content.Shared.Verbs;
|
2022-02-26 18:24:08 +13:00
|
|
|
|
|
|
|
|
namespace Content.Shared.Clothing;
|
|
|
|
|
|
|
|
|
|
public abstract class SharedMagbootsSystem : EntitySystem
|
|
|
|
|
{
|
2022-07-06 07:46:35 -04:00
|
|
|
[Dependency] private readonly SharedActionsSystem _sharedActions = default!;
|
|
|
|
|
[Dependency] private readonly ClothingSpeedModifierSystem _clothingSpeedModifier = default!;
|
|
|
|
|
|
2022-02-26 18:24:08 +13:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2022-07-06 07:46:35 -04:00
|
|
|
SubscribeLocalEvent<MagbootsComponent, GetVerbsEvent<ActivationVerb>>(AddToggleVerb);
|
|
|
|
|
SubscribeLocalEvent<MagbootsComponent, SlipAttemptEvent>(OnSlipAttempt);
|
|
|
|
|
SubscribeLocalEvent<MagbootsComponent, GetItemActionsEvent>(OnGetActions);
|
2022-02-26 18:24:08 +13:00
|
|
|
}
|
|
|
|
|
|
2022-07-06 07:46:35 -04:00
|
|
|
protected void OnChanged(MagbootsComponent component)
|
|
|
|
|
{
|
|
|
|
|
_sharedActions.SetToggled(component.ToggleAction, component.On);
|
|
|
|
|
_clothingSpeedModifier.SetClothingSpeedModifierEnabled(component.Owner, component.On);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddToggleVerb(EntityUid uid, MagbootsComponent component, GetVerbsEvent<ActivationVerb> args)
|
2022-04-02 16:08:39 +13:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-06 07:46:35 -04:00
|
|
|
private void OnSlipAttempt(EntityUid uid, MagbootsComponent component, SlipAttemptEvent args)
|
2022-04-02 16:08:39 +13:00
|
|
|
{
|
|
|
|
|
if (component.On)
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-06 07:46:35 -04:00
|
|
|
private void OnGetActions(EntityUid uid, MagbootsComponent component, GetItemActionsEvent args)
|
2022-02-26 18:24:08 +13:00
|
|
|
{
|
|
|
|
|
args.Actions.Add(component.ToggleAction);
|
|
|
|
|
}
|
|
|
|
|
}
|