Example #1
0
 public HolidayOnSpecificDay(int holidayDay, int holidayMonth, Displace displace, List <DayOfWeek> mustOccurOn)
     : this(holidayDay, holidayMonth, displace)
 {
     if (mustOccurOn == null || mustOccurOn.Distinct().Count() is < 1 or >= 7)
     {
         throw new ArgumentException("Parameter mustOccurOn can not be null and must contain between 1 and 6 days of the week.");
     }
 }
        public Module GetModuleA()
        {
            int octaves = 2 + (int)Mathf.Log(_height, 2);

            octaves = Mathf.Max(8, octaves);

            var map = new Clamp()
            {
                Source0 = new ScaleBias()
                {
                    Source0 = new Perlin()
                    {
                        Frequency   = 1.0f,
                        Lacunarity  = 2.0f,
                        OctaveCount = octaves,
                        Seed        = _seed,
                    },
                    Scale = 1.0f,
                }
            };

            var control = new ScaleBias()
            {
                Source0 = new Perlin
                {
                    Frequency = 0.8f,
                    //Frequency = 1.8f,  // sharp
                    //Lacunarity = 1.9f, // for clouds
                    Lacunarity  = 2.5f, // for land
                    OctaveCount = (int)(octaves / 2f) + 1,
                    Seed        = _seed + 4,
                },
                Scale = 0.8f,
            };

            var displace = new Displace()
            {
                Source0   = map,
                XDisplace = control,
                YDisplace = control,
                ZDisplace = new Constant()
                {
                    ConstantValue = 0,
                },
            };

            return(new Clamp()
            {
                Source0 = displace,
            });
        }
Example #3
0
 public HolidayOnSpecificDay(int holidayDay, int holidayMonth, Displace displace = Displace.Forward)
 {
     if (holidayDay is < 1 or > 31)
     {
         throw new ArgumentOutOfRangeException(nameof(holidayDay), " must be between 1 and 31.");
     }
     if (holidayMonth is < 1 or > 12)
     {
         throw new ArgumentOutOfRangeException(nameof(holidayMonth), " must be between 1 and 12.");
     }
     HolidayDay   = holidayDay;
     HolidayMonth = holidayMonth;
     Displace     = displace;
 }
Example #4
0
        public override Module GetModule()
        {
            var map = new Clamp()
            {
                Source0 = new ScaleBias()
                {
                    Source0 = new Perlin()
                    {
                        Frequency   = _frequencyBase,
                        Lacunarity  = _lacunarityBase,
                        OctaveCount = _octaveBase,
                        Seed        = _seed,
                    },
                    Scale = _scaleBase,
                }
            };

            var control = new ScaleBias()
            {
                Source0 = new Perlin
                {
                    Frequency   = _frequencyDisplace,
                    Lacunarity  = _lacunarityDisplace,
                    OctaveCount = _octaveDisplace,
                    Seed        = _seed + _offset,
                },
                Scale = _scaleDisplace,
            };

            var displace = new Displace()
            {
                Source0   = map,
                XDisplace = control,
                YDisplace = control,
                ZDisplace = new Constant()
                {
                    ConstantValue = _bias,
                },
            };

            return(new Clamp()
            {
                Source0 = displace,
            });
        }
        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);
            }
        }
Example #6
0
 public void SetSouces(IModule3D target, IModule3D sourceModule, IModule3D xModule, IModule3D yModule, IModule3D zModule)
 {
     if (transformerType == TransformerType.Turbulence)
     {
         Turbulence turbulence = target as Turbulence;
         turbulence.SourceModule   = sourceModule;
         turbulence.XDistortModule = xModule;
         turbulence.YDistortModule = yModule;
         turbulence.ZDistortModule = zModule;
     }
     else if (transformerType == TransformerType.RotatePoint)
     {
         RotatePoint rotatePoint = target as RotatePoint;
         rotatePoint.SourceModule = sourceModule;
     }
     else
     {
         Displace displace = target as Displace;
         displace.SourceModule    = sourceModule;
         displace.XDisplaceModule = xModule;
         displace.YDisplaceModule = yModule;
         displace.ZDisplaceModule = zModule;
     }
 }
Example #7
0
 // Use this for initialization
 void Start()
 {
     displaceComponent = GetComponent <Displace>();
 }
Example #8
0
 void Start()
 {
     _displace = GetComponent <Displace>();
 }
Example #9
0
        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);
            }
        }
Example #11
0
        public static float GetBurstValue(ModuleType type, float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            switch (type)
            {
            case ModuleType.Billow:
                return(Billow.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Checker:
                return(Checker.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Const:
                return(Const.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Cylinders:
                return(Cylinders.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Perlin:
                return(Perlin.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.RidgedMultifractal:
                return(RidgedMultifractal.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Spheres:
                return(Spheres.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Voronoi:
                return(Voronoi.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Abs:
                return(Abs.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Add:
                return(Add.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Blend:
                return(Blend.GetBurstValue(x, y, z, data, dataIndex));

            // case ModuleType.Cache:
            //     return Cache.GetBurstValue(x, y, z, data, dataIndex);
            case ModuleType.Clamp:
                return(Clamp.GetBurstValue(x, y, z, data, dataIndex));

            // case ModuleType.Curve:
            //     return Curve.GetBurstValue(x, y, z, data, dataIndex);
            case ModuleType.Displace:
                return(Displace.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Exponent:
                return(Exponent.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Invert:
                return(Invert.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Max:
                return(Max.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Min:
                return(Min.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Multiply:
                return(Multiply.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Power:
                return(Power.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Rotate:
                return(Rotate.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Scale:
                return(Scale.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.ScaleBias:
                return(ScaleBias.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Select:
                return(Select.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Subtract:
                return(Subtract.GetBurstValue(x, y, z, data, dataIndex));

            // case ModuleType.Terrace:
            //     return Terrace.GetBurstValue(x, y, z, data, dataIndex);
            case ModuleType.Translate:
                return(Translate.GetBurstValue(x, y, z, data, dataIndex));

            case ModuleType.Turbulence:
                return(Turbulence.GetBurstValue(x, y, z, data, dataIndex));

            default:
                // Debug.LogError("Not a valid module type");
                return(0);
            }
        }