コード例 #1
0
        public static bool WouldBeLeftToDie(Pawn p, int tile)
        {
            if (p.Downed)
            {
                return(true);
            }
            if (p.health.hediffSet.BleedRateTotal > 0.4f)
            {
                return(true);
            }
            if (tile != -1)
            {
                float f = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, GenLocalDate.Twelfth(p));
                if (!p.SafeTemperatureRange().Includes(f))
                {
                    return(true);
                }
            }
            List <Hediff> hediffs = p.health.hediffSet.hediffs;

            for (int i = 0; i < hediffs.Count; i++)
            {
                HediffStage curStage = hediffs[i].CurStage;
                if (curStage != null && curStage.lifeThreatening)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        protected override float TemperatureForTile(int tileId)
        {
            var y = Find.WorldGrid.LongLatOf(tileId).y;

            var celsiusTemp =
                GenTemperature.AverageTemperatureAtTileForTwelfth(tileId, Season.Summer.GetMiddleTwelfth(y));

            return(celsiusTemp);
        }
コード例 #3
0
        public override void Generate(Map map)
        {
            int num = 0;

            for (int i = (int)(GenLocalDate.Twelfth(map) - Twelfth.Third); i <= (int)GenLocalDate.Twelfth(map); i++)
            {
                int num2 = i;
                if (num2 < 0)
                {
                    num2 += 12;
                }
                Twelfth twelfth = (Twelfth)num2;
                float   num3    = GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth);
                if (num3 < 0f)
                {
                    num++;
                }
            }
            float num4 = 0f;

            switch (num)
            {
            case 0:
                return;

            case 1:
                num4 = 0.3f;
                break;

            case 2:
                num4 = 0.7f;
                break;

            case 3:
                num4 = 1f;
                break;
            }
            if (map.mapTemperature.SeasonalTemp > 0f)
            {
                num4 *= 0.4f;
            }
            if ((double)num4 < 0.3)
            {
                return;
            }
            foreach (IntVec3 current in map.AllCells)
            {
                if (!current.Roofed(map))
                {
                    map.steadyAtmosphereEffects.AddFallenSnowAt(current, num4);
                }
            }
        }
コード例 #4
0
        public override void Generate(Map map, GenStepParams parms)
        {
            int num = 0;

            for (int i = (int)(GenLocalDate.Twelfth(map) - 2); i <= (int)GenLocalDate.Twelfth(map); i++)
            {
                int num2 = i;
                if (num2 < 0)
                {
                    num2 += 12;
                }
                Twelfth twelfth = (Twelfth)num2;
                float   num3    = GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth);
                if (num3 < 0f)
                {
                    num++;
                }
            }
            float num4 = 0f;

            switch (num)
            {
            case 0:
                return;

            case 1:
                num4 = 0.3f;
                break;

            case 2:
                num4 = 0.7f;
                break;

            case 3:
                num4 = 1f;
                break;
            }
            if (map.mapTemperature.SeasonalTemp > 0f)
            {
                num4 *= 0.4f;
            }
            if (!((double)num4 < 0.3))
            {
                foreach (IntVec3 allCell in map.AllCells)
                {
                    if (!allCell.Roofed(map))
                    {
                        map.steadyEnvironmentEffects.AddFallenSnowAt(allCell, num4);
                    }
                }
            }
        }
コード例 #5
0
        private static NeededWarmth ApparelWarmthNeededNow(Pawn pawn, PawnGenerationRequest request, out float mapTemperature)
        {
            int tile = request.Tile;

            if (tile == -1)
            {
                Map anyPlayerHomeMap = Find.AnyPlayerHomeMap;
                if (anyPlayerHomeMap != null)
                {
                    tile = anyPlayerHomeMap.Tile;
                }
            }
            NeededWarmth result;

            if (tile == -1)
            {
                mapTemperature = 21f;
                result         = NeededWarmth.Any;
            }
            else
            {
                NeededWarmth neededWarmth = NeededWarmth.Any;
                Twelfth      twelfth      = GenLocalDate.Twelfth(tile);
                mapTemperature = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, twelfth);
                for (int i = 0; i < 2; i++)
                {
                    NeededWarmth neededWarmth2 = PawnApparelGenerator.CalculateNeededWarmth(pawn, tile, twelfth);
                    if (neededWarmth2 != NeededWarmth.Any)
                    {
                        neededWarmth = neededWarmth2;
                        break;
                    }
                    twelfth = twelfth.NextTwelfth();
                }
                if (pawn.kindDef.apparelIgnoreSeasons)
                {
                    if (request.ForceAddFreeWarmLayerIfNeeded && neededWarmth == NeededWarmth.Warm)
                    {
                        result = neededWarmth;
                    }
                    else
                    {
                        result = NeededWarmth.Any;
                    }
                }
                else
                {
                    result = neededWarmth;
                }
            }
            return(result);
        }
