static Building_GrowerBase_WorkTable()
 {
     cleanlinessCurve.Add(-5.0f, 5.00f);
     cleanlinessCurve.Add(-2.0f, 1.75f);
     cleanlinessCurve.Add(0.0f, 1.0f);
     cleanlinessCurve.Add(0.4f, 0.35f);
     cleanlinessCurve.Add(2.0f, 0.1f);
 }
コード例 #2
0
 public ConcreteManager(World world) : base(world)
 {
     concreteThingList = new Dictionary <Thing, int>();
     daysToHydrate     = Concrete.SettingInt["daysToHydrate"].Value;
     hydrateCurve.Add(new CurvePoint(0, 0));
     hydrateCurve.Add(new CurvePoint(daysToHydrate / 0.25f, 0.5f));
     hydrateCurve.Add(new CurvePoint(daysToHydrate, 1f));
 }
コード例 #3
0
            public static void DoCurveEditor(Rect screenRect, SimpleCurve curve, int decimalPlaces = 0, int displayMult = 100, string valueSuffix = "%", Action onChange = null)
            {
                Widgets.DrawMenuSection(screenRect);
                SimpleCurveDrawer.DrawCurve(screenRect, curve, null, null, default(Rect));
                Vector2 mousePosition    = Event.current.mousePosition - screenRect.position;
                Vector2 mouseCurveCoords = SimpleCurveDrawer.ScreenToCurveCoords(screenRect, curve.View.rect, mousePosition);

                if (Mouse.IsOver(screenRect))
                {
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
                    {
                        var clampedCoords = mouseCurveCoords;
                        clampedCoords.x = Mathf.Clamp(Mathf.Round(clampedCoords.x), 0, 20);
                        clampedCoords.y = Mathf.Clamp((float)Math.Round(clampedCoords.y, 2), 0, 1);
                        List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                        if (!curve.Any(point => point.x == clampedCoords.x))
                        {
                            list2.Add(new FloatMenuOption($"Add point at [{clampedCoords.x:F0} - {(clampedCoords.y * displayMult).ToString($"F{decimalPlaces}")}{valueSuffix}]", () =>
                            {
                                curve.Add(new CurvePoint(clampedCoords), true);
                                onChange?.Invoke();
                            }, MenuOptionPriority.Default, null, null, 0f, null, null, true, 0));
                        }
                        else
                        {
                            var existingPoint = curve.First(point => point.x == clampedCoords.x);

                            list2.Add(new FloatMenuOption($"Move point at [{existingPoint.x:F0} - {(existingPoint.y * displayMult).ToString($"F{decimalPlaces}")}{valueSuffix}] to [{clampedCoords.x:F0} - {(clampedCoords.y * displayMult).ToString($"F{decimalPlaces}")}{valueSuffix}]", () =>
                            {
                                curve.RemovePointNear(existingPoint);
                                curve.Add(new CurvePoint(clampedCoords), true);
                                onChange?.Invoke();
                            }, MenuOptionPriority.Default, null, null, 0f, null, null, true, 0));

                            if (Mathf.RoundToInt(existingPoint.x) != 0 && Mathf.RoundToInt(existingPoint.x) != 20)
                            {
                                list2.Add(new FloatMenuOption($"Remove point at [{existingPoint.x:F0} - {(existingPoint.y * displayMult).ToString($"F{decimalPlaces}")}{valueSuffix}]", () =>
                                {
                                    curve.RemovePointNear(existingPoint);
                                    onChange?.Invoke();
                                }, MenuOptionPriority.Default, null, null, 0f, null, null, true, 0));
                            }
                        }
                        Find.WindowStack.Add(new FloatMenu(list2));
                        Event.current.Use();
                    }
                }
            }
コード例 #4
0
 private static void UpdateCurve(PawnKeyframe key, float?curvePoint, SimpleCurve simpleCurve, float frameAt)
 {
     if (curvePoint.HasValue)
     {
         simpleCurve.Add(frameAt, curvePoint.Value);
     }
     else
     {
         // No value at 0 => add points to prevent the curve from bugging out
         if (key.KeyIndex == 0)
         {
             simpleCurve.Add(0, 0);
             simpleCurve.Add(1, 0);
         }
     }
 }
コード例 #5
0
        public static SimpleCurve CreateCurveFrom(List <Vector2> curvePoints)
        {
            SimpleCurve curve = new SimpleCurve();

            for (int i = 0; i < curvePoints.Count(); i++)
            {
                curve.Add(new CurvePoint(curvePoints[i]));
            }
            return(curve);
        }
