Add teleporter logs (#13375)
This commit is contained in:
7
Content.Client/Teleportation/PortalSystem.cs
Normal file
7
Content.Client/Teleportation/PortalSystem.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
using Content.Shared.Teleportation.Systems;
|
||||||
|
|
||||||
|
namespace Content.Client.Teleportation;
|
||||||
|
|
||||||
|
public sealed class PortalSystem : SharedPortalSystem
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.DoAfter;
|
using Content.Server.DoAfter;
|
||||||
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Teleportation.Components;
|
using Content.Shared.Teleportation.Components;
|
||||||
using Content.Shared.Teleportation.Systems;
|
using Content.Shared.Teleportation.Systems;
|
||||||
@@ -12,6 +14,7 @@ namespace Content.Server.Teleportation;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class HandTeleporterSystem : EntitySystem
|
public sealed class HandTeleporterSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
[Dependency] private readonly LinkedEntitySystem _link = default!;
|
[Dependency] private readonly LinkedEntitySystem _link = default!;
|
||||||
[Dependency] private readonly AudioSystem _audio = default!;
|
[Dependency] private readonly AudioSystem _audio = default!;
|
||||||
[Dependency] private readonly DoAfterSystem _doafter = default!;
|
[Dependency] private readonly DoAfterSystem _doafter = default!;
|
||||||
@@ -98,6 +101,7 @@ 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);
|
||||||
|
_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);
|
_audio.PlayPvs(component.NewPortalSound, uid);
|
||||||
}
|
}
|
||||||
else if (component.SecondPortal == null)
|
else if (component.SecondPortal == null)
|
||||||
@@ -105,11 +109,21 @@ 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);
|
||||||
|
_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);
|
_link.TryLink(component.FirstPortal!.Value, component.SecondPortal.Value, true);
|
||||||
_audio.PlayPvs(component.NewPortalSound, uid);
|
_audio.PlayPvs(component.NewPortalSound, uid);
|
||||||
}
|
}
|
||||||
else
|
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
|
// Clear both portals
|
||||||
QueueDel(component.FirstPortal!.Value);
|
QueueDel(component.FirstPortal!.Value);
|
||||||
QueueDel(component.SecondPortal!.Value);
|
QueueDel(component.SecondPortal!.Value);
|
||||||
|
|||||||
20
Content.Server/Teleportation/PortalSystem.cs
Normal file
20
Content.Server/Teleportation/PortalSystem.cs
Normal file
@@ -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<MindComponent>(subject))
|
||||||
|
_adminLogger.Add(LogType.Teleport, LogImpact.Low, $"{ToPrettyString(subject):player} teleported via {ToPrettyString(portal)} from {source} to {target}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -83,4 +83,6 @@ public enum LogType
|
|||||||
AdminMessage = 78,
|
AdminMessage = 78,
|
||||||
Anomaly = 79,
|
Anomaly = 79,
|
||||||
WireHacking = 80,
|
WireHacking = 80,
|
||||||
|
Teleport = 81,
|
||||||
|
EntityDelete = 82,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Content.Shared.Teleportation.Systems;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles symmetrically linking two entities together, and removing links properly.
|
/// 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)
|
/// 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 <see cref="PortalSystem"/>.
|
/// Systems can do whatever they please with the linked entities, such as <see cref="SharedPortalSystem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class LinkedEntitySystem : EntitySystem
|
public sealed class LinkedEntitySystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Content.Shared.Teleportation.Systems;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This handles teleporting entities through portals, and creating new linked portals.
|
/// This handles teleporting entities through portals, and creating new linked portals.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class PortalSystem : EntitySystem
|
public abstract class SharedPortalSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly INetManager _netMan = default!;
|
[Dependency] private readonly INetManager _netMan = default!;
|
||||||
@@ -153,9 +153,16 @@ public sealed class PortalSystem : EntitySystem
|
|||||||
projectile.IgnoreShooter = false;
|
projectile.IgnoreShooter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogTeleport(portal, subject, Transform(subject).Coordinates, target);
|
||||||
|
|
||||||
Transform(subject).Coordinates = target;
|
Transform(subject).Coordinates = target;
|
||||||
|
|
||||||
_audio.PlayPredicted(departureSound, portal, subject);
|
_audio.PlayPredicted(departureSound, portal, subject);
|
||||||
_audio.PlayPredicted(arrivalSound, subject, subject);
|
_audio.PlayPredicted(arrivalSound, subject, subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void LogTeleport(EntityUid portal, EntityUid subject, EntityCoordinates source,
|
||||||
|
EntityCoordinates target)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user