Add cryopod logs (#16854)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System.Text.Json;
|
||||
using Content.Server.Atmos;
|
||||
|
||||
namespace Content.Server.Administration.Logs.Converters;
|
||||
|
||||
[AdminLogConverter]
|
||||
public sealed class GasMixtureStringRepresentationConverter : AdminLogConverter<GasMixtureStringRepresentation>
|
||||
{
|
||||
public override void Write(Utf8JsonWriter writer, GasMixtureStringRepresentation value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteNumber("mol", value.TotalMoles);
|
||||
writer.WriteNumber("temperature", value.Temperature);
|
||||
writer.WriteNumber("pressure", value.Pressure);
|
||||
|
||||
writer.WriteStartObject("gases");
|
||||
foreach (var x in value.MolesPerGas)
|
||||
{
|
||||
writer.WriteNumber(x.Key, x.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
@@ -207,6 +207,20 @@ namespace Content.Server.Atmos
|
||||
Array.Resize(ref Moles, Atmospherics.AdjustedNumberOfGases);
|
||||
}
|
||||
|
||||
public GasMixtureStringRepresentation ToPrettyString()
|
||||
{
|
||||
var molesPerGas = new Dictionary<string, float>();
|
||||
for (int i = 0; i < Moles.Length; i++)
|
||||
{
|
||||
if (Moles[i] == 0)
|
||||
continue;
|
||||
|
||||
molesPerGas.Add(((Gas) i).ToString(), Moles[i]);
|
||||
}
|
||||
|
||||
return new GasMixtureStringRepresentation(TotalMoles, Temperature, Pressure, molesPerGas);
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is GasMixture mix)
|
||||
|
||||
18
Content.Server/Atmos/GasMixtureStringRepresentation.cs
Normal file
18
Content.Server/Atmos/GasMixtureStringRepresentation.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Server.Atmos;
|
||||
|
||||
public readonly record struct GasMixtureStringRepresentation(float TotalMoles, float Temperature, float Pressure, Dictionary<string, float> MolesPerGas) : IFormattable
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Temperature}K {Pressure} kPa";
|
||||
}
|
||||
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
public static implicit operator string(GasMixtureStringRepresentation rep) => rep.ToString();
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
@@ -17,6 +18,7 @@ using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Emag.Systems;
|
||||
@@ -46,6 +48,7 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaDataSystem = default!;
|
||||
[Dependency] private readonly ReactiveSystem _reactiveSystem = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -110,14 +113,15 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
}
|
||||
}
|
||||
|
||||
public override void EjectBody(EntityUid uid, CryoPodComponent? cryoPodComponent)
|
||||
public override 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;
|
||||
base.EjectBody(uid, cryoPodComponent);
|
||||
_climbSystem.ForciblySetClimbing(contained, uid);
|
||||
return contained;
|
||||
}
|
||||
|
||||
#region Interaction
|
||||
@@ -143,7 +147,15 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
if (args.Cancelled || args.Handled || args.Args.Target == null)
|
||||
return;
|
||||
|
||||
InsertBody(uid, args.Args.Target.Value, component);
|
||||
if (InsertBody(uid, args.Args.Target.Value, component))
|
||||
{
|
||||
if (!TryComp(uid, out CryoPodAirComponent? cryoPodAir))
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium,
|
||||
$"{ToPrettyString(args.User)} inserted {ToPrettyString(args.Args.Target.Value)} into {ToPrettyString(uid)}");
|
||||
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium,
|
||||
$"{ToPrettyString(args.User)} inserted {ToPrettyString(args.Args.Target.Value)} into {ToPrettyString(uid)} which contains gas: {cryoPodAir!.Air.ToPrettyString():gasMix}");
|
||||
}
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user