mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using Content.Client.SubFloor;
|
|
using Content.Shared.Wires;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.Power.Visualizers;
|
|
|
|
public sealed partial class CableVisualizerSystem : EntitySystem
|
|
{
|
|
[Dependency] private AppearanceSystem _appearanceSystem = default!;
|
|
[Dependency] private SpriteSystem _sprite = 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;
|
|
|
|
_sprite.LayerSetRsiState((uid, args.Sprite), 0, $"{component.StatePrefix}{(int)mask}");
|
|
if (component.ExtraLayerPrefix != null)
|
|
_sprite.LayerSetRsiState((uid, args.Sprite), 1, $"{component.ExtraLayerPrefix}{(int)mask}");
|
|
}
|
|
}
|