2021-09-06 15:49:44 +02:00
|
|
|
|
using Content.Shared.Chemistry.Components;
|
2021-07-31 04:50:32 -07:00
|
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-11-03 16:48:03 -07:00
|
|
|
|
using Content.Shared.FixedPoint;
|
2021-07-31 04:50:32 -07:00
|
|
|
|
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.
|
2021-11-20 16:47:53 -07:00
|
|
|
|
///
|
|
|
|
|
|
/// This can also trigger on -other- reagents, not just the one metabolizing. By default, it uses the
|
|
|
|
|
|
/// one being metabolized.
|
2021-07-31 04:50:32 -07:00
|
|
|
|
/// </summary>
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class ReagentThreshold : ReagentEffectCondition
|
2021-07-31 04:50:32 -07:00
|
|
|
|
{
|
|
|
|
|
|
[DataField("min")]
|
2021-11-03 16:48:03 -07:00
|
|
|
|
public FixedPoint2 Min = FixedPoint2.Zero;
|
2021-07-31 04:50:32 -07:00
|
|
|
|
|
|
|
|
|
|
[DataField("max")]
|
2021-11-03 16:48:03 -07:00
|
|
|
|
public FixedPoint2 Max = FixedPoint2.MaxValue;
|
2021-07-31 04:50:32 -07:00
|
|
|
|
|
2021-11-20 16:47:53 -07:00
|
|
|
|
[DataField("reagent")]
|
|
|
|
|
|
public string? Reagent;
|
|
|
|
|
|
|
2021-11-10 03:11:28 -07:00
|
|
|
|
public override bool Condition(ReagentEffectArgs args)
|
2021-07-31 04:50:32 -07:00
|
|
|
|
{
|
2021-11-20 16:47:53 -07:00
|
|
|
|
if (Reagent == null)
|
|
|
|
|
|
Reagent = args.Reagent.ID;
|
|
|
|
|
|
|
|
|
|
|
|
var quant = FixedPoint2.Zero;
|
|
|
|
|
|
if (args.Source != null && args.Source.ContainsReagent(Reagent))
|
2021-11-10 03:11:28 -07:00
|
|
|
|
{
|
2021-11-20 16:47:53 -07:00
|
|
|
|
quant = args.Source.GetReagentQuantity(args.Reagent.ID);
|
2021-11-10 03:11:28 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-20 16:47:53 -07:00
|
|
|
|
return quant >= Min && quant <= Max;
|
2021-07-31 04:50:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|