More artifact content (#22574)
* 3 new effect * new trigger * swap portal to Cak * cake * portals * finish * pupupu * limitations (same maps) * its broken now * a * portal fix, thx deltanedas
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
|
||||
|
||||
/// <summary>
|
||||
/// When activated artifact will spawn an pair portals. First - right in artifact, Second - at random point of station.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(PortalArtifactSystem))]
|
||||
public sealed partial class PortalArtifactComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public EntProtoId PortalProto = "PortalArtifact";
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
|
||||
using Content.Shared.Mind.Components;
|
||||
using Content.Shared.Teleportation.Systems;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
|
||||
|
||||
public sealed class PortalArtifactSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly LinkedEntitySystem _link = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PortalArtifactComponent, ArtifactActivatedEvent>(OnActivate);
|
||||
}
|
||||
|
||||
private void OnActivate(Entity<PortalArtifactComponent> artifact, ref ArtifactActivatedEvent args)
|
||||
{
|
||||
var map = Transform(artifact).MapID;
|
||||
var firstPortal = Spawn(artifact.Comp.PortalProto, _transform.GetMapCoordinates(artifact));
|
||||
|
||||
var minds = new List<EntityUid>();
|
||||
var mindQuery = EntityQueryEnumerator<MindContainerComponent, TransformComponent>();
|
||||
while (mindQuery.MoveNext(out var uid, out var mc, out var xform))
|
||||
{
|
||||
if (mc.HasMind && xform.MapID == map)
|
||||
minds.Add(uid);
|
||||
}
|
||||
|
||||
var target = _random.Pick(minds);
|
||||
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);
|
||||
|
||||
_link.TryLink(firstPortal, secondPortal, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user