Beispiel #1
0
    // Coroutine that handles the syncronization for all currently running water bodies generation threads.
    private IEnumerator WaitForWaterBodyThreads()
    {
        while (waterBodiesThreads.Count > 0) {

            // Cannot delete threads from container while iterating over it.
            List<int> toRemove = new List<int> ();

            foreach (int i in waterBodiesThreads.Keys) {

                //Wait until the thread is done
                if (waterBodiesThreads [i].IsDone) {

                    List<Vector3> result = waterBodiesThreads[i].output;

                    waterBodies[i] = result;

                    toRemove.Add (i);

                    // Update UI status
                    ULE.setWaterBodyStatus (i, (result.Count == 0) ? UIElement.UIStatus.Error : UIElement.UIStatus.OK);
                }
            }

            foreach (int i in toRemove)
                waterBodiesThreads.Remove (i);

            // If any results where obtain, apply them to the terrain chunks.
            if (toRemove.Count > 0)
                ChunkLoader.Instance.ReloadAllChunks_OnlyUpperLayers ();

            yield return null;
        }

        waterBodiesCoroutine = null;

        // When all currently running threads are finished, launch the postprocess of water bodies.
        if (waterBodiesPostprocessCoroutine != null)
            StopCoroutine (waterBodiesPostprocessCoroutine);
        if (waterBodiesPostprocessThread != null)
            waterBodiesPostprocessThread.Abort ();
        waterBodiesPostprocessThread = new WaterBodiesLayerPostprocess ();
        waterBodiesPostprocessThread.Start ();
        waterBodiesPostprocessCoroutine = StartCoroutine (WaitForWaterBodiesPostprocessThread ());
    }
Beispiel #2
0
    // Coroutine that handles syncronization of the postprocess of water bodies thread.
    private IEnumerator WaitForWaterBodiesPostprocessThread()
    {
        while (!waterBodiesPostprocessThread.IsDone)
            yield return null;
        this.waterBodiesProcessedLayer = waterBodiesPostprocessThread.result;
        waterBodiesPostprocessThread = null;

        // Since this is only called when a change in water bodies is made, roads have to be recalculated.
        RecalculateRoads ();
    }