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; }
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; }
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; }