//one day this'll be convoluted enough for me to need comments.
        public override float TemperatureOffset()
        {
            if (settings.cycleType == "Winter is coming")
            {
                return(Mathf.Sin((GenDate.YearsPassedFloat + this.ticksOffset) / settings.cyclePeriods * Mathf.PI * 2f) * 20f - (GenDate.YearsPassedFloat * settings.cycleMultiplier) - 20f);
            }

            if (settings.cycleType == "Waiting for the Sun")
            {
                return(Mathf.Sin((GenDate.YearsPassedFloat + this.ticksOffset) / settings.cyclePeriods * Mathf.PI * 2f) * 20f + (GenDate.YearsPassedFloat * settings.cycleMultiplier));
            }

            if (settings.cycleType == "Normal Summer, Cold Winter")
            {
                if (GenDate.Season(Find.TickManager.TicksAbs, Find.WorldGrid.LongLatOf(this.SingleMap.Tile)) == Season.Fall)
                {
                    return(Mathf.Sin((GenDate.YearsPassedFloat + this.ticksOffset) / settings.cyclePeriods * Mathf.PI * 2f) * 20f - (GenDate.YearsPassedFloat * settings.cycleMultiplier / 2) - 20f);
                }

                if (GenDate.Season(Find.TickManager.TicksAbs, Find.WorldGrid.LongLatOf(this.SingleMap.Tile)) == Season.Winter)
                {
                    return(Mathf.Sin((GenDate.YearsPassedFloat + this.ticksOffset) / settings.cyclePeriods * Mathf.PI * 2f) * 20f - (GenDate.YearsPassedFloat * settings.cycleMultiplier) - (GenDate.YearsPassedFloat * settings.cycleMultiplier) - 20f);
                }

                return(0f);
            }

            return(Mathf.Sin((GenDate.YearsPassedFloat + this.ticksOffset) / settings.cyclePeriods * Mathf.PI * 2f) * (20f + (GenDate.YearsPassedFloat * settings.cycleMultiplier)));
        }
        private float getSeasonMoveCost(int currentPlace)
        {
            WorldGrid grid        = Find.WorldGrid;
            Tile      currentTile = grid.tiles[currentPlace];
            Season    season      = GenDate.Season(Find.TickManager.TicksGame, grid.LongLatOf(currentPlace));

            switch (season)
            {
            case Season.Spring:
                return(currentTile.biome.pathCost_spring);

            case Season.Summer:
            case Season.PermanentSummer:
                return(currentTile.biome.pathCost_summer);

            case Season.Fall:
                return(currentTile.biome.pathCost_fall);

            case Season.Winter:
            case Season.PermanentWinter:
                return(currentTile.biome.pathCost_winter);
            }
            Log.Error("unable to know seasonal move cost");
            return(0);
        }
        // Token: 0x0600001A RID: 26 RVA: 0x00002714 File Offset: 0x00000914
        public override void MapComponentTick()
        {
            base.MapComponentTick();
            if (Find.TickManager.TicksGame % 30000 != 0)
            {
                return;
            }

            if (lastPartyYear == GenDate.YearsPassed)
            {
                //Log.Message(lastPartyYear.ToString());
                return;
            }

            once = true;

            if (!map.listerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("ChristmasTreeBase")).Any() &&
                !map.listerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("ChristmasTreeB")).Any() &&
                !map.listerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("ChristmasTreeC")).Any() &&
                !map.listerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("ChristmasTreeD")).Any())
            {
                //Log.Message("no tree");
                return;
            }

            var season     = GenDate.Season(GenTicks.TicksAbs, Find.WorldGrid.LongLatOf(map.Tile));
            var doTheThing = false;

            if (season == Season.PermanentSummer || season == Season.PermanentWinter)
            {
                //Log.Message("permanent season");
                if (GenDate.Quadrum(GenTicks.TicksAbs, Find.WorldGrid.LongLatOf(map.Tile).x) != Quadrum.Decembary)
                {
                    //Log.Message("not december");
                    return;
                }

                doTheThing = true;
            }

            if (!doTheThing && (season != Season.Winter ||
                                GenDate.DayOfSeason(GenTicks.TicksAbs, Find.WorldGrid.LongLatOf(map.Tile).x) < 2) ||
                !once)
            {
                //Log.Message("not winter");
                return;
            }

            //Log.Message("party");
            once = false;
            ExposeData();
            var incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, map);

            incidentParms.forced = true;
            incidentParms.target = map;
            Find.Storyteller.incidentQueue.Add(XDefOf.PresentDrop, Find.TickManager.TicksGame, incidentParms, 240000);
            TryStartParty();
            lastPartyYear = GenDate.YearsPassed;
        }
