]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Made anchor visuals generic (#33810)
authorTGRCDev <tgrc@tgrc.dev>
Wed, 11 Dec 2024 13:50:20 +0000 (05:50 -0800)
committerGitHub <noreply@github.com>
Wed, 11 Dec 2024 13:50:20 +0000 (14:50 +0100)
Added a generic anchor visuals enum

Content.Server/Atmos/Piping/Unary/EntitySystems/GasPortableSystem.cs
Content.Shared/Atmos/Piping/Unary/Components/SharedGasPortableComponent.cs [deleted file]
Content.Shared/Construction/EntitySystems/AnchorableSystem.cs
Resources/Prototypes/Entities/Structures/Storage/Canisters/gas_canisters.yml

index b6271c22d4c258f3eb27040639f50895a5d17cda..128754bbf8c4f54b60574ae3501e0b62a52fb864 100644 (file)
@@ -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 (file)
index e0963a6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-using Robust.Shared.Serialization;
-
-namespace Content.Shared.Atmos.Piping.Unary.Components
-{
-    /// <summary>
-    /// Used in <see cref="GasPortableVisualizer"/> to determine which visuals to update.
-    /// </summary>
-    [Serializable, NetSerializable]
-        public enum GasPortableVisuals
-        {
-            ConnectedState,
-        }
-}
index efb5dfd024820375bddf73764f90ee595d755fb8..9c3d6fc9fb3245cdb01595993d862e57f64274f7 100644 (file)
@@ -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<PhysicsComponent> _physicsQuery;
 
@@ -47,6 +48,18 @@ public sealed partial class AnchorableSystem : EntitySystem
         SubscribeLocalEvent<AnchorableComponent, TryAnchorCompletedEvent>(OnAnchorComplete);
         SubscribeLocalEvent<AnchorableComponent, TryUnanchorCompletedEvent>(OnUnanchorComplete);
         SubscribeLocalEvent<AnchorableComponent, ExaminedEvent>(OnAnchoredExamine);
+        SubscribeLocalEvent<AnchorableComponent, ComponentStartup>(OnAnchorStartup);
+        SubscribeLocalEvent<AnchorableComponent, AnchorStateChangedEvent>(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);
     }
 
     /// <summary>
@@ -343,3 +356,9 @@ public sealed partial class AnchorableSystem : EntitySystem
     {
     }
 }
+
+[Serializable, NetSerializable]
+public enum AnchorVisuals : byte
+{
+    Anchored
+}
index f51f455e2f20bf62314e4468cb4cd23b186d933e..1db376ceeb24ae5b5484da72107265180958d086 100644 (file)
@@ -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 }