Files
crystall-punk-14/Content.Server/EntityEffects/Effects/ModifyBloodLevel.cs

38 lines
1.2 KiB
C#
Raw Permalink Normal View History

using Content.Server.Body.Components;
2022-02-17 15:00:41 -07:00
using Content.Server.Body.Systems;
using Content.Shared.EntityEffects;
2022-02-17 15:00:41 -07:00
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
2022-02-17 15:00:41 -07:00
namespace Content.Server.EntityEffects.Effects;
2022-02-17 15:00:41 -07:00
public sealed partial class ModifyBloodLevel : EntityEffect
2022-02-17 15:00:41 -07:00
{
[DataField]
2022-02-17 15:00:41 -07:00
public bool Scaled = false;
[DataField]
2022-02-17 15:00:41 -07:00
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)
2022-02-17 15:00:41 -07:00
{
if (args.EntityManager.TryGetComponent<BloodstreamComponent>(args.TargetEntity, out var blood))
2022-02-17 15:00:41 -07:00
{
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);
2022-02-17 15:00:41 -07:00
}
}
}