Improve explosion logs (#13351)

* add types to explosion logs

* make explosions logged by default

* add cause parameter to IThresholdBehavior

* add cause to ExplodeBehaviors

* add cause to power cell explosions

* remove useless log

* add triggerer to triggers

* add logs for damage from explosions

* sneaky power cell update
This commit is contained in:
Chief-Engineer
2023-02-10 17:45:38 -06:00
committed by GitHub
parent 57275d97d3
commit 95e35b94b5
27 changed files with 71 additions and 46 deletions

View File

@@ -51,7 +51,7 @@ namespace Content.Server.Destructible
{
RaiseLocalEvent(uid, new DamageThresholdReached(component, threshold), true);
threshold.Execute(uid, this, EntityManager);
threshold.Execute(uid, this, EntityManager, args.Origin);
}
// if destruction behavior (or some other deletion effect) occurred, don't run other triggers.

View File

@@ -9,7 +9,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataField("node")]
public string Node { get; private set; } = string.Empty;
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (string.IsNullOrEmpty(Node) || !system.EntityManager.TryGetComponent(owner, out ConstructionComponent? construction))
return;

View File

@@ -15,7 +15,7 @@
return (Acts & act) != 0;
}
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (HasAct(ThresholdActs.Breakage))
{

View File

@@ -6,7 +6,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataDefinition]
public sealed class DumpCanisterBehavior : IThresholdBehavior
{
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
system.EntityManager.EntitySysManager.GetEntitySystem<GasCanisterSystem>().PurgeContents(owner);
}

View File

@@ -24,7 +24,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataField("offset")]
public float Offset { get; set; } = 0.5f;
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (!system.EntityManager.TryGetComponent<VendingMachineRestockComponent>(owner, out var packagecomp) ||
!system.EntityManager.TryGetComponent<TransformComponent>(owner, out var xform))

View File

@@ -23,7 +23,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataField("max")]
public int Max = 3;
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (!system.EntityManager.TryGetComponent<VendingMachineComponent>(owner, out var vendingcomp) ||
!system.EntityManager.TryGetComponent<TransformComponent>(owner, out var xform))

View File

@@ -8,7 +8,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataDefinition]
public sealed class EmptyAllContainersBehaviour : IThresholdBehavior
{
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (!system.EntityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
return;

View File

@@ -10,9 +10,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataDefinition]
public sealed class ExplodeBehavior : IThresholdBehavior
{
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
system.ExplosionSystem.TriggerExplosive(owner);
system.ExplosionSystem.TriggerExplosive(owner, user:cause);
}
}
}

View File

@@ -9,7 +9,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
{
[DataField("recursive")] private bool _recursive = true;
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (system.EntityManager.TryGetComponent(owner, out BodyComponent? body))
{

View File

@@ -10,6 +10,7 @@
/// An instance of <see cref="DestructibleSystem"/> to pull dependencies
/// and other systems from.
/// </param>
void Execute(EntityUid owner, DestructibleSystem system);
/// <param name="cause">The entity that caused this behavior.</param>
void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null);
}
}

View File

@@ -13,7 +13,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
/// </summary>
[DataField("sound", required: true)] public SoundSpecifier Sound { get; set; } = default!;
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
var pos = system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates;
SoundSystem.Play(Sound.GetSound(), Filter.Pvs(pos), pos, AudioHelpers.WithVariation(0.125f));

View File

@@ -16,7 +16,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataField("solution", required: true)]
public string Solution = default!;
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (system.SolutionContainerSystem.TryGetSolution(owner, Solution, out var explodingSolution)
&& system.EntityManager.TryGetComponent(owner, out ExplosiveComponent? explosiveComponent))
@@ -39,7 +39,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
// Don't delete the object here - let other processes like physical damage from the
// explosion clean up the exploding object(s)
var explosiveTotalIntensity = explosiveComponent.TotalIntensity * explosionScaleFactor;
system.ExplosionSystem.TriggerExplosive(owner, explosiveComponent, false, explosiveTotalIntensity);
system.ExplosionSystem.TriggerExplosive(owner, explosiveComponent, false, explosiveTotalIntensity, user:cause);
}
}
}

View File

@@ -19,7 +19,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataField("offset")]
public float Offset { get; set; } = 0.5f;
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
var position = system.EntityManager.GetComponent<TransformComponent>(owner).MapPosition;

View File

@@ -19,7 +19,8 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
/// </summary>
/// <param name="owner">Entity on which behavior is executed</param>
/// <param name="system">system calling the behavior</param>
public void Execute(EntityUid owner, DestructibleSystem system)
/// <param name="cause"></param>
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
var spillableSystem = EntitySystem.Get<SpillableSystem>();

View File

@@ -3,8 +3,8 @@
[DataDefinition]
public sealed class TriggerBehavior : IThresholdBehavior
{
public void Execute(EntityUid owner, DestructibleSystem system)
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
system.TriggerSystem.Trigger(owner);
system.TriggerSystem.Trigger(owner, cause);
}
}

View File

@@ -77,7 +77,9 @@ namespace Content.Server.Destructible.Thresholds
/// An instance of <see cref="DestructibleSystem"/> to get dependency and
/// system references from, if relevant.
/// </param>
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager)
/// <param name="entityManager"></param>
/// <param name="cause"></param>
public void Execute(EntityUid owner, DestructibleSystem system, IEntityManager entityManager, EntityUid? cause)
{
Triggered = true;
@@ -87,7 +89,7 @@ namespace Content.Server.Destructible.Thresholds
if (!entityManager.EntityExists(owner))
return;
behavior.Execute(owner, system);
behavior.Execute(owner, system, cause);
}
}
}