Log a lot less reagent effects (#5572)

This commit is contained in:
mirrorcult
2021-11-27 00:31:56 -07:00
committed by GitHub
parent bf30f82ff5
commit f697bf413c
9 changed files with 58 additions and 20 deletions

View File

@@ -160,10 +160,13 @@ namespace Content.Server.Body.Systems
if (!effect.ShouldApply(args, _random)) if (!effect.ShouldApply(args, _random))
continue; continue;
var entity = EntityManager.GetEntity(args.SolutionEntity); if (effect.ShouldLog)
_logSystem.Add(LogType.ReagentEffect, LogImpact.Low, {
$"Metabolism effect {effect.GetType().Name} of reagent {args.Reagent.Name:reagent} applied on entity {entity} at {entity.Transform.Coordinates}"); var entity = EntityManager.GetEntity(args.SolutionEntity);
effect.Effect(args); _logSystem.Add(LogType.ReagentEffect, effect.LogImpact,
$"Metabolism effect {effect.GetType().Name} of reagent {args.Reagent.Name:reagent} applied on entity {entity} at {entity.Transform.Coordinates}");
effect.Effect(args);
}
} }
} }

View File

@@ -2,6 +2,7 @@
using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Components;
using Content.Server.Chemistry.EntitySystems; using Content.Server.Chemistry.EntitySystems;
using Content.Server.Coordinates.Helpers; using Content.Server.Coordinates.Helpers;
using Content.Shared.Administration.Logs;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction; using Content.Shared.Chemistry.Reaction;
@@ -78,6 +79,9 @@ namespace Content.Server.Chemistry.ReactionEffects
/// </summary> /// </summary>
[DataField("sound", required: true)] private SoundSpecifier _sound = default!; [DataField("sound", required: true)] private SoundSpecifier _sound = default!;
public override bool ShouldLog => true;
public override LogImpact LogImpact => LogImpact.High;
void ISerializationHooks.AfterDeserialization() void ISerializationHooks.AfterDeserialization()
{ {
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);

View File

@@ -1,6 +1,7 @@
using System; using System;
using Content.Server.Chemistry.Components.SolutionManager; using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Explosion.EntitySystems; using Content.Server.Explosion.EntitySystems;
using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
@@ -26,6 +27,9 @@ namespace Content.Server.Chemistry.ReactionEffects
/// </summary> /// </summary>
[DataField("maxScale")] private float _maxScale = 1; [DataField("maxScale")] private float _maxScale = 1;
public override bool ShouldLog => true;
public override LogImpact LogImpact => LogImpact.High;
public override void Effect(ReagentEffectArgs args) public override void Effect(ReagentEffectArgs args)
{ {
var floatIntensity = (float) args.Quantity; var floatIntensity = (float) args.Quantity;

View File

@@ -15,6 +15,8 @@ public class Electrocute : ReagentEffect
[DataField("electrocuteDamageScale")] public int ElectrocuteDamageScale = 5; [DataField("electrocuteDamageScale")] public int ElectrocuteDamageScale = 5;
public override bool ShouldLog => true;
public override void Effect(ReagentEffectArgs args) public override void Effect(ReagentEffectArgs args)
{ {
EntitySystem.Get<ElectrocutionSystem>().TryDoElectrocution(args.SolutionEntity, null, EntitySystem.Get<ElectrocutionSystem>().TryDoElectrocution(args.SolutionEntity, null,

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Atmos.Components; using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
@@ -14,6 +15,9 @@ namespace Content.Server.Chemistry.ReagentEffects
[UsedImplicitly] [UsedImplicitly]
public class FlammableReaction : ReagentEffect public class FlammableReaction : ReagentEffect
{ {
public override bool ShouldLog => true;
public override LogImpact LogImpact => LogImpact.Medium;
public override void Effect(ReagentEffectArgs args) public override void Effect(ReagentEffectArgs args)
{ {
if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out FlammableComponent? flammable)) return; if (!args.EntityManager.TryGetComponent(args.SolutionEntity, out FlammableComponent? flammable)) return;

View File

@@ -114,10 +114,13 @@ namespace Content.Shared.Chemistry.Reaction
if (!effect.ShouldApply(args)) if (!effect.ShouldApply(args))
continue; continue;
var entity = EntityManager.GetEntity(args.SolutionEntity); if (effect.ShouldLog)
_logSystem.Add(LogType.ReagentEffect, LogImpact.Low, {
$"Reaction effect {effect.GetType().Name} of reaction ${reaction.ID:reaction} applied on entity {entity} at {entity.Transform.Coordinates}"); var entity = EntityManager.GetEntity(args.SolutionEntity);
effect.Effect(args); _logSystem.Add(LogType.ReagentEffect, effect.LogImpact,
$"Reaction effect {effect.GetType().Name} of reaction ${reaction.ID:reaction} applied on entity {entity} at {entity.Transform.Coordinates}");
effect.Effect(args);
}
} }
} }

View File

@@ -61,10 +61,13 @@ namespace Content.Shared.Chemistry
if (!effect.ShouldApply(args, _robustRandom)) if (!effect.ShouldApply(args, _robustRandom))
continue; continue;
var entity = EntityManager.GetEntity(args.SolutionEntity); if (effect.ShouldLog)
_logSystem.Add(LogType.ReagentEffect, LogImpact.Medium, {
$"Reactive effect {effect.GetType().Name} of reagent {reagent.ID:reagent} with method {method} applied on entity {entity} at {entity.Transform.Coordinates}"); var entity = EntityManager.GetEntity(args.SolutionEntity);
effect.Effect(args); _logSystem.Add(LogType.ReagentEffect, effect.LogImpact,
$"Reactive effect {effect.GetType().Name} of reagent {reagent.ID:reagent} with method {method} applied on entity {entity} at {entity.Transform.Coordinates}");
effect.Effect(args);
}
} }
} }
} }
@@ -85,10 +88,13 @@ namespace Content.Shared.Chemistry
if (!effect.ShouldApply(args, _robustRandom)) if (!effect.ShouldApply(args, _robustRandom))
continue; continue;
var entity = EntityManager.GetEntity(args.SolutionEntity); if (effect.ShouldLog)
_logSystem.Add(LogType.ReagentEffect, LogImpact.Low, {
$"Reactive effect {effect.GetType().Name} of {entity} using reagent {reagent.ID} with method {method} at {entity.Transform.Coordinates}"); var entity = EntityManager.GetEntity(args.SolutionEntity);
effect.Effect(args); _logSystem.Add(LogType.ReagentEffect, effect.LogImpact,
$"Reactive effect {effect.GetType().Name} of {entity} using reagent {reagent.ID} with method {method} at {entity.Transform.Coordinates}");
effect.Effect(args);
}
} }
} }
} }

