Files
tbd-station-14/Content.Server/Materials/MaterialStorageSystem.cs
Chief-Engineer 2a8e5d9096 Add machine logs (#13185)
* add material insert logs

* add lathe queue logs

* add grav gen power logs

* fix count

* replace SharedStackComponent with StackComponent and rm unused imports

* use TryComp

* fix import
2022-12-27 18:01:36 +01:00

41 lines
1.6 KiB
C#

using Content.Server.Administration.Logs;
using Content.Shared.Materials;
using Content.Shared.Popups;
using Content.Server.Power.Components;
using Content.Shared.Database;
using Content.Shared.Stacks;
namespace Content.Server.Materials;
/// <summary>
/// This handles <see cref="SharedMaterialStorageSystem"/>
/// </summary>
public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
public override bool TryInsertMaterialEntity(EntityUid user, EntityUid toInsert, EntityUid receiver, MaterialStorageComponent? component = null)
{
if (!Resolve(receiver, ref component))
return false;
if (TryComp<ApcPowerReceiverComponent>(receiver, out var power) && !power.Powered)
return false;
if (!base.TryInsertMaterialEntity(user, toInsert, receiver, component))
return false;
_audio.PlayPvs(component.InsertingSound, component.Owner);
_popup.PopupEntity(Loc.GetString("machine-insert-item", ("user", user), ("machine", component.Owner),
("item", toInsert)), component.Owner);
QueueDel(toInsert);
// Logging
TryComp<StackComponent>(toInsert, out var stack);
var count = stack?.Count ?? 1;
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(user):player} inserted {count} {ToPrettyString(toInsert):inserted} into {ToPrettyString(receiver):receiver}");
return true;
}
}