示例#4
0
        private void updateBiomeSettings(bool force = false)
        {
            if (this.biomeSettings != null)
            {
                Vector2 location = Find.WorldGrid.LongLatOf(map.Tile);
                Season  season   = GenDate.Season((long)Find.TickManager.TicksAbs, location);
                Quadrum quadrum  = GenDate.Quadrum((long)Find.TickManager.TicksAbs, location.x);

                if (force == true || (biomeSettings.lastChanged != season && biomeSettings.lastChangedQ != quadrum))
                {
//					Log.Warning("Updating seasonal settings");
                    biomeSettings.setWeatherBySeason(map, season, quadrum);
                    biomeSettings.setDiseaseBySeason(season, quadrum);
                    biomeSettings.setIncidentsBySeason(season, quadrum);
                    biomeSettings.lastChanged  = season;
                    biomeSettings.lastChangedQ = quadrum;
                }
            }
        }
示例#5
0
        private void ExecureOperation(int ticksNowAbs)
        {
            if (this.SettingAutoPause)
            {
                if (!Find.TickManager.Paused)
                {
                    Find.TickManager.TogglePaused();
                }
            }

            if (this.SettingDisplayMessage)
            {
                Letter _Letter = new Letter(this.SettingMessageLabel, this.SettingMessageContent, LetterType.Good);
                Find.LetterStack.ReceiveLetter(_Letter, "PhotoDay Letter");
            }

            if (this.SettingAutoScreenshot)
            {
                string _ScreenshotFolderPath = GenFilePaths.ScreenshotFolderPath;

                string _FullFilePath = _ScreenshotFolderPath;
                // _FullFilePath = _FullFilePath + (object)Path.DirectorySeparatorChar + GenDate.DaysPassedFloat.ToString() + ".jpg";
                if (this.SettingAdvancedMode)
                {
                    _FullFilePath = _FullFilePath + (object)Path.DirectorySeparatorChar +
                                    GenDate.Year(ticksNowAbs, this.SettingAdvancedTimeZoneLongitude) + "-" +
                                    GenDate.Season(ticksNowAbs, this.SettingAdvancedTimeZoneLongitude) + "-" +
                                    (GenDate.DayOfSeason(ticksNowAbs, this.SettingAdvancedTimeZoneLongitude) + 1).ToString().PadLeft(2, '0') + "-" +
                                    GenDate.HourOfDay(ticksNowAbs, this.SettingAdvancedTimeZoneLongitude).ToString().PadLeft(2, '0') + ".jpg";
                }
                else
                {
                    _FullFilePath = _FullFilePath + (object)Path.DirectorySeparatorChar +
                                    "Screenshot" + "-" +
                                    ticksNowAbs.ToString() + ".jpg";
                }

                Log.Message(_FullFilePath);
                Application.CaptureScreenshot(_FullFilePath);
            }
        }
 public static Season GetMapSeason(this Thing thing) =>
 GenDate.Season(Find.TickManager.TicksAbs, Find.WorldGrid.LongLatOf(thing.MapHeld.Tile));
