/// <summary>Used internally to update each spawnable's previous-chance so it may be used next validation.</summary>
 private void UpdateTrackersForChanceValues()
 {
     for (int i = 0; i < _spawnables.Count; i++)
     {
         SpawnNodeEnemy s = _spawnables[i];
         s._prevChance = s._chance;
     }
 }
    private void KeepSpawnChancesInRatio()
    {
        if (_spawnables.Count > 0)
        {
            // Find which spawnable had it's chance value modified.
            int index = FindAlteredChanceIndex();

            // Get the sum of all chance values
            float sum = GetChanceSum();
            float sumExcludingModified = GetChanceSum(index);
            float remainder            = (index >= 0) ? 100 - _spawnables[index]._chance : 100;

            if (sum != 100.0f)
            {
                bool changeMade = false;
                // Iterate through each spawnable
                for (int i = 0; i < _spawnables.Count; i++)
                {
                    SpawnNodeEnemy s = _spawnables[i];

                    // Find the ratio, then set the value to this ratio of the remainder
                    if (s._chance > 0 && i != index)
                    {
                        changeMade = true;
                        float ratio = s._chance / sumExcludingModified;
                        s._chance = remainder * ratio;
                    }
                }

                if (!changeMade)
                {
                    // No changes were made! Either there is only one spawnable, or all non-modified are at 0
                    if (_spawnables.Count == 1)
                    {
                        _spawnables[0]._chance = 100;
                    }
                    else
                    {
                        int zeroQuantity = 0;
                        foreach (SpawnNodeEnemy s in _spawnables)
                        {
                            if (s._chance == 0)
                            {
                                zeroQuantity++;
                            }
                        }

                        float ratio = remainder / zeroQuantity;
                        for (int i = 0; i < _spawnables.Count; i++)
                        {
                            SpawnNodeEnemy s = _spawnables[i];

                            if (i != index)
                            {
                                s._chance = ratio;
                            }
                        }
                    }
                }
            }

            // Update each spawnable's previous-chance for use next Validation
            UpdateTrackersForChanceValues();
        }
    }