From 1db51e93b12af6acfa5aec816ab22924dd77e3ad Mon Sep 17 00:00:00 2001 From: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> Date: Tue, 27 Dec 2022 11:00:48 -0600 Subject: [PATCH] add item slot logs (#13184) --- .../Containers/ItemSlot/ItemSlotsSystem.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index 556c149886..d7116e7c9a 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -11,6 +11,8 @@ using Robust.Shared.GameStates; using Robust.Shared.Player; using Robust.Shared.Utility; using System.Diagnostics.CodeAnalysis; +using Content.Shared.Administration.Logs; +using Content.Shared.Database; using Robust.Shared.Network; using Robust.Shared.Timing; @@ -23,6 +25,7 @@ namespace Content.Shared.Containers.ItemSlots { [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly INetManager _netManager = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly SharedContainerSystem _containers = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; @@ -224,9 +227,13 @@ namespace Content.Shared.Containers.ItemSlots /// Useful for predicted interactions private void Insert(EntityUid uid, ItemSlot slot, EntityUid item, EntityUid? user, bool excludeUserAudio = false) { - slot.ContainerSlot?.Insert(item); + var inserted = slot.ContainerSlot?.Insert(item); // ContainerSlot automatically raises a directed EntInsertedIntoContainerMessage + // Logging + if (inserted != null && inserted.Value && user != null) + _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user.Value)} inserted {ToPrettyString(item)} into {slot.ContainerSlot?.ID + " slot of "}{ToPrettyString(uid)}"); + _audioSystem.PlayPredicted(slot.InsertSound, uid, excludeUserAudio ? user : null); } @@ -327,9 +334,13 @@ namespace Content.Shared.Containers.ItemSlots /// Useful for predicted interactions private void Eject(EntityUid uid, ItemSlot slot, EntityUid item, EntityUid? user, bool excludeUserAudio = false) { - slot.ContainerSlot?.Remove(item); + var ejected = slot.ContainerSlot?.Remove(item); // ContainerSlot automatically raises a directed EntRemovedFromContainerMessage + // Logging + if (ejected != null && ejected.Value && user != null) + _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user.Value)} ejected {ToPrettyString(item)} from {slot.ContainerSlot?.ID + " slot of "}{ToPrettyString(uid)}"); + _audioSystem.PlayPredicted(slot.EjectSound, uid, excludeUserAudio ? user : null, slot.SoundOptions); }