Beispiel #1
0
 private static void UpdateCurrentSynchronousEvent(out bool sceneChanged)
 {
     sceneChanged = false;
     if (!currentEvent.ShouldWaitUntilDisplayed)
     {
         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;
         }
     }
 }
Beispiel #2
0
 public static void LongEventsUpdate(out bool sceneChanged)
 {
     sceneChanged = false;
     if (currentEvent != null)
     {
         if (currentEvent.eventActionEnumerator != null)
         {
             UpdateCurrentEnumeratorEvent();
         }
         else if (currentEvent.doAsynchronously)
         {
             UpdateCurrentAsynchronousEvent();
         }
         else
         {
             UpdateCurrentSynchronousEvent(out sceneChanged);
         }
     }
     if (currentEvent == null && eventQueue.Count > 0)
     {
         currentEvent = eventQueue.Dequeue();
         if (currentEvent.eventTextKey == null)
         {
             currentEvent.eventText = string.Empty;
         }
         else
         {
             currentEvent.eventText = currentEvent.eventTextKey.Translate();
         }
     }
 }
Beispiel #3
0
 private static void UpdateCurrentEnumeratorEvent()
 {
     try
     {
         float num = Time.realtimeSinceStartup + 0.1f;
         while (currentEvent.eventActionEnumerator.MoveNext())
         {
             if (num <= Time.realtimeSinceStartup)
             {
                 return;
             }
         }
         (currentEvent.eventActionEnumerator as IDisposable)?.Dispose();
         currentEvent = null;
         eventThread  = null;
         levelLoadOp  = null;
         ExecuteToExecuteWhenFinished();
     }
     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;
     }
 }
Beispiel #4
0
        public static void QueueLongEvent(Action action, string textKey, bool doAsynchronously, Action <Exception> exceptionHandler)
        {
            QueuedLongEvent queuedLongEvent = new QueuedLongEvent();

            queuedLongEvent.eventAction              = action;
            queuedLongEvent.eventTextKey             = textKey;
            queuedLongEvent.doAsynchronously         = doAsynchronously;
            queuedLongEvent.exceptionHandler         = exceptionHandler;
            queuedLongEvent.canEverUseStandardWindow = !AnyEventWhichDoesntUseStandardWindowNowOrWaiting;
            eventQueue.Enqueue(queuedLongEvent);
        }
Beispiel #5
0
        public static void QueueLongEvent(IEnumerable action, string textKey, Action <Exception> exceptionHandler = null)
        {
            QueuedLongEvent queuedLongEvent = new QueuedLongEvent();

            queuedLongEvent.eventActionEnumerator    = action.GetEnumerator();
            queuedLongEvent.eventTextKey             = textKey;
            queuedLongEvent.doAsynchronously         = false;
            queuedLongEvent.exceptionHandler         = exceptionHandler;
            queuedLongEvent.canEverUseStandardWindow = !AnyEventWhichDoesntUseStandardWindowNowOrWaiting;
            eventQueue.Enqueue(queuedLongEvent);
        }
        public static void QueueLongEvent(Action preLoadLevelAction, string levelToLoad, string textKey, bool doAsynchronously, Action <Exception> exceptionHandler, bool showExtraUIInfo = true)
        {
            QueuedLongEvent queuedLongEvent = new QueuedLongEvent();

            queuedLongEvent.eventAction              = preLoadLevelAction;
            queuedLongEvent.levelToLoad              = levelToLoad;
            queuedLongEvent.eventTextKey             = textKey;
            queuedLongEvent.doAsynchronously         = doAsynchronously;
            queuedLongEvent.exceptionHandler         = exceptionHandler;
            queuedLongEvent.canEverUseStandardWindow = !AnyEventWhichDoesntUseStandardWindowNowOrWaiting;
            queuedLongEvent.showExtraUIInfo          = showExtraUIInfo;
            eventQueue.Enqueue(queuedLongEvent);
        }
 private static void UpdateCurrentEnumeratorEvent()
 {
     try
     {
         float num = (float)(Time.realtimeSinceStartup + 0.10000000149011612);
         while (LongEventHandler.currentEvent.eventActionEnumerator.MoveNext())
         {
             if (num <= Time.realtimeSinceStartup)
             {
                 return;
             }
         }
         IDisposable disposable = LongEventHandler.currentEvent.eventActionEnumerator as IDisposable;
         if (disposable != null)
         {
             disposable.Dispose();
         }
         LongEventHandler.currentEvent = null;
         LongEventHandler.eventThread  = null;
         LongEventHandler.levelLoadOp  = null;
         LongEventHandler.ExecuteToExecuteWhenFinished();
     }
     catch (Exception ex)
     {
         Log.Error("Exception from long event: " + ex);
         if (LongEventHandler.currentEvent != null)
         {
             IDisposable disposable2 = LongEventHandler.currentEvent.eventActionEnumerator as IDisposable;
             if (disposable2 != null)
             {
                 disposable2.Dispose();
             }
             if (LongEventHandler.currentEvent.exceptionHandler != null)
             {
                 LongEventHandler.currentEvent.exceptionHandler(ex);
             }
         }
         LongEventHandler.currentEvent = null;
         LongEventHandler.eventThread  = null;
         LongEventHandler.levelLoadOp  = null;
     }
 }
 private static void UpdateCurrentAsynchronousEvent()
 {
     if (eventThread == null)
     {
         eventThread = new Thread((ThreadStart) delegate
         {
             RunEventFromAnotherThread(currentEvent.eventAction);
         });
         eventThread.Start();
     }
     else
     {
         if (eventThread.IsAlive)
         {
             return;
         }
         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();
         }
     }
 }
 private static void UpdateCurrentAsynchronousEvent()
 {
     if (LongEventHandler.eventThread == null)
     {
         LongEventHandler.eventThread = new Thread((ThreadStart) delegate
         {
             LongEventHandler.RunEventFromAnotherThread(LongEventHandler.currentEvent.eventAction);
         });
         LongEventHandler.eventThread.Start();
     }
     else if (!LongEventHandler.eventThread.IsAlive)
     {
         bool flag = false;
         if (!LongEventHandler.currentEvent.levelToLoad.NullOrEmpty())
         {
             if (LongEventHandler.levelLoadOp == null)
             {
                 LongEventHandler.levelLoadOp = SceneManager.LoadSceneAsync(LongEventHandler.currentEvent.levelToLoad);
             }
             else if (LongEventHandler.levelLoadOp.isDone)
             {
                 flag = true;
             }
         }
         else
         {
             flag = true;
         }
         if (flag)
         {
             LongEventHandler.currentEvent = null;
             LongEventHandler.eventThread  = null;
             LongEventHandler.levelLoadOp  = null;
             LongEventHandler.ExecuteToExecuteWhenFinished();
         }
     }
 }