public static void MakeBaseGeometry(Section section, LayerSubMesh sm, AltitudeLayer altitudeLayer) { sm.Clear(MeshParts.Verts | MeshParts.Tris); CellRect cellRect = new CellRect(section.botLeft.x, section.botLeft.z, 17, 17); cellRect.ClipInsideMap(section.map); float y = altitudeLayer.AltitudeFor(); sm.verts.Capacity = cellRect.Area * 9; for (int i = cellRect.minX; i <= cellRect.maxX; i++) { for (int j = cellRect.minZ; j <= cellRect.maxZ; j++) { sm.verts.Add(new Vector3(i, y, j)); sm.verts.Add(new Vector3(i, y, (float)j + 0.5f)); sm.verts.Add(new Vector3(i, y, j + 1)); sm.verts.Add(new Vector3((float)i + 0.5f, y, j + 1)); sm.verts.Add(new Vector3(i + 1, y, j + 1)); sm.verts.Add(new Vector3(i + 1, y, (float)j + 0.5f)); sm.verts.Add(new Vector3(i + 1, y, j)); sm.verts.Add(new Vector3((float)i + 0.5f, y, j)); sm.verts.Add(new Vector3((float)i + 0.5f, y, (float)j + 0.5f)); } } int num = cellRect.Area * 8 * 3; sm.tris.Capacity = num; int num2 = 0; while (sm.tris.Count < num) { sm.tris.Add(num2 + 7); sm.tris.Add(num2); sm.tris.Add(num2 + 1); sm.tris.Add(num2 + 1); sm.tris.Add(num2 + 2); sm.tris.Add(num2 + 3); sm.tris.Add(num2 + 3); sm.tris.Add(num2 + 4); sm.tris.Add(num2 + 5); sm.tris.Add(num2 + 5); sm.tris.Add(num2 + 6); sm.tris.Add(num2 + 7); sm.tris.Add(num2 + 7); sm.tris.Add(num2 + 1); sm.tris.Add(num2 + 8); sm.tris.Add(num2 + 1); sm.tris.Add(num2 + 3); sm.tris.Add(num2 + 8); sm.tris.Add(num2 + 3); sm.tris.Add(num2 + 5); sm.tris.Add(num2 + 8); sm.tris.Add(num2 + 5); sm.tris.Add(num2 + 7); sm.tris.Add(num2 + 8); num2 += 9; } sm.FinalizeMesh(MeshParts.Verts | MeshParts.Tris); }
private static void Rock21x21() { CellRect cellRect = CellRect.CenteredOn(UI.MouseCell(), 10); cellRect.ClipInsideMap(Find.CurrentMap); foreach (IntVec3 item in cellRect) { GenSpawn.Spawn(ThingDefOf.Granite, item, Find.CurrentMap); } }
public void DebugDraw() { if (this.map != Find.CurrentMap) { return; } if (DebugViewSettings.drawRegionTraversal) { CellRect currentViewRect = Find.CameraDriver.CurrentViewRect; currentViewRect.ClipInsideMap(this.map); foreach (IntVec3 c in currentViewRect) { Region validRegionAt = this.GetValidRegionAt(c); if (validRegionAt != null && !this.drawnRegions.Contains(validRegionAt)) { validRegionAt.DebugDraw(); this.drawnRegions.Add(validRegionAt); } } this.drawnRegions.Clear(); } IntVec3 intVec = UI.MouseCell(); if (intVec.InBounds(this.map)) { if (DebugViewSettings.drawRooms) { Room room = intVec.GetRoom(this.map, RegionType.Set_All); if (room != null) { room.DebugDraw(); } } if (DebugViewSettings.drawRoomGroups) { RoomGroup roomGroup = intVec.GetRoomGroup(this.map); if (roomGroup != null) { roomGroup.DebugDraw(); } } if (DebugViewSettings.drawRegions || DebugViewSettings.drawRegionLinks || DebugViewSettings.drawRegionThings) { Region regionAt_NoRebuild_InvalidAllowed = this.GetRegionAt_NoRebuild_InvalidAllowed(intVec); if (regionAt_NoRebuild_InvalidAllowed != null) { regionAt_NoRebuild_InvalidAllowed.DebugDrawMouseover(); } } } }
public void DrawDynamicThings() { if (!DebugViewSettings.drawThingsDynamic) { return; } this.drawingNow = true; try { bool[] fogGrid = this.map.fogGrid.fogGrid; CellRect cellRect = Find.CameraDriver.CurrentViewRect; cellRect.ClipInsideMap(this.map); cellRect = cellRect.ExpandedBy(1); CellIndices cellIndices = this.map.cellIndices; foreach (Thing current in this.drawThings) { IntVec3 position = current.Position; if (cellRect.Contains(position) || current.def.drawOffscreen) { if (!fogGrid[cellIndices.CellToIndex(position)] || current.def.seeThroughFog) { if (current.def.hideAtSnowDepth >= 1f || this.map.snowGrid.GetDepth(current.Position) <= current.def.hideAtSnowDepth) { try { current.Draw(); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception drawing ", current, ": ", ex.ToString() }), false); } } } } } } catch (Exception arg) { Log.Error("Exception drawing dynamic things: " + arg, false); } this.drawingNow = false; }
private static void DestroyTrees21x21() { CellRect cellRect = CellRect.CenteredOn(UI.MouseCell(), 10); cellRect.ClipInsideMap(Find.CurrentMap); foreach (IntVec3 item in cellRect) { List <Thing> thingList = item.GetThingList(Find.CurrentMap); for (int num = thingList.Count - 1; num >= 0; num--) { if (thingList[num].def.category == ThingCategory.Plant && thingList[num].def.plant.IsTree) { thingList[num].Destroy(); } } } }
private void MakeBaseGeometry(LayerSubMesh sm) { glowGrid = base.Map.glowGrid.glowGrid; sectRect = new CellRect(section.botLeft.x, section.botLeft.z, 17, 17); sectRect.ClipInsideMap(base.Map); int capacity = (sectRect.Width + 1) * (sectRect.Height + 1) + sectRect.Area; float y = AltitudeLayer.LightingOverlay.AltitudeFor(); sm.verts.Capacity = capacity; for (int i = sectRect.minZ; i <= sectRect.maxZ + 1; i++) { for (int j = sectRect.minX; j <= sectRect.maxX + 1; j++) { sm.verts.Add(new Vector3(j, y, i)); } } firstCenterInd = sm.verts.Count; for (int k = sectRect.minZ; k <= sectRect.maxZ; k++) { for (int l = sectRect.minX; l <= sectRect.maxX; l++) { sm.verts.Add(new Vector3((float)l + 0.5f, y, (float)k + 0.5f)); } } sm.tris.Capacity = sectRect.Area * 4 * 3; for (int m = sectRect.minZ; m <= sectRect.maxZ; m++) { for (int n = sectRect.minX; n <= sectRect.maxX; n++) { CalculateVertexIndices(n, m, out int botLeft, out int topLeft, out int topRight, out int botRight, out int center); sm.tris.Add(botLeft); sm.tris.Add(center); sm.tris.Add(botRight); sm.tris.Add(botLeft); sm.tris.Add(topLeft); sm.tris.Add(center); sm.tris.Add(topLeft); sm.tris.Add(topRight); sm.tris.Add(center); sm.tris.Add(topRight); sm.tris.Add(botRight); sm.tris.Add(center); } } sm.FinalizeMesh(MeshParts.Verts | MeshParts.Tris); }
public static void ClearArea(CellRect r, Map map) { r.ClipInsideMap(map); foreach (IntVec3 current in r) { map.roofGrid.SetRoof(current, null); } foreach (IntVec3 current2 in r) { foreach (Thing current3 in current2.GetThingList(map).ToList <Thing>()) { if (current3.def.destroyable) { current3.Destroy(DestroyMode.Vanish); } } } }
public static void ClearArea(CellRect r, Map map) { r.ClipInsideMap(map); foreach (IntVec3 item in r) { map.roofGrid.SetRoof(item, null); } foreach (IntVec3 item2 in r) { foreach (Thing item3 in item2.GetThingList(map).ToList()) { if (item3.def.destroyable) { item3.Destroy(DestroyMode.Vanish); } } } }
public static void ClearArea(CellRect r, Map map) { r.ClipInsideMap(map); foreach (IntVec3 c in r) { map.roofGrid.SetRoof(c, null); } foreach (IntVec3 c2 in r) { foreach (Thing thing in c2.GetThingList(map).ToList <Thing>()) { if (thing.def.destroyable) { thing.Destroy(DestroyMode.Vanish); } } } }
public void DebugDraw() { if (map != Find.CurrentMap) { return; } if (DebugViewSettings.drawRegionTraversal) { CellRect currentViewRect = Find.CameraDriver.CurrentViewRect; currentViewRect.ClipInsideMap(map); foreach (IntVec3 item in currentViewRect) { Region validRegionAt = GetValidRegionAt(item); if (validRegionAt != null && !drawnRegions.Contains(validRegionAt)) { validRegionAt.DebugDraw(); drawnRegions.Add(validRegionAt); } } drawnRegions.Clear(); } IntVec3 intVec = UI.MouseCell(); if (intVec.InBounds(map)) { if (DebugViewSettings.drawRooms) { intVec.GetRoom(map, RegionType.Set_All)?.DebugDraw(); } if (DebugViewSettings.drawRoomGroups) { intVec.GetRoomGroup(map)?.DebugDraw(); } if (DebugViewSettings.drawRegions || DebugViewSettings.drawRegionLinks || DebugViewSettings.drawRegionThings) { GetRegionAt_NoRebuild_InvalidAllowed(intVec)?.DebugDrawMouseover(); } } }
public void DrawDynamicThings() { if (!DebugViewSettings.drawThingsDynamic) { return; } drawingNow = true; try { bool[] fogGrid = map.fogGrid.fogGrid; CellRect currentViewRect = Find.CameraDriver.CurrentViewRect; currentViewRect.ClipInsideMap(map); currentViewRect = currentViewRect.ExpandedBy(1); CellIndices cellIndices = map.cellIndices; foreach (Thing drawThing in drawThings) { IntVec3 position = drawThing.Position; if ((currentViewRect.Contains(position) || drawThing.def.drawOffscreen) && (!fogGrid[cellIndices.CellToIndex(position)] || drawThing.def.seeThroughFog) && (!(drawThing.def.hideAtSnowDepth < 1f) || !(map.snowGrid.GetDepth(position) > drawThing.def.hideAtSnowDepth))) { try { drawThing.Draw(); } catch (Exception ex) { Log.Error(string.Concat("Exception drawing ", drawThing, ": ", ex.ToString())); } } } } catch (Exception arg) { Log.Error("Exception drawing dynamic things: " + arg); } drawingNow = false; }
private void TryGenerateAreaNow(Room room) { if (room.Dereferenced || room.TouchesMapEdge) { return; } if (room.RegionCount > 26 || room.CellCount > 320) { return; } if (room.RegionType == RegionType.Portal) { return; } bool flag = false; foreach (IntVec3 c in room.BorderCells) { Thing roofHolderOrImpassable = c.GetRoofHolderOrImpassable(this.map); if (roofHolderOrImpassable != null) { if (roofHolderOrImpassable.Faction != null && roofHolderOrImpassable.Faction != Faction.OfPlayer) { return; } if (roofHolderOrImpassable.def.building != null && !roofHolderOrImpassable.def.building.allowAutoroof) { return; } if (roofHolderOrImpassable.Faction == Faction.OfPlayer) { flag = true; } } } if (!flag) { return; } this.innerCells.Clear(); foreach (IntVec3 intVec in room.Cells) { if (!this.innerCells.Contains(intVec)) { this.innerCells.Add(intVec); } for (int i = 0; i < 8; i++) { IntVec3 c2 = intVec + GenAdj.AdjacentCells[i]; if (c2.InBounds(this.map)) { Thing roofHolderOrImpassable2 = c2.GetRoofHolderOrImpassable(this.map); if (roofHolderOrImpassable2 != null && (roofHolderOrImpassable2.def.size.x > 1 || roofHolderOrImpassable2.def.size.z > 1)) { CellRect cellRect = roofHolderOrImpassable2.OccupiedRect(); cellRect.ClipInsideMap(this.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 (!this.innerCells.Contains(item)) { this.innerCells.Add(item); } } } } } } } this.cellsToRoof.Clear(); foreach (IntVec3 a in this.innerCells) { for (int l = 0; l < 9; l++) { IntVec3 intVec2 = a + GenAdj.AdjacentCellsAndInside[l]; if (intVec2.InBounds(this.map) && (l == 8 || intVec2.GetRoofHolderOrImpassable(this.map) != null) && !this.cellsToRoof.Contains(intVec2)) { this.cellsToRoof.Add(intVec2); } } } this.justRoofedCells.Clear(); foreach (IntVec3 intVec3 in this.cellsToRoof) { if (this.map.roofGrid.RoofAt(intVec3) == null && !this.justRoofedCells.Contains(intVec3)) { if (!this.map.areaManager.NoRoof[intVec3] && RoofCollapseUtility.WithinRangeOfRoofHolder(intVec3, this.map, true)) { this.map.areaManager.BuildRoof[intVec3] = true; this.justRoofedCells.Add(intVec3); } } } }
public override void Regenerate() { if (!MatBases.SunShadow.shader.isSupported) { return; } SectionLayer_SunShadows.edificeGrid = base.Map.edificeGrid.InnerArray; float y = Altitudes.AltitudeFor(AltitudeLayer.Shadows); CellRect cellRect = new CellRect(this.section.botLeft.x, this.section.botLeft.z, 17, 17); cellRect.ClipInsideMap(base.Map); LayerSubMesh subMesh = base.GetSubMesh(MatBases.SunShadow); subMesh.Clear(MeshParts.All); subMesh.verts.Capacity = cellRect.Area * 2; subMesh.tris.Capacity = cellRect.Area * 4; subMesh.colors.Capacity = cellRect.Area * 2; CellIndices cellIndices = base.Map.cellIndices; for (int i = cellRect.minX; i <= cellRect.maxX; i++) { for (int j = cellRect.minZ; j <= cellRect.maxZ; j++) { Thing thing = SectionLayer_SunShadows.edificeGrid[cellIndices.CellToIndex(i, j)]; if (thing != null && thing.def.staticSunShadowHeight > 0f) { float staticSunShadowHeight = thing.def.staticSunShadowHeight; Color32 item = new Color32(0, 0, 0, (byte)(255f * staticSunShadowHeight)); int count = subMesh.verts.Count; subMesh.verts.Add(new Vector3((float)i, y, (float)j)); subMesh.verts.Add(new Vector3((float)i, y, (float)(j + 1))); subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1))); subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)j)); subMesh.colors.Add(SectionLayer_SunShadows.LowVertexColor); subMesh.colors.Add(SectionLayer_SunShadows.LowVertexColor); subMesh.colors.Add(SectionLayer_SunShadows.LowVertexColor); subMesh.colors.Add(SectionLayer_SunShadows.LowVertexColor); int count2 = subMesh.verts.Count; subMesh.tris.Add(count2 - 4); subMesh.tris.Add(count2 - 3); subMesh.tris.Add(count2 - 2); subMesh.tris.Add(count2 - 4); subMesh.tris.Add(count2 - 2); subMesh.tris.Add(count2 - 1); if (i > 0) { thing = SectionLayer_SunShadows.edificeGrid[cellIndices.CellToIndex(i - 1, j)]; if (thing == null || thing.def.staticSunShadowHeight < staticSunShadowHeight) { int count3 = subMesh.verts.Count; subMesh.verts.Add(new Vector3((float)i, y, (float)j)); subMesh.verts.Add(new Vector3((float)i, y, (float)(j + 1))); subMesh.colors.Add(item); subMesh.colors.Add(item); subMesh.tris.Add(count + 1); subMesh.tris.Add(count); subMesh.tris.Add(count3); subMesh.tris.Add(count3); subMesh.tris.Add(count3 + 1); subMesh.tris.Add(count + 1); } } if (i < base.Map.Size.x - 1) { thing = SectionLayer_SunShadows.edificeGrid[cellIndices.CellToIndex(i + 1, j)]; if (thing == null || thing.def.staticSunShadowHeight < staticSunShadowHeight) { int count4 = subMesh.verts.Count; subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1))); subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)j)); subMesh.colors.Add(item); subMesh.colors.Add(item); subMesh.tris.Add(count + 2); subMesh.tris.Add(count4); subMesh.tris.Add(count4 + 1); subMesh.tris.Add(count4 + 1); subMesh.tris.Add(count + 3); subMesh.tris.Add(count + 2); } } if (j > 0) { thing = SectionLayer_SunShadows.edificeGrid[cellIndices.CellToIndex(i, j - 1)]; if (thing == null || thing.def.staticSunShadowHeight < staticSunShadowHeight) { int count5 = subMesh.verts.Count; subMesh.verts.Add(new Vector3((float)i, y, (float)j)); subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)j)); subMesh.colors.Add(item); subMesh.colors.Add(item); subMesh.tris.Add(count); subMesh.tris.Add(count + 3); subMesh.tris.Add(count5); subMesh.tris.Add(count + 3); subMesh.tris.Add(count5 + 1); subMesh.tris.Add(count5); } } } } } if (subMesh.verts.Count > 0) { subMesh.FinalizeMesh(MeshParts.Verts | MeshParts.Tris | MeshParts.Colors); float num = Mathf.Max(15f, 15f); Vector3 size = subMesh.mesh.bounds.size; size.x += 2f * num + 2f; size.z += 2f * num + 2f; subMesh.mesh.bounds = new Bounds(subMesh.mesh.bounds.center, size); } }
public override void Regenerate() { if (!MatBases.SunShadow.shader.isSupported) { return; } LayerSubMesh subMesh = GetSubMesh(MatBases.IndoorMask); subMesh.Clear(MeshParts.All); Building[] innerArray = base.Map.edificeGrid.InnerArray; CellRect cellRect = new CellRect(section.botLeft.x, section.botLeft.z, 17, 17); cellRect.ClipInsideMap(base.Map); subMesh.verts.Capacity = cellRect.Area * 2; subMesh.tris.Capacity = cellRect.Area * 4; float y = AltitudeLayer.MetaOverlays.AltitudeFor(); CellIndices cellIndices = base.Map.cellIndices; for (int i = cellRect.minX; i <= cellRect.maxX; i++) { for (int j = cellRect.minZ; j <= cellRect.maxZ; j++) { IntVec3 intVec = new IntVec3(i, 0, j); if (!HideRainPrimary(intVec)) { bool flag = intVec.Roofed(base.Map); bool flag2 = false; if (flag) { for (int k = 0; k < 8; k++) { IntVec3 c = intVec + GenAdj.AdjacentCells[k]; if (c.InBounds(base.Map) && HideRainPrimary(c)) { flag2 = true; break; } } } if (!flag || !flag2) { continue; } } Thing thing = innerArray[cellIndices.CellToIndex(i, j)]; float num = (thing == null || (thing.def.passability != Traversability.Impassable && !thing.def.IsDoor)) ? 0.16f : 0f; subMesh.verts.Add(new Vector3((float)i - num, y, (float)j - num)); subMesh.verts.Add(new Vector3((float)i - num, y, (float)(j + 1) + num)); subMesh.verts.Add(new Vector3((float)(i + 1) + num, y, (float)(j + 1) + num)); subMesh.verts.Add(new Vector3((float)(i + 1) + num, y, (float)j - num)); int count = subMesh.verts.Count; subMesh.tris.Add(count - 4); subMesh.tris.Add(count - 3); subMesh.tris.Add(count - 2); subMesh.tris.Add(count - 4); subMesh.tris.Add(count - 2); subMesh.tris.Add(count - 1); } } if (subMesh.verts.Count > 0) { subMesh.FinalizeMesh(MeshParts.Verts | MeshParts.Tris); } }
public override void Regenerate() { Building[] innerArray = base.Map.edificeGrid.InnerArray; float y = Altitudes.AltitudeFor(AltitudeLayer.Shadows); CellRect cellRect = new CellRect(base.section.botLeft.x, base.section.botLeft.z, 17, 17); cellRect.ClipInsideMap(base.Map); LayerSubMesh sm = base.GetSubMesh(MatBases.EdgeShadow); sm.Clear(MeshParts.All); sm.verts.Capacity = cellRect.Area * 4; sm.colors.Capacity = cellRect.Area * 4; sm.tris.Capacity = cellRect.Area * 8; bool[] array = new bool[4]; bool[] array2 = new bool[4]; bool[] array3 = new bool[4]; float num = 0f; float num2 = 0f; CellIndices cellIndices = base.Map.cellIndices; for (int i = cellRect.minX; i <= cellRect.maxX; i++) { for (int j = cellRect.minZ; j <= cellRect.maxZ; j++) { Thing thing = innerArray[cellIndices.CellToIndex(i, j)]; if (thing != null && thing.def.castEdgeShadows) { sm.verts.Add(new Vector3((float)i, y, (float)j)); sm.verts.Add(new Vector3((float)i, y, (float)(j + 1))); sm.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1))); sm.verts.Add(new Vector3((float)(i + 1), y, (float)j)); sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); int count = sm.verts.Count; sm.tris.Add(count - 4); sm.tris.Add(count - 3); sm.tris.Add(count - 2); sm.tris.Add(count - 4); sm.tris.Add(count - 2); sm.tris.Add(count - 1); } else { array[0] = false; array[1] = false; array[2] = false; array[3] = false; array2[0] = false; array2[1] = false; array2[2] = false; array2[3] = false; array3[0] = false; array3[1] = false; array3[2] = false; array3[3] = false; IntVec3 a = new IntVec3(i, 0, j); IntVec3[] cardinalDirectionsAround = GenAdj.CardinalDirectionsAround; for (int k = 0; k < 4; k++) { IntVec3 c = a + cardinalDirectionsAround[k]; if (c.InBounds(base.Map)) { thing = innerArray[cellIndices.CellToIndex(c)]; if (thing != null && thing.def.castEdgeShadows) { array2[k] = true; array[(k + 3) % 4] = true; array[k] = true; } } } IntVec3[] diagonalDirectionsAround = GenAdj.DiagonalDirectionsAround; for (int l = 0; l < 4; l++) { if (!array[l]) { IntVec3 c = a + diagonalDirectionsAround[l]; if (c.InBounds(base.Map)) { thing = innerArray[cellIndices.CellToIndex(c)]; if (thing != null && thing.def.castEdgeShadows) { array[l] = true; array3[l] = true; } } } } Action <int> action = delegate(int idx) { sm.tris.Add(sm.verts.Count - 2); sm.tris.Add(idx); sm.tris.Add(sm.verts.Count - 1); sm.tris.Add(sm.verts.Count - 1); sm.tris.Add(idx); sm.tris.Add(idx + 1); }; Action action2 = delegate { sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); sm.colors.Add(SectionLayer_EdgeShadows.Lit); sm.colors.Add(SectionLayer_EdgeShadows.Lit); sm.tris.Add(sm.verts.Count - 3); sm.tris.Add(sm.verts.Count - 2); sm.tris.Add(sm.verts.Count - 1); }; int count2 = sm.verts.Count; if (array[0]) { if (array2[0] || array2[1]) { num = (num2 = 0f); if (array2[0]) { num2 = 0.45f; } if (array2[1]) { num = 0.45f; } sm.verts.Add(new Vector3((float)i, y, (float)j)); sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); sm.verts.Add(new Vector3((float)i + num, y, (float)j + num2)); sm.colors.Add(SectionLayer_EdgeShadows.Lit); if (array[1] && !array3[1]) { action(sm.verts.Count); } } else { sm.verts.Add(new Vector3((float)i, y, (float)j)); sm.verts.Add(new Vector3((float)i, y, (float)((float)j + 0.44999998807907104))); sm.verts.Add(new Vector3((float)((float)i + 0.44999998807907104), y, (float)j)); action2(); } } if (array[1]) { if (array2[1] || array2[2]) { num = (num2 = 0f); if (array2[1]) { num = 0.45f; } if (array2[2]) { num2 = -0.45f; } sm.verts.Add(new Vector3((float)i, y, (float)(j + 1))); sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); sm.verts.Add(new Vector3((float)i + num, y, (float)(j + 1) + num2)); sm.colors.Add(SectionLayer_EdgeShadows.Lit); if (array[2] && !array3[2]) { action(sm.verts.Count); } } else { sm.verts.Add(new Vector3((float)i, y, (float)(j + 1))); sm.verts.Add(new Vector3((float)((float)i + 0.44999998807907104), y, (float)(j + 1))); sm.verts.Add(new Vector3((float)i, y, (float)((float)(j + 1) - 0.44999998807907104))); action2(); } } if (array[2]) { if (array2[2] || array2[3]) { num = (num2 = 0f); if (array2[2]) { num2 = -0.45f; } if (array2[3]) { num = -0.45f; } sm.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1))); sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); sm.verts.Add(new Vector3((float)(i + 1) + num, y, (float)(j + 1) + num2)); sm.colors.Add(SectionLayer_EdgeShadows.Lit); if (array[3] && !array3[3]) { action(sm.verts.Count); } } else { sm.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1))); sm.verts.Add(new Vector3((float)(i + 1), y, (float)((float)(j + 1) - 0.44999998807907104))); sm.verts.Add(new Vector3((float)((float)(i + 1) - 0.44999998807907104), y, (float)(j + 1))); action2(); } } if (array[3]) { if (array2[3] || array2[0]) { num = (num2 = 0f); if (array2[3]) { num = -0.45f; } if (array2[0]) { num2 = 0.45f; } sm.verts.Add(new Vector3((float)(i + 1), y, (float)j)); sm.colors.Add(SectionLayer_EdgeShadows.Shadowed); sm.verts.Add(new Vector3((float)(i + 1) + num, y, (float)j + num2)); sm.colors.Add(SectionLayer_EdgeShadows.Lit); if (array[0] && !array3[0]) { action(count2); } } else { sm.verts.Add(new Vector3((float)(i + 1), y, (float)j)); sm.verts.Add(new Vector3((float)((float)(i + 1) - 0.44999998807907104), y, (float)j)); sm.verts.Add(new Vector3((float)(i + 1), y, (float)((float)j + 0.44999998807907104))); action2(); } } } } } if (sm.verts.Count > 0) { sm.FinalizeMesh(MeshParts.Verts | MeshParts.Tris | MeshParts.Colors); } }
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); } } } } }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); rect.ClipInsideMap(base.Map); }