Fix QSI bringing people into paused maps (#36834)

This commit is contained in:
Nemanja
2025-04-24 17:18:26 -04:00
committed by GitHub
parent b3b6d47310
commit f9b3d59a53

View File

@@ -8,6 +8,7 @@ using Content.Shared.Whitelist;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Network;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -20,6 +21,7 @@ namespace Content.Shared.Teleportation.Systems;
public sealed class SwapTeleporterSystem : EntitySystem public sealed class SwapTeleporterSystem : EntitySystem
{ {
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedContainerSystem _container = default!;
@@ -145,19 +147,16 @@ public sealed class SwapTeleporterSystem : EntitySystem
comp.TeleportTime = null; comp.TeleportTime = null;
Dirty(uid, comp); 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; return;
}
var teleEnt = GetTeleportingEntity((uid, xform)); var teleEnt = GetTeleportingEntity((uid, xform));
var otherTeleEnt = GetTeleportingEntity((linkedEnt, Transform(linkedEnt))); var otherTeleEnt = GetTeleportingEntity((linkedEnt, Transform(linkedEnt)));
var teleXform = Transform(teleEnt);
var otherTeleXform = Transform(otherTeleEnt);
_container.TryGetOuterContainer(teleEnt, Transform(teleEnt), out var cont); if (!CanSwapTeleport((teleEnt, teleXform), (otherTeleEnt, otherTeleXform)))
_container.TryGetOuterContainer(otherTeleEnt, Transform(otherTeleEnt), out var otherCont);
if (otherCont != null && !_container.CanInsert(teleEnt, otherCont) ||
cont != null && !_container.CanInsert(otherTeleEnt, cont))
{ {
_popup.PopupEntity(Loc.GetString("swap-teleporter-popup-teleport-fail", _popup.PopupEntity(Loc.GetString("swap-teleporter-popup-teleport-fail",
("entity", Identity.Entity(linkedEnt, EntityManager))), ("entity", Identity.Entity(linkedEnt, EntityManager))),
@@ -175,6 +174,26 @@ public sealed class SwapTeleporterSystem : EntitySystem
_transform.SwapPositions(teleEnt, otherTeleEnt); _transform.SwapPositions(teleEnt, otherTeleEnt);
} }
/// <summary>
/// Checks if two entities are able to swap positions via the teleporter.
/// </summary>
private bool CanSwapTeleport(
Entity<TransformComponent> entity1,
Entity<TransformComponent> 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;
}
/// <remarks> /// <remarks>
/// HYAH -link /// HYAH -link
/// </remarks> /// </remarks>