Files
tbd-station-14/Content.Server/EntityEffects/Effects/ModifyBloodLevel.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

38 lines
1.2 KiB
C#

using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Shared.EntityEffects;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
namespace Content.Server.EntityEffects.Effects;
public sealed partial class ModifyBloodLevel : EntityEffect
{
[DataField]
public bool Scaled = false;
[DataField]
public FixedPoint2 Amount = 1.0f;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-modify-blood-level", ("chance", Probability),
("deltasign", MathF.Sign(Amount.Float())));
public override void Effect(EntityEffectBaseArgs args)
{
if (args.EntityManager.TryGetComponent<BloodstreamComponent>(args.TargetEntity, out var blood))
{
var sys = args.EntityManager.System<BloodstreamSystem>();
var amt = Amount;
if (args is EntityEffectReagentArgs reagentArgs)
{
if (Scaled)
amt *= reagentArgs.Quantity;
amt *= reagentArgs.Scale;
}
sys.TryModifyBloodLevel(args.TargetEntity, amt, blood);
}
}
}