Reaction & reagent effect logging (#5463)

* Reaction logging

* effect logging

* position
This commit is contained in:
mirrorcult
2021-11-22 23:51:43 -07:00
committed by GitHub
parent 93694b9dd7
commit 732baa56a9
12 changed files with 53 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ using System.Linq;
using Content.Server.Body.Components; using Content.Server.Body.Components;
using Content.Server.Chemistry.Components.SolutionManager; using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems; using Content.Server.Chemistry.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;
@@ -20,6 +21,7 @@ namespace Content.Server.Body.Systems
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAdminLogSystem _logSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -158,6 +160,9 @@ namespace Content.Server.Body.Systems
if (!effect.ShouldApply(args, _random)) if (!effect.ShouldApply(args, _random))
continue; continue;
var entity = EntityManager.GetEntity(args.SolutionEntity);
_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}");
effect.Effect(args); effect.Effect(args);
} }
} }

View File

@@ -1,3 +1,4 @@
using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction; using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
@@ -14,6 +15,10 @@ namespace Content.Server.Chemistry.EntitySystems
{ {
base.OnReaction(solution, reaction, randomReagent, ownerUid, unitReactions); base.OnReaction(solution, reaction, randomReagent, ownerUid, unitReactions);
var entity = EntityManager.GetEntity(ownerUid);
_logSystem.Add(LogType.ChemicalReaction, reaction.Impact,
$"Chemical reaction {reaction.ID} occurred with strength {unitReactions:strength} on entity {entity} at {entity.Transform.Coordinates}");
SoundSystem.Play(Filter.Pvs(ownerUid, entityManager:EntityManager), reaction.Sound.GetSound(), ownerUid); SoundSystem.Play(Filter.Pvs(ownerUid, entityManager:EntityManager), reaction.Sound.GetSound(), ownerUid);
} }
} }

View File

@@ -1,6 +1,10 @@
namespace Content.Shared.Administration.Logs; using System;
using Robust.Shared.Serialization;
namespace Content.Shared.Administration.Logs;
// DO NOT CHANGE THE NUMERIC VALUES OF THESE // DO NOT CHANGE THE NUMERIC VALUES OF THESE
[Serializable, NetSerializable]
public enum LogImpact : sbyte public enum LogImpact : sbyte
{ {
Low = -1, Low = -1,

View File

@@ -14,4 +14,6 @@ public enum LogType
EventStopped = 7, EventStopped = 7,
ShuttleCalled = 8, ShuttleCalled = 8,
ShuttleRecalled = 9, ShuttleRecalled = 9,
ChemicalReaction = 17,
ReagentEffect = 18,
} }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Sound; using Content.Shared.Sound;
@@ -36,6 +37,12 @@ namespace Content.Shared.Chemistry.Reaction
/// </summary> /// </summary>
[DataField("effects", serverOnly: true)] public List<ReagentEffect> Effects = new(); [DataField("effects", serverOnly: true)] public List<ReagentEffect> Effects = new();
/// <summary>
/// How dangerous is this effect? Stuff like bicaridine should be low, while things like methamphetamine
/// or potas/water should be high.
/// </summary>
[DataField("impact", serverOnly: true)] public LogImpact Impact = LogImpact.Low;
// TODO SERV3: Empty on the client, (de)serialize on the server with module manager is server module // TODO SERV3: Empty on the client, (de)serialize on the server with module manager is server module
[DataField("sound", serverOnly: true)] public SoundSpecifier Sound { get; private set; } = new SoundPathSpecifier("/Audio/Effects/Chemistry/bubbles.ogg"); [DataField("sound", serverOnly: true)] public SoundSpecifier Sound { get; private set; } = new SoundPathSpecifier("/Audio/Effects/Chemistry/bubbles.ogg");
} }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
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;
@@ -18,6 +19,7 @@ namespace Content.Shared.Chemistry.Reaction
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] protected readonly SharedAdminLogSystem _logSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -97,6 +99,9 @@ namespace Content.Shared.Chemistry.Reaction
if (!effect.ShouldApply(args)) if (!effect.ShouldApply(args))
continue; continue;
var entity = EntityManager.GetEntity(args.SolutionEntity);
_logSystem.Add(LogType.ReagentEffect, LogImpact.Low,
$"Reaction effect {effect.GetType().Name} of reaction ${reaction.ID:reaction} applied on entity {entity} at {entity.Transform.Coordinates}");
effect.Effect(args); effect.Effect(args);
} }
} }

