Files
tbd-station-14/Content.Shared/Transform/TransformExtensions.cs
Vera Aguilera Puerto a5b57c8e10 Inline Transform
2021-12-03 14:20:34 +01:00

27 lines
707 B
C#

using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Shared.Transform
{
public static class TransformExtensions
{
public static void AttachToGrandparent(this TransformComponent transform)
{
var grandParent = transform.Parent?.Parent;
if (grandParent == null)
{
transform.AttachToGridOrMap();
return;
}
transform.AttachParent(grandParent);
}
public static void AttachToGrandparent(this IEntity entity)
{
AttachToGrandparent(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid));
}
}
}