Esempio n. 1
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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public ControlOutput Enter(Flow flow)
        {
            if (flow.isCoroutine)
            {
                throw new NotSupportedException("Coroutines cannot catch exceptions.");
            }

            try
            {
                flow.Invoke(@try);
            }
            catch (Exception ex)
            {
                if (exceptionType.IsInstanceOfType(ex))
                {
                    flow.SetValue(exception, ex);
                    flow.Invoke(@catch);
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                flow.Invoke(@finally);
            }

            return(null);
        }
 public void Enter(Flow flow)
 {
     if (condition.GetValue <bool>())
     {
         flow.Invoke(ifTrue);
     }
     else
     {
         flow.Invoke(ifFalse);
     }
     flow.Invoke(onNext);
 }
Esempio n. 5
0
        protected override ControlOutput Loop(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))
                {
                    flow.Invoke(body);

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

            flow.DisposePreservedStack(stack);

            flow.ExitLoop(loop);

            return(exit);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
 private void Trigger(Flow flow)
 {
     CustomMachineEvent.Trigger(target.GetValue <FlowMachine>(), name.GetValue <string>(), arguments.Select(arg => arg.GetConvertedValue()).ToArray());
     flow.Invoke(exit);
 }