Ejemplo n.º 1
0
 public Proc QueueJump(IEnumerator queueJumper)
 {
     if (isActive)
     {
         Debug.LogError("UniKH/CSP/Proc: delay proc failed, this proc is currently running.");
     }
     ProcStack.StackPush(queueJumper);
     return(this);
 }
Ejemplo n.º 2
0
        public bool EnqueueOperation(object yieldVal)
        {
            if (yieldVal is null)
            {
                // skip this frame
                return(EnqueueOperation(Skip.New.Start()));
            }

            if (yieldVal is WaitingOperation)
            {
                // WaitingOperation < CustomYieldInstruction < IEnumerator, the default
                SetOpCurr(yieldVal as WaitingOperation);
                return(false);
            }

            if (yieldVal is CustomYieldInstruction)
            {
                SetOpCurr(UnityCustomYieldInstruction.New.Start(yieldVal as CustomYieldInstruction));
                return(false);
            }

            if (yieldVal is IEnumerator)
            {
                ProcStack.StackPush(yieldVal as IEnumerator);
                return(false);
            }

            if (yieldVal is Result)
            {
                Channel.QueuePush((yieldVal as Result).Val);
                return(true);
            }

            if (yieldVal is int)
            {
                float value = ((int)yieldVal);
                return(EnqueueOperation(UnitySecond.New.Start(value)));
            }

            if (yieldVal is uint)
            {
                float value = ((uint)yieldVal);
                return(EnqueueOperation(UnitySecond.New.Start(value)));
            }

            if (yieldVal is float)
            {
                return(EnqueueOperation(UnitySecond.New.Start((float)yieldVal)));
            }

            if (yieldVal is double)
            {
                return(EnqueueOperation(UnitySecond.New.Start((float)(double)yieldVal)));
            }

            if (yieldVal is decimal)
            {
                return(EnqueueOperation(RealSecond.New.Start((float)(decimal)yieldVal)));
            }

            if (yieldVal is AsyncOperation)
            {
                return(EnqueueOperation(UnityAsync.New.Start(yieldVal as AsyncOperation)));
            }

            if (yieldVal is WaitForSeconds)
            {
                var ts    = (yieldVal as WaitForSeconds).GetType();
                var field = ts.GetField("m_Seconds",
                                        System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                var sec = field.GetValue(yieldVal);
                return(EnqueueOperation(UnitySecond.New.Start((float)sec)));
            }

            if (yieldVal is WaitForEndOfFrame)
            {
                // WaitForEndOfFrame: skip this frame, but try execute in the next tickFrame
                return
                    (EnqueueOperation(Skip.New
                                      .Start())); // todo: This implementation is incomplete, and it needs to be reconsidered in the future.
            }

            if (yieldVal is string)
            {
                // wait a frame and show this string
                Debug.Log(yieldVal);
                return(EnqueueOperation(Skip.New.Start()));
            }

            Debug.LogError(SGen.New["yield return value of type "][yieldVal.GetType()]["are not supported."].End);
            End();
            return(false);
        }