Files
ZeroVR/ZeroPacientVR/Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/Utility/Probability.cs
T
2022-04-18 19:17:20 +03:00

25 lines
697 B
C#

using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Utility")]
[Description("Return true or false based on the probability settings. Outcome is calculated EACH time this is checked")]
public class Probability : ConditionTask
{
public BBParameter<float> probability = 0.5f;
public BBParameter<float> maxValue = 1;
protected override string info {
get { return ( probability.value / maxValue.value * 100 ) + "%"; }
}
protected override bool OnCheck() {
return Random.Range(0f, maxValue.value) <= probability.value;
}
}
}