Пример #1
0
    void Update()
    {
        if (!this.IsChildSpawner)
        {
            if (this.Rule != SpawnRule.DistanceOnly && this.TimeToSwitchToDistanceOnly > 0.0f)
            {
                _timeSinceStart += Time.deltaTime;

                if (_timeSinceStart > this.TimeToSwitchToDistanceOnly)
                    this.Rule = SpawnRule.DistanceOnly;
            }

            if (this.DistanceToSpawnIncrease > 0.0f && this.MinDistanceToSpawn > 0.0f && this.MinDistanceToSpawn < this.MinDistanceToSpawnCap)
            {
                this.MinDistanceToSpawn = Mathf.Min(this.MinDistanceToSpawn + this.DistanceToSpawnIncrease * Time.deltaTime, this.MinDistanceToSpawnCap);
            }

            if (this.SpawnCooldown > 0.0f)
            {
                if (_cooldownTimer <= 0.0f)
                {
                    if (distanceCheck() && !_spawning)
                        BeginSpawn();
                }
                else
                {
                    _cooldownTimer -= Time.deltaTime;
                }
            }
            else if (distanceCheck() && !_spawning)
            {
                BeginSpawn();
            }
        }
    }
        /// <summary>
        /// Called after the spawn is complete
        /// </summary>
        /// <param name="spawnRule">The rule that generated this call</param>
        /// <param name="spawnInfo">The spawninfo structure for this call</param>
        public override void PostSpawn(SpawnRule spawnRule, ref SpawnInfo spawnInfo)
        {
            //See if we can load the texture
            if (m_textureHM == null || !m_textureHM.HasData())
            {
                return;
            }

            //Get the terrain
            Terrain t = Gaia.TerrainHelper.GetTerrain(spawnInfo.m_hitLocationWU);

            if (t == null)
            {
                return;
            }

            //Get the cached detail maps
            List <HeightMap> detailMaps = spawnInfo.m_spawner.GetDetailMaps(spawnInfo.m_hitTerrain.GetInstanceID());

            if (detailMaps == null || m_grassIndex >= detailMaps.Count)
            {
                return;
            }

            //Make some speedy calculations
            float   widthWU = spawnInfo.m_hitTerrain.terrainData.size.x;
            float   depthWU = spawnInfo.m_hitTerrain.terrainData.size.z;
            float   radiusWU = spawnRule.GetMaxScaledRadius(ref spawnInfo) * m_scaleMask;
            float   xStartWU = spawnInfo.m_hitLocationWU.x - (radiusWU / 2f);
            float   zStartWU = spawnInfo.m_hitLocationWU.z - (radiusWU / 2f);
            float   xEndWU = xStartWU + radiusWU;
            float   zEndWU = zStartWU + radiusWU;
            float   stepWU = 0.5f;
            Vector3 locationWU = Vector3.zero;
            float   xRotNU = 0f, zRotNU = 0f;
            float   grassRange = (float)(m_maxGrassStrength - m_minGrassStrenth);

            for (float x = xStartWU; x < xEndWU; x += stepWU)
            {
                for (float z = zStartWU; z < zEndWU; z += stepWU)
                {
                    //Need to rotate x,z around the pivot by the rotation angle
                    locationWU = new Vector3(x, spawnInfo.m_hitLocationWU.y, z);
                    locationWU = Gaia.Utils.RotatePointAroundPivot(locationWU, spawnInfo.m_hitLocationWU, new Vector3(0f, spawnInfo.m_spawnRotationY, 0f));

                    //Now normalise the result
                    xRotNU = (locationWU.x / widthWU) + 0.5f;
                    zRotNU = (locationWU.z / depthWU) + 0.5f;

                    //Drop out if out of bounds
                    if (xRotNU < 0f || xRotNU >= 1f || zRotNU < 0f || zRotNU > 1f)
                    {
                        continue;
                    }

                    detailMaps[m_grassIndex][zRotNU, xRotNU] = Mathf.Clamp((m_textureHM[(x - xStartWU) / radiusWU, (z - zStartWU) / radiusWU] * grassRange) + m_minGrassStrenth, 0f, 15f);
                }
            }
        }