View File

@@ -31,6 +31,15 @@ namespace Content.Shared.Chemistry.Reagent
[DataField("probability")] [DataField("probability")]
public float Probability = 1.0f; public float Probability = 1.0f;
[DataField("logImpact")]
public virtual LogImpact LogImpact { get; } = LogImpact.Low;
/// <summary>
/// Should this reagent effect log at all?
/// </summary>
[DataField("shouldLog")]
public virtual bool ShouldLog { get; } = false;
public abstract void Effect(ReagentEffectArgs args); public abstract void Effect(ReagentEffectArgs args);
} }

View File

@@ -120,10 +120,13 @@ namespace Content.Shared.Chemistry.Reagent
if (!plantMetabolizable.ShouldApply(args, random)) if (!plantMetabolizable.ShouldApply(args, random))
continue; continue;
var entity = entMan.GetEntity(args.SolutionEntity); if (plantMetabolizable.ShouldLog)
EntitySystem.Get<SharedAdminLogSystem>().Add(LogType.ReagentEffect, LogImpact.Low, {
$"Plant metabolism effect {plantMetabolizable.GetType().Name:effect} of reagent {ID} applied on entity {entity} at {entity.Transform.Coordinates}"); var entity = entMan.GetEntity(args.SolutionEntity);
plantMetabolizable.Effect(args); EntitySystem.Get<SharedAdminLogSystem>().Add(LogType.ReagentEffect, plantMetabolizable.LogImpact,
$"Plant metabolism effect {plantMetabolizable.GetType().Name:effect} of reagent {ID} applied on entity {entity} at {entity.Transform.Coordinates}");
plantMetabolizable.Effect(args);
}
} }
} }
} }