Files
tbd-station-14/Content.Shared/Transform/TransformExtensions.cs
2021-06-09 22:19:39 +02:00

27 lines
635 B
C#

#nullable enable
using Robust.Shared.GameObjects;
namespace Content.Shared.Transform
{
public static class TransformExtensions
{
public static void AttachToGrandparent(this ITransformComponent transform)
{
var grandParent = transform.Parent?.Parent;
if (grandParent == null)
{
transform.AttachToGridOrMap();
return;
}
transform.AttachParent(grandParent);
}
public static void AttachToGrandparent(this IEntity entity)
{
AttachToGrandparent(entity.Transform);
}
}
}