Пример #3
0
        public static int GetTreePrototypeIDFromSpawnRule(SpawnRule sr, Terrain terrain)
        {
            Spawner spawner = CollisionMask.m_allTreeSpawners.FirstOrDefault(x => x.m_settings.m_spawnerRules.Contains(sr));

            if (spawner != null)
            {
                GameObject treePrefabInRule = spawner.m_settings.m_resources.m_treePrototypes[sr.m_resourceIdx].m_desktopPrefab;
                for (int i = 0; i < terrain.terrainData.treePrototypes.Length; i++)
                {
                    TreePrototype tp = terrain.terrainData.treePrototypes[i];
                    if (tp.prefab == treePrefabInRule)
                    {
                        return(i);
                    }
                }
            }
            return(-1);
        }
Пример #4
0
        public void BakeAllTreeCollisions(string spawnRuleGUID, float radius)
        {
            SpawnRule sr = CollisionMask.m_allTreeSpawnRules.FirstOrDefault(x => x.GUID == spawnRuleGUID);

            if (sr == null)
            {
                return;
            }

            foreach (Terrain t in Terrain.activeTerrains)
            {
                int treePrototypeID = TerrainHelper.GetTreePrototypeIDFromSpawnRule(sr, t);
                if (treePrototypeID != -1)
                {
                    BakeTerrainTreeCollisions(t, treePrototypeID, spawnRuleGUID, radius);
                }
            }
        }
Пример #5
0
    void Update()
    {
        if (!this.IsChildSpawner)
        {
            if (this.Rule != SpawnRule.DistanceOnly && this.TimeToSwitchToDistanceOnly > 0.0f)
            {
                _timeSinceStart += Time.deltaTime;

                if (_timeSinceStart > this.TimeToSwitchToDistanceOnly)
                {
                    this.Rule = SpawnRule.DistanceOnly;
                }
            }

            if (this.DistanceToSpawnIncrease > 0.0f && this.MinDistanceToSpawn > 0.0f && this.MinDistanceToSpawn < this.MinDistanceToSpawnCap)
            {
                this.MinDistanceToSpawn = Mathf.Min(this.MinDistanceToSpawn + this.DistanceToSpawnIncrease * Time.deltaTime, this.MinDistanceToSpawnCap);
            }

            if (this.SpawnCooldown > 0.0f)
            {
                if (_cooldownTimer <= 0.0f)
                {
                    if (distanceCheck() && !_spawning)
                    {
                        BeginSpawn();
                    }
                }
                else
                {
                    _cooldownTimer -= Time.deltaTime;
                }
            }
            else if (distanceCheck() && !_spawning)
            {
                BeginSpawn();
            }
        }
    }
Пример #6
0
    private void PopulateRules(SpawnRule[] rules)
    {
        int level = GameSession.Instance.GetLevel();
        int relativeDifficulty = level;                                            // What rules can spawn
        int difficulty         = Mathf.FloorToInt(5f * (1 + Mathf.Log(level, 2))); // How many of them can spawn

        int failedAttempts = 0;

        while (difficulty > 0 && failedAttempts < MAX_FAILED_SPAWN_ATTEMPTS)
        {
            failedAttempts++;

            SpawnRule rule = rules[Random.Range(0, rules.Length)];

            if (rule.GetRelativeDifficulty() <= relativeDifficulty && rule.GetTotalDifficulty() <= difficulty)
            {
                if (rule.AttemptSpawn(data))
                {
                    difficulty    -= rule.GetTotalDifficulty();
                    failedAttempts = 0;
                }
            }
        }
    }
Пример #7
0
 /// <summary>
 /// Call this to do any post spawn goodness
 /// </summary>
 public virtual void PostSpawn(SpawnRule spawnRule, ref SpawnInfo spawnInfo)
 {
 }
