using System.Threading;
+using Content.Server.Administration.Logs;
using Content.Server.DoAfter;
+using Content.Shared.Database;
using Content.Shared.Interaction.Events;
using Content.Shared.Teleportation.Components;
using Content.Shared.Teleportation.Systems;
/// </summary>
public sealed class HandTeleporterSystem : EntitySystem
{
+ [Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly LinkedEntitySystem _link = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly DoAfterSystem _doafter = default!;
var timeout = EnsureComp<PortalTimeoutComponent>(user);
timeout.EnteredPortal = null;
component.FirstPortal = Spawn(component.FirstPortalPrototype, Transform(user).Coordinates);
+ _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);
}
else if (component.SecondPortal == null)
var timeout = EnsureComp<PortalTimeoutComponent>(user);
timeout.EnteredPortal = null;
component.SecondPortal = Spawn(component.SecondPortalPrototype, Transform(user).Coordinates);
+ _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{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);
_audio.PlayPvs(component.NewPortalSound, uid);
}
else
{
+ // Logging
+ var portalStrings = "";
+ portalStrings += ToPrettyString(component.FirstPortal!.Value);
+ if (portalStrings != "")
+ portalStrings += " and ";
+ portalStrings += ToPrettyString(component.SecondPortal!.Value);
+ if (portalStrings != "")
+ _adminLogger.Add(LogType.EntityDelete, LogImpact.Low, $"{ToPrettyString(user):player} closed {portalStrings} with {ToPrettyString(uid)}");
+
// Clear both portals
QueueDel(component.FirstPortal!.Value);
QueueDel(component.SecondPortal!.Value);
--- /dev/null
+using Content.Server.Mind.Components;
+using Content.Shared.Administration.Logs;
+using Content.Shared.Database;
+using Content.Shared.Teleportation.Systems;
+using Robust.Shared.Map;
+
+namespace Content.Server.Teleportation;
+
+public sealed class PortalSystem : SharedPortalSystem
+{
+ [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
+
+ // TODO Move to shared
+ protected override void LogTeleport(EntityUid portal, EntityUid subject, EntityCoordinates source,
+ EntityCoordinates target)
+ {
+ if (HasComp<MindComponent>(subject))
+ _adminLogger.Add(LogType.Teleport, LogImpact.Low, $"{ToPrettyString(subject):player} teleported via {ToPrettyString(portal)} from {source} to {target}");
+ }
+}
/// <summary>
/// This handles teleporting entities through portals, and creating new linked portals.
/// </summary>
-public sealed class PortalSystem : EntitySystem
+public abstract class SharedPortalSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly INetManager _netMan = default!;
projectile.IgnoreShooter = false;
}
+ LogTeleport(portal, subject, Transform(subject).Coordinates, target);
+
Transform(subject).Coordinates = target;
_audio.PlayPredicted(departureSound, portal, subject);
_audio.PlayPredicted(arrivalSound, subject, subject);
}
+
+ protected virtual void LogTeleport(EntityUid portal, EntityUid subject, EntityCoordinates source,
+ EntityCoordinates target)
+ {
+ }
}