コード例 #1
0
    ModuleBase moduleCreation()
    {
        ModuleBase baseModule = null;

        if (!useRandomSeed)
        {
            seedValue = seed.GetHashCode();
        }
        else
        {
            seedValue = UnityEngine.Random.Range(0, 10000000);
        }
        for (int i = 0; i < noiseFunctions.Length; i++)
        {
            noiseFunctions[i].seed = seedValue + i;
        }
        //generates noise for every noisefunction
        for (int i = 0; i < noiseFunctions.Length; i++)
        {
            if (noiseFunctions[i].enabled)
            {
                noiseFunctions[i].MakeNoise();
            }
        }
        //manipulates the base module based on the noise modules
        for (int i = 0; i < noiseFunctions.Length; i++)
        {
            //for first valid noise pattern simply pass the noise function
            if (baseModule == null && noiseFunctions[i].enabled)
            {
                baseModule = noiseFunctions[i].moduleBase;
            }
            //all others valid add to the previous iteration of the baseModule
            else if (noiseFunctions[i].enabled)
            {
                baseModule = new Add(baseModule, noiseFunctions[i].moduleBase);
            }
        }
        if (clamped)
        {
            baseModule = new Clamp(0, 1, baseModule);
        }
        return(baseModule);
    }
コード例 #2
0
        private void ExecuteDeleteSpecificClamp(Clamp existingClamp)
        {
            _logger.Debug(string.Format("Execute delete of specific clamp (clamp='{0}'", existingClamp));
            const double deletionDelay = 700;             // Must be greater than the animation duration in the DataTemplate !!!

            var deletionTimer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(deletionDelay)
            };

            deletionTimer.Tick += (o, args) =>
            {
                _logger.Debug(string.Format("Remove clamp (clamp='{0}'", existingClamp));
                Clamps.Remove(existingClamp);
                deletionTimer.Stop();
                EventHelper.RemoveAllEventHandler(deletionTimer, "Tick");
            };

            deletionTimer.Start();
            existingClamp.IsRemoving = true;
        }
コード例 #3
0
 public MainObject()
 {
     this.outputs.Bus.Add("output", 0.0);
     this.outputs.Bus.Add("time", 0.0);
     this.inputs.Bus.Add("time", 0.0);
     this.inputs.Bus.Add("dt", 1.0);
     this.inputs.Bus.Add("inputGain1", 0.0);
     this.inputs.Bus.Add("inputGain2", 0.0);
     this.inputs.Bus.Add("inputGain3", 0.0);
     this.Ap          = new DAperiodic(0, this.dt);
     this.Coeficients = new MixerCoeficients();
     //this.Coeficients.OnPortChanged += this.OnObjectsChange;
     this.delay = new Delay(100, this.dt);
     //this.delay.OnPortChanged += this.OnObjectsChange;
     this.noise = new Noise();
     //this.noise.OnPortChanged += this.OnObjectsChange;
     this.InputClamp = new Clamp(0, 100);
     this.gain1      = new Gain();
     this.gain2      = new Gain();
     this.gain3      = new Gain();
 }
コード例 #4
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is Clamp)
            {
                Clamp clamp = (Clamp)item;

                if (clamp.IsEmpty)
                {
                    return(clampTemplate);
                }

                return(shirtTemplate);
            }

            if (item is Foil)
            {
                return(paperTemplate);
            }

            return(null);
        }
コード例 #5
0
ファイル: BeachMaker.cs プロジェクト: potsh/RimWorld
        public static void Init(Map map)
        {
            Rot4 a = Find.World.CoastDirectionAt(map.Tile);

            if (!a.IsValid)
            {
                beachNoise = null;
            }
            else
            {
                ModuleBase input = new Perlin(0.029999999329447746, 2.0, 0.5, 3, Rand.Range(0, 2147483647), QualityMode.Medium);
                input = new ScaleBias(0.5, 0.5, input);
                ModuleBase noise = input;
                IntVec3    size  = map.Size;
                int        x     = size.x;
                IntVec3    size2 = map.Size;
                NoiseDebugUI.StoreNoiseRender(noise, "BeachMaker base", new IntVec2(x, size2.z));
                ModuleBase input2 = new DistFromAxis(CoastWidthRange.RandomInRange);
                if (a == Rot4.North)
                {
                    input2 = new Rotate(0.0, 90.0, 0.0, input2);
                    IntVec3 size3 = map.Size;
                    input2 = new Translate(0.0, 0.0, (double)(-size3.z), input2);
                }
                else if (a == Rot4.East)
                {
                    IntVec3 size4 = map.Size;
                    input2 = new Translate((double)(-size4.x), 0.0, 0.0, input2);
                }
                else if (a == Rot4.South)
                {
                    input2 = new Rotate(0.0, 90.0, 0.0, input2);
                }
                input2 = new ScaleBias(1.0, -1.0, input2);
                input2 = new Clamp(-1.0, 2.5, input2);
                NoiseDebugUI.StoreNoiseRender(input2, "BeachMaker axis bias");
                beachNoise = new Add(input, input2);
                NoiseDebugUI.StoreNoiseRender(beachNoise, "beachNoise");
            }
        }
コード例 #6
0
ファイル: Utils.cs プロジェクト: bmalkus/ForestGenerator
        public PerlinNoise(int seed)
        {
            var baseFlat = new Billow();

            baseFlat.Seed      = seed;
            baseFlat.Frequency = 0.005f;
            var flatTerrain = new ScaleBias(0.09f, -0.75f, baseFlat);
            // var terraced = new Terrace(false, expHills);
            // terraced.Add(-1f);
            // terraced.Add(-0.35f);
            // terraced.Add(0.15f);
            // terraced.Add(0.75f);

            var denseBillow = new Billow();

            denseBillow.Seed      = seed;
            denseBillow.Frequency = 0.01f;
            var expBillow = new Exponent(0.3f, denseBillow);
            var scaled    = new ScaleBias(0.3f, -0.85f, expBillow);

            var terrainType = new Perlin();

            terrainType.Seed        = seed;
            terrainType.Frequency   = 0.005f;
            terrainType.Persistence = 0.15f;
            var flatAndScaled = new Select(0f, 1000f, 0.125f, flatTerrain, scaled);

            flatAndScaled.Controller = terrainType;

            var hills = new Billow();

            hills.Seed      = seed;
            hills.Frequency = 0.002f;
            var expHills = new Exponent(2.5f, hills);
            var clamped  = new Clamp(-1f, 0.75f, expHills);

            noiseProvider = new Blend(flatAndScaled, clamped, new Const(0.5f));
        }
