Make fuel tanks explodey again (#4670)
* make fuel tanks explodey again * tanks now take damage from lit welders,
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user