コード例 #6
0
        private static float AlertNeedWarmClothes_LowestTemperatureComing(Map map)
        {
            Twelfth twelfth = GenLocalDate.Twelfth(map);
            float   a       = GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth);

            for (int i = 0; i < 3; i++)
            {
                twelfth = twelfth.NextTwelfth();
                a       = Mathf.Min(a, GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth));
            }

            return(Mathf.Min(a, map.mapTemperature.OutdoorTemp));
        }
コード例 #7
0
ファイル: DateNotifier.cs プロジェクト: KraigXu/GameProject
        private bool AnyPlayerHomeAvgTempIsLowInWinter()
        {
            List <Map> maps = Find.Maps;

            for (int i = 0; i < maps.Count; i++)
            {
                if (maps[i].IsPlayerHome && GenTemperature.AverageTemperatureAtTileForTwelfth(maps[i].Tile, Season.Winter.GetMiddleTwelfth(Find.WorldGrid.LongLatOf(maps[i].Tile).y)) < 8f)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #8
0
            public CachedTileTemperatureData(int tile)
            {
                this.tile = tile;
                int seed = Gen.HashCombineInt(tile, 199372327);

                this.dailyVariationPerlinCached = new Perlin(5.0000000745058062E-06, 2.0, 0.5, 3, seed, QualityMode.Medium);
                this.twelfthlyTempAverages      = new float[12];
                for (int i = 0; i < 12; i++)
                {
                    this.twelfthlyTempAverages[i] = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, (Twelfth)i);
                }
                this.CheckCache();
            }
コード例 #9
0
        public static NeededWarmth CalculateNeededWarmth(Pawn pawn, int tile, Twelfth twelfth)
        {
            float num = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, twelfth);

            if (num < pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin) - 4f)
            {
                return(NeededWarmth.Warm);
            }
            if (num > pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin) + 4f)
            {
                return(NeededWarmth.Cool);
            }
            return(NeededWarmth.Any);
        }
コード例 #10
0
        public static NeededWarmth CalculateNeededWarmth(Pawn pawn, int tile, Twelfth twelfth)
        {
            float        num = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, twelfth);
            NeededWarmth result;

            if (num < pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null) - 4f)
            {
                result = NeededWarmth.Warm;
            }
            else if (num > pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null) + 4f)
            {
                result = NeededWarmth.Cool;
            }
            else
            {
                result = NeededWarmth.Any;
            }
            return(result);
        }
コード例 #11
0
        public static void ApparelScoreRaw_Postfix(Pawn pawn, Apparel ap, ref float __result)
        {
            //NeededWarmth neededCold = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn));

            float num = GenTemperature.AverageTemperatureAtTileForTwelfth(pawn.Map.Tile, GenLocalDate.Twelfth(pawn));

            SimpleCurve InsulationHeatScoreFactorCurve_NeedCold = new SimpleCurve
            {
                {
                    new CurvePoint(0f, 1f),
                    true
                },
                {
                    new CurvePoint(30f, 8f),
                    true
                }
            };


            // This version uses ComfyTemperatureMax to find if needCool, not comfyTemperatureMin
            if (num < pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax, null) - 4f)
            {
                float statValue  = ap.GetStatValue(StatDefOf.Insulation_Heat, true);
                float coldFactor = 1f;
                coldFactor *= InsulationHeatScoreFactorCurve_NeedCold.Evaluate(statValue);

                __result *= coldFactor;
            }



            //if (neededCold == NeededWarmth.Cool)
            //{
            //    float statValue = ap.GetStatValue(StatDefOf.Insulation_Heat, true);
            //    float coldFactor = 1f;
            //    coldFactor *= InsulationHeatScoreFactorCurve_NeedCold.Evaluate(statValue);

            //    __result *= coldFactor;
            //}
        }
コード例 #12
0
 private float GetTemperature(Twelfth twelfth, [NotNull] Map map)
 {
     return(GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth));
 }
