public void Update(Flow flow)
        {
            var data = flow.stack.GetElementData <Data>(this);

            if (data.isReady)
            {
                return;
            }

            data.remaining -= data.unscaled ? Time.unscaledDeltaTime : Time.deltaTime;

            data.remaining = Mathf.Max(0f, data.remaining);

            AssignMetrics(flow, data);

            var stack = flow.PreserveStack();

            flow.Invoke(tick);

            if (data.isReady)
            {
                flow.RestoreStack(stack);

                flow.Invoke(becameReady);
            }

            flow.DisposePreservedStack(stack);
        }
Exemple #2
0
        public void Update(Flow flow)
        {
            var data = flow.stack.GetElementData <Data>(this);

            if (!data.active || data.paused)
            {
                return;
            }

            data.elapsed += data.unscaled ? Time.unscaledDeltaTime : Time.deltaTime;

            data.elapsed = Mathf.Min(data.elapsed, data.duration);

            AssignMetrics(flow, data);

            var stack = flow.PreserveStack();

            flow.Invoke(tick);

            if (data.elapsed >= data.duration)
            {
                data.active = false;

                flow.RestoreStack(stack);

                flow.Invoke(completed);
            }

            flow.DisposePreservedStack(stack);
        }
Exemple #3
0
        protected override IEnumerator LoopCoroutine(Flow flow)
        {
            var loop = Start(flow, out var enumerator, out var dictionaryEnumerator, out var currentIndex);

            var stack = flow.PreserveStack();

            try
            {
                while (flow.LoopIsNotBroken(loop) && MoveNext(flow, enumerator, dictionaryEnumerator, ref currentIndex))
                {
                    yield return(body);

                    flow.RestoreStack(stack);
                }
            }
            finally
            {
                (enumerator as IDisposable)?.Dispose();
            }

            flow.DisposePreservedStack(stack);

            flow.ExitLoop(loop);

            yield return(exit);
        }
Exemple #4
0
        protected override IEnumerator LoopCoroutine(Flow flow)
        {
            var loop = Start(flow);

            var stack = flow.PreserveStack();

            while (flow.LoopIsNotBroken(loop) && CanMoveNext(flow))
            {
                yield return(body);

                flow.RestoreStack(stack);
            }

            flow.DisposePreservedStack(stack);

            flow.ExitLoop(loop);

            yield return(exit);
        }
Exemple #5
0
        protected override ControlOutput Loop(Flow flow)
        {
            var loop = Start(flow);

            var stack = flow.PreserveStack();

            while (flow.LoopIsNotBroken(loop) && CanMoveNext(flow))
            {
                flow.Invoke(body);

                flow.RestoreStack(stack);
            }

            flow.DisposePreservedStack(stack);

            flow.ExitLoop(loop);

            return(exit);
        }
Exemple #6
0
        protected override ControlOutput Loop(Flow flow)
        {
            var loop = Start(flow, out int currentIndex, out int lastIndex, out bool ascending);

            var stack = flow.PreserveStack();

            while (flow.LoopIsNotBroken(loop) && CanMoveNext(currentIndex, lastIndex, ascending))
            {
                flow.Invoke(body);

                flow.RestoreStack(stack);

                MoveNext(flow, ref currentIndex);
            }

            flow.DisposePreservedStack(stack);

            flow.ExitLoop(loop);

            return(exit);
        }
Exemple #7
0
        protected override IEnumerator LoopCoroutine(Flow flow)
        {
            var loop = Start(flow, out int currentIndex, out int lastIndex, out bool ascending);

            var stack = flow.PreserveStack();

            while (flow.LoopIsNotBroken(loop) && CanMoveNext(currentIndex, lastIndex, ascending))
            {
                yield return(body);

                flow.RestoreStack(stack);

                MoveNext(flow, ref currentIndex);
            }

            flow.DisposePreservedStack(stack);

            flow.ExitLoop(loop);

            yield return(exit);
        }