コード例 #7
0
        public HeightMapGenerator()
        {
            var noise = new Perlin();

            noise.Seed        = new Random().Next(0, Int32.MaxValue);
            noise.Frequency   = 1.5f;
            noise.OctaveCount = 6;
            noise.Persistence = 0.4f;

            var turbulence = new Turbulence();

            turbulence.Power     = 0.25;
            turbulence.Frequency = 4;
            turbulence.Source0   = noise;

            var clamper = new Clamp();

            clamper.LowerBound = 0;
            clamper.UpperBound = 1;
            clamper.Source0    = turbulence;

            Module = clamper;
        }
コード例 #8
0
        /// <summary>
        /// Insert effect.
        /// </summary>
        protected internal override void InsertEffect()
        {
            PlayerImpl player = this.EntityStrategy;

            if (this.Type.Equals(PowerUpT.HEALTH))
            {
                player.Health = Clamp.clamp(player.Health + this.strategy.multiplyEffect(STANDARD_HEALTH), 0, 100);
            }
            else if (this.Type.Equals(PowerUpT.FIRE_BOOST))
            {
                player.CoolDown = player.CoolDown - this.strategy.multiplyEffect(STANDARD_FIRE_RATE_BOOST);
            }
            else
            {
                if (this.GetActivated() == false)
                {
                    player.SHield = this.strategy.multiplyEffect(SHIELD_S);
                }
                else if (player.Shield == 0)
                {
                    this.setDead();
                }
            }
        }
コード例 #9
0
    // フェードアウト
    void FadeOut()
    {
        if (!m_IsFadeOut)
        {
            return;
        }

        /* アルファ値を減らしていく */
        float minus = m_Speed / Time.deltaTime;

        m_Alpha -= minus;
        m_Alpha  = Clamp.ClampFloat(m_Alpha, 0, 1);

        /* 点滅有効なら、フェードアウト後にフェードインへ */
        if (!m_ChangeFade)
        {
            return;
        }

        if (m_Alpha <= 0)
        {
            FadeInStart();
        }
    }
コード例 #10
0
        public MoistureMapGenerator()
        {
            var noise = new Billow();

            noise.Seed        = new Random().Next();
            noise.Frequency   = 0.6f;
            noise.OctaveCount = 8;
            noise.Persistence = 0.1;

            var turbulence = new Turbulence();

            turbulence.Power     = 0.25;
            turbulence.Roughness = 3;
            turbulence.Frequency = 0.15;
            turbulence.Source0   = noise;

            var clamper = new Clamp();

            clamper.LowerBound = 0;
            clamper.UpperBound = 1;
            clamper.Source0    = turbulence;

            Module = clamper;
        }
コード例 #11
0
    // フェードイン
    void FadeIn()
    {
        if (!m_IsFadeIn)
        {
            return;
        }

        /* アルファ値を増やしていく */
        float plus = m_Speed / Time.deltaTime;

        m_Alpha += plus;
        m_Alpha  = Clamp.ClampFloat(m_Alpha, 0, 1);

        /* 点滅有効なら、フェードイン後にフェードアウトへ */
        if (!m_ChangeFade)
        {
            return;
        }

        if (m_Alpha >= 1)
        {
            FadeOutStart();
        }
    }
