File size: 873 Bytes
18a519f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections;
using UnityEngine;

namespace Unity.VisualScripting
{
    /// <summary>
    /// Delays flow by waiting until a condition becomes true.
    /// </summary>
    [UnitTitle("Wait Until")]
    [UnitShortTitle("Wait Until")]
    [UnitOrder(2)]
    public class WaitUntilUnit : WaitUnit
    {
        /// <summary>
        /// The condition to await.
        /// </summary>
        [DoNotSerialize]
        public ValueInput condition { get; private set; }

        protected override void Definition()
        {
            base.Definition();

            condition = ValueInput<bool>(nameof(condition));
            Requirement(condition, enter);
        }

        protected override IEnumerator Await(Flow flow)
        {
            yield return new WaitUntil(() => flow.GetValue<bool>(condition));

            yield return exit;
        }
    }
}