コード例 #13
0
        public override void DoWindowContents(Rect inRect)
        {
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.ColumnWidth = 200f;
            listing_Standard.Begin(inRect.AtZero());
            Text.Font = GameFont.Medium;
            listing_Standard.Label("MapSize".Translate(), -1f, null);
            Text.Font = GameFont.Small;
            IEnumerable <int> enumerable = Dialog_AdvancedGameConfig.MapSizes.AsEnumerable <int>();

            if (Prefs.TestMapSizes)
            {
                enumerable = enumerable.Concat(Dialog_AdvancedGameConfig.TestMapSizes);
            }
            foreach (int num in enumerable)
            {
                if (num == 200)
                {
                    listing_Standard.Label("MapSizeSmall".Translate(), -1f, null);
                }
                else if (num == 250)
                {
                    listing_Standard.Gap(10f);
                    listing_Standard.Label("MapSizeMedium".Translate(), -1f, null);
                }
                else if (num == 300)
                {
                    listing_Standard.Gap(10f);
                    listing_Standard.Label("MapSizeLarge".Translate(), -1f, null);
                }
                else if (num == 350)
                {
                    listing_Standard.Gap(10f);
                    listing_Standard.Label("MapSizeExtreme".Translate(), -1f, null);
                }
                string label = "MapSizeDesc".Translate(new object[]
                {
                    num,
                    num * num
                });
                if (listing_Standard.RadioButton(label, Find.GameInitData.mapSize == num, 0f))
                {
                    Find.GameInitData.mapSize = num;
                }
            }
            listing_Standard.NewColumn();
            Text.Font = GameFont.Medium;
            listing_Standard.Label("MapStartSeason".Translate(), -1f, null);
            Text.Font = GameFont.Small;
            listing_Standard.Label("", -1f, null);
            if (listing_Standard.RadioButton("MapStartSeasonDefault".Translate(), Find.GameInitData.startingSeason == Season.Undefined, 0f))
            {
                Find.GameInitData.startingSeason = Season.Undefined;
            }
            if (listing_Standard.RadioButton(Season.Spring.LabelCap(), Find.GameInitData.startingSeason == Season.Spring, 0f))
            {
                Find.GameInitData.startingSeason = Season.Spring;
            }
            if (listing_Standard.RadioButton(Season.Summer.LabelCap(), Find.GameInitData.startingSeason == Season.Summer, 0f))
            {
                Find.GameInitData.startingSeason = Season.Summer;
            }
            if (listing_Standard.RadioButton(Season.Fall.LabelCap(), Find.GameInitData.startingSeason == Season.Fall, 0f))
            {
                Find.GameInitData.startingSeason = Season.Fall;
            }
            if (listing_Standard.RadioButton(Season.Winter.LabelCap(), Find.GameInitData.startingSeason == Season.Winter, 0f))
            {
                Find.GameInitData.startingSeason = Season.Winter;
            }
            listing_Standard.NewColumn();
            Text.Font = GameFont.Medium;
            listing_Standard.Label("Notice".Translate(), -1f, null);
            Text.Font = GameFont.Small;
            listing_Standard.Label("", -1f, null);
            bool flag = false;

            if (this.selTile >= 0 && Find.GameInitData.startingSeason != Season.Undefined)
            {
                float y = Find.WorldGrid.LongLatOf(this.selTile).y;
                if (GenTemperature.AverageTemperatureAtTileForTwelfth(this.selTile, Find.GameInitData.startingSeason.GetFirstTwelfth(y)) < 3f)
                {
                    listing_Standard.Label("MapTemperatureDangerWarning".Translate(), -1f, null);
                    flag = true;
                }
            }
            if (Find.GameInitData.mapSize > 280)
            {
                listing_Standard.Label("MapSizePerformanceWarning".Translate(), -1f, null);
                flag = true;
            }
            if (!flag)
            {
                listing_Standard.None();
            }
            listing_Standard.End();
        }
