[TaskDescription("The random probability task will return success when the random probability is below the succeed probability. It will otherwise return failure.")]
publicclassRandomProbability:Conditional
{
[Tooltip("The chance that the task will return success")]
publicSharedFloatsuccessProbability=0.5f;
[Tooltip("Seed the random number generator to make things easier to debug")]
publicSharedIntseed;
[Tooltip("Do we want to use the seed?")]
publicSharedBooluseSeed;
publicoverridevoidOnAwake()
{
// If specified, use the seed provided.
if(useSeed.Value){
Random.InitState(seed.Value);
}
}
publicoverrideTaskStatusOnUpdate()
{
// Return success if random value is less than the success probability. Otherwise return failure.
floatrandomValue=Random.value;
if(randomValue<successProbability.Value){
returnTaskStatus.Success;
}
returnTaskStatus.Failure;
}
publicoverridevoidOnReset()
{
// Reset the public properties back to their original values