コード例 #6
0
        private SimpleCurve ListToSimpleCurve(List <CurvePoint> list)
        {
            var curves = new SimpleCurve();

            foreach (var curvePoint in list)
            {
                curves.Add(curvePoint);
            }

            return(curves);
        }
コード例 #7
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            int ransomRaidDelay    = Mathf.RoundToInt(this.settings.ransomRaidDelay / (float)GenDate.TicksPerHour);
            int ransomFailCooldown = Mathf.RoundToInt(this.settings.ransomFailCooldown / (float)GenDate.TicksPerHour);

            Rect sliderSection = inRect.TopPart(0.7f);

            this.settings.ransomFactor = (int)Widgets.HorizontalSlider(rect: sliderSection.TopHalf().TopHalf().BottomHalf(), value: this.settings.ransomFactor, leftValue: 1f, rightValue: 5f, middleAlignment: true, label: "SettingsRansomFactor".Translate(this.settings.ransomFactor), leftAlignedLabel: "1", rightAlignedLabel: "5");
            ransomRaidDelay            = (int)Widgets.HorizontalSlider(rect: sliderSection.TopHalf().BottomHalf().TopHalf(), value: ransomRaidDelay, leftValue: 1f, rightValue: 168f, middleAlignment: true, label: "SettingsRansomRaidDelay".Translate(this.settings.ransomRaidDelay.ToStringTicksToPeriod()), leftAlignedLabel: "1", rightAlignedLabel: "168");
            ransomFailCooldown         = (int)Widgets.HorizontalSlider(rect: sliderSection.BottomHalf().TopHalf().TopHalf(), value: ransomFailCooldown, leftValue: ransomRaidDelay, rightValue: 336f, middleAlignment: true, label: "SettingsRansomFailCooldown".Translate(this.settings.ransomFailCooldown.ToStringTicksToPeriod()), leftAlignedLabel: ransomRaidDelay.ToString(), rightAlignedLabel: "336");
            this.settings.adjustment   = (int)Widgets.HorizontalSlider(rect: sliderSection.BottomHalf().BottomHalf().TopHalf(), value: this.settings.adjustment, leftValue: 40f, rightValue: 95f, middleAlignment: true, label: "SettingsRansomAdjustment".Translate(this.settings.adjustment), leftAlignedLabel: "40", rightAlignedLabel: "95");

            this.settings.ransomRaidDelay    = ransomRaidDelay * GenDate.TicksPerHour;
            this.settings.ransomFailCooldown = ransomFailCooldown * GenDate.TicksPerHour;

            SimpleCurve curve = new SimpleCurve();

            for (int i = -50; i <= 50; i++)
            {
                curve.Add(i, RansomSettings.RansomChanceRaw(-75, 10, i) * 100);
            }

            SimpleCurveDrawInfo drawInfo = new SimpleCurveDrawInfo()
            {
                curve  = curve,
                color  = Color.cyan,
                label  = "LABEL",
                labelY = "Prob"
            };

            SimpleCurveDrawer.DrawCurve(inRect.BottomPart(0.3f), drawInfo, new SimpleCurveDrawerStyle
            {
                DrawBackground      = false,
                DrawBackgroundLines = false,
                DrawCurveMousePoint = true,
                DrawLegend          = true,
                DrawMeasures        = true,
                DrawPoints          = false,
                FixedScale          = new Vector2(0, 100),
                FixedSection        = new FloatRange(-50, 50),
                LabelX = "Adj",
                MeasureLabelsXCount      = 10,
                MeasureLabelsYCount      = 10,
                OnlyPositiveValues       = false,
                PointsRemoveOptimization = false,
                UseAntiAliasedLines      = true,
                UseFixedScale            = true,
                UseFixedSection          = true,
                XIntegersOnly            = true,
                YIntegersOnly            = true
            });
        }
コード例 #8
0
 static CE_Utility()
 {
     lightingCurve.Add(05.00f, 0.05f);
     lightingCurve.Add(10.00f, 0.15f);
     lightingCurve.Add(22.00f, 0.475f);
     lightingCurve.Add(35.00f, 1.00f);
     lightingCurve.Add(60.00f, 1.20f);
     lightingCurve.Add(90.00f, 2.00f);
 }
