From 89522e7144c32dd798e47982d9ddedc331947318 Mon Sep 17 00:00:00 2001 From: TGRCDev Date: Wed, 11 Dec 2024 05:50:20 -0800 Subject: [PATCH] Made anchor visuals generic (#33810) Added a generic anchor visuals enum --- .../Unary/EntitySystems/GasPortableSystem.cs | 5 ----- .../Components/SharedGasPortableComponent.cs | 13 ------------- .../EntitySystems/AnchorableSystem.cs | 19 +++++++++++++++++++ .../Storage/Canisters/gas_canisters.yml | 2 +- 4 files changed, 20 insertions(+), 19 deletions(-) delete mode 100644 Content.Shared/Atmos/Piping/Unary/Components/SharedGasPortableComponent.cs diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs index b6271c22d4..128754bbf8 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs @@ -44,11 +44,6 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems return; portableNode.ConnectionsEnabled = args.Anchored; - - if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance)) - { - _appearance.SetData(uid, GasPortableVisuals.ConnectedState, args.Anchored, appearance); - } } public bool FindGasPortIn(EntityUid? gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent? port) diff --git a/Content.Shared/Atmos/Piping/Unary/Components/SharedGasPortableComponent.cs b/Content.Shared/Atmos/Piping/Unary/Components/SharedGasPortableComponent.cs deleted file mode 100644 index e0963a610c..0000000000 --- a/Content.Shared/Atmos/Piping/Unary/Components/SharedGasPortableComponent.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Robust.Shared.Serialization; - -namespace Content.Shared.Atmos.Piping.Unary.Components -{ - /// - /// Used in to determine which visuals to update. - /// - [Serializable, NetSerializable] - public enum GasPortableVisuals - { - ConnectedState, - } -} diff --git a/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs b/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs index efb5dfd024..9c3d6fc9fb 100644 --- a/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs +++ b/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs @@ -31,6 +31,7 @@ public sealed partial class AnchorableSystem : EntitySystem [Dependency] private readonly SharedToolSystem _tool = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly TagSystem _tagSystem = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; private EntityQuery _physicsQuery; @@ -47,6 +48,18 @@ public sealed partial class AnchorableSystem : EntitySystem SubscribeLocalEvent(OnAnchorComplete); SubscribeLocalEvent(OnUnanchorComplete); SubscribeLocalEvent(OnAnchoredExamine); + SubscribeLocalEvent(OnAnchorStartup); + SubscribeLocalEvent(OnAnchorStateChange); + } + + private void OnAnchorStartup(EntityUid uid, AnchorableComponent comp, ComponentStartup args) + { + _appearance.SetData(uid, AnchorVisuals.Anchored, Transform(uid).Anchored); + } + + private void OnAnchorStateChange(EntityUid uid, AnchorableComponent comp, AnchorStateChangedEvent args) + { + _appearance.SetData(uid, AnchorVisuals.Anchored, args.Anchored); } /// @@ -343,3 +356,9 @@ public sealed partial class AnchorableSystem : EntitySystem { } } + +[Serializable, NetSerializable] +public enum AnchorVisuals : byte +{ + Anchored +} diff --git a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml index f51f455e2f..1db376ceeb 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml @@ -16,7 +16,7 @@ - type: Appearance - type: GenericVisualizer visuals: - enum.GasPortableVisuals.ConnectedState: + enum.AnchorVisuals.Anchored: connectedToPort: False: { state: can-connector, visible: false } True: { state: can-connector, visible: true } -- 2.51.2