Skip to content

Commit

Permalink
Added: NewPopup, check same grid as the FirstPortal
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaldetSkaeg committed Feb 8, 2024
1 parent c78fd2c commit e209072
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
35 changes: 35 additions & 0 deletions Content.Server/Teleportation/HandTeleporterSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Shared.Teleportation.Systems;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Content.Server.Popups;

namespace Content.Server.Teleportation;

Expand All @@ -18,6 +19,7 @@ public sealed class HandTeleporterSystem : EntitySystem
[Dependency] private readonly LinkedEntitySystem _link = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly SharedDoAfterSystem _doafter = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;

/// <inheritdoc/>
public override void Initialize()
Expand Down Expand Up @@ -55,6 +57,18 @@ private void OnUseInHand(EntityUid uid, HandTeleporterComponent component, UseIn
if (xform.ParentUid != xform.GridUid)
return;

//SS220 teleport_grid_resrtictions start
if (component.FirstPortalsGrid == null)
component.FirstPortalsGrid = xform.GridUid;
/*
if (component.FirstPortalsGrid != xform.GridUid)
{
HandlePortalUpdating(uid, component, args.User);
return;
}
*/
//SS220 teleport_grid_resrtictions end

var doafterArgs = new DoAfterArgs(EntityManager, args.User, component.PortalCreationDelay, new TeleporterDoAfterEvent(), uid, used: uid)
{
BreakOnDamage = true,
Expand Down Expand Up @@ -90,6 +104,25 @@ private void HandlePortalUpdating(EntityUid uid, HandTeleporterComponent compone
_adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(user):player} opened {ToPrettyString(component.FirstPortal.Value)} at {Transform(component.FirstPortal.Value).Coordinates} using {ToPrettyString(uid)}");
_audio.PlayPvs(component.NewPortalSound, uid);
}
//SS220 teleport_grid_resrtictions start
else if (component.FirstPortalsGrid != xform.GridUid)
{
// Logging
var portalStrings = "";
portalStrings += ToPrettyString(component.FirstPortal!.Value);
if (portalStrings != "")
_adminLogger.Add(LogType.EntityDelete, LogImpact.Low, $"{ToPrettyString(user):player} closed {portalStrings} with {ToPrettyString(uid)}, not the same grid");

// Clear first portal
QueueDel(component.FirstPortal!.Value);

_popupSystem.PopupEntity(Loc.GetString("hand-teleporter-component-not-the-same-grid-message"), uid, Shared.Popups.PopupType.Medium);

component.FirstPortalsGrid = null;
component.FirstPortal = null;
_audio.PlayPvs(component.ClearPortalsSound, uid);
}
//SS220 teleport_grid_resrtictions end
else if (Deleted(component.SecondPortal))
{
var timeout = EnsureComp<PortalTimeoutComponent>(user);
Expand All @@ -114,6 +147,8 @@ private void HandlePortalUpdating(EntityUid uid, HandTeleporterComponent compone
QueueDel(component.FirstPortal!.Value);
QueueDel(component.SecondPortal!.Value);

component.FirstPortalsGrid = null;//SS220 teleport_grid_resrtictions

component.FirstPortal = null;
component.SecondPortal = null;
_audio.PlayPvs(component.ClearPortalsSound, uid);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.DoAfter;
using Content.Shared.DoAfter;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
Expand Down Expand Up @@ -40,6 +40,9 @@ public sealed partial class HandTeleporterComponent : Component
/// </summary>
[DataField("portalCreationDelay")]
public float PortalCreationDelay = 1.0f;

[ViewVariables]
public EntityUid? FirstPortalsGrid = null;//SS220 teleport_grid_resrtictions
}

[Serializable, NetSerializable]
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/ss220/hand-teleporter-component.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hand-teleporter-component-not-the-same-grid-message = Неизвестное пространство, сброс портала.

0 comments on commit e209072

Please sign in to comment.