Skip to content

Commit

Permalink
refactor harpy singing visuals into InstrumentVisuals
Browse files Browse the repository at this point in the history
  • Loading branch information
deltanedas committed Dec 31, 2024
1 parent 33d14d8 commit 775726b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 45 deletions.
23 changes: 0 additions & 23 deletions Content.Server/DeltaV/Harpy/HarpySingerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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()
{
Expand All @@ -45,8 +43,6 @@ public override void Initialize()
SubscribeLocalEvent<InstrumentComponent, SleepStateChangedEvent>(OnSleep);
SubscribeLocalEvent<InstrumentComponent, StatusEffectAddedEvent>(OnStatusEffect);
SubscribeLocalEvent<InstrumentComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<HarpySingerComponent, BoundUIClosedEvent>(OnBoundUIClosed);
SubscribeLocalEvent<HarpySingerComponent, BoundUIOpenedEvent>(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.
Expand Down Expand Up @@ -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);

}
}
}
17 changes: 0 additions & 17 deletions Content.Shared/DeltaV/Harpy/Components/HarpyVisualSystem.cs

This file was deleted.

18 changes: 18 additions & 0 deletions Content.Shared/DeltaV/Instruments/InstrumentVisualsComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;

namespace Content.Shared.DeltaV.Instruments;

/// <summary>
/// Controls the bool <see cref="InstrumentVisuals"/> when the instrument UI is open.
/// Use GenericVisualizerComponent to then control sprite states.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class InstrumentVisualsComponent : Component;

[Serializable, NetSerializable]
public enum InstrumentVisuals : byte
{
Playing,
Layer
}
33 changes: 33 additions & 0 deletions Content.Shared/DeltaV/Instruments/InstrumentVisualsSystem.cs
Original file line number Diff line number Diff line change
@@ -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<InstrumentVisualsComponent, BoundUIClosedEvent>(OnUIClosed);
SubscribeLocalEvent<InstrumentVisualsComponent, BoundUIOpenedEvent>(OnUIOpened);
}

private void OnUIClosed(Entity<InstrumentVisualsComponent> ent, ref BoundUIClosedEvent args)
{
if (args.UiKey is not InstrumentUiKey)
return;

_appearance.SetData(ent, InstrumentVisuals.Playing, false);
}

private void OnUIOpened(Entity<InstrumentVisualsComponent> ent, ref BoundUIOpenedEvent args)
{
if (args.UiKey is not InstrumentUiKey)
return;

_appearance.SetData(ent, InstrumentVisuals.Playing, true);
}
}
11 changes: 6 additions & 5 deletions Resources/Prototypes/DeltaV/Entities/Mobs/Species/harpy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 775726b

Please sign in to comment.