public static void ProcessRoofHolderDespawned(CellRect rect, IntVec3 position, Map map, bool removalMode = false, bool canRemoveThickRoof = false) { CheckCollapseFlyingRoofs(rect, map, removalMode, canRemoveThickRoof); RoofGrid roofGrid = map.roofGrid; roofsCollapsingBecauseTooFar.Clear(); for (int i = 0; i < RoofCollapseUtility.RoofSupportRadialCellsCount; i++) { IntVec3 intVec = position + GenRadial.RadialPattern[i]; if (intVec.InBounds(map) && roofGrid.Roofed(intVec.x, intVec.z) && !map.roofCollapseBuffer.IsMarkedToCollapse(intVec) && !RoofCollapseUtility.WithinRangeOfRoofHolder(intVec, map)) { if (removalMode && (canRemoveThickRoof || intVec.GetRoof(map).VanishOnCollapse)) { map.roofGrid.SetRoof(intVec, null); } else { map.roofCollapseBuffer.MarkToCollapse(intVec); } roofsCollapsingBecauseTooFar.Add(intVec); } } CheckCollapseFlyingRoofs(roofsCollapsingBecauseTooFar, map, removalMode, canRemoveThickRoof); roofsCollapsingBecauseTooFar.Clear(); }
public void MouseoverReadoutOnGUI() { if (Event.current.type != EventType.Repaint || Find.MainTabsRoot.OpenTab != null) { return; } GenUI.DrawTextWinterShadow(new Rect(256f, UI.screenHeight - 256, -256f, 256f)); Text.Font = GameFont.Small; GUI.color = new Color(1f, 1f, 1f, 0.8f); IntVec3 c = UI.MouseCell(); if (!c.InBounds(Find.CurrentMap)) { return; } float num = 0f; if (c.Fogged(Find.CurrentMap)) { Widgets.Label(new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f), "Undiscovered".Translate()); GUI.color = Color.white; return; } Rect rect = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); int num2 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f); Widgets.Label(rect, glowStrings[num2]); num += 19f; Rect rect2 = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); TerrainDef terrain = c.GetTerrain(Find.CurrentMap); if (terrain != cachedTerrain) { string t = ((double)terrain.fertility > 0.0001) ? (" " + "FertShort".TranslateSimple() + " " + terrain.fertility.ToStringPercent()) : ""; cachedTerrainString = terrain.LabelCap + ((terrain.passability != Traversability.Impassable) ? (" (" + "WalkSpeed".Translate(SpeedPercentString(terrain.pathCost)) + t + ")") : ((TaggedString)null)); cachedTerrain = terrain; } Widgets.Label(rect2, cachedTerrainString); num += 19f; Zone zone = c.GetZone(Find.CurrentMap); if (zone != null) { Rect rect3 = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string label = zone.label; Widgets.Label(rect3, label); num += 19f; } float depth = Find.CurrentMap.snowGrid.GetDepth(c); if (depth > 0.03f) { Rect rect4 = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth); string label2 = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(SpeedPercentString(SnowUtility.MovementTicksAddOn(snowCategory))) + ")"; Widgets.Label(rect4, label2); num += 19f; } List <Thing> thingList = c.GetThingList(Find.CurrentMap); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category != ThingCategory.Mote) { Rect rect5 = new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f); string labelMouseover = thing.LabelMouseover; Widgets.Label(rect5, labelMouseover); num += 19f; } } RoofDef roof = c.GetRoof(Find.CurrentMap); if (roof != null) { Widgets.Label(new Rect(BotLeft.x, (float)UI.screenHeight - BotLeft.y - num, 999f, 999f), roof.LabelCap); num += 19f; } GUI.color = Color.white; }
public static bool TryFindSkyfallerCell(ThingDef skyfaller, Map map, out IntVec3 cell, int minDistToEdge = 10, IntVec3 nearLoc = default(IntVec3), int nearLocMaxDist = -1, bool allowRoofedCells = true, bool allowCellsWithItems = false, bool allowCellsWithBuildings = false, bool colonyReachable = false, Predicate <IntVec3> extraValidator = null) { Predicate <IntVec3> validator = delegate(IntVec3 x) { CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, skyfaller.size).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (current.InBounds(map) && !current.Fogged(map) && current.Standable(map) && (!current.Roofed(map) || !current.GetRoof(map).isThickRoof)) { if (!allowRoofedCells && current.Roofed(map)) { return(false); } if (!allowCellsWithItems && current.GetFirstItem(map) != null) { return(false); } if (!allowCellsWithBuildings && current.GetFirstBuilding(map) != null) { return(false); } if (current.GetFirstSkyfaller(map) != null) { return(false); } iterator.MoveNext(); continue; } return(false); } if (minDistToEdge > 0 && x.DistanceToEdge(map) < minDistToEdge) { return(false); } if (colonyReachable && !map.reachability.CanReachColony(x)) { return(false); } if (extraValidator != null && !extraValidator(x)) { return(false); } return(true); }; if (nearLocMaxDist > 0) { return(CellFinder.TryFindRandomCellNear(nearLoc, map, nearLocMaxDist, validator, out cell)); } return(CellFinderLoose.TryFindRandomNotEdgeCellWith(minDistToEdge, validator, map, out cell)); }
public static bool TryFindSkyfallerCell(ThingDef skyfaller, Map map, out IntVec3 cell, int minDistToEdge = 10, IntVec3 nearLoc = default(IntVec3), int nearLocMaxDist = -1, bool allowRoofedCells = true, bool allowCellsWithItems = false, bool allowCellsWithBuildings = false, bool colonyReachable = false, bool avoidColonistsIfExplosive = true, bool alwaysAvoidColonists = false, Predicate <IntVec3> extraValidator = null) { bool avoidColonists = (avoidColonistsIfExplosive && skyfaller.skyfaller.CausesExplosion) || alwaysAvoidColonists; Predicate <IntVec3> validator = delegate(IntVec3 x) { CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, skyfaller.size).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (!current.InBounds(map) || current.Fogged(map) || !current.Standable(map) || (current.Roofed(map) && current.GetRoof(map).isThickRoof)) { return(false); } if (!allowRoofedCells && current.Roofed(map)) { return(false); } if (!allowCellsWithItems && current.GetFirstItem(map) != null) { return(false); } if (!allowCellsWithBuildings && current.GetFirstBuilding(map) != null) { return(false); } if (current.GetFirstSkyfaller(map) != null) { return(false); } iterator.MoveNext(); } return((!avoidColonists || !SkyfallerUtility.CanPossiblyFallOnColonist(skyfaller, x, map)) && (minDistToEdge <= 0 || x.DistanceToEdge(map) >= minDistToEdge) && (!colonyReachable || map.reachability.CanReachColony(x)) && (extraValidator == null || extraValidator(x))); }; if (nearLocMaxDist > 0) { return(CellFinder.TryFindRandomCellNear(nearLoc, map, nearLocMaxDist, validator, out cell, -1)); } return(CellFinderLoose.TryFindRandomNotEdgeCellWith(minDistToEdge, validator, map, out cell)); }
public void MouseoverReadoutOnGUI() { if (Event.current.type == EventType.Repaint) { if (Find.MainTabsRoot.OpenTab == null) { GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f)); Text.Font = GameFont.Small; GUI.color = new Color(1f, 1f, 1f, 0.8f); IntVec3 c = UI.MouseCell(); if (c.InBounds(Find.CurrentMap)) { float num = 0f; Profiler.BeginSample("fog"); if (c.Fogged(Find.CurrentMap)) { Rect rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); Widgets.Label(rect, "Undiscovered".Translate()); GUI.color = Color.white; Profiler.EndSample(); } else { Profiler.EndSample(); Profiler.BeginSample("light"); Rect rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); int num2 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c, false) * 100f); Widgets.Label(rect, this.glowStrings[num2]); num += 19f; Profiler.EndSample(); Profiler.BeginSample("terrain"); rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); TerrainDef terrain = c.GetTerrain(Find.CurrentMap); if (terrain != this.cachedTerrain) { string str = ((double)terrain.fertility <= 0.0001) ? "" : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent()); this.cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(new object[] { this.SpeedPercentString((float)terrain.pathCost) }) + str + ")")); this.cachedTerrain = terrain; } Widgets.Label(rect, this.cachedTerrainString); num += 19f; Profiler.EndSample(); Profiler.BeginSample("zone"); Zone zone = c.GetZone(Find.CurrentMap); if (zone != null) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); string label = zone.label; Widgets.Label(rect, label); num += 19f; } Profiler.EndSample(); float depth = Find.CurrentMap.snowGrid.GetDepth(c); if (depth > 0.03f) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth); string label2 = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(new object[] { this.SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory)) }) + ")"; Widgets.Label(rect, label2); num += 19f; } Profiler.BeginSample("things"); List <Thing> thingList = c.GetThingList(Find.CurrentMap); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category != ThingCategory.Mote) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); string labelMouseover = thing.LabelMouseover; Widgets.Label(rect, labelMouseover); num += 19f; } } Profiler.EndSample(); Profiler.BeginSample("roof"); RoofDef roof = c.GetRoof(Find.CurrentMap); if (roof != null) { rect = new Rect(MouseoverReadout.BotLeft.x, (float)UI.screenHeight - MouseoverReadout.BotLeft.y - num, 999f, 999f); Widgets.Label(rect, roof.LabelCap); num += 19f; } Profiler.EndSample(); GUI.color = Color.white; } } } } }
public void MouseoverReadoutOnGUI() { if (Event.current.type == EventType.Repaint && Find.MainTabsRoot.OpenTab == null) { GenUI.DrawTextWinterShadow(new Rect(256f, (float)(UI.screenHeight - 256), -256f, 256f)); Text.Font = GameFont.Small; GUI.color = new Color(1f, 1f, 1f, 0.8f); IntVec3 c = UI.MouseCell(); if (c.InBounds(Find.CurrentMap)) { float num = 0f; Rect rect = default(Rect); if (c.Fogged(Find.CurrentMap)) { Vector2 botLeft = BotLeft; float x = botLeft.x; float num2 = (float)UI.screenHeight; Vector2 botLeft2 = BotLeft; rect = new Rect(x, num2 - botLeft2.y - num, 999f, 999f); Widgets.Label(rect, "Undiscovered".Translate()); GUI.color = Color.white; } else { Vector2 botLeft3 = BotLeft; float x2 = botLeft3.x; float num3 = (float)UI.screenHeight; Vector2 botLeft4 = BotLeft; rect = new Rect(x2, num3 - botLeft4.y - num, 999f, 999f); int num4 = Mathf.RoundToInt(Find.CurrentMap.glowGrid.GameGlowAt(c) * 100f); Widgets.Label(rect, glowStrings[num4]); num += 19f; Vector2 botLeft5 = BotLeft; float x3 = botLeft5.x; float num5 = (float)UI.screenHeight; Vector2 botLeft6 = BotLeft; rect = new Rect(x3, num5 - botLeft6.y - num, 999f, 999f); TerrainDef terrain = c.GetTerrain(Find.CurrentMap); if (terrain != cachedTerrain) { string str = (!((double)terrain.fertility > 0.0001)) ? string.Empty : (" " + "FertShort".Translate() + " " + terrain.fertility.ToStringPercent()); cachedTerrainString = terrain.LabelCap + ((terrain.passability == Traversability.Impassable) ? null : (" (" + "WalkSpeed".Translate(SpeedPercentString((float)terrain.pathCost)) + str + ")")); cachedTerrain = terrain; } Widgets.Label(rect, cachedTerrainString); num += 19f; Zone zone = c.GetZone(Find.CurrentMap); if (zone != null) { Vector2 botLeft7 = BotLeft; float x4 = botLeft7.x; float num6 = (float)UI.screenHeight; Vector2 botLeft8 = BotLeft; rect = new Rect(x4, num6 - botLeft8.y - num, 999f, 999f); string label = zone.label; Widgets.Label(rect, label); num += 19f; } float depth = Find.CurrentMap.snowGrid.GetDepth(c); if (depth > 0.03f) { Vector2 botLeft9 = BotLeft; float x5 = botLeft9.x; float num7 = (float)UI.screenHeight; Vector2 botLeft10 = BotLeft; rect = new Rect(x5, num7 - botLeft10.y - num, 999f, 999f); SnowCategory snowCategory = SnowUtility.GetSnowCategory(depth); string label2 = SnowUtility.GetDescription(snowCategory) + " (" + "WalkSpeed".Translate(SpeedPercentString((float)SnowUtility.MovementTicksAddOn(snowCategory))) + ")"; Widgets.Label(rect, label2); num += 19f; } List <Thing> thingList = c.GetThingList(Find.CurrentMap); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category != ThingCategory.Mote) { Vector2 botLeft11 = BotLeft; float x6 = botLeft11.x; float num8 = (float)UI.screenHeight; Vector2 botLeft12 = BotLeft; rect = new Rect(x6, num8 - botLeft12.y - num, 999f, 999f); string labelMouseover = thing.LabelMouseover; Widgets.Label(rect, labelMouseover); num += 19f; } } RoofDef roof = c.GetRoof(Find.CurrentMap); if (roof != null) { Vector2 botLeft13 = BotLeft; float x7 = botLeft13.x; float num9 = (float)UI.screenHeight; Vector2 botLeft14 = BotLeft; rect = new Rect(x7, num9 - botLeft14.y - num, 999f, 999f); Widgets.Label(rect, roof.LabelCap); num += 19f; } GUI.color = Color.white; } } } }