2024-06-30 05:43:43 +02:00
|
|
|
using Content.Server.Body.Components;
|
2022-02-17 15:00:41 -07:00
|
|
|
using Content.Server.Body.Systems;
|
2024-06-30 05:43:43 +02:00
|
|
|
using Content.Shared.EntityEffects;
|
2022-02-17 15:00:41 -07:00
|
|
|
using Content.Shared.FixedPoint;
|
2023-06-04 16:45:02 -04:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-02-17 15:00:41 -07:00
|
|
|
|
2024-06-30 05:43:43 +02:00
|
|
|
namespace Content.Server.EntityEffects.Effects;
|
2022-02-17 15:00:41 -07:00
|
|
|
|
2024-06-30 05:43:43 +02:00
|
|
|
public sealed partial class ModifyBloodLevel : EntityEffect
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
2023-12-29 04:47:43 -08:00
|
|
|
[DataField]
|
2022-02-17 15:00:41 -07:00
|
|
|
public bool Scaled = false;
|
|
|
|
|
|
2023-12-29 04:47:43 -08:00
|
|
|
[DataField]
|
2022-02-17 15:00:41 -07:00
|
|
|
public FixedPoint2 Amount = 1.0f;
|
|
|
|
|
|
2023-06-04 16:45:02 -04:00
|
|
|
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
|
|
|
|
=> Loc.GetString("reagent-effect-guidebook-modify-blood-level", ("chance", Probability),
|
|
|
|
|
("deltasign", MathF.Sign(Amount.Float())));
|
|
|
|
|
|
2024-06-30 05:43:43 +02:00
|
|
|
public override void Effect(EntityEffectBaseArgs args)
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
2024-06-30 05:43:43 +02:00
|
|
|
if (args.EntityManager.TryGetComponent<BloodstreamComponent>(args.TargetEntity, out var blood))
|
2022-02-17 15:00:41 -07:00
|
|
|
{
|
2024-05-12 17:34:52 -07:00
|
|
|
var sys = args.EntityManager.System<BloodstreamSystem>();
|
2024-06-30 05:43:43 +02:00
|
|
|
var amt = Amount;
|
|
|
|
|
if (args is EntityEffectReagentArgs reagentArgs)
|
|
|
|
|
{
|
|
|
|
|
if (Scaled)
|
|
|
|
|
amt *= reagentArgs.Quantity;
|
|
|
|
|
amt *= reagentArgs.Scale;
|
|
|
|
|
}
|
2022-12-21 09:51:49 -05:00
|
|
|
|
2024-06-30 05:43:43 +02:00
|
|
|
sys.TryModifyBloodLevel(args.TargetEntity, amt, blood);
|
2022-02-17 15:00:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|