mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* 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
38 lines
1.3 KiB
C#
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
|
|
}
|