protected override IntVec3 GetWanderRoot(Pawn pawn) { if (pawn.RaceProps.Humanlike) { Watcher watcher = pawn.Map.GetComponent <Watcher>(); JobGiver_GoSwimming.swimmingSpots.Clear(); for (int i = 0; i < watcher.swimmingCellsList.Count; i++) { IntVec3 position = watcher.swimmingCellsList[i]; if (!position.IsForbidden(pawn) && pawn.CanReach(position, PathEndMode.Touch, Danger.None, false, TraverseMode.ByPawn)) { JobGiver_GoSwimming.swimmingSpots.Add(position); } } if (JobGiver_GoSwimming.swimmingSpots.Count > 0) { return(JobGiver_GoSwimming.swimmingSpots.RandomElement <IntVec3>()); } } return(IntVec3.Invalid); }
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; }
static void Postfix() { // Log.Warning("Window: " + window); IntVec3 c = UI.MouseCell(); if (!c.InBounds(Find.VisibleMap)) { return; } Rect rect; Vector2 BotLeft = new Vector2(15f, 65f); float num = 38f; Zone zone = c.GetZone(Find.VisibleMap); if (zone != null) { num += 19f; } float depth = Find.VisibleMap.snowGrid.GetDepth(c); if (depth > 0.03f) { num += 19f; } List <Thing> thingList = c.GetThingList(Find.VisibleMap); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category != ThingCategory.Mote) { num += 19f; } } RoofDef roof = c.GetRoof(Find.VisibleMap); if (roof != null) { num += 19f; } if (Settings.showTempReadout) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label3 = "C: x-" + c.x.ToString() + " y-" + c.y.ToString() + " z-" + c.z.ToString(); Widgets.Label(rect, label3); num += 19f; Map map = Find.VisibleMap; Watcher watcher = map.GetComponent <Watcher>(); cellData cell = watcher.cellWeatherAffects[c]; rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label2 = "Temperature: " + cell.temperature; Widgets.Label(rect, label2); num += 19f; rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label4 = "Cell Info: Base Terrain " + cell.baseTerrain.defName + " | Wet " + cell.isWet.ToString() + " | Melt " + cell.isMelt.ToString() + " | Flooded " + cell.isFlooded.ToString() + " | Frozen " + cell.isFrozen.ToString() + " | Thawed " + cell.isThawed.ToString() + " | How Wet (Plants) " + cell.howWetPlants.ToString() + " | Getting Wet? " + cell.gettingWet.ToString(); Widgets.Label(rect, label4); num += 19f; } depth = Find.VisibleMap.GetComponent <FrostGrid>().GetDepth(c); if (depth > 0.01f) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); FrostCategory frostCategory = FrostUtility.GetFrostCategory(depth); string label2 = FrostUtility.GetDescription(frostCategory); Widgets.Label(rect, label2); // Widgets.Label(rect, label2 + " " + depth.ToString()); num += 19f; } }
static void Postfix() { IntVec3 c = UI.MouseCell(); Map map = Find.CurrentMap; if (!c.InBounds(map)) { return; } Rect rect; Vector2 BotLeft = new Vector2(15f, 65f); float num = 38f; Zone zone = c.GetZone(map); if (zone != null) { num += 19f; } float depth = map.snowGrid.GetDepth(c); if (depth > 0.03f) { num += 19f; } List <Thing> thingList = c.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category != ThingCategory.Mote) { num += 19f; } } RoofDef roof = c.GetRoof(map); if (roof != null) { num += 19f; } if (Settings.showDevReadout) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label3 = "C: x-" + c.x.ToString() + " y-" + c.y.ToString() + " z-" + c.z.ToString(); Widgets.Label(rect, label3); num += 19f; Watcher watcher = map.GetComponent <Watcher>(); cellData cell = watcher.cellWeatherAffects[c]; rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label2 = "Temperature: " + cell.temperature; Widgets.Label(rect, label2); num += 19f; rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label4 = "Cell Info: Base Terrain " + cell.baseTerrain.defName + " Current Terrain " + cell.currentTerrain.defName + " | Wet " + cell.isWet.ToString() + " | Melt " + cell.isMelt.ToString() + " | Flooded " + cell.isFlooded.ToString() + " | Frozen " + cell.isFrozen.ToString() + " | Thawed " + cell.isThawed.ToString() + " | Getting Wet? " + cell.gettingWet.ToString(); Widgets.Label(rect, label4); num += 19f; rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label6 = "TKKN_Wet " + cell.currentTerrain.HasTag("TKKN_Wet") + "TKKN_Swim " + cell.currentTerrain.HasTag("TKKN_Swim"); Widgets.Label(rect, label6); num += 19f; rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label5 = "Cell Info: howWet " + cell.howWet.ToString() + " | How Wet (Plants) " + cell.howWetPlants.ToString() + " | How Packed " + cell.howPacked.ToString(); if (cell.weather != null) { if (cell.weather.wetTerrain != null) { label5 += " | T Wet " + cell.weather.wetTerrain.defName; } if (cell.weather.dryTerrain != null) { label5 += " | T Dry " + cell.weather.dryTerrain.defName; } if (cell.weather.freezeTerrain != null) { label5 += " | T Freeze " + cell.weather.freezeTerrain.defName; } } if (cell.originalTerrain != null) { label5 += " | Orig Terrain " + cell.originalTerrain.defName; } Widgets.Label(rect, label5); num += 19f; } depth = map.GetComponent <FrostGrid>().GetDepth(c); if (depth > 0.01f) { rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); FrostCategory frostCategory = FrostUtility.GetFrostCategory(depth); string label2 = FrostUtility.GetDescription(frostCategory); Widgets.Label(rect, label2); // Widgets.Label(rect, label2 + " " + depth.ToString()); num += 19f; } }