]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Use Transform instead of TryComp<TransformComponent> (#32170)
authorWinkarst <74284083+Winkarst-cpu@users.noreply.github.com>
Sat, 14 Sep 2024 21:34:44 +0000 (00:34 +0300)
committerGitHub <noreply@github.com>
Sat, 14 Sep 2024 21:34:44 +0000 (23:34 +0200)
Use Transform instead of TryComp

Content.Server/Gravity/GravityGeneratorSystem.cs

index 5ab2dc893108b5902793a930bf74c7006202767d..9d58b82d690c7bb83c98e158756aa92079a10ac0 100644 (file)
@@ -36,8 +36,10 @@ public sealed class GravityGeneratorSystem : EntitySystem
     private void OnActivated(Entity<GravityGeneratorComponent> ent, ref ChargedMachineActivatedEvent args)
     {
         ent.Comp.GravityActive = true;
-        if (TryComp<TransformComponent>(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<GravityGeneratorComponent> ent, ref ChargedMachineDeactivatedEvent args)
     {
         ent.Comp.GravityActive = false;
-        if (TryComp<TransformComponent>(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);
         }