public static void CopyEventQueue()
        {
            while (eventQueue1.Count > 0)
            {
                object    obj                           = eventQueue1.Dequeue();
                FieldInfo action                        = obj.GetType().GetField("eventAction", BindingFlags.Public | BindingFlags.Instance);
                FieldInfo textKeyField                  = obj.GetType().GetField("eventTextKey", BindingFlags.Public | BindingFlags.Instance);
                FieldInfo doAsynchronouslyField         = obj.GetType().GetField("doAsynchronously", BindingFlags.Public | BindingFlags.Instance);
                FieldInfo exceptionHandlerField         = obj.GetType().GetField("exceptionHandler", BindingFlags.Public | BindingFlags.Instance);
                FieldInfo canEverUseStandardWindowField = obj.GetType().GetField("canEverUseStandardWindow", BindingFlags.Public | BindingFlags.Instance);
                FieldInfo showExtraUIInfoField          = obj.GetType().GetField("showExtraUIInfo", BindingFlags.Public | BindingFlags.Instance);

                QueuedLongEvent2 queuedLongEvent = new QueuedLongEvent2
                {
                    eventAction              = (Action)(action.GetValue(obj)),
                    eventTextKey             = (string)textKeyField.GetValue(obj),
                    doAsynchronously         = (bool)doAsynchronouslyField.GetValue(obj),
                    exceptionHandler         = (Action <Exception>)exceptionHandlerField.GetValue(obj),
                    canEverUseStandardWindow = (bool)canEverUseStandardWindowField.GetValue(obj),
                    showExtraUIInfo          = (bool)showExtraUIInfoField.GetValue(obj)
                };
                eventQueue.Enqueue(queuedLongEvent);
            }
            initCopyComplete = true;
        }
        public static bool QueueLongEvent(IEnumerable action, string textKey, Action <Exception> exceptionHandler = null, bool showExtraUIInfo = true)
        {
            QueuedLongEvent2 queuedLongEvent = new QueuedLongEvent2
            {
                eventActionEnumerator    = action.GetEnumerator(),
                eventTextKey             = textKey,
                doAsynchronously         = false,
                exceptionHandler         = exceptionHandler,
                canEverUseStandardWindow = !LongEventHandler.AnyEventWhichDoesntUseStandardWindowNowOrWaiting,
                showExtraUIInfo          = showExtraUIInfo
            };

            eventQueue.Enqueue(queuedLongEvent);
            return(false);
        }
        public static bool QueueLongEvent(Action preLoadLevelAction, string levelToLoad, string textKey, bool doAsynchronously, Action <Exception> exceptionHandler, bool showExtraUIInfo = true)
        {
            QueuedLongEvent2 queuedLongEvent = new QueuedLongEvent2
            {
                eventAction              = preLoadLevelAction,
                levelToLoad              = levelToLoad,
                eventTextKey             = textKey,
                doAsynchronously         = doAsynchronously,
                exceptionHandler         = exceptionHandler,
                canEverUseStandardWindow = !LongEventHandler.AnyEventWhichDoesntUseStandardWindowNowOrWaiting,
                showExtraUIInfo          = showExtraUIInfo
            };

            eventQueue.Enqueue(queuedLongEvent);
            return(false);
        }
        public static bool get_AnyEventWhichDoesntUseStandardWindowNowOrWaiting(ref bool __result)
        {
            if (!initCopyComplete)
            {
                return(true);
            }
            QueuedLongEvent2 queuedLongEvent = currentEvent;

            if (queuedLongEvent != null && !queuedLongEvent.UseStandardWindow)
            {
                __result = true;
                return(false);
            }
            __result = eventQueue.Any((QueuedLongEvent2 x) => !x.UseStandardWindow);
            return(false);
        }
        public static bool UpdateCurrentAsynchronousEvent()
        {
            if (eventThread == null)
            {
                eventThread = new Thread((ThreadStart) delegate
                {
                    actionRunEventFromAnotherThread(currentEvent.eventAction);
                });
                eventThread.Start();
            }
            else
            {
                if (eventThread.IsAlive)
                {
                    return(false);
                }

                bool flag = false;
                if (!currentEvent.levelToLoad.NullOrEmpty())
                {
                    if (levelLoadOp == null)
                    {
                        levelLoadOp = SceneManager.LoadSceneAsync(currentEvent.levelToLoad);
                    }
                    else if (levelLoadOp.isDone)
                    {
                        flag = true;
                    }
                }
                else
                {
                    flag = true;
                }

                if (flag)
                {
                    currentEvent = null;
                    eventThread  = null;
                    levelLoadOp  = null;
                    ExecuteToExecuteWhenFinished();
                }
            }
            return(false);
        }
        public static bool UpdateCurrentSynchronousEvent(out bool sceneChanged)
        {
            sceneChanged = false;
            if (currentEvent.ShouldWaitUntilDisplayed)
            {
                return(false);
            }

            try
            {
                if (currentEvent.eventAction != null)
                {
                    currentEvent.eventAction();
                }

                if (!currentEvent.levelToLoad.NullOrEmpty())
                {
                    SceneManager.LoadScene(currentEvent.levelToLoad);
                    sceneChanged = true;
                }

                currentEvent = null;
                eventThread  = null;
                levelLoadOp  = null;
                ExecuteToExecuteWhenFinished();
            }
            catch (Exception ex)
            {
                Log.Error("Exception from long event: " + ex);
                if (currentEvent != null && currentEvent.exceptionHandler != null)
                {
                    currentEvent.exceptionHandler(ex);
                }

                currentEvent = null;
                eventThread  = null;
                levelLoadOp  = null;
            }
            return(false);
        }
        public static bool LongEventsUpdate(ref bool sceneChanged)
        {
            if (!initCopyComplete)
            {
                return(true);
            }

            sceneChanged = false;
            if (currentEvent != null)
            {
                if (currentEvent.eventActionEnumerator != null)
                {
                    actionUpdateCurrentEnumeratorEvent();
                }
                else if (currentEvent.doAsynchronously)
                {
                    actionUpdateCurrentAsynchronousEvent();
                }
                else
                {
                    UpdateCurrentSynchronousEvent(out sceneChanged);
                }
            }

            if (currentEvent == null && eventQueue.Count > 0)
            {
                currentEvent = eventQueue.Dequeue();
                if (currentEvent.eventTextKey == null)
                {
                    currentEvent.eventText = "";
                }
                else
                {
                    currentEvent.eventText = currentEvent.eventTextKey.Translate();
                }
            }
            return(false);
        }
        public static bool UpdateCurrentEnumeratorEvent()
        {
            try
            {
                float num = Time.realtimeSinceStartup + 0.1f;
                do
                {
                    if (!currentEvent.eventActionEnumerator.MoveNext())
                    {
                        (currentEvent.eventActionEnumerator as IDisposable)?.Dispose();
                        currentEvent = null;
                        eventThread  = null;
                        levelLoadOp  = null;
                        ExecuteToExecuteWhenFinished();
                        break;
                    }
                }while (!(num <= Time.realtimeSinceStartup));
            }
            catch (Exception ex)
            {
                Log.Error("Exception from long event: " + ex);
                if (currentEvent != null)
                {
                    (currentEvent.eventActionEnumerator as IDisposable)?.Dispose();
                    if (currentEvent.exceptionHandler != null)
                    {
                        currentEvent.exceptionHandler(ex);
                    }
                }

                currentEvent = null;
                eventThread  = null;
                levelLoadOp  = null;
            }
            return(false);
        }