Add cryopod logs (#16854)

This commit is contained in:
Chief-Engineer
2023-05-28 03:59:27 -05:00
committed by GitHub
parent 6c7db6dbc3
commit 707b9063f9
5 changed files with 97 additions and 12 deletions

View File

@@ -1,5 +1,7 @@
using Content.Server.Medical.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Body.Components;
using Content.Shared.Database;
using Content.Shared.DoAfter;
using Content.Shared.DragDrop;
using Content.Shared.Emag.Systems;
@@ -21,6 +23,7 @@ public abstract partial class SharedCryoPodSystem: EntitySystem
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
public override void Initialize()
{
@@ -60,13 +63,13 @@ public abstract partial class SharedCryoPodSystem: EntitySystem
_appearanceSystem.SetData(uid, CryoPodComponent.CryoPodVisuals.IsOn, cryoPodEnabled, appearance);
}
public void InsertBody(EntityUid uid, EntityUid target, CryoPodComponent cryoPodComponent)
public bool InsertBody(EntityUid uid, EntityUid target, CryoPodComponent cryoPodComponent)
{
if (cryoPodComponent.BodyContainer.ContainedEntity != null)
return;
return false;
if (!HasComp<MobStateComponent>(target))
return;
return false;
var xform = Transform(target);
cryoPodComponent.BodyContainer.Insert(target, transform: xform);
@@ -75,6 +78,7 @@ public abstract partial class SharedCryoPodSystem: EntitySystem
_standingStateSystem.Stand(target, force: true); // Force-stand the mob so that the cryo pod sprite overlays it fully
UpdateAppearance(uid, cryoPodComponent);
return true;
}
public void TryEjectBody(EntityUid uid, EntityUid userId, CryoPodComponent? cryoPodComponent)
@@ -90,16 +94,24 @@ public abstract partial class SharedCryoPodSystem: EntitySystem
return;
}
EjectBody(uid, cryoPodComponent);
var ejected = EjectBody(uid, cryoPodComponent);
if (ejected != null)
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(ejected.Value)} ejected from {ToPrettyString(uid)} by {ToPrettyString(userId)}");
}
public virtual void EjectBody(EntityUid uid, CryoPodComponent? cryoPodComponent)
/// <summary>
/// Ejects the contained body
/// </summary>
/// <param name="uid">The cryopod entity</param>
/// <param name="cryoPodComponent">Cryopod component of <see cref="uid"/></param>
/// <returns>Ejected entity</returns>
public virtual EntityUid? EjectBody(EntityUid uid, CryoPodComponent? cryoPodComponent)
{
if (!Resolve(uid, ref cryoPodComponent))
return;
return null;
if (cryoPodComponent.BodyContainer.ContainedEntity is not {Valid: true} contained)
return;
return null;
cryoPodComponent.BodyContainer.Remove(contained);
// InsideCryoPodComponent is removed automatically in its EntGotRemovedFromContainerMessage listener
@@ -116,6 +128,7 @@ public abstract partial class SharedCryoPodSystem: EntitySystem
}
UpdateAppearance(uid, cryoPodComponent);
return contained;
}
protected void AddAlternativeVerbs(EntityUid uid, CryoPodComponent cryoPodComponent, GetVerbsEvent<AlternativeVerb> args)
@@ -153,7 +166,9 @@ public abstract partial class SharedCryoPodSystem: EntitySystem
if (args.Cancelled)
return;
EjectBody(uid, cryoPodComponent);
var ejected = EjectBody(uid, cryoPodComponent);
if (ejected != null)
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(ejected.Value)} pried out of {ToPrettyString(uid)} by {ToPrettyString(args.User)}");
}
[Serializable, NetSerializable]