コード例 #14
0
        public override void DoWindowContents(Rect inRect)
        {
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.ColumnWidth = 200f;
            listing_Standard.Begin(inRect.AtZero());
            listing_Standard.Label("MapSize".Translate(), -1f);
            int[] mapSizes = Dialog_AdvancedGameConfig.MapSizes;
            for (int i = 0; i < mapSizes.Length; i++)
            {
                int num = mapSizes[i];
                if (num == 200)
                {
                    listing_Standard.Label("MapSizeSmall".Translate(), -1f);
                }
                else if (num == 250)
                {
                    listing_Standard.Label("MapSizeMedium".Translate(), -1f);
                }
                else if (num == 300)
                {
                    listing_Standard.Label("MapSizeLarge".Translate(), -1f);
                }
                else if (num == 350)
                {
                    listing_Standard.Label("MapSizeExtreme".Translate(), -1f);
                }
                string label = "MapSizeDesc".Translate(new object[]
                {
                    num,
                    num * num
                });
                if (listing_Standard.RadioButton(label, Find.GameInitData.mapSize == num, 0f))
                {
                    Find.GameInitData.mapSize = num;
                }
            }
            listing_Standard.NewColumn();
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            listing_Standard.Label("MapStartSeason".Translate(), -1f);
            string label2;

            if (Find.GameInitData.startingSeason == Season.Undefined)
            {
                label2 = "MapStartSeasonDefault".Translate();
            }
            else
            {
                label2 = Find.GameInitData.startingSeason.LabelCap();
            }
            Rect       rect       = listing_Standard.GetRect(32f);
            GridLayout gridLayout = new GridLayout(rect, 5, 1, 0f, 4f);

            if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(0, 1, 1), "-", true, false, true))
            {
                Season season = Find.GameInitData.startingSeason;
                if (season == Season.Undefined)
                {
                    season = Season.Winter;
                }
                else
                {
                    season = (Season)(season - Season.Spring);
                }
                Find.GameInitData.startingSeason = season;
            }
            Widgets.Label(gridLayout.GetCellRectByIndex(1, 3, 1), label2);
            if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(4, 1, 1), "+", true, false, true))
            {
                Season season2 = Find.GameInitData.startingSeason;
                if (season2 == Season.Winter)
                {
                    season2 = Season.Undefined;
                }
                else
                {
                    season2 += 1;
                }
                Find.GameInitData.startingSeason = season2;
            }
            GenUI.ResetLabelAlign();
            if (this.selTile >= 0 && Find.GameInitData.startingSeason != Season.Undefined)
            {
                float y = Find.WorldGrid.LongLatOf(this.selTile).y;
                if (GenTemperature.AverageTemperatureAtTileForTwelfth(this.selTile, Find.GameInitData.startingSeason.GetFirstTwelfth(y)) < 3f)
                {
                    listing_Standard.Label("MapTemperatureDangerWarning".Translate(), -1f);
                }
            }
            if (Find.GameInitData.mapSize > 250)
            {
                listing_Standard.Label("MapSizePerformanceWarning".Translate(), -1f);
            }
            listing_Standard.End();
        }