コード例 #9
0
        private void SetupRainfallNoise()
        {
            float      freqMultiplier = WorldGenStep_Terrain.FreqMultiplier;
            ModuleBase input          = new Perlin(0.014999999664723873 * freqMultiplier, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            input = new ScaleBias(0.5, 0.5, input);
            NoiseDebugUI.StorePlanetNoise(input, "basePerlin");
            SimpleCurve simpleCurve = new SimpleCurve();

            simpleCurve.Add(0f, 1.12f, true);
            simpleCurve.Add(25f, 0.94f, true);
            simpleCurve.Add(45f, 0.7f, true);
            simpleCurve.Add(70f, 0.3f, true);
            simpleCurve.Add(80f, 0.05f, true);
            simpleCurve.Add(90f, 0.05f, true);
            ModuleBase moduleBase = new AbsLatitudeCurve(simpleCurve, 100f);

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

            input2 = new ScaleBias(-1.0, 1.0, input2);
            input2 = new Clamp(0.0, 1.0, input2);
            NoiseDebugUI.StorePlanetNoise(input2, "elevationRainfallEffect");
            this.noiseRainfall = new Multiply(this.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);
            };

            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);
            }
        }
コード例 #10
0
 static StatWorker_Flammability()
 {
     HumidityCurve.Add(0, 2);
     HumidityCurve.Add(0.5f, 1);
     HumidityCurve.Add(1, 0.625f);
 }
コード例 #11
0
        private void SimpleCurveEditor(Listing_Standard listing_Standard, ref SimpleCurve curve)
        {
            float lastx = 0;
            for (var num = 0; num < curve.PointsCount; num++)
            {
                var point = curve.Points[num];

                var rect1 = listing_Standard.GetRect(Text.LineHeight);
                rect1.width = (rect1.width - 55) / 2;
                var rect2 = new Rect(rect1)
                {
                    x = rect1.xMax + 5
                };
                var rect3 = new Rect(rect1)
                {
                    width = 20,
                    x = rect2.xMax + 5
                };
                var rect4 = new Rect(rect3)
                {
                    x = rect3.xMax + 5
                };

                var x = point.x;
                if (x <= lastx)
                {
                    x = lastx + 1f;
                }

                //string buffer2 = x.ToString();
                x = Widgets.HorizontalSlider(rect1, x, 0, 5000f, false, "DaysDescription".Translate() + ": " + x, null,
                    null, 1);
                //listing_Standard.Label("DaysDescription".Translate() + ": " + x);
                //listing_Standard.Slider(x, 0, 10000f);
                //Widgets.TextFieldNumeric<float>(rect2, ref y, ref buffer2, min, max);


                var y = point.y;
                var ypercent = y * 100;
                //string buffer1 = y.ToString();
                ypercent = Widgets.HorizontalSlider(rect2, ypercent, 0, 10000f, false,
                    "PercentDescription".Translate() + ": " + ypercent + "%", null, null, 1);
                //listing_Standard.Label("PercentDescription".Translate() + ": " + ypercent + "%");
                //listing_Standard.Slider(ypercent, 0, 1000f);
                y = ypercent / 100;
                //Widgets.TextFieldNumeric<float>(rect1, ref x, ref buffer1, min, max);

                if (x != point.x || y != point.y)
                {
                    curve.Points[num] = new CurvePoint(x, y);
                    curve.View.SetViewRectAround(curve);
                }

                if (Widgets.ButtonText(rect3, "+"))
                {
                    curve.Add(new CurvePoint(point));
                    curve.View.SetViewRectAround(curve);
                }

                if (Widgets.ButtonText(rect4, "-"))
                {
                    //curves.RemovePointNear(point);
                    curve.Points.RemoveAt(num);
                    if (curve.PointsCount == 0)
                    {
                        curve.Add(0, 1);
                    }

                    curve.View.SetViewRectAround(curve);
                }

                listing_Standard.Gap(listing_Standard.verticalSpacing);
                lastx = x;
            }
        }
コード例 #12
0
 public SoundParameterMapping()
 {
     curve = new SimpleCurve();
     curve.Add(new CurvePoint(0f, 0f));
     curve.Add(new CurvePoint(1f, 1f));
 }
コード例 #13
0
 static StatWorker_Flammability()
 {
     HumidityCurve.Add(0, FireSpread.values.flammabilityHumidityMin);
     HumidityCurve.Add(0.5f, FireSpread.values.flammabilityHumidityHalf);
     HumidityCurve.Add(1, FireSpread.values.flammabilityHumidityMax);
 }
