diff --git a/Content.Client/Teleportation/PortalSystem.cs b/Content.Client/Teleportation/PortalSystem.cs new file mode 100644 index 0000000000..c8a51d6c08 --- /dev/null +++ b/Content.Client/Teleportation/PortalSystem.cs @@ -0,0 +1,7 @@ +using Content.Shared.Teleportation.Systems; + +namespace Content.Client.Teleportation; + +public sealed class PortalSystem : SharedPortalSystem +{ +} diff --git a/Content.Server/Teleportation/HandTeleporterSystem.cs b/Content.Server/Teleportation/HandTeleporterSystem.cs index 78be228d2e..12dddf2f54 100644 --- a/Content.Server/Teleportation/HandTeleporterSystem.cs +++ b/Content.Server/Teleportation/HandTeleporterSystem.cs @@ -1,5 +1,7 @@ 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; @@ -12,6 +14,7 @@ namespace Content.Server.Teleportation; /// 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!; @@ -98,6 +101,7 @@ public sealed class HandTeleporterSystem : EntitySystem var timeout = EnsureComp(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) @@ -105,11 +109,21 @@ public sealed class HandTeleporterSystem : EntitySystem var timeout = EnsureComp(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); diff --git a/Content.Server/Teleportation/PortalSystem.cs b/Content.Server/Teleportation/PortalSystem.cs new file mode 100644 index 0000000000..1730a48ac0 --- /dev/null +++ b/Content.Server/Teleportation/PortalSystem.cs @@ -0,0 +1,20 @@ +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(subject)) + _adminLogger.Add(LogType.Teleport, LogImpact.Low, $"{ToPrettyString(subject):player} teleported via {ToPrettyString(portal)} from {source} to {target}"); + } +} diff --git a/Content.Shared.Database/LogType.cs b/Content.Shared.Database/LogType.cs index ffb5cd84ed..073002f06b 100644 --- a/Content.Shared.Database/LogType.cs +++ b/Content.Shared.Database/LogType.cs @@ -83,4 +83,6 @@ public enum LogType AdminMessage = 78, Anomaly = 79, WireHacking = 80, + Teleport = 81, + EntityDelete = 82, } diff --git a/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs b/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs index bf05e83e8e..165e136505 100644 --- a/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs +++ b/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs @@ -7,7 +7,7 @@ namespace Content.Shared.Teleportation.Systems; /// /// Handles symmetrically linking two entities together, and removing links properly. /// This does not do anything on its own (outside of deleting entities that have 0 links, if that option is true) -/// Systems can do whatever they please with the linked entities, such as . +/// Systems can do whatever they please with the linked entities, such as . /// public sealed class LinkedEntitySystem : EntitySystem { diff --git a/Content.Shared/Teleportation/Systems/PortalSystem.cs b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs similarity index 95% rename from Content.Shared/Teleportation/Systems/PortalSystem.cs rename to Content.Shared/Teleportation/Systems/SharedPortalSystem.cs index 497730da59..6523ce575e 100644 --- a/Content.Shared/Teleportation/Systems/PortalSystem.cs +++ b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs @@ -16,7 +16,7 @@ namespace Content.Shared.Teleportation.Systems; /// /// This handles teleporting entities through portals, and creating new linked portals. /// -public sealed class PortalSystem : EntitySystem +public abstract class SharedPortalSystem : EntitySystem { [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly INetManager _netMan = default!; @@ -153,9 +153,16 @@ public sealed class PortalSystem : EntitySystem 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) + { + } }