Пример #8
0
 /// <summary>
 /// Whether or not this extension should override the spawn itself
 /// </summary>
 /// <param name="spawnInfo"></param>
 /// <returns></returns>
 public virtual bool OverridesSpawn(SpawnRule spawnRule, ref SpawnInfo spawnInfo)
 {
     return(false);
 }
        /// <summary>
        /// Call this to get the degree of completion in range 0..1.
        /// </summary>
        /// <param name="spawner">The spawner this is for</param>
        /// <param name="objSpawned">The object that was spawned in the spawn step (if relevant)</param>
        /// <returns>Return the completion in range of 0 (not started) .. 1 (completed)</returns>
        public override void PostSpawn(SpawnRule spawnRule, ref SpawnInfo spawnInfo)
        {
            //See if we can load the texture
            if (m_textureHM == null || !m_textureHM.HasData())
            {
                return;
            }

            //Get the terrain
            Terrain t = Gaia.TerrainHelper.GetTerrain(spawnInfo.m_hitLocationWU);

            if (t == null)
            {
                return;
            }

            //Get the cached texture maps
            List <HeightMap> txtMaps = spawnInfo.m_spawner.GetTextureMaps(spawnInfo.m_hitTerrain.GetInstanceID());

            if (txtMaps == null || m_textureIndex >= txtMaps.Count)
            {
                return;
            }

            //Make some speedy calculations
            float   widthWU = spawnInfo.m_hitTerrain.terrainData.size.x;
            float   depthWU = spawnInfo.m_hitTerrain.terrainData.size.z;
            float   radiusWU = spawnRule.GetMaxScaledRadius(ref spawnInfo) * m_scaleMask;
            float   xStartWU = spawnInfo.m_hitLocationWU.x - (radiusWU / 2f);
            float   zStartWU = spawnInfo.m_hitLocationWU.z - (radiusWU / 2f);
            float   xEndWU = xStartWU + radiusWU;
            float   zEndWU = zStartWU + radiusWU;
            float   stepWU = 0.5f;
            Vector3 locationWU = Vector3.zero;
            float   xRotNU = 0f, zRotNU = 0f;
            float   currStrength = 0f, newStrength = 1f;

            for (float x = xStartWU; x < xEndWU; x += stepWU)
            {
                for (float z = zStartWU; z < zEndWU; z += stepWU)
                {
                    //Need to rotate x,z around the pivot by the rotation angle
                    locationWU = new Vector3(x, spawnInfo.m_hitLocationWU.y, z);
                    locationWU = Gaia.GaiaUtils.RotatePointAroundPivot(locationWU, spawnInfo.m_hitLocationWU, new Vector3(0f, spawnInfo.m_spawnRotationY, 0f));

                    //Now normalise the result
                    xRotNU = (locationWU.x / widthWU) + 0.5f;
                    zRotNU = (locationWU.z / depthWU) + 0.5f;

                    //Drop out if out of bounds
                    if (xRotNU < 0f || xRotNU >= 1f || zRotNU < 0f || zRotNU > 1f)
                    {
                        continue;
                    }

                    //Only interested in increasing values
                    currStrength = txtMaps[m_textureIndex][zRotNU, xRotNU];
                    newStrength  = m_textureHM[(x - xStartWU) / radiusWU, (z - zStartWU) / radiusWU];
                    if (newStrength > currStrength)
                    {
                        float delta      = newStrength - currStrength;
                        float theRest    = 1f - currStrength;
                        float adjustment = 0f;
                        if (theRest != 0f)
                        {
                            adjustment = 1f - (delta / theRest);
                        }

                        for (int idx = 0; idx < txtMaps.Count; idx++)
                        {
                            if (idx == m_textureIndex)
                            {
                                txtMaps[idx][zRotNU, xRotNU] = newStrength;
                            }
                            else
                            {
                                txtMaps[idx][zRotNU, xRotNU] *= adjustment;
                            }
                        }
                    }
                }
            }

            spawnInfo.m_spawner.SetTextureMapsDirty();
        }