コード例 #14
0
        void DrawUI(Rect rect)
        {
            const float PADDING = 5f;

            draggableIndex = 0;
            float topHeight    = rect.height * VerticalSplit;
            Rect  topArea      = new Rect(rect.x, rect.y, rect.width, topHeight);
            float bottomHeight = rect.height - topHeight;
            Rect  bottomArea   = new Rect(rect.x, rect.y + topHeight, rect.width, bottomHeight);

            // Net power.
            float  netWatts    = 123.5f;
            string netPowerTxt = PowerConvert.GetPrettyPower(netWatts);

            Text.Font = GameFont.Medium;
            var txtSize = Text.CalcSize(netPowerTxt);

            Widgets.Label(new Rect(rect.xMax - txtSize.x - PADDING, rect.y + PADDING, txtSize.x, txtSize.y), netPowerTxt);

            // Vertical slide.
            float vertSize = Mathf.Clamp(Draggable(new Vector2(rect.x, rect.y + topHeight), rect.width, 0) - rect.y, MinVerticalSize, rect.height - MinVerticalSize);

            VerticalSplit = vertSize / rect.height;

            // First section slide.
            float maxSecAWidth = rect.width - SectionCWidth() - MinSectionWidth;

            SectionAWidth = Mathf.Clamp(Draggable(new Vector2(rect.x + SectionAWidth, rect.y + topHeight), 0f, bottomHeight, () =>
            {
                sectionBStart = SectionBWidth;
                sectionAStart = SectionAWidth;
            }) - rect.x, MinSectionWidth, maxSecAWidth);
            if (IsDragging())
            {
                float deltaA    = SectionAWidth - sectionAStart;
                float adjustedB = sectionBStart - deltaA;
                SectionBWidth = adjustedB;
            }

            // Second section slide.
            float cWidth = rect.xMax - Draggable(new Vector2(rect.x + SectionAWidth + SectionBWidth, rect.y + topHeight), 0f, bottomHeight);
            float bWidth = rect.width - cWidth - SectionAWidth;

            SectionBWidth = Mathf.Clamp(bWidth, MinSectionWidth, rect.width - SectionAWidth - MinSectionWidth);

            Rect sectionA = new Rect(rect.x, rect.y + topHeight, SectionAWidth, bottomHeight);
            Rect sectionB = new Rect(rect.x + SectionAWidth, rect.y + topHeight, SectionBWidth, bottomHeight);
            Rect sectionC = new Rect(rect.x + SectionAWidth + SectionBWidth, rect.y + topHeight, SectionCWidth(), bottomHeight);

            List <SimpleCurveDrawInfo> curves = new List <SimpleCurveDrawInfo>();
            var curve  = new SimpleCurve();
            var curve2 = new SimpleCurve();

            for (int i = 0; i < 100; i++)
            {
                float x  = i;
                float y  = x * x;
                float y2 = x * 80;

                curve.Add(new CurvePoint(x, y));
                curve2.Add(new CurvePoint(x, y2));
            }

            var drawInfo = new SimpleCurveDrawInfo();

            drawInfo.curve = curve;
            drawInfo.color = Color.cyan;
            drawInfo.label = "Power Production";
            curves.Add(drawInfo);

            var drawInfo2 = new SimpleCurveDrawInfo();

            drawInfo2.curve = curve2;
            drawInfo2.color = Color.red;
            drawInfo2.label = "Power Consumption";
            curves.Add(drawInfo2);

            var style = new SimpleCurveDrawerStyle();

            //style.UseFixedScale = true;
            style.DrawBackground      = true;
            style.DrawLegend          = true;
            style.DrawMeasures        = true;
            style.DrawPoints          = false;
            style.DrawCurveMousePoint = true;
            style.UseAntiAliasedLines = true;

            SimpleCurveDrawer.DrawCurves(topArea, curves, style);

            //GUI.Box(rect, "");
            GUI.Box(topArea, "");
            GUI.Box(sectionA, "");
            GUI.Box(sectionB, "");
            GUI.Box(sectionC, "");

            float SectionCWidth()
            {
                return(rect.width - SectionAWidth - SectionBWidth);
            }
        }
コード例 #15
0
        public override void ExposeData()
        {
            base.ExposeData();

            if (Scribe.mode == LoadSaveMode.Saving)
            {
                if (CustomCurve != null)
                {
                    values = new List <SimpleCurveValues>(CustomCurve.PointsCount);
                    foreach (CurvePoint p in CustomCurve)
                    {
                        values.Add(
                            new SimpleCurveValues()
                        {
                            StartLevel = p.x,
                            ExpNeeded  = p.y
                        });
                    }
                }
            }

            Scribe_Values.Look <bool>(ref AllowSkillLoss, "ChangeSkillLevel.AllowSkillLoss", true, true);
            Scribe_Values.Look <bool>(ref AdjustSkillLossCaps, "ChangeSkillLevel.AdjustSkillLossCaps", false, true);
            Scribe_Collections.Look(ref SkillLossCaps, "ChangeSkillLevel.SkillLossCaps", LookMode.Value, new object[0]);
            Scribe_Values.Look <bool>(ref CanLoseLevel, "ChangeSkillLevel.CanLoseLevel", false, true);
            Scribe_Values.Look <bool>(ref HasCustomCurve, "ChangeSkillLevel.HasCustomCurve", false, true);
            Scribe_Collections.Look(ref this.values, "ChangeSkillLevel.CurvePoints", LookMode.Deep, new object[0]);

            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                if (HasCustomCurve)
                {
                    if (this.values == null || this.values.Count == 0)
                    {
                        HasCustomCurve = false;
                    }
                    else
                    {
                        CustomCurve = new SimpleCurve();
                        foreach (SimpleCurveValues v in this.values)
                        {
                            CustomCurve.Add(new CurvePoint(v.StartLevel, v.ExpNeeded));
                        }
                    }
                }
            }

            if ((Scribe.mode == LoadSaveMode.PostLoadInit || Scribe.mode == LoadSaveMode.Saving) &&
                this.values != null)
            {
                this.values.Clear();
                this.values = null;
            }

            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                if (SkillLossCaps == null)
                {
                    RepopulateSkillLossCaps();
                }
            }
        }
