2021-07-17 02:37:09 +02:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 14:20:34 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Shared.Transform
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
|
|
|
|
|
public static class TransformExtensions
|
|
|
|
|
|
{
|
2021-11-08 12:37:32 +01:00
|
|
|
|
public static void AttachToGrandparent(this TransformComponent transform)
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
|
|
|
|
|
var grandParent = transform.Parent?.Parent;
|
|
|
|
|
|
|
|
|
|
|
|
if (grandParent == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
transform.AttachToGridOrMap();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
transform.AttachParent(grandParent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-04 12:59:44 +01:00
|
|
|
|
public static void AttachToGrandparent(this EntityUid entity)
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
2021-12-03 15:53:09 +01:00
|
|
|
|
AttachToGrandparent(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity));
|
2020-10-10 15:25:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|