2021-12-30 22:56:10 +01:00
|
|
|
using Content.Server.Atmos.Components;
|
|
|
|
|
using Content.Shared.Alert;
|
2022-02-26 18:24:08 +13:00
|
|
|
using Content.Shared.Clothing;
|
2021-10-05 14:29:03 +11:00
|
|
|
|
2022-07-06 07:46:35 -04:00
|
|
|
namespace Content.Server.Clothing;
|
|
|
|
|
|
|
|
|
|
public sealed class MagbootsSystem : SharedMagbootsSystem
|
2021-10-05 14:29:03 +11:00
|
|
|
{
|
2023-04-22 12:42:36 +02:00
|
|
|
[Dependency] private readonly AlertsSystem _alerts = default!;
|
2022-07-06 07:46:35 -04:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
2021-10-05 14:29:03 +11:00
|
|
|
{
|
2022-07-06 07:46:35 -04:00
|
|
|
base.Initialize();
|
2022-01-05 00:19:23 -08:00
|
|
|
|
2024-04-21 11:00:50 -04:00
|
|
|
SubscribeLocalEvent<MagbootsComponent, ClothingGotEquippedEvent>(OnGotEquipped);
|
|
|
|
|
SubscribeLocalEvent<MagbootsComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
|
2022-07-06 07:46:35 -04:00
|
|
|
}
|
|
|
|
|
|
2022-07-24 23:39:21 +12:00
|
|
|
protected override void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component)
|
2022-07-06 07:46:35 -04:00
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component))
|
|
|
|
|
return;
|
|
|
|
|
state = state && component.On;
|
2021-10-05 14:29:03 +11:00
|
|
|
|
2022-07-06 07:46:35 -04:00
|
|
|
if (TryComp(parent, out MovedByPressureComponent? movedByPressure))
|
|
|
|
|
{
|
|
|
|
|
movedByPressure.Enabled = !state;
|
2021-12-30 22:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-06 07:46:35 -04:00
|
|
|
if (state)
|
|
|
|
|
{
|
2023-04-22 12:42:36 +02:00
|
|
|
_alerts.ShowAlert(parent, AlertType.Magboots);
|
2022-07-06 07:46:35 -04:00
|
|
|
}
|
|
|
|
|
else
|
2021-12-30 22:56:10 +01:00
|
|
|
{
|
2023-04-22 12:42:36 +02:00
|
|
|
_alerts.ClearAlert(parent, AlertType.Magboots);
|
2021-12-30 22:56:10 +01:00
|
|
|
}
|
2022-07-06 07:46:35 -04:00
|
|
|
}
|
|
|
|
|
|
2024-04-21 11:00:50 -04:00
|
|
|
private void OnGotUnequipped(EntityUid uid, MagbootsComponent component, ref ClothingGotUnequippedEvent args)
|
2022-07-06 07:46:35 -04:00
|
|
|
{
|
2024-04-21 11:00:50 -04:00
|
|
|
UpdateMagbootEffects(args.Wearer, uid, false, component);
|
2022-07-06 07:46:35 -04:00
|
|
|
}
|
2021-12-30 22:56:10 +01:00
|
|
|
|
2024-04-21 11:00:50 -04:00
|
|
|
private void OnGotEquipped(EntityUid uid, MagbootsComponent component, ref ClothingGotEquippedEvent args)
|
2022-07-06 07:46:35 -04:00
|
|
|
{
|
2024-04-21 11:00:50 -04:00
|
|
|
UpdateMagbootEffects(args.Wearer, uid, true, component);
|
2021-10-05 14:29:03 +11:00
|
|
|
}
|
|
|
|
|
}
|