コード例 #12
0
        private void SetupRainfallNoise()
        {
            float      freqMultiplier = FreqMultiplier;
            ModuleBase input          = new Perlin(0.015f * freqMultiplier, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            input = new ScaleBias(0.5, 0.5, input);
            NoiseDebugUI.StorePlanetNoise(input, "basePerlin");
            ModuleBase moduleBase = new AbsLatitudeCurve(new SimpleCurve
            {
                {
                    0f,
                    1.12f
                },
                {
                    25f,
                    0.94f
                },
                {
                    45f,
                    0.7f
                },
                {
                    70f,
                    0.3f
                },
                {
                    80f,
                    0.05f
                },
                {
                    90f,
                    0.05f
                }
            }, 100f);

            NoiseDebugUI.StorePlanetNoise(moduleBase, "latCurve");
            noiseRainfall = new Multiply(input, moduleBase);
            float      num    = 0.000222222225f;
            float      num2   = -500f * num;
            ModuleBase input2 = new ScaleBias(num, num2, noiseElevation);

            input2 = new ScaleBias(-1.0, 1.0, input2);
            input2 = new Clamp(0.0, 1.0, input2);
            NoiseDebugUI.StorePlanetNoise(input2, "elevationRainfallEffect");
            noiseRainfall = new Multiply(noiseRainfall, input2);
            Func <double, double> processor = delegate(double val)
            {
                if (val < 0.0)
                {
                    val = 0.0;
                }
                if (val < 0.12)
                {
                    val = (val + 0.12) / 2.0;
                    if (val < 0.03)
                    {
                        val = (val + 0.03) / 2.0;
                    }
                }
                return(val);
            };

            noiseRainfall = new Arbitrary(noiseRainfall, processor);
            noiseRainfall = new Power(noiseRainfall, new Const(1.5));
            noiseRainfall = new Clamp(0.0, 999.0, noiseRainfall);
            NoiseDebugUI.StorePlanetNoise(noiseRainfall, "noiseRainfall before mm");
            noiseRainfall = new ScaleBias(4000.0, 0.0, noiseRainfall);
            SimpleCurve rainfallCurve = Find.World.info.overallRainfall.GetRainfallCurve();

            if (rainfallCurve != null)
            {
                noiseRainfall = new CurveSimple(noiseRainfall, rainfallCurve);
            }
        }
コード例 #13
0
 protected override IGenerator[] GetNewGenerators()
 {
     return(new IGenerator[]
     {
         /////////////////////////////////////////////////////
         // Keyboard Stuff
         /////////////////////////////////////////////////////
         new StoredBoolGenerator("Split Keyboard Axis", false)
         {
             PropertyName = "IsKeyboardAxisSensitivitySplit",
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, splits the keyboard's X- and Y-axis' sensitivity"
             }
         },
         new StoredFloatGenerator("Keyboard X-Axis Sensitivity", 0.5f)
         {
             Processor = Clamp <float> .Get(0, 1),
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "The keyboard's X-axis' sensitivity.",
                 "A value between 0 and 1."
             }
         },
         new StoredFloatGenerator("Keyboard Y-Axis Sensitivity", 0.5f)
         {
             Processor = Clamp <float> .Get(0, 1),
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "The keyboard's Y-axis' sensitivity.",
                 "A value between 0 and 1.",
                 "This value isn't used if <see cref=\"IsKeyboardAxisSensitivitySplit\"/> is false."
             }
         },
         new StoredBoolGenerator("Keyboard X-Axis is Inverted", false)
         {
             PropertyName = "IsKeyboardXAxisInverted",
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, inverts the keyboard's X-axis."
             }
         },
         new StoredBoolGenerator("Keyboard Y-Axis is Inverted", false)
         {
             PropertyName = "IsKeyboardYAxisInverted",
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, inverts the keyboard's Y-axis."
             }
         },
         /////////////////////////////////////////////////////
         // Mouse Stuff
         /////////////////////////////////////////////////////
         new StoredBoolGenerator("Split Mouse Axis", false)
         {
             PropertyName = "IsMouseAxisSensitivitySplit",
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, splits the mouse's X- and Y-axis' sensitivity"
             }
         },
         new StoredFloatGenerator("Mouse X-Axis Sensitivity", 0.5f)
         {
             Processor = Clamp <float> .Get(0, 1),
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "The mouse's X-axis' sensitivity.",
                 "A value between 0 and 1."
             }
         },
         new StoredFloatGenerator("Mouse Y-Axis Sensitivity", 0.5f)
         {
             Processor = Clamp <float> .Get(0, 1),
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "The keyboard's Y-axis' sensitivity.",
                 "A value between 0 and 1.",
                 "This value isn't used if <see cref=\"IsKeyboardAxisSensitivitySplit\"/> is false."
             }
         },
         new StoredBoolGenerator("Mouse X-Axis is Inverted", false)
         {
             PropertyName = "IsMouseXAxisInverted",
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, inverts the keyboard's X-axis."
             }
         },
         new StoredBoolGenerator("Mouse Y-Axis is Inverted", false)
         {
             PropertyName = "IsMouseYAxisInverted",
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, inverts the keyboard's Y-axis."
             }
         },
         /////////////////////////////////////////////////////
         // Scroll Wheel Stuff
         /////////////////////////////////////////////////////
         new StoredFloatGenerator("Scroll Wheel Sensitivity", 0.5f)
         {
             Processor = Clamp <float> .Get(0, 1),
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "The mouse' scroll wheel's sensitivity.",
                 "A value between 0 and 1."
             }
         },
         new StoredBoolGenerator("Scroll Wheel is Inverted", false)
         {
             PropertyName = "IsScrollWheelInverted",
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, inverts the mouse' scroll wheel."
             }
         },
         /////////////////////////////////////////////////////
         // Graphics Stuff
         /////////////////////////////////////////////////////
         new StoredBoolGenerator("Is Smooth Camera Enabled", false)
         {
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, enables smooth camera controls."
             }
         },
         new StoredBoolGenerator("Is Bobbing Camera Enabled", false)
         {
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, enables bobbing camera effect."
             }
         },
         new StoredBoolGenerator("Is Flashes Enabled", true)
         {
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, enables flashing graphic effects."
             }
         },
         new StoredBoolGenerator("Is Motion Blurs Enabled", true)
         {
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, enables motion blur graphic effects."
             }
         },
         new StoredBoolGenerator("Is Bloom Enabled", true)
         {
             SetterScope = AccessModifier.Internal,
             TooltipDocumentation = new string[]
             {
                 "If true, enables bloom graphic effects."
             }
         },
     });
 }
コード例 #14
0
        public static bool Prefix(Map map)
        {
            //if (!DefsUtil.Enable)
            //    return true;
            //if (!DefsUtil.EnableMountainSettings)
            //    return true;
            if (Settings.detectedImpassableMaps && map.TileInfo.hilliness == Hilliness.Impassable)
            {
                return(true);
            }

            NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z);
            ModuleBase input = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            input = new ScaleBias(0.5, 0.5, input);
            NoiseDebugUI.StoreNoiseRender(input, "elev base");
            float num = 1f;

            switch (map.TileInfo.hilliness)
            {
            case Hilliness.Flat:
                num = MapGenTuning.ElevationFactorFlat;
                break;

            case Hilliness.SmallHills:
                num = MapGenTuning.ElevationFactorSmallHills;
                break;

            case Hilliness.LargeHills:
                num = MapGenTuning.ElevationFactorLargeHills;
                break;

            case Hilliness.Mountainous:
                num = MapGenTuning.ElevationFactorMountains;
                break;

            case Hilliness.Impassable:
                num = MapGenTuning.ElevationFactorImpassableMountains;
                break;
            }
            input = new Multiply(input, new Const(num + MapSettings.Mountain.GetMultiplier()));
            NoiseDebugUI.StoreNoiseRender(input, "elev world-factored");
            if (map.TileInfo.hilliness == Hilliness.Mountainous || map.TileInfo.hilliness == Hilliness.Impassable)
            {
                ModuleBase input2 = new DistFromAxis((float)map.Size.x * 0.42f);
                input2 = new Clamp(0.0, 1.0, input2);
                input2 = new Invert(input2);
                input2 = new ScaleBias(1.0, 1.0, input2);
                Rot4 random;
                do
                {
                    random = Rot4.Random;
                }while (random == Find.World.CoastDirectionAt(map.Tile));
                if (random == Rot4.North)
                {
                    input2 = new Rotate(0.0, 90.0, 0.0, input2);
                    input2 = new Translate(0.0, 0.0, -map.Size.z, input2);
                }
                else if (random == Rot4.East)
                {
                    input2 = new Translate(-map.Size.x, 0.0, 0.0, input2);
                }
                else if (random == Rot4.South)
                {
                    input2 = new Rotate(0.0, 90.0, 0.0, input2);
                }
                else
                {
                    _ = random == Rot4.West;
                }
                NoiseDebugUI.StoreNoiseRender(input2, "mountain");
                input = new Add(input, input2);
                NoiseDebugUI.StoreNoiseRender(input, "elev + mountain");
            }
            float           b         = (map.TileInfo.WaterCovered ? 0f : float.MaxValue);
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 allCell in map.AllCells)
            {
                elevation[allCell] = Mathf.Min(input.GetValue(allCell), b);
            }
            ModuleBase input3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            input3 = new ScaleBias(0.5, 0.5, input3);
            NoiseDebugUI.StoreNoiseRender(input3, "noiseFert base");
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 allCell2 in map.AllCells)
            {
                fertility[allCell2] = input3.GetValue(allCell2);
            }
            return(false);
        }
