From 775726badec7124f8dc446cfbc308a632f947c67 Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Tue, 31 Dec 2024 00:57:30 +0000 Subject: [PATCH] refactor harpy singing visuals into InstrumentVisuals --- .../DeltaV/Harpy/HarpySingerSystem.cs | 23 ------------- .../Harpy/Components/HarpyVisualSystem.cs | 17 ---------- .../Instruments/InstrumentVisualsComponent.cs | 18 ++++++++++ .../Instruments/InstrumentVisualsSystem.cs | 33 +++++++++++++++++++ .../DeltaV/Entities/Mobs/Species/harpy.yml | 11 ++++--- 5 files changed, 57 insertions(+), 45 deletions(-) delete mode 100644 Content.Shared/DeltaV/Harpy/Components/HarpyVisualSystem.cs create mode 100644 Content.Shared/DeltaV/Instruments/InstrumentVisualsComponent.cs create mode 100644 Content.Shared/DeltaV/Instruments/InstrumentVisualsSystem.cs diff --git a/Content.Server/DeltaV/Harpy/HarpySingerSystem.cs b/Content.Server/DeltaV/Harpy/HarpySingerSystem.cs index d7710cd514b..ec784dfd5b7 100644 --- a/Content.Server/DeltaV/Harpy/HarpySingerSystem.cs +++ b/Content.Server/DeltaV/Harpy/HarpySingerSystem.cs @@ -20,7 +20,6 @@ using Robust.Server.GameObjects; using Robust.Shared.Player; using Robust.Shared.Prototypes; -using Content.Shared.DeltaV.Harpy.Components; namespace Content.Server.DeltaV.Harpy { @@ -31,7 +30,6 @@ public sealed class HarpySingerSystem : EntitySystem [Dependency] private readonly InventorySystem _inventorySystem = default!; [Dependency] private readonly ActionBlockerSystem _blocker = default!; [Dependency] private readonly IPrototypeManager _prototype = default!; - [Dependency] private readonly SharedAppearanceSystem _appearance = default!; public override void Initialize() { @@ -45,8 +43,6 @@ public override void Initialize() SubscribeLocalEvent(OnSleep); SubscribeLocalEvent(OnStatusEffect); SubscribeLocalEvent(OnDamageChanged); - SubscribeLocalEvent(OnBoundUIClosed); - SubscribeLocalEvent(OnBoundUIOpened); // This is intended to intercept the UI event and stop the MIDI UI from opening if the // singer is unable to sing. Thus it needs to run before the ActivatableUISystem. @@ -160,24 +156,5 @@ private void OnInstrumentOpen(EntityUid uid, HarpySingerComponent component, Ope if (args.Handled) _popupSystem.PopupEntity(Loc.GetString("no-sing-while-no-speak"), uid, uid, PopupType.Medium); } - - private void OnBoundUIClosed(EntityUid uid, HarpySingerComponent component, BoundUIClosedEvent args) - { - if (args.UiKey is not InstrumentUiKey) - return; - - TryComp(uid, out AppearanceComponent? appearance); - _appearance.SetData(uid, HarpyVisualLayers.Singing, SingingVisualLayer.False, appearance); - } - - private void OnBoundUIOpened(EntityUid uid, HarpySingerComponent component, BoundUIOpenedEvent args) - { - if (args.UiKey is not InstrumentUiKey) - return; - - TryComp(uid, out AppearanceComponent? appearance); - _appearance.SetData(uid, HarpyVisualLayers.Singing, SingingVisualLayer.True, appearance); - - } } } diff --git a/Content.Shared/DeltaV/Harpy/Components/HarpyVisualSystem.cs b/Content.Shared/DeltaV/Harpy/Components/HarpyVisualSystem.cs deleted file mode 100644 index f5100e13c7f..00000000000 --- a/Content.Shared/DeltaV/Harpy/Components/HarpyVisualSystem.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Robust.Shared.Serialization; - -namespace Content.Shared.DeltaV.Harpy.Components -{ - [Serializable, NetSerializable] - public enum HarpyVisualLayers - { - Singing, - } - - [Serializable, NetSerializable] - public enum SingingVisualLayer - { - True, - False, - } -} diff --git a/Content.Shared/DeltaV/Instruments/InstrumentVisualsComponent.cs b/Content.Shared/DeltaV/Instruments/InstrumentVisualsComponent.cs new file mode 100644 index 00000000000..ea484fdfccc --- /dev/null +++ b/Content.Shared/DeltaV/Instruments/InstrumentVisualsComponent.cs @@ -0,0 +1,18 @@ +using Robust.Shared.GameStates; +using Robust.Shared.Serialization; + +namespace Content.Shared.DeltaV.Instruments; + +/// +/// Controls the bool when the instrument UI is open. +/// Use GenericVisualizerComponent to then control sprite states. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class InstrumentVisualsComponent : Component; + +[Serializable, NetSerializable] +public enum InstrumentVisuals : byte +{ + Playing, + Layer +} diff --git a/Content.Shared/DeltaV/Instruments/InstrumentVisualsSystem.cs b/Content.Shared/DeltaV/Instruments/InstrumentVisualsSystem.cs new file mode 100644 index 00000000000..d55cd3aa767 --- /dev/null +++ b/Content.Shared/DeltaV/Instruments/InstrumentVisualsSystem.cs @@ -0,0 +1,33 @@ +using Content.Shared.Instruments; +using Content.Shared.UserInterface; + +namespace Content.Shared.DeltaV.Instruments; + +public sealed class InstrumentVisualsSystem : EntitySystem +{ + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnUIClosed); + SubscribeLocalEvent(OnUIOpened); + } + + private void OnUIClosed(Entity ent, ref BoundUIClosedEvent args) + { + if (args.UiKey is not InstrumentUiKey) + return; + + _appearance.SetData(ent, InstrumentVisuals.Playing, false); + } + + private void OnUIOpened(Entity ent, ref BoundUIOpenedEvent args) + { + if (args.UiKey is not InstrumentUiKey) + return; + + _appearance.SetData(ent, InstrumentVisuals.Playing, true); + } +} diff --git a/Resources/Prototypes/DeltaV/Entities/Mobs/Species/harpy.yml b/Resources/Prototypes/DeltaV/Entities/Mobs/Species/harpy.yml index 54af2dc1936..02aa1863842 100644 --- a/Resources/Prototypes/DeltaV/Entities/Mobs/Species/harpy.yml +++ b/Resources/Prototypes/DeltaV/Entities/Mobs/Species/harpy.yml @@ -77,7 +77,7 @@ - map: [ "enum.HumanoidVisualLayers.HeadTop" ] - map: [ "mask" ] - map: [ "head" ] - - map: [ "singingLayer" ] + - map: [ enum.InstrumentVisuals.Layer ] sprite: DeltaV/Effects/harpysinger.rsi state: singing_music_notes visible: false @@ -115,12 +115,13 @@ Male: SoundsHarpy Female: SoundsHarpy Unsexed: SoundsHarpy + - type: InstrumentVisuals - type: GenericVisualizer visuals: - enum.HarpyVisualLayers.Singing: - singingLayer: - False: {visible: false} - True: {visible: true} + enum.InstrumentVisuals.Playing: + enum.InstrumentVisuals.Layer: + False: {visible: false} + True: {visible: true} - type: MovementSpeedModifier baseWalkSpeed: 2.5 baseSprintSpeed: 5.0