示例#7
0
        public static void Postfix(Plant __instance, ref Graphic __result)
        {
            string id = __instance.def.defName;

            if (!__instance.def.HasModExtension <ThingWeatherReaction>())
            {
                return;
            }

            ThingWeatherReaction mod = __instance.def.GetModExtension <ThingWeatherReaction>();
            Map map = __instance.Map;

            string path = "";

            //get flowering or drought graphic if it's over 70
            if (__instance.AmbientTemperature > 21)
            {
                Watcher  watcher = map.GetComponent <Watcher>();
                cellData cell;
                if (watcher.cellWeatherAffects[__instance.Position] != null)
                {
                    cell = watcher.cellWeatherAffects[__instance.Position];
                    Vector2 location = Find.WorldGrid.LongLatOf(__instance.MapHeld.Tile);
                    Season  season   = GenDate.Season((long)Find.TickManager.TicksAbs, location);

                    if (!String.IsNullOrEmpty(mod.floweringGraphicPath) && ((cell.howWetPlants > 60 && map.weatherManager.RainRate <= .001f) || season == Season.Spring))
                    {
                        id  += "flowering";
                        path = mod.floweringGraphicPath;
                    }

                    if (!String.IsNullOrEmpty(mod.droughtGraphicPath) && cell.howWetPlants < 20)
                    {
                        id  += "drought";
                        path = mod.droughtGraphicPath;
                    }
                    else
                    if (__instance.def.plant.leaflessGraphic != null && cell.howWetPlants < 20)
                    {
                        id  += "drought";
                        path = __instance.def.plant.leaflessGraphic.path;
                    }
                }
            }
            if (path != "")
            {
                if (!map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
                {
                    //only load the image once.
                    map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, path, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo));
                }
                if (map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
                {
                    __result = map.GetComponent <Watcher>().graphicHolder[id];
                }
                return;
            }

            if (Settings.showCold)
            {
                //get snow graphic
                if (map.snowGrid.GetDepth(__instance.Position) >= 0.5f)
                {
                    if (!String.IsNullOrEmpty(mod.snowGraphicPath))
                    {
                        id  += "snow";
                        path = mod.snowGraphicPath;
                    }
                }
                else if (map.GetComponent <FrostGrid>().GetDepth(__instance.Position) >= 0.6f)
                {
                    if (!String.IsNullOrEmpty(mod.frostGraphicPath))
                    {
                        id  += "frost";
                        path = mod.frostGraphicPath;
                    }
                }

                if (String.IsNullOrEmpty(path))
                {
                    return;
                }
                //if it's leafless
                if (__instance.def.plant.leaflessGraphic == __result)
                {
                    id   += "leafless";
                    path  = path.Replace("Frosted", "Frosted/Leafless");
                    path  = path.Replace("Snow", "Snow/Leafless");
                    path += "_Leafless";
                }
                else if (__instance.def.blockWind)
                {
                    //make it so snow doesn't fall under the tree until it's leafless.
                    //	map.snowGrid.AddDepth(__instance.Position, -.05f);
                }
            }


            if (!map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
            {
                //only load the image once.
                map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, path, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo));
            }
            if (map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
            {
                __result = map.GetComponent <Watcher>().graphicHolder[id];
            }
            return;
        }
