Files
tbd-station-14/Content.Server/EntityEffects/Effects/EmpReactionEffect.cs
SlamBamActionman b9fa941ca6 Turn ReagentEffects into generic EntityEffects (#28168)
* Oh the possibilities

* Merge fixes

* Forgot to remote LavaSystem oops

* Changed EntityEffectArgs to EntityEffectBaseArgs and EntityEffectReagentArgs

* Throw exception for unimplemented effectargs

* Remove Json and overrideable datafields

* Fix test issues

* Actually fix the compiling issue

* Fix comments and remove EntityEffectArgs (no longer used, replaced with EntityEffectBaseArgs)
2024-06-30 13:43:43 +10:00

59 lines
1.7 KiB
C#

using Content.Server.Emp;
using Content.Shared.EntityEffects;
using Content.Shared.Chemistry.Reagent;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Server.EntityEffects.Effects;
[DataDefinition]
public sealed partial class EmpReactionEffect : EntityEffect
{
/// <summary>
/// Impulse range per unit of quantity
/// </summary>
[DataField("rangePerUnit")]
public float EmpRangePerUnit = 0.5f;
/// <summary>
/// Maximum impulse range
/// </summary>
[DataField("maxRange")]
public float EmpMaxRange = 10;
/// <summary>
/// How much energy will be drain from sources
/// </summary>
[DataField]
public float EnergyConsumption = 12500;
/// <summary>
/// Amount of time entities will be disabled
/// </summary>
[DataField("duration")]
public float DisableDuration = 15;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-emp-reaction-effect", ("chance", Probability));
public override void Effect(EntityEffectBaseArgs args)
{
var tSys = args.EntityManager.System<TransformSystem>();
var transform = args.EntityManager.GetComponent<TransformComponent>(args.TargetEntity);
var range = EmpRangePerUnit;
if (args is EntityEffectReagentArgs reagentArgs)
{
range = MathF.Min((float) (reagentArgs.Quantity * EmpRangePerUnit), EmpMaxRange);
}
args.EntityManager.System<EmpSystem>()
.EmpPulse(tSys.GetMapCoordinates(args.TargetEntity, xform: transform),
range,
EnergyConsumption,
DisableDuration);
}
}