From d30c3b0bbc324a6ea24dc59b2267181219a61450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20C=C3=A9sar=20Ueti?= <52474532+Mirino97@users.noreply.github.com> Date: Sat, 30 Jul 2022 23:47:42 -0300 Subject: [PATCH] Adds detailed logging to AME and PA interactions (#10170) --- .../AME/Components/AMEControllerComponent.cs | 17 +++++++++++++++++ .../ParticleAcceleratorControlBoxComponent.cs | 15 +++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index e9e8e274e7..899f7a9713 100644 --- a/Content.Server/AME/Components/AMEControllerComponent.cs +++ b/Content.Server/AME/Components/AMEControllerComponent.cs @@ -1,8 +1,11 @@ using System.Linq; +using Content.Server.Administration.Logs; +using Content.Server.Mind.Components; using Content.Server.NodeContainer; using Content.Server.Power.Components; using Content.Server.UserInterface; using Content.Shared.AME; +using Content.Shared.Database; using Content.Shared.Hands.EntitySystems; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -16,6 +19,7 @@ namespace Content.Server.AME.Components { [Dependency] private readonly IEntityManager _entities = default!; [Dependency] private readonly IEntitySystemManager _sysMan = default!; + [Dependency] private readonly IAdminLogManager _adminLogger = default!; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(AMEControllerUiKey.Key); private bool _injecting; @@ -167,6 +171,19 @@ namespace Content.Server.AME.Components break; } + // Logging + _entities.TryGetComponent(player, out MindComponent? mindComponent); + if (mindComponent != null) + { + var humanReadableState = _injecting ? "Inject" : "Not inject"; + + if (msg.Button == UiButton.IncreaseFuel || msg.Button == UiButton.DecreaseFuel) + _adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entities.ToPrettyString(mindComponent.Owner):player} has set the AME to inject {InjectionAmount} while set to {humanReadableState}"); + + if (msg.Button == UiButton.ToggleInjection) + _adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entities.ToPrettyString(mindComponent.Owner):player} has set the AME to {humanReadableState}"); + } + GetAMENodeGroup()?.UpdateCoreVisuals(); UpdateUserInterface(); diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index b8d51a5363..870c10b80e 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -1,12 +1,16 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Threading; +using Content.Server.Administration.Logs; +using Content.Server.Mind.Components; using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; using Content.Server.UserInterface; +using Content.Shared.Database; // using Content.Server.WireHacking; using Content.Shared.Singularity.Components; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Map; using Robust.Shared.Utility; // using static Content.Shared.Wires.SharedWiresComponent; @@ -25,6 +29,7 @@ namespace Content.Server.ParticleAccelerator.Components { [Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IAdminLogManager _adminLogger = default!; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ParticleAcceleratorControlBoxUiKey.Key); @@ -143,7 +148,7 @@ namespace Content.Server.ParticleAccelerator.Components break; case ParticleAcceleratorSetPowerStateMessage stateMessage: - SetStrength(stateMessage.State); + SetStrength(stateMessage.State, obj.Session); break; case ParticleAcceleratorRescanPartsMessage _: @@ -501,7 +506,7 @@ namespace Content.Server.ParticleAccelerator.Components UpdatePartVisualStates(); } - public void SetStrength(ParticleAcceleratorPowerState state) + public void SetStrength(ParticleAcceleratorPowerState state, IPlayerSession? playerSession = null) { if (_wireStrengthCut) { @@ -517,6 +522,12 @@ namespace Content.Server.ParticleAccelerator.Components UpdateAppearance(); UpdatePartVisualStates(); + // Logging + _entMan.TryGetComponent(playerSession?.AttachedEntity, out MindComponent? mindComponent); + var humanReadableState = _isEnabled ? "Turned On" : "Turned Off"; + if(mindComponent != null && state == MaxPower) + _adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entMan.ToPrettyString(mindComponent.Owner):player} has set the strength of the Particle Accelerator to a dangerous level while the PA was {humanReadableState}"); + if (_isEnabled) { UpdatePowerDraw();