Magboot & Stun visualizers (#9961)
This commit is contained in:
@@ -1,12 +1,7 @@
|
|||||||
using Content.Server.Atmos.Components;
|
using Content.Server.Atmos.Components;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Clothing;
|
using Content.Shared.Clothing;
|
||||||
using Content.Shared.Inventory;
|
|
||||||
using Content.Shared.Inventory.Events;
|
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 Robust.Shared.GameStates;
|
||||||
using static Content.Shared.Clothing.MagbootsComponent;
|
using static Content.Shared.Clothing.MagbootsComponent;
|
||||||
|
|
||||||
@@ -15,8 +10,6 @@ namespace Content.Server.Clothing;
|
|||||||
public sealed class MagbootsSystem : SharedMagbootsSystem
|
public sealed class MagbootsSystem : SharedMagbootsSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
|
||||||
[Dependency] private readonly SharedContainerSystem _sharedContainer = default!;
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -24,11 +17,10 @@ public sealed class MagbootsSystem : SharedMagbootsSystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<MagbootsComponent, GotEquippedEvent>(OnGotEquipped);
|
SubscribeLocalEvent<MagbootsComponent, GotEquippedEvent>(OnGotEquipped);
|
||||||
SubscribeLocalEvent<MagbootsComponent, GotUnequippedEvent>(OnGotUnequipped);
|
SubscribeLocalEvent<MagbootsComponent, GotUnequippedEvent>(OnGotUnequipped);
|
||||||
SubscribeLocalEvent<MagbootsComponent, ToggleActionEvent>(OnToggleAction);
|
|
||||||
SubscribeLocalEvent<MagbootsComponent, ComponentGetState>(OnGetState);
|
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))
|
if (!Resolve(uid, ref component))
|
||||||
return;
|
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)
|
private void OnGotUnequipped(EntityUid uid, MagbootsComponent component, GotUnequippedEvent args)
|
||||||
{
|
{
|
||||||
if (args.Slot == "shoes")
|
if (args.Slot == "shoes")
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Content.Shared.Jittering;
|
|||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.StatusEffect;
|
using Content.Shared.StatusEffect;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
|
using Content.Shared.Toggleable;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
@@ -87,13 +88,11 @@ namespace Content.Server.Stunnable.Systems
|
|||||||
if (!comp.Activated)
|
if (!comp.Activated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO stunbaton visualizer
|
if (TryComp<SharedItemComponent>(comp.Owner, out var item))
|
||||||
if (TryComp<SpriteComponent>(comp.Owner, out var sprite) &&
|
|
||||||
TryComp<SharedItemComponent>(comp.Owner, out var item))
|
|
||||||
{
|
|
||||||
item.EquippedPrefix = "off";
|
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));
|
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;
|
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";
|
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));
|
SoundSystem.Play(comp.SparksSound.GetSound(), playerFilter, comp.Owner, AudioHelpers.WithVariation(0.25f));
|
||||||
comp.Activated = true;
|
comp.Activated = true;
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
|
using Content.Shared.Inventory;
|
||||||
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Slippery;
|
using Content.Shared.Slippery;
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Toggleable;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
|
|
||||||
namespace Content.Shared.Clothing;
|
namespace Content.Shared.Clothing;
|
||||||
|
|
||||||
@@ -9,6 +12,8 @@ public abstract class SharedMagbootsSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly SharedActionsSystem _sharedActions = default!;
|
[Dependency] private readonly SharedActionsSystem _sharedActions = default!;
|
||||||
[Dependency] private readonly ClothingSpeedModifierSystem _clothingSpeedModifier = default!;
|
[Dependency] private readonly ClothingSpeedModifierSystem _clothingSpeedModifier = default!;
|
||||||
|
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||||
|
[Dependency] private readonly SharedContainerSystem _sharedContainer = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -17,8 +22,33 @@ public abstract class SharedMagbootsSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<MagbootsComponent, GetVerbsEvent<ActivationVerb>>(AddToggleVerb);
|
SubscribeLocalEvent<MagbootsComponent, GetVerbsEvent<ActivationVerb>>(AddToggleVerb);
|
||||||
SubscribeLocalEvent<MagbootsComponent, SlipAttemptEvent>(OnSlipAttempt);
|
SubscribeLocalEvent<MagbootsComponent, SlipAttemptEvent>(OnSlipAttempt);
|
||||||
SubscribeLocalEvent<MagbootsComponent, GetItemActionsEvent>(OnGetActions);
|
SubscribeLocalEvent<MagbootsComponent, GetItemActionsEvent>(OnGetActions);
|
||||||
|
SubscribeLocalEvent<MagbootsComponent, ToggleActionEvent>(OnToggleAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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, uid, true, component);
|
||||||
|
|
||||||
|
if (TryComp<SharedItemComponent>(uid, out var item))
|
||||||
|
item.EquippedPrefix = component.On ? "on" : null;
|
||||||
|
|
||||||
|
if (TryComp(uid, out AppearanceComponent? appearance))
|
||||||
|
appearance.SetData(ToggleVisuals.Toggled, component.On);
|
||||||
|
|
||||||
|
OnChanged(component);
|
||||||
|
Dirty(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component) { }
|
||||||
|
|
||||||
protected void OnChanged(MagbootsComponent component)
|
protected void OnChanged(MagbootsComponent component)
|
||||||
{
|
{
|
||||||
_sharedActions.SetToggled(component.ToggleAction, component.On);
|
_sharedActions.SetToggled(component.ToggleAction, component.On);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Toggleable;
|
namespace Content.Shared.Toggleable;
|
||||||
|
|
||||||
@@ -6,3 +7,13 @@ namespace Content.Shared.Toggleable;
|
|||||||
/// Generic action-event for toggle-able components.
|
/// Generic action-event for toggle-able components.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ToggleActionEvent : InstantActionEvent { }
|
public sealed class ToggleActionEvent : InstantActionEvent { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generic enum keys for toggle-visualizer appearance data & sprite layers.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum ToggleVisuals : byte
|
||||||
|
{
|
||||||
|
Toggled,
|
||||||
|
Layer
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,10 @@
|
|||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Shoes/Boots/magboots.rsi
|
sprite: Clothing/Shoes/Boots/magboots.rsi
|
||||||
state: icon
|
netsync: false
|
||||||
|
layers:
|
||||||
|
- state: icon
|
||||||
|
map: [ "enum.ToggleVisuals.Layer" ]
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Clothing/Shoes/Boots/magboots.rsi
|
sprite: Clothing/Shoes/Boots/magboots.rsi
|
||||||
- type: Magboots
|
- type: Magboots
|
||||||
@@ -21,6 +24,13 @@
|
|||||||
walkModifier: 0.85
|
walkModifier: 0.85
|
||||||
sprintModifier: 0.8
|
sprintModifier: 0.8
|
||||||
enabled: false
|
enabled: false
|
||||||
|
- type: Appearance
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.ToggleVisuals.Toggled:
|
||||||
|
enum.ToggleVisuals.Layer:
|
||||||
|
True: {state: icon-on}
|
||||||
|
False: {state: icon}
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingShoesBootsMag
|
parent: ClothingShoesBootsMag
|
||||||
|
|||||||
@@ -6,7 +6,10 @@
|
|||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Weapons/Melee/stunbaton.rsi
|
sprite: Objects/Weapons/Melee/stunbaton.rsi
|
||||||
state: stunbaton_off
|
netsync: false
|
||||||
|
layers:
|
||||||
|
- state: stunbaton_off
|
||||||
|
map: [ "enum.ToggleVisuals.Layer" ]
|
||||||
- type: Stunbaton
|
- type: Stunbaton
|
||||||
energyPerUse: 100
|
energyPerUse: 100
|
||||||
- type: MeleeWeapon
|
- type: MeleeWeapon
|
||||||
@@ -33,6 +36,13 @@
|
|||||||
- Belt
|
- Belt
|
||||||
- type: DisarmMalus
|
- type: DisarmMalus
|
||||||
malus: 0.225
|
malus: 0.225
|
||||||
|
- type: Appearance
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.ToggleVisuals.Toggled:
|
||||||
|
enum.ToggleVisuals.Layer:
|
||||||
|
True: {state: stunbaton_on}
|
||||||
|
False: {state: stunbaton_off}
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: flash
|
name: flash
|
||||||
|
|||||||
Reference in New Issue
Block a user