Files
tbd-station-14/Content.Server/Chemistry/ReagentEffectConditions/ReagentThreshold.cs
mirrorcult 747f02f3f3 Metabolism tweaks / metabolism 4.0 (#5246)
* Metabolism tweaks

* use MetabolismArgs and convert ReagentEntityReactions into ReagentEffects

* fork forgor 💀

* fixes
2021-11-10 11:11:28 +01:00

33 lines
1002 B
C#

using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Chemistry.ReagentEffectConditions
{
/// <summary>
/// Used for implementing reagent effects that require a certain amount of reagent before it should be applied.
/// For instance, overdoses.
/// </summary>
public class ReagentThreshold : ReagentEffectCondition
{
[DataField("min")]
public FixedPoint2 Min = FixedPoint2.Zero;
[DataField("max")]
public FixedPoint2 Max = FixedPoint2.MaxValue;
public override bool Condition(ReagentEffectArgs args)
{
if (args.Source != null)
{
var quant = args.Source.GetReagentQuantity(args.Reagent.ID);
return quant >= Min && quant <= Max;
}
return false;
}
}
}