コード例 #15
0
ファイル: MathHelper.cs プロジェクト: Michael-Zp/GraphicsWar
 return(new Vector2(Clamp(v.X, min, max), Clamp(v.Y, min, max)));
コード例 #16
0
 void Start()
 {
     Moving       = false;
     objTransform = transform;
     clamp        = gameObject.GetComponent <Clamp>();
 }
コード例 #17
0
ファイル: RavineNoises.cs プロジェクト: emipa606/TerraProject
        public static void WorkOnMapGenerator(Map map)
        {
            ModExt_Biome_GenStep_Ravine extRavine = map.Biome.GetModExtension <ModExt_Biome_GenStep_Ravine>();

            if (extRavine == null)
            {
                return;
            }

            string noiseLabel = "ravine " + map.Biome.defName;
            double xOffset    = map.Size.x / 2;
            double zOffset    = map.Size.z / 2;
            float  baseWidth  = Rand.Range(extRavine.ravineWidthMin, extRavine.ravineWidthMax);
            double modA       = Rand.Range(extRavine.modAMin, extRavine.modAMax);
            double modB       = Rand.Range(extRavine.modBMin, extRavine.modBMax);
            double modC       = Rand.Range(extRavine.modCMin, extRavine.modCMax);
            // Base noise
            ModuleBase moduleBase = new DistFromAxis((float)map.Size.x * baseWidth);

            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base core");
            moduleBase = new CurveAxis(modA, modB, modC, moduleBase);
            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base curved");
            moduleBase = new ScaleBias(extRavine.slopeFactor, -1.0, moduleBase);
            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base scale");
            if (extRavine.invert)
            {
                moduleBase = new Invert(moduleBase);
            }
            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base invert");
            moduleBase = new Clamp(0.0, 999, moduleBase);
            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base clamp");
            NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base");
            // Add offset variance
            float offsetVariance = (Rand.Value - 0.5f) * extRavine.relativeOffsetVariance + extRavine.relativeOffsetFixed;

            xOffset += map.Size.x * offsetVariance;
            zOffset += map.Size.z * offsetVariance;
            // Add random rotation variance
            double rotVariance = (Rand.Value - 0.5f) * extRavine.rotationVariance;
            // Get overall ravine direction
            Rot4 random;

            do
            {
                random = Rot4.Random;
            }while (random == Find.World.CoastDirectionAt(map.Tile));
            if (random == Rot4.North)
            {
                moduleBase = new Rotate(0.0, 270.0 + rotVariance, 0.0, moduleBase);
                moduleBase = new Translate(0.0, 0.0, zOffset, moduleBase);
            }
            else if (random == Rot4.West)
            {
                moduleBase = new Rotate(0.0, 180.0 + rotVariance, 0.0, moduleBase);
                moduleBase = new Translate(xOffset, 0.0, 0.0, moduleBase);
            }
            else if (random == Rot4.South)
            {
                moduleBase = new Rotate(0.0, 90.0 + rotVariance, 0.0, moduleBase);
                moduleBase = new Translate(0.0, 0.0, (-zOffset), moduleBase);
            }
            else if (random == Rot4.East)
            {
                moduleBase = new Rotate(0.0, 0.0 + rotVariance, 0.0, moduleBase);
                moduleBase = new Translate((-xOffset), 0.0, 0.0, moduleBase);
            }
            // Elevation noise scaling
            ModuleBase noiseElevation = new ScaleBias(extRavine.noiseElevationPreScale, extRavine.noiseElevationPreOffset, moduleBase);

            NoiseDebugUI.StoreNoiseRender(noiseElevation, noiseLabel + " elevation");
            // Fertility noise scaling
            ModuleBase noiseFertility = new ScaleBias(extRavine.noiseFertilityPreScale, extRavine.noiseFertilityPreOffset, moduleBase);

            NoiseDebugUI.StoreNoiseRender(noiseFertility, noiseLabel + " fertility");

            // Work on MapGenerator grid
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 cell in map.AllCells)
            {
                // Set elevation
                if (extRavine.calcElevationType == GenStepCalculationType.Set)
                {
                    elevation[cell] = noiseElevation.GetValue(cell) + extRavine.elevationPostOffset;
                }
                else if (extRavine.calcElevationType == GenStepCalculationType.Add)
                {
                    elevation[cell] += noiseElevation.GetValue(cell) + extRavine.elevationPostOffset;
                }
                // Set fertility
                if (extRavine.calcFertilityType == GenStepCalculationType.Set)
                {
                    fertility[cell] = noiseFertility.GetValue(cell) + extRavine.fertilityPostOffset;
                }
                else if (extRavine.calcFertilityType == GenStepCalculationType.Add)
                {
                    fertility[cell] += noiseFertility.GetValue(cell) + extRavine.fertilityPostOffset;
                }
            }
        }
コード例 #18
0
 public MTBClamp(IMTBNoise input)
 {
     _clamp = new Clamp(input.ModuleBase);
 }
