private static bool CheckCollapseFlyingRoofAtAndAdjInternal(IntVec3 root, Map map, bool removalMode, bool canRemoveThickRoof) { RoofCollapseBuffer roofCollapseBuffer = map.roofCollapseBuffer; if (removalMode && roofCollapseBuffer.CellsMarkedToCollapse.Count > 0) { map.roofCollapseBufferResolver.CollapseRoofsMarkedToCollapse(); } for (int i = 0; i < 5; i++) { IntVec3 intVec = root + GenAdj.CardinalDirectionsAndInside[i]; if (intVec.InBounds(map) && intVec.Roofed(map) && !visitedCells.Contains(intVec) && !roofCollapseBuffer.IsMarkedToCollapse(intVec) && !ConnectsToRoofHolder(intVec, map, visitedCells)) { map.floodFiller.FloodFill(intVec, (IntVec3 x) => x.Roofed(map), delegate(IntVec3 x) { roofCollapseBuffer.MarkToCollapse(x); }); if (removalMode) { List <IntVec3> cellsMarkedToCollapse = roofCollapseBuffer.CellsMarkedToCollapse; for (int num = cellsMarkedToCollapse.Count - 1; num >= 0; num--) { RoofDef roofDef = map.roofGrid.RoofAt(cellsMarkedToCollapse[num]); if (roofDef != null && (canRemoveThickRoof || roofDef.VanishOnCollapse)) { map.roofGrid.SetRoof(cellsMarkedToCollapse[num], null); cellsMarkedToCollapse.RemoveAt(num); } } } } } return(false); }
public void SetRoof(IntVec3 c, RoofDef def) { ushort num; if (def == null) { num = 0; } else { num = def.shortHash; } if (this.roofGrid[this.map.cellIndices.CellToIndex(c)] == num) { return; } this.roofGrid[this.map.cellIndices.CellToIndex(c)] = num; this.map.glowGrid.MarkGlowGridDirty(c); Region validRegionAt_NoRebuild = this.map.regionGrid.GetValidRegionAt_NoRebuild(c); if (validRegionAt_NoRebuild != null) { validRegionAt_NoRebuild.Room.Notify_RoofChanged(); } if (this.drawerInt != null) { this.drawerInt.SetDirty(); } this.map.mapDrawer.MapMeshDirty(c, MapMeshFlag.Roofs); }
private static void DropRoofInCellPhaseTwo(IntVec3 c, Map map) { RoofDef roofDef = map.roofGrid.RoofAt(c); if (roofDef == null) { return; } if (roofDef.filthLeaving != null) { FilthMaker.MakeFilth(c, map, roofDef.filthLeaving, 1); } if (roofDef.VanishOnCollapse) { map.roofGrid.SetRoof(c, null); } CellRect bound = CellRect.CenteredOn(c, 2); foreach (Pawn current in from pawn in map.mapPawns.AllPawnsSpawned where bound.Contains(pawn.Position) select pawn) { TaleRecorder.RecordTale(TaleDefOf.CollapseDodged, new object[] { current }); } }
private void ImpactSomething() { if (base.def.projectile.flyOverhead) { RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position); if (roofDef != null) { if (roofDef.isThickRoof) { base.def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); this.Destroy(DestroyMode.Vanish); return; } if (base.Position.GetEdifice(base.Map) == null || base.Position.GetEdifice(base.Map).def.Fillage != FillCategory.Full) { RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map); } } } if (this.assignedTarget != null) { Pawn pawn = this.assignedTarget as Pawn; if (pawn != null && pawn.GetPosture() != 0 && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25 && Rand.Value > 0.20000000298023224) { this.Impact(null); } else { this.Impact(this.assignedTarget); } } else { Projectile.cellThingsFiltered.Clear(); List <Thing> thingList = base.Position.GetThingList(base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Building || thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Plant) { Projectile.cellThingsFiltered.Add(thing); } } Projectile.cellThingsFiltered.Shuffle(); for (int j = 0; j < Projectile.cellThingsFiltered.Count; j++) { Thing t = Projectile.cellThingsFiltered[j]; if (Rand.Value < Projectile.ImpactSomethingHitThingChance(t)) { this.Impact(Projectile.cellThingsFiltered.RandomElement()); return; } } this.Impact(null); } }
public void SetRoof(IntVec3 c, RoofDef def) { if (roofGrid[map.cellIndices.CellToIndex(c)] != def) { roofGrid[map.cellIndices.CellToIndex(c)] = def; map.glowGrid.MarkGlowGridDirty(c); map.regionGrid.GetValidRegionAt_NoRebuild(c)?.Room.Notify_RoofChanged(); if (drawerInt != null) { drawerInt.SetDirty(); } map.mapDrawer.MapMeshDirty(c, MapMeshFlag.Roofs); } }
private static bool CheckCollapseFlyingRoofAtAndAdjInternal(IntVec3 root, Map map, bool removalMode) { RoofCollapseBuffer roofCollapseBuffer = map.roofCollapseBuffer; if (removalMode && roofCollapseBuffer.CellsMarkedToCollapse.Count > 0) { map.roofCollapseBufferResolver.CollapseRoofsMarkedToCollapse(); } for (int i = 0; i < 5; i++) { IntVec3 intVec = root + GenAdj.CardinalDirectionsAndInside[i]; if (intVec.InBounds(map)) { if (intVec.Roofed(map)) { if (!RoofCollapseCellsFinder.visitedCells.Contains(intVec)) { if (!roofCollapseBuffer.IsMarkedToCollapse(intVec)) { if (!RoofCollapseCellsFinder.ConnectsToRoofHolder(intVec, map, RoofCollapseCellsFinder.visitedCells)) { map.floodFiller.FloodFill(intVec, (IntVec3 x) => x.Roofed(map), delegate(IntVec3 x) { roofCollapseBuffer.MarkToCollapse(x); }, 2147483647, false, null); if (removalMode) { List <IntVec3> cellsMarkedToCollapse = roofCollapseBuffer.CellsMarkedToCollapse; for (int j = cellsMarkedToCollapse.Count - 1; j >= 0; j--) { RoofDef roofDef = map.roofGrid.RoofAt(cellsMarkedToCollapse[j]); if (roofDef != null && roofDef.VanishOnCollapse) { map.roofGrid.SetRoof(cellsMarkedToCollapse[j], null); cellsMarkedToCollapse.RemoveAt(j); } } } } } } } } } return(false); }
public void SetRoof(IntVec3 c, RoofDef def) { if (this.roofGrid[this.map.cellIndices.CellToIndex(c)] != def) { this.roofGrid[this.map.cellIndices.CellToIndex(c)] = def; this.map.glowGrid.MarkGlowGridDirty(c); Region validRegionAt_NoRebuild = this.map.regionGrid.GetValidRegionAt_NoRebuild(c); if (validRegionAt_NoRebuild != null) { validRegionAt_NoRebuild.Room.Notify_RoofChanged(); } if (this.drawerInt != null) { this.drawerInt.SetDirty(); } this.map.mapDrawer.MapMeshDirty(c, MapMeshFlag.Roofs); } }
private static void DropRoofInCellPhaseTwo(IntVec3 c, Map map) { RoofDef roofDef = map.roofGrid.RoofAt(c); if (roofDef != null) { if (roofDef.filthLeaving != null) { FilthMaker.TryMakeFilth(c, map, roofDef.filthLeaving); } if (roofDef.VanishOnCollapse) { map.roofGrid.SetRoof(c, null); } CellRect bound = CellRect.CenteredOn(c, 2); foreach (Pawn item in map.mapPawns.AllPawnsSpawned.Where((Pawn pawn) => bound.Contains(pawn.Position))) { TaleRecorder.RecordTale(TaleDefOf.CollapseDodged, item); } } }
private static void DropRoofInCellPhaseOne(IntVec3 c, Map map, List <Thing> outCrushedThings) { RoofDef roofDef = map.roofGrid.RoofAt(c); if (roofDef == null) { return; } if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable) { for (int i = 0; i < 2; i++) { List <Thing> thingList = c.GetThingList(map); for (int j = thingList.Count - 1; j >= 0; j--) { Thing thing = thingList[j]; RoofCollapserImmediate.TryAddToCrushedThingsList(thing, outCrushedThings); Pawn pawn = thing as Pawn; DamageInfo dinfo; if (pawn != null) { DamageDef crush = DamageDefOf.Crush; float amount = 99999f; float armorPenetration = 999f; BodyPartRecord brain = pawn.health.hediffSet.GetBrain(); dinfo = new DamageInfo(crush, amount, armorPenetration, -1f, null, brain, null, DamageInfo.SourceCategory.Collapse, null); } else { dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null); dinfo.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null; if (i == 0 && pawn != null) { battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_Ceiling, null); Find.BattleLog.Add(battleLogEntry_DamageTaken); } thing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_DamageTaken); if (!thing.Destroyed && thing.def.destroyable) { thing.Kill(new DamageInfo?(new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null)), null); } } } } else { List <Thing> thingList2 = c.GetThingList(map); for (int k = thingList2.Count - 1; k >= 0; k--) { Thing thing2 = thingList2[k]; if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn) { RoofCollapserImmediate.TryAddToCrushedThingsList(thing2, outCrushedThings); float num = (float)RoofCollapserImmediate.ThinRoofCrushDamageRange.RandomInRange; if (thing2.def.building != null) { num *= thing2.def.building.roofCollapseDamageMultiplier; } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null; if (thing2 is Pawn) { battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken((Pawn)thing2, RulePackDefOf.DamageEvent_Ceiling, null); Find.BattleLog.Add(battleLogEntry_DamageTaken2); } DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, (float)GenMath.RoundRandom(num), 0f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null); dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); thing2.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_DamageTaken2); } } } if (roofDef.collapseLeavingThingDef != null) { Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map, WipeMode.Vanish); if (thing3.def.rotatable) { thing3.Rotation = Rot4.Random; } } for (int l = 0; l < 1; l++) { Vector3 vector = c.ToVector3Shifted(); vector += Gen.RandomHorizontalVector(0.6f); MoteMaker.ThrowDustPuff(vector, map, 2f); } }
public override void Regenerate() { LayerSubMesh subMesh = base.GetSubMesh(MatBases.LightOverlay); if (subMesh.verts.Count == 0) { this.MakeBaseGeometry(subMesh); } Color32[] array = new Color32[subMesh.verts.Count]; int maxX = this.sectRect.maxX; int maxZ = this.sectRect.maxZ; int width = this.sectRect.Width; Map map = base.Map; int x = map.Size.x; Thing[] innerArray = map.edificeGrid.InnerArray; int num = innerArray.Length; RoofGrid roofGrid = map.roofGrid; CellIndices cellIndices = map.cellIndices; int num2; int num3; int num4; int num5; int num6; this.CalculateVertexIndices(this.sectRect.minX, this.sectRect.minZ, out num2, out num3, out num4, out num5, out num6); int num7 = cellIndices.CellToIndex(new IntVec3(this.sectRect.minX, 0, this.sectRect.minZ)); int[] array2 = new int[4]; array2[0] = -map.Size.x - 1; array2[1] = -map.Size.x; array2[2] = -1; int[] array3 = array2; int[] array4 = new int[4]; array4[0] = -1; array4[1] = -1; int[] array5 = array4; for (int i = this.sectRect.minZ; i <= maxZ + 1; i++) { int num8 = num7 / x; int j = this.sectRect.minX; while (j <= maxX + 1) { ColorInt colorInt = new ColorInt(0, 0, 0, 0); int num9 = 0; bool flag = false; for (int k = 0; k < 4; k++) { int num10 = num7 + array3[k]; if (num10 >= 0 && num10 < num && num10 / x == num8 + array5[k]) { Thing thing = innerArray[num10]; RoofDef roofDef = roofGrid.RoofAt(num10); if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable)) { flag = true; } if (thing == null || !thing.def.blockLight) { colorInt += this.glowGrid[num10]; num9++; } } } if (num9 > 0) { array[num2] = (colorInt / num9).ToColor32; } else { array[num2] = new Color32(0, 0, 0, 0); } if (flag && array[num2].a < 100) { array[num2].a = 100; } j++; num2++; num7++; } int num11 = maxX + 2 - this.sectRect.minX; num2 -= num11; num7 -= num11; num2 += width + 1; num7 += map.Size.x; } int num12; int num13; int num14; int num15; int num16; this.CalculateVertexIndices(this.sectRect.minX, this.sectRect.minZ, out num12, out num13, out num14, out num15, out num16); int num17 = cellIndices.CellToIndex(this.sectRect.minX, this.sectRect.minZ); for (int l = this.sectRect.minZ; l <= maxZ; l++) { int m = this.sectRect.minX; while (m <= maxX) { ColorInt colA = default(ColorInt) + array[num12]; colA += array[num12 + 1]; colA += array[num12 + width + 1]; colA += array[num12 + width + 2]; array[num16] = new Color32((byte)(colA.r / 4), (byte)(colA.g / 4), (byte)(colA.b / 4), (byte)(colA.a / 4)); if (array[num16].a < 100 && roofGrid.Roofed(num17)) { Thing thing2 = innerArray[num17]; if (thing2 == null || !thing2.def.holdsRoof) { array[num16].a = 100; } } m++; num12++; num16++; num17++; } num12++; num17 -= width; num17 += map.Size.x; } subMesh.mesh.colors32 = array; }
private static void DropRoofInCellPhaseOne(IntVec3 c, Map map, List <Thing> outCrushedThings) { RoofDef roofDef = map.roofGrid.RoofAt(c); if (roofDef == null) { return; } if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable) { for (int i = 0; i < 2; i++) { List <Thing> thingList = c.GetThingList(map); for (int num = thingList.Count - 1; num >= 0; num--) { Thing thing = thingList[num]; TryAddToCrushedThingsList(thing, outCrushedThings); Pawn pawn = thing as Pawn; DamageInfo dinfo; if (pawn != null) { dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, pawn.health.hediffSet.GetBrain(), null, DamageInfo.SourceCategory.Collapse); } else { dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse); dinfo.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null; if (i == 0 && pawn != null) { battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_Ceiling); Find.BattleLog.Add(battleLogEntry_DamageTaken); } thing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_DamageTaken); if (!thing.Destroyed && thing.def.destroyable) { thing.Kill(new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse)); } } } } else { List <Thing> thingList2 = c.GetThingList(map); for (int num2 = thingList2.Count - 1; num2 >= 0; num2--) { Thing thing2 = thingList2[num2]; if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn) { TryAddToCrushedThingsList(thing2, outCrushedThings); float num3 = ThinRoofCrushDamageRange.RandomInRange; if (thing2.def.building != null) { num3 *= thing2.def.building.roofCollapseDamageMultiplier; } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null; if (thing2 is Pawn) { battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken((Pawn)thing2, RulePackDefOf.DamageEvent_Ceiling); Find.BattleLog.Add(battleLogEntry_DamageTaken2); } DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, GenMath.RoundRandom(num3), 0f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse); dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); thing2.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_DamageTaken2); } } } if (roofDef.collapseLeavingThingDef != null) { Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map); if (thing3.def.rotatable) { thing3.Rotation = Rot4.Random; } } for (int j = 0; j < 1; j++) { MoteMaker.ThrowDustPuff(c.ToVector3Shifted() + Gen.RandomHorizontalVector(0.6f), map, 2f); } }
public override void Regenerate() { LayerSubMesh subMesh = GetSubMesh(MatBases.LightOverlay); if (subMesh.verts.Count == 0) { MakeBaseGeometry(subMesh); } Color32[] array = new Color32[subMesh.verts.Count]; int maxX = sectRect.maxX; int maxZ = sectRect.maxZ; int width = sectRect.Width; Map map = base.Map; int x = map.Size.x; Thing[] innerArray = map.edificeGrid.InnerArray; Thing[] array2 = innerArray; int num = array2.Length; RoofGrid roofGrid = map.roofGrid; CellIndices cellIndices = map.cellIndices; CalculateVertexIndices(sectRect.minX, sectRect.minZ, out int botLeft, out int _, out int _, out int _, out int _); int num2 = cellIndices.CellToIndex(new IntVec3(sectRect.minX, 0, sectRect.minZ)); int[] array3 = new int[4] { -map.Size.x - 1, -map.Size.x, -1, 0 }; int[] array4 = new int[4] { -1, -1, 0, 0 }; for (int i = sectRect.minZ; i <= maxZ + 1; i++) { int num3 = num2 / x; int num4 = sectRect.minX; while (num4 <= maxX + 1) { ColorInt a = new ColorInt(0, 0, 0, 0); int num5 = 0; bool flag = false; for (int j = 0; j < 4; j++) { int num6 = num2 + array3[j]; if (num6 >= 0 && num6 < num && num6 / x == num3 + array4[j]) { Thing thing = array2[num6]; RoofDef roofDef = roofGrid.RoofAt(num6); if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable)) { flag = true; } if (thing == null || !thing.def.blockLight) { a += glowGrid[num6]; num5++; } } } if (num5 > 0) { array[botLeft] = (a / num5).ToColor32; } else { array[botLeft] = new Color32(0, 0, 0, 0); } if (flag && array[botLeft].a < 100) { array[botLeft].a = 100; } num4++; botLeft++; num2++; } int num7 = maxX + 2 - sectRect.minX; botLeft -= num7; num2 -= num7; botLeft += width + 1; num2 += map.Size.x; } CalculateVertexIndices(sectRect.minX, sectRect.minZ, out int botLeft2, out int _, out int _, out int _, out int center2); int num8 = cellIndices.CellToIndex(sectRect.minX, sectRect.minZ); for (int k = sectRect.minZ; k <= maxZ; k++) { int num9 = sectRect.minX; while (num9 <= maxX) { ColorInt colorInt = default(ColorInt) + array[botLeft2]; colorInt += array[botLeft2 + 1]; colorInt += array[botLeft2 + width + 1]; colorInt += array[botLeft2 + width + 2]; array[center2] = new Color32((byte)(colorInt.r / 4), (byte)(colorInt.g / 4), (byte)(colorInt.b / 4), (byte)(colorInt.a / 4)); if (array[center2].a < 100 && roofGrid.Roofed(num8)) { Thing thing2 = array2[num8]; if (thing2 == null || !thing2.def.holdsRoof) { array[center2].a = 100; } } num9++; botLeft2++; center2++; num8++; } botLeft2++; num8 -= width; num8 += map.Size.x; } subMesh.mesh.colors32 = array; }
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 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; } } } } }
private void TryGenerateAreaNow(Room room) { if (!room.Dereferenced && !room.TouchesMapEdge && room.RegionCount <= 26 && room.CellCount <= 320 && room.RegionType != RegionType.Portal) { bool flag = false; foreach (IntVec3 borderCell in room.BorderCells) { Thing roofHolderOrImpassable = borderCell.GetRoofHolderOrImpassable(map); if (roofHolderOrImpassable != null) { if ((roofHolderOrImpassable.Faction != null && roofHolderOrImpassable.Faction != Faction.OfPlayer) || (roofHolderOrImpassable.def.building != null && !roofHolderOrImpassable.def.building.allowAutoroof)) { return; } if (roofHolderOrImpassable.Faction == Faction.OfPlayer) { flag = true; } } } if (flag) { innerCells.Clear(); foreach (IntVec3 cell in room.Cells) { if (!innerCells.Contains(cell)) { innerCells.Add(cell); } for (int i = 0; i < 8; i++) { IntVec3 c = cell + GenAdj.AdjacentCells[i]; if (c.InBounds(map)) { Thing roofHolderOrImpassable2 = c.GetRoofHolderOrImpassable(map); if (roofHolderOrImpassable2 != null && (roofHolderOrImpassable2.def.size.x > 1 || roofHolderOrImpassable2.def.size.z > 1)) { CellRect cellRect = roofHolderOrImpassable2.OccupiedRect(); cellRect.ClipInsideMap(map); for (int j = cellRect.minZ; j <= cellRect.maxZ; j++) { for (int k = cellRect.minX; k <= cellRect.maxX; k++) { IntVec3 item = new IntVec3(k, 0, j); if (!innerCells.Contains(item)) { innerCells.Add(item); } } } } } } } cellsToRoof.Clear(); foreach (IntVec3 innerCell in innerCells) { for (int l = 0; l < 9; l++) { IntVec3 intVec = innerCell + GenAdj.AdjacentCellsAndInside[l]; if (intVec.InBounds(map) && (l == 8 || intVec.GetRoofHolderOrImpassable(map) != null) && !cellsToRoof.Contains(intVec)) { cellsToRoof.Add(intVec); } } } justRoofedCells.Clear(); foreach (IntVec3 item2 in cellsToRoof) { RoofDef roofDef = map.roofGrid.RoofAt(item2); if (roofDef == null && !justRoofedCells.Contains(item2) && !map.areaManager.NoRoof[item2] && RoofCollapseUtility.WithinRangeOfRoofHolder(item2, map, assumeNonNoRoofCellsAreRoofed: true)) { map.areaManager.BuildRoof[item2] = true; justRoofedCells.Add(item2); } } } } }
private void RegenerateEqualizationData() { thickRoofCoverage = 0f; noRoofCoverage = 0f; equalizeCells.Clear(); if (roomGroup.RoomCount != 0) { Map map = Map; if (!roomGroup.UsesOutdoorTemperature) { int num = 0; foreach (IntVec3 cell in roomGroup.Cells) { RoofDef roof = cell.GetRoof(map); if (roof == null) { noRoofCoverage += 1f; } else if (roof.isThickRoof) { thickRoofCoverage += 1f; } num++; } thickRoofCoverage /= num; noRoofCoverage /= num; foreach (IntVec3 cell2 in roomGroup.Cells) { for (int i = 0; i < 4; i++) { IntVec3 intVec = cell2 + GenAdj.CardinalDirections[i]; IntVec3 intVec2 = cell2 + GenAdj.CardinalDirections[i] * 2; if (intVec.InBounds(map)) { Region region = intVec.GetRegion(map); if (region != null) { if (region.type != RegionType.Portal) { continue; } bool flag = false; for (int j = 0; j < region.links.Count; j++) { Region regionA = region.links[j].RegionA; Region regionB = region.links[j].RegionB; if (regionA.Room.Group != roomGroup && !regionA.IsDoorway) { flag = true; break; } if (regionB.Room.Group != roomGroup && !regionB.IsDoorway) { flag = true; break; } } if (flag) { continue; } } } if (intVec2.InBounds(map) && intVec2.GetRoomGroup(map) != roomGroup) { bool flag2 = false; for (int k = 0; k < 4; k++) { if ((intVec2 + GenAdj.CardinalDirections[k]).GetRoomGroup(map) == roomGroup) { flag2 = true; break; } } if (!flag2) { equalizeCells.Add(intVec2); } } } } equalizeCells.Shuffle(); } } }
private void RegenerateEqualizationData() { this.thickRoofCoverage = 0f; this.noRoofCoverage = 0f; this.equalizeCells.Clear(); if (this.roomGroup.RoomCount != 0) { Map map = this.Map; if (!this.roomGroup.UsesOutdoorTemperature) { int num = 0; foreach (IntVec3 cell in this.roomGroup.Cells) { RoofDef roof = cell.GetRoof(map); if (roof == null) { this.noRoofCoverage += 1f; } else if (roof.isThickRoof) { this.thickRoofCoverage += 1f; } num++; } this.thickRoofCoverage /= (float)num; this.noRoofCoverage /= (float)num; foreach (IntVec3 cell2 in this.roomGroup.Cells) { for (int i = 0; i < 4; i++) { IntVec3 intVec = cell2 + GenAdj.CardinalDirections[i]; IntVec3 intVec2 = cell2 + GenAdj.CardinalDirections[i] * 2; if (intVec.InBounds(map)) { Region region = intVec.GetRegion(map, RegionType.Set_Passable); if (region != null) { if (region.type == RegionType.Portal) { bool flag = false; for (int j = 0; j < region.links.Count; j++) { Region regionA = region.links[j].RegionA; Region regionB = region.links[j].RegionB; if (regionA.Room.Group != this.roomGroup && regionA.portal == null) { flag = true; break; } if (regionB.Room.Group != this.roomGroup && regionB.portal == null) { flag = true; break; } } if (!flag) { goto IL_0234; } } continue; } } goto IL_0234; IL_0234: if (intVec2.InBounds(map)) { RoomGroup roomGroup = intVec2.GetRoomGroup(map); if (roomGroup != this.roomGroup) { bool flag2 = false; for (int k = 0; k < 4; k++) { IntVec3 loc = intVec2 + GenAdj.CardinalDirections[k]; if (loc.GetRoomGroup(map) == this.roomGroup) { flag2 = true; break; } } if (!flag2) { this.equalizeCells.Add(intVec2); } } } } } this.equalizeCells.Shuffle(); } } }
private void ImpactSomething() { if (this.def.projectile.flyOverhead) { RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position); if (roofDef != null) { if (roofDef.isThickRoof) { this.ThrowDebugText("hit-thick-roof", base.Position); this.def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); this.Destroy(DestroyMode.Vanish); return; } if (base.Position.GetEdifice(base.Map) == null || base.Position.GetEdifice(base.Map).def.Fillage != FillCategory.Full) { RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map, null); } } } if (!this.usedTarget.HasThing || !this.CanHit(this.usedTarget.Thing)) { Projectile.cellThingsFiltered.Clear(); List <Thing> thingList = base.Position.GetThingList(base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if ((thing.def.category == ThingCategory.Building || thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Plant) && this.CanHit(thing)) { Projectile.cellThingsFiltered.Add(thing); } } Projectile.cellThingsFiltered.Shuffle <Thing>(); for (int j = 0; j < Projectile.cellThingsFiltered.Count; j++) { Thing thing2 = Projectile.cellThingsFiltered[j]; Pawn pawn = thing2 as Pawn; float num; if (pawn != null) { num = 0.5f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f); if (pawn.GetPosture() != PawnPosture.Standing && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25f) { num *= 0.2f; } if (this.launcher != null && pawn.Faction != null && this.launcher.Faction != null && !pawn.Faction.HostileTo(this.launcher.Faction)) { num *= VerbUtility.InterceptChanceFactorFromDistance(this.origin, base.Position); } } else { num = 1.5f * thing2.def.fillPercent; } if (Rand.Chance(num)) { this.ThrowDebugText("hit-" + num.ToStringPercent(), base.Position); this.Impact(Projectile.cellThingsFiltered.RandomElement <Thing>()); return; } this.ThrowDebugText("miss-" + num.ToStringPercent(), base.Position); } this.Impact(null); return; } Pawn pawn2 = this.usedTarget.Thing as Pawn; if (pawn2 != null && pawn2.GetPosture() != PawnPosture.Standing && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25f && !Rand.Chance(0.2f)) { this.ThrowDebugText("miss-laying", base.Position); this.Impact(null); return; } this.Impact(this.usedTarget.Thing); }
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; } } } }
public override void Regenerate() { LayerSubMesh subMesh = base.GetSubMesh(MatBases.LightOverlay); if (subMesh.verts.Count == 0) { this.MakeBaseGeometry(subMesh); } Color32[] array = new Color32[subMesh.verts.Count]; int maxX = this.sectRect.maxX; int maxZ = this.sectRect.maxZ; bool[] array2 = new bool[4]; Thing[] innerArray = base.Map.edificeGrid.InnerArray; RoofGrid roofGrid = base.Map.roofGrid; CellIndices cellIndices = base.Map.cellIndices; for (int i = this.sectRect.minX; i <= maxX + 1; i++) { for (int j = this.sectRect.minZ; j <= maxZ + 1; j++) { int num = default(int); int num2 = default(int); int num3 = default(int); int num4 = default(int); int num5 = default(int); this.CalculateVertexIndices(i, j, out num, out num2, out num3, out num4, out num5); IntVec3 a = new IntVec3(i, 0, j); bool flag = false; for (int k = 0; k < 4; k++) { IntVec3 c = a + SectionLayer_LightingOverlay.CheckSquareOffsets[k]; if (!c.InBounds(base.Map)) { array2[k] = true; } else { Thing thing = innerArray[cellIndices.CellToIndex(c)]; RoofDef roofDef = roofGrid.RoofAt(c.x, c.z); if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable)) { flag = true; } if (thing != null && thing.def.blockLight) { array2[k] = true; } else { array2[k] = false; } } } ColorInt colorInt = new ColorInt(0, 0, 0, 0); int num6 = 0; if (!array2[0]) { colorInt += this.glowGrid[cellIndices.CellToIndex(i, j - 1)].AsColorInt(); num6++; } if (!array2[1]) { colorInt += this.glowGrid[cellIndices.CellToIndex(i - 1, j - 1)].AsColorInt(); num6++; } if (!array2[2]) { colorInt += this.glowGrid[cellIndices.CellToIndex(i - 1, j)].AsColorInt(); num6++; } if (!array2[3]) { colorInt += this.glowGrid[cellIndices.CellToIndex(i, j)].AsColorInt(); num6++; } if (num6 > 0) { colorInt /= (float)num6; array[num] = colorInt.ToColor32; } else { array[num] = new Color32(0, 0, 0, 0); } if (flag && array[num].a < 100) { array[num].a = 100; } } } for (int l = this.sectRect.minX; l <= maxX; l++) { for (int m = this.sectRect.minZ; m <= maxZ; m++) { int num7 = default(int); int num8 = default(int); int num9 = default(int); int num10 = default(int); int num11 = default(int); this.CalculateVertexIndices(l, m, out num7, out num8, out num9, out num10, out num11); ColorInt colA = default(ColorInt) + array[num7]; colA += array[num8]; colA += array[num9]; colA += array[num10]; array[num11] = (colA / 4f).ToColor32; Thing thing = innerArray[cellIndices.CellToIndex(l, m)]; if (roofGrid.Roofed(l, m) && (thing == null || !thing.def.holdsRoof) && array[num11].a < 100) { array[num11].a = 100; } } } subMesh.mesh.colors32 = array; }
private static void DropRoofInCellPhaseOne(IntVec3 c, Map map) { RoofDef roofDef = map.roofGrid.RoofAt(c); if (roofDef != null) { if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable) { for (int i = 0; i < 2; i++) { List <Thing> thingList = c.GetThingList(map); for (int num = thingList.Count - 1; num >= 0; num--) { Thing thing = thingList[num]; map.roofCollapseBuffer.Notify_Crushed(thing); Pawn pawn = thing as Pawn; DamageInfo dinfo = default(DamageInfo); if (pawn != null) { DamageDef crush = DamageDefOf.Crush; int amount = 99999; BodyPartRecord brain = pawn.health.hediffSet.GetBrain(); dinfo = new DamageInfo(crush, amount, -1f, null, brain, null, DamageInfo.SourceCategory.Collapse); } else { dinfo = new DamageInfo(DamageDefOf.Crush, 99999, -1f, null, null, null, DamageInfo.SourceCategory.Collapse); dinfo.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null; if (i == 0 && pawn != null) { battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_Ceiling, null); Find.BattleLog.Add(battleLogEntry_DamageTaken); } thing.TakeDamage(dinfo).InsertIntoLog(battleLogEntry_DamageTaken); if (!thing.Destroyed && thing.def.destroyable) { thing.Destroy(DestroyMode.Vanish); } } } } else { List <Thing> thingList2 = c.GetThingList(map); for (int num2 = thingList2.Count - 1; num2 >= 0; num2--) { Thing thing2 = thingList2[num2]; if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn) { map.roofCollapseBuffer.Notify_Crushed(thing2); float num3 = (float)RoofCollapserImmediate.ThinRoofCrushDamageRange.RandomInRange; if (thing2.def.building != null) { num3 *= thing2.def.building.roofCollapseDamageMultiplier; } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null; if (thing2 is Pawn) { battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken(thing2 as Pawn, RulePackDefOf.DamageEvent_Ceiling, null); Find.BattleLog.Add(battleLogEntry_DamageTaken2); } DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, GenMath.RoundRandom(num3), -1f, null, null, null, DamageInfo.SourceCategory.Collapse); dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); thing2.TakeDamage(dinfo2).InsertIntoLog(battleLogEntry_DamageTaken2); } } } if (roofDef.collapseLeavingThingDef != null) { Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map); if (thing3.def.rotatable) { thing3.Rotation = Rot4.Random; } } for (int j = 0; j < 1; j++) { Vector3 a = c.ToVector3Shifted(); a += Gen.RandomHorizontalVector(0.6f); MoteMaker.ThrowDustPuff(a, map, 2f); } } }