From 432c50240b77a63cb539fed2907f1ff5edb6670b Mon Sep 17 00:00:00 2001 From: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> Date: Mon, 19 Dec 2022 21:31:29 -0600 Subject: [PATCH] fix pa computer logs (#13092) --- .../ParticleAcceleratorControlBoxComponent.cs | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index 604d181d2d..41c8833092 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -139,11 +139,11 @@ namespace Content.Server.ParticleAccelerator.Components case ParticleAcceleratorSetEnableMessage enableMessage: if (enableMessage.Enabled) { - SwitchOn(); + SwitchOn(obj.Session); } else { - SwitchOff(); + SwitchOff(obj.Session); } break; @@ -153,7 +153,7 @@ namespace Content.Server.ParticleAccelerator.Components break; case ParticleAcceleratorRescanPartsMessage _: - RescanParts(); + RescanParts(obj.Session); break; } @@ -324,9 +324,9 @@ namespace Content.Server.ParticleAccelerator.Components } */ - public void RescanParts() + public void RescanParts(IPlayerSession? playerSession = null) { - SwitchOff(); + SwitchOff(playerSession, true); foreach (var part in AllParts()) { part.Master = null; @@ -453,7 +453,7 @@ namespace Content.Server.ParticleAccelerator.Components yield return _partEmitterRight; } - public void SwitchOn() + public void SwitchOn(IPlayerSession? playerSession = null) { DebugTools.Assert(_isAssembled); @@ -462,6 +462,11 @@ namespace Content.Server.ParticleAccelerator.Components return; } + // Logging + _entMan.TryGetComponent(playerSession?.AttachedEntity, out MindComponent? mindComponent); + if(mindComponent != null) + _adminLogger.Add(LogType.Action, LogImpact.Low, $"{_entMan.ToPrettyString(mindComponent.Owner):player} has set {_entMan.ToPrettyString(Owner)} to on"); + _isEnabled = true; UpdatePowerDraw(); // If we don't have power yet we'll turn on when we receive more power from the powernet. @@ -479,8 +484,13 @@ namespace Content.Server.ParticleAccelerator.Components _partPowerBox!.PowerConsumerComponent!.DrawRate = PowerDrawFor(_selectedStrength); } - public void SwitchOff() + public void SwitchOff(IPlayerSession? playerSession = null, bool rescan = false) { + // Logging + _entMan.TryGetComponent(playerSession?.AttachedEntity, out MindComponent? mindComponent); + if(mindComponent != null) + _adminLogger.Add(LogType.Action, LogImpact.Low, $"{_entMan.ToPrettyString(mindComponent.Owner):player} has set {_entMan.ToPrettyString(Owner)} to off{(rescan ? " via rescan" : "")}"); + _isEnabled = false; PowerOff(); UpdateUI(); @@ -533,9 +543,24 @@ namespace Content.Server.ParticleAccelerator.Components // 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}"); + LogImpact impact; + switch (state) + { + default: + case ParticleAcceleratorPowerState.Standby: + case ParticleAcceleratorPowerState.Level0: + impact = LogImpact.Low; + break; + case ParticleAcceleratorPowerState.Level1: + impact = LogImpact.High; + break; + case ParticleAcceleratorPowerState.Level2: + case ParticleAcceleratorPowerState.Level3: + impact = LogImpact.Extreme; + break; + } + if(mindComponent != null) + _adminLogger.Add(LogType.Action, impact, $"{_entMan.ToPrettyString(mindComponent.Owner):player} has set the strength of {_entMan.ToPrettyString(Owner)} to {state}"); if (_isEnabled) {