コード例 #15
0
        protected override void FillTab()
        {
            Rect rect  = new Rect(0f, 0f, WITab_Terrain.WinSize.x, WITab_Terrain.WinSize.y).ContractedBy(10f);
            Rect rect2 = rect;

            Text.Font = GameFont.Medium;
            Widgets.Label(rect2, base.SelTile.biome.LabelCap);
            Rect rect3 = rect;

            rect3.yMin += 35f;
            Text.Font   = GameFont.Small;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.verticalSpacing = 0f;
            listing_Standard.Begin(rect3);
            Tile  selTile   = base.SelTile;
            int   selTileID = base.SelTileID;
            float y         = Find.WorldGrid.LongLatOf(selTileID).y;

            listing_Standard.Label(selTile.biome.description, -1f);
            listing_Standard.Gap(8f);
            listing_Standard.GapLine(12f);
            if (!selTile.biome.implemented)
            {
                listing_Standard.Label(selTile.biome.LabelCap + " " + "BiomeNotImplemented".Translate(), -1f);
            }
            listing_Standard.LabelDouble("Terrain".Translate(), selTile.hilliness.GetLabelCap());
            if (selTile.VisibleRoads != null)
            {
                listing_Standard.LabelDouble("Road".Translate(), GenText.ToCommaList((from roadlink in selTile.VisibleRoads
                                                                                      select roadlink.road.label).Distinct <string>(), true).CapitalizeFirst());
            }
            if (selTile.VisibleRivers != null)
            {
                listing_Standard.LabelDouble("River".Translate(), selTile.VisibleRivers.MaxBy((Tile.RiverLink riverlink) => riverlink.river.degradeThreshold).river.LabelCap);
            }
            if (!Find.World.Impassable(selTileID))
            {
                int num      = 2500;
                int numTicks = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileID, false, -1f), 120000);
                listing_Standard.LabelDouble("MovementTimeNow".Translate(), numTicks.ToStringTicksToPeriod(true, false, true));
                int numTicks2 = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileID, false, Season.Summer.GetMiddleYearPct(y)), 120000);
                listing_Standard.LabelDouble("MovementTimeSummer".Translate(), numTicks2.ToStringTicksToPeriod(true, false, true));
                int numTicks3 = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileID, false, Season.Winter.GetMiddleYearPct(y)), 120000);
                listing_Standard.LabelDouble("MovementTimeWinter".Translate(), numTicks3.ToStringTicksToPeriod(true, false, true));
            }
            if (selTile.biome.canBuildBase)
            {
                listing_Standard.LabelDouble("StoneTypesHere".Translate(), GenText.ToCommaList(from rt in Find.World.NaturalRockTypesIn(selTileID)
                                                                                               select rt.label, true).CapitalizeFirst());
            }
            listing_Standard.LabelDouble("Elevation".Translate(), selTile.elevation.ToString("F0") + "m");
            listing_Standard.GapLine(12f);
            listing_Standard.LabelDouble("AvgTemp".Translate(), selTile.temperature.ToStringTemperature("F1"));
            float celsiusTemp = GenTemperature.AverageTemperatureAtTileForTwelfth(selTileID, Season.Winter.GetMiddleTwelfth(y));

            listing_Standard.LabelDouble("AvgWinterTemp".Translate(), celsiusTemp.ToStringTemperature("F1"));
            float celsiusTemp2 = GenTemperature.AverageTemperatureAtTileForTwelfth(selTileID, Season.Summer.GetMiddleTwelfth(y));

            listing_Standard.LabelDouble("AvgSummerTemp".Translate(), celsiusTemp2.ToStringTemperature("F1"));
            listing_Standard.LabelDouble("OutdoorGrowingPeriod".Translate(), Zone_Growing.GrowingQuadrumsDescription(selTileID));
            listing_Standard.LabelDouble("Rainfall".Translate(), selTile.rainfall.ToString("F0") + "mm");
            listing_Standard.LabelDouble("AnimalsCanGrazeNow".Translate(), (!VirtualPlantsUtility.EnvironmentAllowsEatingVirtualPlantsNowAt(selTileID)) ? "No".Translate() : "Yes".Translate());
            listing_Standard.GapLine(12f);
            listing_Standard.LabelDouble("AverageDiseaseFrequency".Translate(), string.Format("{0} {1}", (60f / selTile.biome.diseaseMtbDays).ToString("F1"), "PerYear".Translate()));
            listing_Standard.LabelDouble("TimeZone".Translate(), GenDate.TimeZoneAt(Find.WorldGrid.LongLatOf(selTileID).x).ToStringWithSign());
            StringBuilder stringBuilder = new StringBuilder();
            Rot4          rot           = Find.World.CoastDirectionAt(selTileID);

            if (rot.IsValid)
            {
                stringBuilder.AppendWithComma(("HasCoast" + rot.ToString()).Translate());
            }
            if (Find.World.HasCaves(selTileID))
            {
                stringBuilder.AppendWithComma("HasCaves".Translate());
            }
            if (stringBuilder.Length > 0)
            {
                listing_Standard.LabelDouble("SpecialFeatures".Translate(), stringBuilder.ToString().CapitalizeFirst());
            }
            if (Prefs.DevMode)
            {
                listing_Standard.LabelDouble("Debug world tile ID", selTileID.ToString());
            }
            listing_Standard.End();
        }
