add destructible logs (#18788)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.Body.Systems;
|
using Content.Server.Body.Systems;
|
||||||
using Content.Server.Chemistry.EntitySystems;
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
using Content.Server.Construction;
|
using Content.Server.Construction;
|
||||||
@@ -8,6 +10,7 @@ using Content.Server.Explosion.EntitySystems;
|
|||||||
using Content.Server.Fluids.EntitySystems;
|
using Content.Server.Fluids.EntitySystems;
|
||||||
using Content.Server.Stack;
|
using Content.Server.Stack;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@@ -33,6 +36,7 @@ namespace Content.Server.Destructible
|
|||||||
[Dependency] public readonly PuddleSystem PuddleSystem = default!;
|
[Dependency] public readonly PuddleSystem PuddleSystem = default!;
|
||||||
[Dependency] public readonly IPrototypeManager PrototypeManager = default!;
|
[Dependency] public readonly IPrototypeManager PrototypeManager = default!;
|
||||||
[Dependency] public readonly IComponentFactory ComponentFactory = default!;
|
[Dependency] public readonly IComponentFactory ComponentFactory = default!;
|
||||||
|
[Dependency] public readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -51,6 +55,27 @@ namespace Content.Server.Destructible
|
|||||||
{
|
{
|
||||||
RaiseLocalEvent(uid, new DamageThresholdReached(component, threshold), true);
|
RaiseLocalEvent(uid, new DamageThresholdReached(component, threshold), true);
|
||||||
|
|
||||||
|
// Convert behaviors into string for logs
|
||||||
|
var triggeredBehaviors = string.Join(", ", threshold.Behaviors.Select(b =>
|
||||||
|
{
|
||||||
|
if (b is DoActsBehavior doActsBehavior)
|
||||||
|
{
|
||||||
|
return $"{b.GetType().Name}:{doActsBehavior.Acts.ToString()}";
|
||||||
|
}
|
||||||
|
return b.GetType().Name;
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (args.Origin != null)
|
||||||
|
{
|
||||||
|
_adminLogger.Add(LogType.Damaged, LogImpact.Medium,
|
||||||
|
$"{ToPrettyString(args.Origin.Value):actor} caused {ToPrettyString(uid):subject} to trigger [{triggeredBehaviors}]");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_adminLogger.Add(LogType.Damaged, LogImpact.Medium,
|
||||||
|
$"Unknown damage source caused {ToPrettyString(uid):subject} to trigger [{triggeredBehaviors}]");
|
||||||
|
}
|
||||||
|
|
||||||
threshold.Execute(uid, this, EntityManager, args.Origin);
|
threshold.Execute(uid, this, EntityManager, args.Origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user