コード例 #19
0
 public void MinTests()  // Make sure we apply minimum
 {
     Clamp.Value((uint)1, (uint)10, (uint)100).ShouldBe((uint)10);
 }
コード例 #20
0
 public void Close()
 {
     CurrentItem = null;
 }
コード例 #21
0
        public Node <INode> GetNode(string nodeName)
        {
            switch (nodeName)
            {
            case Absolute.NAME:
                INode nodeAbsolute = new Absolute() as INode;
                return(new Node <INode>(nodeAbsolute));

            case Approx.NAME:
                INode nodeAprox = new Approx() as INode;
                return(new Node <INode>(nodeAprox));

            case ArcCos.NAME:
                INode nodeArcCos = new ArcCos() as INode;
                return(new Node <INode>(nodeArcCos));

            case ArcSin.NAME:
                INode nodeArcSin = new ArcSin() as INode;
                return(new Node <INode>(nodeArcSin));

            case ArcTan2.NAME:
                INode nodeArcTan2 = new ArcTan2() as INode;
                return(new Node <INode>(nodeArcTan2));

            case Ceil.NAME:
                INode nodeCeil = new Ceil() as INode;
                return(new Node <INode>(nodeCeil));

            case CeilToInt.NAME:
                INode nodeCeilToInt = new CeilToInt() as INode;
                return(new Node <INode>(nodeCeilToInt));

            case Clamp.NAME:
                INode nodeClamp = new Clamp() as INode;
                return(new Node <INode>(nodeClamp));

            case Clamp01.NAME:
                INode nodeClamp01 = new Clamp01() as INode;
                return(new Node <INode>(nodeClamp01));

            case ClosestPowerOf2.NAME:
                INode nodeClosestPowerOf2 = new ClosestPowerOf2() as INode;
                return(new Node <INode>(nodeClosestPowerOf2));

            case Cosinus.NAME:
                INode nodeCosinus = new Cosinus() as INode;
                return(new Node <INode>(nodeCosinus));

            case DeltaAngle.NAME:
                INode nodeDeltaAngle = new DeltaAngle() as INode;
                return(new Node <INode>(nodeDeltaAngle));

            case Exp.NAME:
                INode nodeExp = new Exp() as INode;
                return(new Node <INode>(nodeExp));

            case Floor.NAME:
                INode nodeFloor = new Floor() as INode;
                return(new Node <INode>(nodeFloor));

            case FloorToInt.NAME:
                INode nodeFloorToInt = new FloorToInt() as INode;
                return(new Node <INode>(nodeFloorToInt));

            case Lerp.NAME:
                INode nodeLerp = new Lerp() as INode;
                return(new Node <INode>(nodeLerp));

            case LerpAngle.NAME:
                INode nodeLerpAngle = new LerpAngle() as INode;
                return(new Node <INode>(nodeLerpAngle));

            case Log10.NAME:
                INode nodeLog10 = new Log10() as INode;
                return(new Node <INode>(nodeLog10));

            case Logarithm.NAME:
                INode nodeLogarithm = new Logarithm() as INode;
                return(new Node <INode>(nodeLogarithm));

            case Sinus.NAME:
                INode nodeSinus_ = new Sinus() as INode;
                return(new Node <INode>(nodeSinus_));

            case Max.NAME:
                INode nodeMax = new Max() as INode;
                return(new Node <INode>(nodeMax));

            case Min.NAME:
                INode nodeMin = new Min() as INode;
                return(new Node <INode>(nodeMin));

            case MoveTowards.NAME:
                INode nodeMoveTowards = new MoveTowards() as INode;
                return(new Node <INode>(nodeMoveTowards));

            case MoveTowardsAngle.NAME:
                INode nodeMoveTowardsAngle = new MoveTowardsAngle() as INode;
                return(new Node <INode>(nodeMoveTowardsAngle));

            case NextPowerOfTwo.NAME:
                INode nodeNextPowerOfTwo = new NextPowerOfTwo() as INode;
                return(new Node <INode>(nodeNextPowerOfTwo));

            case PerlinNoise.NAME:
                INode nodePerlinNoise = new PerlinNoise() as INode;
                return(new Node <INode>(nodePerlinNoise));

            case PingPong.NAME:
                INode nodePingPong = new PingPong() as INode;
                return(new Node <INode> (nodePingPong));

            case Pow.NAME:
                INode nodePow = new Pow() as INode;
                return(new Node <INode>(nodePow));

            case SquareRoot.NAME:
                INode nodeSqrt = new SquareRoot() as INode;
                return(new Node <INode>(nodeSqrt));

            case Tan.NAME:
                INode nodeTan = new Tan() as INode;
                return(new Node <INode>(nodeTan));

            case Random.NAME:
                INode nodeRandom = new Random() as INode;
                return(new Node <INode>(nodeRandom));

            default:
                return(null);
            }
        }
コード例 #22
0
 public void MaxTests()
 {
     Clamp.Value((float)101, (float)10, (float)100).ShouldBe((float)100);
 }
