Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teleporter grid restriction #722

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 = Неизвестное пространство, сброс портала.
Loading