Add moon boots (#29009)

This commit is contained in:
Nemanja
2024-06-14 23:43:23 -04:00
committed by GitHub
parent 06c8238164
commit 748e5831e8
23 changed files with 211 additions and 124 deletions

View File

@@ -1,5 +1,8 @@
using Content.Shared.Actions;
using Content.Shared.Alert;
using Content.Shared.Atmos.Components;
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.Gravity;
using Content.Shared.Inventory;
using Content.Shared.Item;
using Content.Shared.Slippery;
@@ -9,8 +12,9 @@ using Robust.Shared.Containers;
namespace Content.Shared.Clothing;
public abstract class SharedMagbootsSystem : EntitySystem
public sealed class SharedMagbootsSystem : EntitySystem
{
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly ClothingSpeedModifierSystem _clothingSpeedModifier = default!;
[Dependency] private readonly ClothingSystem _clothing = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
@@ -29,6 +33,11 @@ public abstract class SharedMagbootsSystem : EntitySystem
SubscribeLocalEvent<MagbootsComponent, GetItemActionsEvent>(OnGetActions);
SubscribeLocalEvent<MagbootsComponent, ToggleMagbootsEvent>(OnToggleMagboots);
SubscribeLocalEvent<MagbootsComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<MagbootsComponent, ClothingGotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<MagbootsComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
SubscribeLocalEvent<MagbootsComponent, InventoryRelayedEvent<IsWeightlessEvent>>(OnIsWeightless);
}
private void OnMapInit(EntityUid uid, MagbootsComponent component, MapInitEvent args)
@@ -37,6 +46,16 @@ public abstract class SharedMagbootsSystem : EntitySystem
Dirty(uid, component);
}
private void OnGotUnequipped(EntityUid uid, MagbootsComponent component, ref ClothingGotUnequippedEvent args)
{
UpdateMagbootEffects(args.Wearer, uid, false, component);
}
private void OnGotEquipped(EntityUid uid, MagbootsComponent component, ref ClothingGotEquippedEvent args)
{
UpdateMagbootEffects(args.Wearer, uid, true, component);
}
private void OnToggleMagboots(EntityUid uid, MagbootsComponent component, ToggleMagbootsEvent args)
{
if (args.Handled)
@@ -51,9 +70,11 @@ public abstract class SharedMagbootsSystem : EntitySystem
{
magboots.On = !magboots.On;
if (_sharedContainer.TryGetContainingContainer(uid, out var container) &&
if (_sharedContainer.TryGetContainingContainer((uid, Transform(uid)), out var container) &&
_inventory.TryGetSlotEntity(container.Owner, "shoes", out var entityUid) && entityUid == uid)
{
UpdateMagbootEffects(container.Owner, uid, true, magboots);
}
if (TryComp<ItemComponent>(uid, out var item))
{
@@ -66,9 +87,28 @@ public abstract class SharedMagbootsSystem : EntitySystem
Dirty(uid, magboots);
}
protected virtual void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component) { }
public void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component)
{
if (!Resolve(uid, ref component))
return;
state = state && component.On;
protected void OnChanged(EntityUid uid, MagbootsComponent component)
if (TryComp(parent, out MovedByPressureComponent? movedByPressure))
{
movedByPressure.Enabled = !state;
}
if (state)
{
_alerts.ShowAlert(parent, component.MagbootsAlert);
}
else
{
_alerts.ClearAlert(parent, component.MagbootsAlert);
}
}
private void OnChanged(EntityUid uid, MagbootsComponent component)
{
_sharedActions.SetToggled(component.ToggleActionEntity, component.On);
_clothingSpeedModifier.SetClothingSpeedModifierEnabled(uid, component.On);
@@ -79,10 +119,12 @@ public abstract class SharedMagbootsSystem : EntitySystem
if (!args.CanAccess || !args.CanInteract)
return;
ActivationVerb verb = new();
verb.Text = Loc.GetString("toggle-magboots-verb-get-data-text");
verb.Act = () => ToggleMagboots(uid, component);
// TODO VERB ICON add toggle icon? maybe a computer on/off symbol?
ActivationVerb verb = new()
{
Text = Loc.GetString("toggle-magboots-verb-get-data-text"),
Act = () => ToggleMagboots(uid, component),
// TODO VERB ICON add toggle icon? maybe a computer on/off symbol?
};
args.Verbs.Add(verb);
}
@@ -96,6 +138,18 @@ public abstract class SharedMagbootsSystem : EntitySystem
{
args.AddAction(ref component.ToggleActionEntity, component.ToggleAction);
}
private void OnIsWeightless(Entity<MagbootsComponent> ent, ref InventoryRelayedEvent<IsWeightlessEvent> args)
{
if (args.Args.Handled)
return;
if (!ent.Comp.On)
return;
args.Args.IsWeightless = false;
args.Args.Handled = true;
}
}
public sealed partial class ToggleMagbootsEvent : InstantActionEvent {}
public sealed partial class ToggleMagbootsEvent : InstantActionEvent;