Fix position swapping with QSI and artifacts (#26364)
This commit is contained in:
@@ -35,8 +35,7 @@ public sealed class PortalArtifactSystem : EntitySystem
|
||||
var secondPortal = Spawn(artifact.Comp.PortalProto, _transform.GetMapCoordinates(target));
|
||||
|
||||
//Manual position swapping, because the portal that opens doesn't trigger a collision, and doesn't teleport targets the first time.
|
||||
_transform.SetCoordinates(artifact, Transform(secondPortal).Coordinates);
|
||||
_transform.SetCoordinates(target, Transform(firstPortal).Coordinates);
|
||||
_transform.SwapPositions(target, secondPortal);
|
||||
|
||||
_link.TryLink(firstPortal, secondPortal, true);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ public sealed class ShuffleArtifactSystem : EntitySystem
|
||||
{
|
||||
var mobState = GetEntityQuery<MobStateComponent>();
|
||||
|
||||
List<EntityCoordinates> allCoords = new();
|
||||
List<Entity<TransformComponent>> toShuffle = new();
|
||||
|
||||
foreach (var ent in _lookup.GetEntitiesInRange(uid, component.Radius, LookupFlags.Dynamic | LookupFlags.Sundries))
|
||||
@@ -33,13 +32,15 @@ public sealed class ShuffleArtifactSystem : EntitySystem
|
||||
var xform = Transform(ent);
|
||||
|
||||
toShuffle.Add((ent, xform));
|
||||
allCoords.Add(xform.Coordinates);
|
||||
}
|
||||
|
||||
foreach (var xform in toShuffle)
|
||||
_random.Shuffle(toShuffle);
|
||||
|
||||
while (toShuffle.Count > 1)
|
||||
{
|
||||
var xformUid = xform.Owner;
|
||||
_xform.SetCoordinates(xformUid, xform, _random.PickAndTake(allCoords));
|
||||
var ent1 = _random.PickAndTake(toShuffle);
|
||||
var ent2 = _random.PickAndTake(toShuffle);
|
||||
_xform.SwapPositions((ent1, ent1), (ent2, ent2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,27 +145,14 @@ public sealed class SwapTeleporterSystem : EntitySystem
|
||||
}
|
||||
|
||||
var teleEnt = GetTeleportingEntity((uid, xform));
|
||||
var teleEntXform = Transform(teleEnt);
|
||||
var otherTeleEnt = GetTeleportingEntity((linkedEnt, Transform(linkedEnt)));
|
||||
var otherTeleEntXform = Transform(otherTeleEnt);
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("swap-teleporter-popup-teleport-other",
|
||||
("entity", Identity.Entity(linkedEnt, EntityManager))),
|
||||
otherTeleEnt,
|
||||
otherTeleEnt,
|
||||
PopupType.MediumCaution);
|
||||
var pos = teleEntXform.Coordinates;
|
||||
var otherPos = otherTeleEntXform.Coordinates;
|
||||
|
||||
if (_transform.ContainsEntity(teleEnt, (otherTeleEnt, otherTeleEntXform)) ||
|
||||
_transform.ContainsEntity(otherTeleEnt, (teleEnt, teleEntXform)))
|
||||
{
|
||||
Log.Error($"Invalid teleport swap attempt between {ToPrettyString(teleEnt)} and {ToPrettyString(otherTeleEnt)}");
|
||||
return;
|
||||
}
|
||||
|
||||
_transform.SetCoordinates(teleEnt, otherPos);
|
||||
_transform.SetCoordinates(otherTeleEnt, pos);
|
||||
_transform.SwapPositions(teleEnt, otherTeleEnt);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
|
||||
Reference in New Issue
Block a user