From e996fb62f1fd9ae434e60d3e783c24e147f0768e Mon Sep 17 00:00:00 2001 From: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com> Date: Mon, 4 Aug 2025 13:10:54 -0700 Subject: [PATCH] Revert "Fix bug with pipe color" (#39135) --- .../PipeColorVisualizerSystem.cs | 37 -------------- .../Systems/Storage/Controls/ItemGridPiece.cs | 20 +------- .../Components/AtmosPipeColorComponent.cs | 11 ++--- .../EntitySystems/AtmosPipeColorSystem.cs | 48 +++++++++++++++++++ .../Sandbox/Commands/ColorNetworkCommand.cs | 6 +-- .../SprayPainter/SprayPainterSystem.cs | 6 +-- .../EntitySystems/AtmosPipeColorSystem.cs | 36 -------------- 7 files changed, 59 insertions(+), 105 deletions(-) rename {Content.Shared/Atmos => Content.Server/Atmos/Piping}/Components/AtmosPipeColorComponent.cs (63%) create mode 100644 Content.Server/Atmos/Piping/EntitySystems/AtmosPipeColorSystem.cs delete mode 100644 Content.Shared/Atmos/EntitySystems/AtmosPipeColorSystem.cs diff --git a/Content.Client/Atmos/EntitySystems/PipeColorVisualizerSystem.cs b/Content.Client/Atmos/EntitySystems/PipeColorVisualizerSystem.cs index b23a44e403..5595f441f7 100644 --- a/Content.Client/Atmos/EntitySystems/PipeColorVisualizerSystem.cs +++ b/Content.Client/Atmos/EntitySystems/PipeColorVisualizerSystem.cs @@ -1,46 +1,11 @@ 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) @@ -50,8 +15,6 @@ public sealed class PipeColorVisualizerSystem : VisualizerSystem Entity; } -/// -/// This event gets raised before a sprite gets drawn in a grid and lets to change the sprite color for several gameobjects that have special sprites to render in containers. -/// -public sealed class BeforeRenderInGridEvent : EntityEventArgs -{ - public Color Color { get; set; } - - public BeforeRenderInGridEvent(Color color) - { - Color = color; - } -} - public enum ItemGridPieceMarks { First, diff --git a/Content.Shared/Atmos/Components/AtmosPipeColorComponent.cs b/Content.Server/Atmos/Piping/Components/AtmosPipeColorComponent.cs similarity index 63% rename from Content.Shared/Atmos/Components/AtmosPipeColorComponent.cs rename to Content.Server/Atmos/Piping/Components/AtmosPipeColorComponent.cs index ee8e55491f..a8edb07d31 100644 --- a/Content.Shared/Atmos/Components/AtmosPipeColorComponent.cs +++ b/Content.Server/Atmos/Piping/Components/AtmosPipeColorComponent.cs @@ -1,22 +1,19 @@ -using Content.Shared.Atmos.EntitySystems; -using Robust.Shared.GameStates; +using Content.Server.Atmos.Piping.EntitySystems; using JetBrains.Annotations; -namespace Content.Shared.Atmos.Components; +namespace Content.Server.Atmos.Piping.Components; -[RegisterComponent, NetworkedComponent] -[AutoGenerateComponentState] +[RegisterComponent] public sealed partial class AtmosPipeColorComponent : Component { [DataField] - [AutoNetworkedField] public Color Color { get; set; } = Color.White; [ViewVariables(VVAccess.ReadWrite), UsedImplicitly] public Color ColorVV { get => Color; - set => IoCManager.Resolve().System().SetColor((Owner, this), value); + set => IoCManager.Resolve().System().SetColor(Owner, this, value); } } diff --git a/Content.Server/Atmos/Piping/EntitySystems/AtmosPipeColorSystem.cs b/Content.Server/Atmos/Piping/EntitySystems/AtmosPipeColorSystem.cs new file mode 100644 index 0000000000..91f70467b4 --- /dev/null +++ b/Content.Server/Atmos/Piping/EntitySystems/AtmosPipeColorSystem.cs @@ -0,0 +1,48 @@ +using Content.Server.Atmos.Piping.Components; +using Content.Shared.Atmos.Piping; +using Robust.Server.GameObjects; + +namespace Content.Server.Atmos.Piping.EntitySystems +{ + public sealed class AtmosPipeColorSystem : EntitySystem + { + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnStartup); + SubscribeLocalEvent(OnShutdown); + } + + private void OnStartup(EntityUid uid, AtmosPipeColorComponent component, ComponentStartup args) + { + if (!TryComp(uid, out AppearanceComponent? appearance)) + return; + + _appearance.SetData(uid, PipeColorVisuals.Color, component.Color, appearance); + } + + private void OnShutdown(EntityUid uid, AtmosPipeColorComponent component, ComponentShutdown args) + { + if (!TryComp(uid, out AppearanceComponent? appearance)) + return; + + _appearance.SetData(uid, PipeColorVisuals.Color, Color.White, appearance); + } + + public void SetColor(EntityUid uid, AtmosPipeColorComponent component, Color color) + { + component.Color = color; + + if (!TryComp(uid, out AppearanceComponent? appearance)) + return; + + _appearance.SetData(uid, PipeColorVisuals.Color, color, appearance); + + var ev = new AtmosPipeColorChangedEvent(color); + RaiseLocalEvent(uid, ref ev); + } + } +} diff --git a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs index 89c1182eae..8237ccb2eb 100644 --- a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs +++ b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs @@ -1,6 +1,6 @@ using Content.Server.Administration.Managers; -using Content.Shared.Atmos.Components; -using Content.Shared.Atmos.EntitySystems; +using Content.Server.Atmos.Piping.Components; +using Content.Server.Atmos.Piping.EntitySystems; using Content.Shared.Administration; using Content.Shared.NodeContainer; using Content.Shared.NodeContainer.NodeGroups; @@ -78,7 +78,7 @@ namespace Content.Server.Sandbox.Commands if (!EntityManager.TryGetComponent(x.Owner, out AtmosPipeColorComponent? atmosPipeColorComponent)) continue; - _pipeColorSystem.SetColor((x.Owner, atmosPipeColorComponent), color); + _pipeColorSystem.SetColor(x.Owner, atmosPipeColorComponent, color); } } } diff --git a/Content.Server/SprayPainter/SprayPainterSystem.cs b/Content.Server/SprayPainter/SprayPainterSystem.cs index a5e08a91a6..24ab5e0ea2 100644 --- a/Content.Server/SprayPainter/SprayPainterSystem.cs +++ b/Content.Server/SprayPainter/SprayPainterSystem.cs @@ -1,5 +1,5 @@ -using Content.Shared.Atmos.Components; -using Content.Shared.Atmos.EntitySystems; +using Content.Server.Atmos.Piping.Components; +using Content.Server.Atmos.Piping.EntitySystems; using Content.Server.Charges; using Content.Server.Decals; using Content.Server.Destructible; @@ -147,7 +147,7 @@ public sealed class SprayPainterSystem : SharedSprayPainterSystem return; Audio.PlayPvs(ent.Comp.SpraySound, ent); - _pipeColor.SetColor((target, color), args.Color); + _pipeColor.SetColor(target, color, args.Color); args.Handled = true; } diff --git a/Content.Shared/Atmos/EntitySystems/AtmosPipeColorSystem.cs b/Content.Shared/Atmos/EntitySystems/AtmosPipeColorSystem.cs deleted file mode 100644 index 548136fbfa..0000000000 --- a/Content.Shared/Atmos/EntitySystems/AtmosPipeColorSystem.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Content.Shared.Atmos.Components; -using Content.Shared.Atmos.Piping; - -namespace Content.Shared.Atmos.EntitySystems; - -public sealed class AtmosPipeColorSystem : EntitySystem -{ - - [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnStartup); - SubscribeLocalEvent(OnShutdown); - } - - private void OnStartup(Entity item, ref ComponentStartup args) - { - _appearance.SetData(item.Owner, PipeColorVisuals.Color, item.Comp.Color); - } - - private void OnShutdown(Entity item, ref ComponentShutdown args) - { - _appearance.SetData(item.Owner, PipeColorVisuals.Color, Color.White); - } - - public void SetColor(Entity item, Color color) - { - item.Comp.Color = color; - _appearance.SetData(item.Owner, PipeColorVisuals.Color, color); - Dirty(item); - } -} -