using Content.Shared.Body.Components;
using Content.Shared.Body.Systems;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityEffects.Effects.Body;
///
/// Adds a reagent directly to the target's bloodstream.
/// Quantity is modified by scale.
///
///
public sealed partial class AddReagentToBloodstreamEntityEffectSystem : EntityEffectSystem
{
[Dependency] private BloodstreamSystem _bloodstream = default!;
[Dependency] private ReactiveSystem _reactive = default!;
protected override void Effect(Entity entity, ref EntityEffectEvent args)
{
var solution = new Content.Shared.Chemistry.Components.Solution();
solution.AddReagent(args.Effect.Reagent, args.Effect.Quantity * args.Scale);
_bloodstream.TryAddToBloodstream(entity.AsNullable(), solution);
_reactive.DoEntityReaction(entity, solution, ReactionMethod.Injection); // TODO: This should be part of TryAddToBloodstream
}
}
///
public sealed partial class AddReagentToBloodstream : EntityEffectBase
{
///
/// Prototype of the reagent we're adding.
///
[DataField(required: true)]
public ProtoId Reagent;
///
/// Amount of reagent to add to the bloodstream.
///
[DataField]
public FixedPoint2 Quantity = 1.0;
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
{
return prototype.Resolve(Reagent, out var proto)
? Loc.GetString("entity-effect-guidebook-add-reagent-to-bloodstream", ("chance", Probability), ("reagent", proto.LocalizedName), ("quantity", Quantity))
: null;
}
}