private void PlaceDecorations(Point tileOrigin, Microsoft.Xna.Framework.Rectangle magmaMapArea) { FastRandom fastRandom1 = new FastRandom(Main.ActiveWorldFileData.Seed).WithModifier(65440UL); for (int left = magmaMapArea.Left; left < magmaMapArea.Right; ++left) { for (int top = magmaMapArea.Top; top < magmaMapArea.Bottom; ++top) { GraniteBiome.Magma sourceMagma = this._sourceMagmaMap[left, top]; int index1 = left + tileOrigin.X; int index2 = top + tileOrigin.Y; if (sourceMagma.IsActive) { WorldUtils.TileFrame(index1, index2, false); WorldGen.SquareWallFrame(index1, index2, true); FastRandom fastRandom2 = fastRandom1.WithModifier(index1, index2); if (fastRandom2.Next(8) == 0 && GenBase._tiles[index1, index2].active()) { if (!GenBase._tiles[index1, index2 + 1].active()) { WorldGen.PlaceUncheckedStalactite(index1, index2 + 1, fastRandom2.Next(2) == 0, fastRandom2.Next(3), false); } if (!GenBase._tiles[index1, index2 - 1].active()) { WorldGen.PlaceUncheckedStalactite(index1, index2 - 1, fastRandom2.Next(2) == 0, fastRandom2.Next(3), false); } } if (fastRandom2.Next(2) == 0) { Tile.SmoothSlope(index1, index2, true, false); } } } } }
private void PlaceGranite(Point tileOrigin, Microsoft.Xna.Framework.Rectangle magmaMapArea) { bool flag = this.ShouldUseLava(tileOrigin); ushort type = 368; ushort num = 180; if (WorldGen.drunkWorldGen) { type = (ushort)367; num = (ushort)178; } for (int left = magmaMapArea.Left; left < magmaMapArea.Right; ++left) { for (int top = magmaMapArea.Top; top < magmaMapArea.Bottom; ++top) { GraniteBiome.Magma sourceMagma = this._sourceMagmaMap[left, top]; if (sourceMagma.IsActive) { Tile tile = GenBase._tiles[tileOrigin.X + left, tileOrigin.Y + top]; if ((double)Math.Max(1f - Math.Max(0.0f, (float)(Math.Sin((double)(tileOrigin.Y + top) * 0.400000005960464) * 0.699999988079071 + 1.20000004768372) * (float)(0.200000002980232 + 0.5 / Math.Sqrt((double)Math.Max(0.0f, sourceMagma.Pressure - sourceMagma.Resistance)))), sourceMagma.Pressure / 15f) > 0.349999994039536 + (WorldGen.SolidTile(tileOrigin.X + left, tileOrigin.Y + top, false) ? 0.0 : 0.5)) { if (TileID.Sets.Ore[(int)tile.type]) { tile.ResetToType(tile.type); } else { tile.ResetToType(type); } tile.wall = num; } else if ((double)sourceMagma.Resistance < 0.00999999977648258) { WorldUtils.ClearTile(tileOrigin.X + left, tileOrigin.Y + top, false); tile.wall = num; } if (tile.liquid > (byte)0 & flag) { tile.liquidType(1); } } } } }
public override bool Place(Point origin, StructureMap structures) { if (GenBase._tiles[(int)origin.X, (int)origin.Y].active()) { return(false); } int length1 = GraniteBiome._sourceMagmaMap.GetLength(0); int length2 = GraniteBiome._sourceMagmaMap.GetLength(1); int index1 = length1 / 2; int index2 = length2 / 2; // ISSUE: explicit reference operation // ISSUE: variable of a reference type Point& local1 = @origin; // ISSUE: explicit reference operation int num1 = (^ local1).X - index1; // ISSUE: explicit reference operation (^ local1).X = (__Null)num1; // ISSUE: explicit reference operation // ISSUE: variable of a reference type Point& local2 = @origin; // ISSUE: explicit reference operation int num2 = (^ local2).Y - index2; // ISSUE: explicit reference operation (^ local2).Y = (__Null)num2; for (int index3 = 0; index3 < length1; ++index3) { for (int index4 = 0; index4 < length2; ++index4) { int i = index3 + origin.X; int j = index4 + origin.Y; GraniteBiome._sourceMagmaMap[index3, index4] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i, j) ? 4f : 1f); GraniteBiome._targetMagmaMap[index3, index4] = GraniteBiome._sourceMagmaMap[index3, index4]; } } int max1 = index1; int min1 = index1; int max2 = index2; int min2 = index2; for (int index3 = 0; index3 < 300; ++index3) { for (int index4 = max1; index4 <= min1; ++index4) { for (int index5 = max2; index5 <= min2; ++index5) { GraniteBiome.Magma sourceMagma1 = GraniteBiome._sourceMagmaMap[index4, index5]; if (sourceMagma1.IsActive) { float num3 = 0.0f; Vector2 vector2_1 = Vector2.get_Zero(); for (int index6 = -1; index6 <= 1; ++index6) { for (int index7 = -1; index7 <= 1; ++index7) { if (index6 != 0 || index7 != 0) { Vector2 vector2_2; // ISSUE: explicit reference operation ((Vector2)@vector2_2).\u002Ector((float)index6, (float)index7); // ISSUE: explicit reference operation ((Vector2)@vector2_2).Normalize(); GraniteBiome.Magma sourceMagma2 = GraniteBiome._sourceMagmaMap[index4 + index6, index5 + index7]; if ((double)sourceMagma1.Pressure > 0.00999999977648258 && !sourceMagma2.IsActive) { if (index6 == -1) { max1 = Utils.Clamp <int>(index4 + index6, 1, max1); } else { min1 = Utils.Clamp <int>(index4 + index6, min1, length1 - 2); } if (index7 == -1) { max2 = Utils.Clamp <int>(index5 + index7, 1, max2); } else { min2 = Utils.Clamp <int>(index5 + index7, min2, length2 - 2); } GraniteBiome._targetMagmaMap[index4 + index6, index5 + index7] = sourceMagma2.ToFlow(); } float pressure = sourceMagma2.Pressure; num3 += pressure; vector2_1 = Vector2.op_Addition(vector2_1, Vector2.op_Multiply(pressure, vector2_2)); } } } float num4 = num3 / 8f; if ((double)num4 > (double)sourceMagma1.Resistance) { // ISSUE: explicit reference operation float num5 = ((Vector2)@vector2_1).Length() / 8f; float pressure = Math.Max(0.0f, (float)((double)Math.Max(num4 - num5 - sourceMagma1.Pressure, 0.0f) + (double)num5 + (double)sourceMagma1.Pressure * 0.875) - sourceMagma1.Resistance); GraniteBiome._targetMagmaMap[index4, index5] = GraniteBiome.Magma.CreateFlow(pressure, Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f)); } } } } if (index3 < 2) { GraniteBiome._targetMagmaMap[index1, index2] = GraniteBiome.Magma.CreateFlow(25f, 0.0f); } Utils.Swap <GraniteBiome.Magma[, ]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap); } bool flag1 = origin.Y + index2 > WorldGen.lavaLine - 30; bool flag2 = false; for (int index3 = -50; index3 < 50 && !flag2; ++index3) { for (int index4 = -50; index4 < 50 && !flag2; ++index4) { if (GenBase._tiles[origin.X + index1 + index3, origin.Y + index2 + index4].active()) { switch (GenBase._tiles[origin.X + index1 + index3, origin.Y + index2 + index4].type) { case 147: case 161: case 162: case 163: case 200: flag1 = false; flag2 = true; continue; default: continue; } } } } for (int index3 = max1; index3 <= min1; ++index3) { for (int index4 = max2; index4 <= min2; ++index4) { GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index3, index4]; if (sourceMagma.IsActive) { Tile tile = GenBase._tiles[origin.X + index3, origin.Y + index4]; if ((double)Math.Max(1f - Math.Max(0.0f, (float)(Math.Sin((double)(origin.Y + index4) * 0.400000005960464) * 0.699999988079071 + 1.20000004768372) * (float)(0.200000002980232 + 0.5 / Math.Sqrt((double)Math.Max(0.0f, sourceMagma.Pressure - sourceMagma.Resistance)))), sourceMagma.Pressure / 15f) > 0.349999994039536 + (WorldGen.SolidTile(origin.X + index3, origin.Y + index4) ? 0.0 : 0.5)) { if (TileID.Sets.Ore[(int)tile.type]) { tile.ResetToType(tile.type); } else { tile.ResetToType((ushort)368); } tile.wall = (byte)180; } else if ((double)sourceMagma.Resistance < 0.00999999977648258) { WorldUtils.ClearTile(origin.X + index3, origin.Y + index4, false); tile.wall = (byte)180; } if ((int)tile.liquid > 0 && flag1) { tile.liquidType(1); } } } } List <Point16> point16List = new List <Point16>(); for (int index3 = max1; index3 <= min1; ++index3) { for (int index4 = max2; index4 <= min2; ++index4) { if (GraniteBiome._sourceMagmaMap[index3, index4].IsActive) { int num3 = 0; int num4 = index3 + origin.X; int num5 = index4 + origin.Y; if (WorldGen.SolidTile(num4, num5)) { for (int index5 = -1; index5 <= 1; ++index5) { for (int index6 = -1; index6 <= 1; ++index6) { if (WorldGen.SolidTile(num4 + index5, num5 + index6)) { ++num3; } } } if (num3 < 3) { point16List.Add(new Point16(num4, num5)); } } } } } foreach (Point16 point16 in point16List) { int x = (int)point16.X; int y = (int)point16.Y; WorldUtils.ClearTile(x, y, true); GenBase._tiles[x, y].wall = (byte)180; } point16List.Clear(); for (int index3 = max1; index3 <= min1; ++index3) { for (int index4 = max2; index4 <= min2; ++index4) { GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index3, index4]; int index5 = index3 + origin.X; int index6 = index4 + origin.Y; if (sourceMagma.IsActive) { WorldUtils.TileFrame(index5, index6, false); WorldGen.SquareWallFrame(index5, index6, true); if (GenBase._random.Next(8) == 0 && GenBase._tiles[index5, index6].active()) { if (!GenBase._tiles[index5, index6 + 1].active()) { WorldGen.PlaceTight(index5, index6 + 1, (ushort)165, false); } if (!GenBase._tiles[index5, index6 - 1].active()) { WorldGen.PlaceTight(index5, index6 - 1, (ushort)165, false); } } if (GenBase._random.Next(2) == 0) { Tile.SmoothSlope(index5, index6, true); } } } } return(true); }
public override bool Place(Point origin, StructureMap structures) { if (GenBase._tiles[origin.X, origin.Y].active()) { return(false); } int length = GraniteBiome._sourceMagmaMap.GetLength(0); int length2 = GraniteBiome._sourceMagmaMap.GetLength(1); int num = length / 2; int num2 = length2 / 2; origin.X -= num; origin.Y -= num2; for (int i = 0; i < length; i++) { for (int j = 0; j < length2; j++) { int i2 = i + origin.X; int j2 = j + origin.Y; GraniteBiome._sourceMagmaMap[i, j] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i2, j2) ? 4f : 1f); GraniteBiome._targetMagmaMap[i, j] = GraniteBiome._sourceMagmaMap[i, j]; } } int num3 = num; int num4 = num; int num5 = num2; int num6 = num2; for (int k = 0; k < 300; k++) { for (int l = num3; l <= num4; l++) { for (int m = num5; m <= num6; m++) { GraniteBiome.Magma magma = GraniteBiome._sourceMagmaMap[l, m]; if (magma.IsActive) { float num7 = 0f; Vector2 value = Vector2.Zero; for (int n = -1; n <= 1; n++) { for (int num8 = -1; num8 <= 1; num8++) { if (n != 0 || num8 != 0) { Vector2 value2 = new Vector2((float)n, (float)num8); value2.Normalize(); GraniteBiome.Magma magma2 = GraniteBiome._sourceMagmaMap[l + n, m + num8]; if (magma.Pressure > 0.01f && !magma2.IsActive) { if (n == -1) { num3 = Utils.Clamp <int>(l + n, 1, num3); } else { num4 = Utils.Clamp <int>(l + n, num4, length - 2); } if (num8 == -1) { num5 = Utils.Clamp <int>(m + num8, 1, num5); } else { num6 = Utils.Clamp <int>(m + num8, num6, length2 - 2); } GraniteBiome._targetMagmaMap[l + n, m + num8] = magma2.ToFlow(); } float pressure = magma2.Pressure; num7 += pressure; value += pressure * value2; } } } num7 /= 8f; if (num7 > magma.Resistance) { float num9 = value.Length() / 8f; float num10 = Math.Max(num7 - num9 - magma.Pressure, 0f) + num9 + magma.Pressure * 0.875f - magma.Resistance; num10 = Math.Max(0f, num10); GraniteBiome._targetMagmaMap[l, m] = GraniteBiome.Magma.CreateFlow(num10, Math.Max(0f, magma.Resistance - num10 * 0.02f)); } } } } if (k < 2) { GraniteBiome._targetMagmaMap[num, num2] = GraniteBiome.Magma.CreateFlow(25f, 0f); } Utils.Swap <GraniteBiome.Magma[, ]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap); } bool flag = origin.Y + num2 > WorldGen.lavaLine - 30; bool flag2 = false; int num11 = -50; while (num11 < 50 && !flag2) { int num12 = -50; while (num12 < 50 && !flag2) { if (GenBase._tiles[origin.X + num + num11, origin.Y + num2 + num12].active()) { ushort type = GenBase._tiles[origin.X + num + num11, origin.Y + num2 + num12].type; if (type != 147) { switch (type) { case 161: case 162: case 163: break; default: if (type != 200) { goto IL_400; } break; } } flag = false; flag2 = true; } IL_400: num12++; } num11++; } for (int num13 = num3; num13 <= num4; num13++) { for (int num14 = num5; num14 <= num6; num14++) { GraniteBiome.Magma magma3 = GraniteBiome._sourceMagmaMap[num13, num14]; if (magma3.IsActive) { Tile tile = GenBase._tiles[origin.X + num13, origin.Y + num14]; float num15 = (float)Math.Sin((double)((float)(origin.Y + num14) * 0.4f)) * 0.7f + 1.2f; float num16 = 0.2f + 0.5f / (float)Math.Sqrt((double)Math.Max(0f, magma3.Pressure - magma3.Resistance)); float num17 = 1f - Math.Max(0f, num15 * num16); num17 = Math.Max(num17, magma3.Pressure / 15f); if (num17 > 0.35f + (WorldGen.SolidTile(origin.X + num13, origin.Y + num14) ? 0f : 0.5f)) { if (TileID.Sets.Ore[(int)tile.type]) { tile.ResetToType(tile.type); } else { tile.ResetToType(368); } tile.wall = 180; } else if (magma3.Resistance < 0.01f) { WorldUtils.ClearTile(origin.X + num13, origin.Y + num14, false); tile.wall = 180; } if (tile.liquid > 0 && flag) { tile.liquidType(1); } } } } List <Point16> list = new List <Point16>(); for (int num18 = num3; num18 <= num4; num18++) { for (int num19 = num5; num19 <= num6; num19++) { GraniteBiome.Magma magma4 = GraniteBiome._sourceMagmaMap[num18, num19]; if (magma4.IsActive) { int num20 = 0; int num21 = num18 + origin.X; int num22 = num19 + origin.Y; if (WorldGen.SolidTile(num21, num22)) { for (int num23 = -1; num23 <= 1; num23++) { for (int num24 = -1; num24 <= 1; num24++) { if (WorldGen.SolidTile(num21 + num23, num22 + num24)) { num20++; } } } if (num20 < 3) { list.Add(new Point16(num21, num22)); } } } } } foreach (Point16 current in list) { int x = (int)current.X; int y = (int)current.Y; WorldUtils.ClearTile(x, y, true); GenBase._tiles[x, y].wall = 180; } list.Clear(); for (int num25 = num3; num25 <= num4; num25++) { for (int num26 = num5; num26 <= num6; num26++) { GraniteBiome.Magma magma5 = GraniteBiome._sourceMagmaMap[num25, num26]; int num27 = num25 + origin.X; int num28 = num26 + origin.Y; if (magma5.IsActive) { WorldUtils.TileFrame(num27, num28, false); WorldGen.SquareWallFrame(num27, num28, true); if (GenBase._random.Next(8) == 0 && GenBase._tiles[num27, num28].active()) { if (!GenBase._tiles[num27, num28 + 1].active()) { WorldGen.PlaceTight(num27, num28 + 1, 165, false); } if (!GenBase._tiles[num27, num28 - 1].active()) { WorldGen.PlaceTight(num27, num28 - 1, 165, false); } } if (GenBase._random.Next(2) == 0) { Tile.SmoothSlope(num27, num28, true); } } } } return(true); }
private void SimulatePressure(out Microsoft.Xna.Framework.Rectangle effectedMapArea) { int length1 = this._sourceMagmaMap.GetLength(0); int length2 = this._sourceMagmaMap.GetLength(1); int index1 = length1 / 2; int index2 = length2 / 2; int num1 = index1; int min1 = num1; int num2 = index2; int min2 = num2; for (int index3 = 0; index3 < 300; ++index3) { for (int index4 = num1; index4 <= min1; ++index4) { for (int index5 = num2; index5 <= min2; ++index5) { GraniteBiome.Magma sourceMagma1 = this._sourceMagmaMap[index4, index5]; if (sourceMagma1.IsActive) { float num3 = 0.0f; Vector2 zero = Vector2.Zero; for (int index6 = -1; index6 <= 1; ++index6) { for (int index7 = -1; index7 <= 1; ++index7) { if (index6 != 0 || index7 != 0) { Vector2 normalisedVector = GraniteBiome._normalisedVectors[(index6 + 1) * 3 + (index7 + 1)]; GraniteBiome.Magma sourceMagma2 = this._sourceMagmaMap[index4 + index6, index5 + index7]; if ((double)sourceMagma1.Pressure > 0.00999999977648258 && !sourceMagma2.IsActive) { if (index6 == -1) { num1 = Utils.Clamp <int>(index4 + index6, 1, num1); } else { min1 = Utils.Clamp <int>(index4 + index6, min1, length1 - 2); } if (index7 == -1) { num2 = Utils.Clamp <int>(index5 + index7, 1, num2); } else { min2 = Utils.Clamp <int>(index5 + index7, min2, length2 - 2); } this._targetMagmaMap[index4 + index6, index5 + index7] = sourceMagma2.ToFlow(); } float pressure = sourceMagma2.Pressure; num3 += pressure; zero += pressure * normalisedVector; } } } float num4 = num3 / 8f; if ((double)num4 > (double)sourceMagma1.Resistance) { float num5 = zero.Length() / 8f; float pressure = Math.Max(0.0f, (float)((double)Math.Max(num4 - num5 - sourceMagma1.Pressure, 0.0f) + (double)num5 + (double)sourceMagma1.Pressure * 0.875) - sourceMagma1.Resistance); this._targetMagmaMap[index4, index5] = GraniteBiome.Magma.CreateFlow(pressure, Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f)); } } } } if (index3 < 2) { this._targetMagmaMap[index1, index2] = GraniteBiome.Magma.CreateFlow(25f, 0.0f); } Utils.Swap <GraniteBiome.Magma[, ]>(ref this._sourceMagmaMap, ref this._targetMagmaMap); } effectedMapArea = new Microsoft.Xna.Framework.Rectangle(num1, num2, min1 - num1 + 1, min2 - num2 + 1); }
public override bool Place(Point origin, StructureMap structures) { if (GenBase._tiles[origin.X, origin.Y].active()) { return(false); } int length1 = GraniteBiome._sourceMagmaMap.GetLength(0); int length2 = GraniteBiome._sourceMagmaMap.GetLength(1); int index1 = length1 / 2; int index2 = length2 / 2; origin.X -= index1; origin.Y -= index2; for (int index3 = 0; index3 < length1; ++index3) { for (int index4 = 0; index4 < length2; ++index4) { int i = index3 + origin.X; int j = index4 + origin.Y; GraniteBiome._sourceMagmaMap[index3, index4] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i, j) ? 4f : 1f); GraniteBiome._targetMagmaMap[index3, index4] = GraniteBiome._sourceMagmaMap[index3, index4]; } } int max1 = index1; int min1 = index1; int max2 = index2; int min2 = index2; for (int index3 = 0; index3 < 300; ++index3) { for (int index4 = max1; index4 <= min1; ++index4) { for (int index5 = max2; index5 <= min2; ++index5) { GraniteBiome.Magma sourceMagma1 = GraniteBiome._sourceMagmaMap[index4, index5]; if (sourceMagma1.IsActive) { float num1 = 0.0f; Vector2 zero = Vector2.Zero; for (int index6 = -1; index6 <= 1; ++index6) { for (int index7 = -1; index7 <= 1; ++index7) { if (index6 != 0 || index7 != 0) { Vector2 vector2 = new Vector2((float)index6, (float)index7); vector2.Normalize(); GraniteBiome.Magma sourceMagma2 = GraniteBiome._sourceMagmaMap[index4 + index6, index5 + index7]; if ((double)sourceMagma1.Pressure > 0.00999999977648258 && !sourceMagma2.IsActive) { if (index6 == -1) { max1 = Utils.Clamp <int>(index4 + index6, 1, max1); } else { min1 = Utils.Clamp <int>(index4 + index6, min1, length1 - 2); } if (index7 == -1) { max2 = Utils.Clamp <int>(index5 + index7, 1, max2); } else { min2 = Utils.Clamp <int>(index5 + index7, min2, length2 - 2); } GraniteBiome._targetMagmaMap[index4 + index6, index5 + index7] = sourceMagma2.ToFlow(); } float pressure = sourceMagma2.Pressure; num1 += pressure; zero += pressure * vector2; } } } float num2 = num1 / 8f; if ((double)num2 > (double)sourceMagma1.Resistance) { float num3 = zero.Length() / 8f; float pressure = Math.Max(0.0f, (float)((double)Math.Max(num2 - num3 - sourceMagma1.Pressure, 0.0f) + (double)num3 + (double)sourceMagma1.Pressure * 0.875) - sourceMagma1.Resistance); GraniteBiome._targetMagmaMap[index4, index5] = GraniteBiome.Magma.CreateFlow(pressure, Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f)); } } } } if (index3 < 2) { GraniteBiome._targetMagmaMap[index1, index2] = GraniteBiome.Magma.CreateFlow(25f, 0.0f); } Utils.Swap <GraniteBiome.Magma[, ]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap); } bool flag1 = origin.Y + index2 > WorldGen.lavaLine - 30; bool flag2 = false; for (int index3 = -50; index3 < 50 && !flag2; ++index3) { for (int index4 = -50; index4 < 50 && !flag2; ++index4) { if (GenBase._tiles[origin.X + index1 + index3, origin.Y + index2 + index4].active()) { ushort type = GenBase._tiles[origin.X + index1 + index3, origin.Y + index2 + index4].type; if ((int)type == 147 || (uint)type - 161U <= 2U || (int)type == 200) { flag1 = false; flag2 = true; } } } } for (int index3 = max1; index3 <= min1; ++index3) { for (int index4 = max2; index4 <= min2; ++index4) { GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index3, index4]; if (sourceMagma.IsActive) { Tile tile = GenBase._tiles[origin.X + index3, origin.Y + index4]; if ((double)Math.Max(1f - Math.Max(0.0f, (float)(Math.Sin((double)(origin.Y + index4) * 0.400000005960464) * 0.699999988079071 + 1.20000004768372) * (float)(0.200000002980232 + 0.5 / Math.Sqrt((double)Math.Max(0.0f, sourceMagma.Pressure - sourceMagma.Resistance)))), sourceMagma.Pressure / 15f) > 0.349999994039536 + (WorldGen.SolidTile(origin.X + index3, origin.Y + index4) ? 0.0 : 0.5)) { if (TileID.Sets.Ore[(int)tile.type]) { tile.ResetToType(tile.type); } else { tile.ResetToType((ushort)368); } tile.wall = (byte)180; } else if ((double)sourceMagma.Resistance < 0.00999999977648258) { WorldUtils.ClearTile(origin.X + index3, origin.Y + index4, false); tile.wall = (byte)180; } if ((int)tile.liquid > 0 & flag1) { tile.liquidType(1); } } } } List <Point16> point16List = new List <Point16>(); for (int index3 = max1; index3 <= min1; ++index3) { for (int index4 = max2; index4 <= min2; ++index4) { if (GraniteBiome._sourceMagmaMap[index3, index4].IsActive) { int num1 = 0; int num2 = index3 + origin.X; int num3 = index4 + origin.Y; if (WorldGen.SolidTile(num2, num3)) { for (int index5 = -1; index5 <= 1; ++index5) { for (int index6 = -1; index6 <= 1; ++index6) { if (WorldGen.SolidTile(num2 + index5, num3 + index6)) { ++num1; } } } if (num1 < 3) { point16List.Add(new Point16(num2, num3)); } } } } } foreach (Point16 point16 in point16List) { int x = (int)point16.X; int y = (int)point16.Y; WorldUtils.ClearTile(x, y, true); GenBase._tiles[x, y].wall = (byte)180; } point16List.Clear(); for (int index3 = max1; index3 <= min1; ++index3) { for (int index4 = max2; index4 <= min2; ++index4) { GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index3, index4]; int index5 = index3 + origin.X; int index6 = index4 + origin.Y; if (sourceMagma.IsActive) { WorldUtils.TileFrame(index5, index6, false); WorldGen.SquareWallFrame(index5, index6, true); if (GenBase._random.Next(8) == 0 && GenBase._tiles[index5, index6].active()) { if (!GenBase._tiles[index5, index6 + 1].active()) { WorldGen.PlaceTight(index5, index6 + 1, (ushort)165, false); } if (!GenBase._tiles[index5, index6 - 1].active()) { WorldGen.PlaceTight(index5, index6 - 1, (ushort)165, false); } } if (GenBase._random.Next(2) == 0) { Tile.SmoothSlope(index5, index6, true); } } } } return(true); }
public override bool Place(Point origin, StructureMap structures) { if (GenBase._tiles[origin.X, origin.Y].active()) { return(false); } int length = GraniteBiome._sourceMagmaMap.GetLength(0); int num = GraniteBiome._sourceMagmaMap.GetLength(1); int num1 = length / 2; int num2 = num / 2; origin.X = origin.X - num1; origin.Y = origin.Y - num2; for (int i = 0; i < length; i++) { for (int j = 0; j < num; j++) { GraniteBiome._sourceMagmaMap[i, j] = GraniteBiome.Magma.CreateEmpty((WorldGen.SolidTile(i + origin.X, j + origin.Y) ? 4f : 1f)); GraniteBiome._targetMagmaMap[i, j] = GraniteBiome._sourceMagmaMap[i, j]; } } int num3 = num1; int num4 = num1; int num5 = num2; int num6 = num2; for (int k = 0; k < 300; k++) { for (int l = num3; l <= num4; l++) { for (int m = num5; m <= num6; m++) { GraniteBiome.Magma magma = GraniteBiome._sourceMagmaMap[l, m]; if (magma.IsActive) { float single = 0f; Vector2 zero = Vector2.Zero; for (int n = -1; n <= 1; n++) { for (int o = -1; o <= 1; o++) { if (n != 0 || o != 0) { Vector2 vector2 = new Vector2((float)n, (float)o); vector2.Normalize(); GraniteBiome.Magma magma1 = GraniteBiome._sourceMagmaMap[l + n, m + o]; if (magma.Pressure > 0.01f && !magma1.IsActive) { if (n != -1) { num4 = Utils.Clamp <int>(l + n, num4, length - 2); } else { num3 = Utils.Clamp <int>(l + n, 1, num3); } if (o != -1) { num6 = Utils.Clamp <int>(m + o, num6, num - 2); } else { num5 = Utils.Clamp <int>(m + o, 1, num5); } GraniteBiome._targetMagmaMap[l + n, m + o] = magma1.ToFlow(); } float pressure = magma1.Pressure; single = single + pressure; zero = zero + (pressure * vector2); } } } single = single / 8f; if (single > magma.Resistance) { float single1 = zero.Length() / 8f; float single2 = Math.Max(single - single1 - magma.Pressure, 0f) + single1 + magma.Pressure * 0.875f - magma.Resistance; single2 = Math.Max(0f, single2); GraniteBiome._targetMagmaMap[l, m] = GraniteBiome.Magma.CreateFlow(single2, Math.Max(0f, magma.Resistance - single2 * 0.02f)); } } } } if (k < 2) { GraniteBiome._targetMagmaMap[num1, num2] = GraniteBiome.Magma.CreateFlow(25f, 0f); } Utils.Swap <GraniteBiome.Magma[, ]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap); } bool y = origin.Y + num2 > WorldGen.lavaLine - 30; bool flag = false; for (int p = -50; p < 50 && !flag; p++) { for (int q = -50; q < 50 && !flag; q++) { if (GenBase._tiles[origin.X + num1 + p, origin.Y + num2 + q].active()) { ushort num7 = GenBase._tiles[origin.X + num1 + p, origin.Y + num2 + q].type; if (num7 != 147) { switch (num7) { case 161: case 162: case 163: { break; } default: { if (num7 != 200) { continue; } else { break; } } } } y = false; flag = true; } } } for (int r = num3; r <= num4; r++) { for (int s = num5; s <= num6; s++) { GraniteBiome.Magma magma2 = GraniteBiome._sourceMagmaMap[r, s]; if (magma2.IsActive) { Tile tile = GenBase._tiles[origin.X + r, origin.Y + s]; float single3 = (float)Math.Sin((double)((float)(origin.Y + s) * 0.4f)) * 0.7f + 1.2f; float single4 = 0.2f + 0.5f / (float)Math.Sqrt((double)Math.Max(0f, magma2.Pressure - magma2.Resistance)); float single5 = 1f - Math.Max(0f, single3 * single4); single5 = Math.Max(single5, magma2.Pressure / 15f); if (single5 > 0.35f + (WorldGen.SolidTile(origin.X + r, origin.Y + s) ? 0f : 0.5f)) { if (!TileID.Sets.Ore[tile.type]) { tile.ResetToType(368); } else { tile.ResetToType(tile.type); } tile.wall = 180; } else if (magma2.Resistance < 0.01f) { WorldUtils.ClearTile(origin.X + r, origin.Y + s, false); tile.wall = 180; } if (tile.liquid > 0 && y) { tile.liquidType(1); } } } } List <Point16> point16s = new List <Point16>(); for (int t = num3; t <= num4; t++) { for (int u = num5; u <= num6; u++) { if (GraniteBiome._sourceMagmaMap[t, u].IsActive) { int num8 = 0; int x = t + origin.X; int y1 = u + origin.Y; if (WorldGen.SolidTile(x, y1)) { for (int v = -1; v <= 1; v++) { for (int w = -1; w <= 1; w++) { if (WorldGen.SolidTile(x + v, y1 + w)) { num8++; } } } if (num8 < 3) { point16s.Add(new Point16(x, y1)); } } } } } foreach (Point16 point16 in point16s) { int x1 = point16.X; int y2 = point16.Y; WorldUtils.ClearTile(x1, y2, true); GenBase._tiles[x1, y2].wall = 180; } point16s.Clear(); for (int x2 = num3; x2 <= num4; x2++) { for (int y3 = num5; y3 <= num6; y3++) { GraniteBiome.Magma magma3 = GraniteBiome._sourceMagmaMap[x2, y3]; int x3 = x2 + origin.X; int y4 = y3 + origin.Y; if (magma3.IsActive) { WorldUtils.TileFrame(x3, y4, false); WorldGen.SquareWallFrame(x3, y4, true); if (GenBase._random.Next(8) == 0 && GenBase._tiles[x3, y4].active()) { if (!GenBase._tiles[x3, y4 + 1].active()) { WorldGen.PlaceTight(x3, y4 + 1, 165, false); } if (!GenBase._tiles[x3, y4 - 1].active()) { WorldGen.PlaceTight(x3, y4 - 1, 165, false); } } if (GenBase._random.Next(2) == 0) { Tile.SmoothSlope(x3, y4, true); } } } } return(true); }