summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Math/RandomBool.cs
blob: 2cb731d3e5fdd15c95d6fec7631918f77981ef29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using UnityEngine;

namespace BehaviorDesigner.Runtime.Tasks.Basic.Math
{
    [TaskCategory("Basic/Math")]
    [TaskDescription("Sets a random bool value")]
    public class RandomBool : Action
    {
        [Tooltip("The variable to store the result")]
        public SharedBool storeResult;

        public override TaskStatus OnUpdate()
        {
            storeResult.Value = Random.value < 0.5f;
            return TaskStatus.Success;
        }

        public override void OnReset()
        {
            storeResult.Value = false;
        }
    }
}