More PA fixes (#18131)
If the PA Control Box isn't rotated to match the Fuel Chamber, it actually rotates itself to match. This rotation triggered a rotation event, which in turn caused RescanParts() to run again, re-entrantly. This broke everything. Fixed by adding a boolean to just guard against this.
This commit is contained in:
committed by
GitHub
parent
925971472f
commit
a90e7585b9
@@ -39,6 +39,12 @@ public sealed class ParticleAcceleratorControlBoxComponent : Component
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool Firing = false;
|
public bool Firing = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Block re-entrant rescanning.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public bool CurrentlyRescanning = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the PA is currently firing or charging to fire.
|
/// Whether the PA is currently firing or charging to fire.
|
||||||
/// Bounded by <see cref="ParticleAcceleratorPowerState.Standby"/> and <see cref="MaxStrength"/>.
|
/// Bounded by <see cref="ParticleAcceleratorPowerState.Standby"/> and <see cref="MaxStrength"/>.
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ public sealed partial class ParticleAcceleratorSystem
|
|||||||
if (!Resolve(uid, ref controller))
|
if (!Resolve(uid, ref controller))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (controller.CurrentlyRescanning)
|
||||||
|
return;
|
||||||
|
|
||||||
SwitchOff(uid, user, controller);
|
SwitchOff(uid, user, controller);
|
||||||
|
|
||||||
var partQuery = GetEntityQuery<ParticleAcceleratorPartComponent>();
|
var partQuery = GetEntityQuery<ParticleAcceleratorPartComponent>();
|
||||||
@@ -67,6 +70,11 @@ public sealed partial class ParticleAcceleratorSystem
|
|||||||
return;
|
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.
|
// 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,
|
// 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.
|
// because the sprite is far from obvious about the orientation.
|
||||||
@@ -112,6 +120,8 @@ public sealed partial class ParticleAcceleratorSystem
|
|||||||
partState.Master = uid;
|
partState.Master = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
controller.CurrentlyRescanning = false;
|
||||||
|
|
||||||
UpdatePowerDraw(uid, controller);
|
UpdatePowerDraw(uid, controller);
|
||||||
UpdateUI(uid, controller);
|
UpdateUI(uid, controller);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user