示例#1
0
 // Token: 0x0600F741 RID: 63297 RVA: 0x00552958 File Offset: 0x00550B58
 public void EBIJMBJCPIG()
 {
     if (this.ICOMJMLACPH.Count > 0)
     {
         try
         {
             MoonSharp.Interpreter.Coroutine coroutine = this.ICOMJMLACPH.Peek();
             DynValue dynValue = coroutine.Resume();
             if (coroutine.State == CoroutineState.Suspended)
             {
                 this.ICOMJMLACPH.Pop();
                 this.OEGKPMHIJGF = true;
             }
             if (dynValue.Type == DataType.Number)
             {
                 this.ICOMJMLACPH.Push(this.LOKOJMIKEEL.CreateCoroutine(dynValue).Coroutine);
             }
         }
         catch (ScriptRuntimeException ex)
         {
             Debug.LogError(ex.DecoratedMessage);
             this.OEGKPMHIJGF = false;
             this.ICOMJMLACPH.Clear();
         }
     }
     else
     {
         this.OEGKPMHIJGF = true;
     }
 }
示例#2
0
 private IEnumerator ScriptRoutine(DynValue function)
 {
     Assert.IsNull(activeScript);
     activeScript = GlobalContext.CreateCoroutine(function).Coroutine;
     activeScript.Resume();
     while (activeScript.State != CoroutineState.Dead)
     {
         yield return(null);
     }
 }
示例#3
0
        public IEnumerator Co(MoonSharp.Interpreter.Coroutine co)
        {
            while (co.State != CoroutineState.Dead)
            {
                var val = co.Resume();

                /*if (!val.IsNil())
                 *  Debug.Log(val.ToObject());*/
                yield return(val.ToObject());
            }
        }
示例#4
0
 // call a coroutine from lua code
 // any coroutines invoked by proxy objects need to run here
 public void RunRoutineFromLua(IEnumerator routine)
 {
     Assert.IsNotNull(activeScript);
     blockingRoutines += 1;
     StartCoroutine(CoUtils.RunWithCallback(routine, Global.Instance().Lua, () => {
         blockingRoutines -= 1;
         if (blockingRoutines == 0 && activeScript != null)
         {
             activeScript.Resume();
         }
     }));
 }
示例#5
0
        /// <summary>
        /// スクリプトを待機状態から復旧.
        /// </summary>
        public void Resume()
        {
            if (luaCoroutine == null)
            {
                return;
            }

            if (luaCoroutine.State == CoroutineState.Suspended)
            {
                luaCoroutine.Resume();
            }
        }
示例#6
0
        private IEnumerator ExecuteScriptInternal(string script)
        {
            var luaFunc = DynValue.Nil;

            try
            {
                luaFunc = LuaScript.DoString(script);
            }
            catch (InterpreterException ex)
            {
                Debug.LogErrorFormat("Lua Execute error:\n{0}", ex.DecoratedMessage);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            if (luaFunc.IsNil())
            {
                yield break;
            }

            luaCoroutine = null;

            var dynValue = LuaScript.CreateCoroutine(luaFunc);

            if (dynValue.IsNil())
            {
                yield break;
            }

            luaCoroutine = dynValue.Coroutine;

            luaCoroutine.AutoYieldCounter = 1000;

            luaCoroutine.Resume();

            while (true)
            {
                if (luaCoroutine == null)
                {
                    break;
                }

                if (luaCoroutine.State == CoroutineState.Dead)
                {
                    break;
                }

                yield return(null);
            }
        }
    public void AdvanceScript()
    {
        // Check if the Coroutine stack is empty
        if (coroutineStack.Count > 0)
        {
            try
            {
                MoonSharp.Interpreter.Coroutine activeCoroutine = coroutineStack.Peek();

                // Save the active coroutine's return value
                DynValue returnValue = activeCoroutine.Resume();

                // If the active coroutine is dead, pop it off the stack
                if (activeCoroutine.State == CoroutineState.Dead)
                {
                    coroutineStack.Pop();
                    Debug.Log("Dialogue complete");
                }

                // If the return value is a function, add it to the top of the coroutine stack
                if (returnValue.Type == DataType.Function)
                {
                    coroutineStack.Push(environment.CreateCoroutine(returnValue).Coroutine);
                }
            }
            catch (ScriptRuntimeException e)
            {
                Debug.LogError(e.DecoratedMessage);
                coroutineStack.Clear();
            }
        }
        else
        {
            Debug.Log("No active dialogue");
        }
    }
 /// <summary>
 /// Resumes the coroutine.
 ///
 /// This method is supported only on .NET 4.x and .NET 4.x PCL targets.
 /// </summary>
 /// <param name="cor">The coroutine</param>
 /// <param name="context">The ScriptExecutionContext.</param>
 /// <returns></returns>
 public static Task <DynValue> ResumeAsync(this Coroutine cor, ScriptExecutionContext context)
 {
     return(ExecAsync(() => cor.Resume(context)));
 }
 /// <summary>
 /// Resumes the coroutine.
 /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead.
 ///
 /// This method is supported only on .NET 4.x and .NET 4.x PCL targets.
 /// </summary>
 /// <param name="cor">The coroutine</param>
 /// <returns></returns>
 /// <exception cref="System.InvalidOperationException">Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead</exception>
 public static Task <DynValue> ResumeAsync(this Coroutine cor)
 {
     return(ExecAsync(() => cor.Resume()));
 }
 /// <summary>
 /// Resumes the coroutine.
 /// Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead.
 ///
 /// This method is supported only on .NET 4.x and .NET 4.x PCL targets.
 /// </summary>
 /// <param name="cor">The coroutine</param>
 /// <param name="args">The arguments.</param>
 /// <returns></returns>
 /// <exception cref="System.InvalidOperationException">Only non-CLR coroutines can be resumed with this overload of the Resume method. Use the overload accepting a ScriptExecutionContext instead</exception>
 public static Task <DynValue> ResumeAsync(this Coroutine cor, params DynValue[] args)
 {
     return(ExecAsync(() => cor.Resume(args)));
 }