Refactor reaction effects to use reagent effects (#5426)

* reaction effect refactor

* works now
This commit is contained in:
mirrorcult
2021-11-21 00:35:02 -07:00
committed by GitHub
parent 9b39838db7
commit 1ab7170adb
36 changed files with 83 additions and 82 deletions

View File

@@ -1,15 +1,14 @@
using System;
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.ReactionEffects
{
[DataDefinition]
public class ExplosionReactionEffect : IReactionEffect
public class ExplosionReactionEffect : ReagentEffect
{
[DataField("devastationRange")] private float _devastationRange = 1;
[DataField("heavyImpactRange")] private float _heavyImpactRange = 2;
@@ -27,11 +26,11 @@ namespace Content.Server.Chemistry.ReactionEffects
/// </summary>
[DataField("maxScale")] private float _maxScale = 1;
public void React(Solution solution, EntityUid solutionEntity, double intensity, IEntityManager entityManager)
public override void Effect(ReagentEffectArgs args)
{
var floatIntensity = (float) intensity;
var floatIntensity = (float) args.Quantity;
if (!entityManager.HasComponent<SolutionContainerManagerComponent>(solutionEntity))
if (!args.EntityManager.HasComponent<SolutionContainerManagerComponent>(args.SolutionEntity))
return;
//Handle scaling
@@ -49,7 +48,7 @@ namespace Content.Server.Chemistry.ReactionEffects
var finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity);
var finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity);
var finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity);
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(solutionEntity, finalDevastationRange,
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(args.SolutionEntity, finalDevastationRange,
finalHeavyImpactRange, finalLightImpactRange, finalFlashRange);
}
}