From 39f272fa5c63623813fb98d48eacf78b77035283 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sun, 9 Apr 2023 21:10:33 -0700 Subject: [PATCH] Remove PA component references (#15252) --- .../ParticleAcceleratorControlBoxComponent.cs | 25 ++++++++----------- .../ParticleAcceleratorEmitterComponent.cs | 3 +-- .../ParticleAcceleratorEndCapComponent.cs | 10 +++----- ...ParticleAcceleratorFuelChamberComponent.cs | 10 +++----- .../ParticleAcceleratorPartComponent.cs | 6 +++-- .../ParticleAcceleratorPowerBoxComponent.cs | 20 +++++++-------- .../ParticleAcceleratorSystem.PowerBox.cs | 5 ++-- .../Power/Generation/PA/emitter.yml | 9 ++++--- .../Power/Generation/PA/end_cap.yml | 3 ++- .../Power/Generation/PA/fuel_chamber.yml | 5 ++-- .../Power/Generation/PA/power_box.yml | 3 ++- 11 files changed, 49 insertions(+), 50 deletions(-) diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index 435b285421..09e19122d5 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -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(Vector2i offset, [NotNullWhen(true)] out T? part) - where T : ParticleAcceleratorPartComponent + where T : Component { var xform = _entMan.GetComponent(Owner); if (!_mapManager.TryGetGrid(xform.GridUid, out var grid)) @@ -430,7 +433,7 @@ namespace Content.Server.ParticleAccelerator.Components return false; } - private IEnumerable AllParts() + private IEnumerable 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(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 { /// diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs index 7f6650bd18..8dc3658824 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs @@ -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; diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEndCapComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEndCapComponent.cs index 3b67088197..4103e89ff9 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEndCapComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEndCapComponent.cs @@ -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 - { - } } diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorFuelChamberComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorFuelChamberComponent.cs index d62558fb1a..2a87bcdeb8 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorFuelChamberComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorFuelChamberComponent.cs @@ -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 - { - } } diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPartComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPartComponent.cs index fe73f1c961..7fdf687026 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPartComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPartComponent.cs @@ -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(); } diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPowerBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPowerBoxComponent.cs index afe214e79a..f9f9e06876 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPowerBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorPowerBoxComponent.cs @@ -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 = Owner.EnsureComponentWarn(); } } diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.PowerBox.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.PowerBox.cs index 87d1fa0344..ff8defbbc5 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.PowerBox.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.PowerBox.cs @@ -10,12 +10,13 @@ namespace Content.Server.ParticleAccelerator.EntitySystems SubscribeLocalEvent(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); } } } diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/emitter.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/emitter.yml index 61e2a09c15..56454ea874 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/emitter.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/emitter.yml @@ -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 @@ -137,4 +140,4 @@ node: start defaultTarget: completed - type: GuideHelp - guides: [ Singularity, Power ] \ No newline at end of file + guides: [ Singularity, Power ] diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/end_cap.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/end_cap.yml index a535e6458f..3622206d7d 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/end_cap.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/end_cap.yml @@ -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 ] diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/fuel_chamber.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/fuel_chamber.yml index a17a423d57..9f5a0c617b 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/fuel_chamber.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/fuel_chamber.yml @@ -17,13 +17,14 @@ 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 ] diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/power_box.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/power_box.yml index f130860708..ff0a482fd3 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/PA/power_box.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/PA/power_box.yml @@ -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 ] -- 2.51.2