CatStation/Content.Client/Wires/Visualizers/WiresVisualizerSystem.cs
Whatstone d9ffbf1d03
Cleanup: AppearanceSystem.TryGetData to AppearanceChangeEvent.TryGetData (#45373)
* First impl. of appearance TryGetData cleanup

* Handful of fixes

* DamageVisuals: fix HandleDamage call, inheritdoc

* bunch of unused AppearanceSystem instances

* Handful more unused appearance systems, inheritdoc

* JetpackSystem: Ent<T>

* cleanup roundup, more Ent<T>

* a few lingering AppearanceSystem.TryGetData calls

* more lingering AppearanceData access

* Remove unnecessary inheritdoc

* once again, with feeling
2026-10-05 00:45:37 +00:00

38 lines
1.3 KiB
C#

using Content.Shared.Wires;
using Robust.Client.GameObjects;
namespace Content.Client.Wires.Visualizers;
/// <summary>
/// A system that automatically updates sprites for entities with maintenance panels.
/// </summary>
public sealed partial class WiresVisualizerSystem : VisualizerSystem<WiresVisualsComponent>
{
/// <inheritdoc/>
protected override void OnAppearanceChange(EntityUid uid, WiresVisualsComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
var layer = SpriteSystem.LayerMapReserve((uid, args.Sprite), WiresVisualLayers.MaintenancePanel);
// Data doesn't exist (e.g. in the spawn menu), act as though the panel's closed
if (!args.TryGetData<bool>(WiresVisuals.MaintenancePanelState, out var panelOpen))
{
SpriteSystem.LayerSetVisible((uid, args.Sprite), layer, component.VisibleWhenClosed);
return;
}
// Otherwise, set the visibility according to when it's closed.
var visible = component.VisibleWhenClosed ? !panelOpen : panelOpen;
SpriteSystem.LayerSetVisible((uid, args.Sprite), layer, visible);
}
}
/// <summary>
/// Layers for the maintenance panel.
/// </summary>
public enum WiresVisualLayers : byte
{
MaintenancePanel
}