diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index a48d7576e2..035c6ead72 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -39,6 +39,12 @@ public sealed class ParticleAcceleratorControlBoxComponent : Component [ViewVariables] public bool Firing = false; + /// + /// Block re-entrant rescanning. + /// + [ViewVariables(VVAccess.ReadWrite)] + public bool CurrentlyRescanning = false; + /// /// Whether the PA is currently firing or charging to fire. /// Bounded by and . diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs index fc8272185d..860fbdcefe 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs @@ -23,6 +23,9 @@ public sealed partial class ParticleAcceleratorSystem if (!Resolve(uid, ref controller)) return; + if (controller.CurrentlyRescanning) + return; + SwitchOff(uid, user, controller); var partQuery = GetEntityQuery(); @@ -67,6 +70,11 @@ public sealed partial class ParticleAcceleratorSystem return; } + // When we call SetLocalRotation down there to rotate the control box, + // that ends up re-entrantly calling RescanParts() through the move event. + // You'll have to take my word for it that that breaks everything, yeah? + controller.CurrentlyRescanning = true; + // Align ourselves to match fuel chamber orientation. // This means that if you mess up the orientation of the control box it's not a big deal, // because the sprite is far from obvious about the orientation. @@ -112,6 +120,8 @@ public sealed partial class ParticleAcceleratorSystem partState.Master = uid; } + controller.CurrentlyRescanning = false; + UpdatePowerDraw(uid, controller); UpdateUI(uid, controller); }