View File

@@ -1,3 +1,4 @@
using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction; using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
@@ -15,6 +16,7 @@ namespace Content.Shared.Chemistry
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly SharedAdminLogSystem _logSystem = default!;
public void ReactionEntity(EntityUid uid, ReactionMethod method, Solution solution) public void ReactionEntity(EntityUid uid, ReactionMethod method, Solution solution)
{ {
@@ -59,6 +61,9 @@ namespace Content.Shared.Chemistry
if (!effect.ShouldApply(args, _robustRandom)) if (!effect.ShouldApply(args, _robustRandom))
continue; continue;
var entity = EntityManager.GetEntity(args.SolutionEntity);
_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}");
effect.Effect(args); effect.Effect(args);
} }
} }
@@ -80,6 +85,9 @@ namespace Content.Shared.Chemistry
if (!effect.ShouldApply(args, _robustRandom)) if (!effect.ShouldApply(args, _robustRandom))
continue; continue;
var entity = EntityManager.GetEntity(args.SolutionEntity);
_logSystem.Add(LogType.ReagentEffect, LogImpact.Low,
$"Reactive effect {effect.GetType().Name} of {entity} using reagent {reagent.ID} with method {method} at {entity.Transform.Coordinates}");
effect.Effect(args); effect.Effect(args);
} }
} }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
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;

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Administration.Logs;
using Content.Shared.Body.Prototypes; using Content.Shared.Body.Prototypes;
using Content.Shared.Botany; using Content.Shared.Botany;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
@@ -119,6 +120,9 @@ namespace Content.Shared.Chemistry.Reagent
if (!plantMetabolizable.ShouldApply(args, random)) if (!plantMetabolizable.ShouldApply(args, random))
continue; continue;
var entity = entMan.GetEntity(args.SolutionEntity);
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}");
plantMetabolizable.Effect(args); plantMetabolizable.Effect(args);
} }
} }

View File

@@ -56,6 +56,7 @@
- type: reaction - type: reaction
id: PotassiumExplosion id: PotassiumExplosion
impact: High
reactants: reactants:
Water: Water:
amount: 1 amount: 1
@@ -73,6 +74,7 @@
- type: reaction - type: reaction
id: Smoke id: Smoke
impact: High
reactants: reactants:
Phosphorus: Phosphorus:
amount: 1 amount: 1
@@ -95,6 +97,7 @@
- type: reaction - type: reaction
id: Foam id: Foam
impact: High
reactants: reactants:
Fluorosurfactant: Fluorosurfactant:
amount: 1 amount: 1
@@ -118,6 +121,7 @@
- type: reaction - type: reaction
id: IronMetalFoam id: IronMetalFoam
impact: High
reactants: reactants:
Iron: Iron:
amount: 3 amount: 3
@@ -143,6 +147,7 @@
- type: reaction - type: reaction
id: AluminiumMetalFoam id: AluminiumMetalFoam
impact: High
reactants: reactants:
Aluminium: Aluminium:
amount: 3 amount: 3
@@ -178,6 +183,7 @@
- type: reaction - type: reaction
id: Thermite id: Thermite
impact: Medium
reactants: reactants:
Iron: Iron:
amount: 1 amount: 1
@@ -224,6 +230,7 @@
- type: reaction - type: reaction
id: Fluorosurfactant id: Fluorosurfactant
impact: Medium
reactants: reactants:
Carbon: Carbon:
amount: 2 amount: 2
@@ -236,6 +243,7 @@
- type: reaction - type: reaction
id: Desoxyephedrine id: Desoxyephedrine
impact: Medium
reactants: reactants:
Ephedrine: Ephedrine:
amount: 1 amount: 1
@@ -250,6 +258,7 @@
- type: reaction - type: reaction
id: Ephedrine id: Ephedrine
impact: Medium
reactants: reactants:
Oil: Oil:
amount: 1 amount: 1

View File

@@ -22,6 +22,7 @@
- type: reaction - type: reaction
id: SpaceLube id: SpaceLube
impact: Medium
reactants: reactants:
Water: Water:
amount: 1 amount: 1

View File

@@ -370,6 +370,7 @@
- type: reaction - type: reaction
id: Lexorin id: Lexorin
impact: High
reactants: reactants:
Ammonia: Ammonia:
amount: 1 amount: 1