Adds metabolism effects to pretty much every chem already in the game (#5349)
* pass 1 * a little more reagent effect for breakfast * move lots of stuff around * implements all medicines * implement all cleaning & elements * implement toxins/pyrotechnic * p * linter fixies * fixes + narcotic balancing * fix and standardize * reviews * things
This commit is contained in:
@@ -4,6 +4,8 @@ using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.Chemistry.Reagent
|
||||
@@ -22,9 +24,44 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
[DataField("conditions")]
|
||||
public ReagentEffectCondition[]? Conditions;
|
||||
|
||||
/// <summary>
|
||||
/// What's the chance, from 0 to 1, that this effect will occur?
|
||||
/// </summary>
|
||||
[DataField("probability")]
|
||||
public float Probability = 1.0f;
|
||||
|
||||
public abstract void Metabolize(ReagentEffectArgs args);
|
||||
}
|
||||
|
||||
public static class ReagentEffectExt
|
||||
{
|
||||
public static bool ShouldApply(this ReagentEffect effect, ReagentEffectArgs args,
|
||||
IRobustRandom? random = null)
|
||||
{
|
||||
if (random == null)
|
||||
random = IoCManager.Resolve<IRobustRandom>();
|
||||
|
||||
|
||||
// Make sure we still have enough reagent to go...
|
||||
if (args.Source != null && !args.Source.ContainsReagent(args.Reagent.ID))
|
||||
return false;
|
||||
|
||||
if (effect.Probability < 1.0f && !random.Prob(effect.Probability))
|
||||
return false;
|
||||
|
||||
if (effect.Conditions != null)
|
||||
{
|
||||
foreach (var cond in effect.Conditions)
|
||||
{
|
||||
if (!cond.Condition(args))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ReactionMethod
|
||||
{
|
||||
Touch,
|
||||
|
||||
Reference in New Issue
Block a user