Exemplo n.º 1
0
        public override void Generate(Map map, GenStepParams parms)
        {
            ModuleBase chambers = new Perlin(0.010, 1.7, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            ModuleBase columns = new Perlin(0.150, 0.5, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            columns = new ScaleBias(0.5, 0.5, columns);

            // push columns to the centers of chambers
            ModuleBase columnsNoise = new Invert(chambers);

            columnsNoise = new ScaleBias(3f, -2f, columnsNoise);
            columnsNoise = new Min(new Const(0.0), columnsNoise);
            columns      = new Add(columns, columnsNoise);

            // broken tunnel network
            ModuleBase tunnels      = new Perlin(0.01, 1.7, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);
            ModuleBase tunnelsNoise = new Perlin(0.005, 0.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.Medium);

            tunnels = new Abs(tunnels);
            tunnels = new Add(new Const(0.5), tunnels);
            tunnels = new Add(tunnels, new Clamp(0, 0.5, tunnelsNoise));

            chambers = new Min(new Add(chambers, new Const(0.75)), tunnels);

            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 cell in map.AllCells)
            {
                elevation[cell] = Math.Max(columns.GetValue(cell), chambers.GetValue(cell));
            }
        }
Exemplo n.º 2
0
        private void Update(EvaluationContext context)
        {
            var v   = Value.GetValue(context);
            var min = Min.GetValue(context);
            var max = Max.GetValue(context);

            Result.Value = MathUtil.Clamp(v, min, max);
        }
Exemplo n.º 3
0
        private void Update(EvaluationContext context)
        {
            var min   = Min.GetValue(context);
            var max   = Max.GetValue(context);
            var input = this.Input.GetValue(context);

            Result.Value = (max - min) * input + min;
        }
        public override Color?GetBackgroundColor(decimal value, ConditionalFormatting conditionalFormatting)
        {
            var minValue = conditionalFormatting.GetMinValue();
            var maxValue = conditionalFormatting.GetMaxValue();
            var avgValue = Avg.GetValue(minValue, maxValue);

            var newMinValue = Min.GetValue(minValue, maxValue);

            if (newMinValue <= avgValue)
            {
                minValue = newMinValue;
            }

            var newMaxValue = Max.GetValue(minValue, maxValue);

            if (newMaxValue >= avgValue)
            {
                maxValue = newMaxValue;
            }

            if (maxValue == minValue)
            {
                if (value <= newMinValue && Min.Type == ConditionalFormattingVOType.Num)
                {
                    return(ColorMin);
                }

                if (value >= newMaxValue && Max.Type == ConditionalFormattingVOType.Num)
                {
                    return(ColorMax);
                }

                return(value < 0 ? ColorMin : ColorMax);
            }

            if (value <= minValue)
            {
                return(ColorMin);
            }

            if (value >= maxValue)
            {
                return(ColorMax);
            }

            if (value == avgValue)
            {
                return(ColorAvg);
            }

            if (value < avgValue)
            {
                return(MergeColors(value, minValue ?? 0, avgValue, ColorMin, ColorAvg));
            }

            return(MergeColors(value, avgValue, maxValue ?? 0, ColorAvg, ColorMax));
        }
Exemplo n.º 5
0
        public void MinTest(double a, double b)
        {
            var source0 = new Constant {
                ConstantValue = a
            };
            var source1 = new Constant {
                ConstantValue = b
            };
            var module = new Min {
                Source0 = source0, Source1 = source1
            };

            Assert.Equal(Math.Min(a, b), module.GetValue(0, 0, 0));
        }
        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);
            }
        }
Exemplo n.º 7
0
        public void MinTest()
        {
            var min = 0D;
            var max = 1D;

            var source0 = new Constant()
            {
                ConstantValue = min
            };
            var source1 = new Constant()
            {
                ConstantValue = max
            };
            var module = new Min()
            {
                Source0 = source0, Source1 = source1
            };

            Assert.AreEqual(min, module.GetValue(0, 0, 0));
        }
Exemplo n.º 8
0
        private void Update(EvaluationContext context)
        {
            var random         = new System.Random(Seed.GetValue(context));
            var firstIsGarbage = (float)random.NextDouble();

            Result.Value = (float)MathUtils.Remap((float)random.NextDouble(), 0f, 1f, Min.GetValue(context), Max.GetValue(context));
        }
Exemplo n.º 9
0
 public object MinValue()
 {
     return(Min.GetValue());
 }