示例#8
0
        public static bool Prefix(Rect dateRect)
        {
            //--------------------------------------------
            if (GetClocks(Find.VisibleMap).Count() == 0)
            {
                return(true);                                         //use original method
            }
            if (clockAccuracy < 0)
            {
                Log.Warning("Found clock but clockAccuracy not set. Setting to Analog.");
                clockAccuracy = 0;
            }
            //

            //Vector2 location;
            //In event of transpiler just get local variable at end
            if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.selectedTile >= 0)
            {
                location = Find.WorldGrid.LongLatOf(Find.WorldSelector.selectedTile);
            }
            else if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.NumSelectedObjects > 0)
            {
                location = Find.WorldGrid.LongLatOf(Find.WorldSelector.FirstSelectedObject.Tile);
            }
            else
            {
                if (Find.VisibleMap == null)
                {
                    return(false);
                }
                location = Find.WorldGrid.LongLatOf(Find.VisibleMap.Tile);
            }
            index = GenDate.HourInteger(Find.TickManager.TicksAbs, location.x);
            int     num     = GenDate.DayOfTwelfth(Find.TickManager.TicksAbs, location.x);
            Season  season  = GenDate.Season(Find.TickManager.TicksAbs, location);
            Quadrum quadrum = GenDate.Quadrum(Find.TickManager.TicksAbs, location.x);
            int     num2    = GenDate.Year(Find.TickManager.TicksAbs, location.x);

            if (num != dateStringDay || season != dateStringSeason || quadrum != dateStringQuadrum || num2 != dateStringYear)
            {
                dateString        = GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, location);
                dateStringDay     = num;
                dateStringSeason  = season;
                dateStringQuadrum = quadrum;
                dateStringYear    = num2;
            }
            Text.Font = GameFont.Small;
            float num3 = Mathf.Max(Text.CalcSize(fastHourStrings[index]).x, Text.CalcSize(dateString).x + 7f);

            dateRect.xMin = dateRect.xMax - num3;
            if (Mouse.IsOver(dateRect))
            {
                Widgets.DrawHighlight(dateRect);
            }
            GUI.BeginGroup(dateRect);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect = dateRect.AtZero();

            rect.xMax -= 7f;
            //-----------------------------------------------------
            hrtime = (index < 12) ? "amannotation".Translate(fastHourStrings[index].ToString() + currentMin) : "pmannotation".Translate(fastHourStrings[index].ToString() + currentMin);
            Widgets.Label(rect, hrtime);
            //
            //Widgets.Label(rect, fastHourStrings[index]); REPLACED
            rect.yMin += 26f;
            Widgets.Label(rect, dateString);
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            //Remember - this delegate in itself is its own local method (m_XXX)
            //IL code: ldftn instance string RimWorld.DateReadout/'<DateOnGUI>c__AnonStorey449'::'<>m__64B'()
            TooltipHandler.TipRegion(dateRect, new TipSignal(delegate
            {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < 4; i++)
                {
                    Quadrum quadrum2 = (Quadrum)i;
                    stringBuilder.AppendLine(quadrum2.Label() + " - " + quadrum2.GetSeason(location.y).LabelCap());
                }
                return("DateReadoutTip".Translate(new object[]
                {
                    GenDate.DaysPassed,
                    15,
                    season.LabelCap(),
                    15,
                    GenDate.Quadrum((long)GenTicks.TicksAbs, location.x).Label(),
                    stringBuilder.ToString()
                })
                       //-------------------------------------------
                       + (clockAccuracy > 0 ? "TicksAbsOnGUI".Translate(Find.TickManager.TicksGame) : string.Empty)
                       //
                       );
            }, 86423));
            return(false);
        }
