diff --git a/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs b/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs
index 0fbaefc31b..69805fd585 100644
--- a/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs
+++ b/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs
@@ -8,6 +8,7 @@ using Content.Shared.Whitelist;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Map.Components;
+using Robust.Shared.Network;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing;
@@ -20,6 +21,7 @@ namespace Content.Shared.Teleportation.Systems;
public sealed class SwapTeleporterSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
+ [Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
@@ -145,19 +147,16 @@ public sealed class SwapTeleporterSystem : EntitySystem
comp.TeleportTime = null;
Dirty(uid, comp);
- if (comp.LinkedEnt is not { } linkedEnt)
- {
+ // We can't run the teleport logic on the client due to PVS range issues.
+ if (_net.IsClient || comp.LinkedEnt is not { } linkedEnt)
return;
- }
var teleEnt = GetTeleportingEntity((uid, xform));
var otherTeleEnt = GetTeleportingEntity((linkedEnt, Transform(linkedEnt)));
+ var teleXform = Transform(teleEnt);
+ var otherTeleXform = Transform(otherTeleEnt);
- _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))
+ if (!CanSwapTeleport((teleEnt, teleXform), (otherTeleEnt, otherTeleXform)))
{
_popup.PopupEntity(Loc.GetString("swap-teleporter-popup-teleport-fail",
("entity", Identity.Entity(linkedEnt, EntityManager))),
@@ -175,6 +174,26 @@ public sealed class SwapTeleporterSystem : EntitySystem
_transform.SwapPositions(teleEnt, otherTeleEnt);
}
+ ///
+ /// Checks if two entities are able to swap positions via the teleporter.
+ ///
+ private bool CanSwapTeleport(
+ Entity entity1,
+ Entity entity2)
+ {
+ _container.TryGetOuterContainer(entity1, entity1, out var container1);
+ _container.TryGetOuterContainer(entity2, entity2, out var container2);
+
+ if (container2 != null && !_container.CanInsert(entity1, container2) ||
+ container1 != null && !_container.CanInsert(entity2, container1))
+ return false;
+
+ if (IsPaused(entity1) || IsPaused(entity2))
+ return false;
+
+ return true;
+ }
+
///
/// HYAH -link
///