コード例 #23
0
        public override void Generate(Map map)
        {
            IntVec3 size  = map.Size;
            int     x     = size.x;
            IntVec3 size2 = map.Size;

            NoiseRenderer.renderSize = new IntVec2(x, size2.z);
            ModuleBase input = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            input = new ScaleBias(0.5, 0.5, input);
            NoiseDebugUI.StoreNoiseRender(input, "elev base");
            float num = 1f;

            switch (map.TileInfo.hilliness)
            {
            case Hilliness.Flat:
                num = MapGenTuning.ElevationFactorFlat;
                break;

            case Hilliness.SmallHills:
                num = MapGenTuning.ElevationFactorSmallHills;
                break;

            case Hilliness.LargeHills:
                num = MapGenTuning.ElevationFactorLargeHills;
                break;

            case Hilliness.Mountainous:
                num = MapGenTuning.ElevationFactorMountains;
                break;

            case Hilliness.Impassable:
                num = MapGenTuning.ElevationFactorImpassableMountains;
                break;
            }
            input = new Multiply(input, new Const((double)num));
            NoiseDebugUI.StoreNoiseRender(input, "elev world-factored");
            if (map.TileInfo.hilliness != Hilliness.Mountainous && map.TileInfo.hilliness != Hilliness.Impassable)
            {
                goto IL_02b1;
            }
            IntVec3    size3  = map.Size;
            ModuleBase input2 = new DistFromAxis((float)((float)size3.x * 0.41999998688697815));

            input2 = new Clamp(0.0, 1.0, input2);
            input2 = new Invert(input2);
            input2 = new ScaleBias(1.0, 1.0, input2);
            Rot4 random;

            while (true)
            {
                random = Rot4.Random;
                if (!(random == Find.World.CoastDirectionAt(map.Tile)))
                {
                    break;
                }
            }
            if (random == Rot4.North)
            {
                input2 = new Rotate(0.0, 90.0, 0.0, input2);
                IntVec3 size4 = map.Size;
                input2 = new Translate(0.0, 0.0, (double)(-size4.z), input2);
            }
            else if (random == Rot4.East)
            {
                IntVec3 size5 = map.Size;
                input2 = new Translate((double)(-size5.x), 0.0, 0.0, input2);
            }
            else if (random == Rot4.South)
            {
                input2 = new Rotate(0.0, 90.0, 0.0, input2);
            }
            else if (!(random == Rot4.West))
            {
                goto IL_0291;
            }
            goto IL_0291;
IL_0291:
            NoiseDebugUI.StoreNoiseRender(input2, "mountain");
            input = new Add(input, input2);
            NoiseDebugUI.StoreNoiseRender(input, "elev + mountain");
            goto IL_02b1;
IL_02b1:
            float b = (float)((!map.TileInfo.WaterCovered) ? 3.4028234663852886E+38 : 0.0);
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 allCell in map.AllCells)
            {
                elevation[allCell] = Mathf.Min(input.GetValue(allCell), b);
            }
            ModuleBase input3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            input3 = new ScaleBias(0.5, 0.5, input3);
            NoiseDebugUI.StoreNoiseRender(input3, "noiseFert base");
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 allCell2 in map.AllCells)
            {
                fertility[allCell2] = input3.GetValue(allCell2);
            }
        }
コード例 #24
0
ファイル: OutOvenForm.cs プロジェクト: jtzhang163/TengDa
        private void OutOven(object obj)
        {
            string code = obj.ToString();

            Clamp clamp = Current.ovens[i].Floors[j].Clamps.Single(c => c.Code == code);

            string msg = string.Empty;

            lock (locker)
            {
                try
                {
                    if (Current.mes.IsAlive)
                    {
                        if (Current.mes.IsOffline)
                        {
                            Current.mes.IsOffline = false;
                        }

                        this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 正在上传料盒信息..."; this.lbTip.ForeColor = Color.LightGreen; }));
                        if (!MES.UploadCellInfo(clamp))
                        {
                            this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = string.Format("{0}: {1}", code, "上传失败"); this.lbTip.ForeColor = Color.Red; }));
                            LogHelper.WriteError(string.Format("{0}: {1}", code, "上传失败"));
                            return;
                        }
                        this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 上传MES成功"; this.lbTip.ForeColor = Color.LightGreen; }));
                        LogHelper.WriteInfo(code + " 上传MES成功");
                        Thread.Sleep(100);
                    }
                    else
                    {
                        if (TengDa.WF.Current.user.Group.Level > 2 && !Current.mes.IsOffline)
                        {
                            Current.mes.IsOffline = true;
                        }

                        if (!Current.mes.IsOffline)
                        {
                            MesOfflineVerify m = new MesOfflineVerify();

                            DialogResult dr = m.ShowDialog();
                            if (dr == DialogResult.OK)
                            {
                                if (!Current.mes.IsOffline)
                                {
                                    Current.mes.IsOffline = true;
                                }
                            }
                            else
                            {
                                Error.Alert("无法连接至MES,无法入腔!");
                                return;
                            }
                        }
                    }

                    Yield.BlankingOK += clamp.Batteries.Count;
                    Current.ovens[i].Floors[j].Clamps.Remove(clamp);
                    string clampids = string.Empty;
                    foreach (Clamp c in Current.ovens[i].Floors[j].Clamps)
                    {
                        clampids += c.Id + ",";
                    }
                    Current.ovens[i].Floors[j].ClampIds = clampids.TrimEnd(',');

                    this.BeginInvoke(new MethodInvoker(() =>
                    {
                        foreach (ListViewItem li in this.lvClampCodes.Items)
                        {
                            foreach (ListViewItem.ListViewSubItem subli in li.SubItems)
                            {
                                if (subli.Text == code)
                                {
                                    this.lvClampCodes.Items.Remove(li);
                                }
                            }
                        }
                    }));

                    clampCodes.Remove(code);
                }
                catch (Exception ex)
                {
                    Error.Alert(ex.ToString());
                }
            }
        }
コード例 #25
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);
            }
        }
コード例 #26
0
 public void MinTests()  // Make sure we apply minimum
 {
     Clamp.Value((float)1, (float)10.1, (float)100).ShouldBe((float)10.1);
 }
