using Content.Client.Atmos.Components; using Robust.Client.GameObjects; using Content.Client.UserInterface.Systems.Storage.Controls; using Content.Shared.Atmos.Piping; using Content.Shared.Hands; using Content.Shared.Atmos.Components; using Content.Shared.Item; namespace Content.Client.Atmos.EntitySystems; public sealed class PipeColorVisualizerSystem : VisualizerSystem { [Dependency] private readonly SharedItemSystem _itemSystem = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnGetVisuals); SubscribeLocalEvent(OnDrawInGrid); } /// /// This method is used to display the color changes of the pipe on the screen.. /// private void OnGetVisuals(Entity item, ref GetInhandVisualsEvent args) { foreach (var (_, layerData) in args.Layers) { if (TryComp(item.Owner, out AtmosPipeColorComponent? pipeColor)) layerData.Color = pipeColor.Color; } } /// /// This method is used to change the pipe's color in a container grid. /// private void OnDrawInGrid(Entity item, ref BeforeRenderInGridEvent args) { if (TryComp(item.Owner, out AtmosPipeColorComponent? pipeColor)) args.Color = pipeColor.Color; } protected override void OnAppearanceChange(EntityUid uid, PipeColorVisualsComponent component, ref AppearanceChangeEvent args) { if (TryComp(uid, out var sprite) && AppearanceSystem.TryGetData(uid, PipeColorVisuals.Color, out var color, args.Component)) { // T-ray scanner / sub floor runs after this visualizer. Lets not bulldoze transparency. var layer = sprite[PipeVisualLayers.Pipe]; layer.Color = color.WithAlpha(layer.Color.A); } _itemSystem.VisualsChanged(uid); } } public enum PipeVisualLayers : byte { Pipe, }