2021-12-30 22:56:10 +01:00
|
|
|
using Content.Server.Alert;
|
|
|
|
|
using Content.Server.Atmos.Components;
|
2021-10-05 14:29:03 +11:00
|
|
|
using Content.Server.Clothing.Components;
|
2022-02-26 18:24:08 +13:00
|
|
|
using Content.Shared.Actions;
|
2021-12-30 22:56:10 +01:00
|
|
|
using Content.Shared.Alert;
|
2022-02-26 18:24:08 +13:00
|
|
|
using Content.Shared.Clothing;
|
2021-12-30 22:56:10 +01:00
|
|
|
using Content.Shared.Inventory.Events;
|
2021-11-07 22:17:35 -07:00
|
|
|
using Content.Shared.Movement.EntitySystems;
|
2021-10-24 23:43:49 -07:00
|
|
|
using Content.Shared.Slippery;
|
2021-10-05 14:29:03 +11:00
|
|
|
using Content.Shared.Verbs;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Clothing
|
|
|
|
|
{
|
2022-02-26 18:24:08 +13:00
|
|
|
public sealed class MagbootsSystem : SharedMagbootsSystem
|
2021-10-05 14:29:03 +11:00
|
|
|
{
|
2022-01-05 00:19:23 -08:00
|
|
|
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
|
|
|
|
|
2021-10-05 14:29:03 +11:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2022-02-10 15:30:59 +13:00
|
|
|
SubscribeLocalEvent<MagbootsComponent, GetVerbsEvent<ActivationVerb>>(AddToggleVerb);
|
2021-10-24 23:43:49 -07:00
|
|
|
SubscribeLocalEvent<MagbootsComponent, SlipAttemptEvent>(OnSlipAttempt);
|
2021-12-30 22:56:10 +01:00
|
|
|
SubscribeLocalEvent<MagbootsComponent, GotEquippedEvent>(OnGotEquipped);
|
|
|
|
|
SubscribeLocalEvent<MagbootsComponent, GotUnequippedEvent>(OnGotUnequipped);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component))
|
|
|
|
|
return;
|
|
|
|
|
state = state && component.On;
|
|
|
|
|
|
|
|
|
|
if (TryComp(parent, out MovedByPressureComponent? movedByPressure))
|
|
|
|
|
{
|
|
|
|
|
movedByPressure.Enabled = state;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-05 00:19:23 -08:00
|
|
|
if (state)
|
|
|
|
|
{
|
|
|
|
|
_alertsSystem.ShowAlert(parent, AlertType.Magboots);
|
|
|
|
|
}
|
|
|
|
|
else
|
2021-12-30 22:56:10 +01:00
|
|
|
{
|
2022-01-05 00:19:23 -08:00
|
|
|
_alertsSystem.ClearAlert(parent, AlertType.Magboots);
|
2021-12-30 22:56:10 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnGotUnequipped(EntityUid uid, MagbootsComponent component, GotUnequippedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Slot == "shoes")
|
|
|
|
|
{
|
2021-12-31 10:41:08 +01:00
|
|
|
UpdateMagbootEffects(args.Equipee, uid, false, component);
|
2021-12-30 22:56:10 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnGotEquipped(EntityUid uid, MagbootsComponent component, GotEquippedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Slot == "shoes")
|
|
|
|
|
{
|
2021-12-31 10:41:08 +01:00
|
|
|
UpdateMagbootEffects(args.Equipee, uid, true, component);
|
2021-12-30 22:56:10 +01:00
|
|
|
}
|
2021-11-07 22:17:35 -07:00
|
|
|
}
|
|
|
|
|
|
2022-02-10 15:30:59 +13:00
|
|
|
private void AddToggleVerb(EntityUid uid, MagbootsComponent component, GetVerbsEvent<ActivationVerb> args)
|
2021-10-05 14:29:03 +11:00
|
|
|
{
|
2021-12-26 15:32:45 +13:00
|
|
|
if (!args.CanAccess || !args.CanInteract)
|
2021-10-05 14:29:03 +11:00
|
|
|
return;
|
|
|
|
|
|
2022-02-10 15:30:59 +13:00
|
|
|
ActivationVerb verb = new();
|
2021-10-05 14:29:03 +11:00
|
|
|
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);
|
|
|
|
|
}
|
2021-10-24 23:43:49 -07:00
|
|
|
|
|
|
|
|
private void OnSlipAttempt(EntityUid uid, MagbootsComponent component, SlipAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (component.On)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-05 14:29:03 +11:00
|
|
|
}
|
|
|
|
|
}
|