public void InitRockStrataGen(ICoreServerAPI api, Random rand, Dictionary <EnumRockGroup, List <RockStrataVariant> > VariantsByRockGroup) { List <RockStrataGen> Gens = new List <RockStrataGen>(); var values = Enum.GetValues(typeof(EnumRockGroup)); // Console.WriteLine("init rock strata " + code); foreach (EnumRockGroup rockgroup in values) { GeologicProvinceRockStrata gprs = Rockstrata[rockgroup + ""]; float current = gprs.minQuant + (float)rand.NextDouble() * (gprs.maxQuant - gprs.minQuant); gprs.currentq = (int)current + ((rand.NextDouble() * (current - (int)current)) > 0 ? 1 : 0); // Console.WriteLine("add " + current + " " + rockgroup +"s"); for (int i = 0; i < gprs.currentq; i++) { int rnd = rand.Next(VariantsByRockGroup[rockgroup].Count); RockStrataVariant rockType = VariantsByRockGroup[rockgroup][rnd]; float multiplier = rockType.Weight / 100f; // Multiplier range from 0..1 to 100 - 5 //multiplier = (1 - multiplier) * 193 + 7; multiplier = (1 - multiplier) * 95 + 5; int blockId = api.WorldManager.GetBlockId(rockType.BlockCode); if (blockId == -1) { throw new Exception("Block with code " + rockType.BlockCode + " not found! Can't generate rock strata this way :("); } RockStrataGen gen = new RockStrataGen() { amplitude = 1, multiplier = multiplier, offset = (float)rand.NextDouble(), thickness = gprs.maxThickness, blockId = (ushort)blockId, heightErosion = 1 - rockType.HeightErosion }; Gens.Add(gen); // Console.WriteLine("addded rock type generator {0} (id={4}), m={1}, o={2}, t={3}", rockType.BlockCode, gen.blockId, gen.multiplier, gen.offset, gen.thickness); } } ValueGenerators = Gens.ToArray(); }
public void init() { RockStrataIndexed = new GeologicProvinceRockStrata[Enum.GetValues(typeof(EnumRockGroup)).Length]; foreach (var val in Enum.GetValues(typeof(EnumRockGroup))) { RockStrataIndexed[(int)val] = new GeologicProvinceRockStrata(); if (Rockstrata.ContainsKey("" + val)) { RockStrataIndexed[(int)val] = Rockstrata["" + val]; } } }