fixing spessman getting teleported inside artifact (#36719)
* fixing spessman getting teleported inside artifact * refactor: move XAEPortal comp to server * refactor: replace Spawn and coord logic with with TrySpawnNextTo --------- Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Xenoarchaeology.Artifact.XAE.Components;
|
||||
namespace Content.Server.Xenoarchaeology.Artifact.XAE.Components;
|
||||
|
||||
/// <summary>
|
||||
/// When activated artifact will spawn a pair of portals. First - right in artifact, Second - at random point of station.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(XAEPortalSystem)), NetworkedComponent, AutoGenerateComponentState]
|
||||
[RegisterComponent, Access(typeof(XAEPortalSystem))]
|
||||
public sealed partial class XAEPortalComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
@@ -1,13 +1,15 @@
|
||||
using Content.Server.Xenoarchaeology.Artifact.XAE.Components;
|
||||
using Content.Shared.Mind.Components;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Teleportation.Systems;
|
||||
using Content.Shared.Xenoarchaeology.Artifact.XAE.Components;
|
||||
using Content.Shared.Xenoarchaeology.Artifact;
|
||||
using Content.Shared.Xenoarchaeology.Artifact.XAE;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Xenoarchaeology.Artifact.XAE;
|
||||
namespace Content.Server.Xenoarchaeology.Artifact.XAE;
|
||||
|
||||
/// <summary>
|
||||
/// System for xeno artifact effect that creates temporary portal between places on station.
|
||||
@@ -41,17 +43,16 @@ public sealed class XAEPortalSystem : BaseXAESystem<XAEPortalComponent>
|
||||
if (validMinds.Count == 0)
|
||||
return;
|
||||
|
||||
var offset = _random.NextVector2(2, 3);
|
||||
var originWithOffset = args.Coordinates.Offset(offset);
|
||||
var firstPortal = Spawn(ent.Comp.PortalProto, originWithOffset);
|
||||
if(!TrySpawnNextTo(ent.Comp.PortalProto, args.Artifact, out var firstPortal))
|
||||
return;
|
||||
|
||||
var target = _random.Pick(validMinds);
|
||||
|
||||
var secondPortal = Spawn(ent.Comp.PortalProto, _transform.GetMapCoordinates(target));
|
||||
if(!TrySpawnNextTo(ent.Comp.PortalProto, target, out var secondPortal))
|
||||
return;
|
||||
|
||||
// Manual position swapping, because the portal that opens doesn't trigger a collision, and doesn't teleport targets the first time.
|
||||
_transform.SwapPositions(target, ent.Owner);
|
||||
_transform.SwapPositions(target, args.Artifact.Owner);
|
||||
|
||||
_link.TryLink(firstPortal, secondPortal, true);
|
||||
_link.TryLink(firstPortal.Value, secondPortal.Value, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user