File size: 1,133 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
37
38
39
40
41
using System.Collections;

namespace Unity.VisualScripting
{
    public abstract class LoopUnit : Unit
    {
        /// <summary>
        /// The entry point for the loop.
        /// </summary>
        [DoNotSerialize]
        [PortLabelHidden]
        public ControlInput enter { get; private set; }

        /// <summary>
        /// The action to execute after the loop has been completed or broken.
        /// </summary>
        [DoNotSerialize]
        public ControlOutput exit { get; private set; }

        /// <summary>
        /// The action to execute at each loop.
        /// </summary>
        [DoNotSerialize]
        public ControlOutput body { get; private set; }

        protected override void Definition()
        {
            enter = ControlInputCoroutine(nameof(enter), Loop, LoopCoroutine);
            exit = ControlOutput(nameof(exit));
            body = ControlOutput(nameof(body));

            Succession(enter, body);
            Succession(enter, exit);
        }

        protected abstract ControlOutput Loop(Flow flow);

        protected abstract IEnumerator LoopCoroutine(Flow flow);
    }
}