コード例 #16
0
        protected void DrawSelectedTileInfo()
        {
            DrawEntryHeader("Selected Tile Info", backgroundColor: Color.yellow);

            var matchingTiles = PrepareLanding.Instance.TileFilter.AllMatchingTiles;

            if (_selectedTileIndex < 0 || _selectedTileIndex >= matchingTiles.Count)
            {
                return;
            }

            ListingStandard.verticalSpacing = 0f;

            var selTileId = matchingTiles[_selectedTileIndex];
            var selTile   = Find.World.grid[selTileId];

            ListingStandard.Label(selTile.biome.LabelCap);
            var y = Find.WorldGrid.LongLatOf(selTileId).y;

            ListingStandard.Label(selTile.biome.description);
            ListingStandard.Gap(8f);
            ListingStandard.GapLine();
            if (!selTile.biome.implemented)
            {
                ListingStandard.Label(selTile.biome.LabelCap + " " + "BiomeNotImplemented".Translate());
            }
            ListingStandard.LabelDouble("Terrain".Translate(), selTile.hilliness.GetLabelCap());
            if (selTile.VisibleRoads != null)
            {
                ListingStandard.LabelDouble("Road".Translate(), GenText.ToCommaList((from roadlink in selTile.VisibleRoads
                                                                                     select roadlink.road.label).Distinct()).CapitalizeFirst());
            }
            if (selTile.VisibleRivers != null)
            {
                ListingStandard.LabelDouble("River".Translate(), selTile.VisibleRivers.MaxBy((riverlink) => riverlink.river.degradeThreshold).river.LabelCap);
            }
            if (!Find.World.Impassable(selTileId))
            {
                const int num      = 2500;
                var       numTicks = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileId, false), 120000);
                ListingStandard.LabelDouble("MovementTimeNow".Translate(), numTicks.ToStringTicksToPeriod());
                var numTicks2 = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileId, false, Season.Summer.GetMiddleYearPct(y)), 120000);
                ListingStandard.LabelDouble("MovementTimeSummer".Translate(), numTicks2.ToStringTicksToPeriod());
                var numTicks3 = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileId, false, Season.Winter.GetMiddleYearPct(y)), 120000);
                ListingStandard.LabelDouble("MovementTimeWinter".Translate(), numTicks3.ToStringTicksToPeriod());
            }
            if (selTile.biome.canBuildBase)
            {
                ListingStandard.LabelDouble("StoneTypesHere".Translate(), GenText.ToCommaList(from rt in Find.World.NaturalRockTypesIn(selTileId)
                                                                                              select rt.label).CapitalizeFirst());
            }
            ListingStandard.LabelDouble("Elevation".Translate(), selTile.elevation.ToString("F0") + "m");
            ListingStandard.GapLine();
            ListingStandard.LabelDouble("AvgTemp".Translate(), selTile.temperature.ToStringTemperature());
            var celsiusTemp = GenTemperature.AverageTemperatureAtTileForTwelfth(selTileId, Season.Winter.GetMiddleTwelfth(y));

            ListingStandard.LabelDouble("AvgWinterTemp".Translate(), celsiusTemp.ToStringTemperature());
            var celsiusTemp2 = GenTemperature.AverageTemperatureAtTileForTwelfth(selTileId, Season.Summer.GetMiddleTwelfth(y));

            ListingStandard.LabelDouble("AvgSummerTemp".Translate(), celsiusTemp2.ToStringTemperature());
            ListingStandard.LabelDouble("OutdoorGrowingPeriod".Translate(), Zone_Growing.GrowingQuadrumsDescription(selTileId));
            ListingStandard.LabelDouble("Rainfall".Translate(), selTile.rainfall.ToString("F0") + "mm");
            ListingStandard.LabelDouble("AnimalsCanGrazeNow".Translate(), (!VirtualPlantsUtility.EnvironmentAllowsEatingVirtualPlantsNowAt(selTileId)) ? "No".Translate() : "Yes".Translate());
            ListingStandard.GapLine();
            ListingStandard.LabelDouble("TimeZone".Translate(), GenDate.TimeZoneAt(Find.WorldGrid.LongLatOf(selTileId).x).ToStringWithSign());
            var rot = Find.World.CoastDirectionAt(selTileId);

            if (rot.IsValid)
            {
                ListingStandard.LabelDouble(string.Empty, ("HasCoast" + rot).Translate());
            }
            if (Prefs.DevMode)
            {
                ListingStandard.LabelDouble("Debug world tile ID", selTileId.ToString());
            }
        }
