Use Transform instead of TryComp<TransformComponent> (#32170)

Use Transform instead of TryComp
This commit is contained in:
Winkarst
2024-09-15 00:34:44 +03:00
committed by GitHub
parent 4da704fd9c
commit b33aa1aaee

View 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);
}