public static void MassPlaceTrees(TerrainData terrainData, int numberOfTrees, bool randomTreeColor, bool keepExistingTrees)
        {
            int num = terrainData.treePrototypes.Length;

            if (num == 0)
            {
                Debug.Log("Can't place trees because no prototypes are defined");
                return;
            }
            Undo.RegisterCompleteObjectUndo(terrainData, "Mass Place Trees");
            TreeInstance[] array = new TreeInstance[numberOfTrees];
            int            i     = 0;

            while (i < array.Length)
            {
                TreeInstance treeInstance = default(TreeInstance);
                treeInstance.position = new Vector3(UnityEngine.Random.value, 0f, UnityEngine.Random.value);
                if (terrainData.GetSteepness(treeInstance.position.x, treeInstance.position.z) < 30f)
                {
                    treeInstance.color          = ((!randomTreeColor) ? Color.white : TreePainter.GetTreeColor());
                    treeInstance.lightmapColor  = Color.white;
                    treeInstance.prototypeIndex = UnityEngine.Random.Range(0, num);
                    treeInstance.heightScale    = TreePainter.GetTreeHeight();
                    treeInstance.widthScale     = ((!TreePainter.lockWidthToHeight) ? TreePainter.GetTreeWidth() : treeInstance.heightScale);
                    treeInstance.rotation       = TreePainter.GetTreeRotation();
                    array[i++] = treeInstance;
                }
            }
            if (keepExistingTrees)
            {
                TreeInstance[] treeInstances = terrainData.treeInstances;
                TreeInstance[] array2        = new TreeInstance[treeInstances.Length + array.Length];
                Array.Copy(treeInstances, 0, array2, 0, treeInstances.Length);
                Array.Copy(array, 0, array2, treeInstances.Length, array.Length);
                array = array2;
            }
            terrainData.treeInstances = array;
            terrainData.RecalculateTreePositions();
        }