Ejemplo n.º 1
0
 public void Setup()
 {
     _dispatcher         = new CoroutineDispatcher();
     _okayCoroutine      = new Coroutine(OkayEnumerator());
     _waitCoroutine      = new Coroutine(WaitForCoroutine());
     _exceptionCoroutine = new Coroutine(Exceptions());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Calls a specific EventHandler in a background thread
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="args"></param>
        /// <param name="sender"></param>
        public static void InvokeInBackground <T>(EventHandler <T> handler, T args, object sender) where T : EventArgs
        {
            if (handler == null)
            {
                return;
            }


            var list = handler.GetInvocationList();

            foreach (var call in list)
            {
                var eventHandler = ((EventHandler <T>)call);
                if (eventHandler != null)
                {
#if UNITY
                    if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.WebGLPlayer)
                    {
                        CoroutineDispatcher.Dispatch(() => eventHandler(sender, args));
                    }
                    else
                    {
                        Dispatcher.Dispatch(() => eventHandler(sender, args));
                    }
#else
                    Dispatcher.Dispatch(() => eventHandler(sender, args));
#endif
                }
            }
        }
Ejemplo n.º 3
0
    public static CoroutineDispatcher Get()
    {
        CoroutineDispatcher other = FindObjectOfType <CoroutineDispatcher>();

        if (other)
        {
            return(other);
        }

        GameObject gameObject = new GameObject();

        DontDestroyOnLoad(gameObject);

        return(gameObject.AddComponent <CoroutineDispatcher>());
    }
        /// <summary> Constructor. </summary>
        /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
        /// <param name="dispatcher"> The MonoBehavior that created this processor. </param>
        public ChunkProcessor(CoroutineDispatcher dispatcher, World world)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            _dispatcher     = dispatcher;
            _world          = world;
            _chunksToLoad   = new LinkedList <Chunk>();
            _chunksToUnload = new LinkedList <Chunk>();
            _loadedChunks   = new LinkedList <Chunk>();

            _isChunkProcessorActive = false;

            _wall     = Prefabs.GetPrefab("Wall");
            _allWalls = GameObject.Find("All.Walls");
        }
Ejemplo n.º 5
0
    public AsyncOperationAwaiter(AsyncOperation asyncOperation)
    {
        this.asyncOperation = asyncOperation;

        CoroutineDispatcher.Get().DispatchCoroutine(WrappedCoroutine());
    }