public override void Generate(Map map, GenStepParams parms) { // set to an arbitrarily high value ModuleBase tubes = new Const(10); int tubeCount = Rand.Range(4, 10); float angle = Rand.Range(0, 180); IntVec3 center = map.Center; for (int i = 0; i < tubeCount; i++) { ModuleBase newTube = new AxisAsValueX(); newTube = new Abs(newTube); float slope = 0.05f; float width = Rand.Range(-10, 5); width = Math.Min(width, Rand.Range(-10, 5)); newTube = new ScaleBias(slope, 0 - slope * width, newTube); ModuleBase noiseX = new Multiply(new Const(15.0), new Perlin(0.014, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High)); // displace and rotate need to be in this order newTube = new Displace(newTube, noiseX, new Const(0.0), new Const(0.0)); newTube = new Rotate(0.0, Rand.Range(angle, angle + 45f), 0.0, newTube); IntVec3 newCenter = new IntVec3((int)Rand.Range(center.x * 0.2f, center.x * 1.8f), 0, (int)Rand.Range(center.z * 0.2f, center.z * 1.8f)); newTube = new Translate(0f - newCenter.x, 0.0, 0f - newCenter.z, newTube); // noise newTube = new Add(newTube, new Clamp(0.0, 0.5, new Perlin(0.005, 0.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.Medium))); tubes = new Min(tubes, newTube); } MapGenFloatGrid elevation = MapGenerator.Elevation; foreach (IntVec3 cell in map.AllCells) { elevation[cell] = tubes.GetValue(cell); } }
static void Postfix(ref ModuleBase ___generator, ref ModuleBase ___coordinateX, ref ModuleBase ___coordinateZ, ModuleBase ___shallowizer, float ___surfaceLevel, List <IntVec3> ___lhs, List <IntVec3> ___rhs, Vector3 center, float angle) { MapDesignerSettings settings = MapDesignerMod.mod.settings; //___generator = new Abs(___generator); //___coordinateX = new Abs(___coordinateX); ModuleBase originalBranch = new AxisAsValueX(); ModuleBase riverA = new AxisAsValueX(); ModuleBase riverB = new AxisAsValueX(); ////ModuleBase originalBranch = new AxisAsValueX(); ////originalBranch = new Rotate(0.0, angle, 0.0, originalBranch); ////originalBranch = new Translate((double)(-(double)center.x), 0.0, (double)(-(double)center.z), originalBranch); ////originalBranch = new Subtract(new Abs(originalBranch), new Min(___coordinateZ, new Const(0.0))); switch (settings.selRiverStyle) { case MapDesignerSettings.RiverStyle.Vanilla: break; case MapDesignerSettings.RiverStyle.Spring: //Log.Message("[Map Designer] Calling springs from the ground"); ___generator = new Subtract(new Abs(___coordinateX), new Min(___coordinateZ, new Const(0.0))); break; case MapDesignerSettings.RiverStyle.Canal: ___coordinateX = new AxisAsValueX(); ___coordinateZ = new AxisAsValueZ(); ___coordinateX = new Rotate(0.0, 0f - angle, 0.0, ___coordinateX); ___coordinateZ = new Rotate(0.0, 0f - angle, 0.0, ___coordinateZ); ___coordinateX = new Translate(0f - center.x, 0.0, 0f - center.z, ___coordinateX); ___coordinateZ = new Translate(0f - center.x, 0.0, 0f - center.z, ___coordinateZ); ___generator = ___coordinateX; break; case MapDesignerSettings.RiverStyle.Confluence: Log.Message("[Map Designer] Merging rivers"); ___coordinateX = new AxisAsValueX(); ___coordinateZ = new AxisAsValueZ(); ___coordinateX = new Rotate(0.0, 0f - angle, 0.0, ___coordinateX); ___coordinateZ = new Rotate(0.0, 0f - angle, 0.0, ___coordinateZ); ___coordinateX = new Translate(0f - center.x, 0.0, 0f - center.z, ___coordinateX); ___coordinateZ = new Translate(0f - center.x, 0.0, 0f - center.z, ___coordinateZ); ModuleBase moduleBase = new Perlin(0.029999999329447746, 2.0, 0.5, 3, Rand.Range(0, int.MaxValue), QualityMode.Medium); ModuleBase moduleBase2 = new Perlin(0.029999999329447746, 2.0, 0.5, 3, Rand.Range(0, int.MaxValue), QualityMode.Medium); ModuleBase moduleBase3 = new Const(8.0); moduleBase = new Multiply(moduleBase, moduleBase3); moduleBase2 = new Multiply(moduleBase2, moduleBase3); ___coordinateX = new Displace(___coordinateX, moduleBase, new Const(0.0), moduleBase2); ___coordinateZ = new Displace(___coordinateZ, moduleBase, new Const(0.0), moduleBase2); originalBranch = new Rotate(0.0, angle - 180, 0.0, originalBranch); originalBranch = new Translate((double)(-(double)center.x), 0.0, (double)(-(double)center.z), originalBranch); originalBranch = new Subtract(new Abs(originalBranch), new Min(___coordinateZ, new Const(0.0))); riverA = new Rotate(0.0, angle - 30, 0.0, riverA); riverA = new Translate((double)(-(double)center.x), 0.0, (double)(-(double)center.z), riverA); riverA = new Subtract(new Abs(riverA), new Min(new Invert(___coordinateZ), new Const(0.0))); riverB = new Rotate(0.0, angle + 30, 0.0, riverB); riverB = new Translate((double)(-(double)center.x), 0.0, (double)(-(double)center.z), riverB); riverB = new Subtract(new Abs(riverB), new Min(new Invert(___coordinateZ), new Const(0.0))); ___generator = new Min(riverA, riverB); ___generator = new Min(originalBranch, ___generator); ___generator = new Displace(___generator, moduleBase, new Const(0.0), moduleBase2); break; //case MapDesignerSettings.RiverStyle.Fork: // Log.Message("[Map Designer] Forking rivers"); // originalBranch = new Rotate(0.0, angle, 0.0, originalBranch); // originalBranch = new Translate((double)(-(double)center.x), 0.0, (double)(-(double)center.z), originalBranch); // originalBranch = new Subtract(new Abs(originalBranch), new Min(new Invert(___coordinateZ), new Const(0.0))); // riverA = new Rotate(0.0, angle - 30, 0.0, riverA); // riverA = new Translate((double)(-(double)center.x), 0.0, (double)(-(double)center.z), riverA); // riverA = new Subtract(new Abs(riverA), new Min(___coordinateZ, new Const(0.0))); // riverB = new Rotate(0.0, angle + 30, 0.0, riverB); // riverB = new Translate((double)(-(double)center.x), 0.0, (double)(-(double)center.z), riverB); // riverB = new Subtract(new Abs(riverB), new Min(___coordinateZ, new Const(0.0))); // ___generator = new Min(riverA, riverB); // ___generator = new Min(originalBranch, ___generator); // break; //case MapDesignerSettings.RiverStyle.Oxbow: // Log.Message("[Map Designer] Winding rivers"); // ModuleBase oxbow = new AxisAsValueX(); // ModuleBase x = new Perlin(0.008, 0.0, 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium); // ModuleBase z = new Perlin(0.015, 0.0, 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium); // //ModuleBase scaling = new Const(40.0); // x = new Multiply(x, new Const(50.0)); // z = new Multiply(z, new Const(30.0)); // oxbow = new Displace(oxbow, x, new Const(0.0), z); // oxbow = new Rotate(0.0, 0.0 - angle, 0.0, oxbow); // oxbow = new Translate(0.0 - center.x, 0.0, 0.0 - center.z, oxbow); // ___coordinateX = oxbow; // ___generator = oxbow; // break; default: break; } }
/// <summary> /// Mountain amount /// Natural hill distribution /// </summary> /// <param name="map"></param> /// <param name="parms"></param> static void Postfix(Map map, GenStepParams parms) { // Map Reroll uses a map stub to generate previews, which is missing this info. // Checking map.info.parent.def filters Map Reroll previews and categorizes them as "player home" maps bool isPlayerHome = false; if (map.info.parent.def == null) { isPlayerHome = true; } else if (map.IsPlayerHome) { isPlayerHome = true; } if (MapDesignerSettings.flagHomeMapOnly && !isPlayerHome) { return; } MapDesignerSettings settings = MapDesignerMod.mod.settings; MapGenFloatGrid elevation = MapGenerator.Elevation; // pushes hills away from center if (MapDesignerMod.mod.settings.flagHillRadial) { IntVec3 center = map.Center; int size = map.Size.x / 2; float centerSize = settings.hillRadialSize * size; foreach (IntVec3 current in map.AllCells) { float distance = (float)Math.Sqrt(Math.Pow(current.x - center.x, 2) + Math.Pow(current.z - center.z, 2)); elevation[current] += (settings.hillRadialAmt * (distance - centerSize) / size); } } // hills to both sides if (MapDesignerMod.mod.settings.flagHillSplit) { float angle = settings.hillSplitDir; int mapSize = map.Size.x; float gapSize = 0.5f * mapSize * settings.hillSplitSize; float skew = settings.hillSplitAmt; ModuleBase slope = new AxisAsValueX(); slope = new Rotate(0.0, 180.0 - angle, 0.0, slope); slope = new Translate(0.0 - map.Center.x, 0.0, 0.0 - map.Center.z, slope); float multiplier = skew / mapSize; foreach (IntVec3 current in map.AllCells) { float value = slope.GetValue(current); //float num = size - Math.Abs(value); float num = Math.Abs(value) - gapSize; //num = 1 + (skew * num / mapSize); //num = 1 + num * multiplier; elevation[current] += num * multiplier; //elevation[current] *= num; //elevation[current] += num - 1; } } // hills to one side if (MapDesignerMod.mod.settings.flagHillSide) { float angle = settings.hillSideDir; float skew = settings.hillSideAmt; ModuleBase slope = new AxisAsValueX(); slope = new Rotate(0.0, 180.0 - angle, 0.0, slope); slope = new Translate(0.0 - map.Center.x, 0.0, 0.0 - map.Center.z, slope); float multiplier = skew / map.Size.x; foreach (IntVec3 current in map.AllCells) { //elevation[current] *= (1 + slope.GetValue(current) * multiplier); //elevation[current] += 0.5f * slope.GetValue(current) * multiplier; elevation[current] += slope.GetValue(current) * multiplier; } } // hill amount float hillAmount = settings.hillAmount; foreach (IntVec3 current in map.AllCells) { elevation[current] += settings.hillAmount - 1f; } // natural distribution if (MapDesignerMod.mod.settings.flagHillClumping) { float hillSize = MapDesignerMod.mod.settings.hillSize; if (hillSize > 0.022f) // smaller than vanilla only, else skip this step { float clumpSize = Rand.Range(0.01f, Math.Min(0.04f, hillSize)); float clumpStrength = Rand.Range(0.3f, 0.7f); ModuleBase hillClumping = new Perlin(clumpSize, 0.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.Low); foreach (IntVec3 current in map.AllCells) { elevation[current] += clumpStrength * hillClumping.GetValue(current); } } } // exit path if (MapDesignerMod.mod.settings.flagMtnExit) { ModuleBase exitPath = new AxisAsValueX(); ModuleBase crossways = new AxisAsValueZ(); double exitDir = Rand.Range(0, 360); //ModuleBase noise = new Perlin(0.021, 3.5, 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium); //ModuleBase noise = new Perlin(Rand.Range(0.015f, 0.035f), 2.0, 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium); ModuleBase noise = new Perlin(Rand.Range(0.015f, 0.03f), Math.Min(3.5, settings.hillSmoothness), 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium); noise = new Multiply(noise, new Const(25.0)); exitPath = new Displace(exitPath, noise, new Const(0.0), new Const(0.0)); exitPath = new Rotate(0.0, exitDir, 0.0, exitPath); crossways = new Rotate(0.0, exitDir, 0.0, crossways); exitPath = new Translate((double)(-(double)map.Center.x), 0.0, (double)(-(double)map.Center.z), exitPath); crossways = new Translate((double)(-(double)map.Center.x), 0.0, (double)(-(double)map.Center.z), crossways); exitPath = new Abs(exitPath); foreach (IntVec3 current in map.AllCells) { if (crossways.GetValue(current) > 0f) { elevation[current] *= Math.Min(1, 0.1f * exitPath.GetValue(current) - 0.5f); } } } if (isPlayerHome) { GenerateFeatureGrids(map, parms); } }