Another QSI Fix About Things Being in Places they Should not (#30241)

* Another QSI Fix About Things Being in Places they Should not

* cleanup
This commit is contained in:
Cojoke
2024-07-30 09:07:35 -05:00
committed by GitHub
parent 9e1e9b8c34
commit ea136838c0

View File

@@ -150,8 +150,11 @@ public sealed class SwapTeleporterSystem : EntitySystem
return;
}
var (teleEnt, cont) = GetTeleportingEntity((uid, xform));
var (otherTeleEnt, otherCont) = GetTeleportingEntity((linkedEnt, Transform(linkedEnt)));
var teleEnt = GetTeleportingEntity((uid, xform));
var otherTeleEnt = GetTeleportingEntity((linkedEnt, Transform(linkedEnt)));
_container.TryGetOuterContainer(teleEnt, Transform(teleEnt), out var cont);
_container.TryGetOuterContainer(otherTeleEnt, Transform(otherTeleEnt), out var otherCont);
if (otherCont != null && !_container.CanInsert(teleEnt, otherCont) ||
cont != null && !_container.CanInsert(otherTeleEnt, cont))
@@ -195,20 +198,18 @@ public sealed class SwapTeleporterSystem : EntitySystem
DestroyLink(linked, user); // the linked one is shown globally
}
private (EntityUid, BaseContainer?) GetTeleportingEntity(Entity<TransformComponent> ent)
private EntityUid GetTeleportingEntity(Entity<TransformComponent> ent)
{
var parent = ent.Comp.ParentUid;
if (_container.TryGetOuterContainer(ent, ent, out var container))
parent = container.Owner;
if (HasComp<MapGridComponent>(parent) || HasComp<MapComponent>(parent))
return (ent, container);
return ent;
if (!_xformQuery.TryGetComponent(parent, out var parentXform) || parentXform.Anchored)
return (ent, container);
return ent;
if (!TryComp<PhysicsComponent>(parent, out var body) || body.BodyType == BodyType.Static)
return (ent, container);
return ent;
return GetTeleportingEntity((parent, parentXform));
}