Пример #10
0
    public List <Vector2Int> GetSpawnLocations(SpawnRule rules)
    {
        Debug.Log("GridManager.GetSpawnLocations() called.");

        List <Vector2Int> availableSpawnLocations  = new List <Vector2Int>();
        List <Vector2Int> ineligibleSpawnLocations = new List <Vector2Int>();

        Debug.LogFormat("Number of available spawn locations at start: {0}", availableSpawnLocations.Count);

        for (int w = 0; w < levelGrid.GetLength(0); w++)
        {
            for (int h = 0; h < levelGrid.GetLength(1); h++)
            {
                if (rules.spawnRegion == SpawnRule.SpawnRegion.Perimeter)
                {
                    //Debug.LogFormat("Location is perimeter eligible: {0} .", EligiblePerimeterSpawns.Contains(levelGrid[i, j].location));
                    if (EligiblePerimeterSpawns.Contains(levelGrid[w, h].location))
                    {
                        availableSpawnLocations.Add(levelGrid[w, h].location);
                    }
                }
                else if (rules.spawnRegion == SpawnRule.SpawnRegion.Interior)
                {
                    //Debug.LogFormat("Location is interior eligible: {0} .", EligibleInteriorSpawns.Contains(levelGrid[i, j].location));
                    if (EligibleInteriorSpawns.Contains(levelGrid[w, h].location))
                    {
                        availableSpawnLocations.Add(levelGrid[w, h].location);
                    }
                }

                for (int k = 0; k < levelGrid[w, h].objectsOnBlock.Count; k++)
                {
                    Hazard      currentHazard     = levelGrid[w, h].objectsOnBlock[k].GetComponent <Hazard>();
                    MovePattern currentHazardMove = levelGrid[w, h].objectsOnBlock[k].GetComponent <MovePattern>();

                    if (currentHazard != null && currentHazardMove != null)
                    {
                        if (rules.spawnRegion == SpawnRule.SpawnRegion.Perimeter)
                        {
                            if (rules.avoidHazardPaths)
                            {
                                if (currentHazardMove.DirectionOnGrid == Vector2Int.up)
                                {
                                    // Disable spawning on opposing GridBlock at boundary
                                    Vector2Int boundaryLocationToRemove = new Vector2Int((int)currentHazard.currentWorldLocation.x, BoundaryTopActual);
                                    Debug.LogFormat("Adding {0} to the ineligible spawn list.", boundaryLocationToRemove.ToString());
                                    ineligibleSpawnLocations.Add(boundaryLocationToRemove);

                                    // Disable spawning immediately in front of current hazard on left playable boundary
                                    if (boundaryLocationToRemove.x == BoundaryLeftPlay)
                                    {
                                        Vector2Int locationToRemove = WorldToGrid(currentHazard.currentWorldLocation) + Vector2Int.left;
                                        Debug.LogFormat("Adding {0} to the ineligible spawn list.", locationToRemove.ToString());
                                        ineligibleSpawnLocations.Add(locationToRemove);

                                        locationToRemove += Vector2Int.up;
                                        Debug.LogFormat("Adding {0} to the ineligible spawn list.", locationToRemove.ToString());
                                        ineligibleSpawnLocations.Add(locationToRemove);
                                    }
                                    // Disable spawning immediately in front of current hazard on right playable boundary
                                    else if (boundaryLocationToRemove.x == BoundaryRightPlay)
                                    {
                                        Vector2Int locationToRemove = WorldToGrid(currentHazard.currentWorldLocation) + Vector2Int.right;
                                        Debug.LogFormat("Adding {0}sms to the ineligible spawn list.", locationToRemove.ToString());
                                        ineligibleSpawnLocations.Add(locationToRemove);

                                        locationToRemove += Vector2Int.up;
                                        Debug.LogFormat("Adding {0] to the ineligible spawn list.", locationToRemove.ToString());
                                        ineligibleSpawnLocations.Add(locationToRemove);
                                    }
                                }
                                else if (currentHazardMove.DirectionOnGrid == Vector2Int.down)
                                {
                                    // Disable spawning on opposing GridBlock at boundary
                                    Vector2Int boundaryLocationToRemove = new Vector2Int((int)currentHazard.currentWorldLocation.x, BoundaryBottomActual);
                                    ineligibleSpawnLocations.Add(boundaryLocationToRemove);

                                    // Disable spawning immediately in front of current hazard on left playable boundary
                                    if (boundaryLocationToRemove.x == BoundaryLeftPlay)
                                    {
                                        Vector2Int locationToRemove = WorldToGrid(currentHazard.currentWorldLocation) + Vector2Int.left;
                                        ineligibleSpawnLocations.Add(locationToRemove);

                                        locationToRemove += Vector2Int.down;
                                        ineligibleSpawnLocations.Add(locationToRemove);
                                    }
                                    // Disable spawning immediately in front of current hazard on right playable boundary
                                    else if (boundaryLocationToRemove.x == BoundaryRightPlay)
                                    {
                                        Vector2Int locationToRemove = WorldToGrid(currentHazard.currentWorldLocation) + Vector2Int.right;
                                        ineligibleSpawnLocations.Add(locationToRemove);

                                        locationToRemove += Vector2Int.down;
                                        ineligibleSpawnLocations.Add(locationToRemove);
                                    }
                                }
                                else if (currentHazardMove.DirectionOnGrid == Vector2Int.left)
                                {
                                    // Disable spawning on opposing GridBlock at boundary
                                    Vector2Int boundaryLocationToRemove = new Vector2Int(BoundaryLeftActual, (int)currentHazard.currentWorldLocation.y);
                                    ineligibleSpawnLocations.Add(boundaryLocationToRemove);

                                    // Disable spawning immediately in front of current hazard on top playable boundary
                                    if (boundaryLocationToRemove.y == BoundaryTopPlay)
                                    {
                                        Vector2Int locationToRemove = WorldToGrid(currentHazard.currentWorldLocation) + Vector2Int.up;
                                        ineligibleSpawnLocations.Add(locationToRemove);

                                        locationToRemove += Vector2Int.left;
                                        ineligibleSpawnLocations.Add(locationToRemove);
                                    }
                                    // Disable spawning immediately in front of current hazard on bottom playable boundary
                                    else if (currentHazardMove.CanMoveThisTurn && boundaryLocationToRemove.y == BoundaryBottomPlay)
                                    {
                                        Vector2Int locationToRemove = WorldToGrid(currentHazard.currentWorldLocation) + Vector2Int.down;
                                        ineligibleSpawnLocations.Add(locationToRemove);

                                        locationToRemove += Vector2Int.left;
                                        ineligibleSpawnLocations.Add(locationToRemove);
                                    }
                                }
                                else if (currentHazardMove.DirectionOnGrid == Vector2Int.right)
                                {
                                    // Disable spawning on opposing GridBlock at boundary
                                    Vector2Int boundaryLocationToRemove = new Vector2Int(BoundaryRightActual, (int)currentHazard.currentWorldLocation.y);
                                    ineligibleSpawnLocations.Remove(boundaryLocationToRemove);

                                    // Disable spawning in immediate vicinity of current hazard along top playable boundary
                                    if (boundaryLocationToRemove.y == BoundaryTopPlay)
                                    {
                                        Vector2Int locationToRemove = WorldToGrid(currentHazard.currentWorldLocation) + Vector2Int.up;
                                        ineligibleSpawnLocations.Add(locationToRemove);

                                        locationToRemove += Vector2Int.right;
                                        ineligibleSpawnLocations.Add(locationToRemove);
                                    }
                                    // Disable spawning immediately in front of current hazard on bottom playable boundary
                                    else if (boundaryLocationToRemove.y == BoundaryBottomPlay)
                                    {
                                        Vector2Int locationToRemove = WorldToGrid(currentHazard.currentWorldLocation) + Vector2Int.down;
                                        ineligibleSpawnLocations.Add(locationToRemove);

                                        locationToRemove += Vector2Int.right;
                                        ineligibleSpawnLocations.Add(locationToRemove);
                                    }
                                }
                            }

                            if (rules.avoidAdjacentToPlayer == true)
                            {
                                Vector3 playerLocation = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>().currentWorldLocation;
                            }
                        }
                        else if (rules.spawnRegion == SpawnRule.SpawnRegion.Interior)
                        {
                            if (EligibleInteriorSpawns.Contains(levelGrid[w, h].location))
                            {
                                availableSpawnLocations.Add(levelGrid[w, h].location);
                            }

                            Vector2Int currentHazardGridLocation = WorldToGrid(currentHazard.currentWorldLocation);
                            ineligibleSpawnLocations.Add(currentHazardGridLocation);

                            if (rules.avoidHazardPaths)
                            {
                                Vector2Int        direction             = currentHazardMove.DirectionOnGrid;
                                List <Vector2Int> gridLocationsToRemove = GetGridPath(currentHazardGridLocation, direction);
                            }

                            if (rules.avoidAdjacentToPlayer)
                            {
                            }
                        }
                    }
                }
            }
        }

        Debug.LogFormat("Number of available spawn locations at end: {0}", availableSpawnLocations.Count);

        for (int i = 0; i < ineligibleSpawnLocations.Count; i++)
        {
            if (availableSpawnLocations.Contains(ineligibleSpawnLocations[i]))
            {
                availableSpawnLocations.Remove(ineligibleSpawnLocations[i]);
            }
        }
        return(availableSpawnLocations);
    }
