Magboot & Stun visualizers (#9961)
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Toggleable;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using static Content.Shared.Clothing.MagbootsComponent;
|
||||
|
||||
@@ -15,8 +10,6 @@ namespace Content.Server.Clothing;
|
||||
public sealed class MagbootsSystem : SharedMagbootsSystem
|
||||
{
|
||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _sharedContainer = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -24,11 +17,10 @@ public sealed class MagbootsSystem : SharedMagbootsSystem
|
||||
|
||||
SubscribeLocalEvent<MagbootsComponent, GotEquippedEvent>(OnGotEquipped);
|
||||
SubscribeLocalEvent<MagbootsComponent, GotUnequippedEvent>(OnGotUnequipped);
|
||||
SubscribeLocalEvent<MagbootsComponent, ToggleActionEvent>(OnToggleAction);
|
||||
SubscribeLocalEvent<MagbootsComponent, ComponentGetState>(OnGetState);
|
||||
}
|
||||
|
||||
private void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component)
|
||||
protected override void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
@@ -49,28 +41,6 @@ public sealed class MagbootsSystem : SharedMagbootsSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnToggleAction(EntityUid uid, MagbootsComponent component, ToggleActionEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
component.On = !component.On;
|
||||
|
||||
if (_sharedContainer.TryGetContainingContainer(uid, out var container) &&
|
||||
_inventory.TryGetSlotEntity(container.Owner, "shoes", out var entityUid) && entityUid == component.Owner)
|
||||
UpdateMagbootEffects(container.Owner, component.Owner, true, component);
|
||||
|
||||
if (TryComp<SharedItemComponent>(component.Owner, out var item))
|
||||
item.EquippedPrefix = component.On ? "on" : null;
|
||||
|
||||
if (TryComp<SpriteComponent>(component.Owner, out var sprite))
|
||||
sprite.LayerSetState(0, component.On ? "icon-on" : "icon");
|
||||
|
||||
OnChanged(component);
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
private void OnGotUnequipped(EntityUid uid, MagbootsComponent component, GotUnequippedEvent args)
|
||||
{
|
||||
if (args.Slot == "shoes")
|
||||
|
||||
@@ -14,6 +14,7 @@ using Content.Shared.Jittering;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Toggleable;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
@@ -87,13 +88,11 @@ namespace Content.Server.Stunnable.Systems
|
||||
if (!comp.Activated)
|
||||
return;
|
||||
|
||||
// TODO stunbaton visualizer
|
||||
if (TryComp<SpriteComponent>(comp.Owner, out var sprite) &&
|
||||
TryComp<SharedItemComponent>(comp.Owner, out var item))
|
||||
{
|
||||
if (TryComp<SharedItemComponent>(comp.Owner, out var item))
|
||||
item.EquippedPrefix = "off";
|
||||
sprite.LayerSetState(0, "stunbaton_off");
|
||||
}
|
||||
|
||||
if (TryComp(comp.Owner, out AppearanceComponent? appearance))
|
||||
appearance.SetData(ToggleVisuals.Toggled, false);
|
||||
|
||||
SoundSystem.Play(comp.SparksSound.GetSound(), Filter.Pvs(comp.Owner), comp.Owner, AudioHelpers.WithVariation(0.25f));
|
||||
|
||||
@@ -113,12 +112,12 @@ namespace Content.Server.Stunnable.Systems
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntityManager.TryGetComponent<SpriteComponent?>(comp.Owner, out var sprite) &&
|
||||
EntityManager.TryGetComponent<SharedItemComponent?>(comp.Owner, out var item))
|
||||
{
|
||||
|
||||
if (TryComp<SharedItemComponent>(comp.Owner, out var item))
|
||||
item.EquippedPrefix = "on";
|
||||
sprite.LayerSetState(0, "stunbaton_on");
|
||||
}
|
||||
|
||||
if (TryComp(comp.Owner, out AppearanceComponent? appearance))
|
||||
appearance.SetData(ToggleVisuals.Toggled, true);
|
||||
|
||||
SoundSystem.Play(comp.SparksSound.GetSound(), playerFilter, comp.Owner, AudioHelpers.WithVariation(0.25f));
|
||||
comp.Activated = true;
|
||||
|
||||
Reference in New Issue
Block a user