示例#9
0
        public static bool Prefix(
            Rect dateRect,
            ref List <string> ___seasonsCached,
            ref int ___dateStringDay,
            ref Season ___dateStringSeason,
            ref Quadrum ___dateStringQuadrum,
            ref int ___dateStringYear,
            ref string ___dateString
            )
        {
            Vector2 vector2;

            if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.selectedTile >= 0)
            {
                vector2 = Find.WorldGrid.LongLatOf(Find.WorldSelector.selectedTile);
            }
            else if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.NumSelectedObjects > 0)
            {
                vector2 = Find.WorldGrid.LongLatOf(Find.WorldSelector.FirstSelectedObject.Tile);
            }
            else
            {
                if (Find.CurrentMap == null)
                {
                    return(false);
                }
                vector2 = Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);
            }

            var num1     = GenDate.DayOfTwelfth(Find.TickManager.TicksAbs, vector2.x);
            var season   = GenDate.Season(Find.TickManager.TicksAbs, vector2);
            var quadrum1 = GenDate.Quadrum(Find.TickManager.TicksAbs, vector2.x);
            var num2     = GenDate.Year(Find.TickManager.TicksAbs, vector2.x);
            var str      = true ? ___seasonsCached[(int)season] : "";

            if (num1 != ___dateStringDay || season != ___dateStringSeason || quadrum1 != ___dateStringQuadrum || num2 != ___dateStringYear)
            {
                ___dateString        = GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, vector2);
                ___dateStringDay     = num1;
                ___dateStringSeason  = season;
                ___dateStringQuadrum = quadrum1;
                ___dateStringYear    = num2;
            }

            var userTime = "";

            if (!BetterTimeFormatMod.UpdateTime)
            {
                userTime = BetterTimeFormatMod.settings.timeFormat;
                var dayPercent = GenLocalDate.DayPercent(Find.CurrentMap);

                if (BetterTimeFormatMod.UpdateHours)
                {
                    var hours = Math.Floor(dayPercent * 24);
                    if (BetterTimeFormatMod.settings.twelveHourFormat)
                    {
                        hours = dayPercent < 0.6 ? hours : hours - 12;
                    }

                    userTime = userTime.ReplaceFirst("HH", $"{hours,0:00}");
                    userTime = userTime.ReplaceFirst("H", $"{hours,0}");
                }

                if (BetterTimeFormatMod.UpdateMinutes)
                {
                    var minutes = Math.Floor(dayPercent * 24 % 1 * 60);
                    userTime = userTime.ReplaceFirst("MM", $"{minutes,0:00}");
                    userTime = userTime.ReplaceFirst("M", $"{minutes,0:0}");
                }

                if (BetterTimeFormatMod.UpdateSeconds)
                {
                    var seconds = Math.Floor(dayPercent * 24 % 1 * 60 % 1 * 60);
                    userTime = userTime.ReplaceFirst("SS", $"{seconds,0:00}");
                    userTime = userTime.ReplaceFirst("S", $"{seconds,0:0}");
                }

                if (BetterTimeFormatMod.settings.twelveHourFormat)
                {
                    var notation = dayPercent < 0.5 ? BetterTimeFormatMod.settings.amString : BetterTimeFormatMod.settings.pmString;
                    userTime = userTime.ReplaceFirst("N", notation);
                }
            }

            Text.Font = GameFont.Small;
            var num3 =
                Mathf.Max(Mathf.Max(Text.CalcSize(userTime).x, Text.CalcSize(___dateString).x), Text.CalcSize(str).x) + 7f;

            dateRect.xMin = dateRect.xMax - num3;
            if (Mouse.IsOver(dateRect))
            {
                Widgets.DrawHighlight(dateRect);
            }
            GUI.BeginGroup(dateRect);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            var rect = dateRect.AtZero();

            rect.xMax -= 7f;
            Widgets.Label(rect, userTime);
            rect.yMin += 26f;
            Widgets.Label(rect, ___dateString);
            rect.yMin += 26f;
            if (!str.NullOrEmpty())
            {
                Widgets.Label(rect, str);
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            if (!Mouse.IsOver(dateRect))
            {
                return(false);
            }
            var stringBuilder = new StringBuilder();

            for (var index2 = 0; index2 < 4; ++index2)
            {
                var quadrum2 = (Quadrum)index2;
                stringBuilder.AppendLine(quadrum2.Label() + " - " + quadrum2.GetSeason(vector2.y).LabelCap());
            }

            var taggedString = "DateReadoutTip".Translate(GenDate.DaysPassed, 15, (NamedArgument)season.LabelCap(), 15,
                                                          (NamedArgument)GenDate.Quadrum(GenTicks.TicksAbs, vector2.x).Label(), (NamedArgument)stringBuilder.ToString());

            TooltipHandler.TipRegion(dateRect, new TipSignal(taggedString, 86423));

            return(false);
        }