Пример #11
0
        public static void DrawMaskListElement(Rect rect, int index, CollisionMask collisionMask, EditorUtils m_editorUtils, Terrain currentTerrain, GaiaConstants.FeatureOperation operation)
        {
            int oldIndent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            //Active Label
            Rect fieldRect = new Rect(rect.x, rect.y, rect.width * 0.1f, EditorGUIUtility.singleLineHeight);

            EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("MaskActive"));
            //Active Checkbox
            fieldRect.x           += rect.width * 0.1f;
            fieldRect.width        = rect.width * 0.05f;
            collisionMask.m_active = EditorGUI.Toggle(fieldRect, collisionMask.m_active);
            //Invert Label
            fieldRect.x    += rect.width * 0.05f;
            fieldRect.width = rect.width * 0.1f;
            EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("MaskInvert"));
            //Invert Checkbox
            fieldRect.x           += rect.width * 0.1f;
            fieldRect.width        = rect.width * 0.05f;
            collisionMask.m_invert = EditorGUI.Toggle(fieldRect, collisionMask.m_invert);
            //Type dropdown
            fieldRect.x    += rect.width * 0.05f;
            fieldRect.width = rect.width * 0.2f;
            BakedMaskType oldType = collisionMask.m_type;

            collisionMask.m_type = (BakedMaskType)EditorGUI.EnumPopup(fieldRect, collisionMask.m_type);
            EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskTypeTooltip"));
            switch (collisionMask.m_type)
            {
            case BakedMaskType.RadiusTree:
                //Tree dropdown
                string oldTreeId = collisionMask.m_treeSpawnRuleGUID;
                fieldRect.x += rect.width * 0.2f;
                int selectedGUIDIndex = 0;
                if (collisionMask.m_treeSpawnRuleGUID != "")
                {
                    SpawnRule selectedRule = CollisionMask.m_allTreeSpawnRules.FirstOrDefault(x => x.GUID == collisionMask.m_treeSpawnRuleGUID);
                    if (selectedRule != null)
                    {
                        selectedGUIDIndex = Array.IndexOf(CollisionMask.m_allTreeSpawnRules, selectedRule);
                    }
                }
                selectedGUIDIndex = EditorGUI.IntPopup(fieldRect, selectedGUIDIndex, CollisionMask.m_allTreeSpawnRuleNames, CollisionMask.m_allTreeSpawnRuleIndices);
                if (selectedGUIDIndex >= 0 && selectedGUIDIndex < CollisionMask.m_allTreeSpawnRules.Length)
                {
                    collisionMask.m_treeSpawnRuleGUID = CollisionMask.m_allTreeSpawnRules[selectedGUIDIndex].GUID;
                }
                if (oldType != collisionMask.m_type || oldTreeId != collisionMask.m_treeSpawnRuleGUID)
                {
                    SpawnRule selectedRule = CollisionMask.m_allTreeSpawnRules.FirstOrDefault(x => x.GUID == collisionMask.m_treeSpawnRuleGUID);
                    if (selectedRule != null)
                    {
                        Spawner spawner = CollisionMask.m_allTreeSpawners.FirstOrDefault(x => x.m_settings.m_spawnerRules.Contains(selectedRule));
                        if (spawner != null)
                        {
                            GameObject treePrefab = spawner.m_settings.m_resources.m_treePrototypes[selectedRule.m_resourceIdx].m_desktopPrefab;
                            collisionMask.m_Radius = GaiaUtils.GetTreeRadius(treePrefab);
                        }
                    }
                }

                fieldRect.x           += rect.width * 0.2f;
                fieldRect.width        = rect.width * 0.1f;
                collisionMask.m_Radius = EditorGUI.FloatField(fieldRect, collisionMask.m_Radius);
                fieldRect.x           += rect.width * 0.1f;
                fieldRect.width        = rect.width * 0.2f;
                break;

            case BakedMaskType.RadiusTag:
                //Tree dropdown
                fieldRect.x += rect.width * 0.2f;
                ////Building up a value array of incrementing ints of the size of the available tags this array will then match the displayed string selection in the popup
                //int[] tagValueArray = Enumerable
                //                    .Repeat(0, (int)((currentTerrain.terrainData.treePrototypes.Length - 0) / 1) + 1)
                //                    .Select((tr, ti) => tr + (1 * ti))
                //                    .ToArray();
                string oldTag = collisionMask.m_tag;
                collisionMask.m_tag = EditorGUI.TagField(fieldRect, collisionMask.m_tag);

                if (oldType != collisionMask.m_type || oldTag != collisionMask.m_tag)
                {
                    collisionMask.m_Radius = GaiaUtils.GetBoundsForTaggedObject(collisionMask.m_tag);
                }


                fieldRect.x           += rect.width * 0.2f;
                fieldRect.width        = rect.width * 0.1f;
                collisionMask.m_Radius = EditorGUI.FloatField(fieldRect, collisionMask.m_Radius);
                fieldRect.x           += rect.width * 0.1f;
                fieldRect.width        = rect.width * 0.2f;
                break;

            case (BakedMaskType.LayerGameObject):
                //Layer mask selection
                fieldRect.x += rect.width * 0.2f;
                EditorGUI.BeginChangeCheck();
                collisionMask.m_layerMask = GaiaEditorUtils.LayerMaskFieldRect(fieldRect, new GUIContent(""), collisionMask.m_layerMask);
                if (EditorGUI.EndChangeCheck())
                {
                    collisionMask.m_layerMaskLayerNames = GaiaUtils.LayerMaskToString(collisionMask.m_layerMask);
                }
                EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskLayerSelectionTooltip"));
                fieldRect.x    += rect.width * 0.2f;
                fieldRect.width = rect.width * 0.1f;
                collisionMask.m_growShrinkDistance = EditorGUI.FloatField(fieldRect, collisionMask.m_growShrinkDistance);
                EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskGrowShrinkDistanceTooltip"));
                fieldRect.x    += rect.width * 0.1f;
                fieldRect.width = rect.width * 0.2f;

                break;

            case (BakedMaskType.LayerTree):
                //Layer mask selection
                fieldRect.x += rect.width * 0.2f;
                EditorGUI.BeginChangeCheck();
                collisionMask.m_layerMask = GaiaEditorUtils.LayerMaskFieldRect(fieldRect, new GUIContent(""), collisionMask.m_layerMask);
                if (EditorGUI.EndChangeCheck())
                {
                    collisionMask.m_layerMaskLayerNames = GaiaUtils.LayerMaskToString(collisionMask.m_layerMask);
                }
                EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskLayerSelectionTooltip"));
                fieldRect.x    += rect.width * 0.2f;
                fieldRect.width = rect.width * 0.1f;
                collisionMask.m_growShrinkDistance = EditorGUI.FloatField(fieldRect, collisionMask.m_growShrinkDistance);
                EditorGUI.LabelField(fieldRect, m_editorUtils.GetContent("CollisionMaskGrowShrinkDistanceTooltip"));
                fieldRect.x    += rect.width * 0.1f;
                fieldRect.width = rect.width * 0.2f;

                break;
            }

            if (GUI.Button(fieldRect, m_editorUtils.GetContent("MaskCollisionBake")))
            {
                switch (collisionMask.m_type)
                {
                case BakedMaskType.RadiusTree:
                    GaiaSessionManager.GetSessionManager().m_bakedMaskCache.BakeAllTreeCollisions(collisionMask.m_treeSpawnRuleGUID, collisionMask.m_Radius);
                    break;

                case BakedMaskType.RadiusTag:
                    GaiaSessionManager.GetSessionManager().m_bakedMaskCache.BakeAllTagCollisions(collisionMask.m_tag, collisionMask.m_Radius);
                    break;

                case BakedMaskType.LayerGameObject:
                    GaiaSessionManager.GetSessionManager().m_bakedMaskCache.BakeAllLayerGameObjectCollisions(collisionMask.m_layerMask, collisionMask.m_growShrinkDistance);     //, collisionMask.m_Radius);
                    break;

                case BakedMaskType.LayerTree:
                    GaiaSessionManager.GetSessionManager().m_bakedMaskCache.BakeAllLayerTreeCollisions(collisionMask.m_layerMask, collisionMask.m_growShrinkDistance);     //, collisionMask.m_Radius);
                    break;
                }
            }
            EditorGUI.indentLevel = oldIndent;
        }