コード例 #17
0
        private static bool Prefix(ref Dialog_AdvancedGameConfig __instance, Rect inRect)
        {
            var listingStandard = new Listing_Standard {
                ColumnWidth = 200f
            };

            listingStandard.Begin(inRect.AtZero());
            listingStandard.Label("MapSize".Translate());
            var mapSizes = Traverse.Create(__instance).Field("MapSizes").GetValue <int[]>();

            foreach (var mapSize in mapSizes)
            {
                switch (mapSize)
                {
                case 200:
                    listingStandard.Label("MapSizeSmall".Translate());
                    break;

                case 250:
                    listingStandard.Label("MapSizeMedium".Translate());
                    break;

                case 300:
                    listingStandard.Label("MapSizeLarge".Translate());
                    break;

                case 350:
                    listingStandard.Label("MapSizeExtreme".Translate());
                    break;
                }

                var label = "MapSizeDesc".Translate(mapSize, mapSize * mapSize);
                if (listingStandard.RadioButton(label, Find.GameInitData.mapSize == mapSize))
                {
                    Find.GameInitData.mapSize = mapSize;
                }
            }

            listingStandard.Label("Custom Map Size");

            var lab = "MapSizeDesc".Translate(_customSize, _customSize * _customSize);

            if (listingStandard.RadioButton(lab, Find.GameInitData.mapSize == _customSize))
            {
                Find.GameInitData.mapSize = _customSize;
            }

            listingStandard.Label("New Size:");
            _settingsString = Widgets.TextField(new Rect(90f, 362f, 60f, 20f), _settingsString);
            if (Widgets.ButtonText(new Rect(160f, 362f, 40f, 22f), "Apply"))
            {
                if (int.TryParse(_settingsString, out var result) && result > 0)
                {
                    if (mapSizes.Contains(result))
                    {
                        Messages.Message("Built in maps already has these dimensions", MessageTypeDefOf.NegativeEvent);
                        _settingsString = _customSize.ToStringSafe();
                    }
                    else
                    {
                        _customSize = result;
                    }
                }
                else
                {
                    Messages.Message("Must be an positive integer", MessageTypeDefOf.NegativeEvent);
                    _settingsString = _customSize.ToStringSafe();
                }
            }

            listingStandard.NewColumn();
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            listingStandard.Label("MapStartSeason".Translate());
            var label1 = Find.GameInitData.startingSeason != Season.Undefined
                ? Find.GameInitData.startingSeason.LabelCap()
                : "MapStartSeasonDefault".Translate();
            var gridLayout = new GridLayout(listingStandard.GetRect(32f), 5, 1, 0.0f);

            if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(0), "-"))
            {
                var startingSeason = Find.GameInitData.startingSeason;
                Find.GameInitData.startingSeason =
                    startingSeason != Season.Undefined ? startingSeason - 1 : Season.Winter;
            }

            Widgets.Label(gridLayout.GetCellRectByIndex(1, 3), label1);
            if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(4), "+"))
            {
                var startingSeason = Find.GameInitData.startingSeason;
                Find.GameInitData.startingSeason =
                    startingSeason != Season.Winter ? startingSeason + 1 : Season.Undefined;
            }

            GenUI.ResetLabelAlign();

            var selTile = Traverse.Create(__instance).Field("selTile").GetValue <int>();

            if (selTile >= 0 && Find.GameInitData.startingSeason != Season.Undefined &&
                GenTemperature.AverageTemperatureAtTileForTwelfth(selTile,
                                                                  Find.GameInitData.startingSeason.GetFirstTwelfth(Find.WorldGrid.LongLatOf(selTile).y)) <
                3.0)
            {
                listingStandard.Label("MapTemperatureDangerWarning".Translate());
            }
            if (Find.GameInitData.mapSize > 250)
            {
                listingStandard.Label("MapSizePerformanceWarning".Translate());
            }
            listingStandard.End();

            return(false);
        }
コード例 #18
0
        public override void DoWindowContents(Rect inRect)
        {
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.ColumnWidth = 200f;
            listing_Standard.Begin(inRect.AtZero());
            Text.Font = GameFont.Medium;
            listing_Standard.Label("MapSize".Translate());
            Text.Font = GameFont.Small;
            IEnumerable <int> enumerable = MapSizes.AsEnumerable();

            if (Prefs.TestMapSizes)
            {
                enumerable = enumerable.Concat(TestMapSizes);
            }
            foreach (int item in enumerable)
            {
                switch (item)
                {
                case 200:
                    listing_Standard.Label("MapSizeSmall".Translate());
                    break;

                case 250:
                    listing_Standard.Gap(10f);
                    listing_Standard.Label("MapSizeMedium".Translate());
                    break;

                case 300:
                    listing_Standard.Gap(10f);
                    listing_Standard.Label("MapSizeLarge".Translate());
                    break;

                case 350:
                    listing_Standard.Gap(10f);
                    listing_Standard.Label("MapSizeExtreme".Translate());
                    break;
                }
                string label = "MapSizeDesc".Translate(item, item * item);
                if (listing_Standard.RadioButton(label, Find.GameInitData.mapSize == item))
                {
                    Find.GameInitData.mapSize = item;
                }
            }
            listing_Standard.NewColumn();
            Text.Font = GameFont.Medium;
            listing_Standard.Label("MapStartSeason".Translate());
            Text.Font = GameFont.Small;
            listing_Standard.Label("");
            if (listing_Standard.RadioButton("MapStartSeasonDefault".Translate(), Find.GameInitData.startingSeason == Season.Undefined))
            {
                Find.GameInitData.startingSeason = Season.Undefined;
            }
            if (listing_Standard.RadioButton(Season.Spring.LabelCap(), Find.GameInitData.startingSeason == Season.Spring))
            {
                Find.GameInitData.startingSeason = Season.Spring;
            }
            if (listing_Standard.RadioButton(Season.Summer.LabelCap(), Find.GameInitData.startingSeason == Season.Summer))
            {
                Find.GameInitData.startingSeason = Season.Summer;
            }
            if (listing_Standard.RadioButton(Season.Fall.LabelCap(), Find.GameInitData.startingSeason == Season.Fall))
            {
                Find.GameInitData.startingSeason = Season.Fall;
            }
            if (listing_Standard.RadioButton(Season.Winter.LabelCap(), Find.GameInitData.startingSeason == Season.Winter))
            {
                Find.GameInitData.startingSeason = Season.Winter;
            }
            listing_Standard.NewColumn();
            Text.Font = GameFont.Medium;
            listing_Standard.Label("Notice".Translate());
            Text.Font = GameFont.Small;
            listing_Standard.Label("");
            bool flag = false;

            if (selTile >= 0 && Find.GameInitData.startingSeason != 0)
            {
                float y = Find.WorldGrid.LongLatOf(selTile).y;
                if (GenTemperature.AverageTemperatureAtTileForTwelfth(selTile, Find.GameInitData.startingSeason.GetFirstTwelfth(y)) < 3f)
                {
                    listing_Standard.Label("MapTemperatureDangerWarning".Translate());
                    flag = true;
                }
            }
            if (Find.GameInitData.mapSize > 280)
            {
                listing_Standard.Label("MapSizePerformanceWarning".Translate());
                flag = true;
            }
            if (!flag)
            {
                listing_Standard.None();
            }
            listing_Standard.End();
        }
