From f80f252ff273e9fb28dc1ee58c1b1a1e79a2bdc9 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sat, 2 Oct 2021 19:42:46 +1000 Subject: [PATCH] Make fuel tanks explodey again (#4670) * make fuel tanks explodey again * tanks now take damage from lit welders, --- .../DamageOnToolInteractComponent.cs | 13 ++++++------ .../Thresholds/Behaviors/ExplodeBehavior.cs | 21 +++++++++++++++++++ .../Components/ExplosiveComponent.cs | 12 ++++++++++- Content.Server/Explosion/TriggerSystem.cs | 9 +------- .../Tools/Components/WelderComponent.cs | 7 ------- .../Structures/Storage/Tanks/base.yml | 12 +++++++++++ .../Structures/Storage/Tanks/tanks.yml | 18 +++++++++++----- 7 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 Content.Server/Destructible/Thresholds/Behaviors/ExplodeBehavior.cs diff --git a/Content.Server/Damage/Components/DamageOnToolInteractComponent.cs b/Content.Server/Damage/Components/DamageOnToolInteractComponent.cs index 7e07f3bd43..0cdfe5fa18 100644 --- a/Content.Server/Damage/Components/DamageOnToolInteractComponent.cs +++ b/Content.Server/Damage/Components/DamageOnToolInteractComponent.cs @@ -13,19 +13,18 @@ namespace Content.Server.Damage.Components [RegisterComponent] public class DamageOnToolInteractComponent : Component, IInteractUsing { - public override string Name => "DamageOnToolInteract"; [DataField("tools")] private List _tools = new(); - [DataField("weldingDamage", required: true)] + [DataField("weldingDamage")] [ViewVariables(VVAccess.ReadWrite)] - public DamageSpecifier WeldingDamage = default!; + public DamageSpecifier? WeldingDamage; - [DataField("defaultDamage", required: true)] + [DataField("defaultDamage")] [ViewVariables(VVAccess.ReadWrite)] - public DamageSpecifier DefaultDamage = default!; + public DamageSpecifier? DefaultDamage; async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { @@ -33,7 +32,7 @@ namespace Content.Server.Damage.Components { foreach (var toolQuality in _tools) { - if (tool.HasQuality(ToolQuality.Welding) && toolQuality == ToolQuality.Welding) + if (WeldingDamage != null && tool.HasQuality(ToolQuality.Welding) && toolQuality == ToolQuality.Welding) { if (eventArgs.Using.TryGetComponent(out WelderComponent? welder) && welder.WelderLit) { @@ -43,7 +42,7 @@ namespace Content.Server.Damage.Components break; //If the tool quality is welding and its not lit or its not actually a welder that can be lit then its pointless to continue. } - if (tool.HasQuality(toolQuality)) + if (DefaultDamage != null && tool.HasQuality(toolQuality)) { EntitySystem.Get().TryChangeDamage(eventArgs.Target.Uid, DefaultDamage); return true; diff --git a/Content.Server/Destructible/Thresholds/Behaviors/ExplodeBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/ExplodeBehavior.cs new file mode 100644 index 0000000000..c77d780a47 --- /dev/null +++ b/Content.Server/Destructible/Thresholds/Behaviors/ExplodeBehavior.cs @@ -0,0 +1,21 @@ +using Content.Server.Explosion; +using Content.Server.Explosion.Components; +using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Server.Destructible.Thresholds.Behaviors +{ + /// + /// This behavior will trigger entities with to go boom. + /// + [UsedImplicitly] + [DataDefinition] + public class ExplodeBehavior : IThresholdBehavior + { + public void Execute(IEntity owner, DestructibleSystem system) + { + owner.SpawnExplosion(); + } + } +} diff --git a/Content.Server/Explosion/Components/ExplosiveComponent.cs b/Content.Server/Explosion/Components/ExplosiveComponent.cs index 0fc47e991c..839426249b 100644 --- a/Content.Server/Explosion/Components/ExplosiveComponent.cs +++ b/Content.Server/Explosion/Components/ExplosiveComponent.cs @@ -1,11 +1,21 @@ +using Content.Server.Destructible.Thresholds.Behaviors; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Explosion.Components { /// - /// Specifies an explosion range should this entity be exploded. + /// Specifies an explosion range should this entity be exploded. /// + /// + /// Explosions can be caused by: + /// + /// Reaching a damage threshold that causes a + /// Being triggered via the + /// Manually by some other system via functions in (for example, chemistry's + /// ). + /// + /// [RegisterComponent] public class ExplosiveComponent : Component { diff --git a/Content.Server/Explosion/TriggerSystem.cs b/Content.Server/Explosion/TriggerSystem.cs index 3a071e0283..f47240d27d 100644 --- a/Content.Server/Explosion/TriggerSystem.cs +++ b/Content.Server/Explosion/TriggerSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using Content.Server.Explosion.Components; using Content.Server.Flash; using Content.Server.Flash.Components; @@ -43,16 +43,9 @@ namespace Content.Server.Explosion SubscribeLocalEvent(HandleSoundTrigger); SubscribeLocalEvent(HandleExplodeTrigger); SubscribeLocalEvent(HandleFlashTrigger); - - SubscribeLocalEvent(HandleDestruction); } #region Explosions - private void HandleDestruction(EntityUid uid, ExplosiveComponent component, DestructionEventArgs args) - { - Explode(uid, component); - } - private void HandleExplodeTrigger(EntityUid uid, ExplodeOnTriggerComponent component, TriggerEvent args) { if (!EntityManager.TryGetComponent(uid, out ExplosiveComponent? explosiveComponent)) return; diff --git a/Content.Server/Tools/Components/WelderComponent.cs b/Content.Server/Tools/Components/WelderComponent.cs index c5ffdb0999..cc38cb72fe 100644 --- a/Content.Server/Tools/Components/WelderComponent.cs +++ b/Content.Server/Tools/Components/WelderComponent.cs @@ -301,13 +301,6 @@ namespace Content.Server.Tools.Components .TryGetDrainableSolution(eventArgs.Target.Uid, out var targetSolution) && WelderSolution != null) { - if (WelderLit && targetSolution.DrainAvailable > 0) - { - // Oh no no - eventArgs.Target.SpawnExplosion(); - return true; - } - var trans = ReagentUnit.Min(WelderSolution.AvailableVolume, targetSolution.DrainAvailable); if (trans > 0) { diff --git a/Resources/Prototypes/Entities/Structures/Storage/Tanks/base.yml b/Resources/Prototypes/Entities/Structures/Storage/Tanks/base.yml index 69f00f72ec..ae9381273b 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Tanks/base.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Tanks/base.yml @@ -28,10 +28,22 @@ damageModifierSet: Metallic - type: Destructible thresholds: + - trigger: + !type:DamageTypeTrigger + damageType: Heat + damage: 5 + behaviors: + #spill BEFORE exploding, so that one day explosions can ignite puddles + - !type:SpillBehavior + solution: tank + - !type:ExplodeBehavior + #note: only actually explodes if entity has ExplosiveComponent. - trigger: !type:DamageTrigger damage: 10 behaviors: + - !type:SpillBehavior + solution: tank - !type:DoActsBehavior acts: ["Destruction"] - type: SolutionContainerManager diff --git a/Resources/Prototypes/Entities/Structures/Storage/Tanks/tanks.yml b/Resources/Prototypes/Entities/Structures/Storage/Tanks/tanks.yml index 030df50418..7a53dec57f 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Tanks/tanks.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Tanks/tanks.yml @@ -12,6 +12,19 @@ state: fueltank - type: ReagentTank tankType: Fuel + - type: DamageOnToolInteract + tools: + - 16 # welding + weldingDamage: + types: + Heat: 10 + - type: Explosive + # The explosive component is independent of the stored liquid :/ + # I dream of a day where all grenades/explosives will be reagent dependent. + devastationRange: 0 + heavyImpactRange: 2 + lightImpactRange: 6 + flashRange: 5 - type: entity id: WeldingFuelTankFull @@ -20,11 +33,6 @@ suffix: Full description: A storage tank containing welding fuel. components: - - type: Explosive - devastationRange: 0 - heavyImpactRange: 2 - lightImpactRange: 6 - flashRange: 5 - type: SolutionContainerManager solutions: tank: