Adds a new SolutionExplosionBehavior for the benefit of fuel tanks and future exploding canisters (#11260)
This commit is contained in:
@@ -11,6 +11,8 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
|
using Content.Server.Fluids.EntitySystems;
|
||||||
|
|
||||||
namespace Content.Server.Destructible
|
namespace Content.Server.Destructible
|
||||||
{
|
{
|
||||||
@@ -25,6 +27,8 @@ namespace Content.Server.Destructible
|
|||||||
[Dependency] public readonly ExplosionSystem ExplosionSystem = default!;
|
[Dependency] public readonly ExplosionSystem ExplosionSystem = default!;
|
||||||
[Dependency] public readonly StackSystem StackSystem = default!;
|
[Dependency] public readonly StackSystem StackSystem = default!;
|
||||||
[Dependency] public readonly TriggerSystem TriggerSystem = default!;
|
[Dependency] public readonly TriggerSystem TriggerSystem = default!;
|
||||||
|
[Dependency] public readonly SolutionContainerSystem SolutionContainerSystem = default!;
|
||||||
|
[Dependency] public readonly SpillableSystem SpillableSystem = 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!;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
|
using Content.Server.Fluids.Components;
|
||||||
|
using Content.Server.Fluids.EntitySystems;
|
||||||
|
using Content.Server.Explosion.Components;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Works like a SpillBehavior combined with an ExplodeBehavior
|
||||||
|
/// </summary>
|
||||||
|
[UsedImplicitly]
|
||||||
|
[DataDefinition]
|
||||||
|
public sealed class SolutionExplosionBehavior : IThresholdBehavior
|
||||||
|
{
|
||||||
|
[DataField("solution", required: true)]
|
||||||
|
public string Solution = default!;
|
||||||
|
|
||||||
|
public void Execute(EntityUid owner, DestructibleSystem system)
|
||||||
|
{
|
||||||
|
if (system.SolutionContainerSystem.TryGetSolution(owner, Solution, out var explodingSolution)
|
||||||
|
&& system.EntityManager.TryGetComponent(owner, out ExplosiveComponent? explosiveComponent))
|
||||||
|
{
|
||||||
|
// Don't explode if there's no solution
|
||||||
|
if (explodingSolution.CurrentVolume == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Scale the explosion intensity based on the remaining volume of solution
|
||||||
|
var explosionScaleFactor = (explodingSolution.CurrentVolume.Float() / explodingSolution.MaxVolume.Float());
|
||||||
|
|
||||||
|
// TODO: Perhaps some of the liquid should be discarded as if it's being consumed by the explosion
|
||||||
|
|
||||||
|
// Spill the solution out into the world
|
||||||
|
// Spill before exploding in anticipation of a future where the explosion can light the solution on fire.
|
||||||
|
var coordinates = system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates;
|
||||||
|
system.SpillableSystem.SpillAt(explodingSolution, coordinates, "PuddleSmear", combine: true);
|
||||||
|
|
||||||
|
// Explode
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,17 +30,17 @@
|
|||||||
damageType: Heat
|
damageType: Heat
|
||||||
damage: 5
|
damage: 5
|
||||||
behaviors:
|
behaviors:
|
||||||
#spill BEFORE exploding, so that one day explosions can ignite puddles
|
- !type:SolutionExplosionBehavior
|
||||||
- !type:SpillBehavior
|
|
||||||
solution: tank
|
solution: tank
|
||||||
- !type:ExplodeBehavior
|
|
||||||
#note: only actually explodes if entity has ExplosiveComponent.
|
|
||||||
- trigger:
|
- trigger:
|
||||||
!type:DamageTrigger
|
!type:DamageTrigger
|
||||||
damage: 10
|
damage: 10
|
||||||
behaviors:
|
behaviors:
|
||||||
- !type:SpillBehavior
|
- !type:SpillBehavior
|
||||||
solution: tank
|
solution: tank
|
||||||
|
- !type:PlaySoundBehavior
|
||||||
|
sound:
|
||||||
|
path: /Audio/Effects/metalbreak.ogg
|
||||||
- !type:DoActsBehavior
|
- !type:DoActsBehavior
|
||||||
acts: ["Destruction"]
|
acts: ["Destruction"]
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
|
|||||||
Reference in New Issue
Block a user