コード例 #27
0
        // Token: 0x0600003D RID: 61 RVA: 0x000033A0 File Offset: 0x000015A0
        public override void Generate(Map map, GenStepParams parms)
        {
            NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z);
            ModuleBase moduleBase = new Perlin(0.0209999997168779, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            moduleBase = new ScaleBias(0.5, 0.5, moduleBase);
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev base");
            float num = 1.8f;

            moduleBase = new Multiply(moduleBase, new Const((double)num));
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev world-factored");
            ModuleBase moduleBase2 = new DistFromAxis((float)map.Size.x * 0.42f);

            moduleBase2 = new Clamp(0.0, 1.0, moduleBase2);
            moduleBase2 = new Invert(moduleBase2);
            moduleBase2 = new ScaleBias(1.0, 1.0, moduleBase2);
            Rot4 random;

            do
            {
                random = Rot4.Random;
            }while (random == Find.World.CoastDirectionAt(map.Tile));
            bool flag = random == Rot4.North;

            if (flag)
            {
                moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2);
                moduleBase2 = new Translate(0.0, 0.0, -(double)map.Size.z, moduleBase2);
            }
            else
            {
                bool flag2 = random == Rot4.East;
                if (flag2)
                {
                    moduleBase2 = new Translate(-(double)map.Size.x, 0.0, 0.0, moduleBase2);
                }
                else
                {
                    bool flag3 = random == Rot4.South;
                    if (flag3)
                    {
                        moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2);
                    }
                    else
                    {
                        bool flag4 = random == Rot4.West;
                        if (flag4)
                        {
                        }
                    }
                }
            }
            NoiseDebugUI.StoreNoiseRender(moduleBase2, "mountain");
            moduleBase = new Add(moduleBase, moduleBase2);
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev + mountain");
            float           num2      = (!map.TileInfo.WaterCovered) ? 3.402823E+38f : 0f;
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 intVec in map.AllCells)
            {
                elevation[intVec] = Mathf.Min(moduleBase.GetValue(intVec), num2);
            }
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 c in map.AllCells)
            {
                fertility[c] = 0f;
            }
        }
コード例 #28
0
 public void InvalidMinMaxTests()
 {
     Should.Throw <ArgumentOutOfRangeException>(() => Clamp.Value((float)10, (float)100, (float)1));
 }
コード例 #29
0
        private void SetupRainfallNoise()
        {
            float      freqMultiplier = WorldGenStep_Terrain.FreqMultiplier;
            ModuleBase moduleBase     = new Perlin((double)(0.015f * freqMultiplier), 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            moduleBase = new ScaleBias(0.5, 0.5, moduleBase);
            NoiseDebugUI.StorePlanetNoise(moduleBase, "basePerlin");
            ModuleBase moduleBase2 = new AbsLatitudeCurve(new SimpleCurve
            {
                {
                    0f,
                    1.12f,
                    true
                },
                {
                    25f,
                    0.94f,
                    true
                },
                {
                    45f,
                    0.7f,
                    true
                },
                {
                    70f,
                    0.3f,
                    true
                },
                {
                    80f,
                    0.05f,
                    true
                },
                {
                    90f,
                    0.05f,
                    true
                }
            }, 100f);

            NoiseDebugUI.StorePlanetNoise(moduleBase2, "latCurve");
            this.noiseRainfall = new Multiply(moduleBase, moduleBase2);
            float      num         = 0.000222222225f;
            float      num2        = -500f * num;
            ModuleBase moduleBase3 = new ScaleBias((double)num, (double)num2, this.noiseElevation);

            moduleBase3 = new ScaleBias(-1.0, 1.0, moduleBase3);
            moduleBase3 = new Clamp(0.0, 1.0, moduleBase3);
            NoiseDebugUI.StorePlanetNoise(moduleBase3, "elevationRainfallEffect");
            this.noiseRainfall = new Multiply(this.noiseRainfall, moduleBase3);
            Func <double, double> processor = delegate(double val)
            {
                if (val < 0.0)
                {
                    val = 0.0;
                }
                if (val < 0.12)
                {
                    val = (val + 0.12) / 2.0;
                    if (val < 0.03)
                    {
                        val = (val + 0.03) / 2.0;
                    }
                }
                return(val);
            };

            this.noiseRainfall = new Arbitrary(this.noiseRainfall, processor);
            this.noiseRainfall = new Power(this.noiseRainfall, new Const(1.5));
            this.noiseRainfall = new Clamp(0.0, 999.0, this.noiseRainfall);
            NoiseDebugUI.StorePlanetNoise(this.noiseRainfall, "noiseRainfall before mm");
            this.noiseRainfall = new ScaleBias(4000.0, 0.0, this.noiseRainfall);
            SimpleCurve rainfallCurve = Find.World.info.overallRainfall.GetRainfallCurve();

            if (rainfallCurve != null)
            {
                this.noiseRainfall = new CurveSimple(this.noiseRainfall, rainfallCurve);
            }
        }
コード例 #30
0
        // Token: 0x06004083 RID: 16515 RVA: 0x0015444C File Offset: 0x0015264C
        public override void Generate(Map map, GenStepParams parms)
        {
            NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z);
            ModuleBase moduleBase = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            moduleBase = new ScaleBias(0.5, 0.5, moduleBase);
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev base");
            float num = 1f;

            switch (map.TileInfo.hilliness)
            {
            case Hilliness.Flat:
                num = MapGenTuning.ElevationFactorFlat;
                break;

            case Hilliness.SmallHills:
                num = MapGenTuning.ElevationFactorSmallHills;
                break;

            case Hilliness.LargeHills:
                num = MapGenTuning.ElevationFactorLargeHills;
                break;

            case Hilliness.Mountainous:
                num = MapGenTuning.ElevationFactorMountains;
                break;

            case Hilliness.Impassable:
                num = MapGenTuning.ElevationFactorImpassableMountains;
                break;
            }
            moduleBase = new Multiply(moduleBase, new Const((double)num));
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev world-factored");
            if (map.TileInfo.hilliness == Hilliness.Mountainous || map.TileInfo.hilliness == Hilliness.Impassable)
            {
                ModuleBase moduleBase2 = new DistFromAxis((float)map.Size.x * 0.42f);
                moduleBase2 = new Clamp(0.0, 1.0, moduleBase2);
                moduleBase2 = new Invert(moduleBase2);
                moduleBase2 = new ScaleBias(1.0, 1.0, moduleBase2);
                Rot4 random;
                do
                {
                    random = Rot4.Random;
                }while (random == Find.World.CoastDirectionAt(map.Tile));
                if (random == Rot4.North)
                {
                    moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2);
                    moduleBase2 = new Translate(0.0, 0.0, (double)(-(double)map.Size.z), moduleBase2);
                }
                else if (random == Rot4.East)
                {
                    moduleBase2 = new Translate((double)(-(double)map.Size.x), 0.0, 0.0, moduleBase2);
                }
                else if (random == Rot4.South)
                {
                    moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2);
                }
                else
                {
                    //random == Rot4.West;
                }
                NoiseDebugUI.StoreNoiseRender(moduleBase2, "mountain");
                moduleBase = new Add(moduleBase, moduleBase2);
                NoiseDebugUI.StoreNoiseRender(moduleBase, "elev + mountain");
            }
            float           b         = map.TileInfo.WaterCovered ? 0f : float.MaxValue;
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 intVec in map.AllCells)
            {
                elevation[intVec] = Mathf.Min(moduleBase.GetValue(intVec), b);
            }
            ModuleBase moduleBase3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            moduleBase3 = new ScaleBias(0.5, 0.5, moduleBase3);
            NoiseDebugUI.StoreNoiseRender(moduleBase3, "noiseFert base");
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 intVec2 in map.AllCells)
            {
                fertility[intVec2] = moduleBase3.GetValue(intVec2);
            }
        }
