Make fuel tanks explodey again (#4670)

* make fuel tanks explodey again

* tanks now take damage from lit welders,
This commit is contained in:
Leon Friedrich
2021-10-02 19:42:46 +10:00
committed by GitHub
parent 2992bd74cd
commit f80f252ff2
7 changed files with 64 additions and 28 deletions

View File

@@ -13,19 +13,18 @@ namespace Content.Server.Damage.Components
[RegisterComponent]
public class DamageOnToolInteractComponent : Component, IInteractUsing
{
public override string Name => "DamageOnToolInteract";
[DataField("tools")]
private List<ToolQuality> _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<bool> 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<DamageableSystem>().TryChangeDamage(eventArgs.Target.Uid, DefaultDamage);
return true;

View File

@@ -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
{
/// <summary>
/// This behavior will trigger entities with <see cref="ExplosiveComponent"/> to go boom.
/// </summary>
[UsedImplicitly]
[DataDefinition]
public class ExplodeBehavior : IThresholdBehavior
{
public void Execute(IEntity owner, DestructibleSystem system)
{
owner.SpawnExplosion();
}
}
}

View File

@@ -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
{
/// <summary>
/// Specifies an explosion range should this entity be exploded.
/// Specifies an explosion range should this entity be exploded.
/// </summary>
/// <remarks>
/// Explosions can be caused by:
/// <list type="bullet">
/// <item>Reaching a damage threshold that causes a <see cref="ExplodeBehavior"/></item>
/// <item>Being triggered via the <see cref="ExplodeOnTriggerComponent"/></item>
/// <item>Manually by some other system via functions in <see cref="ExplosionHelper"/> (for example, chemistry's
/// <see cref="ExplosionReactionEffect"/>).</item>
/// </list>
/// </remarks>
[RegisterComponent]
public class ExplosiveComponent : Component
{

View File

@@ -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<SoundOnTriggerComponent, TriggerEvent>(HandleSoundTrigger);
SubscribeLocalEvent<ExplodeOnTriggerComponent, TriggerEvent>(HandleExplodeTrigger);
SubscribeLocalEvent<FlashOnTriggerComponent, TriggerEvent>(HandleFlashTrigger);
SubscribeLocalEvent<ExplosiveComponent, DestructionEventArgs>(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;

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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: