2021-01-07 00:31:43 -06:00
|
|
|
using System;
|
2022-01-18 16:44:22 -05:00
|
|
|
using System.Text.Json.Serialization;
|
2021-10-29 13:40:15 +01:00
|
|
|
using Content.Server.Chemistry.Components.SolutionManager;
|
2021-11-09 21:24:35 +01:00
|
|
|
using Content.Server.Explosion.EntitySystems;
|
2021-11-27 00:31:56 -07:00
|
|
|
using Content.Shared.Administration.Logs;
|
2021-11-21 00:35:02 -07:00
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-11-28 14:56:53 +01:00
|
|
|
using Content.Shared.Database;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2019-10-11 16:57:16 -04:00
|
|
|
|
2019-11-21 17:24:19 -05:00
|
|
|
namespace Content.Server.Chemistry.ReactionEffects
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataDefinition]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class ExplosionReactionEffect : ReagentEffect
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2022-01-18 16:44:22 -05:00
|
|
|
[DataField("devastationRange")]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
private float _devastationRange = 1;
|
|
|
|
|
|
|
|
|
|
[DataField("heavyImpactRange")]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
private float _heavyImpactRange = 2;
|
|
|
|
|
|
|
|
|
|
[DataField("lightImpactRange")]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
private float _lightImpactRange = 3;
|
2022-02-16 00:23:23 -07:00
|
|
|
|
2022-01-18 16:44:22 -05:00
|
|
|
[DataField("flashRange")]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
private float _flashRange;
|
2019-10-11 16:57:16 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// If true, then scale ranges by intensity. If not, the ranges are the same regardless of reactant amount.
|
|
|
|
|
/// </summary>
|
2022-01-18 16:44:22 -05:00
|
|
|
[DataField("scaled")]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
private bool _scaled;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
2019-10-11 16:57:16 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Maximum scaling on ranges. For example, if it equals 5, then it won't scaled anywhere past
|
|
|
|
|
/// 5 times the minimum reactant amount.
|
|
|
|
|
/// </summary>
|
2022-01-18 16:44:22 -05:00
|
|
|
[DataField("maxScale")]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
private float _maxScale = 1;
|
2019-10-11 16:57:16 -04:00
|
|
|
|
2021-11-27 00:31:56 -07:00
|
|
|
public override bool ShouldLog => true;
|
|
|
|
|
public override LogImpact LogImpact => LogImpact.High;
|
|
|
|
|
|
2021-11-21 00:35:02 -07:00
|
|
|
public override void Effect(ReagentEffectArgs args)
|
2019-10-11 16:57:16 -04:00
|
|
|
{
|
2021-11-21 00:35:02 -07:00
|
|
|
var floatIntensity = (float) args.Quantity;
|
2021-11-09 11:51:17 +01:00
|
|
|
|
2021-11-21 00:35:02 -07:00
|
|
|
if (!args.EntityManager.HasComponent<SolutionContainerManagerComponent>(args.SolutionEntity))
|
2019-10-11 16:57:16 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//Handle scaling
|
|
|
|
|
if (_scaled)
|
|
|
|
|
{
|
2020-06-13 01:28:28 -04:00
|
|
|
floatIntensity = MathF.Min(floatIntensity, _maxScale);
|
2019-10-11 16:57:16 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
floatIntensity = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Calculate intensities
|
2021-03-05 01:08:38 +01:00
|
|
|
var finalDevastationRange = (int)MathF.Round(_devastationRange * floatIntensity);
|
|
|
|
|
var finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity);
|
|
|
|
|
var finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity);
|
|
|
|
|
var finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity);
|
2021-11-21 00:35:02 -07:00
|
|
|
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(args.SolutionEntity, finalDevastationRange,
|
2019-10-11 16:57:16 -04:00
|
|
|
finalHeavyImpactRange, finalLightImpactRange, finalFlashRange);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|