/// <summary>
        /// Works the same as <see cref="GenerateCoroutine"/> without the
        /// yield instructions. Runs synchronously.
        /// </summary>
        /// <param name="remapMin"></param>
        /// <param name="remapMax"></param>
        private void GenerateEditor(float remapMin = 0f, float remapMax = 1f)
        {
            TerraConfig.Log($"Started tile {GridPosition.ToString()}");

            //Make & set heightmap
            MeshManager.CalculateHeightmap(GridPosition, remapMin, remapMax);

            MeshManager.SetTerrainHeightmap();
            MeshManager.SetVisible();

            //Create TilePaint object
            TilePaint painter = new TilePaint(this);

            //Make biomemap
            int[,] map = painter.GetBiomeMap();

            //Paint terrain
            painter.Paint(map);

            //Apply details to terrain
            // ReSharper disable once IteratorMethodResultIsIgnored
            ApplyDetails(painter, map);
            MeshManager.SetVisible(true);

            TerraConfig.Log("Completed tile " + GridPosition);
        }
 public TileDetail(Tile tile, TilePaint painter, int[,] biomeMap)
 {
     _tile     = tile;
     _biomeMap = biomeMap;
     _painter  = painter;
     _sampler  = new BiomeSampler(_painter.Biomes);
 }
        private IEnumerator GenerateCoroutine(Action onComplete, float remapMin = 0f, float remapMax = 1f)
        {
            TerraConfig conf = TerraConfig.Instance;

            TerraConfig.Log("Started tile " + GridPosition);

            //Make & set heightmap
            bool madeHm = false;

            MeshManager.CalculateHeightmapAsync(remapMin, remapMax, () => madeHm = true);
            while (!madeHm)
            {
                yield return(null);
            }

            MeshManager.SetTerrainHeightmap();
            MeshManager.SetVisible();

            //Create TilePaint object
            TilePaint painter = new TilePaint(this);

            //Make biomemap
            bool madeBm = false;

            int[,] map = null;
            conf.Worker.Enqueue(() => map = painter.GetBiomeMap(), () => madeBm = true);
            while (!madeBm)
            {
                yield return(null); //Skip frame until biomemap made
            }
            //Paint terrain
            bool madePaint = false;

            yield return(StartCoroutine(painter.PaintAsync(map, () => madePaint = true)));

            while (!madePaint)
            {
                yield return(null);
            }

            //Apply details to terrain
            bool madeDetails = false;

            yield return(StartCoroutine(ApplyDetails(painter, map, () => madeDetails = true)));

            while (!madeDetails)
            {
                yield return(null);
            }

            MeshManager.SetVisible(true);

            TerraConfig.Log("Completed tile " + GridPosition);
            onComplete();
        }
        private IEnumerator ApplyDetails(TilePaint painter, int[,] biomeMap, Action onComplete = null)
        {
            //Create detailer
            TileDetail detailer = new TileDetail(this, painter, biomeMap);

            yield return(null);

            yield return(detailer.AddTrees());

            yield return(null);

            yield return(detailer.AddDetailLayers());

            if (onComplete != null)
            {
                onComplete();
            }
        }
示例#5
0
 public TileDetail(Tile tile, TilePaint painter, float[,,] biomeMap)
 {
     _tile     = tile;
     _biomeMap = biomeMap;
     _painter  = painter;
 }