Revert "Fix bug with pipe color" (#39135)

This commit is contained in:
ArtisticRoomba
2025-08-04 13:10:54 -07:00
committed by GitHub
parent f6737d4a57
commit e996fb62f1
7 changed files with 59 additions and 105 deletions

View File

@@ -1,46 +1,11 @@
using Content.Client.Atmos.Components; using Content.Client.Atmos.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Content.Client.UserInterface.Systems.Storage.Controls;
using Content.Shared.Atmos.Piping; using Content.Shared.Atmos.Piping;
using Content.Shared.Hands;
using Content.Shared.Atmos.Components;
using Content.Shared.Item;
namespace Content.Client.Atmos.EntitySystems; namespace Content.Client.Atmos.EntitySystems;
public sealed class PipeColorVisualizerSystem : VisualizerSystem<PipeColorVisualsComponent> public sealed class PipeColorVisualizerSystem : VisualizerSystem<PipeColorVisualsComponent>
{ {
[Dependency] private readonly SharedItemSystem _itemSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PipeColorVisualsComponent, GetInhandVisualsEvent>(OnGetVisuals);
SubscribeLocalEvent<PipeColorVisualsComponent, BeforeRenderInGridEvent>(OnDrawInGrid);
}
/// <summary>
/// This method is used to display the color changes of the pipe on the screen..
/// </summary>
private void OnGetVisuals(Entity<PipeColorVisualsComponent> item, ref GetInhandVisualsEvent args)
{
foreach (var (_, layerData) in args.Layers)
{
if (TryComp(item.Owner, out AtmosPipeColorComponent? pipeColor))
layerData.Color = pipeColor.Color;
}
}
/// <summary>
/// This method is used to change the pipe's color in a container grid.
/// </summary>
private void OnDrawInGrid(Entity<PipeColorVisualsComponent> 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) protected override void OnAppearanceChange(EntityUid uid, PipeColorVisualsComponent component, ref AppearanceChangeEvent args)
{ {
if (TryComp<SpriteComponent>(uid, out var sprite) if (TryComp<SpriteComponent>(uid, out var sprite)
@@ -50,8 +15,6 @@ public sealed class PipeColorVisualizerSystem : VisualizerSystem<PipeColorVisual
var layer = sprite[PipeVisualLayers.Pipe]; var layer = sprite[PipeVisualLayers.Pipe];
layer.Color = color.WithAlpha(layer.Color.A); layer.Color = color.WithAlpha(layer.Color.A);
} }
_itemSystem.VisualsChanged(uid);
} }
} }

View File

@@ -185,12 +185,7 @@ public sealed class ItemGridPiece : Control, IEntityControl
handle.SetTransform(pos, iconRotation); handle.SetTransform(pos, iconRotation);
var box = new UIBox2(root, root + sprite.Size * scale); var box = new UIBox2(root, root + sprite.Size * scale);
handle.DrawTextureRect(sprite, box);
var ev = new BeforeRenderInGridEvent(new Color(255, 255, 255));
_entityManager.EventBus.RaiseLocalEvent(Entity, ev);
handle.DrawTextureRect(sprite, box, ev.Color);
handle.SetTransform(GlobalPixelPosition, Angle.Zero); handle.SetTransform(GlobalPixelPosition, Angle.Zero);
} }
else else
@@ -303,19 +298,6 @@ public sealed class ItemGridPiece : Control, IEntityControl
public EntityUid? UiEntity => Entity; public EntityUid? UiEntity => Entity;
} }
/// <summary>
/// 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.
/// </summary>
public sealed class BeforeRenderInGridEvent : EntityEventArgs
{
public Color Color { get; set; }
public BeforeRenderInGridEvent(Color color)
{
Color = color;
}
}
public enum ItemGridPieceMarks public enum ItemGridPieceMarks
{ {
First, First,

View File

@@ -1,22 +1,19 @@
using Content.Shared.Atmos.EntitySystems; using Content.Server.Atmos.Piping.EntitySystems;
using Robust.Shared.GameStates;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Content.Shared.Atmos.Components; namespace Content.Server.Atmos.Piping.Components;
[RegisterComponent, NetworkedComponent] [RegisterComponent]
[AutoGenerateComponentState]
public sealed partial class AtmosPipeColorComponent : Component public sealed partial class AtmosPipeColorComponent : Component
{ {
[DataField] [DataField]
[AutoNetworkedField]
public Color Color { get; set; } = Color.White; public Color Color { get; set; } = Color.White;
[ViewVariables(VVAccess.ReadWrite), UsedImplicitly] [ViewVariables(VVAccess.ReadWrite), UsedImplicitly]
public Color ColorVV public Color ColorVV
{ {
get => Color; get => Color;
set => IoCManager.Resolve<IEntityManager>().System<AtmosPipeColorSystem>().SetColor((Owner, this), value); set => IoCManager.Resolve<IEntityManager>().System<AtmosPipeColorSystem>().SetColor(Owner, this, value);
} }
} }

View File

@@ -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<AtmosPipeColorComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<AtmosPipeColorComponent, ComponentShutdown>(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);
}
}
}

View File

@@ -1,6 +1,6 @@
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Shared.Atmos.Components; using Content.Server.Atmos.Piping.Components;
using Content.Shared.Atmos.EntitySystems; using Content.Server.Atmos.Piping.EntitySystems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.NodeContainer; using Content.Shared.NodeContainer;
using Content.Shared.NodeContainer.NodeGroups; using Content.Shared.NodeContainer.NodeGroups;
@@ -78,7 +78,7 @@ namespace Content.Server.Sandbox.Commands
if (!EntityManager.TryGetComponent(x.Owner, out AtmosPipeColorComponent? atmosPipeColorComponent)) if (!EntityManager.TryGetComponent(x.Owner, out AtmosPipeColorComponent? atmosPipeColorComponent))
continue; continue;
_pipeColorSystem.SetColor((x.Owner, atmosPipeColorComponent), color); _pipeColorSystem.SetColor(x.Owner, atmosPipeColorComponent, color);
} }
} }
} }

View File

@@ -1,5 +1,5 @@
using Content.Shared.Atmos.Components; using Content.Server.Atmos.Piping.Components;
using Content.Shared.Atmos.EntitySystems; using Content.Server.Atmos.Piping.EntitySystems;
using Content.Server.Charges; using Content.Server.Charges;
using Content.Server.Decals; using Content.Server.Decals;
using Content.Server.Destructible; using Content.Server.Destructible;
@@ -147,7 +147,7 @@ public sealed class SprayPainterSystem : SharedSprayPainterSystem
return; return;
Audio.PlayPvs(ent.Comp.SpraySound, ent); Audio.PlayPvs(ent.Comp.SpraySound, ent);
_pipeColor.SetColor((target, color), args.Color); _pipeColor.SetColor(target, color, args.Color);
args.Handled = true; args.Handled = true;
} }

View File

@@ -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<AtmosPipeColorComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<AtmosPipeColorComponent, ComponentShutdown>(OnShutdown);
}
private void OnStartup(Entity<AtmosPipeColorComponent> item, ref ComponentStartup args)
{
_appearance.SetData(item.Owner, PipeColorVisuals.Color, item.Comp.Color);
}
private void OnShutdown(Entity<AtmosPipeColorComponent> item, ref ComponentShutdown args)
{
_appearance.SetData(item.Owner, PipeColorVisuals.Color, Color.White);
}
public void SetColor(Entity<AtmosPipeColorComponent> item, Color color)
{
item.Comp.Color = color;
_appearance.SetData(item.Owner, PipeColorVisuals.Color, color);
Dirty(item);
}
}