コード例 #16
0
        private static void FertChangeTbf(List <TBF> listTbf)
        {
            MapDesignerSettings     settings = MapDesignerMod.mod.settings;
            List <TerrainThreshold> newTbf   = new List <TerrainThreshold>();
            float rangeSize = maxMapFert - minMapFert;
            List <TerrainThreshold> oldTbf = oldTerrain.terrainsByFertility;

            // the actual adjustments
            listTbf.Sort((x, y) => x.thresh.terrain.fertility.CompareTo(y.thresh.terrain.fertility));
            float minFert = -1;
            float maxFert = -1;

            if (listTbf.Any(t => !t.thresh.terrain.IsWater))
            {
                if (listTbf.Where(t => !t.thresh.terrain.IsWater).Max(t => t.thresh.terrain.fertility) != listTbf.Where(t => !t.thresh.terrain.IsWater).Min(t => t.thresh.terrain.fertility))
                {
                    minFert = listTbf.Where(t => !t.thresh.terrain.IsWater).Min(t => t.thresh.terrain.fertility);
                    maxFert = listTbf.Where(t => !t.thresh.terrain.IsWater).Max(t => t.thresh.terrain.fertility);
                }
            }
            for (int i = 0; i < listTbf.Count(); i++)
            {
                //if(listTbf[i].thresh.terrain.IsWater)
                //{
                //    Log.Message(String.Format("{0} is water", listTbf[i].thresh.terrain.defName));
                //}
                //else
                //{
                //    Log.Message(String.Format("----------{0} is NOT water", listTbf[i].thresh.terrain.defName));
                //}

                //fert
                if (listTbf[i].thresh.terrain.fertility == maxFert && !listTbf[i].thresh.terrain.IsWater)
                {
                    listTbf[i].size *= settings.terrainFert;
                    //Log.Message(String.Format("stretching {0}", listTbf[i].thresh.terrain.defName));
                }
                else if (listTbf[i].thresh.terrain.fertility == minFert && !listTbf[i].thresh.terrain.IsWater)
                {
                    listTbf[i].size /= settings.terrainFert;
                    //Log.Message(String.Format("---- SHRINKING {0}", listTbf[i].thresh.terrain.defName));
                }
                //water
                if (listTbf[i].thresh.terrain.IsWater)
                {
                    listTbf[i].size *= settings.terrainWater;
                }
                else if (settings.flagTerrainWater && !listTbf[i].thresh.terrain.affordances.Contains(TerrainAffordanceDefOf.Heavy))
                {
                    listTbf[i].size *= settings.terrainWater;
                }
            }

            listTbf = listTbf.OrderBy(t => t.thresh.min).ToList();

            newTbf = SquishTerrain(listTbf, minMapFert, maxMapFert);

            // adjust patchmaker min max
            newTbf.Sort((x, y) => x.min.CompareTo(y.min));
            oldTbf.Sort((x, y) => x.min.CompareTo(y.min));

            SimpleCurve curve = new SimpleCurve();

            for (int i = 0; i < oldTbf.Count(); i++)
            {
                curve.Add(new CurvePoint(oldTbf[i].min, newTbf[i].min));
            }
            curve.Add(new CurvePoint(oldTbf.Last().max, newTbf.Last().max));

            foreach (TerrainPatchMaker patchMaker in newTerrain.terrainPatchMakers)
            {
                patchMaker.minFertility = curve.Evaluate(patchMaker.minFertility);
                patchMaker.maxFertility = curve.Evaluate(patchMaker.maxFertility);
            }

            newTerrain.terrainsByFertility = newTbf;
        }