Gateway destinations (#21040)
* Gateway generation * Gateway stuff * gatewehs * mercenaries * play area * Range fixes and tweaks * weh * Gateway UI polish * Lots of fixes * Knock some items off * Fix dungeon spawning Realistically we should probably be using a salvage job. * wahwah * wehvs * expression * weh * eee * a * a * WEH * frfr * Gatwey * Fix gateway windows * Fix gateway windows * a * a * Better layer masking * a * a * Noise fixes * a * Fix fractal calculations * a * More fixes * Fixes * Add layers back in * Fixes * namespaces and ftl * Other TODO * Fix distance * Cleanup * Fix test
This commit is contained in:
@@ -5,7 +5,7 @@ using Robust.Shared.Serialization;
|
||||
namespace Content.Shared.Teleportation.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an entity which is linked to other entities (perhaps portals), and which can be walked through/
|
||||
/// Represents an entity which is linked to other entities (perhaps portals), and which can be walked through /
|
||||
/// thrown into to teleport an entity.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
|
||||
@@ -47,4 +47,10 @@ public sealed partial class PortalComponent : Component
|
||||
/// </remarks>
|
||||
[DataField("maxTeleportRadius")]
|
||||
public float? MaxTeleportRadius;
|
||||
|
||||
/// <summary>
|
||||
/// Should we teleport randomly if nothing is linked.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool RandomTeleport = true;
|
||||
}
|
||||
|
||||
@@ -54,13 +54,29 @@ public sealed class LinkedEntitySystem : EntitySystem
|
||||
_appearance.SetData(first, LinkedEntityVisuals.HasAnyLinks, true);
|
||||
_appearance.SetData(second, LinkedEntityVisuals.HasAnyLinks, true);
|
||||
|
||||
Dirty(firstLink);
|
||||
Dirty(secondLink);
|
||||
Dirty(first, firstLink);
|
||||
Dirty(second, secondLink);
|
||||
|
||||
return firstLink.LinkedEntities.Add(second)
|
||||
&& secondLink.LinkedEntities.Add(first);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does a one-way link from source to target.
|
||||
/// </summary>
|
||||
/// <param name="deleteOnEmptyLinks">Whether both entities should now delete once their links are removed</param>
|
||||
public bool OneWayLink(EntityUid source, EntityUid target, bool deleteOnEmptyLinks=false)
|
||||
{
|
||||
var firstLink = EnsureComp<LinkedEntityComponent>(source);
|
||||
firstLink.DeleteOnEmptyLinks = deleteOnEmptyLinks;
|
||||
|
||||
_appearance.SetData(source, LinkedEntityVisuals.HasAnyLinks, true);
|
||||
|
||||
Dirty(source, firstLink);
|
||||
|
||||
return firstLink.LinkedEntities.Add(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlinks two entities. Deletes either entity if <see cref="LinkedEntityComponent.DeleteOnEmptyLinks"/>
|
||||
/// was true and its links are now empty. Symmetrical, so order doesn't matter.
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class SharedPortalSystem : EntitySystem
|
||||
// if target is a portal, signal that they shouldn't be immediately portaled back
|
||||
var timeout = EnsureComp<PortalTimeoutComponent>(subject);
|
||||
timeout.EnteredPortal = uid;
|
||||
Dirty(timeout);
|
||||
Dirty(subject, timeout);
|
||||
}
|
||||
|
||||
TeleportEntity(uid, subject, Transform(target).Coordinates, target);
|
||||
@@ -142,7 +142,8 @@ public abstract class SharedPortalSystem : EntitySystem
|
||||
return;
|
||||
|
||||
// no linked entity--teleport randomly
|
||||
TeleportRandomly(uid, subject, component);
|
||||
if (component.RandomTeleport)
|
||||
TeleportRandomly(uid, subject, component);
|
||||
}
|
||||
|
||||
private void OnEndCollide(EntityUid uid, PortalComponent component, ref EndCollideEvent args)
|
||||
|
||||
Reference in New Issue
Block a user