Esempio n. 1
0
        private void RunLua(HookedScriptContainer script, string hookName, params object[] args)
        {
            var hook = script.GetHook(hookName);

            if (hook != null)
            {
                if (hook.IsCoroutine)
                {
                    if (hook.Coroutine.Coroutine.State == CoroutineState.Dead || !hook.CheckYieldStatus()) //Doesn't run check yield if coroutine is dead
                    {
                        return;
                    }

                    DynValue ret = hook.Coroutine.Coroutine.Resume(args);

                    switch (hook.Coroutine.Coroutine.State)
                    {
                    case CoroutineState.Suspended:
                        if (ret.IsNotNil())
                        {
                            Yielder yielder = ret.ToObject <Yielder>();
                            hook.CurYielder = yielder;
                        }
                        else
                        {
                            hook.CurYielder = null;
                        }
                        break;

                    case CoroutineState.Dead:
                        hook.CurYielder = null;
                        if (hook.AutoResetCoroutine)
                        {
                            hook.Coroutine.Assign(Lua.CreateCoroutine(hook.LuaFunc));
                        }
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    Lua.Call(hook.LuaFunc, args);
                }
            }
        }
Esempio n. 2
0
 public void SetYielder(Yielder yielder)
 {
     CurYielder = yielder;
 }