Fix admeme hand teleproter. (#36147)

* init

* changes
This commit is contained in:
ScarKy0
2025-03-29 15:51:46 +01:00
committed by GitHub
parent 87be2dde27
commit 89ea21bc31
3 changed files with 17 additions and 1 deletions

View File

@@ -95,6 +95,10 @@ public sealed class HandTeleporterSystem : EntitySystem
var timeout = EnsureComp<PortalTimeoutComponent>(user); var timeout = EnsureComp<PortalTimeoutComponent>(user);
timeout.EnteredPortal = null; timeout.EnteredPortal = null;
component.FirstPortal = Spawn(component.FirstPortalPrototype, Transform(user).Coordinates); component.FirstPortal = Spawn(component.FirstPortalPrototype, Transform(user).Coordinates);
if (component.AllowPortalsOnDifferentMaps && TryComp<PortalComponent>(component.FirstPortal, out var portal))
portal.CanTeleportToOtherMaps = true;
_adminLogger.Add(LogType.EntitySpawn, LogImpact.High, $"{ToPrettyString(user):player} opened {ToPrettyString(component.FirstPortal.Value)} at {Transform(component.FirstPortal.Value).Coordinates} using {ToPrettyString(uid)}"); _adminLogger.Add(LogType.EntitySpawn, LogImpact.High, $"{ToPrettyString(user):player} opened {ToPrettyString(component.FirstPortal.Value)} at {Transform(component.FirstPortal.Value).Coordinates} using {ToPrettyString(uid)}");
_audio.PlayPvs(component.NewPortalSound, uid); _audio.PlayPvs(component.NewPortalSound, uid);
} }
@@ -113,6 +117,10 @@ public sealed class HandTeleporterSystem : EntitySystem
var timeout = EnsureComp<PortalTimeoutComponent>(user); var timeout = EnsureComp<PortalTimeoutComponent>(user);
timeout.EnteredPortal = null; timeout.EnteredPortal = null;
component.SecondPortal = Spawn(component.SecondPortalPrototype, Transform(user).Coordinates); component.SecondPortal = Spawn(component.SecondPortalPrototype, Transform(user).Coordinates);
if (component.AllowPortalsOnDifferentMaps && TryComp<PortalComponent>(component.SecondPortal, out var portal))
portal.CanTeleportToOtherMaps = true;
_adminLogger.Add(LogType.EntitySpawn, LogImpact.High, $"{ToPrettyString(user):player} opened {ToPrettyString(component.SecondPortal.Value)} at {Transform(component.SecondPortal.Value).Coordinates} linked to {ToPrettyString(component.FirstPortal!.Value)} using {ToPrettyString(uid)}"); _adminLogger.Add(LogType.EntitySpawn, LogImpact.High, $"{ToPrettyString(user):player} opened {ToPrettyString(component.SecondPortal.Value)} at {Transform(component.SecondPortal.Value).Coordinates} linked to {ToPrettyString(component.FirstPortal!.Value)} using {ToPrettyString(uid)}");
_link.TryLink(component.FirstPortal!.Value, component.SecondPortal.Value, true); _link.TryLink(component.FirstPortal!.Value, component.SecondPortal.Value, true);
_audio.PlayPvs(component.NewPortalSound, uid); _audio.PlayPvs(component.NewPortalSound, uid);

View File

@@ -21,11 +21,17 @@ public sealed partial class HandTeleporterComponent : Component
public EntityUid? SecondPortal = null; public EntityUid? SecondPortal = null;
/// <summary> /// <summary>
/// Portals can't be placed on different grids? /// Should the portals be able to be placed across grids?
/// </summary> /// </summary>
[DataField] [DataField]
public bool AllowPortalsOnDifferentGrids; public bool AllowPortalsOnDifferentGrids;
/// <summary>
/// Should the portals work across maps?
/// </summary>
[DataField]
public bool AllowPortalsOnDifferentMaps;
[DataField("firstPortalPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] [DataField("firstPortalPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string FirstPortalPrototype = "PortalRed"; public string FirstPortalPrototype = "PortalRed";

View File

@@ -28,5 +28,7 @@
- state: icon - state: icon
color: green color: green
- type: HandTeleporter - type: HandTeleporter
allowPortalsOnDifferentGrids: true
allowPortalsOnDifferentMaps: true
firstPortalPrototype: PortalGatewayBlue firstPortalPrototype: PortalGatewayBlue
secondPortalPrototype: PortalGatewayOrange secondPortalPrototype: PortalGatewayOrange