using Content.Shared.Inventory;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.ReagentEffects;
///
/// A reaction effect that consumes the required amount of reagent and spawns PrototypeID in the
/// entity's Slot. Used to implement the water droplet effect for arachnids.
///
public sealed partial class WearableReaction : ReagentEffect
{
///
/// Minimum quantity of reagent required to trigger this effect.
///
[DataField]
public float AmountThreshold = 1f;
///
/// Slot to spawn the item into.
///
[DataField(required: true)]
public string Slot;
///
/// Prototype ID of item to spawn.
///
[DataField(required: true)]
public string PrototypeID;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => null;
public override void Effect(ReagentEffectArgs args)
{
if (args.Reagent == null || args.Quantity < AmountThreshold)
return;
// SpawnItemInSlot returns false if slot is already occupied
if (args.EntityManager.System().SpawnItemInSlot(args.SolutionEntity, Slot, PrototypeID))
args.Source?.RemoveReagent(args.Reagent.ID, AmountThreshold);
}
}