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<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)
{
if (TryComp<SpriteComponent>(uid, out var sprite)
var layer = sprite[PipeVisualLayers.Pipe];
layer.Color = color.WithAlpha(layer.Color.A);
}
-
- _itemSystem.VisualsChanged(uid);
}
}
handle.SetTransform(pos, iconRotation);
var box = new UIBox2(root, root + sprite.Size * scale);
-
- var ev = new BeforeRenderInGridEvent(new Color(255, 255, 255));
- _entityManager.EventBus.RaiseLocalEvent(Entity, ev);
-
- handle.DrawTextureRect(sprite, box, ev.Color);
-
+ handle.DrawTextureRect(sprite, box);
handle.SetTransform(GlobalPixelPosition, Angle.Zero);
}
else
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
{
First,
-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<IEntityManager>().System<AtmosPipeColorSystem>().SetColor((Owner, this), value);
+ set => IoCManager.Resolve<IEntityManager>().System<AtmosPipeColorSystem>().SetColor(Owner, this, value);
}
}
--- /dev/null
+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);
+ }
+ }
+}
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;
if (!EntityManager.TryGetComponent(x.Owner, out AtmosPipeColorComponent? atmosPipeColorComponent))
continue;
- _pipeColorSystem.SetColor((x.Owner, atmosPipeColorComponent), color);
+ _pipeColorSystem.SetColor(x.Owner, atmosPipeColorComponent, color);
}
}
}
-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;
return;
Audio.PlayPvs(ent.Comp.SpraySound, ent);
- _pipeColor.SetColor((target, color), args.Color);
+ _pipeColor.SetColor(target, color, args.Color);
args.Handled = true;
}
+++ /dev/null
-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);
- }
-}
-