コード例 #31
0
    public static void genNoise(int channelId)
    {
        moduleBase[channelId] = new Perlin();
        if (teNoiseChanTypeIndex[channelId] == 1)
        {
            int tIdx = teNoiseTypeIndex[channelId];
            if (tIdx == 0) { moduleBase[channelId] = new Perlin(frequency[channelId], lacunarity[channelId], persistance[channelId], octaves[channelId], seed[channelId], QualityMode.High); }
            if (tIdx == 1) { moduleBase[channelId] = new Billow(frequency[channelId], lacunarity[channelId], persistance[channelId], octaves[channelId], seed[channelId], QualityMode.High); }
            if (tIdx == 2) { moduleBase[channelId] = new RidgedMultifractal(frequency[channelId], lacunarity[channelId], octaves[channelId], seed[channelId], QualityMode.High); }
            if (tIdx == 3) { moduleBase[channelId] = new Voronoi(frequency[channelId], displacement[channelId], seed[channelId], distance[channelId]); }
            if (tIdx == 4) { moduleBase[channelId] = new BrownianMotion(frequency[channelId], lacunarity[channelId], octaves[channelId], seed[channelId], QualityMode.High); }
            if (tIdx == 5) { moduleBase[channelId] = new HeterogeneousMultiFractal(frequency[channelId], lacunarity[channelId], octaves[channelId], persistance[channelId], seed[channelId], offset[channelId], QualityMode.High); }
            if (tIdx == 6) { moduleBase[channelId] = new HybridMulti(frequency[channelId], lacunarity[channelId], octaves[channelId], persistance[channelId], seed[channelId], offset[channelId], gain[channelId], QualityMode.High); }
            if (tIdx == 7) { moduleBase[channelId] = new LinearGradientNoise(frequency[channelId]); }
        }
        if (teNoiseChanTypeIndex[channelId] == 2)
        {
            int fIdx = teFunctionTypeIndex[channelId];
            if (fIdx == 0) { moduleBase[channelId] = new Add(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 1) { moduleBase[channelId] = new Subtract(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 2) { moduleBase[channelId] = new Multiply(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 3) { moduleBase[channelId] = new Min(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 4) { moduleBase[channelId] = new Max(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); }
            if (fIdx == 5) { moduleBase[channelId] = new Blend(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]], moduleBase[srcChannel3Id[channelId]]); }
            if (fIdx == 6) { moduleBase[channelId] = new Clamp((double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId], moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 7) { moduleBase[channelId] = new Power(moduleBase[srcChannel1Id[channelId]],moduleBase[srcChannel2Id[channelId]]);}
			if (fIdx == 8) { Curve tmpCurve = new Curve(moduleBase[srcChannel1Id[channelId]]);
				double adjust = double.Parse((controlpointcount[channelId]-1).ToString())*0.5;
				for(int i=0;i<controlpointcount[channelId];i++){
					tmpCurve.Add(double.Parse(i.ToString())-adjust,(double)cpval[channelId,i]);
					moduleBase[channelId] = tmpCurve;
				}
			}
			if(fIdx==9){Terrace tmpTerrace = new Terrace(invertTerrace[channelId],moduleBase[srcChannel1Id[channelId]]);
				for(int i=0;i<controlpointcount[channelId];i++){
					tmpTerrace.Add((double)cpval[channelId,i]-0.5);
					moduleBase[channelId] = tmpTerrace;
				}
			}
            if (fIdx == 18) { moduleBase[channelId] = new Mask(moduleBase[srcChannel1Id[channelId]], (double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId]); }
            if (fIdx == 17) { moduleBase[channelId] = new WindexWarp(moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 16) { moduleBase[channelId] = new TEWarp(moduleBase[srcChannel1Id[channelId]]); }
            if (fIdx == 15) { moduleBase[channelId] = new Select((double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId], falloff[channelId], moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]], moduleBase[srcChannel3Id[channelId]]); }
			if (fIdx == 14) { moduleBase[channelId] = new Turbulence(power[channelId],moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 13) { moduleBase[channelId] = new ScaleBias(scale[channelId],bias[channelId],moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 12) { moduleBase[channelId] = new Invert(moduleBase[srcChannel1Id[channelId]]);}
			if (fIdx == 11) { moduleBase[channelId] = new Exponent(exponent[channelId],moduleBase[srcChannel1Id[channelId]]); }
			if (fIdx == 10) { moduleBase[channelId] = new Abs(moduleBase[srcChannel1Id[channelId]]);}
		}
        int resolution = 64;
        int xoffset = 0; int yoffset = 0;
        m_noiseMap[channelId] = new Noise2D(resolution, resolution, moduleBase[channelId]);
        float x1 = xoffset * zoom[channelId];
        float x2 = (xoffset * zoom[channelId]) + ((zoom[channelId] / resolution) * (resolution + 1));
        float y1 = -yoffset * zoom[channelId];
        float y2 = (-yoffset * zoom[channelId]) + ((zoom[channelId] / resolution) * (resolution + 1));
        m_noiseMap[channelId].GeneratePlanar(x1, x2, y1, y2);
        m_textures[channelId] = m_noiseMap[channelId].GetTexture();
        m_textures[channelId].Apply();
    }