Files
wwdpublic/Content.Client/Power/Visualizers/CableVisualizerSystem.cs
SpaceManiac a1a8139916 Fix 38 non-obsolete warnings (#33794)
(cherry picked from commit 41223107356553ccbc7ba4f8b95e4f9049873d09)
2025-09-20 20:34:22 +03:00

36 lines
1.2 KiB
C#

using Content.Client.SubFloor;
using Content.Shared.Wires;
using Robust.Client.GameObjects;
namespace Content.Client.Power.Visualizers;
public sealed class CableVisualizerSystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CableVisualizerComponent, AppearanceChangeEvent>(OnAppearanceChange, after: new[] { typeof(SubFloorHideSystem) });
}
private void OnAppearanceChange(EntityUid uid, CableVisualizerComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
if (!args.Sprite.Visible)
{
// This entity is probably below a floor and is not even visible to the user -> don't bother updating sprite data.
// Note that if the subfloor visuals change, then another AppearanceChangeEvent will get triggered.
return;
}
if (!_appearanceSystem.TryGetData<WireVisDirFlags>(uid, WireVisVisuals.ConnectedMask, out var mask, args.Component))
mask = WireVisDirFlags.None;
args.Sprite.LayerSetState(0, $"{component.StatePrefix}{(int) mask}");
}
}