示例#10
0
        public List <Speciality> getSpecialityList()
        {
            Settlement settlement = TradeSession.trader as Settlement;

            if (settlement == null)
            {
                return(new List <Speciality>());
            }
            List <Speciality> specialityList;

            if (specialityLists.ContainsKey(settlement))
            {
                specialityList = specialityLists[settlement];
            }
            else
            {
                specialityList = new List <Speciality>();
                int                    ticksPerDay            = 60000 / 24 * 14;
                WorldGrid              grid                   = Find.WorldGrid;
                WorldPathFinder        finder                 = Find.WorldPathFinder;
                SpecialityWorldManager specialityWorldManager = Find.World.GetComponent <SpecialityWorldManager>();
                finder.FloodPathsWithCost(new List <int> {
                    settlement.Tile
                }, (int currentPlace, int neighborPlace) => {
                    float moveCost = 2500;
                    Tile tile      = grid.tiles[neighborPlace];
                    if (tile == null && tile.WaterCovered)
                    {
                        return(99999);
                    }
                    Season season = GenDate.Season(Find.TickManager.TicksGame, grid.LongLatOf(neighborPlace));
                    switch (season)
                    {
                    case Season.Spring:
                        moveCost += tile.biome.pathCost_spring;
                        break;

                    case Season.Summer:
                    case Season.PermanentSummer:
                        moveCost += tile.biome.pathCost_summer;
                        break;

                    case Season.Fall:
                        moveCost += tile.biome.pathCost_fall;
                        break;

                    case Season.Winter:
                    case Season.PermanentWinter:
                        moveCost += tile.biome.pathCost_winter;
                        break;
                    }
                    moveCost *= grid.GetRoadMovementMultiplierFast(currentPlace, neighborPlace);
                    return((int)moveCost);
                }, null, (int currentPlace, float cost) => {
                    if (cost <= ticksPerDay)
                    {
                        Speciality speciality = specialityWorldManager.getSpeciality(currentPlace);
                        if (speciality != null)
                        {
                            specialityList.Add(speciality);
                        }
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                });
                specialityLists[settlement] = specialityList;
            }
            return(specialityList);
        }
示例#11
0
        public static void Prefix(Map __instance)
        {
            if (StorageData.GlobalData == null || !StorageData.GlobalData.GrassFixOn)
            {
                return;
            }

            var tick = Find.TickManager.TicksGame;

            //раз в день
            if (tick % 60000 == 59)
            {
                var map = __instance;
                if (map.fertilityGrid == null || map.mapTemperature == null || map.thingGrid == null || map.Tile == 0)
                {
                    return;
                }

                //Loger.Log("map " + map.Tile + " " + GetMapTickOnPlaced());

                //это должна быть весна
                float  latitude  = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).y;
                float  longitude = (map == null) ? 0f : Find.WorldGrid.LongLatOf(map.Tile).x;
                Season season    = GenDate.Season((long)Find.TickManager.TicksAbs, latitude, longitude);
                if (season != Season.Spring)
                {
                    return;
                }

                //в этом году ещё не запускали (сбрасывается при загрузке. Поэтому весной спамит каждый раз после загрузки)
                if (!MapTickOnPlaced.ContainsKey(map.Tile))
                {
                    MapTickOnPlaced.Add(map.Tile, -3600000);
                    StorageData.GameData.GrassFixData = GetMapTickOnPlaced();
                    //Loger.Log("getGrass " + StorageData.GameData.GrassFixData);
                }
                if (MapTickOnPlaced[map.Tile] + 3600000 / 2 > tick)
                {
                    return;
                }

                if (map.mapTemperature.OutdoorTemp > 5f)
                {
                    MapTickOnPlaced[map.Tile]         = tick;
                    StorageData.GameData.GrassFixData = GetMapTickOnPlaced();
                    //Loger.Log("getGrass " + StorageData.GameData.GrassFixData);
                    int goodPlaceNum = 0;
                    int placed       = 0;
                    foreach (var pos in map.AllCells)
                    {
                        if (map.fertilityGrid.FertilityAt(pos) > 0f)
                        {
                            var ths = map.thingGrid.ThingsAt(pos);
                            if (map.thingGrid.ThingsAt(pos).Any(t => t.def == ThingDefOf.PlantGrass /*t is Plant*/))
                            {
                                goodPlaceNum = 0;
                            }
                            else if (map.thingGrid.ThingsAt(pos).Count() == 0)
                            {
                                goodPlaceNum++;
                                if (goodPlaceNum > 10)
                                {
                                    placed++;
                                    goodPlaceNum = 0;
                                    Plant plant = (Plant)ThingMaker.MakeThing(ThingDefOf.PlantGrass, null);
                                    plant.Growth = 0.07f; //Rand.Range(0.07f, 1f);
                                    plant.Age    = 0;
                                    GenSpawn.Spawn(plant, pos, map);
                                }
                            }
                            // GenStep_CavePlants
                        }
                    }
                    var msg = "OCity_GrassFix_Plant".Translate() + placed.ToString() + "OCity_GrassFix_Grass".Translate();
                    Loger.Log(msg);

                    Messages.Message(msg, MessageTypeDefOf.NeutralEvent);
                }
            }
        }