示例#1
0
        private byte GetBiomeId(WeatherBiomes wb, double zone)
        {
            int threeshold    = (int)(zone * wb.TotalBiomesWeight);
            int runningWeight = 0;

            foreach (var biome in wb.BiomesListe)
            {
                runningWeight += biome.ZoneWeight;
                if (runningWeight > threeshold)
                {
                    return(biome.Id);
                }
            }
            return((byte)255);
        }
示例#2
0
        private void Initialize()
        {
            //Assign configuration list position as ID for biome
            byte id = 0;

            foreach (var biome in _config.ProcessorParam.Biomes)
            {
                biome.Id = id;
                id++;
            }

            //Create a biome list per landformtype;
            Dictionary <enuLandFormType, List <Biome> > biomesPerType = new Dictionary <enuLandFormType, List <Biome> >();

            //For each biomes created in the editor
            foreach (var biome in _config.ProcessorParam.Biomes)
            {
                //Take all landscape type where it can spawn
                foreach (var type in biome.LandFormFilters)
                {
                    List <Biome> biomes;

                    if (!biomesPerType.TryGetValue(type, out biomes))
                    {
                        biomes = new List <Biome>();
                        biomesPerType[type] = biomes;
                    }

                    biomes.Add(biome);
                }
            }


            _biomesConfig = new Dictionary <enuLandFormType, List <WeatherBiomes> >();
            foreach (var kvp in biomesPerType)
            {
                WeatherBiomes biomesWithSameWeatherHash;
                //Take all the various weatherHash from the biomes within this enuLandFormType
                foreach (int weatherHash in kvp.Value.Select(x => x.WeatherHash).Distinct().OrderByDescending(x => x))
                {
                    biomesWithSameWeatherHash = new WeatherBiomes()
                    {
                        BiomesListe = new List <Biome>(kvp.Value.Where(x => x.WeatherHash == weatherHash).OrderByDescending(x => x.ZoneWeight))
                    };
                    biomesWithSameWeatherHash.isWeatherBiomes   = biomesWithSameWeatherHash.BiomesListe[0].isWeatherBiomes;
                    biomesWithSameWeatherHash.Moisture          = biomesWithSameWeatherHash.BiomesListe[0].MoistureFilter;
                    biomesWithSameWeatherHash.Temperature       = biomesWithSameWeatherHash.BiomesListe[0].TemperatureFilter;
                    biomesWithSameWeatherHash.TotalBiomes       = biomesWithSameWeatherHash.BiomesListe.Count;
                    biomesWithSameWeatherHash.TotalBiomesWeight = biomesWithSameWeatherHash.BiomesListe.Sum(x => x.ZoneWeight);

                    //Add this List to the Main dictionnary
                    List <WeatherBiomes> allBiomesFromLandscapeType;
                    if (!_biomesConfig.TryGetValue(kvp.Key, out allBiomesFromLandscapeType))
                    {
                        allBiomesFromLandscapeType = new List <WeatherBiomes>();
                        _biomesConfig[kvp.Key]     = allBiomesFromLandscapeType;
                    }
                    allBiomesFromLandscapeType.Add(biomesWithSameWeatherHash);
                }
            }
        }