Example #1
0
        private bool ProcessCurrentInstruction(CoroutineGroup group)
        {
            if (CurrentInstruction != null)
            {
                if (!ProcessInstruction(CurrentInstruction, group))
                {
                    return(false);
                }
                CurrentInstruction = null;
            }

            while (injectedInstructionQueue != null && injectedInstructionQueue.Count > 0)
            {
                CurrentInstruction = injectedInstructionQueue.Dequeue();
                CurrentInstruction.Begin();
                IsCurrentInstructionInjected = true;
                if (!ProcessInstruction(CurrentInstruction, group))
                {
                    return(false);
                }
            }
            IsCurrentInstructionInjected = false;

            return(true);
        }
Example #2
0
        public void Process(CoroutineGroup group)
        {
            if (IsPaused)
            {
                return;
            }

            if (!ProcessCurrentInstruction(group))
            {
                return;
            }

            if (Enumerator == null)
            {
                FMessage.Log(ELogVerbosity.Error, "Coroutine enumerator is null");
                Stop();
                return;
            }

            try
            {
                while (Enumerator.MoveNext())
                {
                    object           current     = Enumerator.Current;
                    YieldInstruction instruction = current as YieldInstruction;
                    if (instruction != null)
                    {
                        CurrentInstruction       = instruction;
                        CurrentInstruction.Owner = this;
                        CurrentInstruction.Begin();

                        if (!ProcessCurrentInstruction(group))
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch (Exception e)
            {
                FMessage.Log(ELogVerbosity.Error, "Exception when running coroutine. " + Environment.NewLine + e.ToString());
                Stop();
                return;
            }

            Complete = true;
        }