diff --git a/Content.Server/Gravity/GravityGeneratorSystem.cs b/Content.Server/Gravity/GravityGeneratorSystem.cs index 5ab2dc8931..9d58b82d69 100644 --- a/Content.Server/Gravity/GravityGeneratorSystem.cs +++ b/Content.Server/Gravity/GravityGeneratorSystem.cs @@ -36,8 +36,10 @@ public sealed class GravityGeneratorSystem : EntitySystem private void OnActivated(Entity ent, ref ChargedMachineActivatedEvent args) { ent.Comp.GravityActive = true; - if (TryComp(ent, out var xform) && - TryComp(xform.ParentUid, out GravityComponent? gravity)) + + var xform = Transform(ent); + + if (TryComp(xform.ParentUid, out GravityComponent? gravity)) { _gravitySystem.EnableGravity(xform.ParentUid, gravity); } @@ -46,8 +48,10 @@ public sealed class GravityGeneratorSystem : EntitySystem private void OnDeactivated(Entity ent, ref ChargedMachineDeactivatedEvent args) { ent.Comp.GravityActive = false; - if (TryComp(ent, out var xform) && - TryComp(xform.ParentUid, out GravityComponent? gravity)) + + var xform = Transform(ent); + + if (TryComp(xform.ParentUid, out GravityComponent? gravity)) { _gravitySystem.RefreshGravity(xform.ParentUid, gravity); }