]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Remove PA component references (#15252)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Mon, 10 Apr 2023 04:10:33 +0000 (21:10 -0700)
committerGitHub <noreply@github.com>
Mon, 10 Apr 2023 04:10:33 +0000 (14:10 +1000)
Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs
Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs
Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEndCapComponent.cs
Content.Server/ParticleAccelerator/Components/ParticleAcceleratorFuelChamberComponent.cs
Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPartComponent.cs
Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPowerBoxComponent.cs
Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.PowerBox.cs
Resources/Prototypes/Entities/Structures/Power/Generation/PA/emitter.yml
Resources/Prototypes/Entities/Structures/Power/Generation/PA/end_cap.yml
Resources/Prototypes/Entities/Structures/Power/Generation/PA/fuel_chamber.yml
Resources/Prototypes/Entities/Structures/Power/Generation/PA/power_box.yml

index 435b285421b95ddcf4f110eb467751c9d201615b..09e19122d5c5cbdb655e870b16d521d3e41e1f05 100644 (file)
@@ -7,15 +7,15 @@ using Content.Server.Power.Components;
 using Content.Server.Power.EntitySystems;
 using Content.Server.UserInterface;
 using Content.Shared.Database;
-// using Content.Server.WireHacking;
 using Content.Shared.Singularity.Components;
 using Robust.Server.GameObjects;
 using Robust.Server.Player;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Utility;
-// using static Content.Shared.Wires.SharedWiresComponent;
 using Timer = Robust.Shared.Timing.Timer;
+// using Content.Server.WireHacking;
+// using static Content.Shared.Wires.SharedWiresComponent;
 
 namespace Content.Server.ParticleAccelerator.Components
 {
@@ -191,7 +191,8 @@ namespace Content.Server.ParticleAccelerator.Components
             Master = null;
             foreach (var part in AllParts())
             {
-                part.Master = null;
+                if (_entMan.TryGetComponent(part.Owner, out ParticleAcceleratorPartComponent? paPart))
+                    paPart.Master = null;
             }
 
             base.OnRemove();
@@ -322,7 +323,8 @@ namespace Content.Server.ParticleAccelerator.Components
             SwitchOff(playerSession, true);
             foreach (var part in AllParts())
             {
-                part.Master = null;
+                if (_entMan.TryGetComponent(part.Owner, out ParticleAcceleratorPartComponent? paPart))
+                    paPart.Master = null;
             }
 
             _isAssembled = false;
@@ -395,7 +397,8 @@ namespace Content.Server.ParticleAccelerator.Components
 
             foreach (var part in AllParts())
             {
-                part.Master = this;
+                if (_entMan.TryGetComponent(part.Owner, out ParticleAcceleratorPartComponent? paPart))
+                    paPart.Master = this;
             }
 
             UpdateUI();
@@ -408,7 +411,7 @@ namespace Content.Server.ParticleAccelerator.Components
         }
 
         private bool ScanPart<T>(Vector2i offset, [NotNullWhen(true)] out T? part)
-            where T : ParticleAcceleratorPartComponent
+            where T : Component
         {
             var xform = _entMan.GetComponent<TransformComponent>(Owner);
             if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
@@ -430,7 +433,7 @@ namespace Content.Server.ParticleAccelerator.Components
             return false;
         }
 
-        private IEnumerable<ParticleAcceleratorPartComponent> AllParts()
+        private IEnumerable<Component> AllParts()
         {
             if (_partFuelChamber != null)
                 yield return _partFuelChamber;
@@ -668,7 +671,7 @@ namespace Content.Server.ParticleAccelerator.Components
             //no endcap because it has no powerlevel-sprites
         }
 
-        private void UpdatePartVisualState(ParticleAcceleratorPartComponent? component)
+        private void UpdatePartVisualState(Component? component)
         {
             if (component == null || !_entMan.TryGetComponent<AppearanceComponent?>(component.Owner, out var appearanceComponent))
             {
@@ -681,12 +684,6 @@ namespace Content.Server.ParticleAccelerator.Components
             appearanceComponent.SetData(ParticleAcceleratorVisuals.VisualState, state);
         }
 
-        public override void Moved()
-        {
-            // We rotate OURSELVES when scanning for parts, so don't actually run rescan on rotate.
-            // That would be silly.
-        }
-
         public enum ParticleAcceleratorControlBoxWires
         {
             /// <summary>
index 7f6650bd18bab8d055e51ffe628ed2e423ffefbe..8dc3658824eb630a7f7ecef5dfd73133fdc84e92 100644 (file)
@@ -3,8 +3,7 @@
 namespace Content.Server.ParticleAccelerator.Components
 {
     [RegisterComponent]
-    [ComponentReference(typeof(ParticleAcceleratorPartComponent))]
-    public sealed class ParticleAcceleratorEmitterComponent : ParticleAcceleratorPartComponent
+    public sealed class ParticleAcceleratorEmitterComponent : Component
     {
         [DataField("emitterType")]
         public ParticleAcceleratorEmitterType Type = ParticleAcceleratorEmitterType.Center;
index 3b6708819744d4c90bc2adfe92951a0041d5f850..4103e89ff9715dec0e37bbfb161b651793713487 100644 (file)
@@ -1,8 +1,6 @@
-namespace Content.Server.ParticleAccelerator.Components
+namespace Content.Server.ParticleAccelerator.Components;
+
+[RegisterComponent]
+public sealed class ParticleAcceleratorEndCapComponent : Component
 {
-    [RegisterComponent]
-    [ComponentReference(typeof(ParticleAcceleratorPartComponent))]
-    public sealed class ParticleAcceleratorEndCapComponent : ParticleAcceleratorPartComponent
-    {
-    }
 }
index d62558fb1a680840597cfdb3e579eb09100af14c..2a87bcdeb8f4e6c3102ba760ae524911c3dd7397 100644 (file)
@@ -1,8 +1,6 @@
-namespace Content.Server.ParticleAccelerator.Components
+namespace Content.Server.ParticleAccelerator.Components;
+
+[RegisterComponent]
+public sealed class ParticleAcceleratorFuelChamberComponent : Component
 {
-    [RegisterComponent]
-    [ComponentReference(typeof(ParticleAcceleratorPartComponent))]
-    public sealed class ParticleAcceleratorFuelChamberComponent : ParticleAcceleratorPartComponent
-    {
-    }
 }
index fe73f1c961f786a1030b45f4ca2b5a18c9f5b2c6..7fdf68702644738d0550aff04c6c9c3a8740c6f9 100644 (file)
@@ -1,6 +1,8 @@
 namespace Content.Server.ParticleAccelerator.Components
 {
-    public abstract class ParticleAcceleratorPartComponent : Component
+    [RegisterComponent]
+    [Virtual]
+    public class ParticleAcceleratorPartComponent : Component
     {
         [ViewVariables] public ParticleAcceleratorControlBoxComponent? Master;
 
@@ -29,7 +31,7 @@ namespace Content.Server.ParticleAccelerator.Components
             Master?.RescanParts();
         }
 
-        public virtual void Moved()
+        public void Moved()
         {
             RescanIfPossible();
         }
index afe214e79a83469332da9f1d34112c5e915fe169..f9f9e06876e9593edca077913ff09e1f473070c9 100644 (file)
@@ -1,18 +1,16 @@
 using Content.Server.Power.Components;
 
-namespace Content.Server.ParticleAccelerator.Components
+namespace Content.Server.ParticleAccelerator.Components;
+
+[RegisterComponent]
+public sealed class ParticleAcceleratorPowerBoxComponent : Component
 {
-    [RegisterComponent]
-    [ComponentReference(typeof(ParticleAcceleratorPartComponent))]
-    public sealed class ParticleAcceleratorPowerBoxComponent : ParticleAcceleratorPartComponent
-    {
-        [ViewVariables] public PowerConsumerComponent? PowerConsumerComponent;
+    [ViewVariables] public PowerConsumerComponent? PowerConsumerComponent;
 
-        protected override void Initialize()
-        {
-            base.Initialize();
+    protected override void Initialize()
+    {
+        base.Initialize();
 
-            PowerConsumerComponent = Owner.EnsureComponentWarn<PowerConsumerComponent>();
-        }
+        PowerConsumerComponent = Owner.EnsureComponentWarn<PowerConsumerComponent>();
     }
 }
index 87d1fa0344578bba7fa2c734b5e8cdc2e3513d7c..ff8defbbc5c57432ef76dc9e2f80c83bfe069acd 100644 (file)
@@ -10,12 +10,13 @@ namespace Content.Server.ParticleAccelerator.EntitySystems
             SubscribeLocalEvent<ParticleAcceleratorPowerBoxComponent, PowerConsumerReceivedChanged>(PowerBoxReceivedChanged);
         }
 
-        private static void PowerBoxReceivedChanged(
+        private void PowerBoxReceivedChanged(
             EntityUid uid,
             ParticleAcceleratorPowerBoxComponent component,
             ref PowerConsumerReceivedChanged args)
         {
-            component.Master?.PowerBoxReceivedChanged(args);
+            if (TryComp(uid, out ParticleAcceleratorPartComponent? paPart))
+                paPart.Master?.PowerBoxReceivedChanged(args);
         }
     }
 }
index 61e2a09c1589b29fa36aefae86e496f277e58bec..56454ea874dadc0156283103e93b93512c4f03b5 100644 (file)
@@ -17,6 +17,7 @@
       visuals:
         - type: ParticleAcceleratorPartVisualizer
           baseState: unlit
+    - type: ParticleAcceleratorPart
     - type: ParticleAcceleratorEmitter
       emitterType: Left
     - type: Construction
@@ -45,6 +46,7 @@
       visuals:
         - type: ParticleAcceleratorPartVisualizer
           baseState: unlit
+    - type: ParticleAcceleratorPart
     - type: ParticleAcceleratorEmitter
       emitterType: Center
     - type: Construction
@@ -52,7 +54,7 @@
       node: completed
     - type: GuideHelp
       guides: [ Singularity, Power ]
-      
+
 - type: entity
   parent: ParticleAcceleratorBase
   id: ParticleAcceleratorEmitterRight
@@ -72,6 +74,7 @@
       visuals:
         - type: ParticleAcceleratorPartVisualizer
           baseState: unlit
+    - type: ParticleAcceleratorPart
     - type: ParticleAcceleratorEmitter
       emitterType: Right
     - type: Construction
@@ -79,7 +82,7 @@
       node: completed
     - type: GuideHelp
       guides: [ Singularity, Power ]
-      
+
 # Unfinished
 
 - type: entity
       node: start
       defaultTarget: completed
     - type: GuideHelp
-      guides: [ Singularity, Power ]
\ No newline at end of file
+      guides: [ Singularity, Power ]
index a535e6458f5f44956c1e2665b91175bf4a3f0eb3..3622206d7d60341445fdaff4d01bf8243e3faf63 100644 (file)
@@ -7,6 +7,7 @@
     - type: Sprite
       sprite: Structures/Power/Generation/PA/end_cap.rsi
       state: capc
+    - type: ParticleAcceleratorPart
     - type: ParticleAcceleratorEndCap
     - type: Construction
       graph: ParticleAcceleratorEndCap
@@ -33,4 +34,4 @@
       node: start
       defaultTarget: completed
     - type: GuideHelp
-      guides: [ Singularity, Power ]
\ No newline at end of file
+      guides: [ Singularity, Power ]
index a17a423d57fcaa5522ca46f39015fca152be514d..9f5a0c617ba8ba2c4917e56468a4123679bd07f5 100644 (file)
       visuals:
         - type: ParticleAcceleratorPartVisualizer
           baseState: unlit
+    - type: ParticleAcceleratorPart
     - type: ParticleAcceleratorFuelChamber
     - type: Construction
       graph: ParticleAcceleratorFuelChamber
       node: completed
     - type: GuideHelp
       guides: [ Singularity, Power ]
-      
+
 # Unfinished
 
 - type: entity
@@ -43,4 +44,4 @@
       node: start
       defaultTarget: completed
     - type: GuideHelp
-      guides: [ Singularity, Power ]
\ No newline at end of file
+      guides: [ Singularity, Power ]
index f130860708ff86262638e2d77329b0a784cb38d1..ff0a482fd3c63b35f9d19bb8557bd816654314eb 100644 (file)
@@ -17,6 +17,7 @@
       visuals:
         - type: ParticleAcceleratorPartVisualizer
           baseState: unlit
+    - type: ParticleAcceleratorPart
     - type: ParticleAcceleratorPowerBox
     - type: PowerConsumer
       voltage: High
@@ -49,4 +50,4 @@
       node: start
       defaultTarget: completed
     - type: GuideHelp
-      guides: [ Singularity, Power ]
\ No newline at end of file
+      guides: [ Singularity, Power ]