コード例 #19
0
        public override void DoWindowContents(Rect inRect)
        {
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.ColumnWidth = 200f;
            listing_Standard.Begin(inRect.AtZero());
            listing_Standard.Label("MapSize".Translate(), -1f);
            int[] mapSizes = Dialog_AdvancedGameConfig.MapSizes;
            foreach (int num in mapSizes)
            {
                switch (num)
                {
                case 200:
                    listing_Standard.Label("MapSizeSmall".Translate(), -1f);
                    break;

                case 250:
                    listing_Standard.Label("MapSizeMedium".Translate(), -1f);
                    break;

                case 300:
                    listing_Standard.Label("MapSizeLarge".Translate(), -1f);
                    break;

                case 350:
                    listing_Standard.Label("MapSizeExtreme".Translate(), -1f);
                    break;
                }
                string label = "MapSizeDesc".Translate(num, num * num);
                if (listing_Standard.RadioButton(label, Find.GameInitData.mapSize == num, 0f))
                {
                    Find.GameInitData.mapSize = num;
                }
            }
            listing_Standard.NewColumn();
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            listing_Standard.Label("MapStartSeason".Translate(), -1f);
            string     label2     = (Find.GameInitData.startingSeason != 0) ? Find.GameInitData.startingSeason.LabelCap() : "MapStartSeasonDefault".Translate();
            Rect       rect       = listing_Standard.GetRect(32f);
            GridLayout gridLayout = new GridLayout(rect, 5, 1, 0f, 4f);

            if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(0, 1, 1), "-", true, false, true))
            {
                Season startingSeason = Find.GameInitData.startingSeason;
                startingSeason = ((startingSeason != 0) ? (startingSeason - 1) : Season.Winter);
                Find.GameInitData.startingSeason = startingSeason;
            }
            Widgets.Label(gridLayout.GetCellRectByIndex(1, 3, 1), label2);
            if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(4, 1, 1), "+", true, false, true))
            {
                Season startingSeason2 = Find.GameInitData.startingSeason;
                startingSeason2 = ((startingSeason2 != Season.Winter) ? (startingSeason2 + 1) : Season.Undefined);
                Find.GameInitData.startingSeason = startingSeason2;
            }
            GenUI.ResetLabelAlign();
            if (this.selTile >= 0 && Find.GameInitData.startingSeason != 0)
            {
                Vector2 vector = Find.WorldGrid.LongLatOf(this.selTile);
                float   y      = vector.y;
                if (GenTemperature.AverageTemperatureAtTileForTwelfth(this.selTile, Find.GameInitData.startingSeason.GetFirstTwelfth(y)) < 3.0)
                {
                    listing_Standard.Label("MapTemperatureDangerWarning".Translate(), -1f);
                }
            }
            if (Find.GameInitData.mapSize > 250)
            {
                listing_Standard.Label("MapSizePerformanceWarning".Translate(), -1f);
            }
            listing_Standard.End();
        }