terraria-source-code/WorldGen.cs
2021-10-27 18:03:19 -04:00

41072 lines
1.6 MiB

// Decompiled with JetBrains decompiler
// Type: Terraria.WorldGen
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.GameContent;
using Terraria.GameContent.Achievements;
using Terraria.GameContent.Biomes;
using Terraria.GameContent.Events;
using Terraria.GameContent.Generation;
using Terraria.GameContent.Tile_Entities;
using Terraria.Graphics.Capture;
using Terraria.ID;
using Terraria.IO;
using Terraria.Localization;
using Terraria.Map;
using Terraria.ObjectData;
using Terraria.Utilities;
using Terraria.World.Generation;
namespace Terraria
{
public class WorldGen
{
public static TownRoomManager TownManager = new TownRoomManager();
private static int lAltarX;
private static int lAltarY;
public static int tileReframeCount = 0;
public static bool noMapUpdate = false;
public static double worldSurfaceLow;
public static int tLeft;
public static int tRight;
public static int tTop;
public static int tBottom;
public static int tRooms;
public static int[] mossType = new int[3];
public static int c = 0;
public static int m = 0;
public static int a = 0;
public static int co = 0;
public static int ir = 0;
public static int si = 0;
public static int go = 0;
public static int copperBar = 20;
public static int ironBar = 22;
public static int silverBar = 21;
public static int goldBar = 19;
public static ushort CopperTierOre = 7;
public static ushort IronTierOre = 6;
public static ushort SilverTierOre = 9;
public static ushort GoldTierOre = 8;
public static int treeBG = 0;
public static int corruptBG = 0;
public static int jungleBG = 0;
public static int snowBG = 0;
public static int hallowBG = 0;
public static int crimsonBG = 0;
public static int desertBG = 0;
public static int oceanBG = 0;
public static int oreTier1 = -1;
public static int oreTier2 = -1;
public static int oreTier3 = -1;
public static bool crimson = false;
public static byte mossTile = 179;
public static byte mossWall = 54;
public static bool[] gem = new bool[6];
public static int[] tileCounts = new int[470];
public static int totalEvil = 0;
public static int totalBlood = 0;
public static int totalGood = 0;
public static int totalSolid = 0;
public static int totalEvil2 = 0;
public static int totalBlood2 = 0;
public static int totalGood2 = 0;
public static int totalSolid2 = 0;
public static byte tEvil = 0;
public static byte tBlood = 0;
public static byte tGood = 0;
public static int totalX = 0;
public static int totalD = 0;
public static bool IsGeneratingHardMode = false;
private static Vector2[] heartPos = new Vector2[100];
private static int heartCount = 0;
public static int lavaLine;
public static int waterLine;
public static bool noTileActions = false;
public static bool spawnEye = false;
public static int spawnHardBoss = 0;
public static int numLarva = 0;
public static int[] larvaX = new int[100];
public static int[] larvaY = new int[100];
public static bool gen = false;
public static bool shadowOrbSmashed = false;
public static int shadowOrbCount = 0;
public static int altarCount = 0;
public static bool spawnMeteor = false;
public static bool loadFailed = false;
public static bool loadSuccess = false;
public static bool worldCleared = false;
public static bool worldBackup = false;
public static bool loadBackup = false;
private static int lastMaxTilesX = 0;
private static int lastMaxTilesY = 0;
public static bool saveLock = false;
private static bool mergeUp = false;
private static bool mergeDown = false;
private static bool mergeLeft = false;
private static bool mergeRight = false;
private static bool stopDrops = false;
private static bool mudWall = false;
private static int grassSpread = 0;
public static bool noLiquidCheck = false;
[ThreadStatic]
public static UnifiedRandom _genRand;
[ThreadStatic]
public static int _genRandSeed = -2;
public static int _lastSeed;
public static string statusText = "";
public static bool destroyObject = false;
public static int spawnDelay = 0;
public static int prioritizedTownNPC = 0;
public static int numTileCount = 0;
public static int maxTileCount = 3500;
public static int maxWallOut2 = 5000;
public static int[] countX = new int[WorldGen.maxTileCount];
public static int[] countY = new int[WorldGen.maxTileCount];
public static int lavaCount = 0;
public static int iceCount = 0;
public static int rockCount = 0;
public static int maxRoomTiles = 750;
public static int numRoomTiles;
public static int[] roomX = new int[WorldGen.maxRoomTiles];
public static int[] roomY = new int[WorldGen.maxRoomTiles];
public static int roomCeilingsCount;
public static int[] roomCeilingX = new int[WorldGen.maxRoomTiles];
public static int[] roomCeilingY = new int[WorldGen.maxRoomTiles];
public static int roomX1;
public static int roomX2;
public static int roomY1;
public static int roomY2;
public static bool canSpawn;
public static bool[] houseTile = new bool[470];
public static int bestX = 0;
public static int bestY = 0;
public static int hiScore = 0;
public static int dungeonX;
public static int dungeonY;
public static Vector2 lastDungeonHall = Vector2.Zero;
public static int maxDRooms = 100;
public static int numDRooms = 0;
public static int[] dRoomX = new int[WorldGen.maxDRooms];
public static int[] dRoomY = new int[WorldGen.maxDRooms];
public static int[] dRoomSize = new int[WorldGen.maxDRooms];
private static bool[] dRoomTreasure = new bool[WorldGen.maxDRooms];
private static int[] dRoomL = new int[WorldGen.maxDRooms];
private static int[] dRoomR = new int[WorldGen.maxDRooms];
private static int[] dRoomT = new int[WorldGen.maxDRooms];
private static int[] dRoomB = new int[WorldGen.maxDRooms];
private static int numDDoors;
private static int[] DDoorX = new int[300];
private static int[] DDoorY = new int[300];
private static int[] DDoorPos = new int[300];
private static int numDPlats;
private static int[] DPlatX = new int[300];
private static int[] DPlatY = new int[300];
private static int JungleItemCount = 0;
private static int[] JChestX = new int[100];
private static int[] JChestY = new int[100];
private static int numJChests = 0;
public static int dEnteranceX = 0;
public static bool dSurface = false;
private static double dxStrength1;
private static double dyStrength1;
private static double dxStrength2;
private static double dyStrength2;
private static int dMinX;
private static int dMaxX;
private static int dMinY;
private static int dMaxY;
private static int numIslandHouses = 0;
private static int houseCount = 0;
private static bool[] skyLake = new bool[30];
private static int[] fihX = new int[30];
private static int[] fihY = new int[30];
private static int numMCaves = 0;
private static int[] mCaveX = new int[30];
private static int[] mCaveY = new int[30];
private static int JungleX = 0;
private static int hellChest = 0;
private static int[] hellChestItem = new int[5];
private static bool roomTorch;
private static bool roomDoor;
private static bool roomChair;
private static bool roomTable;
private static bool roomOccupied;
private static bool roomEvil;
public static Point16[] statueList;
public static List<int> StatuesWithTraps = new List<int>((IEnumerable<int>) new int[4]
{
4,
7,
10,
18
});
public static Microsoft.Xna.Framework.Rectangle UndergroundDesertLocation = Microsoft.Xna.Framework.Rectangle.Empty;
private static bool currentlyTryingToUseAlternateHousingSpot = false;
public static TownNPCRoomCheckFailureReason roomCheckFailureReason = TownNPCRoomCheckFailureReason.None;
private static int[,] trapDiag = new int[4, 2];
private static int tileCounterNum = 0;
private static int tileCounterMax = 20;
private static int[] tileCounterX = new int[WorldGen.tileCounterMax];
private static int[] tileCounterY = new int[WorldGen.tileCounterMax];
private static WorldGenerator _generator;
public static int WorldGenParam_Evil = -1;
public static UnifiedRandom genRand
{
get
{
if (WorldGen._lastSeed != WorldGen._genRandSeed)
{
WorldGen._genRand = new UnifiedRandom(WorldGen._lastSeed);
WorldGen._genRandSeed = WorldGen._lastSeed;
}
if (WorldGen._genRand == null)
{
WorldGen._genRand = new UnifiedRandom(WorldGen._lastSeed);
WorldGen._genRandSeed = WorldGen._lastSeed;
}
return WorldGen._genRand;
}
}
public static void SetupStatueList()
{
List<Point16> point16List = new List<Point16>();
for (int Y = 0; Y < 44; ++Y)
point16List.Add(new Point16(105, Y));
point16List[34] = new Point16(349, 0);
point16List[43] = new Point16(105, 50);
point16List.Add(new Point16(105, 63));
point16List.Add(new Point16(105, 64));
point16List.Add(new Point16(105, 65));
point16List.Add(new Point16(105, 66));
point16List.Add(new Point16(105, 68));
point16List.Add(new Point16(105, 69));
point16List.Add(new Point16(105, 70));
point16List.Add(new Point16(105, 71));
point16List.Add(new Point16(105, 72));
point16List.Add(new Point16(105, 73));
point16List.Add(new Point16(105, 75));
if (Main.expertMode)
{
point16List.Add(new Point16(105, 67));
point16List.Add(new Point16(105, 74));
}
WorldGen.statueList = point16List.ToArray();
}
public static void PlaceStatueTrap(int x, int y)
{
for (int index1 = -10; index1 <= 10; ++index1)
{
for (int index2 = -10; index2 <= 10; ++index2)
{
Tile testTile = Main.tile[x + index1, y + index2 + 1];
Tile tile = Main.tile[x + index1, y + index2];
if (!tile.active() && WorldGen.SolidTile2(testTile))
{
WorldGen.PlaceTile(x + index1, y + index2, 135, true);
if (tile.active() && tile.type == (ushort) 135)
{
WorldUtils.WireLine(new Point(x, y), new Point(x + index1, y + index2));
return;
}
}
}
}
}
public static bool MoveTownNPC(int x, int y, int n)
{
if (!WorldGen.StartRoomCheck(x, y))
{
string textValue = Lang.inter[40].Value;
switch (WorldGen.roomCheckFailureReason)
{
case TownNPCRoomCheckFailureReason.TooCloseToWorldEdge:
textValue = Language.GetTextValue("TownNPCHousingFailureReasons.TooCloseToWorldEdge");
break;
case TownNPCRoomCheckFailureReason.RoomIsTooBig:
textValue = Language.GetTextValue("TownNPCHousingFailureReasons.RoomIsTooBig");
break;
case TownNPCRoomCheckFailureReason.RoomIsTooSmall:
textValue = Language.GetTextValue("TownNPCHousingFailureReasons.RoomIsTooSmall");
break;
case TownNPCRoomCheckFailureReason.HoleInWallIsTooBig:
textValue = Language.GetTextValue("TownNPCHousingFailureReasons.HoleInWallIsTooBig");
break;
case TownNPCRoomCheckFailureReason.RoomCheckStartedInASolidTile:
textValue = Language.GetTextValue("TownNPCHousingFailureReasons.RoomCheckStartedInASolidTile");
break;
}
Main.NewText(textValue, G: (byte) 240, B: (byte) 20);
return false;
}
if (!WorldGen.RoomNeeds(WorldGen.prioritizedTownNPC))
{
int index = 0;
int length = (WorldGen.roomTorch ? 0 : 1) + (WorldGen.roomDoor ? 0 : 1) + (WorldGen.roomTable ? 0 : 1) + (WorldGen.roomChair ? 0 : 1);
string[] strArray = new string[length];
if (!WorldGen.roomTorch)
{
strArray[index] = Language.GetTextValue("Game.HouseLightSource");
++index;
}
if (!WorldGen.roomDoor)
{
strArray[index] = Language.GetTextValue("Game.HouseDoor");
++index;
}
if (!WorldGen.roomTable)
{
strArray[index] = Language.GetTextValue("Game.HouseTable");
++index;
}
if (!WorldGen.roomChair)
{
strArray[index] = Language.GetTextValue("Game.HouseChair");
int num = index + 1;
}
Main.NewText(Language.GetTextValue("Game.HouseMissing_" + (object) length, (object[]) strArray), G: (byte) 240, B: (byte) 20);
return false;
}
WorldGen.ScoreRoom();
if (WorldGen.hiScore <= 0)
{
if (WorldGen.roomOccupied)
Main.NewText(Lang.inter[41].Value, G: (byte) 240, B: (byte) 20);
else if (WorldGen.roomEvil)
Main.NewText(Lang.inter[42].Value, G: (byte) 240, B: (byte) 20);
else
Main.NewText(Lang.inter[40].Value, G: (byte) 240, B: (byte) 20);
return false;
}
if (n <= 0 || WorldGen.CheckSpecialTownNPCSpawningConditions(Main.npc[n].type))
return true;
Main.NewText(Lang.inter[55].Value + " " + Main.npc[n].TypeName, G: (byte) 240, B: (byte) 20);
return false;
}
public static void moveRoom(int x, int y, int n)
{
if (Main.netMode == 1)
{
NetMessage.SendData(60, number: n, number2: ((float) x), number3: ((float) y));
}
else
{
WorldGen.prioritizedTownNPC = Main.npc[n].type;
Main.npc[n].homeless = true;
int num = (int) WorldGen.SpawnTownNPC(x, y);
WorldGen.TownManager.SetRoom(Main.npc[n].type, Main.npc[n].homeTileX, Main.npc[n].homeTileY);
}
}
public static void kickOut(int n)
{
if (Main.netMode == 1)
{
NetMessage.SendData(60, number: n, number4: 1f);
}
else
{
Main.npc[n].homeless = true;
WorldGen.TownManager.KickOut(Main.npc[n]);
}
}
public static bool IsThereASpawnablePrioritizedTownNPC(int x, int y)
{
if (WorldGen.CheckSpecialTownNPCSpawningConditions(WorldGen.prioritizedTownNPC) && NPC.AnyNPCs(WorldGen.prioritizedTownNPC))
return true;
int occupation = WorldGen.TownManager.FindOccupation(x, y);
if (occupation != -1 && Main.townNPCCanSpawn[occupation] && !NPC.AnyNPCs(occupation) && WorldGen.CheckSpecialTownNPCSpawningConditions(occupation))
{
WorldGen.prioritizedTownNPC = occupation;
return true;
}
int num = -1;
for (int index = 0; index < 580; ++index)
{
if (Main.townNPCCanSpawn[index] && WorldGen.CheckSpecialTownNPCSpawningConditions(index))
{
if (NPC.AnyNPCs(index))
Main.townNPCCanSpawn[index] = false;
else if (WorldGen.TownManager.HasRoomQuick(index))
{
if (num == -1)
num = index;
}
else
{
WorldGen.prioritizedTownNPC = index;
return true;
}
}
}
if (num == -1)
return false;
WorldGen.prioritizedTownNPC = num;
return true;
}
public static bool CheckSpecialTownNPCSpawningConditions(int type)
{
if (type != 160)
return true;
if ((double) WorldGen.roomY2 > Main.worldSurface)
return false;
int num1 = 0;
int num2 = WorldGen.roomX1 - Main.zoneX / 2 / 16 - 1 - Lighting.offScreenTiles;
int num3 = WorldGen.roomX2 + Main.zoneX / 2 / 16 + 1 + Lighting.offScreenTiles;
int num4 = WorldGen.roomY1 - Main.zoneY / 2 / 16 - 1 - Lighting.offScreenTiles;
int num5 = WorldGen.roomY2 + Main.zoneY / 2 / 16 + 1 + Lighting.offScreenTiles;
if (num2 < 0)
num2 = 0;
if (num3 >= Main.maxTilesX)
num3 = Main.maxTilesX - 1;
if (num4 < 0)
num4 = 0;
if (num5 > Main.maxTilesX)
num5 = Main.maxTilesX;
for (int index1 = num2 + 1; index1 < num3; ++index1)
{
for (int index2 = num4 + 2; index2 < num5 + 2; ++index2)
{
if (Main.tile[index1, index2].active() && (Main.tile[index1, index2].type == (ushort) 70 || Main.tile[index1, index2].type == (ushort) 71 || Main.tile[index1, index2].type == (ushort) 72))
++num1;
}
}
return num1 >= 100;
}
public static void UnspawnTravelNPC()
{
int number = -1;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && Main.npc[index].type == 368)
{
number = index;
break;
}
}
if (number < 0)
return;
int num1 = (int) ((double) Main.npc[number].Center.X / 16.0);
int num2 = (int) ((double) Main.npc[number].Center.Y / 16.0);
bool flag = true;
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(num1 * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, num2 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active && new Microsoft.Xna.Framework.Rectangle((int) Main.player[index].position.X, (int) Main.player[index].position.Y, Main.player[index].width, Main.player[index].height).Intersects(rectangle))
{
flag = false;
break;
}
}
if (!flag)
return;
string fullName = Main.npc[number].FullName;
switch (Main.netMode)
{
case 0:
Main.NewText(Lang.misc[35].Format((object) fullName), (byte) 50, (byte) 125);
break;
case 2:
NetMessage.BroadcastChatMessage(NetworkText.FromKey(Lang.misc[35].Key, (object) Main.npc[number].GetFullNetName()), new Color(50, 125, (int) byte.MaxValue));
break;
}
Main.npc[number].active = false;
Main.npc[number].netSkip = -1;
Main.npc[number].life = 0;
NetMessage.SendData(23, number: number);
}
public static void SpawnTravelNPC()
{
if (Main.eclipse || !Main.dayTime || Main.invasionType > 0 && Main.invasionDelay == 0 && Main.invasionSize > 0)
return;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && Main.npc[index].type == 368)
return;
}
Chest.SetupTravelShop();
NetMessage.SendTravelShop(-1);
int[] numArray = new int[200];
int maxValue = 0;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && Main.npc[index].townNPC && Main.npc[index].type != 37 && !Main.npc[index].homeless)
{
numArray[maxValue] = index;
++maxValue;
}
}
if (maxValue == 0)
return;
int index1 = numArray[Main.rand.Next(maxValue)];
WorldGen.bestX = Main.npc[index1].homeTileX;
WorldGen.bestY = Main.npc[index1].homeTileY;
int minValue = WorldGen.bestX;
int num1 = WorldGen.bestX;
int bestY = WorldGen.bestY;
for (int bestX = WorldGen.bestX; bestX > WorldGen.bestX - 10 && (WorldGen.SolidTile(bestX, bestY) || Main.tileSolidTop[(int) Main.tile[bestX, bestY].type]) && (!Main.tile[bestX, bestY - 1].active() || !Main.tileSolid[(int) Main.tile[bestX, bestY - 1].type] || Main.tileSolidTop[(int) Main.tile[bestX, bestY - 1].type]) && (!Main.tile[bestX, bestY - 2].active() || !Main.tileSolid[(int) Main.tile[bestX, bestY - 2].type] || Main.tileSolidTop[(int) Main.tile[bestX, bestY - 2].type]) && (!Main.tile[bestX, bestY - 3].active() || !Main.tileSolid[(int) Main.tile[bestX, bestY - 3].type] || Main.tileSolidTop[(int) Main.tile[bestX, bestY - 3].type]); --bestX)
minValue = bestX;
for (int bestX = WorldGen.bestX; bestX < WorldGen.bestX + 10 && (WorldGen.SolidTile(bestX, bestY) || Main.tileSolidTop[(int) Main.tile[bestX, bestY].type]) && (!Main.tile[bestX, bestY - 1].active() || !Main.tileSolid[(int) Main.tile[bestX, bestY - 1].type] || Main.tileSolidTop[(int) Main.tile[bestX, bestY - 1].type]) && (!Main.tile[bestX, bestY - 2].active() || !Main.tileSolid[(int) Main.tile[bestX, bestY - 2].type] || Main.tileSolidTop[(int) Main.tile[bestX, bestY - 2].type]) && (!Main.tile[bestX, bestY - 3].active() || !Main.tileSolid[(int) Main.tile[bestX, bestY - 3].type] || Main.tileSolidTop[(int) Main.tile[bestX, bestY - 3].type]); ++bestX)
num1 = bestX;
for (int index2 = 0; index2 < 30; ++index2)
{
int num2 = Main.rand.Next(minValue, num1 + 1);
if (index2 < 20)
{
if (num2 < WorldGen.bestX - 1 || num2 > WorldGen.bestX + 1)
{
WorldGen.bestX = num2;
break;
}
}
else if (num2 != WorldGen.bestX)
{
WorldGen.bestX = num2;
break;
}
}
int index3 = WorldGen.bestX;
int index4 = WorldGen.bestY;
bool flag = false;
if (!flag && (double) index4 <= Main.worldSurface)
{
for (int index5 = 20; index5 < 500; ++index5)
{
for (int index6 = 0; index6 < 2; ++index6)
{
index3 = index6 != 0 ? WorldGen.bestX - index5 * 2 : WorldGen.bestX + index5 * 2;
if (index3 > 10 && index3 < Main.maxTilesX - 10)
{
int num3 = WorldGen.bestY - index5;
double num4 = (double) (WorldGen.bestY + index5);
if (num3 < 10)
num3 = 10;
if (num4 > Main.worldSurface)
num4 = Main.worldSurface;
for (int index7 = num3; (double) index7 < num4; ++index7)
{
index4 = index7;
if (Main.tile[index3, index4].nactive() && Main.tileSolid[(int) Main.tile[index3, index4].type])
{
if (Main.tile[index3, index4 - 3].liquid == (byte) 0 && Main.tile[index3, index4 - 2].liquid == (byte) 0 && Main.tile[index3, index4 - 1].liquid == (byte) 0 && !Collision.SolidTiles(index3 - 1, index3 + 1, index4 - 3, index4 - 1))
{
flag = true;
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(index3 * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, index4 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
for (int index8 = 0; index8 < (int) byte.MaxValue; ++index8)
{
if (Main.player[index8].active && new Microsoft.Xna.Framework.Rectangle((int) Main.player[index8].position.X, (int) Main.player[index8].position.Y, Main.player[index8].width, Main.player[index8].height).Intersects(rectangle))
{
flag = false;
break;
}
}
break;
}
break;
}
}
}
if (flag)
break;
}
if (flag)
break;
}
}
int index9 = NPC.NewNPC(index3 * 16, index4 * 16, 368, 1);
Main.npc[index9].homeTileX = WorldGen.bestX;
Main.npc[index9].homeTileY = WorldGen.bestY;
Main.npc[index9].homeless = true;
if (index3 < WorldGen.bestX)
Main.npc[index9].direction = 1;
else if (index3 > WorldGen.bestX)
Main.npc[index9].direction = -1;
Main.npc[index9].netUpdate = true;
string fullName = Main.npc[index9].FullName;
if (Main.netMode == 0)
{
Main.NewText(Language.GetTextValue("Announcement.HasArrived", (object) fullName), (byte) 50, (byte) 125);
}
else
{
if (Main.netMode != 2)
return;
NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasArrived", (object) Main.npc[index9].GetFullNetName()), new Color(50, 125, (int) byte.MaxValue));
}
}
public static TownNPCSpawnResult SpawnTownNPC(int x, int y)
{
if (Main.wallHouse[(int) Main.tile[x, y].wall])
WorldGen.canSpawn = true;
if (!WorldGen.canSpawn || !WorldGen.StartRoomCheck(x, y) || !WorldGen.RoomNeeds(WorldGen.prioritizedTownNPC))
return TownNPCSpawnResult.Blocked;
WorldGen.ScoreRoom();
if (WorldGen.hiScore <= 0 || !WorldGen.IsThereASpawnablePrioritizedTownNPC(WorldGen.bestX, WorldGen.bestY))
return TownNPCSpawnResult.Blocked;
int index1 = -1;
for (int index2 = 0; index2 < 200; ++index2)
{
if (Main.npc[index2].active && Main.npc[index2].homeless && Main.npc[index2].type == WorldGen.prioritizedTownNPC && WorldGen.CheckSpecialTownNPCSpawningConditions(Main.npc[index2].type))
{
index1 = index2;
break;
}
}
if (index1 != -1)
{
Main.townNPCCanSpawn[WorldGen.prioritizedTownNPC] = false;
Main.npc[index1].homeTileX = WorldGen.bestX;
Main.npc[index1].homeTileY = WorldGen.bestY;
Main.npc[index1].homeless = false;
AchievementsHelper.NotifyProgressionEvent(8);
WorldGen.prioritizedTownNPC = 0;
return TownNPCSpawnResult.RelocatedHomeless;
}
if (index1 == -1)
{
Point roomPosition;
if (WorldGen.TownManager.HasRoom(WorldGen.prioritizedTownNPC, out roomPosition) && !WorldGen.currentlyTryingToUseAlternateHousingSpot)
{
int bestX = WorldGen.bestX;
int bestY = WorldGen.bestY;
WorldGen.currentlyTryingToUseAlternateHousingSpot = true;
TownNPCSpawnResult townNpcSpawnResult = WorldGen.SpawnTownNPC(roomPosition.X, roomPosition.Y - 2);
WorldGen.currentlyTryingToUseAlternateHousingSpot = false;
WorldGen.bestX = bestX;
WorldGen.bestY = bestY;
if (townNpcSpawnResult == TownNPCSpawnResult.Successful)
return townNpcSpawnResult;
}
int index3 = WorldGen.bestX;
int index4 = WorldGen.bestY;
bool flag1 = false;
for (int index5 = 0; index5 < 200; ++index5)
{
NPC npc = Main.npc[index5];
if (npc.active && npc.townNPC && !npc.homeless && npc.homeTileX == index3 && npc.homeTileY == index4)
{
flag1 = true;
break;
}
}
if (flag1)
return TownNPCSpawnResult.BlockedInfiHousing;
bool flag2 = false;
if (!flag2)
{
flag2 = true;
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(index3 * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, index4 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
for (int index6 = 0; index6 < (int) byte.MaxValue; ++index6)
{
if (Main.player[index6].active && new Microsoft.Xna.Framework.Rectangle((int) Main.player[index6].position.X, (int) Main.player[index6].position.Y, Main.player[index6].width, Main.player[index6].height).Intersects(rectangle))
{
flag2 = false;
break;
}
}
}
if (!flag2 && (double) index4 <= Main.worldSurface)
{
for (int index7 = 1; index7 < 500; ++index7)
{
for (int index8 = 0; index8 < 2; ++index8)
{
index3 = index8 != 0 ? WorldGen.bestX - index7 : WorldGen.bestX + index7;
if (index3 > 10 && index3 < Main.maxTilesX - 10)
{
int num1 = WorldGen.bestY - index7;
double num2 = (double) (WorldGen.bestY + index7);
if (num1 < 10)
num1 = 10;
if (num2 > Main.worldSurface)
num2 = Main.worldSurface;
for (int index9 = num1; (double) index9 < num2; ++index9)
{
index4 = index9;
if (Main.tile[index3, index4].nactive() && Main.tileSolid[(int) Main.tile[index3, index4].type])
{
if (!Collision.SolidTiles(index3 - 1, index3 + 1, index4 - 3, index4 - 1))
{
flag2 = true;
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(index3 * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, index4 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
for (int index10 = 0; index10 < (int) byte.MaxValue; ++index10)
{
if (Main.player[index10].active && new Microsoft.Xna.Framework.Rectangle((int) Main.player[index10].position.X, (int) Main.player[index10].position.Y, Main.player[index10].width, Main.player[index10].height).Intersects(rectangle))
{
flag2 = false;
break;
}
}
break;
}
break;
}
}
}
if (flag2)
break;
}
if (flag2)
break;
}
}
int index11 = NPC.NewNPC(index3 * 16, index4 * 16, WorldGen.prioritizedTownNPC, 1);
Main.townNPCCanSpawn[WorldGen.prioritizedTownNPC] = false;
Main.npc[index11].homeTileX = WorldGen.bestX;
Main.npc[index11].homeTileY = WorldGen.bestY;
if (index3 < WorldGen.bestX)
Main.npc[index11].direction = 1;
else if (index3 > WorldGen.bestX)
Main.npc[index11].direction = -1;
Main.npc[index11].netUpdate = true;
string fullName = Main.npc[index11].FullName;
switch (Main.netMode)
{
case 0:
Main.NewText(Language.GetTextValue("Announcement.HasArrived", (object) fullName), (byte) 50, (byte) 125);
break;
case 2:
NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasArrived", (object) Main.npc[index11].GetFullNetName()), new Color(50, 125, (int) byte.MaxValue));
break;
}
AchievementsHelper.NotifyProgressionEvent(8);
if (Main.npc[index11].type == 160)
AchievementsHelper.NotifyProgressionEvent(18);
WorldGen.CheckAchievement_RealEstate();
WorldGen.prioritizedTownNPC = 0;
}
return TownNPCSpawnResult.Successful;
}
private static void CheckAchievement_RealEstate()
{
bool[] flagArray = new bool[580];
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && Main.npc[index].type >= 0 && Main.npc[index].type < 580)
flagArray[Main.npc[index].type] = true;
}
if (!flagArray[38] || !flagArray[17] || !flagArray[107] || !flagArray[19] || !flagArray[22] || !flagArray[124] || !flagArray[228] || !flagArray[178] || !flagArray[18] || !flagArray[229] || !flagArray[209] || !flagArray[54] || !flagArray[108] || !flagArray[160] || !flagArray[20] || !flagArray[369] || !flagArray[207] || !flagArray[227] || !flagArray[208] || !flagArray[441] || !flagArray[353])
return;
AchievementsHelper.NotifyProgressionEvent(17);
}
public static bool RoomNeeds(int npcType)
{
WorldGen.roomChair = false;
WorldGen.roomDoor = false;
WorldGen.roomTable = false;
WorldGen.roomTorch = false;
for (int index = 0; index < TileID.Sets.RoomNeeds.CountsAsChair.Length; ++index)
{
if (WorldGen.houseTile[TileID.Sets.RoomNeeds.CountsAsChair[index]])
{
WorldGen.roomChair = true;
break;
}
}
for (int index = 0; index < TileID.Sets.RoomNeeds.CountsAsTable.Length; ++index)
{
if (WorldGen.houseTile[TileID.Sets.RoomNeeds.CountsAsTable[index]])
{
WorldGen.roomTable = true;
break;
}
}
for (int index = 0; index < TileID.Sets.RoomNeeds.CountsAsTorch.Length; ++index)
{
if (WorldGen.houseTile[TileID.Sets.RoomNeeds.CountsAsTorch[index]])
{
WorldGen.roomTorch = true;
break;
}
}
for (int index = 0; index < TileID.Sets.RoomNeeds.CountsAsDoor.Length; ++index)
{
if (WorldGen.houseTile[TileID.Sets.RoomNeeds.CountsAsDoor[index]])
{
WorldGen.roomDoor = true;
break;
}
}
WorldGen.canSpawn = WorldGen.roomChair && WorldGen.roomTable && WorldGen.roomDoor && WorldGen.roomTorch;
return WorldGen.canSpawn;
}
public static void QuickFindHome(int npc)
{
if (Main.npc[npc].homeTileX <= 10 || Main.npc[npc].homeTileY <= 10 || Main.npc[npc].homeTileX >= Main.maxTilesX - 10 || Main.npc[npc].homeTileY >= Main.maxTilesY)
return;
WorldGen.canSpawn = false;
WorldGen.StartRoomCheck(Main.npc[npc].homeTileX, Main.npc[npc].homeTileY - 1);
if (!WorldGen.canSpawn)
{
for (int x = Main.npc[npc].homeTileX - 1; x < Main.npc[npc].homeTileX + 2; ++x)
{
int y = Main.npc[npc].homeTileY - 1;
while (y < Main.npc[npc].homeTileY + 2 && !WorldGen.StartRoomCheck(x, y))
++y;
}
}
if (!WorldGen.canSpawn)
{
int num = 10;
for (int x = Main.npc[npc].homeTileX - num; x <= Main.npc[npc].homeTileX + num; x += 2)
{
int y = Main.npc[npc].homeTileY - num;
while (y <= Main.npc[npc].homeTileY + num && !WorldGen.StartRoomCheck(x, y))
y += 2;
}
}
if (WorldGen.canSpawn)
{
WorldGen.RoomNeeds(Main.npc[npc].type);
if (WorldGen.canSpawn)
WorldGen.ScoreRoom(npc);
if (WorldGen.canSpawn && WorldGen.hiScore > 0)
{
for (int index = 0; index < 200; ++index)
{
if (index != npc)
{
NPC npc1 = Main.npc[index];
if (npc1.active && npc1.townNPC && !npc1.homeless && npc1.homeTileX == WorldGen.bestX && npc1.homeTileY == WorldGen.bestY)
{
WorldGen.canSpawn = false;
break;
}
}
}
}
if (WorldGen.canSpawn && WorldGen.hiScore > 0)
{
Main.npc[npc].homeTileX = WorldGen.bestX;
Main.npc[npc].homeTileY = WorldGen.bestY;
Main.npc[npc].homeless = false;
AchievementsHelper.NotifyProgressionEvent(8);
WorldGen.canSpawn = false;
}
else
Main.npc[npc].homeless = true;
}
else
Main.npc[npc].homeless = true;
}
private static bool ScoreRoom_IsThisRoomOccupiedBySomeone(int ignoreNPC = -1)
{
for (int index1 = 0; index1 < 200; ++index1)
{
if (Main.npc[index1].active && Main.npc[index1].townNPC && ignoreNPC != index1 && !Main.npc[index1].homeless)
{
for (int index2 = 0; index2 < WorldGen.numRoomTiles; ++index2)
{
if (Main.npc[index1].homeTileX == WorldGen.roomX[index2] && Main.npc[index1].homeTileY == WorldGen.roomY[index2])
{
bool flag = false;
for (int index3 = 0; index3 < WorldGen.numRoomTiles; ++index3)
{
if (Main.npc[index1].homeTileX == WorldGen.roomX[index3] && Main.npc[index1].homeTileY - 1 == WorldGen.roomY[index3])
{
flag = true;
break;
}
}
if (flag)
return true;
}
}
}
}
return false;
}
public static void CountTileTypesInArea(
int[] tileTypeCounts,
int startX,
int endX,
int startY,
int endY)
{
for (int index1 = startX; index1 <= endX; ++index1)
{
for (int index2 = startY; index2 <= endY; ++index2)
{
if (Main.tile[index1, index2].active())
++tileTypeCounts[(int) Main.tile[index1, index2].type];
}
}
}
public static int GetTileTypeCountByCategory(int[] tileTypeCounts, TileScanGroup group)
{
switch (group)
{
case TileScanGroup.None:
return 0;
case TileScanGroup.Corruption:
return tileTypeCounts[23] + tileTypeCounts[24] + tileTypeCounts[25] + tileTypeCounts[32] + tileTypeCounts[112] + tileTypeCounts[163] + tileTypeCounts[400] + tileTypeCounts[398] + -5 * tileTypeCounts[27];
case TileScanGroup.Crimson:
return tileTypeCounts[199] + tileTypeCounts[203] + tileTypeCounts[200] + tileTypeCounts[401] + tileTypeCounts[399] + tileTypeCounts[234] + tileTypeCounts[352] - 5 * tileTypeCounts[27];
case TileScanGroup.Hallow:
return tileTypeCounts[109] + tileTypeCounts[110] + tileTypeCounts[113] + tileTypeCounts[117] + tileTypeCounts[116] + tileTypeCounts[164] + tileTypeCounts[403] + tileTypeCounts[402];
case TileScanGroup.TotalGoodEvil:
int typeCountByCategory1 = WorldGen.GetTileTypeCountByCategory(tileTypeCounts, TileScanGroup.Hallow);
int typeCountByCategory2 = WorldGen.GetTileTypeCountByCategory(tileTypeCounts, TileScanGroup.Corruption);
int typeCountByCategory3 = WorldGen.GetTileTypeCountByCategory(tileTypeCounts, TileScanGroup.Crimson);
int num1 = 5 * tileTypeCounts[27];
int num2 = typeCountByCategory3;
int num3 = typeCountByCategory2 + num2 + num1;
return typeCountByCategory1 - num3;
default:
return 0;
}
}
public static void ScoreRoom(int ignoreNPC = -1)
{
WorldGen.roomOccupied = false;
WorldGen.roomEvil = false;
if (WorldGen.ScoreRoom_IsThisRoomOccupiedBySomeone(ignoreNPC))
{
WorldGen.roomOccupied = true;
WorldGen.hiScore = -1;
}
else
{
WorldGen.hiScore = 0;
int num1 = 50;
int num2 = 40;
int num3 = WorldGen.roomX1 - Main.zoneX / 2 / 16 - 1 - num2;
int num4 = WorldGen.roomX2 + Main.zoneX / 2 / 16 + 1 + num2;
int num5 = WorldGen.roomY1 - Main.zoneY / 2 / 16 - 1 - num2;
int num6 = WorldGen.roomY2 + Main.zoneY / 2 / 16 + 1 + num2;
if (num3 < 0)
num3 = 0;
if (num4 >= Main.maxTilesX)
num4 = Main.maxTilesX - 1;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY - 1;
int[] tileTypeCounts = new int[470];
WorldGen.CountTileTypesInArea(tileTypeCounts, num3 + 1, num4 - 1, num5 + 2, num6 + 1);
int num7 = -WorldGen.GetTileTypeCountByCategory(tileTypeCounts, TileScanGroup.TotalGoodEvil);
if (num7 < 50)
num7 = 0;
int num8 = num1 - num7;
if (num8 <= -250)
{
WorldGen.hiScore = num8;
WorldGen.roomEvil = true;
}
else
{
int roomX1 = WorldGen.roomX1;
int roomX2 = WorldGen.roomX2;
int roomY1 = WorldGen.roomY1;
int roomY2 = WorldGen.roomY2;
for (int i = roomX1 + 1; i < roomX2; ++i)
{
for (int j = roomY1 + 2; j < roomY2 + 2; ++j)
{
if (Main.tile[i, j].nactive())
{
int num9 = num8;
if (Main.tileSolid[(int) Main.tile[i, j].type] && !Main.tileSolidTop[(int) Main.tile[i, j].type] && !Collision.SolidTiles(i - 1, i + 1, j - 3, j - 1) && Main.tile[i - 1, j].nactive() && Main.tileSolid[(int) Main.tile[i - 1, j].type] && Main.tile[i + 1, j].nactive() && Main.tileSolid[(int) Main.tile[i + 1, j].type])
{
int num10 = 0;
int num11 = 0;
for (int x = i - 2; x < i + 3; ++x)
{
for (int y = j - 4; y < j; ++y)
{
if (Main.tile[x, y].nactive())
{
if (x == i)
{
++num10;
}
else
{
Tile tile = Main.tile[x, y];
if (TileID.Sets.BasicChest[(int) tile.type])
++num11;
else if (tile.type == (ushort) 10 || tile.type == (ushort) 388)
num9 -= 20;
else if (WorldGen.IsOpenDoorAnchorFrame(x, y))
num9 -= 20;
else if (Main.tileSolid[(int) tile.type])
num9 -= 5;
else
num9 += 5;
}
}
}
}
if (num9 > 0 && num11 > 0)
{
num9 -= 30 * num11;
if (num9 < 1)
num9 = 1;
}
if (num9 > 0 && num10 > 0)
{
num9 -= 15 * num10;
if (num9 <= 0)
num9 = 0;
}
if (num9 > WorldGen.hiScore)
{
bool flag1 = WorldGen.Housing_CheckIfInRoom(i, j);
bool[] flagArray = new bool[3];
for (int index = 1; index <= 3; ++index)
{
if (!Main.tile[i, j - index].active() || !Main.tileSolid[(int) Main.tile[i, j - index].type])
flagArray[index - 1] = true;
if (!WorldGen.Housing_CheckIfInRoom(i, j - index))
flagArray[index - 1] = false;
}
foreach (bool flag2 in flagArray)
{
if (!flag2)
{
flag1 = false;
break;
}
}
if (flag1 && !WorldGen.Housing_CheckIfIsCeiling(i, j))
{
WorldGen.hiScore = num9;
WorldGen.bestX = i;
WorldGen.bestY = j;
}
}
}
}
}
}
}
}
}
private static void ScoreRoom_CountEvilTilesOld(
ref int startScore,
int startX,
int endX,
int startY,
int endY)
{
int num = 0;
for (int index1 = startX + 1; index1 < endX; ++index1)
{
for (int index2 = startY + 2; index2 < endY + 2; ++index2)
{
if (Main.tile[index1, index2].active())
{
if (Main.tile[index1, index2].type == (ushort) 23 || Main.tile[index1, index2].type == (ushort) 24 || Main.tile[index1, index2].type == (ushort) 25 || Main.tile[index1, index2].type == (ushort) 32 || Main.tile[index1, index2].type == (ushort) 112 || Main.tile[index1, index2].type == (ushort) 163)
++num;
else if (Main.tile[index1, index2].type == (ushort) 199 || Main.tile[index1, index2].type == (ushort) 201 || Main.tile[index1, index2].type == (ushort) 200 || Main.tile[index1, index2].type == (ushort) 203 || Main.tile[index1, index2].type == (ushort) 234)
++num;
else if (Main.tile[index1, index2].type == (ushort) 27)
num -= 5;
else if (Main.tile[index1, index2].type == (ushort) 109 || Main.tile[index1, index2].type == (ushort) 110 || Main.tile[index1, index2].type == (ushort) 113 || Main.tile[index1, index2].type == (ushort) 116 || Main.tile[index1, index2].type == (ushort) 164)
--num;
}
}
}
if (num < 50)
num = 0;
startScore -= num;
}
private static bool Housing_CheckIfIsCeiling(int i, int j)
{
bool flag = false;
for (int index = 0; index < WorldGen.roomCeilingsCount; ++index)
{
if (WorldGen.roomCeilingX[index] == i)
{
if (WorldGen.roomCeilingY[index] == j)
{
flag = true;
break;
}
break;
}
}
return flag;
}
private static bool Housing_CheckIfInRoom(int i, int j)
{
bool flag = false;
for (int index = 0; index < WorldGen.numRoomTiles; ++index)
{
if (WorldGen.roomX[index] == i && WorldGen.roomY[index] == j)
{
flag = true;
break;
}
}
return flag;
}
public static bool StartRoomCheck(int x, int y)
{
WorldGen.roomX1 = x;
WorldGen.roomX2 = x;
WorldGen.roomY1 = y;
WorldGen.roomY2 = y;
WorldGen.numRoomTiles = 0;
WorldGen.roomCeilingsCount = 0;
for (int index = 0; index < 470; ++index)
WorldGen.houseTile[index] = false;
WorldGen.canSpawn = true;
if (Main.tile[x, y].nactive() && Main.tileSolid[(int) Main.tile[x, y].type])
{
WorldGen.roomCheckFailureReason = TownNPCRoomCheckFailureReason.RoomCheckStartedInASolidTile;
WorldGen.canSpawn = false;
return false;
}
WorldGen.roomCheckFailureReason = TownNPCRoomCheckFailureReason.None;
WorldGen.CheckRoom(x, y);
if (!WorldGen.canSpawn)
return false;
if (WorldGen.numRoomTiles < 60)
{
WorldGen.roomCheckFailureReason = TownNPCRoomCheckFailureReason.RoomIsTooSmall;
WorldGen.canSpawn = false;
return false;
}
return WorldGen.canSpawn;
}
public static void CheckRoom(int x, int y)
{
if (!WorldGen.canSpawn)
return;
if (x < 10 || y < 10 || x >= Main.maxTilesX - 10 || y >= WorldGen.lastMaxTilesY - 10)
{
WorldGen.roomCheckFailureReason = TownNPCRoomCheckFailureReason.TooCloseToWorldEdge;
WorldGen.canSpawn = false;
}
else
{
for (int index = 0; index < WorldGen.numRoomTiles; ++index)
{
if (WorldGen.roomX[index] == x && WorldGen.roomY[index] == y)
return;
}
WorldGen.roomX[WorldGen.numRoomTiles] = x;
WorldGen.roomY[WorldGen.numRoomTiles] = y;
bool flag1 = false;
for (int index = 0; index < WorldGen.roomCeilingsCount; ++index)
{
if (WorldGen.roomCeilingX[index] == x)
{
flag1 = true;
if (WorldGen.roomCeilingY[index] > y)
{
WorldGen.roomCeilingY[index] = y;
break;
}
break;
}
}
if (!flag1)
{
WorldGen.roomCeilingX[WorldGen.roomCeilingsCount] = x;
WorldGen.roomCeilingY[WorldGen.roomCeilingsCount] = y;
++WorldGen.roomCeilingsCount;
}
++WorldGen.numRoomTiles;
if (WorldGen.numRoomTiles >= WorldGen.maxRoomTiles)
{
WorldGen.roomCheckFailureReason = TownNPCRoomCheckFailureReason.RoomIsTooBig;
WorldGen.canSpawn = false;
}
else
{
if (Main.tile[x, y].nactive())
{
WorldGen.houseTile[(int) Main.tile[x, y].type] = true;
if (Main.tileSolid[(int) Main.tile[x, y].type] || Main.tile[x, y].type == (ushort) 11 && (Main.tile[x, y].frameX == (short) 0 || Main.tile[x, y].frameX == (short) 54 || Main.tile[x, y].frameX == (short) 72 || Main.tile[x, y].frameX == (short) 126) || Main.tile[x, y].type == (ushort) 389 || Main.tile[x, y].type == (ushort) 386 && (Main.tile[x, y].frameX < (short) 36 && Main.tile[x, y].frameY == (short) 18 || Main.tile[x, y].frameX >= (short) 36 && Main.tile[x, y].frameY == (short) 0))
return;
}
if (x < WorldGen.roomX1)
WorldGen.roomX1 = x;
if (x > WorldGen.roomX2)
WorldGen.roomX2 = x;
if (y < WorldGen.roomY1)
WorldGen.roomY1 = y;
if (y > WorldGen.roomY2)
WorldGen.roomY2 = y;
bool flag2 = false;
bool flag3 = false;
for (int index = -2; index < 3; ++index)
{
if (Main.wallHouse[(int) Main.tile[x + index, y].wall])
flag2 = true;
if (Main.tile[x + index, y].nactive() && (Main.tileSolid[(int) Main.tile[x + index, y].type] || TileID.Sets.HousingWalls[(int) Main.tile[x + index, y].type]))
flag2 = true;
if (Main.wallHouse[(int) Main.tile[x, y + index].wall])
flag3 = true;
if (Main.tile[x, y + index].nactive() && (Main.tileSolid[(int) Main.tile[x, y + index].type] || TileID.Sets.HousingWalls[(int) Main.tile[x, y + index].type]))
flag3 = true;
}
if (!flag2 || !flag3)
{
WorldGen.roomCheckFailureReason = TownNPCRoomCheckFailureReason.HoleInWallIsTooBig;
WorldGen.canSpawn = false;
}
else
{
for (int x1 = x - 1; x1 < x + 2; ++x1)
{
for (int y1 = y - 1; y1 < y + 2; ++y1)
{
if ((x1 != x || y1 != y) && WorldGen.canSpawn)
WorldGen.CheckRoom(x1, y1);
}
}
}
}
}
}
public static void dropMeteor()
{
bool flag = true;
if (Main.netMode == 1)
return;
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active)
{
flag = false;
break;
}
}
int num1 = 0;
int num2 = (int) (400.0 * (double) (Main.maxTilesX / 4200));
for (int index1 = 5; index1 < Main.maxTilesX - 5; ++index1)
{
for (int index2 = 5; (double) index2 < Main.worldSurface; ++index2)
{
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 37)
{
++num1;
if (num1 > num2)
return;
}
}
}
float num3 = 600f;
while (!flag)
{
float num4 = (float) Main.maxTilesX * 0.08f;
int i1 = Main.rand.Next(150, Main.maxTilesX - 150);
while ((double) i1 > (double) Main.spawnTileX - (double) num4 && (double) i1 < (double) Main.spawnTileX + (double) num4)
i1 = Main.rand.Next(150, Main.maxTilesX - 150);
for (int j1 = (int) (Main.worldSurface * 0.3); j1 < Main.maxTilesY; ++j1)
{
if (Main.tile[i1, j1].active() && Main.tileSolid[(int) Main.tile[i1, j1].type])
{
int num5 = 0;
int num6 = 15;
for (int i2 = i1 - num6; i2 < i1 + num6; ++i2)
{
for (int j2 = j1 - num6; j2 < j1 + num6; ++j2)
{
if (WorldGen.SolidTile(i2, j2))
{
++num5;
if (Main.tile[i2, j2].type == (ushort) 189 || Main.tile[i2, j2].type == (ushort) 202)
num5 -= 100;
}
else if (Main.tile[i2, j2].liquid > (byte) 0)
--num5;
}
}
if ((double) num5 >= (double) num3)
{
flag = WorldGen.meteor(i1, j1);
if (!flag)
break;
break;
}
num3 -= 0.5f;
break;
}
}
if ((double) num3 < 100.0)
break;
}
}
public static bool meteor(int i, int j)
{
if (i < 50 || i > Main.maxTilesX - 50 || j < 50 || j > Main.maxTilesY - 50)
return false;
int num1 = 35;
Microsoft.Xna.Framework.Rectangle rectangle1 = new Microsoft.Xna.Framework.Rectangle((i - num1) * 16, (j - num1) * 16, num1 * 2 * 16, num1 * 2 * 16);
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active)
{
Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle((int) ((double) Main.player[index].position.X + (double) (Main.player[index].width / 2) - (double) (NPC.sWidth / 2) - (double) NPC.safeRangeX), (int) ((double) Main.player[index].position.Y + (double) (Main.player[index].height / 2) - (double) (NPC.sHeight / 2) - (double) NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
if (rectangle1.Intersects(rectangle2))
return false;
}
}
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active)
{
Microsoft.Xna.Framework.Rectangle rectangle3 = new Microsoft.Xna.Framework.Rectangle((int) Main.npc[index].position.X, (int) Main.npc[index].position.Y, Main.npc[index].width, Main.npc[index].height);
if (rectangle1.Intersects(rectangle3))
return false;
}
}
for (int index1 = i - num1; index1 < i + num1; ++index1)
{
for (int index2 = j - num1; index2 < j + num1; ++index2)
{
if (Main.tile[index1, index2].active() && TileID.Sets.BasicChest[(int) Main.tile[index1, index2].type])
return false;
}
}
WorldGen.stopDrops = true;
int num2 = WorldGen.genRand.Next(17, 23);
for (int index3 = i - num2; index3 < i + num2; ++index3)
{
for (int index4 = j - num2; index4 < j + num2; ++index4)
{
if (index4 > j + Main.rand.Next(-2, 3) - 5)
{
double num3 = (double) Math.Abs(i - index3);
float num4 = (float) Math.Abs(j - index4);
if (Math.Sqrt(num3 * num3 + (double) num4 * (double) num4) < (double) num2 * 0.9 + (double) Main.rand.Next(-4, 5))
{
if (!Main.tileSolid[(int) Main.tile[index3, index4].type])
Main.tile[index3, index4].active(false);
Main.tile[index3, index4].type = (ushort) 37;
}
}
}
}
int num5 = WorldGen.genRand.Next(8, 14);
for (int index5 = i - num5; index5 < i + num5; ++index5)
{
for (int index6 = j - num5; index6 < j + num5; ++index6)
{
if (index6 > j + Main.rand.Next(-2, 3) - 4)
{
double num6 = (double) Math.Abs(i - index5);
float num7 = (float) Math.Abs(j - index6);
if (Math.Sqrt(num6 * num6 + (double) num7 * (double) num7) < (double) num5 * 0.8 + (double) Main.rand.Next(-3, 4))
Main.tile[index5, index6].active(false);
}
}
}
int num8 = WorldGen.genRand.Next(25, 35);
for (int i1 = i - num8; i1 < i + num8; ++i1)
{
for (int j1 = j - num8; j1 < j + num8; ++j1)
{
double num9 = (double) Math.Abs(i - i1);
float num10 = (float) Math.Abs(j - j1);
if (Math.Sqrt(num9 * num9 + (double) num10 * (double) num10) < (double) num8 * 0.7)
{
if (Main.tile[i1, j1].type == (ushort) 5 || Main.tile[i1, j1].type == (ushort) 32 || Main.tile[i1, j1].type == (ushort) 352)
WorldGen.KillTile(i1, j1);
Main.tile[i1, j1].liquid = (byte) 0;
}
if (Main.tile[i1, j1].type == (ushort) 37)
{
if (!WorldGen.SolidTile(i1 - 1, j1) && !WorldGen.SolidTile(i1 + 1, j1) && !WorldGen.SolidTile(i1, j1 - 1) && !WorldGen.SolidTile(i1, j1 + 1))
Main.tile[i1, j1].active(false);
else if ((Main.tile[i1, j1].halfBrick() || Main.tile[i1 - 1, j1].topSlope()) && !WorldGen.SolidTile(i1, j1 + 1))
Main.tile[i1, j1].active(false);
}
WorldGen.SquareTileFrame(i1, j1);
WorldGen.SquareWallFrame(i1, j1);
}
}
int num11 = WorldGen.genRand.Next(23, 32);
for (int i2 = i - num11; i2 < i + num11; ++i2)
{
for (int j2 = j - num11; j2 < j + num11; ++j2)
{
if (j2 > j + WorldGen.genRand.Next(-3, 4) - 3 && Main.tile[i2, j2].active() && Main.rand.Next(10) == 0)
{
double num12 = (double) Math.Abs(i - i2);
float num13 = (float) Math.Abs(j - j2);
if (Math.Sqrt(num12 * num12 + (double) num13 * (double) num13) < (double) num11 * 0.8)
{
if (Main.tile[i2, j2].type == (ushort) 5 || Main.tile[i2, j2].type == (ushort) 32 || Main.tile[i2, j2].type == (ushort) 352)
WorldGen.KillTile(i2, j2);
Main.tile[i2, j2].type = (ushort) 37;
WorldGen.SquareTileFrame(i2, j2);
}
}
}
}
int num14 = WorldGen.genRand.Next(30, 38);
for (int i3 = i - num14; i3 < i + num14; ++i3)
{
for (int j3 = j - num14; j3 < j + num14; ++j3)
{
if (j3 > j + WorldGen.genRand.Next(-2, 3) && Main.tile[i3, j3].active() && Main.rand.Next(20) == 0)
{
double num15 = (double) Math.Abs(i - i3);
float num16 = (float) Math.Abs(j - j3);
if (Math.Sqrt(num15 * num15 + (double) num16 * (double) num16) < (double) num14 * 0.85)
{
if (Main.tile[i3, j3].type == (ushort) 5 || Main.tile[i3, j3].type == (ushort) 32 || Main.tile[i3, j3].type == (ushort) 352)
WorldGen.KillTile(i3, j3);
Main.tile[i3, j3].type = (ushort) 37;
WorldGen.SquareTileFrame(i3, j3);
}
}
}
}
WorldGen.stopDrops = false;
if (Main.netMode == 0)
Main.NewText(Lang.gen[59].Value, (byte) 50, B: (byte) 130);
else if (Main.netMode == 2)
NetMessage.BroadcastChatMessage(NetworkText.FromKey(Lang.gen[59].Key), new Color(50, (int) byte.MaxValue, 130));
if (Main.netMode != 1)
NetMessage.SendTileSquare(-1, i, j, 40);
return true;
}
public static void setWorldSize()
{
Main.bottomWorld = (float) (Main.maxTilesY * 16);
Main.rightWorld = (float) (Main.maxTilesX * 16);
Main.maxSectionsX = Main.maxTilesX / 200;
Main.maxSectionsY = Main.maxTilesY / 150;
}
public static void worldGenCallBack(object threadContext)
{
Main.PlaySound(10);
WorldGen.clearWorld();
WorldGen.generateWorld(Main.ActiveWorldFileData.Seed, threadContext as GenerationProgress);
WorldFile.saveWorld(Main.ActiveWorldFileData.IsCloudSave, true);
if (Main.menuMode == 10 || Main.menuMode == 888)
Main.menuMode = 6;
Main.PlaySound(10);
}
public static void CreateNewWorld(GenerationProgress progress = null)
{
Main.rand = new UnifiedRandom(Main.ActiveWorldFileData.Seed);
ThreadPool.QueueUserWorkItem(new WaitCallback(WorldGen.worldGenCallBack), (object) progress);
}
public static void SaveAndQuitCallBack(object threadContext)
{
try
{
Main.PlaySound(34, Style: 0);
Main.PlaySound(35, Style: 0);
}
catch
{
}
if (Main.netMode == 0)
WorldFile.CacheSaveTime();
Main.invasionProgress = 0;
Main.invasionProgressDisplayLeft = 0;
Main.invasionProgressAlpha = 0.0f;
Main.menuMode = 10;
Main.gameMenu = true;
Main.StopTrackedSounds();
CaptureInterface.ResetFocus();
Main.ActivePlayerFileData.StopPlayTimer();
Player.SavePlayer(Main.ActivePlayerFileData);
if (Main.netMode == 0)
{
WorldFile.saveWorld();
Main.PlaySound(10);
}
else
{
Netplay.disconnect = true;
Main.netMode = 0;
}
Main.fastForwardTime = false;
Main.UpdateSundial();
Main.menuMode = 0;
if (threadContext == null)
return;
((Action) threadContext)();
}
public static void SaveAndQuit(Action callback = null)
{
Main.PlaySound(11);
ThreadPool.QueueUserWorkItem(new WaitCallback(WorldGen.SaveAndQuitCallBack), (object) callback);
}
public static void playWorldCallBack(object threadContext)
{
if (Main.rand == null)
Main.rand = new UnifiedRandom((int) DateTime.Now.Ticks);
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (index != Main.myPlayer)
Main.player[index].active = false;
}
WorldGen.noMapUpdate = true;
WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave);
if (WorldGen.loadFailed || !WorldGen.loadSuccess)
{
WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave);
if (WorldGen.loadFailed || !WorldGen.loadSuccess)
{
bool isCloudSave = Main.ActiveWorldFileData.IsCloudSave;
WorldGen.worldBackup = FileUtilities.Exists(Main.worldPathName + ".bak", isCloudSave);
if (!Main.dedServ)
{
if (WorldGen.worldBackup)
{
Main.menuMode = 200;
return;
}
Main.menuMode = 201;
return;
}
if (WorldGen.worldBackup)
{
FileUtilities.Copy(Main.worldPathName, Main.worldPathName + ".bad", isCloudSave);
FileUtilities.Copy(Main.worldPathName + ".bak", Main.worldPathName, isCloudSave);
FileUtilities.Delete(Main.worldPathName + ".bak", isCloudSave);
WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave);
if (WorldGen.loadFailed || !WorldGen.loadSuccess)
{
WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave);
if (WorldGen.loadFailed || !WorldGen.loadSuccess)
{
FileUtilities.Copy(Main.worldPathName, Main.worldPathName + ".bak", isCloudSave);
FileUtilities.Copy(Main.worldPathName + ".bad", Main.worldPathName, isCloudSave);
FileUtilities.Delete(Main.worldPathName + ".bad", isCloudSave);
Console.WriteLine(Language.GetTextValue("Error.LoadFailed"));
return;
}
}
}
else
{
Console.WriteLine(Language.GetTextValue("Error.LoadFailedNoBackup"));
return;
}
}
}
if (Main.mapEnabled)
Main.Map.Load();
if (Main.netMode != 2)
Main.sectionManager.SetAllFramesLoaded();
while (Main.loadMapLock)
{
float num = (float) Main.loadMapLastX / (float) Main.maxTilesX;
Main.statusText = Lang.gen[68].Value + " " + (object) (int) ((double) num * 100.0 + 1.0) + "%";
Thread.Sleep(0);
if (!Main.mapEnabled)
break;
}
if (Main.gameMenu)
Main.gameMenu = false;
if (Main.netMode == 0 && Main.anglerWhoFinishedToday.Contains(Main.player[Main.myPlayer].name))
Main.anglerQuestFinished = true;
Main.player[Main.myPlayer].Spawn();
Main.player[Main.myPlayer].Update(Main.myPlayer);
Main.ActivePlayerFileData.StartPlayTimer();
WorldGen._lastSeed = Main.ActiveWorldFileData.Seed;
Player.Hooks.EnterWorld(Main.myPlayer);
WorldFile.SetOngoingToTemps();
Main.PlaySound(11);
Main.resetClouds = true;
WorldGen.noMapUpdate = false;
}
public static void playWorld() => ThreadPool.QueueUserWorkItem(new WaitCallback(WorldGen.playWorldCallBack), (object) 1);
public static void saveAndPlayCallBack(object threadContext) => WorldFile.saveWorld();
public static void saveAndPlay() => ThreadPool.QueueUserWorkItem(new WaitCallback(WorldGen.saveAndPlayCallBack), (object) 1);
public static void saveToonWhilePlayingCallBack(object threadContext) => Player.SavePlayer(Main.ActivePlayerFileData);
public static void saveToonWhilePlaying() => ThreadPool.QueueUserWorkItem(new WaitCallback(WorldGen.saveToonWhilePlayingCallBack), (object) 1);
public static void serverLoadWorldCallBack(object threadContext)
{
Main.rand = new UnifiedRandom((int) DateTime.Now.Ticks);
WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave);
if (WorldGen.loadFailed || !WorldGen.loadSuccess)
{
WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave);
if (WorldGen.loadFailed || !WorldGen.loadSuccess)
{
bool isCloudSave = Main.ActiveWorldFileData.IsCloudSave;
WorldGen.worldBackup = FileUtilities.Exists(Main.worldPathName + ".bak", isCloudSave);
if (!Main.dedServ)
{
if (WorldGen.worldBackup)
{
Main.menuMode = 200;
return;
}
Main.menuMode = 201;
return;
}
if (WorldGen.worldBackup)
{
FileUtilities.Copy(Main.worldPathName + ".bak", Main.worldPathName, isCloudSave);
FileUtilities.Delete(Main.worldPathName + ".bak", isCloudSave);
WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave);
if (WorldGen.loadFailed || !WorldGen.loadSuccess)
{
WorldFile.loadWorld(Main.ActiveWorldFileData.IsCloudSave);
if (WorldGen.loadFailed || !WorldGen.loadSuccess)
{
Console.WriteLine(Language.GetTextValue("Error.LoadFailed"));
return;
}
}
}
else
{
Console.WriteLine(Language.GetTextValue("Error.LoadFailedNoBackup"));
return;
}
}
}
WorldGen._lastSeed = Main.ActiveWorldFileData.Seed;
Main.PlaySound(10);
Netplay.StartServer();
WorldFile.SetOngoingToTemps();
WorldGen.Hooks.WorldLoaded();
}
public static void serverLoadWorld() => ThreadPool.QueueUserWorkItem(new WaitCallback(WorldGen.serverLoadWorldCallBack), (object) 1);
public static void clearWorld()
{
WorldGen.TownManager = new TownRoomManager();
WorldGen.Hooks.ClearWorld();
TileEntity.Clear();
Main.checkXMas();
Main.checkHalloween();
if (Main.mapReady)
{
for (int index = 0; index < WorldGen.lastMaxTilesX; ++index)
{
double num = (double) index / (double) WorldGen.lastMaxTilesX;
Main.statusText = Lang.gen[65].Value;
}
Main.Map.Clear();
}
NPC.MoonLordCountdown = 0;
Main.pumpkinMoon = false;
Main.clearMap = true;
Main.mapTime = 0;
Main.updateMap = false;
Main.mapReady = false;
Main.refreshMap = false;
Main.eclipse = false;
Main.slimeRain = false;
Main.slimeRainTime = 0.0;
Main.sundialCooldown = 0;
Main.fastForwardTime = false;
BirthdayParty.WorldClear();
Sandstorm.WorldClear();
Main.UpdateSundial();
Main.wof = -1;
NPC.waveKills = 0.0f;
WorldGen.spawnHardBoss = 0;
WorldGen.totalSolid2 = 0;
WorldGen.totalGood2 = 0;
WorldGen.totalEvil2 = 0;
WorldGen.totalBlood2 = 0;
WorldGen.totalSolid = 0;
WorldGen.totalGood = 0;
WorldGen.totalEvil = 0;
WorldGen.totalBlood = 0;
WorldFile.ResetTemps();
Main.maxRaining = 0.0f;
WorldGen.totalX = 0;
WorldGen.totalD = 0;
WorldGen.tEvil = (byte) 0;
WorldGen.tBlood = (byte) 0;
WorldGen.tGood = (byte) 0;
WorldGen.spawnEye = false;
WorldGen.prioritizedTownNPC = 0;
WorldGen.shadowOrbCount = 0;
WorldGen.altarCount = 0;
WorldGen.oreTier1 = -1;
WorldGen.oreTier2 = -1;
WorldGen.oreTier3 = -1;
Main.cloudBGActive = 0.0f;
Main.raining = false;
Main.hardMode = false;
Main.helpText = 0;
Main.BartenderHelpTextIndex = 0;
Main.dungeonX = 0;
Main.dungeonY = 0;
NPC.downedBoss1 = false;
NPC.downedBoss2 = false;
NPC.downedBoss3 = false;
NPC.downedQueenBee = false;
NPC.downedSlimeKing = false;
NPC.downedMechBossAny = false;
NPC.downedMechBoss1 = false;
NPC.downedMechBoss2 = false;
NPC.downedMechBoss3 = false;
NPC.downedFishron = false;
NPC.downedAncientCultist = false;
NPC.downedMoonlord = false;
NPC.downedHalloweenKing = false;
NPC.downedHalloweenTree = false;
NPC.downedChristmasIceQueen = false;
NPC.downedChristmasSantank = false;
NPC.downedChristmasTree = false;
NPC.downedPlantBoss = false;
NPC.downedGolemBoss = false;
NPC.savedStylist = false;
NPC.savedGoblin = false;
NPC.savedWizard = false;
NPC.savedMech = false;
NPC.savedTaxCollector = false;
NPC.savedAngler = false;
NPC.savedBartender = false;
NPC.downedGoblins = false;
NPC.downedClown = false;
NPC.downedFrost = false;
NPC.downedPirates = false;
NPC.downedMartians = false;
int num1;
NPC.LunarApocalypseIsUp = (num1 = 0) != 0;
NPC.downedTowerStardust = num1 != 0;
NPC.downedTowerNebula = num1 != 0;
NPC.downedTowerVortex = num1 != 0;
NPC.downedTowerSolar = num1 != 0;
int num2;
NPC.TowerActiveStardust = (num2 = 0) != 0;
NPC.TowerActiveNebula = num2 != 0;
NPC.TowerActiveVortex = num2 != 0;
NPC.TowerActiveSolar = num2 != 0;
DD2Event.ResetProgressEntirely();
NPC.ClearFoundActiveNPCs();
WorldGen.shadowOrbSmashed = false;
WorldGen.spawnMeteor = false;
WorldGen.stopDrops = false;
Main.invasionDelay = 0;
Main.invasionType = 0;
Main.invasionSize = 0;
Main.invasionWarn = 0;
Main.invasionX = 0.0;
Main.invasionSizeStart = 0;
Main.treeX[0] = Main.maxTilesX;
Main.treeX[1] = Main.maxTilesX;
Main.treeX[2] = Main.maxTilesX;
Main.treeStyle[0] = 0;
Main.treeStyle[1] = 0;
Main.treeStyle[2] = 0;
Main.treeStyle[3] = 0;
WorldGen.noLiquidCheck = false;
Liquid.numLiquid = 0;
LiquidBuffer.numLiquidBuffer = 0;
if (Main.netMode == 1 || WorldGen.lastMaxTilesX > Main.maxTilesX || WorldGen.lastMaxTilesY > Main.maxTilesY)
{
for (int index1 = 0; index1 < WorldGen.lastMaxTilesX; ++index1)
{
float num3 = (float) index1 / (float) WorldGen.lastMaxTilesX;
Main.statusText = Lang.gen[46].Value + " " + (object) (int) ((double) num3 * 100.0 + 1.0) + "%";
for (int index2 = 0; index2 < WorldGen.lastMaxTilesY; ++index2)
Main.tile[index1, index2] = (Tile) null;
}
}
WorldGen.lastMaxTilesX = Main.maxTilesX;
WorldGen.lastMaxTilesY = Main.maxTilesY;
if (Main.netMode != 2)
Main.sectionManager = new WorldSections(Main.maxTilesX / 200, Main.maxTilesY / 150);
if (Main.netMode != 1)
{
for (int index3 = 0; index3 < Main.maxTilesX; ++index3)
{
float num4 = (float) index3 / (float) Main.maxTilesX;
Main.statusText = Lang.gen[47].Value + " " + (object) (int) ((double) num4 * 100.0 + 1.0) + "%";
for (int index4 = 0; index4 < Main.maxTilesY; ++index4)
{
if (Main.tile[index3, index4] == null)
Main.tile[index3, index4] = new Tile();
else
Main.tile[index3, index4].ClearEverything();
}
}
}
CombatText.clearAll();
for (int index = 0; index < 6000; ++index)
{
Main.dust[index] = new Dust();
Main.dust[index].dustIndex = index;
}
for (int index = 0; index < 500; ++index)
Main.gore[index] = new Gore();
for (int index = 0; index < 400; ++index)
{
Main.item[index] = new Item();
Main.itemLockoutTime[index] = 0;
}
for (int index = 0; index < 200; ++index)
Main.npc[index] = new NPC();
for (int index = 0; index < 1000; ++index)
Main.projectile[index] = new Projectile();
for (int index = 0; index < 1000; ++index)
Main.chest[index] = (Chest) null;
for (int index = 0; index < 1000; ++index)
Main.sign[index] = (Sign) null;
for (int index = 0; index < Liquid.resLiquid; ++index)
Main.liquid[index] = new Liquid();
for (int index = 0; index < 10000; ++index)
Main.liquidBuffer[index] = new LiquidBuffer();
WorldGen.setWorldSize();
WorldGen.worldCleared = true;
}
public static void setBG(int bg, int style)
{
switch (bg)
{
case 0:
WorldGen.treeBG = style;
Main.treeMntBG[0] = 7;
Main.treeMntBG[1] = 8;
switch (style)
{
case 1:
Main.treeBG[0] = 50;
Main.treeBG[1] = 51;
Main.treeBG[2] = 52;
return;
case 2:
Main.treeBG[0] = 53;
Main.treeBG[1] = 54;
Main.treeBG[2] = 55;
return;
case 3:
Main.treeMntBG[1] = 90;
Main.treeBG[0] = 91;
Main.treeBG[1] = -1;
Main.treeBG[2] = 92;
return;
case 4:
Main.treeMntBG[0] = 93;
Main.treeMntBG[1] = 94;
Main.treeBG[0] = -1;
Main.treeBG[1] = -1;
Main.treeBG[2] = -1;
return;
case 5:
Main.treeMntBG[0] = 93;
Main.treeMntBG[1] = 94;
Main.treeBG[0] = -1;
Main.treeBG[1] = -1;
Main.treeBG[2] = 55;
return;
case 6:
Main.treeMntBG[0] = 171;
Main.treeMntBG[1] = 172;
Main.treeBG[0] = 173;
Main.treeBG[1] = -1;
Main.treeBG[2] = -1;
return;
case 7:
Main.treeMntBG[0] = 176;
Main.treeMntBG[1] = 177;
Main.treeBG[0] = 178;
Main.treeBG[1] = -1;
Main.treeBG[2] = -1;
return;
case 8:
Main.treeMntBG[0] = 179;
Main.treeMntBG[1] = 180;
Main.treeBG[0] = 184;
Main.treeBG[1] = -1;
Main.treeBG[2] = -1;
return;
case 31:
Main.treeMntBG[1] = 90;
Main.treeBG[0] = 91;
Main.treeBG[1] = -1;
Main.treeBG[2] = 11;
return;
case 51:
Main.treeMntBG[0] = 93;
Main.treeMntBG[1] = 94;
Main.treeBG[0] = -1;
Main.treeBG[1] = -1;
Main.treeBG[2] = 11;
return;
case 71:
Main.treeMntBG[0] = 176;
Main.treeMntBG[1] = 177;
Main.treeBG[0] = 178;
Main.treeBG[1] = -1;
Main.treeBG[2] = 11;
return;
case 72:
Main.treeMntBG[0] = 176;
Main.treeMntBG[1] = 177;
Main.treeBG[0] = 178;
Main.treeBG[1] = -1;
Main.treeBG[2] = 52;
return;
case 73:
Main.treeMntBG[0] = 176;
Main.treeMntBG[1] = 177;
Main.treeBG[0] = 178;
Main.treeBG[1] = -1;
Main.treeBG[2] = 55;
return;
default:
Main.treeBG[0] = 9;
Main.treeBG[1] = 10;
Main.treeBG[2] = 11;
return;
}
case 1:
WorldGen.corruptBG = style;
if (style == 1)
{
Main.corruptBG[0] = 56;
Main.corruptBG[1] = 57;
Main.corruptBG[2] = 58;
break;
}
Main.corruptBG[0] = 12;
Main.corruptBG[1] = 13;
Main.corruptBG[2] = 14;
break;
case 2:
WorldGen.jungleBG = style;
if (style == 1)
{
Main.jungleBG[0] = 59;
Main.jungleBG[1] = 60;
Main.jungleBG[2] = 61;
break;
}
Main.jungleBG[0] = 15;
Main.jungleBG[1] = 16;
Main.jungleBG[2] = 17;
break;
case 3:
WorldGen.snowBG = style;
Main.snowMntBG[0] = 35;
Main.snowMntBG[1] = 36;
switch (style)
{
case 1:
Main.snowBG[0] = 97;
Main.snowBG[1] = 96;
Main.snowBG[2] = 95;
return;
case 2:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 99;
Main.snowBG[0] = -1;
Main.snowBG[1] = -1;
Main.snowBG[2] = -1;
return;
case 3:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 100;
Main.snowBG[0] = -1;
Main.snowBG[1] = -1;
Main.snowBG[2] = -1;
return;
case 4:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 101;
Main.snowBG[0] = -1;
Main.snowBG[1] = -1;
Main.snowBG[2] = -1;
return;
case 21:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 99;
Main.snowBG[0] = 95;
Main.snowBG[1] = 96;
Main.snowBG[2] = 97;
return;
case 22:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 99;
Main.snowBG[0] = 37;
Main.snowBG[1] = 38;
Main.snowBG[2] = 39;
return;
case 31:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 100;
Main.snowBG[0] = 95;
Main.snowBG[1] = 96;
Main.snowBG[2] = 97;
return;
case 32:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 100;
Main.snowBG[0] = 37;
Main.snowBG[1] = 38;
Main.snowBG[2] = 39;
return;
case 41:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 101;
Main.snowBG[0] = 95;
Main.snowBG[1] = 96;
Main.snowBG[2] = 97;
return;
case 42:
Main.snowMntBG[0] = 98;
Main.snowMntBG[1] = 101;
Main.snowBG[0] = 37;
Main.snowBG[1] = 38;
Main.snowBG[2] = 39;
return;
default:
Main.snowBG[0] = 37;
Main.snowBG[1] = 38;
Main.snowBG[2] = 39;
return;
}
case 4:
WorldGen.hallowBG = style;
if (style == 1)
{
Main.hallowBG[0] = 102;
Main.hallowBG[1] = 103;
Main.hallowBG[2] = 104;
break;
}
Main.hallowBG[0] = 29;
Main.hallowBG[1] = 30;
Main.hallowBG[2] = 31;
break;
case 5:
WorldGen.crimsonBG = style;
if (style == 1)
{
Main.crimsonBG[0] = 105;
Main.crimsonBG[1] = 106;
Main.crimsonBG[2] = 107;
}
if (style == 2)
{
Main.crimsonBG[0] = 174;
Main.crimsonBG[1] = -1;
Main.crimsonBG[2] = 175;
break;
}
Main.crimsonBG[0] = 43;
Main.crimsonBG[1] = 44;
Main.crimsonBG[2] = 45;
break;
case 6:
WorldGen.desertBG = style;
if (style == 1)
{
Main.desertBG[0] = 108;
Main.desertBG[1] = 109;
break;
}
Main.desertBG[0] = 21;
Main.desertBG[1] = 20;
break;
case 7:
WorldGen.oceanBG = style;
if (style == 1)
{
Main.oceanBG = 110;
break;
}
if (style == 2)
{
Main.oceanBG = 111;
break;
}
Main.oceanBG = 28;
break;
}
}
public static void RandomizeWeather()
{
if (Main.cloudLimit < 10)
return;
Main.numClouds = WorldGen.genRand.Next(10, Main.cloudLimit);
Main.windSpeed = 0.0f;
while ((double) Main.windSpeed == 0.0)
{
Main.windSpeed = (float) WorldGen.genRand.Next(-100, 101) * 0.01f;
Main.windSpeedSet = Main.windSpeed;
}
Cloud.resetClouds();
}
public static void RandomizeMoonState() => Main.moonType = WorldGen.genRand.Next(Main.maxMoons);
public static void RandomizeBackgrounds()
{
WorldGen.treeBG = WorldGen.genRand.Next(9);
if ((WorldGen.treeBG == 1 || WorldGen.treeBG == 2) && WorldGen.genRand.Next(2) == 0)
WorldGen.treeBG = WorldGen.genRand.Next(7);
if (WorldGen.treeBG == 0)
WorldGen.treeBG = WorldGen.genRand.Next(7);
if (WorldGen.treeBG == 3 && WorldGen.genRand.Next(3) == 0)
WorldGen.treeBG = 31;
if (WorldGen.treeBG == 5 && WorldGen.genRand.Next(2) == 0)
WorldGen.treeBG = 51;
if (WorldGen.treeBG == 7 && WorldGen.genRand.Next(4) == 0)
WorldGen.treeBG = WorldGen.genRand.Next(71, 74);
WorldGen.setBG(0, WorldGen.treeBG);
WorldGen.setBG(1, WorldGen.genRand.Next(2));
WorldGen.setBG(2, WorldGen.genRand.Next(2));
WorldGen.snowBG = WorldGen.genRand.Next(6);
if (WorldGen.snowBG == 2 && WorldGen.genRand.Next(2) == 0)
WorldGen.snowBG = WorldGen.genRand.Next(2) != 0 ? 22 : 21;
if (WorldGen.snowBG == 3 && WorldGen.genRand.Next(2) == 0)
WorldGen.snowBG = WorldGen.genRand.Next(2) != 0 ? 32 : 31;
if (WorldGen.snowBG == 4 && WorldGen.genRand.Next(2) == 0)
WorldGen.snowBG = WorldGen.genRand.Next(2) != 0 ? 42 : 41;
WorldGen.setBG(3, WorldGen.snowBG);
WorldGen.setBG(4, WorldGen.genRand.Next(2));
WorldGen.setBG(5, WorldGen.genRand.Next(3));
WorldGen.setBG(6, WorldGen.genRand.Next(2));
WorldGen.setBG(7, WorldGen.genRand.Next(3));
}
public static void RandomizeTreeStyle()
{
switch (Main.maxTilesX)
{
case 4200:
Main.treeX[0] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.5 - (double) Main.maxTilesX * 0.25), (int) ((double) Main.maxTilesX * 0.5 + (double) Main.maxTilesX * 0.25));
Main.treeStyle[0] = WorldGen.genRand.Next(6);
Main.treeStyle[1] = WorldGen.genRand.Next(6);
while (Main.treeStyle[1] == Main.treeStyle[0])
Main.treeStyle[1] = WorldGen.genRand.Next(6);
Main.treeX[1] = Main.maxTilesX;
Main.treeX[2] = Main.maxTilesX;
break;
case 6400:
Main.treeX[0] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.334 - (double) Main.maxTilesX * 0.200000002980232), (int) ((double) Main.maxTilesX * 0.334 + (double) Main.maxTilesX * 0.200000002980232));
Main.treeX[1] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.667 - (double) Main.maxTilesX * 0.200000002980232), (int) ((double) Main.maxTilesX * 0.667 + (double) Main.maxTilesX * 0.200000002980232));
Main.treeStyle[0] = WorldGen.genRand.Next(6);
Main.treeStyle[1] = WorldGen.genRand.Next(6);
Main.treeStyle[2] = WorldGen.genRand.Next(6);
while (Main.treeStyle[1] == Main.treeStyle[0])
Main.treeStyle[1] = WorldGen.genRand.Next(6);
while (Main.treeStyle[2] == Main.treeStyle[0] || Main.treeStyle[2] == Main.treeStyle[1])
Main.treeStyle[2] = WorldGen.genRand.Next(6);
Main.treeX[2] = Main.maxTilesX;
break;
default:
Main.treeX[0] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.25 - (double) Main.maxTilesX * 0.150000005960464), (int) ((double) Main.maxTilesX * 0.25 + (double) Main.maxTilesX * 0.150000005960464));
Main.treeX[1] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.5 - (double) Main.maxTilesX * 0.150000005960464), (int) ((double) Main.maxTilesX * 0.5 + (double) Main.maxTilesX * 0.150000005960464));
Main.treeX[2] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.75 - (double) Main.maxTilesX * 0.150000005960464), (int) ((double) Main.maxTilesX * 0.75 + (double) Main.maxTilesX * 0.150000005960464));
Main.treeStyle[0] = WorldGen.genRand.Next(6);
Main.treeStyle[1] = WorldGen.genRand.Next(6);
Main.treeStyle[2] = WorldGen.genRand.Next(6);
Main.treeStyle[3] = WorldGen.genRand.Next(6);
while (Main.treeStyle[1] == Main.treeStyle[0])
Main.treeStyle[1] = WorldGen.genRand.Next(6);
while (Main.treeStyle[2] == Main.treeStyle[0] || Main.treeStyle[2] == Main.treeStyle[1])
Main.treeStyle[2] = WorldGen.genRand.Next(6);
while (Main.treeStyle[3] == Main.treeStyle[0] || Main.treeStyle[3] == Main.treeStyle[1] || Main.treeStyle[3] == Main.treeStyle[2])
Main.treeStyle[3] = WorldGen.genRand.Next(6);
break;
}
}
public static void RandomizeCaveBackgrounds()
{
int maxValue = 8;
switch (Main.maxTilesX)
{
case 4200:
Main.caveBackX[0] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.5 - (double) Main.maxTilesX * 0.25), (int) ((double) Main.maxTilesX * 0.5 + (double) Main.maxTilesX * 0.25));
Main.caveBackX[1] = Main.maxTilesX;
Main.caveBackX[2] = Main.maxTilesX;
Main.caveBackStyle[0] = WorldGen.genRand.Next(maxValue);
Main.caveBackStyle[1] = WorldGen.genRand.Next(maxValue);
while (Main.caveBackStyle[1] == Main.caveBackStyle[0])
Main.caveBackStyle[1] = WorldGen.genRand.Next(maxValue);
break;
case 6400:
Main.caveBackX[0] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.334 - (double) Main.maxTilesX * 0.200000002980232), (int) ((double) Main.maxTilesX * 0.334 + (double) Main.maxTilesX * 0.200000002980232));
Main.caveBackX[1] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.667 - (double) Main.maxTilesX * 0.200000002980232), (int) ((double) Main.maxTilesX * 0.667 + (double) Main.maxTilesX * 0.200000002980232));
Main.caveBackX[2] = Main.maxTilesX;
Main.caveBackStyle[0] = WorldGen.genRand.Next(maxValue);
Main.caveBackStyle[1] = WorldGen.genRand.Next(maxValue);
Main.caveBackStyle[2] = WorldGen.genRand.Next(maxValue);
while (Main.caveBackStyle[1] == Main.caveBackStyle[0])
Main.caveBackStyle[1] = WorldGen.genRand.Next(maxValue);
while (Main.caveBackStyle[2] == Main.caveBackStyle[0] || Main.caveBackStyle[2] == Main.caveBackStyle[1])
Main.caveBackStyle[2] = WorldGen.genRand.Next(maxValue);
break;
default:
Main.caveBackX[0] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.25 - (double) Main.maxTilesX * 0.150000005960464), (int) ((double) Main.maxTilesX * 0.25 + (double) Main.maxTilesX * 0.150000005960464));
Main.caveBackX[1] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.5 - (double) Main.maxTilesX * 0.150000005960464), (int) ((double) Main.maxTilesX * 0.5 + (double) Main.maxTilesX * 0.150000005960464));
Main.caveBackX[2] = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.75 - (double) Main.maxTilesX * 0.150000005960464), (int) ((double) Main.maxTilesX * 0.75 + (double) Main.maxTilesX * 0.150000005960464));
Main.caveBackStyle[0] = WorldGen.genRand.Next(maxValue);
Main.caveBackStyle[1] = WorldGen.genRand.Next(maxValue);
Main.caveBackStyle[2] = WorldGen.genRand.Next(maxValue);
Main.caveBackStyle[3] = WorldGen.genRand.Next(maxValue);
while (Main.caveBackStyle[1] == Main.caveBackStyle[0])
Main.caveBackStyle[1] = WorldGen.genRand.Next(maxValue);
while (Main.caveBackStyle[2] == Main.caveBackStyle[0] || Main.caveBackStyle[2] == Main.caveBackStyle[1])
Main.caveBackStyle[2] = WorldGen.genRand.Next(maxValue);
while (Main.caveBackStyle[3] == Main.caveBackStyle[0] || Main.caveBackStyle[3] == Main.caveBackStyle[1] || Main.caveBackStyle[3] == Main.caveBackStyle[2])
Main.caveBackStyle[3] = WorldGen.genRand.Next(maxValue);
break;
}
Main.iceBackStyle = WorldGen.genRand.Next(4);
Main.hellBackStyle = WorldGen.genRand.Next(3);
Main.jungleBackStyle = WorldGen.genRand.Next(2);
}
private static void ResetGenerator()
{
WorldGen.mudWall = false;
WorldGen.hellChest = 0;
WorldGen.JungleX = 0;
WorldGen.numMCaves = 0;
WorldGen.numIslandHouses = 0;
WorldGen.houseCount = 0;
WorldGen.dEnteranceX = 0;
WorldGen.numDRooms = 0;
WorldGen.numDDoors = 0;
WorldGen.numDPlats = 0;
WorldGen.numJChests = 0;
WorldGen.JungleItemCount = 0;
}
public static bool mayanTrap(int x2, int y2)
{
int num1 = 1;
if (WorldGen.genRand.Next(3) == 0)
num1 = 0;
int i1 = x2;
int j1 = y2;
while (!WorldGen.SolidTile(i1, j1))
{
++j1;
if (j1 >= Main.maxTilesY - 300)
return false;
}
if (Main.tile[i1, j1].type == (ushort) 232)
return false;
int j2 = j1 - 1;
if (Main.tile[i1, j2].liquid > (byte) 0 && Main.tile[i1, j2].lava())
return false;
if (num1 == -1 && WorldGen.genRand.Next(20) == 0)
num1 = 2;
else if (num1 == -1)
num1 = WorldGen.genRand.Next(2);
if (Main.tile[i1, j2].nactive() || Main.tile[i1 - 1, j2].nactive() || Main.tile[i1 + 1, j2].nactive() || Main.tile[i1, j2 - 1].nactive() || Main.tile[i1 - 1, j2 - 1].nactive() || Main.tile[i1 + 1, j2 - 1].nactive() || Main.tile[i1, j2 - 2].nactive() || Main.tile[i1 - 1, j2 - 2].nactive() || Main.tile[i1 + 1, j2 - 2].nactive() || Main.tile[i1, j2 + 1].type == (ushort) 48 || Main.tile[i1, j2 + 1].type == (ushort) 232)
return false;
switch (num1)
{
case 0:
int i2 = i1;
int j3 = j2 - WorldGen.genRand.Next(3);
while (!WorldGen.SolidTile(i2, j3))
--i2;
int i3 = i2;
int i4 = i1;
while (!WorldGen.SolidTile(i4, j3))
++i4;
int i5 = i4;
int num2 = i1 - i3;
int num3 = i5 - i1;
bool flag1 = false;
bool flag2 = false;
if (num2 > 5 && num2 < 50)
flag1 = true;
if (num3 > 5 && num3 < 50)
flag2 = true;
if (flag1 && !WorldGen.SolidTile(i3, j3 + 1))
flag1 = false;
if (flag2 && !WorldGen.SolidTile(i5, j3 + 1))
flag2 = false;
if (flag1 && (Main.tile[i3, j3].type == (ushort) 10 || Main.tile[i3, j3].type == (ushort) 48 || Main.tile[i3, j3 + 1].type == (ushort) 10 || Main.tile[i3, j3 + 1].type == (ushort) 48))
flag1 = false;
if (flag2 && (Main.tile[i5, j3].type == (ushort) 10 || Main.tile[i5, j3].type == (ushort) 48 || Main.tile[i5, j3 + 1].type == (ushort) 10 || Main.tile[i5, j3 + 1].type == (ushort) 48))
flag2 = false;
int num4;
int i6;
if (flag1 & flag2)
{
num4 = 1;
i6 = i3;
if (WorldGen.genRand.Next(2) == 0)
{
i6 = i5;
num4 = -1;
}
}
else if (flag2)
{
i6 = i5;
num4 = -1;
}
else
{
if (!flag1)
return false;
i6 = i3;
num4 = 1;
}
if (Main.tile[i6, j3].wall != (byte) 87 || Main.tile[i6, j3].type == (ushort) 190 || Main.tile[i6, j3].type == (ushort) 135 || Main.tile[i6, j3].type == (ushort) 137 || Main.tile[i6, j3].type == (ushort) 232)
return false;
WorldGen.PlaceTile(i1, j2, 135, true, true, style: 6);
WorldGen.KillTile(i6, j3);
int num5 = WorldGen.genRand.Next(3);
if (Main.tile[i1, j2].wire())
num5 = 0;
if (Main.tile[i1, j2].wire2())
num5 = 1;
if (Main.tile[i1, j2].wire3())
num5 = 2;
int num6 = Math.Abs(i6 - i1);
int style1 = 1;
if (num6 < 10 && WorldGen.genRand.Next(3) != 0)
style1 = 2;
WorldGen.PlaceTile(i6, j3, 137, true, true, style: style1);
if (num4 == 1)
Main.tile[i6, j3].frameX += (short) 18;
int num7 = WorldGen.genRand.Next(5);
int j4 = j3;
while (num7 > 0)
{
--num7;
--j4;
if (WorldGen.SolidTile(i6, j4) && WorldGen.SolidTile(i6 - num4, j4) && !WorldGen.SolidTile(i6 + num4, j4))
{
WorldGen.PlaceTile(i6, j4, 137, true, true, style: style1);
if (num4 == 1)
Main.tile[i6, j4].frameX += (short) 18;
switch (num5)
{
case 0:
Main.tile[i6, j4].wire(true);
continue;
case 1:
Main.tile[i6, j4].wire2(true);
continue;
case 2:
Main.tile[i6, j4].wire3(true);
continue;
default:
continue;
}
}
else
break;
}
int index1 = i1;
int index2 = j2;
while (index1 != i6 || index2 != j3)
{
switch (num5)
{
case 0:
Main.tile[index1, index2].wire(true);
break;
case 1:
Main.tile[index1, index2].wire2(true);
break;
case 2:
Main.tile[index1, index2].wire3(true);
break;
}
if (index1 > i6)
--index1;
if (index1 < i6)
++index1;
switch (num5)
{
case 0:
Main.tile[index1, index2].wire(true);
break;
case 1:
Main.tile[index1, index2].wire2(true);
break;
case 2:
Main.tile[index1, index2].wire3(true);
break;
}
if (index2 > j3)
--index2;
if (index2 < j3)
++index2;
switch (num5)
{
case 0:
Main.tile[index1, index2].wire(true);
continue;
case 1:
Main.tile[index1, index2].wire2(true);
continue;
case 2:
Main.tile[index1, index2].wire3(true);
continue;
default:
continue;
}
}
return true;
case 1:
int i7 = i1;
int j5 = j2;
while (!WorldGen.SolidTile(i7, j5))
{
--j5;
if ((double) j5 < Main.worldSurface)
return false;
}
int num8 = Math.Abs(j5 - j2);
if (num8 < 3)
return false;
int num9 = WorldGen.genRand.Next(3);
if (Main.tile[i1, j2].wire())
num9 = 0;
if (Main.tile[i1, j2].wire2())
num9 = 1;
if (Main.tile[i1, j2].wire3())
num9 = 2;
int style2 = 3;
if (num8 < 16 && WorldGen.genRand.Next(3) != 0)
style2 = 4;
if (Main.tile[i7, j5].type == (ushort) 135 || Main.tile[i7, j5].type == (ushort) 137 || Main.tile[i7, j5].type == (ushort) 232 || Main.tile[i7, j5].wall != (byte) 87)
return false;
WorldGen.PlaceTile(i1, j2, 135, true, true, style: 6);
WorldGen.PlaceTile(i7, j5, 137, true, true, style: style2);
for (int index3 = 0; index3 < 2; ++index3)
{
int num10 = WorldGen.genRand.Next(1, 5);
int i8 = i7;
int num11 = -1;
if (index3 == 1)
num11 = 1;
while (num10 > 0)
{
--num10;
i8 += num11;
if (WorldGen.SolidTile(i8, j5 - 1) && !WorldGen.SolidTile(i8, j5 + 1))
{
WorldGen.PlaceTile(i8, j5, 137, true, true, style: style2);
switch (num9)
{
case 0:
Main.tile[i8, j5].wire(true);
continue;
case 1:
Main.tile[i8, j5].wire2(true);
continue;
case 2:
Main.tile[i8, j5].wire3(true);
continue;
default:
continue;
}
}
else
break;
}
}
int index4 = i1;
int index5 = j2;
while (index4 != i7 || index5 != j5)
{
switch (num9)
{
case 0:
Main.tile[index4, index5].wire(true);
break;
case 1:
Main.tile[index4, index5].wire2(true);
break;
case 2:
Main.tile[index4, index5].wire3(true);
break;
}
if (index4 > i7)
--index4;
if (index4 < i7)
++index4;
switch (num9)
{
case 0:
Main.tile[index4, index5].wire(true);
break;
case 1:
Main.tile[index4, index5].wire2(true);
break;
case 2:
Main.tile[index4, index5].wire3(true);
break;
}
if (index5 > j5)
--index5;
if (index5 < j5)
++index5;
switch (num9)
{
case 0:
Main.tile[index4, index5].wire(true);
continue;
case 1:
Main.tile[index4, index5].wire2(true);
continue;
case 2:
Main.tile[index4, index5].wire3(true);
continue;
default:
continue;
}
}
return true;
default:
return false;
}
}
public static bool placeTrap(int x2, int y2, int type = -1)
{
int index1 = x2;
int j1 = y2;
bool flag1 = false;
bool flag2 = false;
while (!WorldGen.SolidTile(index1, j1))
{
++j1;
if (j1 >= Main.maxTilesY - 300)
flag2 = true;
}
int index2 = j1 - 1;
if (Main.tile[index1, index2].wall == (byte) 87)
return false;
if (Main.tile[index1, index2].liquid > (byte) 0 && Main.tile[index1, index2].lava())
flag1 = true;
if (type == -1 && WorldGen.genRand.Next(20) == 0)
type = 2;
else if (type == -1 && index2 > WorldGen.lavaLine + 30 && WorldGen.genRand.Next(6) != 0)
type = 3;
else if (type == -1)
type = WorldGen.genRand.Next(2);
if (!WorldGen.InWorld(index1, index2, 3) || flag1 && type != 3 || flag2 && type != 3 || Main.tile[index1, index2].nactive() || Main.tile[index1 - 1, index2].nactive() || Main.tile[index1 + 1, index2].nactive() || Main.tile[index1, index2 - 1].nactive() || Main.tile[index1 - 1, index2 - 1].nactive() || Main.tile[index1 + 1, index2 - 1].nactive() || Main.tile[index1, index2 - 2].nactive() || Main.tile[index1 - 1, index2 - 2].nactive() || Main.tile[index1 + 1, index2 - 2].nactive() || Main.tile[index1, index2 + 1].type == (ushort) 48 || Main.tile[index1, index2 + 1].type == (ushort) 232)
return false;
if (type == 1)
{
for (int index3 = index1 - 3; index3 <= index1 + 3; ++index3)
{
for (int index4 = index2 - 3; index4 <= index2 + 3; ++index4)
{
if (Main.tile[index3, index4].type == (ushort) 147 || Main.tile[index3, index4].type == (ushort) 161)
type = 0;
}
}
}
if (type == 0)
{
int i1 = index1;
int j2 = index2 - WorldGen.genRand.Next(3);
while (!WorldGen.SolidTile(i1, j2))
--i1;
int i2 = i1;
int i3 = index1;
while (!WorldGen.SolidTile(i3, j2))
++i3;
int i4 = i3;
int num1 = index1 - i2;
int num2 = i4 - index1;
bool flag3 = false;
bool flag4 = false;
if (num1 > 5 && num1 < 50)
flag3 = true;
if (num2 > 5 && num2 < 50)
flag4 = true;
if (flag3 && !WorldGen.SolidTile(i2, j2 + 1))
flag3 = false;
if (flag4 && !WorldGen.SolidTile(i4, j2 + 1))
flag4 = false;
if (flag3 && (Main.tile[i2, j2].type == (ushort) 10 || Main.tile[i2, j2].type == (ushort) 48 || Main.tile[i2, j2 + 1].type == (ushort) 10 || Main.tile[i2, j2 + 1].type == (ushort) 48))
flag3 = false;
if (flag4 && (Main.tile[i4, j2].type == (ushort) 10 || Main.tile[i4, j2].type == (ushort) 48 || Main.tile[i4, j2 + 1].type == (ushort) 10 || Main.tile[i4, j2 + 1].type == (ushort) 48))
flag4 = false;
int num3;
int i5;
if (flag3 & flag4)
{
num3 = 1;
i5 = i2;
if (WorldGen.genRand.Next(2) == 0)
{
i5 = i4;
num3 = -1;
}
}
else if (flag4)
{
i5 = i4;
num3 = -1;
}
else if (flag3)
{
i5 = i2;
num3 = 1;
}
else
{
++WorldGen.trapDiag[type, 0];
return false;
}
if (Main.tile[i5, j2].type == (ushort) 190)
{
++WorldGen.trapDiag[type, 0];
return false;
}
if (Main.tile[index1, index2].wall > (byte) 0)
WorldGen.PlaceTile(index1, index2, 135, true, true, style: 2);
else
WorldGen.PlaceTile(index1, index2, 135, true, true, style: WorldGen.genRand.Next(2, 4));
WorldGen.KillTile(i5, j2);
WorldGen.PlaceTile(i5, j2, 137, true, true);
if (num3 == 1)
Main.tile[i5, j2].frameX += (short) 18;
int index5 = index1;
int index6 = index2;
while (index5 != i5 || index6 != j2)
{
Main.tile[index5, index6].wire(true);
if (index5 > i5)
--index5;
if (index5 < i5)
++index5;
Main.tile[index5, index6].wire(true);
if (index6 > j2)
--index6;
if (index6 < j2)
++index6;
Main.tile[index5, index6].wire(true);
}
++WorldGen.trapDiag[type, 1];
return true;
}
if (type == 1)
{
int num4 = index1;
int num5 = index2 - 8;
int i6 = num4 + WorldGen.genRand.Next(-1, 2);
bool flag5 = true;
while (flag5)
{
bool flag6 = true;
int num6 = 0;
for (int i7 = i6 - 2; i7 <= i6 + 3; ++i7)
{
for (int j3 = num5; j3 <= num5 + 3; ++j3)
{
if (!WorldGen.SolidTile(i7, j3))
flag6 = false;
if (Main.tile[i7, j3].active() && (Main.tile[i7, j3].type == (ushort) 0 || Main.tile[i7, j3].type == (ushort) 1 || Main.tile[i7, j3].type == (ushort) 59))
++num6;
}
}
--num5;
if ((double) num5 < Main.worldSurface)
{
++WorldGen.trapDiag[type, 0];
return false;
}
if (flag6 && num6 > 2)
flag5 = false;
}
if (index2 - num5 <= 5 || index2 - num5 >= 40)
{
++WorldGen.trapDiag[type, 0];
return false;
}
for (int i8 = i6; i8 <= i6 + 1; ++i8)
{
for (int j4 = num5; j4 <= index2; ++j4)
{
if (WorldGen.SolidTile(i8, j4))
WorldGen.KillTile(i8, j4);
}
}
for (int i9 = i6 - 2; i9 <= i6 + 3; ++i9)
{
for (int j5 = num5 - 2; j5 <= num5 + 3; ++j5)
{
if (WorldGen.SolidTile(i9, j5))
Main.tile[i9, j5].type = (ushort) 1;
}
}
WorldGen.PlaceTile(index1, index2, 135, true, true, style: WorldGen.genRand.Next(2, 4));
WorldGen.PlaceTile(i6, num5 + 2, 130, true);
WorldGen.PlaceTile(i6 + 1, num5 + 2, 130, true);
WorldGen.PlaceTile(i6 + 1, num5 + 1, 138, true);
int index7 = num5 + 2;
Main.tile[i6, index7].wire(true);
Main.tile[i6 + 1, index7].wire(true);
int j6 = index7 + 1;
WorldGen.PlaceTile(i6, j6, 130, true);
WorldGen.PlaceTile(i6 + 1, j6, 130, true);
Main.tile[i6, j6].wire(true);
Main.tile[i6 + 1, j6].wire(true);
WorldGen.PlaceTile(i6, j6 + 1, 130, true);
WorldGen.PlaceTile(i6 + 1, j6 + 1, 130, true);
Main.tile[i6, j6 + 1].wire(true);
Main.tile[i6 + 1, j6 + 1].wire(true);
int index8 = index1;
int index9 = index2;
while (index8 != i6 || index9 != j6)
{
Main.tile[index8, index9].wire(true);
if (index8 > i6)
--index8;
if (index8 < i6)
++index8;
Main.tile[index8, index9].wire(true);
if (index9 > j6)
--index9;
if (index9 < j6)
++index9;
Main.tile[index8, index9].wire(true);
}
++WorldGen.trapDiag[type, 1];
return true;
}
if (type == 2)
{
int num = WorldGen.genRand.Next(4, 7);
int i10 = index1 + WorldGen.genRand.Next(-1, 2);
int j7 = index2;
for (int index10 = 0; index10 < num; ++index10)
{
++j7;
if (!WorldGen.SolidTile(i10, j7))
{
++WorldGen.trapDiag[type, 0];
return false;
}
}
for (int i11 = i10 - 2; i11 <= i10 + 2; ++i11)
{
for (int j8 = j7 - 2; j8 <= j7 + 2; ++j8)
{
if (!WorldGen.SolidTile(i11, j8))
return false;
}
}
WorldGen.KillTile(i10, j7);
Main.tile[i10, j7].active(true);
Main.tile[i10, j7].type = (ushort) 141;
Main.tile[i10, j7].frameX = (short) 0;
Main.tile[i10, j7].frameY = (short) (18 * WorldGen.genRand.Next(2));
WorldGen.PlaceTile(index1, index2, 135, true, true, style: WorldGen.genRand.Next(2, 4));
int index11 = index1;
int index12 = index2;
while (index11 != i10 || index12 != j7)
{
Main.tile[index11, index12].wire(true);
if (index11 > i10)
--index11;
if (index11 < i10)
++index11;
Main.tile[index11, index12].wire(true);
if (index12 > j7)
--index12;
if (index12 < j7)
++index12;
Main.tile[index11, index12].wire(true);
}
++WorldGen.trapDiag[type, 1];
}
else if (type == 3)
{
int num7 = 0;
int num8 = 0;
for (int index13 = 0; index13 < 4; ++index13)
{
if (num7 < 2 && WorldGen.genRand.Next(5) == 0)
{
++num7;
}
else
{
int num9 = index1;
int j9 = index2;
bool flag7 = false;
int i12 = num8 != 0 ? num9 + WorldGen.genRand.Next(-15, 16) : num9 + WorldGen.genRand.Next(-1, 2);
int num10 = WorldGen.genRand.Next(3, 6 + (num8 > 0).ToInt() * 3);
for (int index14 = 0; index14 < num10; ++index14)
{
++j9;
if (!WorldGen.SolidTile(i12, j9))
{
++WorldGen.trapDiag[type, 0];
flag7 = true;
break;
}
}
if (!flag7)
{
int num11 = 2;
for (int i13 = i12 - num11; i13 <= i12 + num11; ++i13)
{
for (int j10 = j9 - num11; j10 <= j9 + num11; ++j10)
{
if (!WorldGen.SolidTile(i13, j10))
{
++WorldGen.trapDiag[type, 0];
flag7 = true;
break;
}
}
if (flag7)
break;
}
if (!flag7)
{
int num12 = 10;
for (int i14 = i12; i14 <= i12 + 1; ++i14)
{
int j11 = j9;
while (j11 > j9 - 20 && WorldGen.SolidTile(i14, j11))
--j11;
for (int j12 = j11 - num12; j12 <= j11; ++j12)
{
if (WorldGen.SolidTile(i14, j12))
{
++WorldGen.trapDiag[type, 0];
flag7 = true;
break;
}
}
if (flag7)
break;
}
if (!flag7)
{
WorldGen.KillTile(i12, j9);
WorldGen.KillTile(i12 + 1, j9);
int num13 = WorldGen.genRand.Next(2);
for (int index15 = 0; index15 < 2; ++index15)
{
Main.tile[i12 + index15, j9].active(true);
Main.tile[i12 + index15, j9].type = (ushort) 443;
Main.tile[i12 + index15, j9].frameX = (short) (18 * index15 + 36 * num13);
Main.tile[i12 + index15, j9].frameY = (short) 0;
}
WorldGen.PlaceTile(index1, index2, 135, true, true, style: WorldGen.genRand.Next(2, 4));
int index16 = index1;
int index17 = index2;
while (index16 != i12 || index17 != j9)
{
Main.tile[index16, index17].wire(true);
if (index16 > i12)
--index16;
if (index16 < i12)
++index16;
Main.tile[index16, index17].wire(true);
if (index17 > j9)
--index17;
if (index17 < j9)
++index17;
Main.tile[index16, index17].wire(true);
}
++num8;
++WorldGen.trapDiag[type, 1];
}
}
}
}
}
}
return false;
}
public static int countTiles(int x, int y, bool jungle = false, bool lavaOk = false)
{
WorldGen.numTileCount = 0;
WorldGen.lavaCount = 0;
WorldGen.iceCount = 0;
WorldGen.rockCount = 0;
WorldGen.nextCount(x, y, jungle, lavaOk);
return WorldGen.numTileCount;
}
public static void nextCount(int x, int y, bool jungle = false, bool lavaOk = false)
{
if (WorldGen.numTileCount >= WorldGen.maxTileCount)
return;
if (x <= 1 || x >= Main.maxTilesX - 1 || y <= 1 || y >= Main.maxTilesY - 1)
{
WorldGen.numTileCount = WorldGen.maxTileCount;
}
else
{
for (int index = 0; index < WorldGen.numTileCount; ++index)
{
if (WorldGen.countX[index] == x && WorldGen.countY[index] == y)
return;
}
if (!jungle)
{
if (Main.tile[x, y].wall != (byte) 0)
{
WorldGen.numTileCount = WorldGen.maxTileCount;
return;
}
if (!lavaOk)
{
if (Main.tile[x, y].lava() && Main.tile[x, y].liquid > (byte) 0)
{
++WorldGen.lavaCount;
WorldGen.numTileCount = WorldGen.maxTileCount;
return;
}
}
else if (Main.tile[x, y].lava() && Main.tile[x, y].liquid > (byte) 0)
++WorldGen.lavaCount;
}
if (Main.tile[x, y].active())
{
if (Main.tile[x, y].type == (ushort) 1)
++WorldGen.rockCount;
if (Main.tile[x, y].type == (ushort) 147 || Main.tile[x, y].type == (ushort) 161)
++WorldGen.iceCount;
}
if (WorldGen.SolidTile(x, y))
return;
WorldGen.countX[WorldGen.numTileCount] = x;
WorldGen.countY[WorldGen.numTileCount] = y;
++WorldGen.numTileCount;
WorldGen.nextCount(x - 1, y, jungle, lavaOk);
WorldGen.nextCount(x + 1, y, jungle, lavaOk);
WorldGen.nextCount(x, y - 1, jungle, lavaOk);
WorldGen.nextCount(x, y + 1, jungle, lavaOk);
}
}
public static int countDirtTiles(int x, int y)
{
WorldGen.numTileCount = 0;
WorldGen.nextDirtCount(x, y);
return WorldGen.numTileCount;
}
public static void nextDirtCount(int x, int y)
{
if (WorldGen.numTileCount >= WorldGen.maxTileCount)
return;
if (x <= 1 || x >= Main.maxTilesX - 1 || y <= 1 || y >= Main.maxTilesY - 1)
{
WorldGen.numTileCount = WorldGen.maxTileCount;
}
else
{
for (int index = 0; index < WorldGen.numTileCount; ++index)
{
if (WorldGen.countX[index] == x && WorldGen.countY[index] == y)
return;
}
if (Main.tile[x, y].active() && (Main.tile[x, y].type == (ushort) 147 || Main.tile[x, y].type == (ushort) 161))
WorldGen.numTileCount = WorldGen.maxTileCount;
else if (Main.tile[x, y].wall == (byte) 78 || Main.tile[x, y].wall == (byte) 83 || Main.tile[x, y].wall == (byte) 3)
{
WorldGen.numTileCount = WorldGen.maxTileCount;
}
else
{
if (WorldGen.SolidTile(x, y) || Main.tile[x, y].wall != (byte) 2 && Main.tile[x, y].wall != (byte) 59)
return;
WorldGen.countX[WorldGen.numTileCount] = x;
WorldGen.countY[WorldGen.numTileCount] = y;
++WorldGen.numTileCount;
WorldGen.nextDirtCount(x - 1, y);
WorldGen.nextDirtCount(x + 1, y);
WorldGen.nextDirtCount(x, y - 1);
WorldGen.nextDirtCount(x, y + 1);
WorldGen.nextDirtCount(x - 1, y - 1);
WorldGen.nextDirtCount(x - 1, y + 1);
WorldGen.nextDirtCount(x + 1, y - 1);
WorldGen.nextDirtCount(x + 1, y + 1);
WorldGen.nextDirtCount(x - 2, y);
WorldGen.nextDirtCount(x + 2, y);
}
}
}
public static bool InWorld(int x, int y, int fluff = 0) => x >= fluff && x < Main.maxTilesX - fluff && y >= fluff && y < Main.maxTilesY - fluff;
public static void gemCave(int x, int y)
{
WorldGen.countTiles(x, y);
for (int index = 0; index < 6; ++index)
WorldGen.gem[index] = false;
WorldGen.gem[WorldGen.genRand.Next(6)] = true;
for (int index = 0; index < 6; ++index)
{
if (WorldGen.genRand.Next(6) == 0)
WorldGen.gem[index] = true;
}
WorldGen.Spread.Gem(x, y);
}
public static int randGem()
{
int index = WorldGen.genRand.Next(6);
while (!WorldGen.gem[index])
index = WorldGen.genRand.Next(6);
return index;
}
public static ushort randGemTile()
{
if (WorldGen.genRand.Next(20) != 0)
return 1;
switch ((ushort) WorldGen.randGem())
{
case 0:
return 67;
case 1:
return 66;
case 2:
return 63;
case 3:
return 65;
case 4:
return 64;
default:
return 68;
}
}
public static void randMoss()
{
WorldGen.mossType[0] = WorldGen.genRand.Next(5);
WorldGen.mossType[1] = WorldGen.genRand.Next(5);
while (WorldGen.mossType[1] == WorldGen.mossType[0])
WorldGen.mossType[1] = WorldGen.genRand.Next(5);
WorldGen.mossType[2] = WorldGen.genRand.Next(5);
while (WorldGen.mossType[2] == WorldGen.mossType[0] || WorldGen.mossType[2] == WorldGen.mossType[1])
WorldGen.mossType[2] = WorldGen.genRand.Next(5);
}
public static void setMoss(int x, int y)
{
int index = (double) x >= (double) Main.maxTilesX * 0.334 ? ((double) x >= (double) Main.maxTilesX * 0.667 ? 2 : 1) : 0;
WorldGen.mossWall = (byte) (54 + WorldGen.mossType[index]);
WorldGen.mossTile = (byte) (179 + WorldGen.mossType[index]);
}
public static void tileCountAndDestroy()
{
for (int x = 10; x < Main.maxTilesX - 10; ++x)
{
for (int y = 10; y < Main.maxTilesY - 10; ++y)
{
if (Main.tile[x, y].active() && WorldGen.tileCounter(x, y) < WorldGen.tileCounterMax)
WorldGen.tileCounterKill();
}
}
}
public static int tileCounter(int x, int y)
{
WorldGen.tileCounterNum = 0;
WorldGen.tileCounterNext(x, y);
return WorldGen.tileCounterNum;
}
public static void tileCounterNext(int x, int y)
{
if (WorldGen.tileCounterNum >= WorldGen.tileCounterMax || x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5 || !Main.tile[x, y].active() || !Main.tileSolid[(int) Main.tile[x, y].type] || !TileID.Sets.CanBeClearedDuringGeneration[(int) Main.tile[x, y].type])
return;
for (int index = 0; index < WorldGen.tileCounterNum; ++index)
{
if (WorldGen.tileCounterX[index] == x && WorldGen.tileCounterY[index] == y)
return;
}
WorldGen.tileCounterX[WorldGen.tileCounterNum] = x;
WorldGen.tileCounterY[WorldGen.tileCounterNum] = y;
++WorldGen.tileCounterNum;
WorldGen.tileCounterNext(x - 1, y);
WorldGen.tileCounterNext(x + 1, y);
WorldGen.tileCounterNext(x, y - 1);
WorldGen.tileCounterNext(x, y + 1);
}
public static void tileCounterKill()
{
for (int index1 = 0; index1 < WorldGen.tileCounterNum; ++index1)
{
int index2 = WorldGen.tileCounterX[index1];
int index3 = WorldGen.tileCounterY[index1];
Main.tile[index2, index3].active(false);
}
}
private static void AddGenerationPass(string name, WorldGenLegacyMethod method) => WorldGen._generator.Append((GenPass) new PassLegacy(name, method));
private static void AddGenerationPass(string name, float weight, WorldGenLegacyMethod method) => WorldGen._generator.Append((GenPass) new PassLegacy(name, method, weight));
public static bool checkUnderground(int x, int y)
{
try
{
int num1 = 120;
int num2 = 80;
int num3 = 3;
if ((double) y > Main.worldSurface + (double) num2)
return true;
if ((double) y < Main.worldSurface / 2.0)
return false;
int num4 = y - num2;
int num5 = x - num1 / 2;
int num6 = 0;
if (num5 < 0)
num5 = 0;
if (num5 >= Main.maxTilesX - num1)
num5 = Main.maxTilesX - num1 - 1;
for (int i = num5; i < num5 + num1; ++i)
{
for (int j = num4; j < num4 + num3; ++j)
{
if (WorldGen.SolidTile(i, j) || Main.tile[x, y].wall > (byte) 0)
++num6;
}
}
if ((double) num6 >= (double) (num1 * num3) * 0.8)
return true;
}
catch
{
}
return false;
}
public static int GetNextJungleChestItem()
{
int num = 211;
switch (WorldGen.JungleItemCount % 4)
{
case 0:
num = 211;
break;
case 1:
num = 212;
break;
case 2:
num = 213;
break;
case 3:
num = 964;
break;
}
if (WorldGen.genRand.Next(50) == 0)
num = 753;
else if (WorldGen.genRand.Next(30) == 0)
num = 2292;
else if (WorldGen.genRand.Next(20) == 0)
num = 3017;
++WorldGen.JungleItemCount;
return num;
}
public static void generateWorld(int seed, GenerationProgress customProgressObject = null)
{
WorldGen._lastSeed = seed;
WorldGen._generator = new WorldGenerator(seed);
Main.rand = new UnifiedRandom(seed);
MicroBiome.ResetAll();
StructureMap structures = new StructureMap();
double worldSurface = 0.0;
WorldGen.worldSurfaceLow = 0.0;
double worldSurfaceHigh = 0.0;
double rockLayer = 0.0;
double rockLayerLow = 0.0;
double rockLayerHigh = 0.0;
int copper = 7;
int iron = 6;
int silver = 9;
int gold = 8;
int dungeonSide = 0;
ushort jungleHut = (ushort) WorldGen.genRand.Next(5);
int howFar = 0;
int[] PyrX = (int[]) null;
int[] PyrY = (int[]) null;
int numPyr = 0;
int[] snowMinX = new int[Main.maxTilesY];
int[] snowMaxX = new int[Main.maxTilesY];
int snowTop = 0;
int snowBottom = 0;
float dub2 = 0.0f;
int skyLakes = 1;
if (Main.maxTilesX > 8000)
++skyLakes;
if (Main.maxTilesX > 6000)
++skyLakes;
for (int index1 = 0; index1 < WorldGen.hellChestItem.Length; ++index1)
{
bool flag = true;
while (flag)
{
flag = false;
WorldGen.hellChestItem[index1] = WorldGen.genRand.Next(WorldGen.hellChestItem.Length);
for (int index2 = 0; index2 < index1; ++index2)
{
if (WorldGen.hellChestItem[index2] == WorldGen.hellChestItem[index1])
flag = true;
}
}
}
WorldGen.AddGenerationPass("Reset", (WorldGenLegacyMethod) (progress =>
{
Liquid.ReInit();
WorldGen.noTileActions = true;
progress.Message = "";
WorldGen.SetupStatueList();
WorldGen.RandomizeWeather();
Main.cloudAlpha = 0.0f;
Main.maxRaining = 0.0f;
WorldFile.tempMaxRain = 0.0f;
Main.raining = false;
WorldGen.heartCount = 0;
Main.checkXMas();
Main.checkHalloween();
WorldGen.gen = true;
WorldGen.ResetGenerator();
WorldGen.numLarva = 0;
int num = 86400;
Main.slimeRainTime = (double) -WorldGen.genRand.Next(num * 2, num * 3);
Main.cloudBGActive = (float) -WorldGen.genRand.Next(8640, 86400);
WorldGen.CopperTierOre = (ushort) 7;
WorldGen.IronTierOre = (ushort) 6;
WorldGen.SilverTierOre = (ushort) 9;
WorldGen.GoldTierOre = (ushort) 8;
WorldGen.copperBar = 20;
WorldGen.ironBar = 22;
WorldGen.silverBar = 21;
WorldGen.goldBar = 19;
if (WorldGen.genRand.Next(2) == 0)
{
copper = 166;
WorldGen.copperBar = 703;
WorldGen.CopperTierOre = (ushort) 166;
}
if (WorldGen.genRand.Next(2) == 0)
{
iron = 167;
WorldGen.ironBar = 704;
WorldGen.IronTierOre = (ushort) 167;
}
if (WorldGen.genRand.Next(2) == 0)
{
silver = 168;
WorldGen.silverBar = 705;
WorldGen.SilverTierOre = (ushort) 168;
}
if (WorldGen.genRand.Next(2) == 0)
{
gold = 169;
WorldGen.goldBar = 706;
WorldGen.GoldTierOre = (ushort) 169;
}
WorldGen.crimson = WorldGen.genRand.Next(2) == 0;
if (WorldGen.WorldGenParam_Evil == 0)
WorldGen.crimson = false;
if (WorldGen.WorldGenParam_Evil == 1)
WorldGen.crimson = true;
switch (jungleHut)
{
case 0:
jungleHut = (ushort) 119;
break;
case 1:
jungleHut = (ushort) 120;
break;
case 2:
jungleHut = (ushort) 158;
break;
case 3:
jungleHut = (ushort) 175;
break;
case 4:
jungleHut = (ushort) 45;
break;
}
Main.worldID = WorldGen.genRand.Next(int.MaxValue);
WorldGen.RandomizeTreeStyle();
WorldGen.RandomizeCaveBackgrounds();
WorldGen.RandomizeBackgrounds();
WorldGen.RandomizeMoonState();
dungeonSide = WorldGen.genRand.Next(2) == 0 ? -1 : 1;
}));
WorldGen.AddGenerationPass("Terrain", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[0].Value;
int num1 = 0;
int num2 = 0;
worldSurface = (double) Main.maxTilesY * 0.3;
worldSurface *= (double) WorldGen.genRand.Next(90, 110) * 0.005;
rockLayer = worldSurface + (double) Main.maxTilesY * 0.2;
rockLayer *= (double) WorldGen.genRand.Next(90, 110) * 0.01;
WorldGen.worldSurfaceLow = worldSurface;
worldSurfaceHigh = worldSurface;
rockLayerLow = rockLayer;
rockLayerHigh = rockLayer;
for (int index3 = 0; index3 < Main.maxTilesX; ++index3)
{
float num3 = (float) index3 / (float) Main.maxTilesX;
progress.Set(num3);
if (worldSurface < WorldGen.worldSurfaceLow)
WorldGen.worldSurfaceLow = worldSurface;
if (worldSurface > worldSurfaceHigh)
worldSurfaceHigh = worldSurface;
if (rockLayer < rockLayerLow)
rockLayerLow = rockLayer;
if (rockLayer > rockLayerHigh)
rockLayerHigh = rockLayer;
if (num2 <= 0)
{
num1 = WorldGen.genRand.Next(0, 5);
num2 = WorldGen.genRand.Next(5, 40);
if (num1 == 0)
num2 *= (int) ((double) WorldGen.genRand.Next(5, 30) * 0.2);
}
--num2;
if ((double) index3 > (double) Main.maxTilesX * 0.43 && (double) index3 < (double) Main.maxTilesX * 0.57 && num1 >= 3)
num1 = WorldGen.genRand.Next(3);
if ((double) index3 > (double) Main.maxTilesX * 0.47 && (double) index3 < (double) Main.maxTilesX * 0.53)
num1 = 0;
switch (num1)
{
case 0:
while (WorldGen.genRand.Next(0, 7) == 0)
worldSurface += (double) WorldGen.genRand.Next(-1, 2);
break;
case 1:
while (WorldGen.genRand.Next(0, 4) == 0)
--worldSurface;
while (WorldGen.genRand.Next(0, 10) == 0)
++worldSurface;
break;
case 2:
while (WorldGen.genRand.Next(0, 4) == 0)
++worldSurface;
while (WorldGen.genRand.Next(0, 10) == 0)
--worldSurface;
break;
case 3:
while (WorldGen.genRand.Next(0, 2) == 0)
--worldSurface;
while (WorldGen.genRand.Next(0, 6) == 0)
++worldSurface;
break;
case 4:
while (WorldGen.genRand.Next(0, 2) == 0)
++worldSurface;
while (WorldGen.genRand.Next(0, 5) == 0)
--worldSurface;
break;
}
if (worldSurface < (double) Main.maxTilesY * 0.17)
{
worldSurface = (double) Main.maxTilesY * 0.17;
num2 = 0;
}
else if (worldSurface > (double) Main.maxTilesY * 0.3)
{
worldSurface = (double) Main.maxTilesY * 0.3;
num2 = 0;
}
if ((index3 < 275 || index3 > Main.maxTilesX - 275) && worldSurface > (double) Main.maxTilesY * 0.25)
{
worldSurface = (double) Main.maxTilesY * 0.25;
num2 = 1;
}
while (WorldGen.genRand.Next(0, 3) == 0)
rockLayer += (double) WorldGen.genRand.Next(-2, 3);
if (rockLayer < worldSurface + (double) Main.maxTilesY * 0.05)
++rockLayer;
if (rockLayer > worldSurface + (double) Main.maxTilesY * 0.35)
--rockLayer;
for (int index4 = 0; (double) index4 < worldSurface; ++index4)
{
Main.tile[index3, index4].active(false);
Main.tile[index3, index4].frameX = (short) -1;
Main.tile[index3, index4].frameY = (short) -1;
}
for (int index5 = (int) worldSurface; index5 < Main.maxTilesY; ++index5)
{
if ((double) index5 < rockLayer)
{
Main.tile[index3, index5].active(true);
Main.tile[index3, index5].type = (ushort) 0;
Main.tile[index3, index5].frameX = (short) -1;
Main.tile[index3, index5].frameY = (short) -1;
}
else
{
Main.tile[index3, index5].active(true);
Main.tile[index3, index5].type = (ushort) 1;
Main.tile[index3, index5].frameX = (short) -1;
Main.tile[index3, index5].frameY = (short) -1;
}
}
}
Main.worldSurface = worldSurfaceHigh + 25.0;
Main.rockLayer = rockLayerHigh;
double num4 = (double) ((int) ((Main.rockLayer - Main.worldSurface) / 6.0) * 6);
Main.rockLayer = Main.worldSurface + num4;
WorldGen.waterLine = (int) (Main.rockLayer + (double) Main.maxTilesY) / 2;
WorldGen.waterLine += WorldGen.genRand.Next(-100, 20);
WorldGen.lavaLine = WorldGen.waterLine + WorldGen.genRand.Next(50, 80);
}));
WorldGen.AddGenerationPass("Tunnels", (WorldGenLegacyMethod) (progress =>
{
for (int index6 = 0; index6 < (int) ((double) Main.maxTilesX * 0.0015); ++index6)
{
int[] numArray1 = new int[10];
int[] numArray2 = new int[10];
int num = WorldGen.genRand.Next(450, Main.maxTilesX - 450);
while ((double) num > (double) Main.maxTilesX * 0.449999988079071 && (double) num < (double) Main.maxTilesX * 0.550000011920929)
num = WorldGen.genRand.Next(0, Main.maxTilesX);
int index7 = 0;
for (int index8 = 0; index8 < 10; ++index8)
{
int index9 = num % Main.maxTilesX;
while (!Main.tile[index9, index7].active())
++index7;
numArray1[index8] = index9;
numArray2[index8] = index7 - WorldGen.genRand.Next(11, 16);
num = index9 + WorldGen.genRand.Next(5, 11);
}
for (int index10 = 0; index10 < 10; ++index10)
{
WorldGen.TileRunner(numArray1[index10], numArray2[index10], (double) WorldGen.genRand.Next(5, 8), WorldGen.genRand.Next(6, 9), 0, true, -2f, -0.3f);
WorldGen.TileRunner(numArray1[index10], numArray2[index10], (double) WorldGen.genRand.Next(5, 8), WorldGen.genRand.Next(6, 9), 0, true, 2f, -0.3f);
}
}
}));
WorldGen.AddGenerationPass("Sand", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[1].Value;
int length = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.0008), (int) ((double) Main.maxTilesX * (1.0 / 400.0))) + 2;
PyrX = new int[length];
PyrY = new int[length];
for (int index11 = 0; index11 < length; ++index11)
{
int num5 = WorldGen.genRand.Next(Main.maxTilesX);
while ((double) num5 > (double) Main.maxTilesX * 0.400000005960464 && (double) num5 < (double) Main.maxTilesX * 0.600000023841858)
num5 = WorldGen.genRand.Next(Main.maxTilesX);
int num6 = WorldGen.genRand.Next(35, 90);
if (index11 == 1)
{
float num7 = (float) (Main.maxTilesX / 4200);
num6 += (int) ((double) WorldGen.genRand.Next(20, 40) * (double) num7);
}
if (WorldGen.genRand.Next(3) == 0)
num6 *= 2;
if (index11 == 1)
num6 *= 2;
int num8 = num5 - num6;
int num9 = WorldGen.genRand.Next(35, 90);
if (WorldGen.genRand.Next(3) == 0)
num9 *= 2;
if (index11 == 1)
num9 *= 2;
int num10 = num5 + num9;
if (num8 < 0)
num8 = 0;
if (num10 > Main.maxTilesX)
num10 = Main.maxTilesX;
switch (index11)
{
case 0:
num8 = 0;
num10 = WorldGen.genRand.Next(260, 300);
if (dungeonSide == 1)
{
num10 += 40;
break;
}
break;
case 2:
num8 = Main.maxTilesX - WorldGen.genRand.Next(260, 300);
num10 = Main.maxTilesX;
if (dungeonSide == -1)
{
num8 -= 40;
break;
}
break;
}
int num11 = WorldGen.genRand.Next(50, 100);
for (int index12 = num8; index12 < num10; ++index12)
{
if (WorldGen.genRand.Next(2) == 0)
{
num11 += WorldGen.genRand.Next(-1, 2);
if (num11 < 50)
num11 = 50;
if (num11 > 100)
num11 = 100;
}
for (int index13 = 0; (double) index13 < Main.worldSurface; ++index13)
{
if (Main.tile[index12, index13].active())
{
if (index12 == (num8 + num10) / 2 && WorldGen.genRand.Next(6) == 0)
{
PyrX[numPyr] = index12;
PyrY[numPyr] = index13;
++numPyr;
}
int num12 = num11;
if (index12 - num8 < num12)
num12 = index12 - num8;
if (num10 - index12 < num12)
num12 = num10 - index12;
int num13 = num12 + WorldGen.genRand.Next(5);
for (int index14 = index13; index14 < index13 + num13; ++index14)
{
if (index12 > num8 + WorldGen.genRand.Next(5) && index12 < num10 - WorldGen.genRand.Next(5))
Main.tile[index12, index14].type = (ushort) 53;
}
break;
}
}
}
}
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 8E-06); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) Main.worldSurface, (int) Main.rockLayer), (double) WorldGen.genRand.Next(15, 70), WorldGen.genRand.Next(20, 130), 53);
}));
WorldGen.AddGenerationPass("Mount Caves", (WorldGenLegacyMethod) (progress =>
{
WorldGen.numMCaves = 0;
progress.Message = Lang.gen[2].Value;
for (int index15 = 0; index15 < (int) ((double) Main.maxTilesX * 0.0008); ++index15)
{
int num = 0;
bool flag1 = false;
bool flag2 = false;
int i = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.25), (int) ((double) Main.maxTilesX * 0.75));
while (!flag2)
{
flag2 = true;
while (i > Main.maxTilesX / 2 - 100 && i < Main.maxTilesX / 2 + 100)
i = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.25), (int) ((double) Main.maxTilesX * 0.75));
for (int index16 = 0; index16 < WorldGen.numMCaves; ++index16)
{
if (i > WorldGen.mCaveX[index16] - 50 && i < WorldGen.mCaveX[index16] + 50)
{
++num;
flag2 = false;
break;
}
}
if (num >= 200)
{
flag1 = true;
break;
}
}
if (!flag1)
{
for (int j = 0; (double) j < Main.worldSurface; ++j)
{
if (Main.tile[i, j].active())
{
for (int index17 = i - 50; index17 < i + 50; ++index17)
{
for (int index18 = j - 25; index18 < j + 25; ++index18)
{
if (Main.tile[index17, index18].active() && (Main.tile[index17, index18].type == (ushort) 53 || Main.tile[index17, index18].type == (ushort) 151 || Main.tile[index17, index18].type == (ushort) 274))
flag1 = true;
}
}
if (!flag1)
{
WorldGen.Mountinater(i, j);
WorldGen.mCaveX[WorldGen.numMCaves] = i;
WorldGen.mCaveY[WorldGen.numMCaves] = j;
++WorldGen.numMCaves;
break;
}
}
}
}
}
}));
WorldGen.AddGenerationPass("Dirt Wall Backgrounds", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[3].Value;
for (int index19 = 1; index19 < Main.maxTilesX - 1; ++index19)
{
byte num14 = 2;
float num15 = (float) index19 / (float) Main.maxTilesX;
progress.Set(num15);
bool flag = false;
howFar += WorldGen.genRand.Next(-1, 2);
if (howFar < 0)
howFar = 0;
if (howFar > 10)
howFar = 10;
for (int index20 = 0; (double) index20 < Main.worldSurface + 10.0 && (double) index20 <= Main.worldSurface + (double) howFar; ++index20)
{
if (Main.tile[index19, index20].active())
num14 = Main.tile[index19, index20].type != (ushort) 147 ? (byte) 2 : (byte) 40;
if (flag && Main.tile[index19, index20].wall != (byte) 64)
Main.tile[index19, index20].wall = num14;
if (Main.tile[index19, index20].active() && Main.tile[index19 - 1, index20].active() && Main.tile[index19 + 1, index20].active() && Main.tile[index19, index20 + 1].active() && Main.tile[index19 - 1, index20 + 1].active() && Main.tile[index19 + 1, index20 + 1].active())
flag = true;
}
}
}));
WorldGen.AddGenerationPass("Rocks In Dirt", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[4].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.00015); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next(0, (int) WorldGen.worldSurfaceLow + 1), (double) WorldGen.genRand.Next(4, 15), WorldGen.genRand.Next(5, 40), 1);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0002); ++index)
{
int i = WorldGen.genRand.Next(0, Main.maxTilesX);
int j = WorldGen.genRand.Next((int) WorldGen.worldSurfaceLow, (int) worldSurfaceHigh + 1);
if (!Main.tile[i, j - 10].active())
j = WorldGen.genRand.Next((int) WorldGen.worldSurfaceLow, (int) worldSurfaceHigh + 1);
WorldGen.TileRunner(i, j, (double) WorldGen.genRand.Next(4, 10), WorldGen.genRand.Next(5, 30), 1);
}
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0045); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) worldSurfaceHigh, (int) rockLayerHigh + 1), (double) WorldGen.genRand.Next(2, 7), WorldGen.genRand.Next(2, 23), 1);
}));
WorldGen.AddGenerationPass("Dirt In Rocks", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[5].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.005); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerLow, Main.maxTilesY), (double) WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(2, 40), 0);
}));
WorldGen.AddGenerationPass("Clay", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[6].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 2E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next(0, (int) WorldGen.worldSurfaceLow), (double) WorldGen.genRand.Next(4, 14), WorldGen.genRand.Next(10, 50), 40);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 5E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) WorldGen.worldSurfaceLow, (int) worldSurfaceHigh + 1), (double) WorldGen.genRand.Next(8, 14), WorldGen.genRand.Next(15, 45), 40);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 2E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) worldSurfaceHigh, (int) rockLayerHigh + 1), (double) WorldGen.genRand.Next(8, 15), WorldGen.genRand.Next(5, 50), 40);
for (int index21 = 5; index21 < Main.maxTilesX - 5; ++index21)
{
for (int index22 = 1; (double) index22 < Main.worldSurface - 1.0; ++index22)
{
if (Main.tile[index21, index22].active())
{
for (int index23 = index22; index23 < index22 + 5; ++index23)
{
if (Main.tile[index21, index23].type == (ushort) 40)
Main.tile[index21, index23].type = (ushort) 0;
}
break;
}
}
}
}));
int i2;
WorldGen.AddGenerationPass("Small Holes", (WorldGenLegacyMethod) (progress =>
{
i2 = 0;
progress.Message = Lang.gen[7].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0015); ++index)
{
float num = (float) index / ((float) (Main.maxTilesX * Main.maxTilesY) * 0.0015f);
progress.Set(num);
int type = -1;
if (WorldGen.genRand.Next(5) == 0)
type = -2;
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) worldSurfaceHigh, Main.maxTilesY), (double) WorldGen.genRand.Next(2, 5), WorldGen.genRand.Next(2, 20), type);
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) worldSurfaceHigh, Main.maxTilesY), (double) WorldGen.genRand.Next(8, 15), WorldGen.genRand.Next(7, 30), type);
}
}));
WorldGen.AddGenerationPass("Dirt Layer Caves", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[8].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 3E-05); ++index)
{
float num = (float) index / ((float) (Main.maxTilesX * Main.maxTilesY) * 3E-05f);
progress.Set(num);
if (rockLayerHigh <= (double) Main.maxTilesY)
{
int type = -1;
if (WorldGen.genRand.Next(6) == 0)
type = -2;
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) WorldGen.worldSurfaceLow, (int) rockLayerHigh + 1), (double) WorldGen.genRand.Next(5, 15), WorldGen.genRand.Next(30, 200), type);
}
}
}));
WorldGen.AddGenerationPass("Rock Layer Caves", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[9].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.00013); ++index)
{
float num = (float) index / ((float) (Main.maxTilesX * Main.maxTilesY) * 0.00013f);
progress.Set(num);
if (rockLayerHigh <= (double) Main.maxTilesY)
{
int type = -1;
if (WorldGen.genRand.Next(10) == 0)
type = -2;
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerHigh, Main.maxTilesY), (double) WorldGen.genRand.Next(6, 20), WorldGen.genRand.Next(50, 300), type);
}
}
}));
WorldGen.AddGenerationPass("Surface Caves", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[10].Value;
for (int index = 0; index < (int) ((double) Main.maxTilesX * 0.002); ++index)
{
i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
while ((double) i2 > (double) Main.maxTilesX * 0.449999988079071 && (double) i2 < (double) Main.maxTilesX * 0.550000011920929)
i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
for (int j = 0; (double) j < worldSurfaceHigh; ++j)
{
if (Main.tile[i2, j].active())
{
WorldGen.TileRunner(i2, j, (double) WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(5, 50), -1, speedX: ((float) WorldGen.genRand.Next(-10, 11) * 0.1f), speedY: 1f);
break;
}
}
}
for (int index = 0; index < (int) ((double) Main.maxTilesX * 0.0007); ++index)
{
i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
while ((double) i2 > (double) Main.maxTilesX * 0.430000007152557 && (double) i2 < (double) Main.maxTilesX * 0.569999992847443)
i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
for (int j = 0; (double) j < worldSurfaceHigh; ++j)
{
if (Main.tile[i2, j].active())
{
WorldGen.TileRunner(i2, j, (double) WorldGen.genRand.Next(10, 15), WorldGen.genRand.Next(50, 130), -1, speedX: ((float) WorldGen.genRand.Next(-10, 11) * 0.1f), speedY: 2f);
break;
}
}
}
for (int index = 0; index < (int) ((double) Main.maxTilesX * 0.0003); ++index)
{
i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
while ((double) i2 > (double) Main.maxTilesX * 0.400000005960464 && (double) i2 < (double) Main.maxTilesX * 0.600000023841858)
i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
for (int j = 0; (double) j < worldSurfaceHigh; ++j)
{
if (Main.tile[i2, j].active())
{
WorldGen.TileRunner(i2, j, (double) WorldGen.genRand.Next(12, 25), WorldGen.genRand.Next(150, 500), -1, speedX: ((float) WorldGen.genRand.Next(-10, 11) * 0.1f), speedY: 4f);
WorldGen.TileRunner(i2, j, (double) WorldGen.genRand.Next(8, 17), WorldGen.genRand.Next(60, 200), -1, speedX: ((float) WorldGen.genRand.Next(-10, 11) * 0.1f), speedY: 2f);
WorldGen.TileRunner(i2, j, (double) WorldGen.genRand.Next(5, 13), WorldGen.genRand.Next(40, 170), -1, speedX: ((float) WorldGen.genRand.Next(-10, 11) * 0.1f), speedY: 2f);
break;
}
}
}
for (int index = 0; index < (int) ((double) Main.maxTilesX * 0.0004); ++index)
{
i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
while ((double) i2 > (double) Main.maxTilesX * 0.400000005960464 && (double) i2 < (double) Main.maxTilesX * 0.600000023841858)
i2 = WorldGen.genRand.Next(0, Main.maxTilesX);
for (int j = 0; (double) j < worldSurfaceHigh; ++j)
{
if (Main.tile[i2, j].active())
{
WorldGen.TileRunner(i2, j, (double) WorldGen.genRand.Next(7, 12), WorldGen.genRand.Next(150, 250), -1, speedY: 1f, noYChange: true);
break;
}
}
}
float num = (float) (Main.maxTilesX / 4200);
for (int index = 0; (double) index < 5.0 * (double) num; ++index)
{
try
{
WorldGen.Caverer(WorldGen.genRand.Next(100, Main.maxTilesX - 100), WorldGen.genRand.Next((int) Main.rockLayer, Main.maxTilesY - 400));
}
catch
{
}
}
}));
WorldGen.AddGenerationPass("Slush Check", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[56].Value;
snowTop = (int) Main.worldSurface;
int num16 = WorldGen.genRand.Next(Main.maxTilesX);
if (dungeonSide == 1)
{
while ((double) num16 < (double) Main.maxTilesX * 0.550000011920929 || (double) num16 > (double) Main.maxTilesX * 0.699999988079071)
num16 = WorldGen.genRand.Next(Main.maxTilesX);
}
else
{
while ((double) num16 < (double) Main.maxTilesX * 0.300000011920929 || (double) num16 > (double) Main.maxTilesX * 0.449999988079071)
num16 = WorldGen.genRand.Next(Main.maxTilesX);
}
int num17 = WorldGen.genRand.Next(50, 90);
float num18 = (float) (Main.maxTilesX / 4200);
int num19 = num17 + (int) ((double) WorldGen.genRand.Next(20, 40) * (double) num18) + (int) ((double) WorldGen.genRand.Next(20, 40) * (double) num18);
int num20 = num16 - num19;
int num21 = WorldGen.genRand.Next(50, 90) + (int) ((double) WorldGen.genRand.Next(20, 40) * (double) num18) + (int) ((double) WorldGen.genRand.Next(20, 40) * (double) num18);
int num22 = num16 + num21;
if (num20 < 0)
num20 = 0;
if (num22 > Main.maxTilesX)
num22 = Main.maxTilesX;
int num23 = 10;
for (int index24 = 0; index24 <= WorldGen.lavaLine - 140; ++index24)
{
num20 += WorldGen.genRand.Next(-4, 4);
num22 += WorldGen.genRand.Next(-3, 5);
snowMinX[index24] = num20;
snowMaxX[index24] = num22;
for (int index25 = num20; index25 < num22; ++index25)
{
if (index24 < WorldGen.lavaLine - 140)
{
if (Main.tile[index25, index24].wall == (byte) 2)
Main.tile[index25, index24].wall = (byte) 40;
switch (Main.tile[index25, index24].type)
{
case 0:
case 2:
case 23:
case 40:
case 53:
Main.tile[index25, index24].type = (ushort) 147;
continue;
case 1:
Main.tile[index25, index24].type = (ushort) 161;
continue;
default:
continue;
}
}
else
{
num23 += WorldGen.genRand.Next(-3, 4);
if (WorldGen.genRand.Next(3) == 0)
{
num23 += WorldGen.genRand.Next(-4, 5);
if (WorldGen.genRand.Next(3) == 0)
num23 += WorldGen.genRand.Next(-6, 7);
}
if (num23 < 0)
num23 = WorldGen.genRand.Next(3);
else if (num23 > 50)
num23 = 50 - WorldGen.genRand.Next(3);
for (int index26 = index24; index26 < index24 + num23; ++index26)
{
if (Main.tile[index25, index26].wall == (byte) 2)
Main.tile[index25, index26].wall = (byte) 40;
switch (Main.tile[index25, index26].type)
{
case 0:
case 2:
case 23:
case 40:
case 53:
Main.tile[index25, index26].type = (ushort) 147;
break;
case 1:
Main.tile[index25, index26].type = (ushort) 161;
break;
}
}
}
}
if (snowBottom < index24)
snowBottom = index24;
}
}));
WorldGen.AddGenerationPass("Grass", (WorldGenLegacyMethod) (progress =>
{
for (int index27 = 0; index27 < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.002); ++index27)
{
int index28 = WorldGen.genRand.Next(1, Main.maxTilesX - 1);
int index29 = WorldGen.genRand.Next((int) WorldGen.worldSurfaceLow, (int) worldSurfaceHigh);
if (index29 >= Main.maxTilesY)
index29 = Main.maxTilesY - 2;
if (Main.tile[index28 - 1, index29].active() && Main.tile[index28 - 1, index29].type == (ushort) 0 && Main.tile[index28 + 1, index29].active() && Main.tile[index28 + 1, index29].type == (ushort) 0 && Main.tile[index28, index29 - 1].active() && Main.tile[index28, index29 - 1].type == (ushort) 0 && Main.tile[index28, index29 + 1].active() && Main.tile[index28, index29 + 1].type == (ushort) 0)
{
Main.tile[index28, index29].active(true);
Main.tile[index28, index29].type = (ushort) 2;
}
int index30 = WorldGen.genRand.Next(1, Main.maxTilesX - 1);
int index31 = WorldGen.genRand.Next(0, (int) WorldGen.worldSurfaceLow);
if (index31 >= Main.maxTilesY)
index31 = Main.maxTilesY - 2;
if (Main.tile[index30 - 1, index31].active() && Main.tile[index30 - 1, index31].type == (ushort) 0 && Main.tile[index30 + 1, index31].active() && Main.tile[index30 + 1, index31].type == (ushort) 0 && Main.tile[index30, index31 - 1].active() && Main.tile[index30, index31 - 1].type == (ushort) 0 && Main.tile[index30, index31 + 1].active() && Main.tile[index30, index31 + 1].type == (ushort) 0)
{
Main.tile[index30, index31].active(true);
Main.tile[index30, index31].type = (ushort) 2;
}
}
}));
WorldGen.AddGenerationPass("Jungle", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[11].Value;
float num24 = (float) (Main.maxTilesX / 4200) * 1.5f;
float num25 = (float) WorldGen.genRand.Next(15, 30) * 0.01f;
int num26;
if (dungeonSide == -1)
{
float num27 = 1f - num25;
num26 = (int) ((double) Main.maxTilesX * (double) num27);
}
else
num26 = (int) ((double) Main.maxTilesX * (double) num25);
int num28 = (int) ((double) Main.maxTilesY + Main.rockLayer) / 2;
int i1 = num26 + WorldGen.genRand.Next((int) (-100.0 * (double) num24), (int) (101.0 * (double) num24));
int j1 = num28 + WorldGen.genRand.Next((int) (-100.0 * (double) num24), (int) (101.0 * (double) num24));
int num29 = i1;
int num30 = j1;
WorldGen.TileRunner(i1, j1, (double) WorldGen.genRand.Next((int) (250.0 * (double) num24), (int) (500.0 * (double) num24)), WorldGen.genRand.Next(50, 150), 59, speedX: ((float) (dungeonSide * 3)));
for (int index = 0; (double) index < 6.0 * (double) num24; ++index)
WorldGen.TileRunner(i1 + WorldGen.genRand.Next(-(int) (125.0 * (double) num24), (int) (125.0 * (double) num24)), j1 + WorldGen.genRand.Next(-(int) (125.0 * (double) num24), (int) (125.0 * (double) num24)), (double) WorldGen.genRand.Next(3, 7), WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(63, 65));
WorldGen.mudWall = true;
progress.Set(0.15f);
int i3 = i1 + WorldGen.genRand.Next((int) (-250.0 * (double) num24), (int) (251.0 * (double) num24));
int j2 = j1 + WorldGen.genRand.Next((int) (-150.0 * (double) num24), (int) (151.0 * (double) num24));
int num31 = i3;
int num32 = j2;
int num33 = i3;
int num34 = j2;
WorldGen.TileRunner(i3, j2, (double) WorldGen.genRand.Next((int) (250.0 * (double) num24), (int) (500.0 * (double) num24)), WorldGen.genRand.Next(50, 150), 59);
WorldGen.mudWall = false;
for (int index = 0; (double) index < 6.0 * (double) num24; ++index)
WorldGen.TileRunner(i3 + WorldGen.genRand.Next(-(int) (125.0 * (double) num24), (int) (125.0 * (double) num24)), j2 + WorldGen.genRand.Next(-(int) (125.0 * (double) num24), (int) (125.0 * (double) num24)), (double) WorldGen.genRand.Next(3, 7), WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(65, 67));
WorldGen.mudWall = true;
progress.Set(0.3f);
int i4 = i3 + WorldGen.genRand.Next((int) (-400.0 * (double) num24), (int) (401.0 * (double) num24));
int j3 = j2 + WorldGen.genRand.Next((int) (-150.0 * (double) num24), (int) (151.0 * (double) num24));
int num35 = i4;
int num36 = j3;
WorldGen.TileRunner(i4, j3, (double) WorldGen.genRand.Next((int) (250.0 * (double) num24), (int) (500.0 * (double) num24)), WorldGen.genRand.Next(50, 150), 59, speedX: ((float) (dungeonSide * -3)));
WorldGen.mudWall = false;
for (int index = 0; (double) index < 6.0 * (double) num24; ++index)
WorldGen.TileRunner(i4 + WorldGen.genRand.Next(-(int) (125.0 * (double) num24), (int) (125.0 * (double) num24)), j3 + WorldGen.genRand.Next(-(int) (125.0 * (double) num24), (int) (125.0 * (double) num24)), (double) WorldGen.genRand.Next(3, 7), WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(67, 69));
WorldGen.mudWall = true;
progress.Set(0.45f);
int i5 = (num29 + num31 + num35) / 3;
int j4 = (num30 + num32 + num36) / 3;
WorldGen.TileRunner(i5, j4, (double) WorldGen.genRand.Next((int) (400.0 * (double) num24), (int) (600.0 * (double) num24)), 10000, 59, speedY: -20f, noYChange: true);
WorldGen.JungleRunner(i5, j4);
progress.Set(0.6f);
WorldGen.mudWall = false;
for (int index = 0; index < Main.maxTilesX / 4; ++index)
{
int i6 = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
int j5;
for (j5 = WorldGen.genRand.Next((int) worldSurface + 10, Main.maxTilesY - 200); Main.tile[i6, j5].wall != (byte) 64 && Main.tile[i6, j5].wall != (byte) 15; j5 = WorldGen.genRand.Next((int) worldSurface + 10, Main.maxTilesY - 200))
i6 = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
WorldGen.MudWallRunner(i6, j5);
}
int i7 = num33;
int j6 = num34;
for (int index = 0; (double) index <= 20.0 * (double) num24; ++index)
{
progress.Set((float) ((60.0 + (double) index / (double) num24) * 0.00999999977648258));
i7 += WorldGen.genRand.Next((int) (-5.0 * (double) num24), (int) (6.0 * (double) num24));
j6 += WorldGen.genRand.Next((int) (-5.0 * (double) num24), (int) (6.0 * (double) num24));
WorldGen.TileRunner(i7, j6, (double) WorldGen.genRand.Next(40, 100), WorldGen.genRand.Next(300, 500), 59);
}
for (int index32 = 0; (double) index32 <= 10.0 * (double) num24; ++index32)
{
progress.Set((float) ((80.0 + (double) index32 / (double) num24 * 2.0) * 0.00999999977648258));
int i8 = num33 + WorldGen.genRand.Next((int) (-600.0 * (double) num24), (int) (600.0 * (double) num24));
int j7;
for (j7 = num34 + WorldGen.genRand.Next((int) (-200.0 * (double) num24), (int) (200.0 * (double) num24)); i8 < 1 || i8 >= Main.maxTilesX - 1 || j7 < 1 || j7 >= Main.maxTilesY - 1 || Main.tile[i8, j7].type != (ushort) 59; j7 = num34 + WorldGen.genRand.Next((int) (-200.0 * (double) num24), (int) (200.0 * (double) num24)))
i8 = num33 + WorldGen.genRand.Next((int) (-600.0 * (double) num24), (int) (600.0 * (double) num24));
for (int index33 = 0; (double) index33 < 8.0 * (double) num24; ++index33)
{
i8 += WorldGen.genRand.Next(-30, 31);
j7 += WorldGen.genRand.Next(-30, 31);
int type = -1;
if (WorldGen.genRand.Next(7) == 0)
type = -2;
WorldGen.TileRunner(i8, j7, (double) WorldGen.genRand.Next(10, 20), WorldGen.genRand.Next(30, 70), type);
}
}
for (int index = 0; (double) index <= 300.0 * (double) num24; ++index)
{
int i9 = num33 + WorldGen.genRand.Next((int) (-600.0 * (double) num24), (int) (600.0 * (double) num24));
int j8;
for (j8 = num34 + WorldGen.genRand.Next((int) (-200.0 * (double) num24), (int) (200.0 * (double) num24)); i9 < 1 || i9 >= Main.maxTilesX - 1 || j8 < 1 || j8 >= Main.maxTilesY - 1 || Main.tile[i9, j8].type != (ushort) 59; j8 = num34 + WorldGen.genRand.Next((int) (-200.0 * (double) num24), (int) (200.0 * (double) num24)))
i9 = num33 + WorldGen.genRand.Next((int) (-600.0 * (double) num24), (int) (600.0 * (double) num24));
WorldGen.TileRunner(i9, j8, (double) WorldGen.genRand.Next(4, 10), WorldGen.genRand.Next(5, 30), 1);
if (WorldGen.genRand.Next(4) == 0)
{
int type = WorldGen.genRand.Next(63, 69);
WorldGen.TileRunner(i9 + WorldGen.genRand.Next(-1, 2), j8 + WorldGen.genRand.Next(-1, 2), (double) WorldGen.genRand.Next(3, 7), WorldGen.genRand.Next(4, 8), type);
}
}
}));
WorldGen.AddGenerationPass("Marble", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[80].Value;
float num37 = (float) (Main.maxTilesX * Main.maxTilesY) / 5040000f;
int num38 = (int) ((double) WorldGen.genRand.Next(10, 15) * (double) num37);
float num39 = (float) (Main.maxTilesX - 160) / (float) num38;
int num40 = 0;
while (num40 < num38)
{
float num41 = (float) num40 / (float) num38;
progress.Set(num41);
if (Terraria.World.Generation.Biomes<MarbleBiome>.Place(WorldGen.RandomRectanglePoint((int) ((double) num41 * (double) (Main.maxTilesX - 160)) + 80, (int) rockLayer + 20, (int) num39, Main.maxTilesY - ((int) rockLayer + 40) - 200), structures))
++num40;
}
}));
WorldGen.AddGenerationPass("Granite", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[81].Value;
float num42 = (float) Main.maxTilesX / 4200f;
int num43 = (int) ((double) WorldGen.genRand.Next(8, 14) * (double) num42);
float num44 = (float) (Main.maxTilesX - 200) / (float) num43;
int num45 = 0;
while (num45 < num43)
{
float num46 = (float) num45 / (float) num43;
progress.Set(num46);
if (Terraria.World.Generation.Biomes<GraniteBiome>.Place(WorldGen.RandomRectanglePoint((int) ((double) num46 * (double) (Main.maxTilesX - 200)) + 100, (int) rockLayer + 20, (int) num44, Main.maxTilesY - ((int) rockLayer + 40) - 200), structures))
++num45;
}
}));
WorldGen.AddGenerationPass("Mud Caves To Grass", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[77].Value;
for (int i = 0; i < Main.maxTilesX; ++i)
{
for (int j = 0; j < Main.maxTilesY; ++j)
{
if (Main.tile[i, j].active())
{
WorldGen.grassSpread = 0;
WorldGen.SpreadGrass(i, j, 59, 60);
}
progress.Set((float) (0.200000002980232 * ((double) (i * Main.maxTilesY + j) / (double) (Main.maxTilesX * Main.maxTilesY))));
}
}
for (int x = 10; x < Main.maxTilesX - 10; ++x)
{
for (int y = 10; y < Main.maxTilesY - 10; ++y)
{
if (Main.tile[x, y].active() && WorldGen.tileCounter(x, y) < WorldGen.tileCounterMax)
WorldGen.tileCounterKill();
float num = (float) ((x - 10) * (Main.maxTilesY - 20) + (y - 10)) / (float) ((Main.maxTilesX - 20) * (Main.maxTilesY - 20));
progress.Set((float) (0.200000002980232 + (double) num * 0.800000011920929));
}
}
}));
WorldGen.AddGenerationPass("Full Desert", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[78].Value;
int num47 = dungeonSide;
int maxValue = Main.maxTilesX / 2;
int num48 = WorldGen.genRand.Next(maxValue) / 8 + maxValue / 8;
int x = maxValue + num48 * -num47;
int num49 = 0;
while (!Terraria.World.Generation.Biomes<DesertBiome>.Place(new Point(x, (int) worldSurface), structures))
{
int num50 = WorldGen.genRand.Next(maxValue) / 2 + maxValue / 8;
x = maxValue + num50 * -num47;
if (++num49 > 1000)
{
num47 *= -1;
num49 = 0;
}
}
}));
WorldGen.AddGenerationPass("Floating Islands", (WorldGenLegacyMethod) (progress =>
{
WorldGen.numIslandHouses = 0;
WorldGen.houseCount = 0;
progress.Message = Lang.gen[12].Value;
for (int index34 = 0; index34 < (int) ((double) Main.maxTilesX * 0.0008) + skyLakes; ++index34)
{
int num51 = 1000;
int i = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.1), (int) ((double) Main.maxTilesX * 0.9));
while (--num51 > 0)
{
bool flag3 = true;
while (i > Main.maxTilesX / 2 - 80 && i < Main.maxTilesX / 2 + 80)
i = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.1), (int) ((double) Main.maxTilesX * 0.9));
for (int index35 = 0; index35 < WorldGen.numIslandHouses; ++index35)
{
if (i > WorldGen.fihX[index35] - 180 && i < WorldGen.fihX[index35] + 180)
{
flag3 = false;
break;
}
}
if (flag3)
{
bool flag4 = false;
int num52 = 0;
for (int index36 = 200; (double) index36 < Main.worldSurface; ++index36)
{
if (Main.tile[i, index36].active())
{
num52 = index36;
flag4 = true;
break;
}
}
if (flag4)
{
int j = Math.Min(WorldGen.genRand.Next(90, num52 - 100), (int) WorldGen.worldSurfaceLow - 50);
if (index34 < skyLakes)
{
WorldGen.skyLake[WorldGen.numIslandHouses] = true;
WorldGen.CloudLake(i, j);
}
else
WorldGen.CloudIsland(i, j);
WorldGen.fihX[WorldGen.numIslandHouses] = i;
WorldGen.fihY[WorldGen.numIslandHouses] = j;
++WorldGen.numIslandHouses;
}
}
}
}
}));
WorldGen.AddGenerationPass("Mushroom Patches", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[13].Value;
for (int index = 0; index < Main.maxTilesX / 500; ++index)
{
int num53 = 0;
bool flag = true;
while (flag)
{
int i = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.3), (int) ((double) Main.maxTilesX * 0.7));
int j = WorldGen.genRand.Next((int) Main.rockLayer, Main.maxTilesY - 350);
flag = false;
int num54 = 60;
for (int x = i - num54; x < i + num54; x += 3)
{
for (int y = j - num54; y < j + num54; y += 3)
{
if (Main.tile[x, y].type == (ushort) 147 || Main.tile[x, y].type == (ushort) 161 || Main.tile[x, y].type == (ushort) 162)
{
flag = true;
break;
}
if (WorldGen.UndergroundDesertLocation.Contains(new Point(x, y)))
{
flag = true;
break;
}
}
}
if (!flag)
WorldGen.ShroomPatch(i, j);
++num53;
if (num53 > 100)
break;
}
}
for (int i10 = 0; i10 < Main.maxTilesX; ++i10)
{
for (int worldSurface1 = (int) Main.worldSurface; worldSurface1 < Main.maxTilesY; ++worldSurface1)
{
if (Main.tile[i10, worldSurface1].active())
{
WorldGen.grassSpread = 0;
WorldGen.SpreadGrass(i10, worldSurface1, 59, 70, false);
if (Main.tile[i10, worldSurface1].type == (ushort) 70 && WorldGen.genRand.Next(20) == 0)
{
int num55 = WorldGen.genRand.Next(5) != 0 ? 1 : 2;
int num56 = WorldGen.genRand.Next(2, 6);
int j9 = worldSurface1 - num56;
bool flag = true;
for (int index = i10 - num55; index <= i10 + num55; ++index)
{
if (Main.tile[index, j9].active())
flag = false;
if (Main.tileBrick[(int) Main.tile[index, j9 - 1].type])
flag = false;
if (Main.tileBrick[(int) Main.tile[index, j9 + 1].type])
flag = false;
}
if (Main.tile[i10 - num55 - 1, j9].type == (ushort) 190)
flag = false;
if (Main.tile[i10 + num55 + 1, j9].type == (ushort) 190)
flag = false;
for (int index = j9; index < worldSurface1; ++index)
{
if (Main.tile[i10, index].active())
flag = false;
if (Main.tileBrick[(int) Main.tile[i10 - 1, index].type])
flag = false;
if (Main.tileBrick[(int) Main.tile[i10 + 1, index].type])
flag = false;
}
if (flag)
{
for (int i11 = i10 - num55; i11 <= i10 + num55; ++i11)
WorldGen.PlaceTile(i11, j9, 190, true, true);
for (int j10 = j9; j10 < worldSurface1; ++j10)
WorldGen.PlaceTile(i10, j10, 190, true, true);
}
}
}
}
}
}));
WorldGen.AddGenerationPass("Mud To Dirt", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[14].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.001); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerLow, Main.maxTilesY), (double) WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(2, 40), 59);
}));
WorldGen.AddGenerationPass("Silt", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[15].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0001); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerHigh, Main.maxTilesY), (double) WorldGen.genRand.Next(5, 12), WorldGen.genRand.Next(15, 50), 123);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0005); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerHigh, Main.maxTilesY), (double) WorldGen.genRand.Next(2, 5), WorldGen.genRand.Next(2, 5), 123);
}));
WorldGen.AddGenerationPass("Shinies", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[16].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 6E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) WorldGen.worldSurfaceLow, (int) worldSurfaceHigh), (double) WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), copper);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 8E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) worldSurfaceHigh, (int) rockLayerHigh), (double) WorldGen.genRand.Next(3, 7), WorldGen.genRand.Next(3, 7), copper);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0002); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerLow, Main.maxTilesY), (double) WorldGen.genRand.Next(4, 9), WorldGen.genRand.Next(4, 8), copper);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 3E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) WorldGen.worldSurfaceLow, (int) worldSurfaceHigh), (double) WorldGen.genRand.Next(3, 7), WorldGen.genRand.Next(2, 5), iron);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 8E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) worldSurfaceHigh, (int) rockLayerHigh), (double) WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(3, 6), iron);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0002); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerLow, Main.maxTilesY), (double) WorldGen.genRand.Next(4, 9), WorldGen.genRand.Next(4, 8), iron);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 2.6E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) worldSurfaceHigh, (int) rockLayerHigh), (double) WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(3, 6), silver);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.00015); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerLow, Main.maxTilesY), (double) WorldGen.genRand.Next(4, 9), WorldGen.genRand.Next(4, 8), silver);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.00017); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next(0, (int) WorldGen.worldSurfaceLow), (double) WorldGen.genRand.Next(4, 9), WorldGen.genRand.Next(4, 8), silver);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.00012); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerLow, Main.maxTilesY), (double) WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(4, 8), gold);
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.00012); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next(0, (int) WorldGen.worldSurfaceLow - 20), (double) WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(4, 8), gold);
if (WorldGen.crimson)
{
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 2E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerLow, Main.maxTilesY), (double) WorldGen.genRand.Next(2, 4), WorldGen.genRand.Next(3, 6), 204);
}
else
{
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 2E-05); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int) rockLayerLow, Main.maxTilesY), (double) WorldGen.genRand.Next(2, 4), WorldGen.genRand.Next(3, 6), 22);
}
}));
WorldGen.AddGenerationPass("Webs", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[17].Value;
for (int index37 = 0; index37 < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0006); ++index37)
{
int index38 = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
int index39 = WorldGen.genRand.Next((int) worldSurfaceHigh, Main.maxTilesY - 20);
if (index37 < WorldGen.numMCaves)
{
index38 = WorldGen.mCaveX[index37];
index39 = WorldGen.mCaveY[index37];
}
if (!Main.tile[index38, index39].active() && ((double) index39 > Main.worldSurface || Main.tile[index38, index39].wall > (byte) 0))
{
while (!Main.tile[index38, index39].active() && index39 > (int) WorldGen.worldSurfaceLow)
--index39;
int j = index39 + 1;
int num = 1;
if (WorldGen.genRand.Next(2) == 0)
num = -1;
while (!Main.tile[index38, j].active() && index38 > 10 && index38 < Main.maxTilesX - 10)
index38 += num;
int i = index38 - num;
if ((double) j > Main.worldSurface || Main.tile[i, j].wall > (byte) 0)
WorldGen.TileRunner(i, j, (double) WorldGen.genRand.Next(4, 11), WorldGen.genRand.Next(2, 4), 51, true, (float) num, -1f, overRide: false);
}
}
}));
WorldGen.AddGenerationPass("Underworld", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[18].Value;
progress.Set(0.0f);
int num57 = Main.maxTilesY - WorldGen.genRand.Next(150, 190);
for (int index40 = 0; index40 < Main.maxTilesX; ++index40)
{
num57 += WorldGen.genRand.Next(-3, 4);
if (num57 < Main.maxTilesY - 190)
num57 = Main.maxTilesY - 190;
if (num57 > Main.maxTilesY - 160)
num57 = Main.maxTilesY - 160;
for (int index41 = num57 - 20 - WorldGen.genRand.Next(3); index41 < Main.maxTilesY; ++index41)
{
if (index41 >= num57)
{
Main.tile[index40, index41].active(false);
Main.tile[index40, index41].lava(false);
Main.tile[index40, index41].liquid = (byte) 0;
}
else
Main.tile[index40, index41].type = (ushort) 57;
}
}
int num58 = Main.maxTilesY - WorldGen.genRand.Next(40, 70);
for (int index42 = 10; index42 < Main.maxTilesX - 10; ++index42)
{
num58 += WorldGen.genRand.Next(-10, 11);
if (num58 > Main.maxTilesY - 60)
num58 = Main.maxTilesY - 60;
if (num58 < Main.maxTilesY - 100)
num58 = Main.maxTilesY - 120;
for (int index43 = num58; index43 < Main.maxTilesY - 10; ++index43)
{
if (!Main.tile[index42, index43].active())
{
Main.tile[index42, index43].lava(true);
Main.tile[index42, index43].liquid = byte.MaxValue;
}
}
}
for (int index44 = 0; index44 < Main.maxTilesX; ++index44)
{
if (WorldGen.genRand.Next(50) == 0)
{
int index45 = Main.maxTilesY - 65;
while (!Main.tile[index44, index45].active() && index45 > Main.maxTilesY - 135)
--index45;
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), index45 + WorldGen.genRand.Next(20, 50), (double) WorldGen.genRand.Next(15, 20), 1000, 57, true, speedY: ((float) WorldGen.genRand.Next(1, 3)), noYChange: true);
}
}
Liquid.QuickWater(-2);
for (int i = 0; i < Main.maxTilesX; ++i)
{
float num59 = (float) i / (float) (Main.maxTilesX - 1);
progress.Set((float) ((double) num59 / 2.0 + 0.5));
if (WorldGen.genRand.Next(13) == 0)
{
int index = Main.maxTilesY - 65;
while ((Main.tile[i, index].liquid > (byte) 0 || Main.tile[i, index].active()) && index > Main.maxTilesY - 140)
--index;
WorldGen.TileRunner(i, index - WorldGen.genRand.Next(2, 5), (double) WorldGen.genRand.Next(5, 30), 1000, 57, true, speedY: ((float) WorldGen.genRand.Next(1, 3)), noYChange: true);
float num60 = (float) WorldGen.genRand.Next(1, 3);
if (WorldGen.genRand.Next(3) == 0)
num60 *= 0.5f;
if (WorldGen.genRand.Next(2) == 0)
WorldGen.TileRunner(i, index - WorldGen.genRand.Next(2, 5), (double) (int) ((double) WorldGen.genRand.Next(5, 15) * (double) num60), (int) ((double) WorldGen.genRand.Next(10, 15) * (double) num60), 57, true, 1f, 0.3f);
if (WorldGen.genRand.Next(2) == 0)
{
float num61 = (float) WorldGen.genRand.Next(1, 3);
WorldGen.TileRunner(i, index - WorldGen.genRand.Next(2, 5), (double) (int) ((double) WorldGen.genRand.Next(5, 15) * (double) num61), (int) ((double) WorldGen.genRand.Next(10, 15) * (double) num61), 57, true, -1f, 0.3f);
}
WorldGen.TileRunner(i + WorldGen.genRand.Next(-10, 10), index + WorldGen.genRand.Next(-10, 10), (double) WorldGen.genRand.Next(5, 15), WorldGen.genRand.Next(5, 10), -2, speedX: ((float) WorldGen.genRand.Next(-1, 3)), speedY: ((float) WorldGen.genRand.Next(-1, 3)));
if (WorldGen.genRand.Next(3) == 0)
WorldGen.TileRunner(i + WorldGen.genRand.Next(-10, 10), index + WorldGen.genRand.Next(-10, 10), (double) WorldGen.genRand.Next(10, 30), WorldGen.genRand.Next(10, 20), -2, speedX: ((float) WorldGen.genRand.Next(-1, 3)), speedY: ((float) WorldGen.genRand.Next(-1, 3)));
if (WorldGen.genRand.Next(5) == 0)
WorldGen.TileRunner(i + WorldGen.genRand.Next(-15, 15), index + WorldGen.genRand.Next(-15, 10), (double) WorldGen.genRand.Next(15, 30), WorldGen.genRand.Next(5, 20), -2, speedX: ((float) WorldGen.genRand.Next(-1, 3)), speedY: ((float) WorldGen.genRand.Next(-1, 3)));
}
}
for (int index = 0; index < Main.maxTilesX; ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(20, Main.maxTilesX - 20), WorldGen.genRand.Next(Main.maxTilesY - 180, Main.maxTilesY - 10), (double) WorldGen.genRand.Next(2, 7), WorldGen.genRand.Next(2, 7), -2);
for (int index = 0; index < Main.maxTilesX; ++index)
{
if (!Main.tile[index, Main.maxTilesY - 145].active())
{
Main.tile[index, Main.maxTilesY - 145].liquid = byte.MaxValue;
Main.tile[index, Main.maxTilesY - 145].lava(true);
}
if (!Main.tile[index, Main.maxTilesY - 144].active())
{
Main.tile[index, Main.maxTilesY - 144].liquid = byte.MaxValue;
Main.tile[index, Main.maxTilesY - 144].lava(true);
}
}
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0008); ++index)
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next(Main.maxTilesY - 140, Main.maxTilesY), (double) WorldGen.genRand.Next(2, 7), WorldGen.genRand.Next(3, 7), 58);
WorldGen.AddHellHouses();
}));
WorldGen.AddGenerationPass("Lakes", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[19].Value;
int num62 = WorldGen.genRand.Next(2, (int) ((double) Main.maxTilesX * 0.005));
for (int index = 0; index < num62; ++index)
{
float num63 = (float) index / (float) num62;
progress.Set(num63);
int i = WorldGen.genRand.Next(300, Main.maxTilesX - 300);
while (i > Main.maxTilesX / 2 - 100 && i < Main.maxTilesX / 2 + 100)
i = WorldGen.genRand.Next(300, Main.maxTilesX - 300);
int j = (int) WorldGen.worldSurfaceLow - 20;
while (!Main.tile[i, j].active())
++j;
WorldGen.Lakinater(i, j);
}
}));
WorldGen.AddGenerationPass("Dungeon", (WorldGenLegacyMethod) (progress =>
{
int x;
if (dungeonSide == -1)
{
x = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.05), (int) ((double) Main.maxTilesX * 0.2));
dungeonSide = -1;
}
else
{
x = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.8), (int) ((double) Main.maxTilesX * 0.95));
dungeonSide = 1;
}
int y = (int) ((Main.worldSurface + Main.rockLayer) / 2.0) + WorldGen.genRand.Next(-200, 200);
WorldGen.MakeDungeon(x, y);
}));
WorldGen.AddGenerationPass("Corruption", (WorldGenLegacyMethod) (progress =>
{
if (WorldGen.crimson)
{
progress.Message = Lang.gen[72].Value;
for (int index46 = 0; (double) index46 < (double) Main.maxTilesX * 0.00045; ++index46)
{
float num64 = (float) index46 / ((float) Main.maxTilesX * 0.00045f);
progress.Set(num64);
bool flag5 = false;
int i = 0;
int num65 = 0;
int num66 = 0;
while (!flag5)
{
int num67 = 0;
flag5 = true;
int num68 = Main.maxTilesX / 2;
int num69 = 200;
i = dungeonSide >= 0 ? WorldGen.genRand.Next(320, Main.maxTilesX - 600) : WorldGen.genRand.Next(600, Main.maxTilesX - 320);
num65 = i - WorldGen.genRand.Next(200) - 100;
num66 = i + WorldGen.genRand.Next(200) + 100;
if (num65 < 285)
num65 = 285;
if (num66 > Main.maxTilesX - 285)
num66 = Main.maxTilesX - 285;
if (dungeonSide < 0 && num65 < 400)
num65 = 400;
else if (dungeonSide > 0 && num65 > Main.maxTilesX - 400)
num65 = Main.maxTilesX - 400;
if (i > num68 - num69 && i < num68 + num69)
flag5 = false;
if (num65 > num68 - num69 && num65 < num68 + num69)
flag5 = false;
if (num66 > num68 - num69 && num66 < num68 + num69)
flag5 = false;
if (i > WorldGen.UndergroundDesertLocation.X && i < WorldGen.UndergroundDesertLocation.X + WorldGen.UndergroundDesertLocation.Width)
flag5 = false;
if (num65 > WorldGen.UndergroundDesertLocation.X && num65 < WorldGen.UndergroundDesertLocation.X + WorldGen.UndergroundDesertLocation.Width)
flag5 = false;
if (num66 > WorldGen.UndergroundDesertLocation.X && num66 < WorldGen.UndergroundDesertLocation.X + WorldGen.UndergroundDesertLocation.Width)
flag5 = false;
for (int index47 = num65; index47 < num66; ++index47)
{
for (int index48 = 0; index48 < (int) Main.worldSurface; index48 += 5)
{
if (Main.tile[index47, index48].active() && Main.tileDungeon[(int) Main.tile[index47, index48].type])
{
flag5 = false;
break;
}
if (!flag5)
break;
}
}
if (num67 < 200 && WorldGen.JungleX > num65 && WorldGen.JungleX < num66)
{
int num70 = num67 + 1;
flag5 = false;
}
}
WorldGen.CrimStart(i, (int) WorldGen.worldSurfaceLow - 10);
for (int index49 = num65; index49 < num66; ++index49)
{
for (int worldSurfaceLow = (int) WorldGen.worldSurfaceLow; (double) worldSurfaceLow < Main.worldSurface - 1.0; ++worldSurfaceLow)
{
if (Main.tile[index49, worldSurfaceLow].active())
{
int num71 = worldSurfaceLow + WorldGen.genRand.Next(10, 14);
for (int index50 = worldSurfaceLow; index50 < num71; ++index50)
{
if ((Main.tile[index49, index50].type == (ushort) 59 || Main.tile[index49, index50].type == (ushort) 60) && index49 >= num65 + WorldGen.genRand.Next(5) && index49 < num66 - WorldGen.genRand.Next(5))
Main.tile[index49, index50].type = (ushort) 0;
}
break;
}
}
}
double num72 = Main.worldSurface + 40.0;
for (int index51 = num65; index51 < num66; ++index51)
{
num72 += (double) WorldGen.genRand.Next(-2, 3);
if (num72 < Main.worldSurface + 30.0)
num72 = Main.worldSurface + 30.0;
if (num72 > Main.worldSurface + 50.0)
num72 = Main.worldSurface + 50.0;
i2 = index51;
bool flag6 = false;
for (int worldSurfaceLow = (int) WorldGen.worldSurfaceLow; (double) worldSurfaceLow < num72; ++worldSurfaceLow)
{
if (Main.tile[i2, worldSurfaceLow].active())
{
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 53 && i2 >= num65 + WorldGen.genRand.Next(5) && i2 <= num66 - WorldGen.genRand.Next(5))
Main.tile[i2, worldSurfaceLow].type = (ushort) 234;
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 0 && (double) worldSurfaceLow < Main.worldSurface - 1.0 && !flag6)
{
WorldGen.grassSpread = 0;
WorldGen.SpreadGrass(i2, worldSurfaceLow, grass: 199);
}
flag6 = true;
if (Main.tile[i2, worldSurfaceLow].wall == (byte) 216)
Main.tile[i2, worldSurfaceLow].wall = (byte) 218;
else if (Main.tile[i2, worldSurfaceLow].wall == (byte) 187)
Main.tile[i2, worldSurfaceLow].wall = (byte) 221;
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 1)
{
if (i2 >= num65 + WorldGen.genRand.Next(5) && i2 <= num66 - WorldGen.genRand.Next(5))
Main.tile[i2, worldSurfaceLow].type = (ushort) 203;
}
else if (Main.tile[i2, worldSurfaceLow].type == (ushort) 2)
Main.tile[i2, worldSurfaceLow].type = (ushort) 199;
else if (Main.tile[i2, worldSurfaceLow].type == (ushort) 161)
Main.tile[i2, worldSurfaceLow].type = (ushort) 200;
else if (Main.tile[i2, worldSurfaceLow].type == (ushort) 396)
Main.tile[i2, worldSurfaceLow].type = (ushort) 401;
else if (Main.tile[i2, worldSurfaceLow].type == (ushort) 397)
Main.tile[i2, worldSurfaceLow].type = (ushort) 399;
}
}
}
int num73 = WorldGen.genRand.Next(10, 15);
for (int index52 = 0; index52 < num73; ++index52)
{
int num74 = 0;
bool flag7 = false;
int num75 = 0;
while (!flag7)
{
++num74;
int x = WorldGen.genRand.Next(num65 - num75, num66 + num75);
int y = WorldGen.genRand.Next((int) (Main.worldSurface - (double) (num75 / 2)), (int) (Main.worldSurface + 100.0 + (double) num75));
if (num74 > 100)
{
++num75;
num74 = 0;
}
if (!Main.tile[x, y].active())
{
while (!Main.tile[x, y].active())
++y;
--y;
}
else
{
while (Main.tile[x, y].active() && (double) y > Main.worldSurface)
--y;
}
if (num75 > 10 || Main.tile[x, y + 1].active() && Main.tile[x, y + 1].type == (ushort) 203)
{
WorldGen.Place3x2(x, y, (ushort) 26, 1);
if (Main.tile[x, y].type == (ushort) 26)
flag7 = true;
}
if (num75 > 100)
flag7 = true;
}
}
}
}
else
{
progress.Message = Lang.gen[20].Value;
for (int index53 = 0; (double) index53 < (double) Main.maxTilesX * 0.00045; ++index53)
{
float num76 = (float) index53 / ((float) Main.maxTilesX * 0.00045f);
progress.Set(num76);
bool flag8 = false;
int num77 = 0;
int num78 = 0;
int num79 = 0;
while (!flag8)
{
int num80 = 0;
flag8 = true;
int num81 = Main.maxTilesX / 2;
int num82 = 200;
num77 = WorldGen.genRand.Next(320, Main.maxTilesX - 320);
num78 = num77 - WorldGen.genRand.Next(200) - 100;
num79 = num77 + WorldGen.genRand.Next(200) + 100;
if (num78 < 285)
num78 = 285;
if (num79 > Main.maxTilesX - 285)
num79 = Main.maxTilesX - 285;
if (num77 > num81 - num82 && num77 < num81 + num82)
flag8 = false;
if (num78 > num81 - num82 && num78 < num81 + num82)
flag8 = false;
if (num79 > num81 - num82 && num79 < num81 + num82)
flag8 = false;
if (num77 > WorldGen.UndergroundDesertLocation.X && num77 < WorldGen.UndergroundDesertLocation.X + WorldGen.UndergroundDesertLocation.Width)
flag8 = false;
if (num78 > WorldGen.UndergroundDesertLocation.X && num78 < WorldGen.UndergroundDesertLocation.X + WorldGen.UndergroundDesertLocation.Width)
flag8 = false;
if (num79 > WorldGen.UndergroundDesertLocation.X && num79 < WorldGen.UndergroundDesertLocation.X + WorldGen.UndergroundDesertLocation.Width)
flag8 = false;
for (int index54 = num78; index54 < num79; ++index54)
{
for (int index55 = 0; index55 < (int) Main.worldSurface; index55 += 5)
{
if (Main.tile[index54, index55].active() && Main.tileDungeon[(int) Main.tile[index54, index55].type])
{
flag8 = false;
break;
}
if (!flag8)
break;
}
}
if (num80 < 200 && WorldGen.JungleX > num78 && WorldGen.JungleX < num79)
{
int num83 = num80 + 1;
flag8 = false;
}
}
int num84 = 0;
for (int i = num78; i < num79; ++i)
{
if (num84 > 0)
--num84;
if (i == num77 || num84 == 0)
{
for (int worldSurfaceLow = (int) WorldGen.worldSurfaceLow; (double) worldSurfaceLow < Main.worldSurface - 1.0; ++worldSurfaceLow)
{
if (Main.tile[i, worldSurfaceLow].active() || Main.tile[i, worldSurfaceLow].wall > (byte) 0)
{
if (i == num77)
{
num84 = 20;
WorldGen.ChasmRunner(i, worldSurfaceLow, WorldGen.genRand.Next(150) + 150, true);
break;
}
if (WorldGen.genRand.Next(35) == 0 && num84 == 0)
{
num84 = 30;
bool makeOrb = true;
WorldGen.ChasmRunner(i, worldSurfaceLow, WorldGen.genRand.Next(50) + 50, makeOrb);
break;
}
break;
}
}
}
for (int worldSurfaceLow = (int) WorldGen.worldSurfaceLow; (double) worldSurfaceLow < Main.worldSurface - 1.0; ++worldSurfaceLow)
{
if (Main.tile[i, worldSurfaceLow].active())
{
int num85 = worldSurfaceLow + WorldGen.genRand.Next(10, 14);
for (int index56 = worldSurfaceLow; index56 < num85; ++index56)
{
if ((Main.tile[i, index56].type == (ushort) 59 || Main.tile[i, index56].type == (ushort) 60) && i >= num78 + WorldGen.genRand.Next(5) && i < num79 - WorldGen.genRand.Next(5))
Main.tile[i, index56].type = (ushort) 0;
}
break;
}
}
}
double num86 = Main.worldSurface + 40.0;
for (int index57 = num78; index57 < num79; ++index57)
{
num86 += (double) WorldGen.genRand.Next(-2, 3);
if (num86 < Main.worldSurface + 30.0)
num86 = Main.worldSurface + 30.0;
if (num86 > Main.worldSurface + 50.0)
num86 = Main.worldSurface + 50.0;
i2 = index57;
bool flag9 = false;
for (int worldSurfaceLow = (int) WorldGen.worldSurfaceLow; (double) worldSurfaceLow < num86; ++worldSurfaceLow)
{
if (Main.tile[i2, worldSurfaceLow].active())
{
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 53 && i2 >= num78 + WorldGen.genRand.Next(5) && i2 <= num79 - WorldGen.genRand.Next(5))
Main.tile[i2, worldSurfaceLow].type = (ushort) 112;
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 0 && (double) worldSurfaceLow < Main.worldSurface - 1.0 && !flag9)
{
WorldGen.grassSpread = 0;
WorldGen.SpreadGrass(i2, worldSurfaceLow, grass: 23);
}
flag9 = true;
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 1 && i2 >= num78 + WorldGen.genRand.Next(5) && i2 <= num79 - WorldGen.genRand.Next(5))
Main.tile[i2, worldSurfaceLow].type = (ushort) 25;
if (Main.tile[i2, worldSurfaceLow].wall == (byte) 216)
Main.tile[i2, worldSurfaceLow].wall = (byte) 217;
else if (Main.tile[i2, worldSurfaceLow].wall == (byte) 187)
Main.tile[i2, worldSurfaceLow].wall = (byte) 220;
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 2)
Main.tile[i2, worldSurfaceLow].type = (ushort) 23;
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 161)
Main.tile[i2, worldSurfaceLow].type = (ushort) 163;
else if (Main.tile[i2, worldSurfaceLow].type == (ushort) 396)
Main.tile[i2, worldSurfaceLow].type = (ushort) 400;
else if (Main.tile[i2, worldSurfaceLow].type == (ushort) 397)
Main.tile[i2, worldSurfaceLow].type = (ushort) 398;
}
}
}
for (int index58 = num78; index58 < num79; ++index58)
{
for (int index59 = 0; index59 < Main.maxTilesY - 50; ++index59)
{
if (Main.tile[index58, index59].active() && Main.tile[index58, index59].type == (ushort) 31)
{
int num87 = index58 - 13;
int num88 = index58 + 13;
int num89 = index59 - 13;
int num90 = index59 + 13;
for (int index60 = num87; index60 < num88; ++index60)
{
if (index60 > 10 && index60 < Main.maxTilesX - 10)
{
for (int index61 = num89; index61 < num90; ++index61)
{
if (Math.Abs(index60 - index58) + Math.Abs(index61 - index59) < 9 + WorldGen.genRand.Next(11) && WorldGen.genRand.Next(3) != 0 && Main.tile[index60, index61].type != (ushort) 31)
{
Main.tile[index60, index61].active(true);
Main.tile[index60, index61].type = (ushort) 25;
if (Math.Abs(index60 - index58) <= 1 && Math.Abs(index61 - index59) <= 1)
Main.tile[index60, index61].active(false);
}
if (Main.tile[index60, index61].type != (ushort) 31 && Math.Abs(index60 - index58) <= 2 + WorldGen.genRand.Next(3) && Math.Abs(index61 - index59) <= 2 + WorldGen.genRand.Next(3))
Main.tile[index60, index61].active(false);
}
}
}
}
}
}
}
}
}));
WorldGen.AddGenerationPass("Slush", (WorldGenLegacyMethod) (progress =>
{
for (int index62 = snowTop; index62 < snowBottom; ++index62)
{
for (int index63 = snowMinX[index62]; index63 < snowMaxX[index62]; ++index63)
{
switch (Main.tile[index63, index62].type)
{
case 1:
Main.tile[index63, index62].type = (ushort) 161;
break;
case 59:
bool flag = true;
int num = 3;
for (int index64 = index63 - num; index64 <= index63 + num; ++index64)
{
for (int index65 = index62 - num; index65 <= index62 + num; ++index65)
{
if (Main.tile[index64, index65].type == (ushort) 60 || Main.tile[index64, index65].type == (ushort) 70 || Main.tile[index64, index65].type == (ushort) 71 || Main.tile[index64, index65].type == (ushort) 72)
{
flag = false;
break;
}
}
}
if (flag)
{
Main.tile[index63, index62].type = (ushort) 224;
break;
}
break;
case 123:
Main.tile[index63, index62].type = (ushort) 224;
break;
}
}
}
}));
WorldGen.AddGenerationPass("Mud Caves To Grass", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[21].Value;
for (int index = 0; index < WorldGen.numMCaves; ++index)
{
int i = WorldGen.mCaveX[index];
int j = WorldGen.mCaveY[index];
WorldGen.CaveOpenater(i, j);
WorldGen.Cavinator(i, j, WorldGen.genRand.Next(40, 50));
}
}));
WorldGen.AddGenerationPass("Beaches", (WorldGenLegacyMethod) (progress =>
{
int index66 = 0;
int index67 = 0;
int index68 = 20;
int index69 = Main.maxTilesX - 20;
progress.Message = Lang.gen[22].Value;
for (int index70 = 0; index70 < 2; ++index70)
{
if (index70 == 0)
{
int num91 = 0;
int num92 = WorldGen.genRand.Next(125, 200) + 50;
if (dungeonSide == 1)
num92 = 275;
int num93 = 0;
float num94 = 1f;
int index71 = 0;
while (!Main.tile[num92 - 1, index71].active())
++index71;
index66 = index71;
int num95 = index71 + WorldGen.genRand.Next(1, 5);
for (int index72 = num92 - 1; index72 >= num91; --index72)
{
++num93;
if (num93 < 3)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.2f;
else if (num93 < 6)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.15f;
else if (num93 < 9)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.1f;
else if (num93 < 15)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.07f;
else if (num93 < 50)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.05f;
else if (num93 < 75)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.04f;
else if (num93 < 100)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.03f;
else if (num93 < 125)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.02f;
else if (num93 < 150)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.01f;
else if (num93 < 175)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.005f;
else if (num93 < 200)
num94 += (float) WorldGen.genRand.Next(10, 20) * (1f / 1000f);
else if (num93 < 230)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.01f;
else if (num93 < 235)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.05f;
else if (num93 < 240)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.1f;
else if (num93 < 245)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.05f;
else if (num93 < (int) byte.MaxValue)
num94 += (float) WorldGen.genRand.Next(10, 20) * 0.01f;
if (num93 == 235)
index69 = index72;
if (num93 == 235)
index68 = index72;
int num96 = WorldGen.genRand.Next(15, 20);
for (int index73 = 0; (double) index73 < (double) num95 + (double) num94 + (double) num96; ++index73)
{
if ((double) index73 < (double) num95 + (double) num94 * 0.75 - 3.0)
{
Main.tile[index72, index73].active(false);
if (index73 > num95)
Main.tile[index72, index73].liquid = byte.MaxValue;
else if (index73 == num95)
Main.tile[index72, index73].liquid = (byte) 127;
}
else if (index73 > num95)
{
Main.tile[index72, index73].type = (ushort) 53;
Main.tile[index72, index73].active(true);
}
Main.tile[index72, index73].wall = (byte) 0;
}
}
}
else
{
int index74 = Main.maxTilesX - WorldGen.genRand.Next(125, 200) - 50;
int maxTilesX = Main.maxTilesX;
if (dungeonSide == -1)
index74 = Main.maxTilesX - 275;
float num97 = 1f;
int num98 = 0;
int index75 = 0;
while (!Main.tile[index74, index75].active())
++index75;
index67 = index75;
int num99 = index75 + WorldGen.genRand.Next(1, 5);
for (int index76 = index74; index76 < maxTilesX; ++index76)
{
++num98;
if (num98 < 3)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.2f;
else if (num98 < 6)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.15f;
else if (num98 < 9)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.1f;
else if (num98 < 15)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.07f;
else if (num98 < 50)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.05f;
else if (num98 < 75)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.04f;
else if (num98 < 100)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.03f;
else if (num98 < 125)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.02f;
else if (num98 < 150)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.01f;
else if (num98 < 175)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.005f;
else if (num98 < 200)
num97 += (float) WorldGen.genRand.Next(10, 20) * (1f / 1000f);
else if (num98 < 230)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.01f;
else if (num98 < 235)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.05f;
else if (num98 < 240)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.1f;
else if (num98 < 245)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.05f;
else if (num98 < (int) byte.MaxValue)
num97 += (float) WorldGen.genRand.Next(10, 20) * 0.01f;
if (num98 == 235)
index69 = index76;
int num100 = WorldGen.genRand.Next(15, 20);
for (int index77 = 0; (double) index77 < (double) num99 + (double) num97 + (double) num100; ++index77)
{
if ((double) index77 < (double) num99 + (double) num97 * 0.75 - 3.0 && (double) index77 < Main.worldSurface - 2.0)
{
Main.tile[index76, index77].active(false);
if (index77 > num99)
Main.tile[index76, index77].liquid = byte.MaxValue;
else if (index77 == num99)
Main.tile[index76, index77].liquid = (byte) 127;
}
else if (index77 > num99)
{
Main.tile[index76, index77].type = (ushort) 53;
Main.tile[index76, index77].active(true);
}
Main.tile[index76, index77].wall = (byte) 0;
}
}
}
}
while (!Main.tile[index68, index66].active())
++index66;
int num101 = index66 + 1;
while (!Main.tile[index69, index67].active())
++index67;
int num102 = index67 + 1;
}));
WorldGen.AddGenerationPass("Gems", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[23].Value;
for (int type = 63; type <= 68; ++type)
{
float num103 = 0.0f;
switch (type)
{
case 63:
num103 = (float) Main.maxTilesX * 0.3f;
break;
case 64:
num103 = (float) Main.maxTilesX * 0.1f;
break;
case 65:
num103 = (float) Main.maxTilesX * 0.25f;
break;
case 66:
num103 = (float) Main.maxTilesX * 0.45f;
break;
case 67:
num103 = (float) Main.maxTilesX * 0.5f;
break;
case 68:
num103 = (float) Main.maxTilesX * 0.05f;
break;
}
float num104 = num103 * 0.2f;
for (int index = 0; (double) index < (double) num104; ++index)
{
int i = WorldGen.genRand.Next(0, Main.maxTilesX);
int j;
for (j = WorldGen.genRand.Next((int) Main.worldSurface, Main.maxTilesY); Main.tile[i, j].type != (ushort) 1; j = WorldGen.genRand.Next((int) Main.worldSurface, Main.maxTilesY))
i = WorldGen.genRand.Next(0, Main.maxTilesX);
WorldGen.TileRunner(i, j, (double) WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(3, 7), type);
}
}
for (int index78 = 0; index78 < 2; ++index78)
{
int num105 = 1;
int num106 = 5;
int num107 = Main.maxTilesX - 5;
if (index78 == 1)
{
num105 = -1;
num106 = Main.maxTilesX - 5;
num107 = 5;
}
for (int index79 = num106; index79 != num107; index79 += num105)
{
for (int index80 = 10; index80 < Main.maxTilesY - 10; ++index80)
{
if (Main.tile[index79, index80].active() && Main.tile[index79, index80 + 1].active() && Main.tileSand[(int) Main.tile[index79, index80].type] && Main.tileSand[(int) Main.tile[index79, index80 + 1].type])
{
ushort type = Main.tile[index79, index80].type;
int index81 = index79 + num105;
int index82 = index80 + 1;
if (!Main.tile[index81, index80].active() && !Main.tile[index81, index80 + 1].active())
{
while (!Main.tile[index81, index82].active())
++index82;
int index83 = index82 - 1;
Main.tile[index79, index80].active(false);
Main.tile[index81, index83].active(true);
Main.tile[index81, index83].type = type;
}
}
}
}
}
}));
WorldGen.AddGenerationPass("Gravitating Sand", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[24].Value;
for (int x = 0; x < Main.maxTilesX; ++x)
{
float num108 = (float) x / (float) (Main.maxTilesX - 1);
progress.Set(num108);
bool flag = false;
int num109 = 0;
for (int y = Main.maxTilesY - 1; y > 0; --y)
{
if (WorldGen.SolidOrSlopedTile(x, y))
{
ushort type = Main.tile[x, y].type;
if (flag && y < (int) Main.worldSurface && y != num109 - 1 && TileID.Sets.Falling[(int) type])
{
for (int index = y; index < num109; ++index)
{
Main.tile[x, index].type = type;
Main.tile[x, index].active(true);
}
}
flag = true;
num109 = y;
}
}
}
}));
WorldGen.AddGenerationPass("Clean Up Dirt", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[25].Value;
for (int index84 = 3; index84 < Main.maxTilesX - 3; ++index84)
{
float num = (float) index84 / (float) Main.maxTilesX;
progress.Set(0.5f * num);
bool flag = true;
for (int index85 = 0; (double) index85 < Main.worldSurface; ++index85)
{
if (flag)
{
if (Main.tile[index84, index85].wall == (byte) 2 || Main.tile[index84, index85].wall == (byte) 40 || Main.tile[index84, index85].wall == (byte) 64)
Main.tile[index84, index85].wall = (byte) 0;
if (Main.tile[index84, index85].type != (ushort) 53 && Main.tile[index84, index85].type != (ushort) 112 && Main.tile[index84, index85].type != (ushort) 234)
{
if (Main.tile[index84 - 1, index85].wall == (byte) 2 || Main.tile[index84 - 1, index85].wall == (byte) 40 || Main.tile[index84 - 1, index85].wall == (byte) 40)
Main.tile[index84 - 1, index85].wall = (byte) 0;
if ((Main.tile[index84 - 2, index85].wall == (byte) 2 || Main.tile[index84 - 2, index85].wall == (byte) 40 || Main.tile[index84 - 2, index85].wall == (byte) 40) && WorldGen.genRand.Next(2) == 0)
Main.tile[index84 - 2, index85].wall = (byte) 0;
if ((Main.tile[index84 - 3, index85].wall == (byte) 2 || Main.tile[index84 - 3, index85].wall == (byte) 40 || Main.tile[index84 - 3, index85].wall == (byte) 40) && WorldGen.genRand.Next(2) == 0)
Main.tile[index84 - 3, index85].wall = (byte) 0;
if (Main.tile[index84 + 1, index85].wall == (byte) 2 || Main.tile[index84 + 1, index85].wall == (byte) 40 || Main.tile[index84 + 1, index85].wall == (byte) 40)
Main.tile[index84 + 1, index85].wall = (byte) 0;
if ((Main.tile[index84 + 2, index85].wall == (byte) 2 || Main.tile[index84 + 2, index85].wall == (byte) 40 || Main.tile[index84 + 2, index85].wall == (byte) 40) && WorldGen.genRand.Next(2) == 0)
Main.tile[index84 + 2, index85].wall = (byte) 0;
if ((Main.tile[index84 + 3, index85].wall == (byte) 2 || Main.tile[index84 + 3, index85].wall == (byte) 40 || Main.tile[index84 + 3, index85].wall == (byte) 40) && WorldGen.genRand.Next(2) == 0)
Main.tile[index84 + 3, index85].wall = (byte) 0;
if (Main.tile[index84, index85].active())
flag = false;
}
}
else if (Main.tile[index84, index85].wall == (byte) 0 && Main.tile[index84, index85 + 1].wall == (byte) 0 && Main.tile[index84, index85 + 2].wall == (byte) 0 && Main.tile[index84, index85 + 3].wall == (byte) 0 && Main.tile[index84, index85 + 4].wall == (byte) 0 && Main.tile[index84 - 1, index85].wall == (byte) 0 && Main.tile[index84 + 1, index85].wall == (byte) 0 && Main.tile[index84 - 2, index85].wall == (byte) 0 && Main.tile[index84 + 2, index85].wall == (byte) 0 && !Main.tile[index84, index85].active() && !Main.tile[index84, index85 + 1].active() && !Main.tile[index84, index85 + 2].active() && !Main.tile[index84, index85 + 3].active())
flag = true;
}
}
for (int index86 = Main.maxTilesX - 5; index86 >= 5; --index86)
{
float num = (float) index86 / (float) Main.maxTilesX;
progress.Set((float) (1.0 - 0.5 * (double) num));
bool flag = true;
for (int index87 = 0; (double) index87 < Main.worldSurface; ++index87)
{
if (flag)
{
if (Main.tile[index86, index87].wall == (byte) 2 || Main.tile[index86, index87].wall == (byte) 40 || Main.tile[index86, index87].wall == (byte) 64)
Main.tile[index86, index87].wall = (byte) 0;
if (Main.tile[index86, index87].type != (ushort) 53)
{
if (Main.tile[index86 - 1, index87].wall == (byte) 2 || Main.tile[index86 - 1, index87].wall == (byte) 40 || Main.tile[index86 - 1, index87].wall == (byte) 40)
Main.tile[index86 - 1, index87].wall = (byte) 0;
if ((Main.tile[index86 - 2, index87].wall == (byte) 2 || Main.tile[index86 - 2, index87].wall == (byte) 40 || Main.tile[index86 - 2, index87].wall == (byte) 40) && WorldGen.genRand.Next(2) == 0)
Main.tile[index86 - 2, index87].wall = (byte) 0;
if ((Main.tile[index86 - 3, index87].wall == (byte) 2 || Main.tile[index86 - 3, index87].wall == (byte) 40 || Main.tile[index86 - 3, index87].wall == (byte) 40) && WorldGen.genRand.Next(2) == 0)
Main.tile[index86 - 3, index87].wall = (byte) 0;
if (Main.tile[index86 + 1, index87].wall == (byte) 2 || Main.tile[index86 + 1, index87].wall == (byte) 40 || Main.tile[index86 + 1, index87].wall == (byte) 40)
Main.tile[index86 + 1, index87].wall = (byte) 0;
if ((Main.tile[index86 + 2, index87].wall == (byte) 2 || Main.tile[index86 + 2, index87].wall == (byte) 40 || Main.tile[index86 + 2, index87].wall == (byte) 40) && WorldGen.genRand.Next(2) == 0)
Main.tile[index86 + 2, index87].wall = (byte) 0;
if ((Main.tile[index86 + 3, index87].wall == (byte) 2 || Main.tile[index86 + 3, index87].wall == (byte) 40 || Main.tile[index86 + 3, index87].wall == (byte) 40) && WorldGen.genRand.Next(2) == 0)
Main.tile[index86 + 3, index87].wall = (byte) 0;
if (Main.tile[index86, index87].active())
flag = false;
}
}
else if (Main.tile[index86, index87].wall == (byte) 0 && Main.tile[index86, index87 + 1].wall == (byte) 0 && Main.tile[index86, index87 + 2].wall == (byte) 0 && Main.tile[index86, index87 + 3].wall == (byte) 0 && Main.tile[index86, index87 + 4].wall == (byte) 0 && Main.tile[index86 - 1, index87].wall == (byte) 0 && Main.tile[index86 + 1, index87].wall == (byte) 0 && Main.tile[index86 - 2, index87].wall == (byte) 0 && Main.tile[index86 + 2, index87].wall == (byte) 0 && !Main.tile[index86, index87].active() && !Main.tile[index86, index87 + 1].active() && !Main.tile[index86, index87 + 2].active() && !Main.tile[index86, index87 + 3].active())
flag = true;
}
}
}));
WorldGen.AddGenerationPass("Pyramids", (WorldGenLegacyMethod) (progress =>
{
for (int index88 = 0; index88 < numPyr; ++index88)
{
int i = PyrX[index88];
int index89 = PyrY[index88];
if (i > 300 && i < Main.maxTilesX - 300 && (dungeonSide >= 0 || (double) i >= (double) WorldGen.dungeonX + (double) Main.maxTilesX * 0.15) && (dungeonSide <= 0 || (double) i <= (double) WorldGen.dungeonX - (double) Main.maxTilesX * 0.15))
{
while (!Main.tile[i, index89].active() && (double) index89 < Main.worldSurface)
++index89;
if ((double) index89 < Main.worldSurface && Main.tile[i, index89].type == (ushort) 53)
{
int num110 = Main.maxTilesX;
for (int index90 = 0; index90 < index88; ++index90)
{
int num111 = Math.Abs(i - PyrX[index90]);
if (num111 < num110)
num110 = num111;
}
if (num110 >= 250)
{
int j = index89 - 1;
WorldGen.Pyramid(i, j);
}
}
}
}
}));
WorldGen.AddGenerationPass("Dirt Rock Wall Runner", (WorldGenLegacyMethod) (progress =>
{
for (int index = 0; index < Main.maxTilesX; ++index)
{
int i = WorldGen.genRand.Next(10, Main.maxTilesX - 10);
int j = WorldGen.genRand.Next(10, (int) Main.worldSurface);
if (Main.tile[i, j].wall == (byte) 2)
WorldGen.DirtyRockRunner(i, j);
}
}));
WorldGen.AddGenerationPass("Living Trees", (WorldGenLegacyMethod) (progress =>
{
int num112 = WorldGen.genRand.Next(0, (int) (3.0 * (double) (Main.maxTilesX / 4200)));
for (int index91 = 0; index91 < num112; ++index91)
{
bool flag10 = false;
int num113 = 0;
while (!flag10)
{
++num113;
if (num113 > 1000)
flag10 = true;
int i = WorldGen.genRand.Next(300, Main.maxTilesX - 300);
if (i <= Main.maxTilesX / 2 - 100 || i >= Main.maxTilesX / 2 + 100)
{
int index92 = 0;
while (!Main.tile[i, index92].active() && (double) index92 < Main.worldSurface)
++index92;
if (Main.tile[i, index92].type == (ushort) 0)
{
int j = index92 - 1;
if (j > 150)
{
bool flag11 = true;
for (int index93 = i - 50; index93 < i + 50; ++index93)
{
for (int index94 = j - 50; index94 < j + 50; ++index94)
{
if (Main.tile[index93, index94].active())
{
switch (Main.tile[index93, index94].type)
{
case 41:
case 43:
case 44:
case 189:
case 196:
flag11 = false;
continue;
default:
continue;
}
}
}
}
if (flag11)
flag10 = WorldGen.GrowLivingTree(i, j);
}
}
}
}
}
Main.tileSolid[192] = false;
}));
WorldGen.AddGenerationPass("Wood Tree Walls", (WorldGenLegacyMethod) (progress =>
{
for (int index95 = 25; index95 < Main.maxTilesX - 25; ++index95)
{
for (int index96 = 25; (double) index96 < Main.worldSurface; ++index96)
{
if (Main.tile[index95, index96].type == (ushort) 191 || Main.tile[index95, index96 - 1].type == (ushort) 191 || Main.tile[index95 - 1, index96].type == (ushort) 191 || Main.tile[index95 + 1, index96].type == (ushort) 191 || Main.tile[index95, index96 + 1].type == (ushort) 191)
{
bool flag = true;
for (int index97 = index95 - 1; index97 <= index95 + 1; ++index97)
{
for (int index98 = index96 - 1; index98 <= index96 + 1; ++index98)
{
if (index97 != index95 && index98 != index96 && Main.tile[index97, index98].type != (ushort) 191 && Main.tile[index97, index98].wall != (byte) 78)
flag = false;
}
}
if (flag)
Main.tile[index95, index96].wall = (byte) 78;
}
}
}
}));
WorldGen.AddGenerationPass("Altars", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[26].Value;
int num = (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 1.99999994947575E-05);
for (int index99 = 0; index99 < num; ++index99)
{
progress.Set((float) index99 / (float) num);
for (int index100 = 0; index100 < 10000; ++index100)
{
int x = WorldGen.genRand.Next(1, Main.maxTilesX - 3);
int y = (int) (worldSurfaceHigh + 20.0);
int style = WorldGen.crimson ? 1 : 0;
WorldGen.Place3x2(x, y, (ushort) 26, style);
if (Main.tile[x, y].type == (ushort) 26)
break;
}
}
}));
WorldGen.AddGenerationPass("Wet Jungle", (WorldGenLegacyMethod) (progress =>
{
for (int index = 0; index < Main.maxTilesX; ++index)
{
i2 = index;
for (int worldSurfaceLow = (int) WorldGen.worldSurfaceLow; (double) worldSurfaceLow < Main.worldSurface - 1.0; ++worldSurfaceLow)
{
if (Main.tile[i2, worldSurfaceLow].active())
{
if (Main.tile[i2, worldSurfaceLow].type == (ushort) 60)
{
Main.tile[i2, worldSurfaceLow - 1].liquid = byte.MaxValue;
Main.tile[i2, worldSurfaceLow - 2].liquid = byte.MaxValue;
break;
}
break;
}
}
}
}));
WorldGen.AddGenerationPass("Remove Water From Sand", (WorldGenLegacyMethod) (progress =>
{
label_10:
for (int index101 = 400; index101 < Main.maxTilesX - 400; ++index101)
{
i2 = index101;
for (int worldSurfaceLow = (int) WorldGen.worldSurfaceLow; (double) worldSurfaceLow < Main.worldSurface - 1.0; ++worldSurfaceLow)
{
if (Main.tile[i2, worldSurfaceLow].active())
{
switch (Main.tile[i2, worldSurfaceLow].type)
{
case 53:
case 396:
case 397:
case 404:
case 407:
int index102 = worldSurfaceLow;
while ((double) index102 > WorldGen.worldSurfaceLow)
{
--index102;
Main.tile[i2, index102].liquid = (byte) 0;
}
goto label_10;
default:
goto label_10;
}
}
}
}
Main.tileSolid[192] = true;
}));
WorldGen.AddGenerationPass("Jungle Temple", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[70].Value;
bool flag = true;
while (flag)
{
int y = WorldGen.genRand.Next((int) Main.rockLayer, Main.maxTilesY - 500);
int x = dungeonSide >= 0 ? WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.15), (int) ((double) Main.maxTilesX * 0.4)) : WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.6), (int) ((double) Main.maxTilesX * 0.85));
if (Main.tile[x, y].active() && Main.tile[x, y].type == (ushort) 60)
{
flag = false;
WorldGen.makeTemple(x, y);
}
}
}));
WorldGen.AddGenerationPass("Hives", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[71].Value;
float num114 = (float) (Main.maxTilesX / 4200);
float num115 = (float) (1 + WorldGen.genRand.Next((int) (5.0 * (double) num114), (int) (8.0 * (double) num114)));
int num116 = 10000;
label_6:
while ((double) num115 > 0.0 && num116 > 0)
{
--num116;
Point origin = WorldGen.RandomWorldPoint((int) (Main.worldSurface + Main.rockLayer) >> 1, 20, 300, 20);
if (Terraria.World.Generation.Biomes<HiveBiome>.Place(origin, structures))
{
--num115;
int num117 = WorldGen.genRand.Next(5);
int num118 = 0;
int num119 = 10000;
while (true)
{
int x;
int y;
do
{
if (num118 < num117 && num119 > 0)
{
float num120 = (float) ((double) WorldGen.genRand.NextFloat() * 60.0 + 30.0);
double a;
x = (int) (Math.Cos(a = (double) WorldGen.genRand.NextFloat() * 6.28318548202515) * (double) num120) + origin.X;
y = (int) (Math.Sin(a) * (double) num120) + origin.Y;
--num119;
}
else
goto label_6;
}
while (x <= 50 || x >= Main.maxTilesX - 50 || !Terraria.World.Generation.Biomes<HoneyPatchBiome>.Place(x, y, structures));
++num118;
}
}
}
}));
WorldGen.AddGenerationPass("Jungle Chests", (WorldGenLegacyMethod) (progress =>
{
WorldGen.genRand.Next(40, Main.maxTilesX - 40);
WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 400);
float num121 = (float) WorldGen.genRand.Next(7, 12) * (float) (Main.maxTilesX / 4200);
for (int index103 = 0; (double) index103 < (double) num121; ++index103)
{
bool flag12 = true;
while (flag12)
{
int index104 = WorldGen.genRand.Next(40, Main.maxTilesX / 2 - 40);
if (dungeonSide < 0)
index104 += Main.maxTilesX / 2;
int index105 = WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 400);
if (Main.tile[index104, index105].type == (ushort) 60)
{
int num122 = 30;
flag12 = false;
for (int index106 = index104 - num122; index106 < index104 + num122; index106 += 3)
{
for (int index107 = index105 - num122; index107 < index105 + num122; index107 += 3)
{
if (Main.tile[index106, index107].active() && (Main.tile[index106, index107].type == (ushort) 225 || Main.tile[index106, index107].type == (ushort) 229 || Main.tile[index106, index107].type == (ushort) 226 || Main.tile[index106, index107].type == (ushort) 119 || Main.tile[index106, index107].type == (ushort) 120))
flag12 = false;
if (Main.tile[index106, index107].wall == (byte) 86 || Main.tile[index106, index107].wall == (byte) 87)
flag12 = false;
}
}
}
if (!flag12)
{
int num123 = WorldGen.genRand.Next(2, 4);
int num124 = WorldGen.genRand.Next(2, 4);
int num125 = 0;
switch (jungleHut)
{
case 45:
num125 = 10;
break;
case 119:
num125 = 23;
break;
case 120:
num125 = 24;
break;
case 158:
num125 = 42;
break;
case 175:
num125 = 45;
break;
}
for (int index108 = index104 - num123 - 1; index108 <= index104 + num123 + 1; ++index108)
{
for (int index109 = index105 - num124 - 1; index109 <= index105 + num124 + 1; ++index109)
{
Main.tile[index108, index109].active(true);
Main.tile[index108, index109].type = jungleHut;
Main.tile[index108, index109].liquid = (byte) 0;
Main.tile[index108, index109].lava(false);
}
}
for (int index110 = index104 - num123; index110 <= index104 + num123; ++index110)
{
for (int index111 = index105 - num124; index111 <= index105 + num124; ++index111)
{
Main.tile[index110, index111].active(false);
Main.tile[index110, index111].wall = (byte) num125;
}
}
bool flag13 = false;
int num126 = 0;
while (!flag13 && num126 < 100)
{
++num126;
int i = WorldGen.genRand.Next(index104 - num123, index104 + num123 + 1);
int j = WorldGen.genRand.Next(index105 - num124, index105 + num124 - 2);
WorldGen.PlaceTile(i, j, 4, true, style: 3);
if (Main.tile[i, j].type == (ushort) 4)
flag13 = true;
}
for (int index112 = index104 - num123 - 1; index112 <= index104 + num123 + 1; ++index112)
{
for (int index113 = index105 + num124 - 2; index113 <= index105 + num124; ++index113)
Main.tile[index112, index113].active(false);
}
for (int index114 = index104 - num123 - 1; index114 <= index104 + num123 + 1; ++index114)
{
for (int index115 = index105 + num124 - 2; index115 <= index105 + num124 - 1; ++index115)
Main.tile[index114, index115].active(false);
}
for (int index116 = index104 - num123 - 1; index116 <= index104 + num123 + 1; ++index116)
{
int num127 = 4;
for (int index117 = index105 + num124 + 2; !Main.tile[index116, index117].active() && index117 < Main.maxTilesY && num127 > 0; --num127)
{
Main.tile[index116, index117].active(true);
Main.tile[index116, index117].type = (ushort) 59;
++index117;
}
}
int num128 = num123 - WorldGen.genRand.Next(1, 3);
int index118 = index105 - num124 - 2;
while (num128 > -1)
{
for (int index119 = index104 - num128 - 1; index119 <= index104 + num128 + 1; ++index119)
{
Main.tile[index119, index118].active(true);
Main.tile[index119, index118].type = jungleHut;
}
num128 -= WorldGen.genRand.Next(1, 3);
--index118;
}
WorldGen.JChestX[WorldGen.numJChests] = index104;
WorldGen.JChestY[WorldGen.numJChests] = index105;
++WorldGen.numJChests;
}
}
}
Main.tileSolid[137] = false;
}));
WorldGen.AddGenerationPass("Smooth World", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[60].Value;
for (int index120 = 20; index120 < Main.maxTilesX - 20; ++index120)
{
float num = (float) index120 / (float) Main.maxTilesX;
progress.Set(num);
for (int index121 = 20; index121 < Main.maxTilesY - 20; ++index121)
{
if (Main.tile[index120, index121].type != (ushort) 48 && Main.tile[index120, index121].type != (ushort) 137 && Main.tile[index120, index121].type != (ushort) 232 && Main.tile[index120, index121].type != (ushort) 191 && Main.tile[index120, index121].type != (ushort) 151 && Main.tile[index120, index121].type != (ushort) 274)
{
if (!Main.tile[index120, index121 - 1].active())
{
if (WorldGen.SolidTile(index120, index121) && TileID.Sets.CanBeClearedDuringGeneration[(int) Main.tile[index120, index121].type])
{
if (!Main.tile[index120 - 1, index121].halfBrick() && !Main.tile[index120 + 1, index121].halfBrick() && Main.tile[index120 - 1, index121].slope() == (byte) 0 && Main.tile[index120 + 1, index121].slope() == (byte) 0)
{
if (WorldGen.SolidTile(index120, index121 + 1))
{
if (!WorldGen.SolidTile(index120 - 1, index121) && !Main.tile[index120 - 1, index121 + 1].halfBrick() && WorldGen.SolidTile(index120 - 1, index121 + 1) && WorldGen.SolidTile(index120 + 1, index121) && !Main.tile[index120 + 1, index121 - 1].active())
{
if (WorldGen.genRand.Next(2) == 0)
WorldGen.SlopeTile(index120, index121, 2);
else
WorldGen.PoundTile(index120, index121);
}
else if (!WorldGen.SolidTile(index120 + 1, index121) && !Main.tile[index120 + 1, index121 + 1].halfBrick() && WorldGen.SolidTile(index120 + 1, index121 + 1) && WorldGen.SolidTile(index120 - 1, index121) && !Main.tile[index120 - 1, index121 - 1].active())
{
if (WorldGen.genRand.Next(2) == 0)
WorldGen.SlopeTile(index120, index121, 1);
else
WorldGen.PoundTile(index120, index121);
}
else if (WorldGen.SolidTile(index120 + 1, index121 + 1) && WorldGen.SolidTile(index120 - 1, index121 + 1) && !Main.tile[index120 + 1, index121].active() && !Main.tile[index120 - 1, index121].active())
WorldGen.PoundTile(index120, index121);
if (WorldGen.SolidTile(index120, index121))
{
if (WorldGen.SolidTile(index120 - 1, index121) && WorldGen.SolidTile(index120 + 1, index121 + 2) && !Main.tile[index120 + 1, index121].active() && !Main.tile[index120 + 1, index121 + 1].active() && !Main.tile[index120 - 1, index121 - 1].active())
WorldGen.KillTile(index120, index121);
else if (WorldGen.SolidTile(index120 + 1, index121) && WorldGen.SolidTile(index120 - 1, index121 + 2) && !Main.tile[index120 - 1, index121].active() && !Main.tile[index120 - 1, index121 + 1].active() && !Main.tile[index120 + 1, index121 - 1].active())
WorldGen.KillTile(index120, index121);
else if (!Main.tile[index120 - 1, index121 + 1].active() && !Main.tile[index120 - 1, index121].active() && WorldGen.SolidTile(index120 + 1, index121) && WorldGen.SolidTile(index120, index121 + 2))
{
if (WorldGen.genRand.Next(5) == 0)
WorldGen.KillTile(index120, index121);
else if (WorldGen.genRand.Next(5) == 0)
WorldGen.PoundTile(index120, index121);
else
WorldGen.SlopeTile(index120, index121, 2);
}
else if (!Main.tile[index120 + 1, index121 + 1].active() && !Main.tile[index120 + 1, index121].active() && WorldGen.SolidTile(index120 - 1, index121) && WorldGen.SolidTile(index120, index121 + 2))
{
if (WorldGen.genRand.Next(5) == 0)
WorldGen.KillTile(index120, index121);
else if (WorldGen.genRand.Next(5) == 0)
WorldGen.PoundTile(index120, index121);
else
WorldGen.SlopeTile(index120, index121, 1);
}
}
}
if (WorldGen.SolidTile(index120, index121) && !Main.tile[index120 - 1, index121].active() && !Main.tile[index120 + 1, index121].active())
WorldGen.KillTile(index120, index121);
}
}
else if (!Main.tile[index120, index121].active() && Main.tile[index120, index121 + 1].type != (ushort) 151 && Main.tile[index120, index121 + 1].type != (ushort) 274)
{
if (Main.tile[index120 + 1, index121].type != (ushort) 190 && Main.tile[index120 + 1, index121].type != (ushort) 48 && Main.tile[index120 + 1, index121].type != (ushort) 232 && WorldGen.SolidTile(index120 - 1, index121 + 1) && WorldGen.SolidTile(index120 + 1, index121) && !Main.tile[index120 - 1, index121].active() && !Main.tile[index120 + 1, index121 - 1].active())
{
WorldGen.PlaceTile(index120, index121, (int) Main.tile[index120, index121 + 1].type);
if (WorldGen.genRand.Next(2) == 0)
WorldGen.SlopeTile(index120, index121, 2);
else
WorldGen.PoundTile(index120, index121);
}
if (Main.tile[index120 - 1, index121].type != (ushort) 190 && Main.tile[index120 - 1, index121].type != (ushort) 48 && Main.tile[index120 - 1, index121].type != (ushort) 232 && WorldGen.SolidTile(index120 + 1, index121 + 1) && WorldGen.SolidTile(index120 - 1, index121) && !Main.tile[index120 + 1, index121].active() && !Main.tile[index120 - 1, index121 - 1].active())
{
WorldGen.PlaceTile(index120, index121, (int) Main.tile[index120, index121 + 1].type);
if (WorldGen.genRand.Next(2) == 0)
WorldGen.SlopeTile(index120, index121, 1);
else
WorldGen.PoundTile(index120, index121);
}
}
}
else if (!Main.tile[index120, index121 + 1].active() && WorldGen.genRand.Next(2) == 0 && WorldGen.SolidTile(index120, index121) && !Main.tile[index120 - 1, index121].halfBrick() && !Main.tile[index120 + 1, index121].halfBrick() && Main.tile[index120 - 1, index121].slope() == (byte) 0 && Main.tile[index120 + 1, index121].slope() == (byte) 0 && WorldGen.SolidTile(index120, index121 - 1))
{
if (WorldGen.SolidTile(index120 - 1, index121) && !WorldGen.SolidTile(index120 + 1, index121) && WorldGen.SolidTile(index120 - 1, index121 - 1))
WorldGen.SlopeTile(index120, index121, 3);
else if (WorldGen.SolidTile(index120 + 1, index121) && !WorldGen.SolidTile(index120 - 1, index121) && WorldGen.SolidTile(index120 + 1, index121 - 1))
WorldGen.SlopeTile(index120, index121, 4);
}
if (TileID.Sets.Conversion.Sand[(int) Main.tile[index120, index121].type])
Tile.SmoothSlope(index120, index121, false);
}
}
}
for (int i = 20; i < Main.maxTilesX - 20; ++i)
{
for (int j = 20; j < Main.maxTilesY - 20; ++j)
{
if (WorldGen.genRand.Next(2) == 0 && !Main.tile[i, j - 1].active() && Main.tile[i, j].type != (ushort) 137 && Main.tile[i, j].type != (ushort) 48 && Main.tile[i, j].type != (ushort) 232 && Main.tile[i, j].type != (ushort) 191 && Main.tile[i, j].type != (ushort) 151 && Main.tile[i, j].type != (ushort) 274 && Main.tile[i, j].type != (ushort) 75 && Main.tile[i, j].type != (ushort) 76 && WorldGen.SolidTile(i, j) && Main.tile[i - 1, j].type != (ushort) 137 && Main.tile[i + 1, j].type != (ushort) 137)
{
if (WorldGen.SolidTile(i, j + 1) && WorldGen.SolidTile(i + 1, j) && !Main.tile[i - 1, j].active())
WorldGen.SlopeTile(i, j, 2);
if (WorldGen.SolidTile(i, j + 1) && WorldGen.SolidTile(i - 1, j) && !Main.tile[i + 1, j].active())
WorldGen.SlopeTile(i, j, 1);
}
if (Main.tile[i, j].slope() == (byte) 1 && !WorldGen.SolidTile(i - 1, j))
{
WorldGen.SlopeTile(i, j);
WorldGen.PoundTile(i, j);
}
if (Main.tile[i, j].slope() == (byte) 2 && !WorldGen.SolidTile(i + 1, j))
{
WorldGen.SlopeTile(i, j);
WorldGen.PoundTile(i, j);
}
}
}
Main.tileSolid[137] = true;
Main.tileSolid[190] = false;
Main.tileSolid[192] = false;
}));
WorldGen.AddGenerationPass("Settle Liquids", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[27].Value;
Liquid.QuickWater(3);
WorldGen.WaterCheck();
int num129 = 0;
Liquid.quickSettle = true;
while (num129 < 10)
{
int num130 = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
++num129;
float num131 = 0.0f;
while (Liquid.numLiquid > 0)
{
float num132 = (float) (num130 - (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer)) / (float) num130;
if (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer > num130)
num130 = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
if ((double) num132 > (double) num131)
num131 = num132;
else
num132 = num131;
if (num129 == 1)
progress.Set((float) ((double) num132 / 3.0 + 0.330000013113022));
int num133 = 10;
if (num129 > num133)
;
Liquid.UpdateLiquid();
}
WorldGen.WaterCheck();
progress.Set((float) ((double) num129 * 0.100000001490116 / 3.0 + 0.660000026226044));
}
Liquid.quickSettle = false;
Main.tileSolid[190] = true;
}));
WorldGen.AddGenerationPass("Waterfalls", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[69].Value;
for (int i = 20; i < Main.maxTilesX - 20; ++i)
{
float num134 = (float) i / (float) Main.maxTilesX;
progress.Set(num134 * 0.5f);
for (int j = 20; j < Main.maxTilesY - 20; ++j)
{
if (WorldGen.SolidTile(i, j) && !Main.tile[i - 1, j].active() && WorldGen.SolidTile(i, j + 1) && !Main.tile[i + 1, j].active() && (Main.tile[i - 1, j].liquid > (byte) 0 || Main.tile[i + 1, j].liquid > (byte) 0))
{
bool flag = true;
int num135 = WorldGen.genRand.Next(8, 20);
int num136 = WorldGen.genRand.Next(8, 20);
int num137 = j - num135;
int num138 = num136 + j;
for (int index = num137; index <= num138; ++index)
{
if (Main.tile[i, index].halfBrick())
flag = false;
}
if ((Main.tile[i, j].type == (ushort) 75 || Main.tile[i, j].type == (ushort) 76) && WorldGen.genRand.Next(10) != 0)
flag = false;
if (flag)
WorldGen.PoundTile(i, j);
}
}
}
for (int i = 20; i < Main.maxTilesX - 20; ++i)
{
float num = (float) i / (float) Main.maxTilesX;
progress.Set((float) ((double) num * 0.5 + 0.5));
for (int j = 20; j < Main.maxTilesY - 20; ++j)
{
if (Main.tile[i, j].type != (ushort) 48 && Main.tile[i, j].type != (ushort) 232 && WorldGen.SolidTile(i, j) && WorldGen.SolidTile(i, j + 1))
{
if (!WorldGen.SolidTile(i + 1, j) && Main.tile[i - 1, j].halfBrick() && Main.tile[i - 2, j].liquid > (byte) 0)
WorldGen.PoundTile(i, j);
if (!WorldGen.SolidTile(i - 1, j) && Main.tile[i + 1, j].halfBrick() && Main.tile[i + 2, j].liquid > (byte) 0)
WorldGen.PoundTile(i, j);
}
}
}
}));
WorldGen.AddGenerationPass("Ice", (WorldGenLegacyMethod) (progress =>
{
for (int i = 10; i < Main.maxTilesX - 10; ++i)
{
for (int worldSurface2 = (int) Main.worldSurface; worldSurface2 < Main.maxTilesY - 100; ++worldSurface2)
{
if (Main.tile[i, worldSurface2].liquid > (byte) 0 && !Main.tile[i, worldSurface2].lava())
WorldGen.MakeWateryIceThing(i, worldSurface2);
}
}
Main.tileSolid[226] = false;
Main.tileSolid[162] = false;
}));
WorldGen.AddGenerationPass("Wall Variety", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[79].Value;
int num139 = (int) (300.0 * (double) ((float) (Main.maxTilesX * Main.maxTilesY) / 5040000f));
int num140 = num139;
ShapeData data = new ShapeData();
while (num139 > 0)
{
progress.Set((float) (1.0 - (double) num139 / (double) num140));
Point point = WorldGen.RandomWorldPoint((int) worldSurface, 2, 190, 2);
Tile tile1 = Main.tile[point.X, point.Y];
Tile tile2 = Main.tile[point.X, point.Y - 1];
byte type = 0;
if (tile1.type == (ushort) 59 || tile1.type == (ushort) 60)
type = (byte) (204 + WorldGen.genRand.Next(4));
else if (tile1.type == (ushort) 1 && tile2.wall == (byte) 0)
type = (double) point.Y >= rockLayer ? (point.Y >= WorldGen.lavaLine ? (byte) (208 + WorldGen.genRand.Next(4)) : (byte) (212 + WorldGen.genRand.Next(4))) : (byte) (196 + WorldGen.genRand.Next(4));
if (tile1.active() && type != (byte) 0 && !tile2.active())
{
bool foundInvalidTile = false;
bool flag = WorldUtils.Gen(new Point(point.X, point.Y - 1), (GenShape) new ShapeFloodFill(1000), Actions.Chain((GenAction) new Modifiers.IsNotSolid(), new Actions.Blank().Output(data), (GenAction) new Actions.ContinueWrapper(Actions.Chain((GenAction) new Modifiers.IsTouching(true, new ushort[5]
{
(ushort) 60,
(ushort) 147,
(ushort) 161,
(ushort) 396,
(ushort) 397
}), (GenAction) new Actions.Custom((GenBase.CustomPerUnitAction) ((x, y, args) =>
{
foundInvalidTile = true;
return true;
}))))));
if (data.Count > 50 & flag && !foundInvalidTile)
{
WorldUtils.Gen(new Point(point.X, point.Y), (GenShape) new ModShapes.OuterOutline(data, useInterior: true), (GenAction) new Actions.PlaceWall(type));
--num139;
}
data.Clear();
}
}
}));
WorldGen.AddGenerationPass("Traps", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[34].Value;
for (int index122 = 0; index122 < (int) ((double) Main.maxTilesX * 0.05); ++index122)
{
float num = (float) index122 / ((float) Main.maxTilesX * 0.05f);
progress.Set(num);
for (int index123 = 0; index123 < 1150; ++index123)
{
int x2 = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
int y2 = WorldGen.genRand.Next((int) Main.worldSurface, Main.maxTilesY - 210);
if (Main.tile[x2, y2].wall == (byte) 0 && WorldGen.placeTrap(x2, y2))
break;
}
}
}));
WorldGen.AddGenerationPass("Life Crystals", (WorldGenLegacyMethod) (progress =>
{
dub2 = (float) (Main.maxTilesX / 4200);
progress.Message = Lang.gen[28].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 2E-05); ++index)
{
float num141 = (float) index / ((float) (Main.maxTilesX * Main.maxTilesY) * 2E-05f);
progress.Set(num141);
bool flag = false;
int num142 = 0;
while (!flag)
{
if (WorldGen.AddLifeCrystal(WorldGen.genRand.Next(40, Main.maxTilesX - 40), WorldGen.genRand.Next((int) (worldSurfaceHigh + 20.0), Main.maxTilesY - 300)))
{
flag = true;
}
else
{
++num142;
if (num142 >= 10000)
flag = true;
}
}
}
Main.tileSolid[225] = false;
}));
WorldGen.AddGenerationPass("Statues", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[29].Value;
int index124 = 0;
int num143 = (int) ((double) (WorldGen.statueList.Length * 2) * (double) dub2);
for (int index125 = 0; index125 < num143; ++index125)
{
if (index124 >= WorldGen.statueList.Length)
index124 = 0;
int x = (int) WorldGen.statueList[index124].X;
int y = (int) WorldGen.statueList[index124].Y;
float num144 = (float) (index125 / num143);
progress.Set(num144);
bool flag = false;
int num145 = 0;
while (!flag)
{
int index126 = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
int index127 = WorldGen.genRand.Next((int) (worldSurfaceHigh + 20.0), Main.maxTilesY - 300);
while (!Main.tile[index126, index127].active())
++index127;
int index128 = index127 - 1;
WorldGen.PlaceTile(index126, index128, x, true, true, style: y);
if (Main.tile[index126, index128].active() && (int) Main.tile[index126, index128].type == x)
{
flag = true;
if (WorldGen.StatuesWithTraps.Contains(index124))
WorldGen.PlaceStatueTrap(index126, index128);
++index124;
}
else
{
++num145;
if (num145 >= 10000)
flag = true;
}
}
}
}));
WorldGen.AddGenerationPass("Buried Chests", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[30].Value;
Main.tileSolid[226] = true;
Main.tileSolid[162] = true;
Main.tileSolid[225] = true;
for (int index129 = 0; index129 < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 1.6E-05); ++index129)
{
float num146 = (float) index129 / ((float) (Main.maxTilesX * Main.maxTilesY) * 1.6E-05f);
progress.Set(num146);
bool flag = false;
int num147 = 0;
while (!flag)
{
float num148 = (float) WorldGen.genRand.Next((int) (5.0 * (double) dub2), (int) (8.0 * (double) dub2 + 1.0));
int i = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
int j = WorldGen.genRand.Next((int) (worldSurfaceHigh + 20.0), Main.maxTilesY - 230);
if ((double) index129 <= (double) num148)
j = WorldGen.genRand.Next(Main.maxTilesY - 200, Main.maxTilesY - 50);
int num149 = 0;
while (Main.wallDungeon[(int) Main.tile[i, j].wall])
{
++num149;
i = WorldGen.genRand.Next(1, Main.maxTilesX);
j = WorldGen.genRand.Next((int) (worldSurfaceHigh + 20.0), Main.maxTilesY - 230);
if (num149 < 1000 && (double) index129 <= (double) num148)
j = WorldGen.genRand.Next(Main.maxTilesY - 200, Main.maxTilesY - 50);
}
if ((double) index129 > (double) num148)
{
for (int index130 = 10; index130 > 0; --index130)
{
if (Terraria.World.Generation.Biomes<CaveHouseBiome>.Place(WorldGen.genRand.Next(80, Main.maxTilesX - 80), WorldGen.genRand.Next((int) (worldSurfaceHigh + 20.0), Main.maxTilesY - 230), structures))
{
flag = true;
break;
}
}
}
else if (WorldGen.AddBuriedChest(i, j))
flag = true;
++num147;
if (num147 >= 1000)
flag = true;
}
}
int num = (int) (2.0 * (double) (Main.maxTilesX * Main.maxTilesY) / 5040000.0);
for (int index = 1000; index >= 0 && num >= 0; --index)
{
if (Terraria.World.Generation.Biomes<CaveHouseBiome>.Place(WorldGen.RandomRectanglePoint(WorldGen.UndergroundDesertLocation), structures))
--num;
}
Main.tileSolid[226] = false;
Main.tileSolid[162] = false;
Main.tileSolid[225] = false;
}));
WorldGen.AddGenerationPass("Surface Chests", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[31].Value;
for (int index = 0; index < (int) ((double) Main.maxTilesX * 0.005); ++index)
{
float num150 = (float) index / ((float) Main.maxTilesX * 0.005f);
progress.Set(num150);
bool flag14 = false;
int num151 = 0;
while (!flag14)
{
int i = WorldGen.genRand.Next(300, Main.maxTilesX - 300);
int j = WorldGen.genRand.Next((int) WorldGen.worldSurfaceLow, (int) Main.worldSurface);
bool flag15 = false;
if (Main.tile[i, j].wall == (byte) 2 && !Main.tile[i, j].active())
flag15 = true;
if (flag15 && WorldGen.AddBuriedChest(i, j, notNearOtherChests: true))
{
flag14 = true;
}
else
{
++num151;
if (num151 >= 2000)
flag14 = true;
}
}
}
}));
WorldGen.AddGenerationPass("Jungle Chests Placement", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[32].Value;
for (int index131 = 0; index131 < WorldGen.numJChests; ++index131)
{
float num = (float) (index131 / WorldGen.numJChests);
progress.Set(num);
int nextJungleChestItem = WorldGen.GetNextJungleChestItem();
if (!WorldGen.AddBuriedChest(WorldGen.JChestX[index131] + WorldGen.genRand.Next(2), WorldGen.JChestY[index131], nextJungleChestItem, Style: 10))
{
for (int i = WorldGen.JChestX[index131] - 1; i <= WorldGen.JChestX[index131] + 1; ++i)
{
for (int j = WorldGen.JChestY[index131]; j <= WorldGen.JChestY[index131] + 2; ++j)
WorldGen.KillTile(i, j);
}
for (int index132 = WorldGen.JChestX[index131] - 1; index132 <= WorldGen.JChestX[index131] + 1; ++index132)
{
for (int index133 = WorldGen.JChestY[index131]; index133 <= WorldGen.JChestY[index131] + 3; ++index133)
{
if (index133 < Main.maxTilesY)
{
Main.tile[index132, index133].slope((byte) 0);
Main.tile[index132, index133].halfBrick(false);
}
}
}
WorldGen.AddBuriedChest(WorldGen.JChestX[index131], WorldGen.JChestY[index131], nextJungleChestItem, Style: 10);
}
}
}));
WorldGen.AddGenerationPass("Water Chests", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[33].Value;
int num152 = 0;
for (int index = 0; (double) index < 9.0 * (double) dub2; ++index)
{
float num153 = (float) index / (9f * dub2);
progress.Set(num153);
++num152;
int contain;
if (WorldGen.genRand.Next(15) == 0)
{
contain = 863;
}
else
{
switch (num152)
{
case 1:
contain = 186;
break;
case 2:
contain = 277;
break;
default:
contain = 187;
num152 = 0;
break;
}
}
int i12;
int j11;
for (bool flag = false; !flag; flag = WorldGen.AddBuriedChest(i12, j11, contain, Style: 17))
{
i12 = WorldGen.genRand.Next(1, Main.maxTilesX);
for (j11 = WorldGen.genRand.Next(1, Main.maxTilesY - 200); Main.tile[i12, j11].liquid < (byte) 200 || Main.tile[i12, j11].lava(); j11 = WorldGen.genRand.Next(1, Main.maxTilesY - 200))
i12 = WorldGen.genRand.Next(1, Main.maxTilesX);
}
int i13;
int j12;
for (bool flag = false; !flag; flag = WorldGen.AddBuriedChest(i13, j12, contain, Style: 17))
{
i13 = WorldGen.genRand.Next(1, Main.maxTilesX);
for (j12 = WorldGen.genRand.Next((int) Main.worldSurface, Main.maxTilesY - 200); Main.tile[i13, j12].liquid < (byte) 200 || Main.tile[i13, j12].lava(); j12 = WorldGen.genRand.Next(1, Main.maxTilesY - 200))
i13 = WorldGen.genRand.Next(1, Main.maxTilesX);
}
}
}));
WorldGen.AddGenerationPass("Spider Caves", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[64].Value;
WorldGen.maxTileCount = 3500;
for (int index134 = 0; index134 < (int) ((double) Main.maxTilesX * 0.005); ++index134)
{
float num154 = (float) index134 / ((float) Main.maxTilesX * 0.005f);
progress.Set(num154);
int num155 = 0;
int x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
int y = WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 230);
for (int index135 = WorldGen.countTiles(x, y, lavaOk: true); (index135 >= 3500 || index135 < 500) && num155 < 500; index135 = WorldGen.countTiles(x, y, lavaOk: true))
{
++num155;
x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
y = WorldGen.genRand.Next((int) Main.rockLayer + 30, Main.maxTilesY - 230);
}
if (num155 < 500)
WorldGen.Spread.Spider(x, y);
}
Main.tileSolid[162] = true;
}));
WorldGen.AddGenerationPass("Gem Caves", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[64].Value;
WorldGen.maxTileCount = 300;
for (int index136 = 0; index136 < (int) ((double) Main.maxTilesX * 0.003); ++index136)
{
float num156 = (float) index136 / ((float) Main.maxTilesX * (3f / 1000f));
progress.Set(num156);
int num157 = 0;
int x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
int y = WorldGen.genRand.Next((int) Main.rockLayer + 30, Main.maxTilesY - 230);
for (int index137 = WorldGen.countTiles(x, y); (index137 >= 300 || index137 < 50 || WorldGen.lavaCount > 0 || WorldGen.iceCount > 0 || WorldGen.rockCount == 0) && num157 < 1000; index137 = WorldGen.countTiles(x, y))
{
++num157;
x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
y = WorldGen.genRand.Next((int) Main.rockLayer + 30, Main.maxTilesY - 230);
}
if (num157 < 1000)
WorldGen.gemCave(x, y);
}
}));
WorldGen.AddGenerationPass("Moss", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[61].Value;
WorldGen.randMoss();
WorldGen.maxTileCount = 2500;
for (int index138 = 0; index138 < (int) ((double) Main.maxTilesX * 0.01); ++index138)
{
float num158 = (float) index138 / ((float) Main.maxTilesX * 0.01f);
progress.Set(num158);
int num159 = 0;
int x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
int y = WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, WorldGen.waterLine);
for (int index139 = WorldGen.countTiles(x, y); (index139 >= 2500 || index139 < 10 || WorldGen.lavaCount > 0 || WorldGen.iceCount > 0 || WorldGen.rockCount == 0) && num159 < 1000; index139 = WorldGen.countTiles(x, y))
{
++num159;
x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
y = WorldGen.genRand.Next((int) Main.rockLayer + 30, Main.maxTilesY - 230);
}
if (num159 < 1000)
{
WorldGen.setMoss(x, y);
WorldGen.Spread.Moss(x, y);
}
}
for (int index = 0; index < Main.maxTilesX; ++index)
{
int x = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
int y = WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, WorldGen.lavaLine);
if (Main.tile[x, y].type == (ushort) 1)
{
WorldGen.setMoss(x, y);
Main.tile[x, y].type = (ushort) WorldGen.mossTile;
}
}
float num160 = (float) Main.maxTilesX * 0.05f;
while ((double) num160 > 0.0)
{
int x = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
int y = WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, WorldGen.lavaLine);
if (Main.tile[x, y].type == (ushort) 1 && (!Main.tile[x - 1, y].active() || !Main.tile[x + 1, y].active() || !Main.tile[x, y - 1].active() || !Main.tile[x, y + 1].active()))
{
WorldGen.setMoss(x, y);
Main.tile[x, y].type = (ushort) WorldGen.mossTile;
--num160;
}
}
float num161 = (float) Main.maxTilesX * 0.065f;
while ((double) num161 > 0.0)
{
int index140 = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
int index141 = WorldGen.genRand.Next(WorldGen.waterLine, Main.maxTilesY - 200);
if (Main.tile[index140, index141].type == (ushort) 1 && (!Main.tile[index140 - 1, index141].active() || !Main.tile[index140 + 1, index141].active() || !Main.tile[index140, index141 - 1].active() || !Main.tile[index140, index141 + 1].active()))
{
int num162 = 25;
int num163 = 0;
for (int index142 = index140 - num162; index142 < index140 + num162; ++index142)
{
for (int index143 = index141 - num162; index143 < index141 + num162; ++index143)
{
if (Main.tile[index142, index143].liquid > (byte) 0 && Main.tile[index142, index143].lava())
++num163;
}
}
if (num163 > 20)
{
Main.tile[index140, index141].type = (ushort) 381;
--num161;
}
else
num161 -= 1f / 500f;
}
}
for (int index144 = 0; index144 < Main.maxTilesX; ++index144)
{
for (int index145 = 0; index145 < Main.maxTilesY; ++index145)
{
if (Main.tile[index144, index145].active() && Main.tileMoss[(int) Main.tile[index144, index145].type])
{
for (int index146 = 0; index146 < 4; ++index146)
{
int i = index144;
int j = index145;
if (index146 == 0)
--i;
if (index146 == 1)
++i;
if (index146 == 2)
--j;
if (index146 == 3)
++j;
try
{
WorldGen.grassSpread = 0;
WorldGen.SpreadGrass(i, j, 1, (int) Main.tile[index144, index145].type);
}
catch
{
WorldGen.grassSpread = 0;
WorldGen.SpreadGrass(i, j, 1, (int) Main.tile[index144, index145].type, false);
}
}
}
}
}
}));
WorldGen.AddGenerationPass("Temple", (WorldGenLegacyMethod) (progress =>
{
Main.tileSolid[162] = false;
Main.tileSolid[226] = true;
WorldGen.templePart2();
Main.tileSolid[232] = false;
}));
WorldGen.AddGenerationPass("Ice Walls", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[63].Value;
WorldGen.maxTileCount = 1500;
for (int index147 = 0; index147 < (int) ((double) Main.maxTilesX * 0.04); ++index147)
{
float num164 = (float) index147 / ((float) Main.maxTilesX * 0.04f);
progress.Set(num164 * 0.66f);
int num165 = 0;
int x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
int y = WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 220);
for (int index148 = WorldGen.countTiles(x, y, lavaOk: true); (index148 >= 1500 || index148 < 10) && num165 < 500; index148 = WorldGen.countTiles(x, y, lavaOk: true))
{
++num165;
x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
y = WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, Main.maxTilesY - 220);
}
if (num165 < 500)
{
int wallType = WorldGen.genRand.Next(2);
if (WorldGen.iceCount > 0)
{
switch (wallType)
{
case 0:
wallType = 40;
break;
case 1:
wallType = 71;
break;
}
}
else if (WorldGen.lavaCount > 0)
{
wallType = 79;
}
else
{
wallType = WorldGen.genRand.Next(4);
switch (wallType)
{
case 0:
wallType = 59;
break;
case 1:
wallType = 61;
break;
case 2:
wallType = 170;
break;
case 3:
wallType = 171;
break;
}
}
WorldGen.Spread.Wall(x, y, wallType);
}
}
WorldGen.maxTileCount = 1500;
for (int index = 0; index < (int) ((double) Main.maxTilesX * 0.02); ++index)
{
float num166 = (float) index / ((float) Main.maxTilesX * 0.02f);
progress.Set((float) ((double) num166 * 0.340000003576279 + 0.660000026226044));
int num167 = 0;
int x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
int y = WorldGen.genRand.Next((int) Main.worldSurface, WorldGen.lavaLine);
int num168 = 0;
if (Main.tile[x, y].wall == (byte) 64)
num168 = WorldGen.countTiles(x, y, true);
while ((num168 >= 1500 || num168 < 10) && num167 < 1000)
{
++num167;
x = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
y = WorldGen.genRand.Next((int) Main.worldSurface, WorldGen.lavaLine);
if (!Main.wallHouse[(int) Main.tile[x, y].wall])
num168 = Main.tile[x, y].wall != (byte) 64 ? 0 : WorldGen.countTiles(x, y, true);
}
if (num167 < 1000)
WorldGen.Spread.Wall2(x, y, 15);
}
}));
WorldGen.AddGenerationPass("Jungle Trees", (WorldGenLegacyMethod) (progress =>
{
for (int i = 0; i < Main.maxTilesX; ++i)
{
for (int y = (int) Main.worldSurface - 1; y < Main.maxTilesY - 350; ++y)
{
if (WorldGen.genRand.Next(10) == 0)
WorldGen.GrowUndergroundTree(i, y);
}
}
}));
WorldGen.AddGenerationPass("Floating Island Houses", (WorldGenLegacyMethod) (progress =>
{
for (int index = 0; index < WorldGen.numIslandHouses; ++index)
{
if (!WorldGen.skyLake[index])
WorldGen.IslandHouse(WorldGen.fihX[index], WorldGen.fihY[index]);
}
}));
WorldGen.AddGenerationPass("Quick Cleanup", (WorldGenLegacyMethod) (progress =>
{
Main.tileSolid[137] = false;
Main.tileSolid[130] = false;
for (int i = 20; i < Main.maxTilesX - 20; ++i)
{
for (int index = 20; index < Main.maxTilesY - 20; ++index)
{
if (Main.tile[i, index].type != (ushort) 19 && TileID.Sets.CanBeClearedDuringGeneration[(int) Main.tile[i, index].type])
{
if (Main.tile[i, index].topSlope() || Main.tile[i, index].halfBrick())
{
if (!WorldGen.SolidTile(i, index + 1))
Main.tile[i, index].active(false);
if (Main.tile[i + 1, index].type == (ushort) 137 || Main.tile[i - 1, index].type == (ushort) 137)
Main.tile[i, index].active(false);
}
else if (Main.tile[i, index].bottomSlope())
{
if (!WorldGen.SolidTile(i, index - 1))
Main.tile[i, index].active(false);
if (Main.tile[i + 1, index].type == (ushort) 137 || Main.tile[i - 1, index].type == (ushort) 137)
Main.tile[i, index].active(false);
}
}
}
}
}));
WorldGen.AddGenerationPass("Pots", (WorldGenLegacyMethod) (progress =>
{
Main.tileSolid[137] = true;
Main.tileSolid[130] = true;
progress.Message = Lang.gen[35].Value;
for (int index = 0; index < (int) ((double) (Main.maxTilesX * Main.maxTilesY) * 0.0008); ++index)
{
float num169 = (float) index / ((float) (Main.maxTilesX * Main.maxTilesY) * 0.0008f);
progress.Set(num169);
bool flag16 = false;
int num170 = 0;
while (!flag16)
{
int num171 = WorldGen.genRand.Next((int) worldSurfaceHigh, Main.maxTilesY - 10);
if ((double) num169 > 0.93)
num171 = Main.maxTilesY - 150;
else if ((double) num169 > 0.75)
num171 = (int) WorldGen.worldSurfaceLow;
int x = WorldGen.genRand.Next(1, Main.maxTilesX);
bool flag17 = false;
for (int y = num171; y < Main.maxTilesY; ++y)
{
if (!flag17)
{
if (Main.tile[x, y].active() && Main.tileSolid[(int) Main.tile[x, y].type] && !Main.tile[x, y - 1].lava())
flag17 = true;
}
else
{
int style = WorldGen.genRand.Next(0, 4);
int num172 = 0;
if (y < Main.maxTilesY - 5)
num172 = (int) Main.tile[x, y + 1].type;
if (num172 == 147 || num172 == 161 || num172 == 162)
style = WorldGen.genRand.Next(4, 7);
if (num172 == 60)
style = WorldGen.genRand.Next(7, 10);
if (Main.wallDungeon[(int) Main.tile[x, y].wall])
style = WorldGen.genRand.Next(10, 13);
if (num172 == 41 || num172 == 43 || num172 == 44)
style = WorldGen.genRand.Next(10, 13);
if (num172 == 22 || num172 == 23 || num172 == 25)
style = WorldGen.genRand.Next(16, 19);
if (num172 == 199 || num172 == 203 || num172 == 204 || num172 == 200)
style = WorldGen.genRand.Next(22, 25);
if (num172 == 367)
style = WorldGen.genRand.Next(31, 34);
if (num172 == 226)
style = WorldGen.genRand.Next(28, 31);
if (y > Main.maxTilesY - 200)
style = WorldGen.genRand.Next(13, 16);
if (WorldGen.PlacePot(x, y, style: style))
{
flag16 = true;
break;
}
++num170;
if (num170 >= 10000)
{
flag16 = true;
break;
}
}
}
}
}
}));
WorldGen.AddGenerationPass("Hellforge", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[36].Value;
for (int index149 = 0; index149 < Main.maxTilesX / 200; ++index149)
{
float num173 = (float) (index149 / (Main.maxTilesX / 200));
progress.Set(num173);
bool flag = false;
int num174 = 0;
while (!flag)
{
int i = WorldGen.genRand.Next(1, Main.maxTilesX);
int index150 = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 5);
try
{
if (Main.tile[i, index150].wall != (byte) 13)
{
if (Main.tile[i, index150].wall != (byte) 14)
continue;
}
while (!Main.tile[i, index150].active())
++index150;
int j = index150 - 1;
WorldGen.PlaceTile(i, j, 77);
if (Main.tile[i, j].type == (ushort) 77)
{
flag = true;
}
else
{
++num174;
if (num174 >= 10000)
flag = true;
}
}
catch
{
}
}
}
}));
WorldGen.AddGenerationPass("Spreading Grass", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[37].Value;
for (int index = 0; index < Main.maxTilesX; ++index)
{
i2 = index;
bool flag = true;
for (int j = 0; (double) j < Main.worldSurface - 1.0; ++j)
{
if (Main.tile[i2, j].active())
{
if (flag)
{
if (Main.tile[i2, j].type == (ushort) 0)
{
try
{
WorldGen.grassSpread = 0;
WorldGen.SpreadGrass(i2, j);
}
catch
{
WorldGen.grassSpread = 0;
WorldGen.SpreadGrass(i2, j, repeat: false);
}
}
}
if ((double) j <= worldSurfaceHigh)
flag = false;
else
break;
}
else if (Main.tile[i2, j].wall == (byte) 0)
flag = true;
}
}
}));
WorldGen.AddGenerationPass("Piles", (WorldGenLegacyMethod) (progress =>
{
Main.tileSolid[190] = false;
Main.tileSolid[196] = false;
Main.tileSolid[189] = false;
Main.tileSolid[202] = false;
for (int index151 = 0; (double) index151 < (double) Main.maxTilesX * 0.06; ++index151)
{
bool flag = false;
while (!flag)
{
int i14 = WorldGen.genRand.Next(25, Main.maxTilesX - 25);
int j13 = WorldGen.genRand.Next((int) Main.worldSurface, Main.maxTilesY - 300);
if (!Main.tile[i14, j13].active())
{
int type = 186;
while (!Main.tile[i14, j13 + 1].active() && j13 < Main.maxTilesY - 5)
++j13;
int style = WorldGen.genRand.Next(22);
switch (style)
{
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
style = WorldGen.genRand.Next(22);
break;
}
if ((Main.tile[i14, j13 + 1].type == (ushort) 0 || Main.tile[i14, j13 + 1].type == (ushort) 1 || Main.tileMoss[(int) Main.tile[i14, j13 + 1].type]) && WorldGen.genRand.Next(5) == 0)
{
style = WorldGen.genRand.Next(23, 29);
type = 187;
}
if (j13 > Main.maxTilesY - 300 || Main.wallDungeon[(int) Main.tile[i14, j13].wall] || Main.tile[i14, j13 + 1].type == (ushort) 30 || Main.tile[i14, j13 + 1].type == (ushort) 19 || Main.tile[i14, j13 + 1].type == (ushort) 25 || Main.tile[i14, j13 + 1].type == (ushort) 203)
{
style = WorldGen.genRand.Next(7);
type = 186;
}
if (Main.tile[i14, j13 + 1].type == (ushort) 147 || Main.tile[i14, j13 + 1].type == (ushort) 161 || Main.tile[i14, j13 + 1].type == (ushort) 162)
{
style = WorldGen.genRand.Next(26, 32);
type = 186;
}
if (Main.tile[i14, j13 + 1].type == (ushort) 60)
{
type = 187;
style = WorldGen.genRand.Next(6);
}
if ((Main.tile[i14, j13 + 1].type == (ushort) 57 || Main.tile[i14, j13 + 1].type == (ushort) 58) && WorldGen.genRand.Next(3) < 2)
{
type = 187;
style = WorldGen.genRand.Next(6, 9);
}
if (Main.tile[i14, j13 + 1].type == (ushort) 226)
{
type = 187;
style = WorldGen.genRand.Next(18, 23);
}
if (Main.tile[i14, j13 + 1].type == (ushort) 70)
{
style = WorldGen.genRand.Next(32, 35);
type = 186;
}
if (type == 186 && style >= 7 && style <= 15 && WorldGen.genRand.Next(75) == 0)
{
type = 187;
style = 17;
}
if (Main.wallDungeon[(int) Main.tile[i14, j13].wall] && WorldGen.genRand.Next(3) != 0)
{
flag = true;
}
else
{
WorldGen.PlaceTile(i14, j13, type, true, style: style);
if (Main.tile[i14, j13].type == (ushort) 186 || Main.tile[i14, j13].type == (ushort) 187)
flag = true;
if (flag && type == 186 && style <= 7)
{
int num = WorldGen.genRand.Next(1, 5);
for (int index152 = 0; index152 < num; ++index152)
{
int i15 = i14 + WorldGen.genRand.Next(-10, 11);
int j14 = j13 - WorldGen.genRand.Next(5);
if (!Main.tile[i15, j14].active())
{
while (!Main.tile[i15, j14 + 1].active() && j14 < Main.maxTilesY - 5)
++j14;
int X = WorldGen.genRand.Next(12, 36);
WorldGen.PlaceSmallPile(i15, j14, X, 0);
}
}
}
}
}
}
}
for (int index153 = 0; (double) index153 < (double) Main.maxTilesX * 0.01; ++index153)
{
bool flag = false;
while (!flag)
{
int i16 = WorldGen.genRand.Next(25, Main.maxTilesX - 25);
int j15 = WorldGen.genRand.Next(Main.maxTilesY - 300, Main.maxTilesY - 10);
if (!Main.tile[i16, j15].active())
{
int type = 186;
while (!Main.tile[i16, j15 + 1].active() && j15 < Main.maxTilesY - 5)
++j15;
int style = WorldGen.genRand.Next(22);
switch (style)
{
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
style = WorldGen.genRand.Next(22);
break;
}
if (j15 > Main.maxTilesY - 300 || Main.wallDungeon[(int) Main.tile[i16, j15].wall] || Main.tile[i16, j15 + 1].type == (ushort) 30 || Main.tile[i16, j15 + 1].type == (ushort) 19)
style = WorldGen.genRand.Next(7);
if ((Main.tile[i16, j15 + 1].type == (ushort) 57 || Main.tile[i16, j15 + 1].type == (ushort) 58) && WorldGen.genRand.Next(3) < 2)
{
type = 187;
style = WorldGen.genRand.Next(6, 9);
}
if (Main.tile[i16, j15 + 1].type == (ushort) 147 || Main.tile[i16, j15 + 1].type == (ushort) 161 || Main.tile[i16, j15 + 1].type == (ushort) 162)
style = WorldGen.genRand.Next(26, 32);
WorldGen.PlaceTile(i16, j15, type, true, style: style);
if (Main.tile[i16, j15].type == (ushort) 186 || Main.tile[i16, j15].type == (ushort) 187)
flag = true;
if (flag && type == 186 && style <= 7)
{
int num = WorldGen.genRand.Next(1, 5);
for (int index154 = 0; index154 < num; ++index154)
{
int i17 = i16 + WorldGen.genRand.Next(-10, 11);
int j16 = j15 - WorldGen.genRand.Next(5);
if (!Main.tile[i17, j16].active())
{
while (!Main.tile[i17, j16 + 1].active() && j16 < Main.maxTilesY - 5)
++j16;
int X = WorldGen.genRand.Next(12, 36);
WorldGen.PlaceSmallPile(i17, j16, X, 0);
}
}
}
}
}
}
for (int index = 0; (double) index < (double) Main.maxTilesX * 0.003; ++index)
{
bool flag = false;
while (!flag)
{
int type = 186;
int i = WorldGen.genRand.Next(25, Main.maxTilesX - 25);
int j = WorldGen.genRand.Next(10, (int) Main.worldSurface);
if (!Main.tile[i, j].active())
{
while (!Main.tile[i, j + 1].active() && j < Main.maxTilesY - 5)
++j;
int style = WorldGen.genRand.Next(7, 13);
if (j > Main.maxTilesY - 300 || Main.wallDungeon[(int) Main.tile[i, j].wall] || Main.tile[i, j + 1].type == (ushort) 30 || Main.tile[i, j + 1].type == (ushort) 19 || Main.tile[i, j + 1].type == (ushort) 53 || Main.tile[i, j + 1].type == (ushort) 25 || Main.tile[i, j + 1].type == (ushort) 203)
style = -1;
if (Main.tile[i, j + 1].type == (ushort) 147 || Main.tile[i, j + 1].type == (ushort) 161 || Main.tile[i, j + 1].type == (ushort) 162)
style = WorldGen.genRand.Next(26, 32);
if (Main.tile[i, j + 1].type == (ushort) 2 || Main.tile[i - 1, j + 1].type == (ushort) 2 || Main.tile[i + 1, j + 1].type == (ushort) 2)
{
type = 187;
style = WorldGen.genRand.Next(14, 17);
}
if (Main.tile[i, j + 1].type == (ushort) 151 || Main.tile[i, j + 1].type == (ushort) 274)
{
type = 186;
style = WorldGen.genRand.Next(7);
}
if (style >= 0)
WorldGen.PlaceTile(i, j, type, true, style: style);
if ((int) Main.tile[i, j].type == type)
flag = true;
}
}
}
for (int index155 = 0; (double) index155 < (double) Main.maxTilesX * 0.0035; ++index155)
{
bool flag = false;
while (!flag)
{
int i18 = WorldGen.genRand.Next(25, Main.maxTilesX - 25);
int j17 = WorldGen.genRand.Next(10, (int) Main.worldSurface);
if (!Main.tile[i18, j17].active() && Main.tile[i18, j17].wall > (byte) 0)
{
int type = 186;
while (!Main.tile[i18, j17 + 1].active() && j17 < Main.maxTilesY - 5)
++j17;
int style = WorldGen.genRand.Next(7, 13);
if (j17 > Main.maxTilesY - 300 || Main.wallDungeon[(int) Main.tile[i18, j17].wall] || Main.tile[i18, j17 + 1].type == (ushort) 30 || Main.tile[i18, j17 + 1].type == (ushort) 19)
style = -1;
if (Main.tile[i18, j17 + 1].type == (ushort) 25)
style = WorldGen.genRand.Next(7);
if (Main.tile[i18, j17 + 1].type == (ushort) 147 || Main.tile[i18, j17 + 1].type == (ushort) 161 || Main.tile[i18, j17 + 1].type == (ushort) 162)
style = WorldGen.genRand.Next(26, 32);
if (Main.tile[i18, j17 + 1].type == (ushort) 2 || Main.tile[i18 - 1, j17 + 1].type == (ushort) 2 || Main.tile[i18 + 1, j17 + 1].type == (ushort) 2)
{
type = 187;
style = WorldGen.genRand.Next(14, 17);
}
if (Main.tile[i18, j17 + 1].type == (ushort) 151 || Main.tile[i18, j17 + 1].type == (ushort) 274)
{
type = 186;
style = WorldGen.genRand.Next(7);
}
if (style >= 0)
WorldGen.PlaceTile(i18, j17, type, true, style: style);
if ((int) Main.tile[i18, j17].type == type)
flag = true;
if (flag && style <= 7)
{
int num = WorldGen.genRand.Next(1, 5);
for (int index156 = 0; index156 < num; ++index156)
{
int i19 = i18 + WorldGen.genRand.Next(-10, 11);
int j18 = j17 - WorldGen.genRand.Next(5);
if (!Main.tile[i19, j18].active())
{
while (!Main.tile[i19, j18 + 1].active() && j18 < Main.maxTilesY - 5)
++j18;
int X = WorldGen.genRand.Next(12, 36);
WorldGen.PlaceSmallPile(i19, j18, X, 0);
}
}
}
}
}
}
for (int index157 = 0; (double) index157 < (double) Main.maxTilesX * 0.6; ++index157)
{
bool flag = false;
while (!flag)
{
int i20 = WorldGen.genRand.Next(25, Main.maxTilesX - 25);
int j19 = WorldGen.genRand.Next((int) Main.worldSurface, Main.maxTilesY - 20);
if (Main.tile[i20, j19].wall == (byte) 87 && WorldGen.genRand.Next(2) == 0)
{
i20 = WorldGen.genRand.Next(25, Main.maxTilesX - 25);
j19 = WorldGen.genRand.Next((int) Main.worldSurface, Main.maxTilesY - 20);
}
if (!Main.tile[i20, j19].active())
{
while (!Main.tile[i20, j19 + 1].active() && j19 < Main.maxTilesY - 5)
++j19;
int Y = WorldGen.genRand.Next(2);
int X1 = WorldGen.genRand.Next(36);
switch (X1)
{
case 28:
case 29:
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
X1 = WorldGen.genRand.Next(36);
break;
}
if (Y == 1)
{
X1 = WorldGen.genRand.Next(25);
switch (X1)
{
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
X1 = WorldGen.genRand.Next(25);
break;
}
}
if (j19 > Main.maxTilesY - 300)
{
if (Y == 0)
X1 = WorldGen.genRand.Next(12, 28);
if (Y == 1)
X1 = WorldGen.genRand.Next(6, 16);
}
if (Main.wallDungeon[(int) Main.tile[i20, j19].wall] || Main.tile[i20, j19 + 1].type == (ushort) 30 || Main.tile[i20, j19 + 1].type == (ushort) 19 || Main.tile[i20, j19 + 1].type == (ushort) 25 || Main.tile[i20, j19 + 1].type == (ushort) 203 || Main.tile[i20, j19].wall == (byte) 87)
{
if (Y == 0 && X1 < 12)
X1 += 12;
if (Y == 1 && X1 < 6)
X1 += 6;
if (Y == 1 && X1 >= 17)
X1 -= 10;
}
if (Main.tile[i20, j19 + 1].type == (ushort) 147 || Main.tile[i20, j19 + 1].type == (ushort) 161 || Main.tile[i20, j19 + 1].type == (ushort) 162)
{
if (Y == 0 && X1 < 12)
X1 += 36;
if (Y == 1 && X1 >= 20)
X1 += 6;
if (Y == 1 && X1 < 6)
X1 += 25;
}
if (Main.tile[i20, j19 + 1].type == (ushort) 151 || Main.tile[i20, j19 + 1].type == (ushort) 274)
{
if (Y == 0)
X1 = WorldGen.genRand.Next(12, 28);
if (Y == 1)
X1 = WorldGen.genRand.Next(12, 19);
}
flag = Main.wallDungeon[(int) Main.tile[i20, j19].wall] && WorldGen.genRand.Next(3) != 0 || WorldGen.PlaceSmallPile(i20, j19, X1, Y);
if (flag && Y == 1 && X1 >= 6 && X1 <= 15)
{
int num = WorldGen.genRand.Next(1, 5);
for (int index158 = 0; index158 < num; ++index158)
{
int i21 = i20 + WorldGen.genRand.Next(-10, 11);
int j20 = j19 - WorldGen.genRand.Next(5);
if (!Main.tile[i21, j20].active())
{
while (!Main.tile[i21, j20 + 1].active() && j20 < Main.maxTilesY - 5)
++j20;
int X2 = WorldGen.genRand.Next(12, 36);
WorldGen.PlaceSmallPile(i21, j20, X2, 0);
}
}
}
}
}
}
for (int index = 0; (double) index < (double) Main.maxTilesX * 0.0199999995529652; ++index)
{
bool flag = false;
while (!flag)
{
int i = WorldGen.genRand.Next(25, Main.maxTilesX - 25);
int j = WorldGen.genRand.Next(15, (int) Main.worldSurface);
if (!Main.tile[i, j].active())
{
while (!Main.tile[i, j + 1].active() && j < Main.maxTilesY - 5)
++j;
int Y = WorldGen.genRand.Next(2);
int X = WorldGen.genRand.Next(11);
if (Y == 1)
X = WorldGen.genRand.Next(5);
if (Main.tile[i, j + 1].type == (ushort) 147 || Main.tile[i, j + 1].type == (ushort) 161 || Main.tile[i, j + 1].type == (ushort) 162)
{
if (Y == 0 && X < 12)
X += 36;
if (Y == 1 && X >= 20)
X += 6;
if (Y == 1 && X < 6)
X += 25;
}
if (Main.tile[i, j + 1].type == (ushort) 2 && Y == 1)
X = WorldGen.genRand.Next(38, 41);
if (Main.tile[i, j + 1].type == (ushort) 151 || Main.tile[i, j + 1].type == (ushort) 274)
{
if (Y == 0)
X = WorldGen.genRand.Next(12, 28);
if (Y == 1)
X = WorldGen.genRand.Next(12, 19);
}
if (!Main.wallDungeon[(int) Main.tile[i, j].wall] && Main.tile[i, j + 1].type != (ushort) 30 && Main.tile[i, j + 1].type != (ushort) 19 && Main.tile[i, j + 1].type != (ushort) 41 && Main.tile[i, j + 1].type != (ushort) 43 && Main.tile[i, j + 1].type != (ushort) 44 && Main.tile[i, j + 1].type != (ushort) 45 && Main.tile[i, j + 1].type != (ushort) 46 && Main.tile[i, j + 1].type != (ushort) 47 && Main.tile[i, j + 1].type != (ushort) 175 && Main.tile[i, j + 1].type != (ushort) 176 && Main.tile[i, j + 1].type != (ushort) 177 && Main.tile[i, j + 1].type != (ushort) 53 && Main.tile[i, j + 1].type != (ushort) 25 && Main.tile[i, j + 1].type != (ushort) 203)
flag = WorldGen.PlaceSmallPile(i, j, X, Y);
}
}
}
for (int index = 0; (double) index < (double) Main.maxTilesX * 0.150000005960464; ++index)
{
bool flag = false;
while (!flag)
{
int i = WorldGen.genRand.Next(25, Main.maxTilesX - 25);
int j = WorldGen.genRand.Next(15, (int) Main.worldSurface);
if (!Main.tile[i, j].active() && (Main.tile[i, j].wall == (byte) 2 || Main.tile[i, j].wall == (byte) 40))
{
while (!Main.tile[i, j + 1].active() && j < Main.maxTilesY - 5)
++j;
int Y = WorldGen.genRand.Next(2);
int X = WorldGen.genRand.Next(11);
if (Y == 1)
X = WorldGen.genRand.Next(5);
if (Main.tile[i, j + 1].type == (ushort) 147 || Main.tile[i, j + 1].type == (ushort) 161 || Main.tile[i, j + 1].type == (ushort) 162)
{
if (Y == 0 && X < 12)
X += 36;
if (Y == 1 && X >= 20)
X += 6;
if (Y == 1 && X < 6)
X += 25;
}
if (Main.tile[i, j + 1].type == (ushort) 2 && Y == 1)
X = WorldGen.genRand.Next(38, 41);
if (Main.tile[i, j + 1].type == (ushort) 151 || Main.tile[i, j + 1].type == (ushort) 274)
{
if (Y == 0)
X = WorldGen.genRand.Next(12, 28);
if (Y == 1)
X = WorldGen.genRand.Next(12, 19);
}
if (!Main.wallDungeon[(int) Main.tile[i, j].wall] && Main.tile[i, j + 1].type != (ushort) 30 && Main.tile[i, j + 1].type != (ushort) 19 && Main.tile[i, j + 1].type != (ushort) 41 && Main.tile[i, j + 1].type != (ushort) 43 && Main.tile[i, j + 1].type != (ushort) 44 && Main.tile[i, j + 1].type != (ushort) 45 && Main.tile[i, j + 1].type != (ushort) 46 && Main.tile[i, j + 1].type != (ushort) 47 && Main.tile[i, j + 1].type != (ushort) 175 && Main.tile[i, j + 1].type != (ushort) 176 && Main.tile[i, j + 1].type != (ushort) 177 && Main.tile[i, j + 1].type != (ushort) 25 && Main.tile[i, j + 1].type != (ushort) 203)
flag = WorldGen.PlaceSmallPile(i, j, X, Y);
}
}
}
Main.tileSolid[190] = true;
Main.tileSolid[192] = true;
Main.tileSolid[196] = true;
Main.tileSolid[189] = true;
Main.tileSolid[202] = true;
Main.tileSolid[225] = true;
}));
WorldGen.AddGenerationPass("Moss", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[38].Value;
int num175 = 8;
int num176 = 400;
int num177 = 4;
int num178 = 275;
for (int index = 0; index < 3; ++index)
{
int num179;
int num180;
bool flag;
int maxValue;
switch (index)
{
case 1:
num179 = num176;
num180 = Main.maxTilesX - num176;
flag = true;
maxValue = num175;
break;
case 2:
num179 = Main.maxTilesX - num178;
num180 = Main.maxTilesX - 5;
flag = false;
maxValue = num177;
break;
default:
num179 = 5;
num180 = num178;
flag = false;
maxValue = num177;
break;
}
for (int i = num179; i < num180; ++i)
{
if (WorldGen.genRand.Next(maxValue) == 0)
{
for (int j = 0; (double) j < Main.worldSurface - 1.0; ++j)
{
Tile tile3 = Main.tile[i, j];
if (tile3.active() && tile3.type == (ushort) 53)
{
Tile tile4 = Main.tile[i, j - 1];
if (!tile4.active() && tile4.wall == (byte) 0)
{
if (flag)
{
WorldGen.PlantCactus(i, j);
break;
}
if (Main.tile[i, j - 2].liquid == byte.MaxValue && Main.tile[i, j - 3].liquid == byte.MaxValue && Main.tile[i, j - 4].liquid == byte.MaxValue)
{
if (WorldGen.genRand.Next(2) == 0)
{
WorldGen.PlaceTile(i, j - 1, 81, true);
break;
}
WorldGen.PlaceTile(i, j - 1, 324, true, style: WorldGen.genRand.Next(2));
break;
}
if (Main.tile[i, j - 2].liquid == (byte) 0)
{
WorldGen.PlaceTile(i, j - 1, 324, true, style: WorldGen.genRand.Next(2));
break;
}
}
}
}
}
}
}
}));
WorldGen.AddGenerationPass("Spawn Point", (WorldGenLegacyMethod) (progress =>
{
int num181 = 5;
bool flag = true;
while (flag)
{
int index159 = Main.maxTilesX / 2 + WorldGen.genRand.Next(-num181, num181 + 1);
for (int index160 = 0; index160 < Main.maxTilesY; ++index160)
{
if (Main.tile[index159, index160].active())
{
Main.spawnTileX = index159;
Main.spawnTileY = index160;
break;
}
}
flag = false;
++num181;
if ((double) Main.spawnTileY > Main.worldSurface)
flag = true;
if (Main.tile[Main.spawnTileX, Main.spawnTileY - 1].liquid > (byte) 0)
flag = true;
}
int num182 = 10;
while ((double) Main.spawnTileY > Main.worldSurface)
{
int index161 = WorldGen.genRand.Next(Main.maxTilesX / 2 - num182, Main.maxTilesX / 2 + num182);
for (int index162 = 0; index162 < Main.maxTilesY; ++index162)
{
if (Main.tile[index161, index162].active())
{
Main.spawnTileX = index161;
Main.spawnTileY = index162;
break;
}
}
++num182;
}
}));
WorldGen.AddGenerationPass("Grass Wall", (WorldGenLegacyMethod) (progress =>
{
WorldGen.maxTileCount = 3500;
for (int index163 = 50; index163 < Main.maxTilesX - 50; ++index163)
{
for (int index164 = 0; (double) index164 < Main.worldSurface - 10.0; ++index164)
{
if (WorldGen.genRand.Next(4) == 0)
{
bool flag = false;
int x = -1;
int y = -1;
if (Main.tile[index163, index164].active() && Main.tile[index163, index164].type == (ushort) 2 && (Main.tile[index163, index164].wall == (byte) 2 || Main.tile[index163, index164].wall == (byte) 63))
{
for (int i = index163 - 1; i <= index163 + 1; ++i)
{
for (int j = index164 - 1; j <= index164 + 1; ++j)
{
if (Main.tile[i, j].wall == (byte) 0 && !WorldGen.SolidTile(i, j))
flag = true;
}
}
if (flag)
{
for (int i = index163 - 1; i <= index163 + 1; ++i)
{
for (int j = index164 - 1; j <= index164 + 1; ++j)
{
if ((Main.tile[i, j].wall == (byte) 2 || Main.tile[i, j].wall == (byte) 15) && !WorldGen.SolidTile(i, j))
{
x = i;
y = j;
}
}
}
}
}
if (flag && x > -1 && y > -1)
{
if (WorldGen.countDirtTiles(x, y) < WorldGen.maxTileCount)
{
try
{
WorldGen.Spread.Wall2(x, y, 63);
}
catch
{
}
}
}
}
}
}
for (int i = 5; i < Main.maxTilesX - 5; ++i)
{
for (int j = 10; (double) j < Main.worldSurface - 1.0; ++j)
{
if (Main.tile[i, j].wall == (byte) 63 && WorldGen.genRand.Next(10) == 0)
Main.tile[i, j].wall = (byte) 65;
if (Main.tile[i, j].active() && Main.tile[i, j].type == (ushort) 0)
{
bool flag = false;
for (int index165 = i - 1; index165 <= i + 1; ++index165)
{
for (int index166 = j - 1; index166 <= j + 1; ++index166)
{
if (Main.tile[i, j].wall == (byte) 63 || Main.tile[i, j].wall == (byte) 65)
{
flag = true;
break;
}
}
}
if (flag)
WorldGen.SpreadGrass(i, j);
}
}
}
}));
WorldGen.AddGenerationPass("Guide", (WorldGenLegacyMethod) (progress =>
{
int index = NPC.NewNPC(Main.spawnTileX * 16, Main.spawnTileY * 16, 22);
Main.npc[index].homeTileX = Main.spawnTileX;
Main.npc[index].homeTileY = Main.spawnTileY;
Main.npc[index].direction = 1;
Main.npc[index].homeless = true;
}));
WorldGen.AddGenerationPass("Sunflowers", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[39].Value;
for (int index167 = 0; (double) index167 < (double) Main.maxTilesX * 0.002; ++index167)
{
int num183 = Main.maxTilesX / 2;
int num184 = WorldGen.genRand.Next(Main.maxTilesX);
int num185 = num184 - WorldGen.genRand.Next(10) - 7;
int num186 = num184 + WorldGen.genRand.Next(10) + 7;
if (num185 < 0)
num185 = 0;
if (num186 > Main.maxTilesX - 1)
num186 = Main.maxTilesX - 1;
for (int i = num185; i < num186; ++i)
{
for (int index168 = 1; (double) index168 < Main.worldSurface - 1.0; ++index168)
{
if (Main.tile[i, index168].type == (ushort) 2 && Main.tile[i, index168].active() && !Main.tile[i, index168 - 1].active())
WorldGen.PlaceTile(i, index168 - 1, 27, true);
if (Main.tile[i, index168].active())
break;
}
}
}
}));
WorldGen.AddGenerationPass("Planting Trees", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[40].Value;
for (int index = 0; (double) index < (double) Main.maxTilesX * 0.003; ++index)
{
int num187 = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
int num188 = WorldGen.genRand.Next(25, 50);
for (int i = num187 - num188; i < num187 + num188; ++i)
{
for (int y = 20; (double) y < Main.worldSurface; ++y)
WorldGen.GrowEpicTree(i, y);
}
}
WorldGen.AddTrees();
}));
WorldGen.AddGenerationPass("Herbs", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[41].Value;
for (int index = 0; (double) index < (double) Main.maxTilesX * 1.7; ++index)
WorldGen.PlantAlch();
}));
WorldGen.AddGenerationPass("Dye Plants", (WorldGenLegacyMethod) (progress =>
{
for (int index = 0; index < Main.maxTilesX; ++index)
WorldGen.plantDye(WorldGen.genRand.Next(100, Main.maxTilesX - 100), WorldGen.genRand.Next(100, Main.maxTilesY - 200));
for (int index = 0; index < Main.maxTilesX / 8; ++index)
WorldGen.plantDye(WorldGen.genRand.Next(100, Main.maxTilesX - 100), WorldGen.genRand.Next(100, Main.maxTilesY - 200), true);
}));
WorldGen.AddGenerationPass("Webs And Honey", (WorldGenLegacyMethod) (progress =>
{
for (int index = 100; index < Main.maxTilesX - 100; ++index)
{
for (int worldSurface3 = (int) Main.worldSurface; worldSurface3 < Main.maxTilesY - 100; ++worldSurface3)
{
if (Main.tile[index, worldSurface3].wall == (byte) 86)
{
if (Main.tile[index, worldSurface3].liquid > (byte) 0)
Main.tile[index, worldSurface3].honey(true);
if (WorldGen.genRand.Next(3) == 0)
WorldGen.PlaceTight(index, worldSurface3);
}
if (Main.tile[index, worldSurface3].wall == (byte) 62)
{
Main.tile[index, worldSurface3].liquid = (byte) 0;
Main.tile[index, worldSurface3].lava(false);
}
if (Main.tile[index, worldSurface3].wall == (byte) 62 && !Main.tile[index, worldSurface3].active() && WorldGen.genRand.Next(10) != 0)
{
int num189 = WorldGen.genRand.Next(2, 5);
int num190 = index - num189;
int num191 = index + num189;
int num192 = worldSurface3 - num189;
int num193 = worldSurface3 + num189;
bool flag = false;
for (int i = num190; i <= num191; ++i)
{
for (int j = num192; j <= num193; ++j)
{
if (WorldGen.SolidTile(i, j))
{
flag = true;
break;
}
}
}
if (flag)
{
WorldGen.PlaceTile(index, worldSurface3, 51, true);
WorldGen.TileFrame(index, worldSurface3);
}
}
}
}
}));
WorldGen.AddGenerationPass("Weeds", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[42].Value;
if (Main.halloween)
{
for (int index169 = 40; index169 < Main.maxTilesX - 40; ++index169)
{
for (int index170 = 50; (double) index170 < Main.worldSurface; ++index170)
{
if (Main.tile[index169, index170].active() && Main.tile[index169, index170].type == (ushort) 2 && WorldGen.genRand.Next(15) == 0)
{
WorldGen.PlacePumpkin(index169, index170 - 1);
int num = WorldGen.genRand.Next(5);
for (int index171 = 0; index171 < num; ++index171)
WorldGen.GrowPumpkin(index169, index170 - 1, 254);
}
}
}
}
WorldGen.AddPlants();
}));
WorldGen.AddGenerationPass("Mud Caves To Grass", (WorldGenLegacyMethod) (progress =>
{
for (int i = 0; i < Main.maxTilesX; ++i)
{
for (int y = 0; y < Main.maxTilesY; ++y)
{
if (Main.tile[i, y].active())
{
if (y >= (int) Main.worldSurface && Main.tile[i, y].type == (ushort) 70 && !Main.tile[i, y - 1].active())
{
WorldGen.GrowShroom(i, y);
if (!Main.tile[i, y - 1].active())
WorldGen.PlaceTile(i, y - 1, 71, true);
}
if (Main.tile[i, y].type == (ushort) 60 && !Main.tile[i, y - 1].active())
WorldGen.PlaceTile(i, y - 1, 61, true);
}
}
}
}));
WorldGen.AddGenerationPass("Jungle Plants", (WorldGenLegacyMethod) (progress =>
{
for (int index172 = 0; index172 < Main.maxTilesX * 100; ++index172)
{
int X2 = WorldGen.genRand.Next(40, Main.maxTilesX / 2 - 40);
if (dungeonSide < 0)
X2 += Main.maxTilesX / 2;
int index173 = WorldGen.genRand.Next(Main.maxTilesY - 300);
while (!Main.tile[X2, index173].active() && index173 < Main.maxTilesY - 300)
++index173;
if (Main.tile[X2, index173].active() && Main.tile[X2, index173].type == (ushort) 60)
{
int Y2 = index173 - 1;
WorldGen.PlaceJunglePlant(X2, Y2, (ushort) 233, WorldGen.genRand.Next(8), 0);
if (Main.tile[X2, Y2].type != (ushort) 233)
WorldGen.PlaceJunglePlant(X2, Y2, (ushort) 233, WorldGen.genRand.Next(12), 1);
}
}
}));
WorldGen.AddGenerationPass("Vines", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[43].Value;
for (int i22 = 0; i22 < Main.maxTilesX; ++i22)
{
int num194 = 0;
for (int index = 0; (double) index < Main.worldSurface; ++index)
{
if (num194 > 0 && !Main.tile[i22, index].active())
{
Main.tile[i22, index].active(true);
Main.tile[i22, index].type = (ushort) 52;
--num194;
}
else
num194 = 0;
if (Main.tile[i22, index].active() && !Main.tile[i22, index].bottomSlope() && (Main.tile[i22, index].type == (ushort) 2 || Main.tile[i22, index].type == (ushort) 192 && WorldGen.genRand.Next(4) == 0) && WorldGen.genRand.Next(5) < 3)
num194 = WorldGen.genRand.Next(1, 10);
}
int num195 = 0;
for (int j21 = 0; j21 < Main.maxTilesY; ++j21)
{
if (num195 > 0 && !Main.tile[i22, j21].active())
{
Main.tile[i22, j21].active(true);
Main.tile[i22, j21].type = (ushort) 62;
--num195;
}
else
num195 = 0;
if (Main.tile[i22, j21].active() && Main.tile[i22, j21].type == (ushort) 60 && !Main.tile[i22, j21].bottomSlope())
{
if (i22 < Main.maxTilesX - 1 && j21 < Main.maxTilesY - 2 && Main.tile[i22 + 1, j21].active() && Main.tile[i22 + 1, j21].type == (ushort) 60 && !Main.tile[i22 + 1, j21].bottomSlope() && WorldGen.genRand.Next(40) == 0)
{
bool flag = true;
for (int index174 = i22; index174 < i22 + 2; ++index174)
{
for (int index175 = j21 + 1; index175 < j21 + 3; ++index175)
{
if (Main.tile[index174, index175].active() && (!Main.tileCut[(int) Main.tile[index174, index175].type] || Main.tile[index174, index175].type == (ushort) 444))
{
flag = false;
break;
}
if (Main.tile[index174, index175].liquid > (byte) 0 || Main.wallHouse[(int) Main.tile[index174, index175].wall])
{
flag = false;
break;
}
}
if (!flag)
break;
}
if (flag)
{
if (WorldGen.CountNearBlocksTypes(i22, j21, 20, 1, 444) > 0)
flag = false;
}
if (flag)
{
for (int i23 = i22; i23 < i22 + 2; ++i23)
{
for (int j22 = j21 + 1; j22 < j21 + 3; ++j22)
WorldGen.KillTile(i23, j22);
}
for (int index176 = i22; index176 < i22 + 2; ++index176)
{
for (int index177 = j21 + 1; index177 < j21 + 3; ++index177)
{
Main.tile[index176, index177].active(true);
Main.tile[index176, index177].type = (ushort) 444;
Main.tile[index176, index177].frameX = (short) ((index176 - i22) * 18);
Main.tile[index176, index177].frameY = (short) ((index177 - j21 - 1) * 18);
}
}
continue;
}
}
if (WorldGen.genRand.Next(5) < 3)
num195 = WorldGen.genRand.Next(1, 10);
}
}
int num196 = 0;
for (int index = 0; index < Main.maxTilesY; ++index)
{
if (num196 > 0 && !Main.tile[i22, index].active())
{
Main.tile[i22, index].active(true);
Main.tile[i22, index].type = (ushort) 205;
--num196;
}
else
num196 = 0;
if (Main.tile[i22, index].active() && Main.tile[i22, index].type == (ushort) 199 && WorldGen.genRand.Next(5) < 3)
num196 = WorldGen.genRand.Next(1, 10);
}
}
}));
WorldGen.AddGenerationPass("Flowers", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[44].Value;
for (int index178 = 0; (double) index178 < (double) Main.maxTilesX * 0.005; ++index178)
{
int index179 = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
int num197 = WorldGen.genRand.Next(5, 15);
int num198 = WorldGen.genRand.Next(15, 30);
for (int index180 = 1; (double) index180 < Main.worldSurface - 1.0; ++index180)
{
if (Main.tile[index179, index180].active())
{
for (int index181 = index179 - num197; index181 < index179 + num197; ++index181)
{
for (int index182 = index180 - num198; index182 < index180 + num198; ++index182)
{
if (Main.tile[index181, index182].type == (ushort) 3 || Main.tile[index181, index182].type == (ushort) 24)
{
Main.tile[index181, index182].frameX = (short) (WorldGen.genRand.Next(6, 8) * 18);
if (Main.tile[index181, index182].type == (ushort) 3 && WorldGen.genRand.Next(2) == 0)
Main.tile[index181, index182].frameX = (short) (WorldGen.genRand.Next(9, 11) * 18);
}
}
}
break;
}
}
}
}));
WorldGen.AddGenerationPass("Mushrooms", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[45].Value;
for (int index183 = 0; (double) index183 < (double) Main.maxTilesX * 0.002; ++index183)
{
int index184 = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
int num199 = WorldGen.genRand.Next(4, 10);
int num200 = WorldGen.genRand.Next(15, 30);
for (int index185 = 1; (double) index185 < Main.worldSurface - 1.0; ++index185)
{
if (Main.tile[index184, index185].active())
{
for (int index186 = index184 - num199; index186 < index184 + num199; ++index186)
{
for (int index187 = index185 - num200; index187 < index185 + num200; ++index187)
{
if (Main.tile[index186, index187].type == (ushort) 3 || Main.tile[index186, index187].type == (ushort) 24)
Main.tile[index186, index187].frameX = (short) 144;
else if (Main.tile[index186, index187].type == (ushort) 201)
Main.tile[index186, index187].frameX = (short) 270;
}
}
break;
}
}
}
}));
WorldGen.AddGenerationPass("Stalac", (WorldGenLegacyMethod) (progress =>
{
for (int x = 20; x < Main.maxTilesX - 20; ++x)
{
for (int worldSurface4 = (int) Main.worldSurface; worldSurface4 < Main.maxTilesY - 20; ++worldSurface4)
{
if (!Main.tile[x, worldSurface4].active() && WorldGen.genRand.Next(5) == 0)
{
if ((Main.tile[x, worldSurface4 - 1].type == (ushort) 1 || Main.tile[x, worldSurface4 - 1].type == (ushort) 147 || Main.tile[x, worldSurface4 - 1].type == (ushort) 161 || Main.tile[x, worldSurface4 - 1].type == (ushort) 25 || Main.tile[x, worldSurface4 - 1].type == (ushort) 203 || Main.tileStone[(int) Main.tile[x, worldSurface4 - 1].type] || Main.tileMoss[(int) Main.tile[x, worldSurface4 - 1].type]) && !Main.tile[x, worldSurface4].active() && !Main.tile[x, worldSurface4 + 1].active())
Main.tile[x, worldSurface4 - 1].slope((byte) 0);
if ((Main.tile[x, worldSurface4 + 1].type == (ushort) 1 || Main.tile[x, worldSurface4 + 1].type == (ushort) 147 || Main.tile[x, worldSurface4 + 1].type == (ushort) 161 || Main.tile[x, worldSurface4 + 1].type == (ushort) 25 || Main.tile[x, worldSurface4 + 1].type == (ushort) 203 || Main.tileStone[(int) Main.tile[x, worldSurface4 + 1].type] || Main.tileMoss[(int) Main.tile[x, worldSurface4 + 1].type]) && !Main.tile[x, worldSurface4].active() && !Main.tile[x, worldSurface4 - 1].active())
Main.tile[x, worldSurface4 + 1].slope((byte) 0);
WorldGen.PlaceTight(x, worldSurface4);
}
}
for (int y = 5; y < (int) Main.worldSurface; ++y)
{
if ((Main.tile[x, y - 1].type == (ushort) 147 || Main.tile[x, y - 1].type == (ushort) 161) && WorldGen.genRand.Next(5) == 0)
{
if (!Main.tile[x, y].active() && !Main.tile[x, y + 1].active())
Main.tile[x, y - 1].slope((byte) 0);
WorldGen.PlaceTight(x, y);
}
if ((Main.tile[x, y - 1].type == (ushort) 25 || Main.tile[x, y - 1].type == (ushort) 203) && WorldGen.genRand.Next(5) == 0)
{
if (!Main.tile[x, y].active() && !Main.tile[x, y + 1].active())
Main.tile[x, y - 1].slope((byte) 0);
WorldGen.PlaceTight(x, y);
}
if ((Main.tile[x, y + 1].type == (ushort) 25 || Main.tile[x, y + 1].type == (ushort) 203) && WorldGen.genRand.Next(5) == 0)
{
if (!Main.tile[x, y].active() && !Main.tile[x, y - 1].active())
Main.tile[x, y + 1].slope((byte) 0);
WorldGen.PlaceTight(x, y);
}
}
}
}));
WorldGen.AddGenerationPass("Gems In Ice Biome", (WorldGenLegacyMethod) (progress =>
{
for (int index188 = 0; (double) index188 < (double) Main.maxTilesX * 0.25; ++index188)
{
int index189 = WorldGen.genRand.Next((int) (Main.worldSurface + Main.rockLayer) / 2, WorldGen.lavaLine);
int index190 = WorldGen.genRand.Next(snowMinX[index189], snowMaxX[index189]);
if (Main.tile[index190, index189].active() && (Main.tile[index190, index189].type == (ushort) 147 || Main.tile[index190, index189].type == (ushort) 161 || Main.tile[index190, index189].type == (ushort) 162 || Main.tile[index190, index189].type == (ushort) 224))
{
int num201 = WorldGen.genRand.Next(1, 4);
int num202 = WorldGen.genRand.Next(1, 4);
int num203 = WorldGen.genRand.Next(1, 4);
int num204 = WorldGen.genRand.Next(1, 4);
int num205 = WorldGen.genRand.Next(12);
int style = num205 >= 3 ? (num205 >= 6 ? (num205 >= 8 ? (num205 >= 10 ? (num205 >= 11 ? 5 : 4) : 3) : 2) : 1) : 0;
for (int i = index190 - num201; i < index190 + num202; ++i)
{
for (int j = index189 - num203; j < index189 + num204; ++j)
{
if (!Main.tile[i, j].active())
WorldGen.PlaceTile(i, j, 178, true, style: style);
}
}
}
}
}));
WorldGen.AddGenerationPass("Random Gems", (WorldGenLegacyMethod) (progress =>
{
for (int index = 0; index < Main.maxTilesX; ++index)
{
int i = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
int j = WorldGen.genRand.Next((int) Main.rockLayer, Main.maxTilesY - 300);
if (!Main.tile[i, j].active() && !Main.tile[i, j].lava() && !Main.wallDungeon[(int) Main.tile[i, j].wall] && Main.tile[i, j].wall != (byte) 27)
{
int num = WorldGen.genRand.Next(12);
int style = num >= 3 ? (num >= 6 ? (num >= 8 ? (num >= 10 ? (num >= 11 ? 5 : 4) : 3) : 2) : 1) : 0;
WorldGen.PlaceTile(i, j, 178, true, style: style);
}
}
}));
WorldGen.AddGenerationPass("Moss Grass", (WorldGenLegacyMethod) (progress =>
{
for (int index191 = 5; index191 < Main.maxTilesX - 5; ++index191)
{
for (int index192 = 5; index192 < Main.maxTilesY - 5; ++index192)
{
if (Main.tile[index191, index192].active() && Main.tileMoss[(int) Main.tile[index191, index192].type])
{
for (int index193 = 0; index193 < 4; ++index193)
{
int i = index191;
int j = index192;
if (index193 == 0)
--i;
if (index193 == 1)
++i;
if (index193 == 2)
--j;
if (index193 == 3)
++j;
if (!Main.tile[i, j].active())
WorldGen.PlaceTile(i, j, 184, true);
}
}
}
}
}));
WorldGen.AddGenerationPass("Muds Walls In Jungle", (WorldGenLegacyMethod) (progress =>
{
int num206 = 0;
int num207 = 0;
bool flag18 = false;
for (int index194 = 5; index194 < Main.maxTilesX - 5; ++index194)
{
for (int index195 = 0; (double) index195 < Main.worldSurface + 20.0; ++index195)
{
if (Main.tile[index194, index195].active() && Main.tile[index194, index195].type == (ushort) 60)
{
num206 = index194;
flag18 = true;
break;
}
}
if (flag18)
break;
}
bool flag19 = false;
for (int index196 = Main.maxTilesX - 5; index196 > 5; --index196)
{
for (int index197 = 0; (double) index197 < Main.worldSurface + 20.0; ++index197)
{
if (Main.tile[index196, index197].active() && Main.tile[index196, index197].type == (ushort) 60)
{
num207 = index196;
flag19 = true;
break;
}
}
if (flag19)
break;
}
for (int index198 = num206; index198 <= num207; ++index198)
{
for (int index199 = 0; (double) index199 < Main.worldSurface + 20.0; ++index199)
{
if ((index198 >= num206 + 2 && index198 <= num207 - 2 || WorldGen.genRand.Next(2) != 0) && (index198 >= num206 + 3 && index198 <= num207 - 3 || WorldGen.genRand.Next(3) != 0) && (Main.tile[index198, index199].wall == (byte) 2 || Main.tile[index198, index199].wall == (byte) 59))
Main.tile[index198, index199].wall = (byte) 15;
}
}
}));
WorldGen.AddGenerationPass("Larva", (WorldGenLegacyMethod) (progress =>
{
for (int index200 = 0; index200 < WorldGen.numLarva; ++index200)
{
int i = WorldGen.larvaX[index200];
int j = WorldGen.larvaY[index200];
for (int index201 = i - 1; index201 <= i + 1; ++index201)
{
for (int index202 = j - 2; index202 <= j + 1; ++index202)
{
if (index202 != j + 1)
{
Main.tile[index201, index202].active(false);
}
else
{
Main.tile[index201, index202].active(true);
Main.tile[index201, index202].type = (ushort) 225;
Main.tile[index201, index202].slope((byte) 0);
Main.tile[index201, index202].halfBrick(false);
}
}
}
WorldGen.PlaceTile(i, j, 231, true);
}
Main.tileSolid[232] = true;
Main.tileSolid[162] = true;
}));
WorldGen.AddGenerationPass("Settle Liquids Again", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[27].Value;
Liquid.QuickWater(3);
WorldGen.WaterCheck();
int num208 = 0;
Liquid.quickSettle = true;
while (num208 < 10)
{
int num209 = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
++num208;
float num210 = 0.0f;
while (Liquid.numLiquid > 0)
{
float num211 = (float) (num209 - (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer)) / (float) num209;
if (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer > num209)
num209 = Liquid.numLiquid + LiquidBuffer.numLiquidBuffer;
if ((double) num211 > (double) num210)
num210 = num211;
else
num211 = num210;
if (num208 == 1)
progress.Set((float) ((double) num211 / 3.0 + 0.330000013113022));
int num212 = 10;
if (num208 > num212)
;
Liquid.UpdateLiquid();
}
WorldGen.WaterCheck();
progress.Set((float) ((double) num208 * 0.100000001490116 / 3.0 + 0.660000026226044));
}
Liquid.quickSettle = false;
}));
WorldGen.AddGenerationPass("Tile Cleanup", (WorldGenLegacyMethod) (progress =>
{
for (int i = 40; i < Main.maxTilesX - 40; ++i)
{
for (int index203 = 40; index203 < Main.maxTilesY - 40; ++index203)
{
if (!Main.tile[i, index203].active() && Main.tile[i, index203].liquid == (byte) 0 && WorldGen.genRand.Next(3) != 0 && WorldGen.SolidTile(i, index203 - 1))
{
int num213 = WorldGen.genRand.Next(15, 21);
for (int index204 = index203 - 2; index204 >= index203 - num213; --index204)
{
if (Main.tile[i, index204].liquid >= (byte) 128)
{
int num214 = 373;
if (Main.tile[i, index204].lava())
num214 = 374;
else if (Main.tile[i, index204].honey())
num214 = 375;
if (WorldGen.genRand.Next(index203 - index204) <= 1)
{
Main.tile[i, index203].type = (ushort) num214;
Main.tile[i, index203].frameX = (short) 0;
Main.tile[i, index203].frameY = (short) 0;
Main.tile[i, index203].active(true);
break;
}
}
}
if (!Main.tile[i, index203].active())
{
int num215 = WorldGen.genRand.Next(3, 11);
for (int index205 = index203 + 1; index205 <= index203 + num215; ++index205)
{
if (Main.tile[i, index205].liquid >= (byte) 200)
{
int num216 = 373;
if (Main.tile[i, index205].lava())
num216 = 374;
else if (Main.tile[i, index205].honey())
num216 = 375;
if (WorldGen.genRand.Next((index205 - index203) * 3) <= 1)
{
Main.tile[i, index203].type = (ushort) num216;
Main.tile[i, index203].frameX = (short) 0;
Main.tile[i, index203].frameY = (short) 0;
Main.tile[i, index203].active(true);
break;
}
}
}
}
if (!Main.tile[i, index203].active() && WorldGen.genRand.Next(3) != 0)
{
Tile tile = Main.tile[i, index203 - 1];
if (TileID.Sets.Conversion.Sandstone[(int) tile.type] || TileID.Sets.Conversion.HardenedSand[(int) tile.type])
{
Main.tile[i, index203].type = (ushort) 461;
Main.tile[i, index203].frameX = (short) 0;
Main.tile[i, index203].frameY = (short) 0;
Main.tile[i, index203].active(true);
}
}
}
if (Main.tile[i, index203].type == (ushort) 137)
{
if (Main.tile[i, index203].frameY <= (short) 52)
{
int num = -1;
if (Main.tile[i, index203].frameX >= (short) 18)
num = 1;
if (Main.tile[i + num, index203].halfBrick() || Main.tile[i + num, index203].slope() != (byte) 0)
Main.tile[i + num, index203].active(false);
}
}
else if (Main.tile[i, index203].type == (ushort) 162 && Main.tile[i, index203 + 1].liquid == (byte) 0)
Main.tile[i, index203].active(false);
if (Main.tile[i, index203].wall == (byte) 13 || Main.tile[i, index203].wall == (byte) 14)
Main.tile[i, index203].liquid = (byte) 0;
if (Main.tile[i, index203].type == (ushort) 31)
{
int num217 = (int) Main.tile[i, index203].frameX / 18;
int num218 = 0;
int num219 = i;
int num220 = num218 + num217 / 2;
int num221 = WorldGen.crimson ? 1 : 0;
int num222 = num217 % 2;
int num223 = num219 - num222;
int num224 = (int) Main.tile[i, index203].frameY / 18;
int num225 = 0;
int num226 = index203;
int num227 = num225 + num224 / 2;
int num228 = num224 % 2;
int num229 = num226 - num228;
for (int index206 = 0; index206 < 2; ++index206)
{
for (int index207 = 0; index207 < 2; ++index207)
{
int index208 = num223 + index206;
int index209 = num229 + index207;
Main.tile[index208, index209].active(true);
Main.tile[index208, index209].slope((byte) 0);
Main.tile[index208, index209].halfBrick(false);
Main.tile[index208, index209].type = (ushort) 31;
Main.tile[index208, index209].frameX = (short) (index206 * 18 + 36 * num221);
Main.tile[index208, index209].frameY = (short) (index207 * 18 + 36 * num227);
}
}
}
if (Main.tile[i, index203].type == (ushort) 12)
{
int num230 = (int) Main.tile[i, index203].frameX / 18;
int num231 = 0;
int num232 = i;
int num233 = num231 + num230 / 2;
int num234 = num230 % 2;
int num235 = num232 - num234;
int num236 = (int) Main.tile[i, index203].frameY / 18;
int num237 = 0;
int num238 = index203;
int num239 = num237 + num236 / 2;
int num240 = num236 % 2;
int num241 = num238 - num240;
for (int index210 = 0; index210 < 2; ++index210)
{
for (int index211 = 0; index211 < 2; ++index211)
{
int index212 = num235 + index210;
int index213 = num241 + index211;
Main.tile[index212, index213].active(true);
Main.tile[index212, index213].slope((byte) 0);
Main.tile[index212, index213].halfBrick(false);
Main.tile[index212, index213].type = (ushort) 12;
Main.tile[index212, index213].frameX = (short) (index210 * 18 + 36 * num233);
Main.tile[index212, index213].frameY = (short) (index211 * 18 + 36 * num239);
}
if (!Main.tile[index210, index203 + 2].active())
{
Main.tile[index210, index203 + 2].active(true);
if (!Main.tileSolid[(int) Main.tile[index210, index203 + 2].type] || Main.tileSolidTop[(int) Main.tile[index210, index203 + 2].type])
Main.tile[index210, index203 + 2].type = (ushort) 0;
}
Main.tile[index210, index203 + 2].slope((byte) 0);
Main.tile[index210, index203 + 2].halfBrick(false);
}
}
if (TileID.Sets.BasicChest[(int) Main.tile[i, index203].type])
{
int num242 = (int) Main.tile[i, index203].frameX / 18;
int num243 = 0;
int num244 = i;
int Y = index203 - (int) Main.tile[i, index203].frameY / 18;
for (; num242 >= 2; num242 -= 2)
++num243;
int X = num244 - num242;
int chest = Chest.FindChest(X, Y);
if (chest != -1)
{
switch (Main.chest[chest].item[0].type)
{
case 1156:
num243 = 23;
break;
case 1260:
num243 = 26;
break;
case 1569:
num243 = 25;
break;
case 1571:
num243 = 24;
break;
case 1572:
num243 = 27;
break;
}
}
for (int index214 = 0; index214 < 2; ++index214)
{
for (int index215 = 0; index215 < 2; ++index215)
{
int index216 = X + index214;
int index217 = Y + index215;
Main.tile[index216, index217].active(true);
Main.tile[index216, index217].slope((byte) 0);
Main.tile[index216, index217].halfBrick(false);
Main.tile[index216, index217].type = (ushort) 21;
Main.tile[index216, index217].frameX = (short) (index214 * 18 + 36 * num243);
Main.tile[index216, index217].frameY = (short) (index215 * 18);
}
if (!Main.tile[index214, index203 + 2].active())
{
Main.tile[index214, index203 + 2].active(true);
if (!Main.tileSolid[(int) Main.tile[index214, index203 + 2].type] || Main.tileSolidTop[(int) Main.tile[index214, index203 + 2].type])
Main.tile[index214, index203 + 2].type = (ushort) 0;
}
Main.tile[index214, index203 + 2].slope((byte) 0);
Main.tile[index214, index203 + 2].halfBrick(false);
}
}
if (Main.tile[i, index203].type == (ushort) 28)
{
int num245 = (int) Main.tile[i, index203].frameX / 18;
int num246 = 0;
int num247 = i;
for (; num245 >= 2; num245 -= 2)
++num246;
int num248 = num247 - num245;
int num249 = (int) Main.tile[i, index203].frameY / 18;
int num250 = 0;
int num251 = index203;
for (; num249 >= 2; num249 -= 2)
++num250;
int num252 = num251 - num249;
for (int index218 = 0; index218 < 2; ++index218)
{
for (int index219 = 0; index219 < 2; ++index219)
{
int index220 = num248 + index218;
int index221 = num252 + index219;
Main.tile[index220, index221].active(true);
Main.tile[index220, index221].slope((byte) 0);
Main.tile[index220, index221].halfBrick(false);
Main.tile[index220, index221].type = (ushort) 28;
Main.tile[index220, index221].frameX = (short) (index218 * 18 + 36 * num246);
Main.tile[index220, index221].frameY = (short) (index219 * 18 + 36 * num250);
}
if (!Main.tile[index218, index203 + 2].active())
{
Main.tile[index218, index203 + 2].active(true);
if (!Main.tileSolid[(int) Main.tile[index218, index203 + 2].type] || Main.tileSolidTop[(int) Main.tile[index218, index203 + 2].type])
Main.tile[index218, index203 + 2].type = (ushort) 0;
}
Main.tile[index218, index203 + 2].slope((byte) 0);
Main.tile[index218, index203 + 2].halfBrick(false);
}
}
if (Main.tile[i, index203].type == (ushort) 26)
{
int num253 = (int) Main.tile[i, index203].frameX / 18;
int num254 = 0;
int num255 = i;
int num256 = index203 - (int) Main.tile[i, index203].frameY / 18;
for (; num253 >= 3; num253 -= 3)
++num254;
int num257 = num255 - num253;
for (int index222 = 0; index222 < 3; ++index222)
{
for (int index223 = 0; index223 < 2; ++index223)
{
int index224 = num257 + index222;
int index225 = num256 + index223;
Main.tile[index224, index225].active(true);
Main.tile[index224, index225].slope((byte) 0);
Main.tile[index224, index225].halfBrick(false);
Main.tile[index224, index225].type = (ushort) 26;
Main.tile[index224, index225].frameX = (short) (index222 * 18 + 54 * num254);
Main.tile[index224, index225].frameY = (short) (index223 * 18);
}
if (!Main.tile[num257 + index222, num256 + 2].active() || !Main.tileSolid[(int) Main.tile[num257 + index222, num256 + 2].type] || Main.tileSolidTop[(int) Main.tile[num257 + index222, num256 + 2].type])
{
Main.tile[num257 + index222, num256 + 2].active(true);
if (!TileID.Sets.Platforms[(int) Main.tile[num257 + index222, num256 + 2].type] && (!Main.tileSolid[(int) Main.tile[num257 + index222, num256 + 2].type] || Main.tileSolidTop[(int) Main.tile[num257 + index222, num256 + 2].type]))
Main.tile[num257 + index222, num256 + 2].type = (ushort) 0;
}
Main.tile[num257 + index222, num256 + 2].slope((byte) 0);
Main.tile[num257 + index222, num256 + 2].halfBrick(false);
if (Main.tile[num257 + index222, num256 + 3].type == (ushort) 28 && (int) Main.tile[num257 + index222, num256 + 3].frameY % 36 >= 18)
{
Main.tile[num257 + index222, num256 + 3].type = (ushort) 0;
Main.tile[num257 + index222, num256 + 3].active(false);
}
}
for (int index226 = 0; index226 < 3; ++index226)
{
if ((Main.tile[num257 - 1, num256 + index226].type == (ushort) 28 || Main.tile[num257 - 1, num256 + index226].type == (ushort) 12) && (int) Main.tile[num257 - 1, num256 + index226].frameX % 36 < 18)
{
Main.tile[num257 - 1, num256 + index226].type = (ushort) 0;
Main.tile[num257 - 1, num256 + index226].active(false);
}
if ((Main.tile[num257 + 3, num256 + index226].type == (ushort) 28 || Main.tile[num257 + 3, num256 + index226].type == (ushort) 12) && (int) Main.tile[num257 + 3, num256 + index226].frameX % 36 >= 18)
{
Main.tile[num257 + 3, num256 + index226].type = (ushort) 0;
Main.tile[num257 + 3, num256 + index226].active(false);
}
}
}
if (Main.tile[i, index203].type == (ushort) 237 && Main.tile[i, index203 + 1].type == (ushort) 232)
Main.tile[i, index203 + 1].type = (ushort) 226;
}
}
}));
WorldGen.AddGenerationPass("Lihzahrd Altars", (WorldGenLegacyMethod) (progress =>
{
int lAltarX = WorldGen.lAltarX;
int lAltarY = WorldGen.lAltarY;
for (int index227 = 0; index227 <= 2; ++index227)
{
for (int index228 = 0; index228 <= 1; ++index228)
{
int index229 = lAltarX + index227;
int index230 = lAltarY + index228;
Main.tile[index229, index230].active(true);
Main.tile[index229, index230].type = (ushort) 237;
Main.tile[index229, index230].frameX = (short) (index227 * 18);
Main.tile[index229, index230].frameY = (short) (index228 * 18);
}
Main.tile[index227, lAltarY + 2].active(true);
Main.tile[index227, lAltarY + 2].slope((byte) 0);
Main.tile[index227, lAltarY + 2].halfBrick(false);
Main.tile[index227, lAltarY + 2].type = (ushort) 226;
}
}));
WorldGen.AddGenerationPass("Micro Biomes", (WorldGenLegacyMethod) (progress =>
{
progress.Message = Lang.gen[76].Value;
float num258 = (float) (Main.maxTilesX * Main.maxTilesY) / 5040000f;
float num259 = (float) Main.maxTilesX / 4200f;
int num260 = (int) ((double) WorldGen.genRand.Next(3, 6) * (double) num258);
int num261 = 0;
while (num261 < num260)
{
if (Terraria.World.Generation.Biomes<ThinIceBiome>.Place(WorldGen.RandomWorldPoint((int) Main.worldSurface + 20, 50, 200, 50), structures))
++num261;
}
progress.Set(0.1f);
int num262 = (int) Math.Ceiling((double) num258);
int num263 = 0;
while (num263 < num262)
{
Point origin;
origin.Y = (int) worldSurface + WorldGen.genRand.Next(50, 100);
origin.X = WorldGen.genRand.Next(2) != 0 ? WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.699999988079071), Main.maxTilesX - 50) : WorldGen.genRand.Next(50, (int) ((double) Main.maxTilesX * 0.300000011920929));
if (Terraria.World.Generation.Biomes<EnchantedSwordBiome>.Place(origin, structures))
++num263;
}
progress.Set(0.2f);
int num264 = (int) ((double) WorldGen.genRand.Next(6, 12) * (double) num258);
int num265 = 0;
while (num265 < num264)
{
if (Terraria.World.Generation.Biomes<CampsiteBiome>.Place(WorldGen.RandomWorldPoint((int) Main.worldSurface, 50, 200, 50), structures))
++num265;
}
int num266 = (int) ((double) WorldGen.genRand.Next(14, 30) * (double) num258);
int num267 = 0;
while (num267 < num266)
{
if (Terraria.World.Generation.Biomes<MiningExplosivesBiome>.Place(WorldGen.RandomWorldPoint((int) rockLayer, 50, 200, 50), structures))
++num267;
}
progress.Set(0.3f);
int num268 = (int) ((double) WorldGen.genRand.Next(6, 12) * (double) num259);
int num269 = 0;
for (int index = 0; num269 < num268 && index < 20000; ++index)
{
if (Terraria.World.Generation.Biomes<MahoganyTreeBiome>.Place(WorldGen.RandomWorldPoint((int) Main.worldSurface + 50, 50, 500, 50), structures))
++num269;
}
progress.Set(0.4f);
if (!WorldGen.crimson)
{
int num270 = (int) ((double) WorldGen.genRand.Next(1, 3) * (double) num258);
int num271 = 0;
while (num271 < num270)
{
if (Terraria.World.Generation.Biomes<CorruptionPitBiome>.Place(WorldGen.RandomWorldPoint((int) Main.worldSurface, 50, 500, 50), structures))
++num271;
}
}
TrackGenerator.Run((int) (10.0 * (double) num258), (int) ((double) num258 * 25.0) + 250);
progress.Set(1f);
}));
WorldGen.AddGenerationPass("Final Cleanup", (WorldGenLegacyMethod) (progress =>
{
for (int i = 0; i < Main.maxTilesX; ++i)
{
for (int index = 0; index < Main.maxTilesY; ++index)
{
if (Main.tile[i, index].active() && (!WorldGen.SolidTile(i, index + 1) || !WorldGen.SolidTile(i, index + 2)))
{
switch (Main.tile[i, index].type)
{
case 53:
Main.tile[i, index].type = (ushort) 397;
continue;
case 112:
Main.tile[i, index].type = (ushort) 398;
continue;
case 123:
Main.tile[i, index].type = (ushort) 1;
continue;
case 224:
Main.tile[i, index].type = (ushort) 147;
continue;
case 234:
Main.tile[i, index].type = (ushort) 399;
continue;
default:
continue;
}
}
}
}
WorldGen.noTileActions = false;
WorldGen.gen = false;
Main.AnglerQuestSwap();
}));
WorldGen._generator.GenerateWorld(customProgressObject);
Main.WorldFileMetadata = FileMetadata.FromCurrentSettings(FileType.World);
}
public static Point RandomRectanglePoint(Microsoft.Xna.Framework.Rectangle rectangle) => new Point(WorldGen.genRand.Next(rectangle.X, rectangle.X + rectangle.Width), WorldGen.genRand.Next(rectangle.Y, rectangle.Y + rectangle.Height));
public static Point RandomRectanglePoint(int x, int y, int width, int height) => new Point(WorldGen.genRand.Next(x, x + width), WorldGen.genRand.Next(y, y + height));
public static Point RandomWorldPoint(int padding) => WorldGen.RandomWorldPoint(padding, padding, padding, padding);
public static Point RandomWorldPoint(int top = 0, int right = 0, int bottom = 0, int left = 0) => new Point(WorldGen.genRand.Next(left, Main.maxTilesX - right), WorldGen.genRand.Next(top, Main.maxTilesY - bottom));
public static bool GrowPalmTree(int i, int y)
{
int index1 = y;
while (Main.tile[i, index1].type == (ushort) 20)
++index1;
Tile tile1 = Main.tile[i, index1];
Tile tile2 = Main.tile[i, index1 - 1];
if (!tile1.active() || tile1.halfBrick() || tile1.slope() != (byte) 0 || tile2.wall != (byte) 0 || tile2.liquid != (byte) 0 || tile1.type != (ushort) 53 && tile1.type != (ushort) 234 && tile1.type != (ushort) 116 && tile1.type != (ushort) 112 || !WorldGen.EmptyTileCheck(i - 1, i + 1, index1 - 30, index1 - 1, 20))
return false;
int num1 = WorldGen.genRand.Next(10, 21);
int num2 = WorldGen.genRand.Next(-8, 9) * 2;
short num3 = 0;
for (int index2 = 0; index2 < num1; ++index2)
{
Tile tile3 = Main.tile[i, index1 - 1 - index2];
if (index2 == 0)
{
tile3.active(true);
tile3.type = (ushort) 323;
tile3.frameX = (short) 66;
tile3.frameY = (short) 0;
}
else if (index2 == num1 - 1)
{
tile3.active(true);
tile3.type = (ushort) 323;
tile3.frameX = (short) (22 * WorldGen.genRand.Next(4, 7));
tile3.frameY = num3;
}
else
{
if ((int) num3 != num2)
{
float num4 = (float) index2 / (float) num1;
if ((double) num4 >= 0.25 && ((double) num4 < 0.5 && WorldGen.genRand.Next(13) == 0 || (double) num4 < 0.699999988079071 && WorldGen.genRand.Next(9) == 0 || (double) num4 < 0.949999988079071 && WorldGen.genRand.Next(5) == 0 || true))
{
short num5 = (short) Math.Sign(num2);
num3 += (short) ((int) num5 * 2);
}
}
tile3.active(true);
tile3.type = (ushort) 323;
tile3.frameX = (short) (22 * WorldGen.genRand.Next(0, 3));
tile3.frameY = num3;
}
}
WorldGen.RangeFrame(i - 2, index1 - num1 - 1, i + 2, index1 + 1);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, i, (int) ((double) index1 - (double) num1 * 0.5), num1 + 1);
return true;
}
public static bool GrowEpicTree(int i, int y)
{
int index1 = y;
while (Main.tile[i, index1].type == (ushort) 20)
++index1;
if (Main.tile[i, index1].active() && !Main.tile[i, index1].halfBrick() && Main.tile[i, index1].slope() == (byte) 0 && Main.tile[i, index1].type == (ushort) 2 && Main.tile[i, index1 - 1].wall == (byte) 0 && Main.tile[i, index1 - 1].liquid == (byte) 0 && (Main.tile[i - 1, index1].active() && (Main.tile[i - 1, index1].type == (ushort) 2 || Main.tile[i - 1, index1].type == (ushort) 23 || Main.tile[i - 1, index1].type == (ushort) 60 || Main.tile[i - 1, index1].type == (ushort) 109) || Main.tile[i + 1, index1].active() && (Main.tile[i + 1, index1].type == (ushort) 2 || Main.tile[i + 1, index1].type == (ushort) 23 || Main.tile[i + 1, index1].type == (ushort) 60 || Main.tile[i + 1, index1].type == (ushort) 109)))
{
int num1 = 2;
if (WorldGen.EmptyTileCheck(i - num1, i + num1, index1 - 55, index1 - 1, 20))
{
bool flag1 = false;
bool flag2 = false;
int num2 = WorldGen.genRand.Next(20, 30);
for (int index2 = index1 - num2; index2 < index1; ++index2)
{
Main.tile[i, index2].frameNumber((byte) WorldGen.genRand.Next(3));
Main.tile[i, index2].active(true);
Main.tile[i, index2].type = (ushort) 5;
int num3 = WorldGen.genRand.Next(3);
int num4 = WorldGen.genRand.Next(10);
if (index2 == index1 - 1 || index2 == index1 - num2)
num4 = 0;
while (((num4 == 5 ? 1 : (num4 == 7 ? 1 : 0)) & (flag1 ? 1 : 0)) != 0 || ((num4 == 6 ? 1 : (num4 == 7 ? 1 : 0)) & (flag2 ? 1 : 0)) != 0)
num4 = WorldGen.genRand.Next(10);
flag1 = false;
flag2 = false;
if (num4 == 5 || num4 == 7)
flag1 = true;
if (num4 == 6 || num4 == 7)
flag2 = true;
switch (num4)
{
case 1:
if (num3 == 0)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 66;
}
if (num3 == 1)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 88;
}
if (num3 == 2)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 2:
if (num3 == 0)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 0;
}
if (num3 == 1)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 22;
}
if (num3 == 2)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
case 3:
if (num3 == 0)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 66;
}
if (num3 == 1)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 88;
}
if (num3 == 2)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 4:
if (num3 == 0)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 66;
}
if (num3 == 1)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 88;
}
if (num3 == 2)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 5:
if (num3 == 0)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 0;
}
if (num3 == 1)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 22;
}
if (num3 == 2)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
case 6:
if (num3 == 0)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 66;
}
if (num3 == 1)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 88;
}
if (num3 == 2)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 7:
if (num3 == 0)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 66;
}
if (num3 == 1)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 88;
}
if (num3 == 2)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
default:
if (num3 == 0)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 0;
}
if (num3 == 1)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 22;
}
if (num3 == 2)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
}
if (num4 == 5 || num4 == 7)
{
Main.tile[i - 1, index2].active(true);
Main.tile[i - 1, index2].type = (ushort) 5;
int num5 = WorldGen.genRand.Next(3);
if (WorldGen.genRand.Next(3) < 2)
{
if (num5 == 0)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 198;
}
if (num5 == 1)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 220;
}
if (num5 == 2)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 242;
}
}
else
{
if (num5 == 0)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 0;
}
if (num5 == 1)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 22;
}
if (num5 == 2)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 44;
}
}
}
if (num4 == 6 || num4 == 7)
{
Main.tile[i + 1, index2].active(true);
Main.tile[i + 1, index2].type = (ushort) 5;
int num6 = WorldGen.genRand.Next(3);
if (WorldGen.genRand.Next(3) < 2)
{
if (num6 == 0)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 198;
}
if (num6 == 1)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 220;
}
if (num6 == 2)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 242;
}
}
else
{
if (num6 == 0)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 66;
}
if (num6 == 1)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 88;
}
if (num6 == 2)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 110;
}
}
}
}
int num7 = WorldGen.genRand.Next(3);
bool flag3 = false;
bool flag4 = false;
if (Main.tile[i - 1, index1].active() && !Main.tile[i - 1, index1].halfBrick() && Main.tile[i - 1, index1].slope() == (byte) 0 && (Main.tile[i - 1, index1].type == (ushort) 2 || Main.tile[i - 1, index1].type == (ushort) 23 || Main.tile[i - 1, index1].type == (ushort) 60 || Main.tile[i - 1, index1].type == (ushort) 109))
flag3 = true;
if (Main.tile[i + 1, index1].active() && !Main.tile[i + 1, index1].halfBrick() && Main.tile[i + 1, index1].slope() == (byte) 0 && (Main.tile[i + 1, index1].type == (ushort) 2 || Main.tile[i + 1, index1].type == (ushort) 23 || Main.tile[i + 1, index1].type == (ushort) 60 || Main.tile[i + 1, index1].type == (ushort) 109))
flag4 = true;
if (!flag3)
{
if (num7 == 0)
num7 = 2;
if (num7 == 1)
num7 = 3;
}
if (!flag4)
{
if (num7 == 0)
num7 = 1;
if (num7 == 2)
num7 = 3;
}
if (flag3 && !flag4)
num7 = 2;
if (flag4 && !flag3)
num7 = 1;
if (num7 == 0 || num7 == 1)
{
Main.tile[i + 1, index1 - 1].active(true);
Main.tile[i + 1, index1 - 1].type = (ushort) 5;
int num8 = WorldGen.genRand.Next(3);
if (num8 == 0)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 132;
}
if (num8 == 1)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 154;
}
if (num8 == 2)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 176;
}
}
if (num7 == 0 || num7 == 2)
{
Main.tile[i - 1, index1 - 1].active(true);
Main.tile[i - 1, index1 - 1].type = (ushort) 5;
int num9 = WorldGen.genRand.Next(3);
if (num9 == 0)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 132;
}
if (num9 == 1)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 154;
}
if (num9 == 2)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 176;
}
}
int num10 = WorldGen.genRand.Next(3);
switch (num7)
{
case 0:
if (num10 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num10 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num10 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
case 1:
if (num10 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num10 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num10 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
case 2:
if (num10 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num10 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num10 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
}
if (WorldGen.genRand.Next(8) != 0)
{
int num11 = WorldGen.genRand.Next(3);
if (num11 == 0)
{
Main.tile[i, index1 - num2].frameX = (short) 22;
Main.tile[i, index1 - num2].frameY = (short) 198;
}
if (num11 == 1)
{
Main.tile[i, index1 - num2].frameX = (short) 22;
Main.tile[i, index1 - num2].frameY = (short) 220;
}
if (num11 == 2)
{
Main.tile[i, index1 - num2].frameX = (short) 22;
Main.tile[i, index1 - num2].frameY = (short) 242;
}
}
else
{
int num12 = WorldGen.genRand.Next(3);
if (num12 == 0)
{
Main.tile[i, index1 - num2].frameX = (short) 0;
Main.tile[i, index1 - num2].frameY = (short) 198;
}
if (num12 == 1)
{
Main.tile[i, index1 - num2].frameX = (short) 0;
Main.tile[i, index1 - num2].frameY = (short) 220;
}
if (num12 == 2)
{
Main.tile[i, index1 - num2].frameX = (short) 0;
Main.tile[i, index1 - num2].frameY = (short) 242;
}
}
WorldGen.RangeFrame(i - 2, index1 - num2 - 1, i + 2, index1 + 1);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, i, (int) ((double) index1 - (double) num2 * 0.5), num2 + 1);
return true;
}
}
return false;
}
public static bool Pyramid(int i, int j)
{
ushort num1 = 151;
int num2 = j - WorldGen.genRand.Next(0, 7);
int num3 = WorldGen.genRand.Next(9, 13);
int num4 = 1;
int num5 = j + WorldGen.genRand.Next(75, 125);
for (int index1 = num2; index1 < num5; ++index1)
{
for (int index2 = i - num4; index2 < i + num4 - 1; ++index2)
{
Main.tile[index2, index1].type = num1;
Main.tile[index2, index1].active(true);
Main.tile[index2, index1].halfBrick(false);
Main.tile[index2, index1].slope((byte) 0);
}
++num4;
}
for (int i1 = i - num4 - 5; i1 <= i + num4 + 5; ++i1)
{
for (int j1 = j - 1; j1 <= num5 + 1; ++j1)
{
bool flag = true;
for (int index3 = i1 - 1; index3 <= i1 + 1; ++index3)
{
for (int index4 = j1 - 1; index4 <= j1 + 1; ++index4)
{
if ((int) Main.tile[index3, index4].type != (int) num1)
flag = false;
}
}
if (flag)
{
Main.tile[i1, j1].wall = (byte) 34;
WorldGen.SquareWallFrame(i1, j1);
}
}
}
int num6 = 1;
if (WorldGen.genRand.Next(2) == 0)
num6 = -1;
int num7 = i - num3 * num6;
int j2 = j + num3;
int num8 = WorldGen.genRand.Next(5, 8);
bool flag1 = true;
int num9 = WorldGen.genRand.Next(20, 30);
while (flag1)
{
flag1 = false;
bool flag2 = false;
for (int index5 = j2; index5 <= j2 + num8; ++index5)
{
int index6 = num7;
if (Main.tile[index6, index5 - 1].type == (ushort) 53)
flag2 = true;
if ((int) Main.tile[index6, index5].type == (int) num1)
{
Main.tile[index6, index5 + 1].wall = (byte) 34;
Main.tile[index6 + num6, index5].wall = (byte) 34;
Main.tile[index6, index5].active(false);
flag1 = true;
}
if (flag2)
{
Main.tile[index6, index5].type = (ushort) 53;
Main.tile[index6, index5].active(true);
Main.tile[index6, index5].halfBrick(false);
Main.tile[index6, index5].slope((byte) 0);
}
}
num7 -= num6;
}
int index7 = i - num3 * num6;
bool flag3 = true;
bool flag4 = false;
bool flag5 = true;
while (flag5)
{
for (int index8 = j2; index8 <= j2 + num8; ++index8)
{
int index9 = index7;
Main.tile[index9, index8].active(false);
}
index7 += num6;
++j2;
--num9;
if (j2 >= num5 - num8 * 2)
num9 = 10;
if (num9 <= 0)
{
bool flag6 = false;
if (!flag3 && !flag4)
{
flag4 = true;
flag6 = true;
int num10 = WorldGen.genRand.Next(7, 13);
int num11 = WorldGen.genRand.Next(23, 28);
int num12 = num11;
int num13 = index7;
while (num11 > 0)
{
for (int index10 = j2 - num10 + num8; index10 <= j2 + num8; ++index10)
{
if (num11 == num12 || num11 == 1)
{
if (index10 >= j2 - num10 + num8 + 2)
Main.tile[index7, index10].active(false);
}
else if (num11 == num12 - 1 || num11 == 2 || num11 == num12 - 2 || num11 == 3)
{
if (index10 >= j2 - num10 + num8 + 1)
Main.tile[index7, index10].active(false);
}
else
Main.tile[index7, index10].active(false);
}
--num11;
index7 += num6;
}
int num14 = index7 - num6;
int minValue = num14;
int maxValue = num13;
if (num14 > num13)
{
minValue = num13;
maxValue = num14;
}
int contain = WorldGen.genRand.Next(3);
switch (contain)
{
case 0:
contain = 857;
break;
case 1:
contain = 848;
break;
case 2:
contain = 934;
break;
}
WorldGen.AddBuriedChest((minValue + maxValue) / 2, j2, contain, Style: 1);
int num15 = WorldGen.genRand.Next(1, 10);
for (int index11 = 0; index11 < num15; ++index11)
WorldGen.PlaceSmallPile(WorldGen.genRand.Next(minValue, maxValue), j2 + num8, WorldGen.genRand.Next(16, 19), 1);
WorldGen.PlaceTile(minValue + 2, j2 - num10 + num8 + 1, 91, true, style: WorldGen.genRand.Next(4, 7));
WorldGen.PlaceTile(minValue + 3, j2 - num10 + num8, 91, true, style: WorldGen.genRand.Next(4, 7));
WorldGen.PlaceTile(maxValue - 2, j2 - num10 + num8 + 1, 91, true, style: WorldGen.genRand.Next(4, 7));
WorldGen.PlaceTile(maxValue - 3, j2 - num10 + num8, 91, true, style: WorldGen.genRand.Next(4, 7));
for (int x = minValue; x <= maxValue; ++x)
WorldGen.PlacePot(x, j2 + num8, style: WorldGen.genRand.Next(25, 28));
}
if (flag3)
{
flag3 = false;
num6 *= -1;
num9 = WorldGen.genRand.Next(15, 20);
}
else if (flag6)
{
num9 = WorldGen.genRand.Next(10, 15);
}
else
{
num6 *= -1;
num9 = WorldGen.genRand.Next(20, 40);
}
}
if (j2 >= num5 - num8)
flag5 = false;
}
int num16 = WorldGen.genRand.Next(100, 200);
int num17 = WorldGen.genRand.Next(500, 800);
bool flag7 = true;
int num18 = num8;
int num19 = WorldGen.genRand.Next(10, 50);
if (num6 == 1)
index7 -= num18;
int num20 = WorldGen.genRand.Next(5, 10);
while (flag7)
{
--num16;
--num17;
--num19;
for (int index12 = index7 - num20 - WorldGen.genRand.Next(0, 2); index12 <= index7 + num18 + num20 + WorldGen.genRand.Next(0, 2); ++index12)
{
int index13 = j2;
if (index12 >= index7 && index12 <= index7 + num18)
{
Main.tile[index12, index13].active(false);
}
else
{
Main.tile[index12, index13].type = num1;
Main.tile[index12, index13].active(true);
Main.tile[index12, index13].halfBrick(false);
Main.tile[index12, index13].slope((byte) 0);
}
if (index12 >= index7 - 1 && index12 <= index7 + 1 + num18)
Main.tile[index12, index13].wall = (byte) 34;
}
++j2;
index7 += num6;
if (num16 <= 0)
{
flag7 = false;
for (int index14 = index7 + 1; index14 <= index7 + num18 - 1; ++index14)
{
if (Main.tile[index14, j2].active())
flag7 = true;
}
}
if (num19 < 0)
{
num19 = WorldGen.genRand.Next(10, 50);
num6 *= -1;
}
if (num17 <= 0)
flag7 = false;
}
return true;
}
public static bool GrowLivingTree(int i, int j)
{
int index1 = 0;
int[] numArray1 = new int[1000];
int[] numArray2 = new int[1000];
int[] numArray3 = new int[1000];
int[] numArray4 = new int[1000];
int index2 = 0;
int[] numArray5 = new int[2000];
int[] numArray6 = new int[2000];
bool[] flagArray = new bool[2000];
if (!WorldGen.SolidTile(i, j + 1) || Main.tile[i, j].active())
return false;
int num1 = i - WorldGen.genRand.Next(1, 4);
int num2 = i + WorldGen.genRand.Next(1, 4);
if (j < 150)
return false;
int num3 = i - 50;
int num4 = i + 50;
for (int index3 = num3; index3 <= num4; ++index3)
{
for (int index4 = 5; index4 < j - 5; ++index4)
{
if (Main.tile[index3, index4].active())
return false;
}
}
int num5 = num1;
int num6 = num2;
int num7 = num1;
int num8 = num2;
int minValue = num2 - num1;
bool flag1 = true;
int num9 = WorldGen.genRand.Next(-10, -5);
int num10 = WorldGen.genRand.Next(2);
int index5 = j;
while (flag1)
{
++num9;
if (num9 > WorldGen.genRand.Next(5, 30))
{
num9 = 0;
numArray2[index1] = index5 + WorldGen.genRand.Next(5);
if (WorldGen.genRand.Next(5) == 0)
num10 = num10 != 0 ? 0 : 1;
if (num10 == 0)
{
numArray3[index1] = -1;
numArray1[index1] = num1;
numArray4[index1] = num2 - num1;
if (WorldGen.genRand.Next(2) == 0)
++num1;
++num5;
num10 = 1;
}
else
{
numArray3[index1] = 1;
numArray1[index1] = num2;
numArray4[index1] = num2 - num1;
if (WorldGen.genRand.Next(2) == 0)
--num2;
--num6;
num10 = 0;
}
if (num5 == num6)
flag1 = false;
++index1;
}
for (int index6 = num1; index6 <= num2; ++index6)
{
Main.tile[index6, index5].type = (ushort) 191;
Main.tile[index6, index5].active(true);
Main.tile[index6, index5].halfBrick(false);
}
--index5;
}
for (int index7 = 0; index7 < index1; ++index7)
{
int index8 = numArray1[index7] + numArray3[index7];
int index9 = numArray2[index7];
int num11 = (int) ((double) numArray4[index7] * (1.0 + (double) WorldGen.genRand.Next(20, 30) * 0.100000001490116));
Main.tile[index8, index9 + 1].type = (ushort) 191;
Main.tile[index8, index9 + 1].active(true);
Main.tile[index8, index9 + 1].halfBrick(false);
int num12 = WorldGen.genRand.Next(3, 5);
while (num11 > 0)
{
--num11;
Main.tile[index8, index9].type = (ushort) 191;
Main.tile[index8, index9].active(true);
Main.tile[index8, index9].halfBrick(false);
if (WorldGen.genRand.Next(10) == 0)
{
if (WorldGen.genRand.Next(2) == 0)
--index9;
else
++index9;
}
else
index8 += numArray3[index7];
if (num12 > 0)
--num12;
else if (WorldGen.genRand.Next(2) == 0)
{
num12 = WorldGen.genRand.Next(2, 5);
if (WorldGen.genRand.Next(2) == 0)
{
Main.tile[index8, index9].type = (ushort) 191;
Main.tile[index8, index9].active(true);
Main.tile[index8, index9].halfBrick(false);
Main.tile[index8, index9 - 1].type = (ushort) 191;
Main.tile[index8, index9 - 1].active(true);
Main.tile[index8, index9 - 1].halfBrick(false);
numArray5[index2] = index8;
numArray6[index2] = index9;
++index2;
}
else
{
Main.tile[index8, index9].type = (ushort) 191;
Main.tile[index8, index9].active(true);
Main.tile[index8, index9].halfBrick(false);
Main.tile[index8, index9 + 1].type = (ushort) 191;
Main.tile[index8, index9 + 1].active(true);
Main.tile[index8, index9 + 1].halfBrick(false);
numArray5[index2] = index8;
numArray6[index2] = index9;
++index2;
}
}
if (num11 == 0)
{
numArray5[index2] = index8;
numArray6[index2] = index9;
++index2;
}
}
}
int index10 = (num1 + num2) / 2;
int index11 = index5;
int num13 = WorldGen.genRand.Next(minValue * 3, minValue * 5);
int num14 = 0;
int num15 = 0;
for (; num13 > 0; --num13)
{
Main.tile[index10, index11].type = (ushort) 191;
Main.tile[index10, index11].active(true);
Main.tile[index10, index11].halfBrick(false);
if (num14 > 0)
--num14;
if (num15 > 0)
--num15;
for (int index12 = -1; index12 < 2; ++index12)
{
if (index12 != 0 && (index12 < 0 && num14 == 0 || index12 > 0 && num15 == 0) && WorldGen.genRand.Next(2) == 0)
{
int index13 = index10;
int index14 = index11;
int num16 = WorldGen.genRand.Next(minValue, minValue * 3);
if (index12 < 0)
num14 = WorldGen.genRand.Next(3, 5);
if (index12 > 0)
num15 = WorldGen.genRand.Next(3, 5);
int num17 = 0;
while (num16 > 0)
{
--num16;
index13 += index12;
Main.tile[index13, index14].type = (ushort) 191;
Main.tile[index13, index14].active(true);
Main.tile[index13, index14].halfBrick(false);
if (num16 == 0)
{
numArray5[index2] = index13;
numArray6[index2] = index14;
flagArray[index2] = true;
++index2;
}
if (WorldGen.genRand.Next(5) == 0)
{
if (WorldGen.genRand.Next(2) == 0)
--index14;
else
++index14;
Main.tile[index13, index14].type = (ushort) 191;
Main.tile[index13, index14].active(true);
Main.tile[index13, index14].halfBrick(false);
}
if (num17 > 0)
--num17;
else if (WorldGen.genRand.Next(3) == 0)
{
num17 = WorldGen.genRand.Next(2, 4);
int index15 = index13;
int num18 = index14;
int index16 = WorldGen.genRand.Next(2) != 0 ? num18 + 1 : num18 - 1;
Main.tile[index15, index16].type = (ushort) 191;
Main.tile[index15, index16].active(true);
Main.tile[index15, index16].halfBrick(false);
numArray5[index2] = index15;
numArray6[index2] = index16;
flagArray[index2] = true;
++index2;
}
}
}
}
numArray5[index2] = index10;
numArray6[index2] = index11;
++index2;
if (WorldGen.genRand.Next(4) == 0)
{
if (WorldGen.genRand.Next(2) == 0)
--index10;
else
++index10;
Main.tile[index10, index11].type = (ushort) 191;
Main.tile[index10, index11].active(true);
Main.tile[index10, index11].halfBrick(false);
}
--index11;
}
for (int i1 = num7; i1 <= num8; ++i1)
{
int num19 = WorldGen.genRand.Next(1, 6);
int j1 = j + 1;
while (num19 > 0)
{
if (WorldGen.SolidTile(i1, j1))
--num19;
Main.tile[i1, j1].type = (ushort) 191;
Main.tile[i1, j1].active(true);
Main.tile[i1, j1].halfBrick(false);
++j1;
}
int num20 = j1;
for (int index17 = 0; index17 < 2; ++index17)
{
int index18 = num20;
int num21 = (num7 + num8) / 2;
int num22 = 1;
int num23 = i1 >= num21 ? 1 : -1;
if (i1 == num21 || minValue > 6 && (i1 == num21 - 1 || i1 == num21 + 1))
num23 = 0;
int num24 = num23;
int index19 = i1;
int num25 = WorldGen.genRand.Next((int) ((double) minValue * 2.5), minValue * 4);
while (num25 > 0)
{
--num25;
index19 += num23;
Main.tile[index19, index18].type = (ushort) 191;
Main.tile[index19, index18].active(true);
Main.tile[index19, index18].halfBrick(false);
index18 += num22;
Main.tile[index19, index18].type = (ushort) 191;
Main.tile[index19, index18].active(true);
Main.tile[index19, index18].halfBrick(false);
if (!Main.tile[index19, index18 + 1].active())
{
num23 = 0;
num22 = 1;
}
if (WorldGen.genRand.Next(3) == 0)
num23 = num24 >= 0 ? (num24 <= 0 ? WorldGen.genRand.Next(-1, 2) : (num23 != 0 ? 0 : 1)) : (num23 != 0 ? 0 : -1);
if (WorldGen.genRand.Next(3) == 0)
num22 = num22 != 0 ? 0 : 1;
}
}
}
for (int index20 = 0; index20 < index2; ++index20)
{
int num26 = (int) ((double) WorldGen.genRand.Next(5, 8) * (1.0 + (double) minValue * 0.0500000007450581));
if (flagArray[index20])
num26 = WorldGen.genRand.Next(7, 13);
int num27 = numArray5[index20] - num26;
int num28 = numArray5[index20] + num26;
int num29 = numArray6[index20] - num26;
int num30 = numArray6[index20] + num26;
float num31 = (float) (2.0 - (double) WorldGen.genRand.Next(5) * 0.100000001490116);
for (int index21 = num27; index21 <= num28; ++index21)
{
for (int index22 = num29; index22 <= num30; ++index22)
{
if (Main.tile[index21, index22].type != (ushort) 191 && (double) Math.Abs(numArray5[index20] - index21) + (double) Math.Abs(numArray6[index20] - index22) * (double) num31 < (double) num26)
{
Main.tile[index21, index22].type = (ushort) 192;
Main.tile[index21, index22].active(true);
Main.tile[index21, index22].halfBrick(false);
}
}
}
}
if (minValue >= 4 && WorldGen.genRand.Next(3) != 0)
{
bool flag2 = false;
int num32 = num7;
int num33 = num8;
int j2 = j - 5;
int num34 = 50;
int num35 = WorldGen.genRand.Next(400, 700);
int num36 = 1;
bool flag3 = true;
while (num35 > 0)
{
++j2;
--num35;
--num34;
int num37 = (num7 + num8) / 2;
int num38 = 0;
if (j2 > j && minValue == 4)
num38 = 1;
for (int index23 = num7 - num38; index23 <= num8 + num38; ++index23)
{
if (index23 > num37 - 2 && index23 <= num37 + 1)
{
if (Main.tile[index23, j2].type != (ushort) 19)
Main.tile[index23, j2].active(false);
Main.tile[index23, j2].wall = (byte) 78;
if (Main.tile[index23 - 1, j2].wall > (byte) 0 || (double) j2 >= Main.worldSurface)
Main.tile[index23 - 1, j2].wall = (byte) 78;
if (Main.tile[index23 + 1, j2].wall > (byte) 0 || (double) j2 >= Main.worldSurface)
Main.tile[index23 + 1, j2].wall = (byte) 78;
}
else
{
Main.tile[index23, j2].type = (ushort) 191;
Main.tile[index23, j2].active(true);
Main.tile[index23, j2].halfBrick(false);
}
}
++num36;
if (num36 >= 6)
{
num36 = 0;
int num39 = WorldGen.genRand.Next(3);
if (num39 == 0)
num39 = -1;
if (flag3)
num39 = 2;
if (num39 == 2)
{
flag3 = false;
for (int i2 = num7; i2 <= num8; ++i2)
{
if (i2 > num37 - 2 && i2 <= num37 + 1)
{
Main.tile[i2, j2 + 1].active(false);
WorldGen.PlaceTile(i2, j2 + 1, 19, true, style: 23);
}
}
}
else
{
num7 += num39;
num8 += num39;
}
if (num34 <= 0 && !flag2)
{
flag2 = true;
int num40 = WorldGen.genRand.Next(2);
if (num40 == 0)
num40 = -1;
int num41 = j2 - 2;
int num42 = j2;
int num43 = (num7 + num8) / 2;
if (num40 < 0)
--num43;
if (num40 > 0)
++num43;
int num44 = WorldGen.genRand.Next(15, 30);
int num45 = num43 + num44;
if (num40 < 0)
{
num45 = num43;
num43 -= num44;
}
WorldGen.dMinX = num43;
WorldGen.dMaxX = num45;
if (num40 < 0)
WorldGen.dMinX -= 40;
else
WorldGen.dMaxX += 40;
bool flag4 = false;
for (int index24 = num43; index24 < num45; ++index24)
{
for (int index25 = j2 - 20; index25 < j2 + 10; ++index25)
{
if (Main.tile[index24, index25].wall == (byte) 0 && !Main.tile[index24, index25].active() && (double) index25 < Main.worldSurface)
flag4 = true;
}
}
if (!flag4)
{
for (int index26 = num43; index26 <= num45; ++index26)
{
for (int index27 = num41 - 2; index27 <= num42 + 2; ++index27)
{
if (Main.tile[index26, index27].wall != (byte) 78 && Main.tile[index26, index27].type != (ushort) 19)
{
Main.tile[index26, index27].active(true);
Main.tile[index26, index27].type = (ushort) 191;
Main.tile[index26, index27].halfBrick(false);
}
if (index27 >= num41 && index27 <= num42)
{
Main.tile[index26, index27].liquid = (byte) 0;
Main.tile[index26, index27].wall = (byte) 78;
Main.tile[index26, index27].active(false);
}
}
}
int i3 = (num7 + num8) / 2 + 3 * num40;
int j3 = j2;
WorldGen.PlaceTile(i3, j3, 10, true, style: 7);
int num46 = WorldGen.genRand.Next(5, 9);
int num47 = WorldGen.genRand.Next(4, 6);
int num48;
int num49;
if (num40 < 0)
{
num48 = num43 + num46;
num49 = num43 - num46;
}
else
{
num49 = num45 - num46;
num48 = num45 + num46;
}
int num50 = num42 - num47;
for (int index28 = num49 - 2; index28 <= num48 + 2; ++index28)
{
for (int index29 = num50 - 2; index29 <= num42 + 2; ++index29)
{
if (Main.tile[index28, index29].wall != (byte) 78 && Main.tile[index28, index29].type != (ushort) 19)
{
Main.tile[index28, index29].active(true);
Main.tile[index28, index29].type = (ushort) 191;
Main.tile[index28, index29].halfBrick(false);
}
if (index29 >= num50 && index29 <= num42 && index28 >= num49 && index28 <= num48)
{
Main.tile[index28, index29].liquid = (byte) 0;
Main.tile[index28, index29].wall = (byte) 78;
Main.tile[index28, index29].active(false);
}
}
}
int i4 = num49 - 2;
if (num40 < 0)
i4 = num48 + 2;
WorldGen.PlaceTile(i4, j3, 10, true, style: 7);
int i5 = num48;
if (num40 < 0)
i5 = num49;
WorldGen.PlaceTile(i5, j2, 15, true, style: 5);
if (num40 < 0)
{
Main.tile[i5, j2 - 1].frameX += (short) 18;
Main.tile[i5, j2].frameX += (short) 18;
}
int i6 = num48 - 2;
if (num40 < 0)
i6 = num49 + 2;
WorldGen.PlaceTile(i6, j2, 14, true, style: 6);
int i7 = num48 - 4;
if (num40 < 0)
i7 = num49 + 4;
WorldGen.PlaceTile(i7, j2, 15, true, style: 5);
if (num40 > 0)
{
Main.tile[i7, j2 - 1].frameX += (short) 18;
Main.tile[i7, j2].frameX += (short) 18;
}
int i8 = num48 - 7;
if (num40 < 0)
i8 = num49 + 8;
WorldGen.genRand.Next(2);
int contain = 832;
WorldGen.AddBuriedChest(i8, j2, contain, Style: 12);
}
}
}
if (num34 <= 0)
{
bool flag5 = true;
for (int i9 = num7; i9 <= num8; ++i9)
{
for (int j4 = j2 + 1; j4 <= j2 + 4; ++j4)
{
if (WorldGen.SolidTile(i9, j4))
flag5 = false;
}
}
if (flag5)
num35 = 0;
}
}
int num51 = num32;
int num52 = num33;
int num53 = (num51 + num52) / 2;
if (WorldGen.genRand.Next(2) == 0)
num52 = num53;
else
num51 = num53;
for (int index30 = num51; index30 <= num52; ++index30)
{
for (int index31 = j - 3; index31 <= j; ++index31)
{
Main.tile[index30, index31].active(false);
bool flag6 = true;
for (int index32 = index30 - 1; index32 <= index30 + 1; ++index32)
{
for (int index33 = index31 - 1; index33 <= index31 + 1; ++index33)
{
if (!Main.tile[index32, index33].active() && Main.tile[index32, index33].wall == (byte) 0)
flag6 = false;
}
}
if (flag6)
Main.tile[index30, index31].wall = (byte) 78;
}
}
}
return true;
}
public static void TreeGrowFXCheck(int x, int y)
{
int height = 1;
int num1 = -1;
Tile tile1 = (Tile) null;
for (int index = -1; index > -100; --index)
{
Tile tile2 = Main.tile[x, y + index];
if (tile2.active() && (tile2.type == (ushort) 5 || tile2.type == (ushort) 323 || tile2.type == (ushort) 72))
{
tile1 = tile2;
++height;
}
else
break;
}
for (int index = 1; index < 5; ++index)
{
Tile tile3 = Main.tile[x, y + index];
if (tile3.active() && (tile3.type == (ushort) 5 || tile3.type == (ushort) 323 || tile3.type == (ushort) 72))
{
++height;
}
else
{
int num2 = 0;
if (tile1.frameX == (short) 22)
{
if (tile1.frameY == (short) 220)
num2 = 1;
else if (tile1.frameY == (short) 242)
num2 = 2;
}
switch (tile3.type)
{
case 2:
num1 = 910;
goto label_39;
case 23:
case 400:
num1 = 915;
goto label_39;
case 53:
num1 = 911;
goto label_39;
case 60:
num1 = 914;
goto label_39;
case 70:
num1 = 912;
goto label_39;
case 109:
if (x % 3 == 1)
num2 += 3;
if (x % 3 == 2)
num2 += 6;
int num3 = 917;
switch (num2)
{
case 0:
num1 = 2;
break;
case 1:
num1 = 1;
break;
case 2:
num1 = 7;
break;
case 3:
num1 = 4;
break;
case 4:
num1 = 5;
break;
case 5:
num1 = 6;
break;
case 6:
num1 = 3;
break;
case 7:
num1 = 8;
break;
case 8:
num1 = 0;
break;
}
num1 += num3;
height += 5;
goto label_39;
case 116:
num1 = 919;
goto label_39;
case 147:
num1 = 913;
goto label_39;
case 199:
case 234:
num1 = 916;
goto label_39;
default:
goto label_39;
}
}
}
label_39:
if (height <= 0 || num1 <= 0)
return;
if (Main.netMode == 2)
NetMessage.SendData(112, number: 1, number2: ((float) x), number3: ((float) y), number4: ((float) height), number5: num1);
if (Main.netMode != 0)
return;
WorldGen.TreeGrowFX(x, y, height, num1);
}
public static void TreeGrowFX(int x, int y, int height, int treeGore)
{
Vector2 vector2 = new Vector2((float) x, (float) y) * 16f + new Vector2(8f, 8f);
int Type = treeGore;
int num = 4;
int maxValue = 2;
for (int index1 = 0; index1 > -height; --index1)
{
if (index1 > -height / 2 && Main.rand.Next(3) != 0)
{
for (int index2 = 0; index2 < 5; ++index2)
Dust.NewDust(vector2 + new Vector2(-16f, (float) (index1 * 16)) + Utils.RandomVector2(Main.rand, -20f, 20f), 4, 4, num + Main.rand.Next(maxValue), SpeedY: -4f, Alpha: 100);
}
else
{
float max = 10f;
Gore.NewGore(vector2 + new Vector2(-16f, (float) (index1 * 16)), Utils.RandomVector2(Main.rand, -max, max), Type, (float) (0.699999988079071 + (double) Main.rand.NextFloat() * 0.600000023841858));
Gore.NewGore(vector2 + new Vector2(0.0f, (float) (index1 * 16)), Utils.RandomVector2(Main.rand, -max, max), Type, (float) (0.699999988079071 + (double) Main.rand.NextFloat() * 0.600000023841858));
Gore.NewGore(vector2 + new Vector2(16f, (float) (index1 * 16)), Utils.RandomVector2(Main.rand, -max, max), Type, (float) (0.699999988079071 + (double) Main.rand.NextFloat() * 0.600000023841858));
if (index1 == -height + 1)
{
for (int index3 = 0; index3 < 20; ++index3)
Gore.NewGore(vector2 + new Vector2(0.0f, (float) (index1 * 16 - 40)) + Utils.RandomVector2(Main.rand, -40f, 40f), Utils.RandomVector2(Main.rand, -10f, 10f), Type, (float) (0.699999988079071 + (double) Main.rand.NextFloat() * 0.600000023841858));
}
}
}
}
public static bool GrowTree(int i, int y)
{
int index1 = y;
while (Main.tile[i, index1].type == (ushort) 20)
++index1;
if ((Main.tile[i - 1, index1 - 1].liquid != (byte) 0 || Main.tile[i, index1 - 1].liquid != (byte) 0 || Main.tile[i + 1, index1 - 1].liquid != (byte) 0) && Main.tile[i, index1].type != (ushort) 60 || !Main.tile[i, index1].nactive() || Main.tile[i, index1].halfBrick() || Main.tile[i, index1].slope() != (byte) 0 || Main.tile[i, index1].type != (ushort) 2 && Main.tile[i, index1].type != (ushort) 23 && Main.tile[i, index1].type != (ushort) 60 && Main.tile[i, index1].type != (ushort) 109 && Main.tile[i, index1].type != (ushort) 147 && Main.tile[i, index1].type != (ushort) 199 && Main.tile[i, index1].type != (ushort) 70 || Main.tile[i, index1 - 1].wall != (byte) 0 && Main.tile[i, index1 - 1].wall != (byte) 106 && Main.tile[i, index1 - 1].wall != (byte) 107 && (Main.tile[i, index1 - 1].wall < (byte) 138 || Main.tile[i, index1 - 1].wall > (byte) 141) && Main.tile[i, index1 - 1].wall != (byte) 145 && Main.tile[i, index1 - 1].wall != (byte) 150 && Main.tile[i, index1 - 1].wall != (byte) 152 || (!Main.tile[i - 1, index1].active() || Main.tile[i - 1, index1].type != (ushort) 2 && Main.tile[i - 1, index1].type != (ushort) 23 && Main.tile[i - 1, index1].type != (ushort) 60 && Main.tile[i - 1, index1].type != (ushort) 109 && Main.tile[i - 1, index1].type != (ushort) 147 && Main.tile[i - 1, index1].type != (ushort) 199 && Main.tile[i - 1, index1].type != (ushort) 70) && (!Main.tile[i + 1, index1].active() || Main.tile[i + 1, index1].type != (ushort) 2 && Main.tile[i + 1, index1].type != (ushort) 23 && Main.tile[i + 1, index1].type != (ushort) 60 && Main.tile[i + 1, index1].type != (ushort) 109 && Main.tile[i + 1, index1].type != (ushort) 147 && Main.tile[i + 1, index1].type != (ushort) 199 && Main.tile[i + 1, index1].type != (ushort) 70))
return false;
int num1 = 2;
int num2 = 16;
if (Main.tile[i, index1].type == (ushort) 60)
num2 += 5;
if (!WorldGen.EmptyTileCheck(i - num1, i + num1, index1 - num2, index1 - 1, 20))
return false;
bool flag1 = false;
bool flag2 = false;
int num3 = WorldGen.genRand.Next(5, num2 + 1);
for (int index2 = index1 - num3; index2 < index1; ++index2)
{
Main.tile[i, index2].frameNumber((byte) WorldGen.genRand.Next(3));
Main.tile[i, index2].active(true);
Main.tile[i, index2].type = (ushort) 5;
int num4 = WorldGen.genRand.Next(3);
int num5 = WorldGen.genRand.Next(10);
if (index2 == index1 - 1 || index2 == index1 - num3)
num5 = 0;
while (((num5 == 5 ? 1 : (num5 == 7 ? 1 : 0)) & (flag1 ? 1 : 0)) != 0 || ((num5 == 6 ? 1 : (num5 == 7 ? 1 : 0)) & (flag2 ? 1 : 0)) != 0)
num5 = WorldGen.genRand.Next(10);
flag1 = false;
flag2 = false;
if (num5 == 5 || num5 == 7)
flag1 = true;
if (num5 == 6 || num5 == 7)
flag2 = true;
switch (num5)
{
case 1:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 2:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 0;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 22;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
case 3:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 4:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 5:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 0;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 22;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
case 6:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 7:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
default:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 0;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 22;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
}
if (num5 == 5 || num5 == 7)
{
Main.tile[i - 1, index2].active(true);
Main.tile[i - 1, index2].type = (ushort) 5;
int num6 = WorldGen.genRand.Next(3);
if (WorldGen.genRand.Next(3) < 2)
{
if (num6 == 0)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 198;
}
if (num6 == 1)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 220;
}
if (num6 == 2)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 242;
}
}
else
{
if (num6 == 0)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 0;
}
if (num6 == 1)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 22;
}
if (num6 == 2)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 44;
}
}
}
if (num5 == 6 || num5 == 7)
{
Main.tile[i + 1, index2].active(true);
Main.tile[i + 1, index2].type = (ushort) 5;
int num7 = WorldGen.genRand.Next(3);
if (WorldGen.genRand.Next(3) < 2)
{
if (num7 == 0)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 198;
}
if (num7 == 1)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 220;
}
if (num7 == 2)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 242;
}
}
else
{
if (num7 == 0)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 66;
}
if (num7 == 1)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 88;
}
if (num7 == 2)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 110;
}
}
}
}
int num8 = WorldGen.genRand.Next(3);
bool flag3 = false;
bool flag4 = false;
if (Main.tile[i - 1, index1].nactive() && !Main.tile[i - 1, index1].halfBrick() && Main.tile[i - 1, index1].slope() == (byte) 0 && (Main.tile[i - 1, index1].type == (ushort) 2 || Main.tile[i - 1, index1].type == (ushort) 23 || Main.tile[i - 1, index1].type == (ushort) 60 || Main.tile[i - 1, index1].type == (ushort) 109 || Main.tile[i - 1, index1].type == (ushort) 147 || Main.tile[i - 1, index1].type == (ushort) 199))
flag3 = true;
if (Main.tile[i + 1, index1].nactive() && !Main.tile[i + 1, index1].halfBrick() && Main.tile[i + 1, index1].slope() == (byte) 0 && (Main.tile[i + 1, index1].type == (ushort) 2 || Main.tile[i + 1, index1].type == (ushort) 23 || Main.tile[i + 1, index1].type == (ushort) 60 || Main.tile[i + 1, index1].type == (ushort) 109 || Main.tile[i + 1, index1].type == (ushort) 147 || Main.tile[i + 1, index1].type == (ushort) 199))
flag4 = true;
if (!flag3)
{
if (num8 == 0)
num8 = 2;
if (num8 == 1)
num8 = 3;
}
if (!flag4)
{
if (num8 == 0)
num8 = 1;
if (num8 == 2)
num8 = 3;
}
if (flag3 && !flag4)
num8 = 2;
if (flag4 && !flag3)
num8 = 1;
if (num8 == 0 || num8 == 1)
{
Main.tile[i + 1, index1 - 1].active(true);
Main.tile[i + 1, index1 - 1].type = (ushort) 5;
int num9 = WorldGen.genRand.Next(3);
if (num9 == 0)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 132;
}
if (num9 == 1)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 154;
}
if (num9 == 2)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 176;
}
}
if (num8 == 0 || num8 == 2)
{
Main.tile[i - 1, index1 - 1].active(true);
Main.tile[i - 1, index1 - 1].type = (ushort) 5;
int num10 = WorldGen.genRand.Next(3);
if (num10 == 0)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 132;
}
if (num10 == 1)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 154;
}
if (num10 == 2)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 176;
}
}
int num11 = WorldGen.genRand.Next(3);
switch (num8)
{
case 0:
if (num11 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num11 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num11 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
case 1:
if (num11 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num11 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num11 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
case 2:
if (num11 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num11 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num11 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
}
if (WorldGen.genRand.Next(8) != 0)
{
int num12 = WorldGen.genRand.Next(3);
if (num12 == 0)
{
Main.tile[i, index1 - num3].frameX = (short) 22;
Main.tile[i, index1 - num3].frameY = (short) 198;
}
if (num12 == 1)
{
Main.tile[i, index1 - num3].frameX = (short) 22;
Main.tile[i, index1 - num3].frameY = (short) 220;
}
if (num12 == 2)
{
Main.tile[i, index1 - num3].frameX = (short) 22;
Main.tile[i, index1 - num3].frameY = (short) 242;
}
}
else
{
int num13 = WorldGen.genRand.Next(3);
if (num13 == 0)
{
Main.tile[i, index1 - num3].frameX = (short) 0;
Main.tile[i, index1 - num3].frameY = (short) 198;
}
if (num13 == 1)
{
Main.tile[i, index1 - num3].frameX = (short) 0;
Main.tile[i, index1 - num3].frameY = (short) 220;
}
if (num13 == 2)
{
Main.tile[i, index1 - num3].frameX = (short) 0;
Main.tile[i, index1 - num3].frameY = (short) 242;
}
}
WorldGen.RangeFrame(i - 2, index1 - num3 - 1, i + 2, index1 + 1);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, i, (int) ((double) index1 - (double) num3 * 0.5), num3 + 1);
return true;
}
public static void GrowUndergroundTree(int i, int y)
{
int index1 = y;
if (Main.tile[i, index1].type != (ushort) 60 || !Main.tile[i, index1].nactive() || Main.tile[i, index1].halfBrick() || Main.tile[i, index1].slope() != (byte) 0 || Main.tile[i, index1].type != (ushort) 60 || (!Main.tile[i - 1, index1].active() || Main.tile[i - 1, index1].type != (ushort) 60) && (!Main.tile[i + 1, index1].active() || Main.tile[i + 1, index1].type != (ushort) 60))
return;
int num1 = 1;
int num2 = WorldGen.genRand.Next(5, 15);
int num3 = num2 + 2;
if (Main.tile[i, index1].type == (ushort) 60)
num3 += 5;
if (!WorldGen.EmptyTileCheck(i - num1, i + num1, index1 - num3, index1 - 1, 20))
return;
bool flag1 = false;
bool flag2 = false;
for (int index2 = index1 - num2; index2 < index1; ++index2)
{
Main.tile[i, index2].frameNumber((byte) WorldGen.genRand.Next(3));
Main.tile[i, index2].active(true);
Main.tile[i, index2].type = (ushort) 5;
int num4 = WorldGen.genRand.Next(3);
int num5 = WorldGen.genRand.Next(10);
if (index2 == index1 - 1 || index2 == index1 - num2)
num5 = 0;
while (((num5 == 5 ? 1 : (num5 == 7 ? 1 : 0)) & (flag1 ? 1 : 0)) != 0 || ((num5 == 6 ? 1 : (num5 == 7 ? 1 : 0)) & (flag2 ? 1 : 0)) != 0)
num5 = WorldGen.genRand.Next(10);
flag1 = false;
flag2 = false;
if (num5 == 5 || num5 == 7)
flag1 = true;
if (num5 == 6 || num5 == 7)
flag2 = true;
switch (num5)
{
case 1:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 2:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 0;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 22;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
case 3:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 44;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 4:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 22;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 5:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 0;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 22;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 88;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
case 6:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 66;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
case 7:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 66;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 88;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 110;
Main.tile[i, index2].frameY = (short) 110;
break;
}
break;
default:
if (num4 == 0)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 0;
}
if (num4 == 1)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 22;
}
if (num4 == 2)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 44;
break;
}
break;
}
if (num5 == 5 || num5 == 7)
{
Main.tile[i - 1, index2].active(true);
Main.tile[i - 1, index2].type = (ushort) 5;
int num6 = WorldGen.genRand.Next(3);
if (WorldGen.genRand.Next(3) < 2)
{
if (num6 == 0)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 198;
}
if (num6 == 1)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 220;
}
if (num6 == 2)
{
Main.tile[i - 1, index2].frameX = (short) 44;
Main.tile[i - 1, index2].frameY = (short) 242;
}
}
else
{
if (num6 == 0)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 0;
}
if (num6 == 1)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 22;
}
if (num6 == 2)
{
Main.tile[i - 1, index2].frameX = (short) 66;
Main.tile[i - 1, index2].frameY = (short) 44;
}
}
}
if (num5 == 6 || num5 == 7)
{
Main.tile[i + 1, index2].active(true);
Main.tile[i + 1, index2].type = (ushort) 5;
int num7 = WorldGen.genRand.Next(3);
if (WorldGen.genRand.Next(3) < 2)
{
if (num7 == 0)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 198;
}
if (num7 == 1)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 220;
}
if (num7 == 2)
{
Main.tile[i + 1, index2].frameX = (short) 66;
Main.tile[i + 1, index2].frameY = (short) 242;
}
}
else
{
if (num7 == 0)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 66;
}
if (num7 == 1)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 88;
}
if (num7 == 2)
{
Main.tile[i + 1, index2].frameX = (short) 88;
Main.tile[i + 1, index2].frameY = (short) 110;
}
}
}
}
int num8 = WorldGen.genRand.Next(3);
bool flag3 = false;
bool flag4 = false;
if (Main.tile[i - 1, index1].nactive() && !Main.tile[i - 1, index1].halfBrick() && Main.tile[i - 1, index1].slope() == (byte) 0 && (Main.tile[i - 1, index1].type == (ushort) 2 || Main.tile[i - 1, index1].type == (ushort) 23 || Main.tile[i - 1, index1].type == (ushort) 60 || Main.tile[i - 1, index1].type == (ushort) 109 || Main.tile[i - 1, index1].type == (ushort) 147))
flag3 = true;
if (Main.tile[i + 1, index1].nactive() && !Main.tile[i + 1, index1].halfBrick() && Main.tile[i + 1, index1].slope() == (byte) 0 && (Main.tile[i + 1, index1].type == (ushort) 2 || Main.tile[i + 1, index1].type == (ushort) 23 || Main.tile[i + 1, index1].type == (ushort) 60 || Main.tile[i + 1, index1].type == (ushort) 109 || Main.tile[i + 1, index1].type == (ushort) 147))
flag4 = true;
if (!flag3)
{
if (num8 == 0)
num8 = 2;
if (num8 == 1)
num8 = 3;
}
if (!flag4)
{
if (num8 == 0)
num8 = 1;
if (num8 == 2)
num8 = 3;
}
if (flag3 && !flag4)
num8 = 2;
if (flag4 && !flag3)
num8 = 1;
if (num8 == 0 || num8 == 1)
{
Main.tile[i + 1, index1 - 1].active(true);
Main.tile[i + 1, index1 - 1].type = (ushort) 5;
int num9 = WorldGen.genRand.Next(3);
if (num9 == 0)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 132;
}
if (num9 == 1)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 154;
}
if (num9 == 2)
{
Main.tile[i + 1, index1 - 1].frameX = (short) 22;
Main.tile[i + 1, index1 - 1].frameY = (short) 176;
}
}
if (num8 == 0 || num8 == 2)
{
Main.tile[i - 1, index1 - 1].active(true);
Main.tile[i - 1, index1 - 1].type = (ushort) 5;
int num10 = WorldGen.genRand.Next(3);
if (num10 == 0)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 132;
}
if (num10 == 1)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 154;
}
if (num10 == 2)
{
Main.tile[i - 1, index1 - 1].frameX = (short) 44;
Main.tile[i - 1, index1 - 1].frameY = (short) 176;
}
}
int num11 = WorldGen.genRand.Next(3);
switch (num8)
{
case 0:
if (num11 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num11 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num11 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 88;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
case 1:
if (num11 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num11 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num11 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 0;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
case 2:
if (num11 == 0)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 132;
}
if (num11 == 1)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 154;
}
if (num11 == 2)
{
Main.tile[i, index1 - 1].frameX = (short) 66;
Main.tile[i, index1 - 1].frameY = (short) 176;
break;
}
break;
}
if (WorldGen.genRand.Next(8) != 0)
{
int num12 = WorldGen.genRand.Next(3);
if (num12 == 0)
{
Main.tile[i, index1 - num2].frameX = (short) 22;
Main.tile[i, index1 - num2].frameY = (short) 198;
}
if (num12 == 1)
{
Main.tile[i, index1 - num2].frameX = (short) 22;
Main.tile[i, index1 - num2].frameY = (short) 220;
}
if (num12 == 2)
{
Main.tile[i, index1 - num2].frameX = (short) 22;
Main.tile[i, index1 - num2].frameY = (short) 242;
}
}
else
{
int num13 = WorldGen.genRand.Next(3);
if (num13 == 0)
{
Main.tile[i, index1 - num2].frameX = (short) 0;
Main.tile[i, index1 - num2].frameY = (short) 198;
}
if (num13 == 1)
{
Main.tile[i, index1 - num2].frameX = (short) 0;
Main.tile[i, index1 - num2].frameY = (short) 220;
}
if (num13 == 2)
{
Main.tile[i, index1 - num2].frameX = (short) 0;
Main.tile[i, index1 - num2].frameY = (short) 242;
}
}
WorldGen.RangeFrame(i - 2, index1 - num2 - 1, i + 2, index1 + 1);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, i, (int) ((double) index1 - (double) num2 * 0.5), num2 + 1);
}
public static bool GrowShroom(int i, int y)
{
int index1 = y;
if (Main.tile[i - 1, index1 - 1].lava() || Main.tile[i - 1, index1 - 1].lava() || Main.tile[i + 1, index1 - 1].lava() || !Main.tile[i, index1].nactive() || Main.tile[i, index1].halfBrick() || Main.tile[i, index1].slope() != (byte) 0 || Main.tile[i, index1].type != (ushort) 70 || Main.tile[i, index1 - 1].wall != (byte) 0 || !Main.tile[i - 1, index1].active() || Main.tile[i - 1, index1].type != (ushort) 70 || !Main.tile[i + 1, index1].active() || Main.tile[i + 1, index1].type != (ushort) 70 || !WorldGen.EmptyTileCheck(i - 2, i + 2, index1 - 13, index1 - 1, 71))
return false;
int num1 = WorldGen.genRand.Next(4, 11);
for (int index2 = index1 - num1; index2 < index1; ++index2)
{
Main.tile[i, index2].frameNumber((byte) WorldGen.genRand.Next(3));
Main.tile[i, index2].active(true);
Main.tile[i, index2].type = (ushort) 72;
int num2 = WorldGen.genRand.Next(3);
if (num2 == 0)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 0;
}
if (num2 == 1)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 18;
}
if (num2 == 2)
{
Main.tile[i, index2].frameX = (short) 0;
Main.tile[i, index2].frameY = (short) 36;
}
}
int num3 = WorldGen.genRand.Next(3);
if (num3 == 0)
{
Main.tile[i, index1 - num1].frameX = (short) 36;
Main.tile[i, index1 - num1].frameY = (short) 0;
}
if (num3 == 1)
{
Main.tile[i, index1 - num1].frameX = (short) 36;
Main.tile[i, index1 - num1].frameY = (short) 18;
}
if (num3 == 2)
{
Main.tile[i, index1 - num1].frameX = (short) 36;
Main.tile[i, index1 - num1].frameY = (short) 36;
}
WorldGen.RangeFrame(i - 2, index1 - num1 - 1, i + 2, index1 + 1);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, i, (int) ((double) index1 - (double) num1 * 0.5), num1 + 1);
return true;
}
public static void AddTrees()
{
for (int i = 1; i < Main.maxTilesX - 1; ++i)
{
for (int y = 20; (double) y < Main.worldSurface; ++y)
{
WorldGen.GrowTree(i, y);
if ((i < 380 || i > Main.maxTilesX - 380) && WorldGen.genRand.Next(3) == 0)
WorldGen.GrowPalmTree(i, y);
}
if (WorldGen.genRand.Next(3) == 0)
++i;
if (WorldGen.genRand.Next(4) == 0)
++i;
}
}
public static void ExplodeMine(int i, int j)
{
int type = (int) Main.tile[i, j].type;
WorldGen.KillTile(i, j, noItem: true);
NetMessage.SendTileSquare(-1, i, j, 1);
Projectile.NewProjectile((float) (i * 16 + 8), (float) (j * 16 + 8), 0.0f, 0.0f, 164, 250, 10f, Main.myPlayer);
}
public static bool EmptyTileCheck(int startX, int endX, int startY, int endY, int ignoreID = -1)
{
if (startX < 0 || endX >= Main.maxTilesX || startY < 0 || endY >= Main.maxTilesY)
return false;
for (int index1 = startX; index1 < endX + 1; ++index1)
{
for (int index2 = startY; index2 < endY + 1; ++index2)
{
if (Main.tile[index1, index2].active())
{
switch (ignoreID)
{
case -1:
return false;
case 11:
if (Main.tile[index1, index2].type != (ushort) 11)
return false;
continue;
case 20:
switch (Main.tile[index1, index2].type)
{
case 3:
case 20:
case 24:
case 32:
case 61:
case 62:
case 69:
case 71:
case 73:
case 74:
case 82:
case 83:
case 84:
case 110:
case 113:
case 201:
case 233:
case 352:
continue;
default:
return false;
}
case 71:
if (Main.tile[index1, index2].type != (ushort) 71)
return false;
continue;
default:
continue;
}
}
}
}
return true;
}
public static void StartHardmode()
{
if (Main.netMode == 1 || Main.hardMode)
return;
Main.hardMode = true;
Main.InitLifeBytes();
ThreadPool.QueueUserWorkItem(new WaitCallback(WorldGen.smCallBack), (object) 1);
}
public static void smCallBack(object threadContext)
{
WorldGen.IsGeneratingHardMode = true;
if (Main.rand == null)
Main.rand = new UnifiedRandom((int) DateTime.Now.Ticks);
float num1 = (float) WorldGen.genRand.Next(300, 400) * (1f / 1000f);
float num2 = (float) WorldGen.genRand.Next(200, 300) * (1f / 1000f);
int i1 = (int) ((double) Main.maxTilesX * (double) num1);
int i2 = (int) ((double) Main.maxTilesX * (1.0 - (double) num1));
int num3 = 1;
if (WorldGen.genRand.Next(2) == 0)
{
i2 = (int) ((double) Main.maxTilesX * (double) num1);
i1 = (int) ((double) Main.maxTilesX * (1.0 - (double) num1));
num3 = -1;
}
int num4 = 1;
if (WorldGen.dungeonX < Main.maxTilesX / 2)
num4 = -1;
if (num4 < 0)
{
if (i2 < i1)
i2 = (int) ((double) Main.maxTilesX * (double) num2);
else
i1 = (int) ((double) Main.maxTilesX * (double) num2);
}
else if (i2 > i1)
i2 = (int) ((double) Main.maxTilesX * (1.0 - (double) num2));
else
i1 = (int) ((double) Main.maxTilesX * (1.0 - (double) num2));
WorldGen.GERunner(i1, 0, (float) (3 * num3), 5f);
WorldGen.GERunner(i2, 0, (float) (3 * -num3), 5f, false);
int num5 = (int) (25.0 * (double) ((float) Main.maxTilesX / 4200f));
ShapeData data = new ShapeData();
int num6 = 0;
while (num5 > 0)
{
if (++num6 % 15000 == 0)
--num5;
Point point = WorldGen.RandomWorldPoint((int) Main.worldSurface - 100, 1, 190, 1);
Tile tile1 = Main.tile[point.X, point.Y];
Tile tile2 = Main.tile[point.X, point.Y - 1];
byte type = 0;
if (TileID.Sets.Crimson[(int) tile1.type])
type = (byte) (192 + WorldGen.genRand.Next(4));
else if (TileID.Sets.Corrupt[(int) tile1.type])
type = (byte) (188 + WorldGen.genRand.Next(4));
else if (TileID.Sets.Hallow[(int) tile1.type])
type = (byte) (200 + WorldGen.genRand.Next(4));
if (tile1.active() && type != (byte) 0 && !tile2.active())
{
bool flag = WorldUtils.Gen(new Point(point.X, point.Y - 1), (GenShape) new ShapeFloodFill(1000), Actions.Chain((GenAction) new Modifiers.IsNotSolid(), (GenAction) new Modifiers.OnlyWalls(new byte[30]
{
(byte) 0,
(byte) 54,
(byte) 55,
(byte) 56,
(byte) 57,
(byte) 58,
(byte) 59,
(byte) 61,
(byte) 185,
(byte) 212,
(byte) 213,
(byte) 214,
(byte) 215,
(byte) 196,
(byte) 197,
(byte) 198,
(byte) 199,
(byte) 15,
(byte) 40,
(byte) 71,
(byte) 64,
(byte) 204,
(byte) 205,
(byte) 206,
(byte) 207,
(byte) 208,
(byte) 209,
(byte) 210,
(byte) 211,
(byte) 71
}), new Actions.Blank().Output(data)));
if (data.Count > 50 & flag)
{
WorldUtils.Gen(new Point(point.X, point.Y), (GenShape) new ModShapes.OuterOutline(data, useInterior: true), (GenAction) new Actions.PlaceWall(type));
--num5;
}
data.Clear();
}
}
switch (Main.netMode)
{
case 0:
Main.NewText(Lang.misc[15].Value, (byte) 50, B: (byte) 130);
break;
case 2:
NetMessage.BroadcastChatMessage(NetworkText.FromKey(Lang.misc[15].Key), new Color(50, (int) byte.MaxValue, 130));
break;
}
AchievementsHelper.NotifyProgressionEvent(9);
if (Main.netMode == 2)
Netplay.ResetSections();
WorldGen.IsGeneratingHardMode = false;
}
public static bool PlaceDoor(int i, int j, int type, int style = 0)
{
int num = 54 * style;
try
{
if (!Main.tile[i, j - 2].nactive() || !Main.tileSolid[(int) Main.tile[i, j - 2].type] || !WorldGen.SolidTile(i, j + 2))
return false;
Main.tile[i, j - 1].active(true);
Main.tile[i, j - 1].type = (ushort) 10;
Main.tile[i, j - 1].frameY = (short) num;
Main.tile[i, j - 1].frameX = (short) (WorldGen.genRand.Next(3) * 18);
Main.tile[i, j].active(true);
Main.tile[i, j].type = (ushort) 10;
Main.tile[i, j].frameY = (short) (num + 18);
Main.tile[i, j].frameX = (short) (WorldGen.genRand.Next(3) * 18);
Main.tile[i, j + 1].active(true);
Main.tile[i, j + 1].type = (ushort) 10;
Main.tile[i, j + 1].frameY = (short) (num + 36);
Main.tile[i, j + 1].frameX = (short) (WorldGen.genRand.Next(3) * 18);
return true;
}
catch
{
return false;
}
}
public static bool CloseDoor(int i, int j, bool forced = false)
{
int num1 = 0;
int num2 = i;
if (Main.tile[i, j] == null)
Main.tile[i, j] = new Tile();
int frameX = (int) Main.tile[i, j].frameX;
Tile tile = Main.tile[i, j];
if (tile.type != (ushort) 11)
return false;
int frameY = (int) tile.frameY;
int num3 = 0;
int num4 = 0;
while (frameY >= 54)
{
frameY -= 54;
++num3;
}
if (frameX >= 72)
{
int num5 = num3 + 36 * (frameX / 72);
num4 += 54 * (frameX / 72);
}
int y = j - frameY / 18;
switch (frameX % 72)
{
case 0:
num2 = i;
num1 = 1;
break;
case 18:
num2 = i - 1;
num1 = 1;
break;
case 36:
num2 = i + 1;
num1 = -1;
break;
case 54:
num2 = i;
num1 = -1;
break;
}
int num6 = num2;
if (num1 == -1)
num6 = num2 - 1;
if (!forced)
{
for (int j1 = y; j1 < y + 3; ++j1)
{
if (!Collision.EmptyTile(num2, j1, true))
return false;
}
}
for (int index1 = num6; index1 < num6 + 2; ++index1)
{
for (int index2 = y; index2 < y + 3; ++index2)
{
if (index1 == num2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
Main.tile[index1, index2].type = (ushort) 10;
Main.tile[index1, index2].frameX = (short) (WorldGen.genRand.Next(3) * 18 + num4);
}
else
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
Main.tile[index1, index2].active(false);
}
}
}
if (Main.netMode != 1 && Wiring.running)
{
Wiring.SkipWire(num2, y);
Wiring.SkipWire(num2, y + 1);
Wiring.SkipWire(num2, y + 2);
}
for (int i1 = num2 - 1; i1 <= num2 + 1; ++i1)
{
for (int j2 = y - 1; j2 <= y + 2; ++j2)
WorldGen.TileFrame(i1, j2);
}
Main.PlaySound(9, i * 16, j * 16);
return true;
}
public static bool AddLifeCrystal(int i, int j)
{
for (int index = j; index < Main.maxTilesY; ++index)
{
if (Main.tile[i, index].active() && Main.tileSolid[(int) Main.tile[i, index].type])
{
int endX = i;
int endY = index - 1;
if (Main.tile[endX, endY - 1].lava() || Main.tile[endX - 1, endY - 1].lava() || !WorldGen.EmptyTileCheck(endX - 1, endX, endY - 1, endY) || Main.wallDungeon[(int) Main.tile[endX, endY].wall])
return false;
Tile tile1 = Main.tile[endX - 1, endY + 1];
Tile tile2 = Main.tile[endX, endY + 1];
if (!tile1.nactive() || !Main.tileSolid[(int) tile1.type] || !tile2.nactive() || !Main.tileSolid[(int) tile2.type])
return false;
if (tile1.blockType() != 0)
{
tile1.slope((byte) 0);
tile1.halfBrick(false);
}
if (tile2.blockType() != 0)
{
tile2.slope((byte) 0);
tile2.halfBrick(false);
}
Main.tile[endX - 1, endY - 1].active(true);
Main.tile[endX - 1, endY - 1].type = (ushort) 12;
Main.tile[endX - 1, endY - 1].frameX = (short) 0;
Main.tile[endX - 1, endY - 1].frameY = (short) 0;
Main.tile[endX, endY - 1].active(true);
Main.tile[endX, endY - 1].type = (ushort) 12;
Main.tile[endX, endY - 1].frameX = (short) 18;
Main.tile[endX, endY - 1].frameY = (short) 0;
Main.tile[endX - 1, endY].active(true);
Main.tile[endX - 1, endY].type = (ushort) 12;
Main.tile[endX - 1, endY].frameX = (short) 0;
Main.tile[endX - 1, endY].frameY = (short) 18;
Main.tile[endX, endY].active(true);
Main.tile[endX, endY].type = (ushort) 12;
Main.tile[endX, endY].frameX = (short) 18;
Main.tile[endX, endY].frameY = (short) 18;
return true;
}
}
return false;
}
public static void AddShadowOrb(int x, int y)
{
if (x < 10 || x > Main.maxTilesX - 10 || y < 10 || y > Main.maxTilesY - 10)
return;
for (int index1 = x - 1; index1 < x + 1; ++index1)
{
for (int index2 = y - 1; index2 < y + 1; ++index2)
{
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 31)
return;
}
}
short num = 0;
if (WorldGen.crimson)
num += (short) 36;
Main.tile[x - 1, y - 1].active(true);
Main.tile[x - 1, y - 1].type = (ushort) 31;
Main.tile[x - 1, y - 1].frameX = num;
Main.tile[x - 1, y - 1].frameY = (short) 0;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].type = (ushort) 31;
Main.tile[x, y - 1].frameX = (short) (18 + (int) num);
Main.tile[x, y - 1].frameY = (short) 0;
Main.tile[x - 1, y].active(true);
Main.tile[x - 1, y].type = (ushort) 31;
Main.tile[x - 1, y].frameX = num;
Main.tile[x - 1, y].frameY = (short) 18;
Main.tile[x, y].active(true);
Main.tile[x, y].type = (ushort) 31;
Main.tile[x, y].frameX = (short) (18 + (int) num);
Main.tile[x, y].frameY = (short) 18;
}
public static void AddHellHouses()
{
int minValue = (int) ((double) Main.maxTilesX * 0.25);
for (int i = minValue; i < Main.maxTilesX - minValue; ++i)
{
int j = Main.maxTilesY - 40;
while (Main.tile[i, j].active() || Main.tile[i, j].liquid > (byte) 0)
--j;
if (Main.tile[i, j + 1].active())
{
ushort tileType = (ushort) WorldGen.genRand.Next(75, 77);
byte wallType = 13;
if (WorldGen.genRand.Next(5) > 0)
tileType = (ushort) 75;
if (tileType == (ushort) 75)
wallType = (byte) 14;
WorldGen.HellFort(i, j, tileType, wallType);
i += WorldGen.genRand.Next(30, 130);
if (WorldGen.genRand.Next(10) == 0)
i += WorldGen.genRand.Next(0, 200);
}
}
float num1 = (float) (Main.maxTilesX / 4200);
for (int index1 = 0; (double) index1 < 200.0 * (double) num1; ++index1)
{
int num2 = 0;
bool flag1 = false;
while (!flag1)
{
++num2;
int index2 = WorldGen.genRand.Next((int) ((double) Main.maxTilesX * 0.2), (int) ((double) Main.maxTilesX * 0.8));
int j = WorldGen.genRand.Next(Main.maxTilesY - 300, Main.maxTilesY - 20);
if (Main.tile[index2, j].active() && (Main.tile[index2, j].type == (ushort) 75 || Main.tile[index2, j].type == (ushort) 76))
{
int num3 = 0;
if (Main.tile[index2 - 1, j].wall > (byte) 0)
num3 = -1;
else if (Main.tile[index2 + 1, j].wall > (byte) 0)
num3 = 1;
if (!Main.tile[index2 + num3, j].active() && !Main.tile[index2 + num3, j + 1].active())
{
bool flag2 = false;
for (int index3 = index2 - 8; index3 < index2 + 8; ++index3)
{
for (int index4 = j - 8; index4 < j + 8; ++index4)
{
if (Main.tile[index3, index4].active() && Main.tile[index3, index4].type == (ushort) 4)
{
flag2 = true;
break;
}
}
}
if (!flag2)
{
WorldGen.PlaceTile(index2 + num3, j, 4, true, true, style: 7);
flag1 = true;
}
}
}
if (num2 > 1000)
flag1 = true;
}
}
float num4 = 4200000f / (float) Main.maxTilesX;
for (int index5 = 0; (double) index5 < (double) num4; ++index5)
{
int i1 = WorldGen.genRand.Next(minValue, Main.maxTilesX - minValue);
int j;
for (j = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20); Main.tile[i1, j].wall != (byte) 13 && Main.tile[i1, j].wall != (byte) 14 || Main.tile[i1, j].active(); j = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20))
i1 = WorldGen.genRand.Next(minValue, Main.maxTilesX - minValue);
if ((Main.tile[i1, j].wall == (byte) 13 || Main.tile[i1, j].wall == (byte) 14) && !Main.tile[i1, j].active())
{
while (!WorldGen.SolidTile(i1, j) && j < Main.maxTilesY - 20)
++j;
int index6 = j - 1;
int i2 = i1;
int i3 = i1;
while (!Main.tile[i2, index6].active() && WorldGen.SolidTile(i2, index6 + 1))
--i2;
int num5 = i2 + 1;
while (!Main.tile[i3, index6].active() && WorldGen.SolidTile(i3, index6 + 1))
++i3;
int num6 = i3 - 1;
int num7 = num6 - num5;
int index7 = (num6 + num5) / 2;
if (!Main.tile[index7, index6].active() && (Main.tile[index7, index6].wall == (byte) 13 || Main.tile[index7, index6].wall == (byte) 14) && WorldGen.SolidTile(index7, index6 + 1))
{
int style1 = 16;
int style2 = 13;
int style3 = 14;
int style4 = 49;
int style5 = 4;
int style6 = 8;
int style7 = 15;
int style8 = 9;
int style9 = 10;
int style10 = 17;
int style11 = 25;
int style12 = 25;
int style13 = 23;
int style14 = 25;
int num8 = WorldGen.genRand.Next(13);
int num9 = 0;
int num10 = 0;
if (num8 == 0)
{
num9 = 5;
num10 = 4;
}
if (num8 == 1)
{
num9 = 4;
num10 = 3;
}
if (num8 == 2)
{
num9 = 3;
num10 = 5;
}
if (num8 == 3)
{
num9 = 4;
num10 = 6;
}
if (num8 == 4)
{
num9 = 3;
num10 = 3;
}
if (num8 == 5)
{
num9 = 5;
num10 = 3;
}
if (num8 == 6)
{
num9 = 5;
num10 = 4;
}
if (num8 == 7)
{
num9 = 5;
num10 = 4;
}
if (num8 == 8)
{
num9 = 5;
num10 = 4;
}
if (num8 == 9)
{
num9 = 3;
num10 = 5;
}
if (num8 == 10)
{
num9 = 5;
num10 = 3;
}
if (num8 == 11)
{
num9 = 2;
num10 = 4;
}
if (num8 == 12)
{
num9 = 3;
num10 = 3;
}
for (int index8 = index7 - num9; index8 <= index7 + num9; ++index8)
{
for (int index9 = index6 - num10; index9 <= index6; ++index9)
{
if (Main.tile[index8, index9].active())
{
num8 = -1;
break;
}
}
}
if ((double) num7 < (double) num9 * 1.75)
num8 = -1;
switch (num8)
{
case 0:
WorldGen.PlaceTile(index7, index6, 14, true, style: style2);
int num11 = WorldGen.genRand.Next(6);
if (num11 < 3)
WorldGen.PlaceTile(index7 + num11, index6 - 2, 33, true, style: style12);
if (Main.tile[index7, index6].active())
{
if (!Main.tile[index7 - 2, index6].active())
{
WorldGen.PlaceTile(index7 - 2, index6, 15, true, style: style1);
if (Main.tile[index7 - 2, index6].active())
{
Main.tile[index7 - 2, index6].frameX += (short) 18;
Main.tile[index7 - 2, index6 - 1].frameX += (short) 18;
}
}
if (!Main.tile[index7 + 2, index6].active())
{
WorldGen.PlaceTile(index7 + 2, index6, 15, true, style: style1);
continue;
}
continue;
}
continue;
case 1:
WorldGen.PlaceTile(index7, index6, 18, true, style: style3);
int num12 = WorldGen.genRand.Next(4);
if (num12 < 2)
WorldGen.PlaceTile(index7 + num12, index6 - 1, 33, true, style: style12);
if (Main.tile[index7, index6].active())
{
if (WorldGen.genRand.Next(2) == 0)
{
if (!Main.tile[index7 - 1, index6].active())
{
WorldGen.PlaceTile(index7 - 1, index6, 15, true, style: style1);
if (Main.tile[index7 - 1, index6].active())
{
Main.tile[index7 - 1, index6].frameX += (short) 18;
Main.tile[index7 - 1, index6 - 1].frameX += (short) 18;
continue;
}
continue;
}
continue;
}
if (!Main.tile[index7 + 2, index6].active())
{
WorldGen.PlaceTile(index7 + 2, index6, 15, true, style: style1);
continue;
}
continue;
}
continue;
case 2:
WorldGen.PlaceTile(index7, index6, 105, true, style: style4);
continue;
case 3:
WorldGen.PlaceTile(index7, index6, 101, true, style: style5);
continue;
case 4:
if (WorldGen.genRand.Next(2) == 0)
{
WorldGen.PlaceTile(index7, index6, 15, true, style: style1);
Main.tile[index7, index6].frameX += (short) 18;
Main.tile[index7, index6 - 1].frameX += (short) 18;
continue;
}
WorldGen.PlaceTile(index7, index6, 15, true, style: style1);
continue;
case 5:
if (WorldGen.genRand.Next(2) == 0)
{
WorldGen.Place4x2(index7, index6, (ushort) 79, 1, style6);
continue;
}
WorldGen.Place4x2(index7, index6, (ushort) 79, style: style6);
continue;
case 6:
WorldGen.PlaceTile(index7, index6, 87, true, style: style7);
continue;
case 7:
WorldGen.PlaceTile(index7, index6, 88, true, style: style8);
continue;
case 8:
WorldGen.PlaceTile(index7, index6, 89, true, style: style9);
continue;
case 9:
WorldGen.PlaceTile(index7, index6, 104, true, style: style10);
continue;
case 10:
if (WorldGen.genRand.Next(2) == 0)
{
WorldGen.Place4x2(index7, index6, (ushort) 90, 1, style14);
continue;
}
WorldGen.Place4x2(index7, index6, (ushort) 90, style: style14);
continue;
case 11:
WorldGen.PlaceTile(index7, index6, 93, true, style: style13);
continue;
case 12:
WorldGen.PlaceTile(index7, index6, 100, true, style: style11);
continue;
default:
continue;
}
}
}
}
float num13 = 420000f / (float) Main.maxTilesX;
for (int index10 = 0; (double) index10 < (double) num13; ++index10)
{
int index11 = WorldGen.genRand.Next(minValue, Main.maxTilesX - minValue);
int index12;
for (index12 = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20); Main.tile[index11, index12].wall != (byte) 13 && Main.tile[index11, index12].wall != (byte) 14 || Main.tile[index11, index12].active(); index12 = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20))
index11 = WorldGen.genRand.Next(minValue, Main.maxTilesX - minValue);
for (int index13 = 0; index13 < 2; ++index13)
{
int index14 = index11;
int index15 = index11;
while (!Main.tile[index14, index12].active() && (Main.tile[index14, index12].wall == (byte) 13 || Main.tile[index14, index12].wall == (byte) 14))
--index14;
int num14 = index14 + 1;
while (!Main.tile[index15, index12].active() && (Main.tile[index15, index12].wall == (byte) 13 || Main.tile[index15, index12].wall == (byte) 14))
++index15;
int num15 = index15 - 1;
index11 = (num14 + num15) / 2;
int index16 = index12;
int index17 = index12;
while (!Main.tile[index11, index16].active() && (Main.tile[index11, index16].wall == (byte) 13 || Main.tile[index11, index16].wall == (byte) 14))
--index16;
int num16 = index16 + 1;
while (!Main.tile[index11, index17].active() && (Main.tile[index11, index17].wall == (byte) 13 || Main.tile[index11, index17].wall == (byte) 14))
++index17;
int num17 = index17 - 1;
index12 = (num16 + num17) / 2;
}
int index18 = index11;
int index19 = index11;
while (!Main.tile[index18, index12].active() && !Main.tile[index18, index12 - 1].active() && !Main.tile[index18, index12 + 1].active())
--index18;
int num18 = index18 + 1;
while (!Main.tile[index19, index12].active() && !Main.tile[index19, index12 - 1].active() && !Main.tile[index19, index12 + 1].active())
++index19;
int num19 = index19 - 1;
int index20 = index12;
int index21 = index12;
while (!Main.tile[index11, index20].active() && !Main.tile[index11 - 1, index20].active() && !Main.tile[index11 + 1, index20].active())
--index20;
int num20 = index20 + 1;
while (!Main.tile[index11, index21].active() && !Main.tile[index11 - 1, index21].active() && !Main.tile[index11 + 1, index21].active())
++index21;
int num21 = index21 - 1;
int num22 = (num18 + num19) / 2;
int num23 = (num20 + num21) / 2;
int num24 = num19 - num18;
int num25 = num21 - num20;
if (num24 > 7 && num25 > 5)
{
int num26 = 0;
if (WorldGen.nearPicture2(num22, num23))
num26 = -1;
if (num26 == 0)
{
Vector2 vector2 = WorldGen.randHellPicture();
int x = (int) vector2.X;
int y = (int) vector2.Y;
if (!WorldGen.nearPicture(num22, num23))
WorldGen.PlaceTile(num22, num23, x, true, style: y);
}
}
}
int[] numArray = new int[3]
{
WorldGen.genRand.Next(16, 22),
WorldGen.genRand.Next(16, 22),
WorldGen.genRand.Next(16, 22)
};
while (numArray[1] == numArray[0])
numArray[1] = WorldGen.genRand.Next(16, 22);
while (numArray[2] == numArray[0] || numArray[2] == numArray[1])
numArray[2] = WorldGen.genRand.Next(16, 22);
float num27 = 420000f / (float) Main.maxTilesX;
for (int index22 = 0; (double) index22 < (double) num27; ++index22)
{
int i;
int j1;
do
{
i = WorldGen.genRand.Next(minValue, Main.maxTilesX - minValue);
j1 = WorldGen.genRand.Next(Main.maxTilesY - 250, Main.maxTilesY - 20);
}
while (Main.tile[i, j1].wall != (byte) 13 && Main.tile[i, j1].wall != (byte) 14 || Main.tile[i, j1].active());
while (!WorldGen.SolidTile(i, j1) && j1 > 10)
--j1;
int j2 = j1 + 1;
if (Main.tile[i, j2].wall == (byte) 13 || Main.tile[i, j2].wall == (byte) 14)
{
int num28 = WorldGen.genRand.Next(3);
int style15 = 32;
int style16 = 32;
int num29;
int num30;
switch (num28)
{
case 1:
num29 = 3;
num30 = 3;
break;
case 2:
num29 = 1;
num30 = 2;
break;
default:
num29 = 1;
num30 = 3;
break;
}
for (int index23 = i - 1; index23 <= i + num29; ++index23)
{
for (int index24 = j2; index24 <= j2 + num30; ++index24)
{
Tile tile = Main.tile[i, j2];
if (index23 < i || index23 == i + num29)
{
if (tile.active())
{
switch (tile.type)
{
case 10:
case 11:
case 34:
case 42:
case 91:
num28 = -1;
continue;
default:
continue;
}
}
}
else if (tile.active())
num28 = -1;
}
}
switch (num28)
{
case 0:
WorldGen.PlaceTile(i, j2, 91, true, style: numArray[WorldGen.genRand.Next(3)]);
continue;
case 1:
WorldGen.PlaceTile(i, j2, 34, true, style: style15);
continue;
case 2:
WorldGen.PlaceTile(i, j2, 42, true, style: style16);
continue;
default:
continue;
}
}
}
}
public static void HellFort(int i, int j, ushort tileType = 75, byte wallType = 14)
{
int[] numArray1 = new int[5];
int[] numArray2 = new int[5];
int[] numArray3 = new int[10];
int[] numArray4 = new int[10];
int minValue1 = 8;
int maxValue1 = 20;
numArray1[2] = i - WorldGen.genRand.Next(minValue1 / 2, maxValue1 / 2);
numArray2[2] = i + WorldGen.genRand.Next(minValue1 / 2, maxValue1 / 2);
numArray1[3] = numArray2[2];
numArray2[3] = numArray1[3] + WorldGen.genRand.Next(minValue1, maxValue1);
numArray1[4] = numArray2[3];
numArray2[4] = numArray1[4] + WorldGen.genRand.Next(minValue1, maxValue1);
numArray2[1] = numArray1[2];
numArray1[1] = numArray2[1] - WorldGen.genRand.Next(minValue1, maxValue1);
numArray2[0] = numArray1[1];
numArray1[0] = numArray2[0] - WorldGen.genRand.Next(minValue1, maxValue1);
int minValue2 = 6;
int maxValue2 = 12;
numArray3[3] = j - WorldGen.genRand.Next(minValue2, maxValue2);
numArray4[3] = j;
for (int index = 4; index < 10; ++index)
{
numArray3[index] = numArray4[index - 1];
numArray4[index] = numArray3[index] + WorldGen.genRand.Next(minValue2, maxValue2);
}
for (int index = 2; index >= 0; --index)
{
numArray4[index] = numArray3[index + 1];
numArray3[index] = numArray4[index] - WorldGen.genRand.Next(minValue2, maxValue2);
}
bool flag1 = false;
bool flag2 = false;
bool[,] flagArray1 = new bool[5, 10];
int num1 = 3;
int num2 = 3;
for (int index1 = 0; index1 < 2; ++index1)
{
if (WorldGen.genRand.Next(3) == 0)
{
flag1 = true;
int index2 = WorldGen.genRand.Next(10);
if (index2 < num1)
num1 = index2;
if (index2 > num2)
num2 = index2;
int index3 = 1;
if (WorldGen.genRand.Next(2) == 0)
{
flagArray1[0, index2] = true;
flagArray1[1, index2] = true;
index3 = 0;
}
else
flagArray1[1, index2] = true;
int num3 = WorldGen.genRand.Next(2);
if (num3 == 0)
num3 = -1;
for (int index4 = WorldGen.genRand.Next(10); index4 > 0 && index2 >= 0 && index2 < 10; index2 += num3)
flagArray1[index3, index2] = true;
}
if (WorldGen.genRand.Next(3) == 0)
{
flag2 = true;
int index5 = WorldGen.genRand.Next(10);
if (index5 < num1)
num1 = index5;
if (index5 > num2)
num2 = index5;
int index6 = 3;
if (WorldGen.genRand.Next(2) == 0)
{
flagArray1[3, index5] = true;
flagArray1[4, index5] = true;
index6 = 4;
}
else
flagArray1[3, index5] = true;
int num4 = WorldGen.genRand.Next(2);
if (num4 == 0)
num4 = -1;
for (int index7 = WorldGen.genRand.Next(10); index7 > 0 && index5 >= 0 && index5 < 10; index5 += num4)
flagArray1[index6, index5] = true;
}
}
for (int index8 = 0; index8 < 5; ++index8)
{
int index9 = numArray1[index8];
bool flag3 = false;
for (int index10 = Main.maxTilesY - 200; index10 < Main.maxTilesY; ++index10)
{
if (Main.tile[index9, index10].wall > (byte) 0)
flag3 = true;
}
if (flag3)
{
for (int index11 = 0; index11 < 10; ++index11)
flagArray1[index8, index11] = false;
}
}
int num5 = WorldGen.genRand.Next(10);
if (num5 < num1)
num1 = num5;
int num6 = WorldGen.genRand.Next(10);
if (num6 > num2)
num2 = num6;
if (!flag1 && !flag2)
{
while (num2 - num1 < 5)
{
int num7 = WorldGen.genRand.Next(10);
if (num7 < num1)
num1 = num7;
int num8 = WorldGen.genRand.Next(10);
if (num8 > num2)
num2 = num8;
}
}
for (int index = num1; index <= num2; ++index)
flagArray1[2, index] = true;
for (int index12 = 0; index12 < 5; ++index12)
{
for (int index13 = 0; index13 < 10; ++index13)
{
if (flagArray1[index12, index13] && (numArray3[index13] < Main.maxTilesY - 200 || numArray4[index13] > Main.maxTilesY - 20))
flagArray1[index12, index13] = false;
}
}
for (int index14 = 0; index14 < 5; ++index14)
{
for (int index15 = 0; index15 < 10; ++index15)
{
if (flagArray1[index14, index15])
{
for (int index16 = numArray1[index14]; index16 <= numArray2[index14]; ++index16)
{
for (int index17 = numArray3[index15]; index17 <= numArray4[index15]; ++index17)
{
Main.tile[index16, index17].liquid = (byte) 0;
if (index16 == numArray1[index14] || index16 == numArray2[index14] || index17 == numArray3[index15] || index17 == numArray4[index15])
{
Main.tile[index16, index17].active(true);
Main.tile[index16, index17].type = tileType;
Main.tile[index16, index17].halfBrick(false);
Main.tile[index16, index17].slope((byte) 0);
}
else
{
Main.tile[index16, index17].wall = wallType;
Main.tile[index16, index17].active(false);
}
}
}
}
}
}
int style1 = 19;
int style2 = 13;
for (int index18 = 0; index18 < 4; ++index18)
{
bool[] flagArray2 = new bool[10];
bool flag4 = false;
for (int index19 = 0; index19 < 10; ++index19)
{
if (flagArray1[index18, index19] && flagArray1[index18 + 1, index19])
{
flagArray2[index19] = true;
flag4 = true;
}
}
while (flag4)
{
int index20 = WorldGen.genRand.Next(10);
if (flagArray2[index20])
{
flag4 = false;
Main.tile[numArray2[index18], numArray4[index20] - 1].active(false);
Main.tile[numArray2[index18], numArray4[index20] - 2].active(false);
Main.tile[numArray2[index18], numArray4[index20] - 3].active(false);
Main.tile[numArray2[index18], numArray4[index20] - 1].wall = wallType;
Main.tile[numArray2[index18], numArray4[index20] - 2].wall = wallType;
Main.tile[numArray2[index18], numArray4[index20] - 3].wall = wallType;
WorldGen.PlaceTile(numArray2[index18], numArray4[index20] - 1, 10, true, style: style1);
}
}
}
for (int index21 = 0; index21 < 5; ++index21)
{
for (int index22 = 0; index22 < 10; ++index22)
{
if (flagArray1[index21, index22])
{
if (index22 > 0 && flagArray1[index21, index22 - 1])
{
int num9 = WorldGen.genRand.Next(numArray1[index21] + 2, numArray2[index21] - 1);
int num10;
for (num10 = WorldGen.genRand.Next(numArray1[index21] + 2, numArray2[index21] - 1); num10 - num9 < 2 || num10 - num9 > 5; num10 = WorldGen.genRand.Next(numArray1[index21] + 2, numArray2[index21] - 1))
num9 = WorldGen.genRand.Next(numArray1[index21] + 2, numArray2[index21] - 1);
for (int i1 = num9; i1 <= num10; ++i1)
{
Main.tile[i1, numArray3[index22]].active(false);
WorldGen.PlaceTile(i1, numArray3[index22], 19, true, true, style: style2);
Main.tile[i1, numArray3[index22]].wall = wallType;
}
}
if (index21 < 4 && flagArray1[index21 + 1, index22] && WorldGen.genRand.Next(3) == 0)
{
Main.tile[numArray2[index21], numArray4[index22] - 1].active(false);
Main.tile[numArray2[index21], numArray4[index22] - 2].active(false);
Main.tile[numArray2[index21], numArray4[index22] - 3].active(false);
Main.tile[numArray2[index21], numArray4[index22] - 1].wall = wallType;
Main.tile[numArray2[index21], numArray4[index22] - 2].wall = wallType;
Main.tile[numArray2[index21], numArray4[index22] - 3].wall = wallType;
WorldGen.PlaceTile(numArray2[index21], numArray4[index22] - 1, 10, true, style: style1);
}
}
}
}
bool flag5 = false;
for (int index23 = 0; index23 < 5; ++index23)
{
bool[] flagArray3 = new bool[10];
for (int index24 = 0; index24 < 10; ++index24)
{
if (flagArray1[index23, index24])
{
flag5 = true;
flagArray3[index24] = true;
}
}
if (flag5)
{
bool flag6 = false;
for (int index25 = 0; index25 < 10; ++index25)
{
if (flagArray3[index25])
{
if (!Main.tile[numArray1[index23] - 1, numArray4[index25] - 1].active() && !Main.tile[numArray1[index23] - 1, numArray4[index25] - 2].active() && !Main.tile[numArray1[index23] - 1, numArray4[index25] - 3].active() && Main.tile[numArray1[index23] - 1, numArray4[index25] - 1].liquid == (byte) 0 && Main.tile[numArray1[index23] - 1, numArray4[index25] - 2].liquid == (byte) 0 && Main.tile[numArray1[index23] - 1, numArray4[index25] - 3].liquid == (byte) 0)
flag6 = true;
else
flagArray3[index25] = false;
}
}
while (flag6)
{
int index26 = WorldGen.genRand.Next(10);
if (flagArray3[index26])
{
flag6 = false;
Main.tile[numArray1[index23], numArray4[index26] - 1].active(false);
Main.tile[numArray1[index23], numArray4[index26] - 2].active(false);
Main.tile[numArray1[index23], numArray4[index26] - 3].active(false);
WorldGen.PlaceTile(numArray1[index23], numArray4[index26] - 1, 10, true, style: style1);
}
}
break;
}
}
bool flag7 = false;
for (int index27 = 4; index27 >= 0; --index27)
{
bool[] flagArray4 = new bool[10];
for (int index28 = 0; index28 < 10; ++index28)
{
if (flagArray1[index27, index28])
{
flag7 = true;
flagArray4[index28] = true;
}
}
if (flag7)
{
bool flag8 = false;
for (int index29 = 0; index29 < 10; ++index29)
{
if (flagArray4[index29])
{
if (!Main.tile[numArray2[index27] + 1, numArray4[index29] - 1].active() && !Main.tile[numArray2[index27] + 1, numArray4[index29] - 2].active() && !Main.tile[numArray2[index27] + 1, numArray4[index29] - 3].active() && Main.tile[numArray2[index27] + 1, numArray4[index29] - 1].liquid == (byte) 0 && Main.tile[numArray2[index27] + 1, numArray4[index29] - 2].liquid == (byte) 0 && Main.tile[numArray2[index27] + 1, numArray4[index29] - 3].liquid == (byte) 0)
flag8 = true;
else
flagArray4[index29] = false;
}
}
while (flag8)
{
int index30 = WorldGen.genRand.Next(10);
if (flagArray4[index30])
{
flag8 = false;
Main.tile[numArray2[index27], numArray4[index30] - 1].active(false);
Main.tile[numArray2[index27], numArray4[index30] - 2].active(false);
Main.tile[numArray2[index27], numArray4[index30] - 3].active(false);
WorldGen.PlaceTile(numArray2[index27], numArray4[index30] - 1, 10, true, style: style1);
}
}
break;
}
}
bool flag9 = false;
for (int index31 = 0; index31 < 10; ++index31)
{
bool[] flagArray5 = new bool[10];
for (int index32 = 0; index32 < 5; ++index32)
{
if (flagArray1[index32, index31])
{
flag9 = true;
flagArray5[index32] = true;
}
}
if (flag9)
{
bool flag10 = true;
while (flag10)
{
int index33 = WorldGen.genRand.Next(5);
if (flagArray5[index33])
{
int num11 = WorldGen.genRand.Next(numArray1[index33] + 2, numArray2[index33] - 1);
int num12;
for (num12 = WorldGen.genRand.Next(numArray1[index33] + 2, numArray2[index33] - 1); num12 - num11 < 2 || num12 - num11 > 5; num12 = WorldGen.genRand.Next(numArray1[index33] + 2, numArray2[index33] - 1))
num11 = WorldGen.genRand.Next(numArray1[index33] + 2, numArray2[index33] - 1);
for (int index34 = num11; index34 <= num12; ++index34)
{
if (Main.tile[index34, numArray3[index31] - 1].active() || Main.tile[index34, numArray3[index31] - 1].liquid > (byte) 0)
flag10 = false;
}
if (flag10)
{
for (int i2 = num11; i2 <= num12; ++i2)
{
Main.tile[i2, numArray3[index31]].active(false);
WorldGen.PlaceTile(i2, numArray3[index31], 19, true, true, style: style2);
}
}
flag10 = false;
}
}
break;
}
}
}
public static void HellHouse(int i, int j, byte type = 76, byte wall = 13)
{
int width = WorldGen.genRand.Next(8, 20);
int num1 = WorldGen.genRand.Next(1, 3);
int num2 = WorldGen.genRand.Next(4, 13);
int i1 = i;
int j1 = j;
for (int index = 0; index < num1; ++index)
{
int height = WorldGen.genRand.Next(5, 9);
WorldGen.HellRoom(i1, j1, width, height, type, wall);
j1 -= height;
}
int j2 = j;
for (int index = 0; index < num2; ++index)
{
int height = WorldGen.genRand.Next(5, 9);
j2 += height;
WorldGen.HellRoom(i1, j2, width, height, type, wall);
}
for (int index1 = i - width / 2; index1 <= i + width / 2; ++index1)
{
int index2 = j;
while (index2 < Main.maxTilesY && (Main.tile[index1, index2].active() && (Main.tile[index1, index2].type == (ushort) 76 || Main.tile[index1, index2].type == (ushort) 75) || Main.tile[i, index2].wall == (byte) 13 || Main.tile[i, index2].wall == (byte) 14))
++index2;
int num3 = 6 + WorldGen.genRand.Next(3);
while (index2 < Main.maxTilesY && !Main.tile[index1, index2].active())
{
--num3;
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].type = (ushort) 57;
++index2;
if (num3 <= 0)
break;
}
}
int index3 = j;
while (index3 < Main.maxTilesY && (Main.tile[i, index3].active() && (Main.tile[i, index3].type == (ushort) 76 || Main.tile[i, index3].type == (ushort) 75) || Main.tile[i, index3].wall == (byte) 13 || Main.tile[i, index3].wall == (byte) 14))
++index3;
int index4 = index3 - 1;
int maxValue = index4;
while (Main.tile[i, index4].active() && (Main.tile[i, index4].type == (ushort) 76 || Main.tile[i, index4].type == (ushort) 75) || Main.tile[i, index4].wall == (byte) 13 || Main.tile[i, index4].wall == (byte) 14)
{
--index4;
if (Main.tile[i, index4].active() && (Main.tile[i, index4].type == (ushort) 76 || Main.tile[i, index4].type == (ushort) 75))
{
int num4 = WorldGen.genRand.Next(i - width / 2 + 1, i + width / 2 - 1);
int num5 = WorldGen.genRand.Next(i - width / 2 + 1, i + width / 2 - 1);
if (num4 > num5)
{
int num6 = num4;
num4 = num5;
num5 = num6;
}
if (num4 == num5)
{
if (num4 < i)
++num5;
else
--num4;
}
for (int index5 = num4; index5 <= num5; ++index5)
{
if (Main.tile[index5, index4 - 1].wall == (byte) 13)
Main.tile[index5, index4].wall = (byte) 13;
if (Main.tile[index5, index4 - 1].wall == (byte) 14)
Main.tile[index5, index4].wall = (byte) 14;
Main.tile[index5, index4].type = (ushort) 19;
Main.tile[index5, index4].active(true);
}
--index4;
}
}
int minValue = index4;
float num7 = (float) ((maxValue - minValue) * width) * 0.02f;
for (int index6 = 0; (double) index6 < (double) num7; ++index6)
{
int num8 = WorldGen.genRand.Next(i - width / 2, i + width / 2 + 1);
int num9 = WorldGen.genRand.Next(minValue, maxValue);
int num10 = WorldGen.genRand.Next(3, 8);
for (int index7 = num8 - num10; index7 <= num8 + num10; ++index7)
{
for (int index8 = num9 - num10; index8 <= num9 + num10; ++index8)
{
double num11 = (double) Math.Abs(index7 - num8);
float num12 = (float) Math.Abs(index8 - num9);
if (Math.Sqrt(num11 * num11 + (double) num12 * (double) num12) < (double) num10 * 0.4)
{
try
{
if (Main.tile[index7, index8].type == (ushort) 76 || Main.tile[index7, index8].type == (ushort) 19)
Main.tile[index7, index8].active(false);
Main.tile[index7, index8].wall = (byte) 0;
}
catch
{
}
}
}
}
}
}
public static void HellRoom(int i, int j, int width, int height, byte type = 76, byte wall = 13)
{
if (j > Main.maxTilesY - 40)
return;
for (int index1 = i - width / 2; index1 <= i + width / 2; ++index1)
{
for (int index2 = j - height; index2 <= j; ++index2)
{
try
{
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].type = (ushort) type;
Main.tile[index1, index2].liquid = (byte) 0;
Main.tile[index1, index2].lava(false);
}
catch
{
}
}
}
for (int index3 = i - width / 2 + 1; index3 <= i + width / 2 - 1; ++index3)
{
for (int index4 = j - height + 1; index4 <= j - 1; ++index4)
{
try
{
Main.tile[index3, index4].active(false);
Main.tile[index3, index4].wall = wall;
Main.tile[index3, index4].liquid = (byte) 0;
Main.tile[index3, index4].lava(false);
}
catch
{
}
}
}
}
public static void templeCleaner(int x, int y)
{
int index1 = x;
int index2 = y;
int num = 0;
if (Main.tile[x + 1, y].active() && Main.tile[x + 1, y].type == (ushort) 226)
++num;
if (Main.tile[x - 1, y].active() && Main.tile[x - 1, y].type == (ushort) 226)
++num;
if (Main.tile[x, y + 1].active() && Main.tile[x, y + 1].type == (ushort) 226)
++num;
if (Main.tile[x, y - 1].active() && Main.tile[x, y - 1].type == (ushort) 226)
++num;
if (Main.tile[x, y].active() && Main.tile[x, y].type == (ushort) 226)
{
if (num > 1)
return;
Main.tile[index1, index2].active(false);
Main.tile[index1, index2].wall = (byte) 87;
}
else
{
if (Main.tile[x, y].active() || num != 3)
return;
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].type = (ushort) 226;
Main.tile[index1, index2].liquid = (byte) 0;
Main.tile[index1, index2].slope((byte) 0);
Main.tile[index1, index2].halfBrick(false);
}
}
public static Vector2 templePather(Vector2 templePath, int destX, int destY)
{
int x = (int) templePath.X;
int y = (int) templePath.Y;
int num1 = WorldGen.genRand.Next(5, 20);
int num2 = WorldGen.genRand.Next(2, 5);
while (num1 > 0 && (x != destX || y != destY))
{
--num1;
if (x > destX)
--x;
if (x < destX)
++x;
if (y > destY)
--y;
if (y < destY)
++y;
for (int index1 = x - num2; index1 < x + num2; ++index1)
{
for (int index2 = y - num2; index2 < y + num2; ++index2)
{
Main.tile[index1, index2].active(false);
Main.tile[index1, index2].wall = (byte) 87;
}
}
}
return new Vector2((float) x, (float) y);
}
public static void outerTempled(int x, int y)
{
if (Main.tile[x, y].active() & Main.tile[x, y].type == (ushort) 226 || Main.tile[x, y].wall == (byte) 87)
return;
int num = 6;
for (int index1 = x - num; index1 <= x + num; ++index1)
{
for (int index2 = y - num; index2 <= y + num; ++index2)
{
if (!Main.tile[index1, index2].active() && Main.tile[index1, index2].wall == (byte) 87)
{
int index3 = x;
int index4 = y;
Main.tile[index3, index4].active(true);
Main.tile[index3, index4].type = (ushort) 226;
Main.tile[index3, index4].liquid = (byte) 0;
Main.tile[index3, index4].slope((byte) 0);
Main.tile[index3, index4].halfBrick(false);
return;
}
}
}
}
public static void makeTemple(int x, int y)
{
Microsoft.Xna.Framework.Rectangle[] rectangleArray = new Microsoft.Xna.Framework.Rectangle[40];
float num1 = (float) (Main.maxTilesX / 4200);
int maxValue = WorldGen.genRand.Next((int) ((double) num1 * 10.0), (int) ((double) num1 * 16.0));
int num2 = 1;
if (WorldGen.genRand.Next(2) == 0)
num2 = -1;
int num3 = num2;
int num4 = x;
int num5 = y;
int num6 = x;
int num7 = y;
int num8 = WorldGen.genRand.Next(1, 3);
int num9 = 0;
for (int index1 = 0; index1 < maxValue; ++index1)
{
++num9;
int num10 = num2;
int num11 = num6;
int num12 = num7;
bool flag = true;
int width1 = 0;
int height1 = 0;
int num13 = -10;
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(num11 - width1 / 2, num12 - height1 / 2, width1, height1);
while (flag)
{
int num14 = num6;
int num15 = num7;
int width2 = WorldGen.genRand.Next(25, 50);
int height2 = WorldGen.genRand.Next(20, 35);
if (height2 > width2)
height2 = width2;
if (index1 == maxValue - 1)
{
int num16 = WorldGen.genRand.Next(55, 65);
int num17 = WorldGen.genRand.Next(45, 50);
if (num17 > num16)
num17 = num16;
width2 = (int) ((double) num16 * 1.6);
height2 = (int) ((double) num17 * 1.35);
num15 += WorldGen.genRand.Next(5, 10);
}
if (num9 > num8)
{
num12 = num15 + (WorldGen.genRand.Next(height2 + 1, height2 + 3) + num13);
num11 = num14 + WorldGen.genRand.Next(-5, 6);
num10 = num2 * -1;
}
else
{
num11 = num14 + (WorldGen.genRand.Next(width2 + 1, width2 + 3) + num13) * num10;
num12 = num15 + WorldGen.genRand.Next(-5, 6);
}
flag = false;
rectangle = new Microsoft.Xna.Framework.Rectangle(num11 - width2 / 2, num12 - height2 / 2, width2, height2);
for (int index2 = 0; index2 < index1; ++index2)
{
if (rectangle.Intersects(rectangleArray[index2]))
flag = true;
if (WorldGen.genRand.Next(100) == 0)
++num13;
}
}
if (num9 > num8)
{
++num8;
num9 = 1;
}
rectangleArray[index1] = rectangle;
num2 = num10;
num6 = num11;
num7 = num12;
}
for (int index3 = 0; index3 < maxValue; ++index3)
{
for (int index4 = 0; index4 < 2; ++index4)
{
for (int index5 = 0; index5 < maxValue; ++index5)
{
for (int index6 = 0; index6 < 2; ++index6)
{
int x1 = rectangleArray[index3].X;
if (index4 == 1)
x1 += rectangleArray[index3].Width - 1;
int y1 = rectangleArray[index3].Y;
int num18 = y1 + rectangleArray[index3].Height;
int x2 = rectangleArray[index5].X;
if (index6 == 1)
x2 += rectangleArray[index5].Width - 1;
int y2 = rectangleArray[index5].Y;
int num19 = y2 + rectangleArray[index5].Height;
while (x1 != x2 || y1 != y2 || num18 != num19)
{
if (x1 < x2)
++x1;
if (x1 > x2)
--x1;
if (y1 < y2)
++y1;
if (y1 > y2)
--y1;
if (num18 < num19)
++num18;
if (num18 > num19)
--num18;
int index7 = x1;
for (int index8 = y1; index8 < num18; ++index8)
{
Main.tile[index7, index8].active(true);
Main.tile[index7, index8].type = (ushort) 226;
Main.tile[index7, index8].liquid = (byte) 0;
Main.tile[index7, index8].slope((byte) 0);
Main.tile[index7, index8].halfBrick(false);
}
}
}
}
}
}
for (int index9 = 0; index9 < maxValue; ++index9)
{
if (WorldGen.genRand.Next(1) == 0)
{
for (int x3 = rectangleArray[index9].X; x3 < rectangleArray[index9].X + rectangleArray[index9].Width; ++x3)
{
for (int y3 = rectangleArray[index9].Y; y3 < rectangleArray[index9].Y + rectangleArray[index9].Height; ++y3)
{
Main.tile[x3, y3].active(true);
Main.tile[x3, y3].type = (ushort) 226;
Main.tile[x3, y3].liquid = (byte) 0;
Main.tile[x3, y3].slope((byte) 0);
Main.tile[x3, y3].halfBrick(false);
}
}
int x4 = rectangleArray[index9].X;
int num20 = x4 + rectangleArray[index9].Width;
int y4 = rectangleArray[index9].Y;
int num21 = y4 + rectangleArray[index9].Height;
int num22 = x4 + WorldGen.genRand.Next(3, 8);
int num23 = num20 - WorldGen.genRand.Next(3, 8);
int num24 = y4 + WorldGen.genRand.Next(3, 8);
int num25 = num21 - WorldGen.genRand.Next(3, 8);
int num26 = num22;
int num27 = num23;
int num28 = num24;
int num29 = num25;
int num30 = (num22 + num23) / 2;
int num31 = (num24 + num25) / 2;
for (int index10 = num22; index10 < num23; ++index10)
{
for (int index11 = num24; index11 < num25; ++index11)
{
if (WorldGen.genRand.Next(20) == 0)
num28 += WorldGen.genRand.Next(-1, 2);
if (WorldGen.genRand.Next(20) == 0)
num29 += WorldGen.genRand.Next(-1, 2);
if (WorldGen.genRand.Next(20) == 0)
num26 += WorldGen.genRand.Next(-1, 2);
if (WorldGen.genRand.Next(20) == 0)
num27 += WorldGen.genRand.Next(-1, 2);
if (num26 < num22)
num26 = num22;
if (num27 > num23)
num27 = num23;
if (num28 < num24)
num28 = num24;
if (num29 > num25)
num29 = num25;
if (num26 > num30)
num26 = num30;
if (num27 < num30)
num27 = num30;
if (num28 > num31)
num28 = num31;
if (num29 < num31)
num29 = num31;
if (index10 >= num26 && index10 < num27 & index11 >= num28 && index11 <= num29)
{
Main.tile[index10, index11].active(false);
Main.tile[index10, index11].wall = (byte) 87;
}
}
}
for (int index12 = num25; index12 > num24; --index12)
{
for (int index13 = num23; index13 > num22; --index13)
{
if (WorldGen.genRand.Next(20) == 0)
num28 += WorldGen.genRand.Next(-1, 2);
if (WorldGen.genRand.Next(20) == 0)
num29 += WorldGen.genRand.Next(-1, 2);
if (WorldGen.genRand.Next(20) == 0)
num26 += WorldGen.genRand.Next(-1, 2);
if (WorldGen.genRand.Next(20) == 0)
num27 += WorldGen.genRand.Next(-1, 2);
if (num26 < num22)
num26 = num22;
if (num27 > num23)
num27 = num23;
if (num28 < num24)
num28 = num24;
if (num29 > num25)
num29 = num25;
if (num26 > num30)
num26 = num30;
if (num27 < num30)
num27 = num30;
if (num28 > num31)
num28 = num31;
if (num29 < num31)
num29 = num31;
if (index13 >= num26 && index13 < num27 & index12 >= num28 && index12 <= num29)
{
Main.tile[index13, index12].active(false);
Main.tile[index13, index12].wall = (byte) 87;
}
}
}
}
}
Vector2 templePath = new Vector2((float) num4, (float) num5);
for (int index14 = 0; index14 < maxValue; ++index14)
{
Microsoft.Xna.Framework.Rectangle rectangle = rectangleArray[index14];
rectangle.X += 8;
rectangle.Y += 8;
rectangle.Width -= 16;
rectangle.Height -= 16;
bool flag1 = true;
while (flag1)
{
int destX = WorldGen.genRand.Next(rectangle.X, rectangle.X + rectangle.Width);
int destY = WorldGen.genRand.Next(rectangle.Y, rectangle.Y + rectangle.Height);
templePath = WorldGen.templePather(templePath, destX, destY);
if ((double) templePath.X == (double) destX && (double) templePath.Y == (double) destY)
flag1 = false;
}
if (index14 < maxValue - 1)
{
if (WorldGen.genRand.Next(3) != 0)
{
int index15 = index14 + 1;
if (rectangleArray[index15].Y >= rectangleArray[index14].Y + rectangleArray[index14].Height)
{
rectangle.X = rectangleArray[index15].X;
if (rectangleArray[index15].X < rectangleArray[index14].X)
rectangle.X += (int) ((double) rectangleArray[index15].Width * 0.2);
else
rectangle.X += (int) ((double) rectangleArray[index15].Width * 0.8);
rectangle.Y = rectangleArray[index15].Y;
}
else
{
rectangle.X = (rectangleArray[index14].X + rectangleArray[index14].Width / 2 + (rectangleArray[index15].X + rectangleArray[index15].Width / 2)) / 2;
rectangle.Y = (int) ((double) rectangleArray[index15].Y + (double) rectangleArray[index15].Height * 0.8);
}
int x5 = rectangle.X;
int y5 = rectangle.Y;
bool flag2 = true;
while (flag2)
{
int destX = WorldGen.genRand.Next(x5 - 6, x5 + 7);
int destY = WorldGen.genRand.Next(y5 - 6, y5 + 7);
templePath = WorldGen.templePather(templePath, destX, destY);
if ((double) templePath.X == (double) destX && (double) templePath.Y == (double) destY)
flag2 = false;
}
}
else
{
int index16 = index14 + 1;
int num32 = (rectangleArray[index14].X + rectangleArray[index14].Width / 2 + (rectangleArray[index16].X + rectangleArray[index16].Width / 2)) / 2;
int num33 = (rectangleArray[index14].Y + rectangleArray[index14].Height / 2 + (rectangleArray[index16].Y + rectangleArray[index16].Height / 2)) / 2;
bool flag3 = true;
while (flag3)
{
int destX = WorldGen.genRand.Next(num32 - 6, num32 + 7);
int destY = WorldGen.genRand.Next(num33 - 6, num33 + 7);
templePath = WorldGen.templePather(templePath, destX, destY);
if ((double) templePath.X == (double) destX && (double) templePath.Y == (double) destY)
flag3 = false;
}
}
}
}
int num34 = Main.maxTilesX - 20;
int num35 = 20;
int num36 = Main.maxTilesY - 20;
int num37 = 20;
for (int index = 0; index < maxValue; ++index)
{
if (rectangleArray[index].X < num34)
num34 = rectangleArray[index].X;
if (rectangleArray[index].X + rectangleArray[index].Width > num35)
num35 = rectangleArray[index].X + rectangleArray[index].Width;
if (rectangleArray[index].Y < num36)
num36 = rectangleArray[index].Y;
if (rectangleArray[index].Y + rectangleArray[index].Height > num37)
num37 = rectangleArray[index].Y + rectangleArray[index].Height;
}
int num38 = num34 - 10;
int num39 = num35 + 10;
int num40 = num36 - 10;
int num41 = num37 + 10;
for (int x6 = num38; x6 < num39; ++x6)
{
for (int y6 = num40; y6 < num41; ++y6)
WorldGen.outerTempled(x6, y6);
}
for (int x7 = num39; x7 >= num38; --x7)
{
for (int y7 = num40; y7 < num41 / 2; ++y7)
WorldGen.outerTempled(x7, y7);
}
for (int y8 = num40; y8 < num41; ++y8)
{
for (int x8 = num38; x8 < num39; ++x8)
WorldGen.outerTempled(x8, y8);
}
for (int y9 = num41; y9 >= num40; --y9)
{
for (int x9 = num38; x9 < num39; ++x9)
WorldGen.outerTempled(x9, y9);
}
int num42 = -num3;
Vector2 vector2 = new Vector2((float) num4, (float) num5);
int num43 = WorldGen.genRand.Next(2, 5);
bool flag4 = true;
int num44 = 0;
int num45 = WorldGen.genRand.Next(9, 14);
while (flag4)
{
++num44;
if (num44 >= num45)
{
num44 = 0;
--vector2.Y;
}
vector2.X += (float) num42;
int x10 = (int) vector2.X;
flag4 = false;
for (int index = (int) vector2.Y - num43; (double) index < (double) vector2.Y + (double) num43; ++index)
{
if (Main.tile[x10, index].wall == (byte) 87 || Main.tile[x10, index].active() && Main.tile[x10, index].type == (ushort) 226)
flag4 = true;
if (Main.tile[x10, index].active() && Main.tile[x10, index].type == (ushort) 226)
{
Main.tile[x10, index].active(false);
Main.tile[x10, index].wall = (byte) 87;
}
}
}
int i1 = num4;
int index17 = num5;
while (!Main.tile[i1, index17].active())
++index17;
int j1 = index17 - 4;
int index18 = j1;
while (Main.tile[i1, index18].active() && Main.tile[i1, index18].type == (ushort) 226 || Main.tile[i1, index18].wall == (byte) 87)
--index18;
int num46 = index18 + 2;
for (int index19 = i1 - 1; index19 <= i1 + 1; ++index19)
{
for (int index20 = num46; index20 <= j1; ++index20)
{
Main.tile[index19, index20].active(true);
Main.tile[index19, index20].type = (ushort) 226;
Main.tile[index19, index20].liquid = (byte) 0;
Main.tile[index19, index20].slope((byte) 0);
Main.tile[index19, index20].halfBrick(false);
}
}
for (int index21 = i1 - 4; index21 <= i1 + 4; ++index21)
{
for (int index22 = j1 - 1; index22 < j1 + 3; ++index22)
{
Main.tile[index21, index22].active(false);
Main.tile[index21, index22].wall = (byte) 87;
}
}
for (int index23 = i1 - 1; index23 <= i1 + 1; ++index23)
{
for (int index24 = j1 - 5; index24 <= j1 + 8; ++index24)
{
Main.tile[index23, index24].active(true);
Main.tile[index23, index24].type = (ushort) 226;
Main.tile[index23, index24].liquid = (byte) 0;
Main.tile[index23, index24].slope((byte) 0);
Main.tile[index23, index24].halfBrick(false);
}
}
for (int index25 = i1 - 1; index25 <= i1 + 1; ++index25)
{
for (int index26 = j1; index26 < j1 + 3; ++index26)
{
Main.tile[index25, index26].active(false);
Main.tile[index25, index26].wall = (byte) 87;
}
}
WorldGen.PlaceTile(i1, j1, 10, true, style: 11);
for (int x11 = num38; x11 < num39; ++x11)
{
for (int y10 = num40; y10 < num41; ++y10)
WorldGen.templeCleaner(x11, y10);
}
for (int y11 = num41; y11 >= num40; --y11)
{
for (int x12 = num39; x12 >= num38; --x12)
WorldGen.templeCleaner(x12, y11);
}
for (int index27 = num38; index27 < num39; ++index27)
{
for (int index28 = num40; index28 < num41; ++index28)
{
bool flag5 = true;
for (int index29 = index27 - 1; index29 <= index27 + 1; ++index29)
{
for (int index30 = index28 - 1; index30 <= index28 + 1; ++index30)
{
if ((!Main.tile[index29, index30].active() || Main.tile[index29, index30].type != (ushort) 226) && Main.tile[index29, index30].wall != (byte) 87)
{
flag5 = false;
break;
}
}
}
if (flag5)
Main.tile[index27, index28].wall = (byte) 87;
}
}
int num47 = 0;
Microsoft.Xna.Framework.Rectangle rectangle1;
do
{
++num47;
rectangle1 = rectangleArray[maxValue - 1];
int i2 = rectangle1.X + WorldGen.genRand.Next(rectangle1.Width);
int j2 = rectangle1.Y + WorldGen.genRand.Next(rectangle1.Height);
WorldGen.PlaceTile(i2, j2, 237);
if (Main.tile[i2, j2].type == (ushort) 237)
{
WorldGen.lAltarX = i2 - (int) Main.tile[i2, j2].frameX / 18;
WorldGen.lAltarY = j2 - (int) Main.tile[i2, j2].frameY / 18;
goto label_278;
}
}
while (num47 < 1000);
int num48 = rectangle1.X + rectangle1.Width / 2;
int num49 = rectangle1.Y + rectangle1.Height / 2;
int index31 = num48 + WorldGen.genRand.Next(-10, 11);
int index32 = num49 + WorldGen.genRand.Next(-10, 11);
while (!Main.tile[index31, index32].active())
++index32;
Main.tile[index31 - 1, index32].active(true);
Main.tile[index31 - 1, index32].slope((byte) 0);
Main.tile[index31 - 1, index32].halfBrick(false);
Main.tile[index31 - 1, index32].type = (ushort) 226;
Main.tile[index31, index32].active(true);
Main.tile[index31, index32].slope((byte) 0);
Main.tile[index31, index32].halfBrick(false);
Main.tile[index31, index32].type = (ushort) 226;
Main.tile[index31 + 1, index32].active(true);
Main.tile[index31 + 1, index32].slope((byte) 0);
Main.tile[index31 + 1, index32].halfBrick(false);
Main.tile[index31 + 1, index32].type = (ushort) 226;
int num50 = index32 - 2;
int num51 = index31 - 1;
for (int index33 = -1; index33 <= 3; ++index33)
{
for (int index34 = -1; index34 <= 1; ++index34)
{
x = num51 + index33;
y = num50 + index34;
Main.tile[x, y].active(false);
}
}
WorldGen.lAltarX = num51;
WorldGen.lAltarY = num50;
for (int index35 = 0; index35 <= 2; ++index35)
{
for (int index36 = 0; index36 <= 1; ++index36)
{
x = num51 + index35;
y = num50 + index36;
Main.tile[x, y].active(true);
Main.tile[x, y].type = (ushort) 237;
Main.tile[x, y].frameX = (short) (index35 * 18);
Main.tile[x, y].frameY = (short) (index36 * 18);
}
}
label_278:
float num52 = (float) maxValue * 1.1f * (float) (1.0 + (double) WorldGen.genRand.Next(-25, 26) * 0.00999999977648258);
int num53 = 0;
while ((double) num52 > 0.0)
{
++num53;
int index37 = WorldGen.genRand.Next(maxValue);
int index38 = WorldGen.genRand.Next(rectangleArray[index37].X, rectangleArray[index37].X + rectangleArray[index37].Width);
int index39 = WorldGen.genRand.Next(rectangleArray[index37].Y, rectangleArray[index37].Y + rectangleArray[index37].Height);
if (Main.tile[index38, index39].wall == (byte) 87 && !Main.tile[index38, index39].active())
{
bool flag6 = false;
if (WorldGen.genRand.Next(2) == 0)
{
int num54 = 1;
if (WorldGen.genRand.Next(2) == 0)
num54 = -1;
while (!Main.tile[index38, index39].active())
index39 += num54;
int num55 = index39 - num54;
int num56 = WorldGen.genRand.Next(2);
int num57 = WorldGen.genRand.Next(3, 10);
bool flag7 = true;
for (int index40 = index38 - num57; index40 < index38 + num57; ++index40)
{
for (int index41 = num55 - num57; index41 < num55 + num57; ++index41)
{
if (Main.tile[index40, index41].active() && Main.tile[index40, index41].type == (ushort) 10)
{
flag7 = false;
break;
}
}
}
if (flag7)
{
for (int i3 = index38 - num57; i3 < index38 + num57; ++i3)
{
for (int j3 = num55 - num57; j3 < num55 + num57; ++j3)
{
if (WorldGen.SolidTile(i3, j3) && Main.tile[i3, j3].type != (ushort) 232 && !WorldGen.SolidTile(i3, j3 - num54))
{
Main.tile[i3, j3].type = (ushort) 232;
flag6 = true;
if (num56 == 0)
{
Main.tile[i3, j3 - 1].type = (ushort) 232;
Main.tile[i3, j3 - 1].active(true);
}
else
{
Main.tile[i3, j3 + 1].type = (ushort) 232;
Main.tile[i3, j3 + 1].active(true);
}
++num56;
if (num56 > 1)
num56 = 0;
}
}
}
}
if (flag6)
{
num53 = 0;
--num52;
}
}
else
{
int num58 = 1;
if (WorldGen.genRand.Next(2) == 0)
num58 = -1;
while (!Main.tile[index38, index39].active())
index38 += num58;
int num59 = index38 - num58;
int num60 = WorldGen.genRand.Next(2);
int num61 = WorldGen.genRand.Next(3, 10);
bool flag8 = true;
for (int index42 = num59 - num61; index42 < num59 + num61; ++index42)
{
for (int index43 = index39 - num61; index43 < index39 + num61; ++index43)
{
if (Main.tile[index42, index43].active() && Main.tile[index42, index43].type == (ushort) 10)
{
flag8 = false;
break;
}
}
}
if (flag8)
{
for (int i4 = num59 - num61; i4 < num59 + num61; ++i4)
{
for (int j4 = index39 - num61; j4 < index39 + num61; ++j4)
{
if (WorldGen.SolidTile(i4, j4) && Main.tile[i4, j4].type != (ushort) 232 && !WorldGen.SolidTile(i4 - num58, j4))
{
Main.tile[i4, j4].type = (ushort) 232;
flag6 = true;
if (num60 == 0)
{
Main.tile[i4 - 1, j4].type = (ushort) 232;
Main.tile[i4 - 1, j4].active(true);
}
else
{
Main.tile[i4 + 1, j4].type = (ushort) 232;
Main.tile[i4 + 1, j4].active(true);
}
++num60;
if (num60 > 1)
num60 = 0;
}
}
}
}
if (flag6)
{
num53 = 0;
--num52;
}
}
}
if (num53 > 1000)
{
num53 = 0;
--num52;
}
}
WorldGen.tLeft = num38;
WorldGen.tRight = num39;
WorldGen.tTop = num40;
WorldGen.tBottom = num41;
WorldGen.tRooms = maxValue;
}
public static void templePart2()
{
int tLeft = WorldGen.tLeft;
int tRight = WorldGen.tRight;
int tTop = WorldGen.tTop;
int tBottom = WorldGen.tBottom;
int tRooms = WorldGen.tRooms;
float num1 = (float) tRooms * 1.9f * (float) (1.0 + (double) WorldGen.genRand.Next(-15, 16) * 0.00999999977648258);
int num2 = 0;
while ((double) num1 > 0.0)
{
int x2 = WorldGen.genRand.Next(tLeft, tRight);
int y2 = WorldGen.genRand.Next(tTop, tBottom);
if (Main.tile[x2, y2].wall == (byte) 87 && !Main.tile[x2, y2].active())
{
if (WorldGen.mayanTrap(x2, y2))
{
--num1;
num2 = 0;
}
else
++num2;
}
else
++num2;
if (num2 > 100)
{
num2 = 0;
--num1;
}
}
Main.tileSolid[232] = false;
float num3 = (float) tRooms * 0.35f * (float) (1.0 + (double) WorldGen.genRand.Next(-15, 16) * 0.00999999977648258);
int contain = 1293;
int num4 = 0;
while ((double) num3 > 0.0)
{
int i = WorldGen.genRand.Next(tLeft, tRight);
int j = WorldGen.genRand.Next(tTop, tBottom);
if (Main.tile[i, j].wall == (byte) 87 && !Main.tile[i, j].active() && WorldGen.AddBuriedChest(i, j, contain, true, 16))
{
--num3;
num4 = 0;
}
++num4;
if (num4 > 10000)
break;
}
float num5 = (float) tRooms * 1.25f * (float) (1.0 + (double) WorldGen.genRand.Next(-25, 36) * 0.00999999977648258);
int num6 = 0;
while ((double) num5 > 0.0)
{
++num6;
int index1 = WorldGen.genRand.Next(tLeft, tRight);
int index2 = WorldGen.genRand.Next(tTop, tBottom);
if (Main.tile[index1, index2].wall == (byte) 87 && !Main.tile[index1, index2].active())
{
int i = index1;
int index3 = index2;
while (!Main.tile[i, index3].active())
{
++index3;
if (index3 > tBottom)
break;
}
int j = index3 - 1;
if (j <= tBottom)
{
WorldGen.PlaceTile(i, j, 105, true, style: WorldGen.genRand.Next(43, 46));
if (Main.tile[i, j].type == (ushort) 105)
--num5;
}
}
}
float num7 = (float) tRooms * 1.35f * (float) (1.0 + (double) WorldGen.genRand.Next(-15, 26) * 0.00999999977648258);
int num8 = 0;
while ((double) num7 > 0.0)
{
++num8;
int index4 = WorldGen.genRand.Next(tLeft, tRight);
int index5 = WorldGen.genRand.Next(tTop, tBottom);
if (Main.tile[index4, index5].wall == (byte) 87 && !Main.tile[index4, index5].active())
{
int i = index4;
int index6 = index5;
while (!Main.tile[i, index6].active())
{
++index6;
if (index6 > tBottom)
break;
}
int j = index6 - 1;
if (j <= tBottom)
{
switch (WorldGen.genRand.Next(3))
{
case 0:
WorldGen.PlaceTile(i, j, 18, true, style: 10);
if (Main.tile[i, j].type == (ushort) 18)
{
--num7;
break;
}
break;
case 1:
WorldGen.PlaceTile(i, j, 14, true, style: 9);
if (Main.tile[i, j].type == (ushort) 14)
{
--num7;
break;
}
break;
case 2:
WorldGen.PlaceTile(i, j, 15, true, style: 12);
if (Main.tile[i, j].type == (ushort) 15)
{
--num7;
break;
}
break;
}
}
}
if (num8 > 10000)
break;
}
Main.tileSolid[232] = true;
}
public static bool nearPicture(int x, int y)
{
for (int index1 = x - 4; index1 <= x + 3; ++index1)
{
for (int index2 = y - 3; index2 <= y + 2; ++index2)
{
if (Main.tile[index1, index2].active())
return true;
}
}
return false;
}
public static bool nearPicture2(int x, int y)
{
if (Main.tile[x, y].wall != (byte) 7 && Main.tile[x, y].wall != (byte) 8 && Main.tile[x, y].wall != (byte) 9)
{
for (int index1 = x - 8; index1 <= x + 8; ++index1)
{
for (int index2 = y - 5; index2 <= y + 5; ++index2)
{
if (Main.tile[index1, index2].active() && (Main.tile[index1, index2].type == (ushort) 240 || Main.tile[index1, index2].type == (ushort) 241 || Main.tile[index1, index2].type == (ushort) 242))
return true;
}
}
}
else
{
for (int index3 = x - 15; index3 <= x + 15; ++index3)
{
for (int index4 = y - 10; index4 <= y + 10; ++index4)
{
if (Main.tile[index3, index4].active() && (Main.tile[index3, index4].type == (ushort) 240 || Main.tile[index3, index4].type == (ushort) 241 || Main.tile[index3, index4].type == (ushort) 242))
return true;
}
}
}
return false;
}
public static void MakeDungeon(int x, int y)
{
int num1 = WorldGen.genRand.Next(3);
WorldGen.genRand.Next(3);
ushort tileType;
int wallType;
switch (num1)
{
case 0:
tileType = (ushort) 41;
wallType = 7;
break;
case 1:
tileType = (ushort) 43;
wallType = 8;
break;
default:
tileType = (ushort) 44;
wallType = 9;
break;
}
WorldGen.numDDoors = 0;
WorldGen.numDPlats = 0;
WorldGen.numDRooms = 0;
WorldGen.dungeonX = x;
WorldGen.dungeonY = y;
WorldGen.dMinX = x;
WorldGen.dMaxX = x;
WorldGen.dMinY = y;
WorldGen.dMaxY = y;
WorldGen.dxStrength1 = (double) WorldGen.genRand.Next(25, 30);
WorldGen.dyStrength1 = (double) WorldGen.genRand.Next(20, 25);
WorldGen.dxStrength2 = (double) WorldGen.genRand.Next(35, 50);
WorldGen.dyStrength2 = (double) WorldGen.genRand.Next(10, 15);
float num2 = (float) (Main.maxTilesX / 60);
float num3 = num2 + (float) WorldGen.genRand.Next(0, (int) ((double) num2 / 3.0));
float num4 = num3;
int num5 = 5;
WorldGen.DungeonRoom(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
while ((double) num3 > 0.0)
{
if (WorldGen.dungeonX < WorldGen.dMinX)
WorldGen.dMinX = WorldGen.dungeonX;
if (WorldGen.dungeonX > WorldGen.dMaxX)
WorldGen.dMaxX = WorldGen.dungeonX;
if (WorldGen.dungeonY > WorldGen.dMaxY)
WorldGen.dMaxY = WorldGen.dungeonY;
--num3;
Main.statusText = Lang.gen[58].Value + " " + (object) (int) (((double) num4 - (double) num3) / (double) num4 * 60.0) + "%";
if (num5 > 0)
--num5;
if (num5 == 0 & WorldGen.genRand.Next(3) == 0)
{
num5 = 5;
if (WorldGen.genRand.Next(2) == 0)
{
int dungeonX = WorldGen.dungeonX;
int dungeonY = WorldGen.dungeonY;
WorldGen.DungeonHalls(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
if (WorldGen.genRand.Next(2) == 0)
WorldGen.DungeonHalls(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
WorldGen.DungeonRoom(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
WorldGen.dungeonX = dungeonX;
WorldGen.dungeonY = dungeonY;
}
else
WorldGen.DungeonRoom(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
}
else
WorldGen.DungeonHalls(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
}
WorldGen.DungeonRoom(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
int num6 = WorldGen.dRoomX[0];
int num7 = WorldGen.dRoomY[0];
for (int index = 0; index < WorldGen.numDRooms; ++index)
{
if (WorldGen.dRoomY[index] < num7)
{
num6 = WorldGen.dRoomX[index];
num7 = WorldGen.dRoomY[index];
}
}
WorldGen.dungeonX = num6;
WorldGen.dungeonY = num7;
WorldGen.dEnteranceX = num6;
WorldGen.dSurface = false;
int num8 = 5;
while (!WorldGen.dSurface)
{
if (num8 > 0)
--num8;
if (num8 == 0 && WorldGen.genRand.Next(5) == 0 && (double) WorldGen.dungeonY > Main.worldSurface + 100.0)
{
num8 = 10;
int dungeonX = WorldGen.dungeonX;
int dungeonY = WorldGen.dungeonY;
WorldGen.DungeonHalls(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType, true);
WorldGen.DungeonRoom(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
WorldGen.dungeonX = dungeonX;
WorldGen.dungeonY = dungeonY;
}
WorldGen.DungeonStairs(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
}
WorldGen.DungeonEnt(WorldGen.dungeonX, WorldGen.dungeonY, tileType, wallType);
Main.statusText = Lang.gen[58].Value + " 65%";
for (int index1 = 0; index1 < WorldGen.numDRooms; ++index1)
{
for (int index2 = WorldGen.dRoomL[index1]; index2 <= WorldGen.dRoomR[index1]; ++index2)
{
if (!Main.tile[index2, WorldGen.dRoomT[index1] - 1].active())
{
WorldGen.DPlatX[WorldGen.numDPlats] = index2;
WorldGen.DPlatY[WorldGen.numDPlats] = WorldGen.dRoomT[index1] - 1;
++WorldGen.numDPlats;
break;
}
}
for (int index3 = WorldGen.dRoomL[index1]; index3 <= WorldGen.dRoomR[index1]; ++index3)
{
if (!Main.tile[index3, WorldGen.dRoomB[index1] + 1].active())
{
WorldGen.DPlatX[WorldGen.numDPlats] = index3;
WorldGen.DPlatY[WorldGen.numDPlats] = WorldGen.dRoomB[index1] + 1;
++WorldGen.numDPlats;
break;
}
}
for (int index4 = WorldGen.dRoomT[index1]; index4 <= WorldGen.dRoomB[index1]; ++index4)
{
if (!Main.tile[WorldGen.dRoomL[index1] - 1, index4].active())
{
WorldGen.DDoorX[WorldGen.numDDoors] = WorldGen.dRoomL[index1] - 1;
WorldGen.DDoorY[WorldGen.numDDoors] = index4;
WorldGen.DDoorPos[WorldGen.numDDoors] = -1;
++WorldGen.numDDoors;
break;
}
}
for (int index5 = WorldGen.dRoomT[index1]; index5 <= WorldGen.dRoomB[index1]; ++index5)
{
if (!Main.tile[WorldGen.dRoomR[index1] + 1, index5].active())
{
WorldGen.DDoorX[WorldGen.numDDoors] = WorldGen.dRoomR[index1] + 1;
WorldGen.DDoorY[WorldGen.numDDoors] = index5;
WorldGen.DDoorPos[WorldGen.numDDoors] = 1;
++WorldGen.numDDoors;
break;
}
}
}
Main.statusText = Lang.gen[58].Value + " 70%";
int num9 = 0;
int num10 = 1000;
int num11 = 0;
while (num11 < Main.maxTilesX / 100)
{
++num9;
int index6 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int index7 = WorldGen.genRand.Next((int) Main.worldSurface + 25, WorldGen.dMaxY);
int num12 = index6;
if ((int) Main.tile[index6, index7].wall == wallType && !Main.tile[index6, index7].active())
{
int num13 = 1;
if (WorldGen.genRand.Next(2) == 0)
num13 = -1;
while (!Main.tile[index6, index7].active())
index7 += num13;
if (Main.tile[index6 - 1, index7].active() && Main.tile[index6 + 1, index7].active() && !Main.tile[index6 - 1, index7 - num13].active() && !Main.tile[index6 + 1, index7 - num13].active())
{
++num11;
for (int index8 = WorldGen.genRand.Next(5, 13); Main.tile[index6 - 1, index7].active() && Main.tile[index6, index7 + num13].active() && Main.tile[index6, index7].active() && !Main.tile[index6, index7 - num13].active() && index8 > 0; --index8)
{
Main.tile[index6, index7].type = (ushort) 48;
if (!Main.tile[index6 - 1, index7 - num13].active() && !Main.tile[index6 + 1, index7 - num13].active())
{
Main.tile[index6, index7 - num13].type = (ushort) 48;
Main.tile[index6, index7 - num13].active(true);
}
--index6;
}
int num14 = WorldGen.genRand.Next(5, 13);
for (int index9 = num12 + 1; Main.tile[index9 + 1, index7].active() && Main.tile[index9, index7 + num13].active() && Main.tile[index9, index7].active() && !Main.tile[index9, index7 - num13].active() && num14 > 0; --num14)
{
Main.tile[index9, index7].type = (ushort) 48;
if (!Main.tile[index9 - 1, index7 - num13].active() && !Main.tile[index9 + 1, index7 - num13].active())
{
Main.tile[index9, index7 - num13].type = (ushort) 48;
Main.tile[index9, index7 - num13].active(true);
}
++index9;
}
}
}
if (num9 > num10)
{
num9 = 0;
++num11;
}
}
int num15 = 0;
int num16 = 1000;
int num17 = 0;
Main.statusText = Lang.gen[58].Value + " 75%";
while (num17 < Main.maxTilesX / 100)
{
++num15;
int index10 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int index11 = WorldGen.genRand.Next((int) Main.worldSurface + 25, WorldGen.dMaxY);
int num18 = index11;
if ((int) Main.tile[index10, index11].wall == wallType && !Main.tile[index10, index11].active())
{
int num19 = 1;
if (WorldGen.genRand.Next(2) == 0)
num19 = -1;
while (index10 > 5 && index10 < Main.maxTilesX - 5 && !Main.tile[index10, index11].active())
index10 += num19;
if (Main.tile[index10, index11 - 1].active() && Main.tile[index10, index11 + 1].active() && !Main.tile[index10 - num19, index11 - 1].active() && !Main.tile[index10 - num19, index11 + 1].active())
{
++num17;
for (int index12 = WorldGen.genRand.Next(5, 13); Main.tile[index10, index11 - 1].active() && Main.tile[index10 + num19, index11].active() && Main.tile[index10, index11].active() && !Main.tile[index10 - num19, index11].active() && index12 > 0; --index12)
{
Main.tile[index10, index11].type = (ushort) 48;
if (!Main.tile[index10 - num19, index11 - 1].active() && !Main.tile[index10 - num19, index11 + 1].active())
{
Main.tile[index10 - num19, index11].type = (ushort) 48;
Main.tile[index10 - num19, index11].active(true);
}
--index11;
}
int num20 = WorldGen.genRand.Next(5, 13);
for (int index13 = num18 + 1; Main.tile[index10, index13 + 1].active() && Main.tile[index10 + num19, index13].active() && Main.tile[index10, index13].active() && !Main.tile[index10 - num19, index13].active() && num20 > 0; --num20)
{
Main.tile[index10, index13].type = (ushort) 48;
if (!Main.tile[index10 - num19, index13 - 1].active() && !Main.tile[index10 - num19, index13 + 1].active())
{
Main.tile[index10 - num19, index13].type = (ushort) 48;
Main.tile[index10 - num19, index13].active(true);
}
++index13;
}
}
}
if (num15 > num16)
{
num15 = 0;
++num17;
}
}
Main.statusText = Lang.gen[58].Value + " 80%";
for (int index14 = 0; index14 < WorldGen.numDDoors; ++index14)
{
int num21 = WorldGen.DDoorX[index14] - 10;
int num22 = WorldGen.DDoorX[index14] + 10;
int num23 = 100;
int num24 = 0;
for (int index15 = num21; index15 < num22; ++index15)
{
bool flag1 = true;
int index16 = WorldGen.DDoorY[index14];
while (index16 > 10 && !Main.tile[index15, index16].active())
--index16;
if (!Main.tileDungeon[(int) Main.tile[index15, index16].type])
flag1 = false;
int num25 = index16;
int index17 = WorldGen.DDoorY[index14];
while (!Main.tile[index15, index17].active())
++index17;
if (!Main.tileDungeon[(int) Main.tile[index15, index17].type])
flag1 = false;
int num26 = index17;
if (num26 - num25 >= 3)
{
int num27 = index15 - 20;
int num28 = index15 + 20;
int num29 = num26 - 10;
int num30 = num26 + 10;
for (int index18 = num27; index18 < num28; ++index18)
{
for (int index19 = num29; index19 < num30; ++index19)
{
if (Main.tile[index18, index19].active() && Main.tile[index18, index19].type == (ushort) 10)
{
flag1 = false;
break;
}
}
}
if (flag1)
{
for (int index20 = num26 - 3; index20 < num26; ++index20)
{
for (int index21 = index15 - 3; index21 <= index15 + 3; ++index21)
{
if (Main.tile[index21, index20].active())
{
flag1 = false;
break;
}
}
}
}
if (flag1 && num26 - num25 < 20)
{
bool flag2 = false;
if (WorldGen.DDoorPos[index14] == 0 && num26 - num25 < num23)
flag2 = true;
if (WorldGen.DDoorPos[index14] == -1 && index15 > num24)
flag2 = true;
if (WorldGen.DDoorPos[index14] == 1 && (index15 < num24 || num24 == 0))
flag2 = true;
if (flag2)
{
num24 = index15;
num23 = num26 - num25;
}
}
}
}
if (num23 < 20)
{
int i = num24;
int index22 = WorldGen.DDoorY[index14];
int index23 = index22;
for (; !Main.tile[i, index22].active(); ++index22)
Main.tile[i, index22].active(false);
while (!Main.tile[i, index23].active())
--index23;
int j = index22 - 1;
int num31 = index23 + 1;
for (int index24 = num31; index24 < j - 2; ++index24)
{
Main.tile[i, index24].active(true);
Main.tile[i, index24].type = tileType;
}
int style = 13;
if (WorldGen.genRand.Next(3) == 0)
{
switch (wallType)
{
case 7:
style = 16;
break;
case 8:
style = 17;
break;
case 9:
style = 18;
break;
}
}
WorldGen.PlaceTile(i, j, 10, true, style: style);
int index25 = i - 1;
int index26 = j - 3;
while (!Main.tile[index25, index26].active())
--index26;
if (j - index26 < j - num31 + 5 && Main.tileDungeon[(int) Main.tile[index25, index26].type])
{
for (int index27 = j - 4 - WorldGen.genRand.Next(3); index27 > index26; --index27)
{
Main.tile[index25, index27].active(true);
Main.tile[index25, index27].type = tileType;
}
}
int index28 = index25 + 2;
int index29 = j - 3;
while (!Main.tile[index28, index29].active())
--index29;
if (j - index29 < j - num31 + 5 && Main.tileDungeon[(int) Main.tile[index28, index29].type])
{
for (int index30 = j - 4 - WorldGen.genRand.Next(3); index30 > index29; --index30)
{
Main.tile[index28, index30].active(true);
Main.tile[index28, index30].type = tileType;
}
}
int index31 = j + 1;
int num32 = index28 - 1;
Main.tile[num32 - 1, index31].active(true);
Main.tile[num32 - 1, index31].type = tileType;
Main.tile[num32 + 1, index31].active(true);
Main.tile[num32 + 1, index31].type = tileType;
}
}
int[] roomWall = new int[3];
switch (wallType)
{
case 7:
roomWall[0] = 7;
roomWall[1] = 94;
roomWall[2] = 95;
break;
case 9:
roomWall[0] = 9;
roomWall[1] = 96;
roomWall[2] = 97;
break;
default:
roomWall[0] = 8;
roomWall[1] = 98;
roomWall[2] = 99;
break;
}
for (int index32 = 0; index32 < 5; ++index32)
{
for (int index33 = 0; index33 < 3; ++index33)
{
int num33 = WorldGen.genRand.Next(40, 240);
int num34 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int num35 = WorldGen.genRand.Next(WorldGen.dMinY, WorldGen.dMaxY);
for (int x1 = num34 - num33; x1 < num34 + num33; ++x1)
{
for (int y1 = num35 - num33; y1 < num35 + num33; ++y1)
{
if ((double) y1 > Main.worldSurface)
{
double num36 = (double) Math.Abs(num34 - x1);
float num37 = (float) Math.Abs(num35 - y1);
if (Math.Sqrt(num36 * num36 + (double) num37 * (double) num37) < (double) num33 * 0.4 && Main.wallDungeon[(int) Main.tile[x1, y1].wall])
WorldGen.Spread.WallDungeon(x1, y1, roomWall[index33]);
}
}
}
}
}
Main.statusText = Lang.gen[58].Value + " 85%";
for (int index34 = 0; index34 < WorldGen.numDPlats; ++index34)
{
int index35 = WorldGen.DPlatX[index34];
int num38 = WorldGen.DPlatY[index34];
int num39 = Main.maxTilesX;
int num40 = 10;
if ((double) num38 < Main.worldSurface + 50.0)
num40 = 20;
for (int index36 = num38 - 5; index36 <= num38 + 5; ++index36)
{
int index37 = index35;
int index38 = index35;
bool flag3 = false;
if (Main.tile[index37, index36].active())
{
flag3 = true;
}
else
{
while (!Main.tile[index37, index36].active())
{
--index37;
if (!Main.tileDungeon[(int) Main.tile[index37, index36].type])
flag3 = true;
}
while (!Main.tile[index38, index36].active())
{
++index38;
if (!Main.tileDungeon[(int) Main.tile[index38, index36].type])
flag3 = true;
}
}
if (!flag3 && index38 - index37 <= num40)
{
bool flag4 = true;
int num41 = index35 - num40 / 2 - 2;
int num42 = index35 + num40 / 2 + 2;
int num43 = index36 - 5;
int num44 = index36 + 5;
for (int index39 = num41; index39 <= num42; ++index39)
{
for (int index40 = num43; index40 <= num44; ++index40)
{
if (Main.tile[index39, index40].active() && Main.tile[index39, index40].type == (ushort) 19)
{
flag4 = false;
break;
}
}
}
for (int index41 = index36 + 3; index41 >= index36 - 5; --index41)
{
if (Main.tile[index35, index41].active())
{
flag4 = false;
break;
}
}
if (flag4)
{
num39 = index36;
break;
}
}
}
if (num39 > num38 - 10 && num39 < num38 + 10)
{
int index42 = index35;
int index43 = num39;
int index44 = index35 + 1;
for (; !Main.tile[index42, index43].active(); --index42)
{
Main.tile[index42, index43].active(true);
Main.tile[index42, index43].type = (ushort) 19;
if (wallType == 7)
Main.tile[index42, index43].frameY = (short) 108;
if (wallType == 8)
Main.tile[index42, index43].frameY = (short) 144;
if (wallType == 9)
Main.tile[index42, index43].frameY = (short) 126;
}
for (; !Main.tile[index44, index43].active(); ++index44)
{
Main.tile[index44, index43].active(true);
Main.tile[index44, index43].type = (ushort) 19;
if (wallType == 7)
Main.tile[index44, index43].frameY = (short) 108;
if (wallType == 8)
Main.tile[index44, index43].frameY = (short) 144;
if (wallType == 9)
Main.tile[index44, index43].frameY = (short) 126;
}
}
}
for (int index = 0; index < 4; ++index)
{
bool flag = false;
while (!flag)
{
int i = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int j = WorldGen.genRand.Next((int) Main.worldSurface, WorldGen.dMaxY);
if (Main.wallDungeon[(int) Main.tile[i, j].wall] && !Main.tile[i, j].active())
{
int contain = 0;
int Style = 0;
switch (index)
{
case 0:
Style = 23;
contain = 1156;
break;
case 1:
if (!WorldGen.crimson)
{
Style = 24;
contain = 1571;
break;
}
Style = 25;
contain = 1569;
break;
case 2:
Style = 26;
contain = 1260;
break;
case 3:
Style = 27;
contain = 1572;
break;
}
flag = WorldGen.AddBuriedChest(i, j, contain, Style: Style);
}
}
}
int[] numArray = new int[3]
{
WorldGen.genRand.Next(9, 13),
WorldGen.genRand.Next(9, 13),
0
};
while (numArray[1] == numArray[0])
numArray[1] = WorldGen.genRand.Next(9, 13);
numArray[2] = WorldGen.genRand.Next(9, 13);
while (numArray[2] == numArray[0] || numArray[2] == numArray[1])
numArray[2] = WorldGen.genRand.Next(9, 13);
Main.statusText = Lang.gen[58].Value + " 90%";
int num45 = 0;
int num46 = 1000;
int num47 = 0;
while (num47 < Main.maxTilesX / 20)
{
++num45;
int index45 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int index46 = WorldGen.genRand.Next(WorldGen.dMinY, WorldGen.dMaxY);
bool flag5 = true;
if (Main.wallDungeon[(int) Main.tile[index45, index46].wall] && !Main.tile[index45, index46].active())
{
int num48 = 1;
if (WorldGen.genRand.Next(2) == 0)
num48 = -1;
while (flag5 && !Main.tile[index45, index46].active())
{
index45 -= num48;
if (index45 < 5 || index45 > Main.maxTilesX - 5)
flag5 = false;
else if (Main.tile[index45, index46].active() && !Main.tileDungeon[(int) Main.tile[index45, index46].type])
flag5 = false;
}
if (flag5 && Main.tile[index45, index46].active() && Main.tileDungeon[(int) Main.tile[index45, index46].type] && Main.tile[index45, index46 - 1].active() && Main.tileDungeon[(int) Main.tile[index45, index46 - 1].type] && Main.tile[index45, index46 + 1].active() && Main.tileDungeon[(int) Main.tile[index45, index46 + 1].type])
{
int i1 = index45 + num48;
for (int index47 = i1 - 3; index47 <= i1 + 3; ++index47)
{
for (int index48 = index46 - 3; index48 <= index46 + 3; ++index48)
{
if (Main.tile[index47, index48].active() && Main.tile[index47, index48].type == (ushort) 19)
{
flag5 = false;
break;
}
}
}
if (flag5 && !Main.tile[i1, index46 - 1].active() & !Main.tile[i1, index46 - 2].active() & !Main.tile[i1, index46 - 3].active())
{
int index49 = i1;
int num49 = i1;
while (index49 > WorldGen.dMinX && index49 < WorldGen.dMaxX && !Main.tile[index49, index46].active() && !Main.tile[index49, index46 - 1].active() && !Main.tile[index49, index46 + 1].active())
index49 += num48;
int num50 = Math.Abs(i1 - index49);
bool flag6 = false;
if (WorldGen.genRand.Next(2) == 0)
flag6 = true;
if (num50 > 5)
{
for (int index50 = WorldGen.genRand.Next(1, 4); index50 > 0; --index50)
{
Main.tile[i1, index46].active(true);
Main.tile[i1, index46].type = (ushort) 19;
if ((int) Main.tile[i1, index46].wall == roomWall[0])
Main.tile[i1, index46].frameY = (short) (18 * numArray[0]);
if ((int) Main.tile[i1, index46].wall == roomWall[1])
Main.tile[i1, index46].frameY = (short) (18 * numArray[1]);
if ((int) Main.tile[i1, index46].wall == roomWall[2])
Main.tile[i1, index46].frameY = (short) (18 * numArray[2]);
if (flag6)
{
WorldGen.PlaceTile(i1, index46 - 1, 50, true);
if (WorldGen.genRand.Next(50) == 0 && Main.tile[i1, index46 - 1].type == (ushort) 50)
Main.tile[i1, index46 - 1].frameX = (short) 90;
}
i1 += num48;
}
num45 = 0;
++num47;
if (!flag6 && WorldGen.genRand.Next(2) == 0)
{
int i2 = num49;
int j = index46 - 1;
int type = 0;
if (WorldGen.genRand.Next(4) == 0)
type = 1;
switch (type)
{
case 0:
type = 13;
break;
case 1:
type = 49;
break;
}
WorldGen.PlaceTile(i2, j, type, true);
if (Main.tile[i2, j].type == (ushort) 13)
Main.tile[i2, j].frameX = WorldGen.genRand.Next(2) != 0 ? (short) 36 : (short) 18;
}
}
}
}
}
if (num45 > num46)
{
num45 = 0;
++num47;
}
}
Main.statusText = Lang.gen[58].Value + " 95%";
int num51 = 1;
for (int index = 0; index < WorldGen.numDRooms; ++index)
{
int num52 = 0;
while (num52 < 1000)
{
int num53 = (int) ((double) WorldGen.dRoomSize[index] * 0.4);
int i = WorldGen.dRoomX[index] + WorldGen.genRand.Next(-num53, num53 + 1);
int j = WorldGen.dRoomY[index] + WorldGen.genRand.Next(-num53, num53 + 1);
int Style = 2;
int contain;
switch (num51)
{
case 1:
contain = 329;
break;
case 2:
contain = 155;
break;
case 3:
contain = 156;
break;
case 4:
contain = 157;
break;
case 5:
contain = 163;
break;
case 6:
contain = 113;
break;
case 7:
contain = 3317;
break;
case 8:
contain = 327;
Style = 0;
break;
default:
contain = 164;
num51 = 0;
break;
}
if ((double) j < Main.worldSurface + 50.0)
{
contain = 327;
Style = 0;
}
if (contain == 0 && WorldGen.genRand.Next(2) == 0)
{
num52 = 1000;
}
else
{
if (WorldGen.AddBuriedChest(i, j, contain, Style: Style))
{
num52 += 1000;
++num51;
}
++num52;
}
}
}
WorldGen.dMinX -= 25;
WorldGen.dMaxX += 25;
WorldGen.dMinY -= 25;
WorldGen.dMaxY += 25;
if (WorldGen.dMinX < 0)
WorldGen.dMinX = 0;
if (WorldGen.dMaxX > Main.maxTilesX)
WorldGen.dMaxX = Main.maxTilesX;
if (WorldGen.dMinY < 0)
WorldGen.dMinY = 0;
if (WorldGen.dMaxY > Main.maxTilesY)
WorldGen.dMaxY = Main.maxTilesY;
int failCount = 0;
int failMax1 = 1000;
int numAdd = 0;
WorldGen.MakeDungeon_Lights(tileType, ref failCount, failMax1, ref numAdd, roomWall);
failCount = 0;
int failMax2 = 1000;
numAdd = 0;
WorldGen.MakeDungeon_Traps(ref failCount, failMax2, ref numAdd);
float count1 = WorldGen.MakeDungeon_GroundFurniture(wallType);
float count2 = WorldGen.MakeDungeon_Pictures(roomWall, count1);
WorldGen.MakeDungeon_Banners(roomWall, count2);
}
private static void MakeDungeon_Traps(ref int failCount, int failMax, ref int numAdd)
{
while (numAdd < Main.maxTilesX / 500)
{
++failCount;
int x2 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int y2 = WorldGen.genRand.Next(WorldGen.dMinY, WorldGen.dMaxY);
while ((double) y2 < Main.worldSurface)
y2 = WorldGen.genRand.Next(WorldGen.dMinY, WorldGen.dMaxY);
if (Main.wallDungeon[(int) Main.tile[x2, y2].wall] && WorldGen.placeTrap(x2, y2, 0))
failCount = failMax;
if (failCount > failMax)
{
++numAdd;
failCount = 0;
}
}
}
private static void MakeDungeon_Lights(
ushort tileType,
ref int failCount,
int failMax,
ref int numAdd,
int[] roomWall)
{
int[] numArray = new int[3]
{
WorldGen.genRand.Next(7),
WorldGen.genRand.Next(7),
0
};
while (numArray[1] == numArray[0])
numArray[1] = WorldGen.genRand.Next(7);
numArray[2] = WorldGen.genRand.Next(7);
while (numArray[2] == numArray[0] || numArray[2] == numArray[1])
numArray[2] = WorldGen.genRand.Next(7);
while (numAdd < Main.maxTilesX / 150)
{
++failCount;
int index1 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int index2 = WorldGen.genRand.Next(WorldGen.dMinY, WorldGen.dMaxY);
if (Main.wallDungeon[(int) Main.tile[index1, index2].wall])
{
for (int y = index2; y > WorldGen.dMinY; --y)
{
if (Main.tile[index1, y - 1].active() && (int) Main.tile[index1, y - 1].type == (int) tileType)
{
bool flag1 = false;
for (int index3 = index1 - 15; index3 < index1 + 15; ++index3)
{
for (int index4 = y - 15; index4 < y + 15; ++index4)
{
if (index3 > 0 && index3 < Main.maxTilesX && index4 > 0 && index4 < Main.maxTilesY && (Main.tile[index3, index4].type == (ushort) 42 || Main.tile[index3, index4].type == (ushort) 34))
{
flag1 = true;
break;
}
}
}
if (Main.tile[index1 - 1, y].active() || Main.tile[index1 + 1, y].active() || Main.tile[index1 - 1, y + 1].active() || Main.tile[index1 + 1, y + 1].active() || Main.tile[index1, y + 2].active())
flag1 = true;
if (!flag1)
{
bool flag2 = false;
if (!flag2 && WorldGen.genRand.Next(7) == 0)
{
int style = 27;
switch (roomWall[0])
{
case 7:
style = 27;
break;
case 8:
style = 28;
break;
case 9:
style = 29;
break;
}
bool flag3 = false;
for (int index5 = 0; index5 < 15; ++index5)
{
if (WorldGen.SolidTile(index1, y + index5))
{
flag3 = true;
break;
}
}
if (!flag3)
WorldGen.PlaceChand(index1, y, (ushort) 34, style);
if (Main.tile[index1, y].type == (ushort) 34)
{
flag2 = true;
failCount = 0;
++numAdd;
for (int index6 = 0; index6 < 1000; ++index6)
{
int i = index1 + WorldGen.genRand.Next(-12, 13);
int j = y + WorldGen.genRand.Next(3, 21);
if (!Main.tile[i, j].active() && !Main.tile[i, j + 1].active() && Main.tile[i - 1, j].type != (ushort) 48 && Main.tile[i + 1, j].type != (ushort) 48 && Collision.CanHit(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, new Vector2((float) (index1 * 16), (float) (y * 16 + 1)), 16, 16))
{
if (WorldGen.SolidTile(i - 1, j) && Main.tile[i - 1, j].type != (ushort) 10 || WorldGen.SolidTile(i + 1, j) && Main.tile[i + 1, j].type != (ushort) 10 || WorldGen.SolidTile(i, j + 1))
WorldGen.PlaceTile(i, j, 136, true);
if (Main.tile[i, j].active())
{
while (i != index1 || j != y)
{
Main.tile[i, j].wire(true);
if (i > index1)
--i;
if (i < index1)
++i;
Main.tile[i, j].wire(true);
if (j > y)
--j;
if (j < y)
++j;
Main.tile[i, j].wire(true);
}
if (WorldGen.genRand.Next(3) > 0)
{
Main.tile[index1, y].frameX = (short) 18;
Main.tile[index1, y + 1].frameX = (short) 18;
break;
}
break;
}
}
}
}
}
if (!flag2)
{
int style = numArray[0];
if ((int) Main.tile[index1, y].wall == roomWall[1])
style = numArray[1];
if ((int) Main.tile[index1, y].wall == roomWall[2])
style = numArray[2];
WorldGen.Place1x2Top(index1, y, (ushort) 42, style);
if (Main.tile[index1, y].type == (ushort) 42)
{
failCount = 0;
++numAdd;
for (int index7 = 0; index7 < 1000; ++index7)
{
int i = index1 + WorldGen.genRand.Next(-12, 13);
int j = y + WorldGen.genRand.Next(3, 21);
if (!Main.tile[i, j].active() && !Main.tile[i, j + 1].active() && Main.tile[i - 1, j].type != (ushort) 48 && Main.tile[i + 1, j].type != (ushort) 48 && Collision.CanHit(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, new Vector2((float) (index1 * 16), (float) (y * 16 + 1)), 16, 16))
{
if (WorldGen.SolidTile(i - 1, j) && Main.tile[i - 1, j].type != (ushort) 10 || WorldGen.SolidTile(i + 1, j) && Main.tile[i + 1, j].type != (ushort) 10 || WorldGen.SolidTile(i, j + 1))
WorldGen.PlaceTile(i, j, 136, true);
if (Main.tile[i, j].active())
{
while (i != index1 || j != y)
{
Main.tile[i, j].wire(true);
if (i > index1)
--i;
if (i < index1)
++i;
Main.tile[i, j].wire(true);
if (j > y)
--j;
if (j < y)
++j;
Main.tile[i, j].wire(true);
}
if (WorldGen.genRand.Next(3) > 0)
{
Main.tile[index1, y].frameX = (short) 18;
Main.tile[index1, y + 1].frameX = (short) 18;
break;
}
break;
}
}
}
break;
}
break;
}
break;
}
break;
}
}
}
if (failCount > failMax)
{
++numAdd;
failCount = 0;
}
}
}
private static float MakeDungeon_Banners(int[] roomWall, float count)
{
count = 840000f / (float) Main.maxTilesX;
for (int index1 = 0; (double) index1 < (double) count; ++index1)
{
int i = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int j1;
for (j1 = WorldGen.genRand.Next(WorldGen.dMinY, WorldGen.dMaxY); !Main.wallDungeon[(int) Main.tile[i, j1].wall] || Main.tile[i, j1].active(); j1 = WorldGen.genRand.Next(WorldGen.dMinY, WorldGen.dMaxY))
i = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
while (!WorldGen.SolidTile(i, j1) && j1 > 10)
--j1;
int j2 = j1 + 1;
if (Main.wallDungeon[(int) Main.tile[i, j2].wall] && Main.tile[i, j2 - 1].type != (ushort) 48 && !Main.tile[i, j2].active() && !Main.tile[i, j2 + 1].active() && !Main.tile[i, j2 + 2].active() && !Main.tile[i, j2 + 3].active())
{
bool flag = true;
for (int index2 = i - 1; index2 <= i + 1; ++index2)
{
for (int index3 = j2; index3 <= j2 + 3; ++index3)
{
if (Main.tile[index2, index3].active() && (Main.tile[index2, index3].type == (ushort) 10 || Main.tile[index2, index3].type == (ushort) 11 || Main.tile[index2, index3].type == (ushort) 91))
flag = false;
}
}
if (flag)
{
int num = 10;
if ((int) Main.tile[i, j2].wall == roomWall[1])
num = 12;
if ((int) Main.tile[i, j2].wall == roomWall[2])
num = 14;
int style = num + WorldGen.genRand.Next(2);
WorldGen.PlaceTile(i, j2, 91, true, style: style);
}
}
}
return count;
}
private static float MakeDungeon_Pictures(int[] roomWall, float count)
{
count = 420000f / (float) Main.maxTilesX;
for (int index1 = 0; (double) index1 < (double) count; ++index1)
{
int index2 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int index3;
for (index3 = WorldGen.genRand.Next((int) Main.worldSurface, WorldGen.dMaxY); !Main.wallDungeon[(int) Main.tile[index2, index3].wall] || Main.tile[index2, index3].active(); index3 = WorldGen.genRand.Next((int) Main.worldSurface, WorldGen.dMaxY))
index2 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
for (int index4 = 0; index4 < 2; ++index4)
{
int index5 = index2;
int index6 = index2;
while (!Main.tile[index5, index3].active() && Main.wallDungeon[(int) Main.tile[index5, index3].wall])
--index5;
int num1 = index5 + 1;
while (!Main.tile[index6, index3].active() && Main.wallDungeon[(int) Main.tile[index6, index3].wall])
++index6;
int num2 = index6 - 1;
index2 = (num1 + num2) / 2;
int index7 = index3;
int index8 = index3;
while (!Main.tile[index2, index7].active() && Main.wallDungeon[(int) Main.tile[index2, index7].wall])
--index7;
int num3 = index7 + 1;
while (!Main.tile[index2, index8].active() && Main.wallDungeon[(int) Main.tile[index2, index8].wall])
++index8;
int num4 = index8 - 1;
index3 = (num3 + num4) / 2;
}
int index9 = index2;
int index10 = index2;
while (!Main.tile[index9, index3].active() && !Main.tile[index9, index3 - 1].active() && !Main.tile[index9, index3 + 1].active())
--index9;
int num5 = index9 + 1;
while (!Main.tile[index10, index3].active() && !Main.tile[index10, index3 - 1].active() && !Main.tile[index10, index3 + 1].active())
++index10;
int num6 = index10 - 1;
int index11 = index3;
int index12 = index3;
while (!Main.tile[index2, index11].active() && !Main.tile[index2 - 1, index11].active() && !Main.tile[index2 + 1, index11].active())
--index11;
int num7 = index11 + 1;
while (!Main.tile[index2, index12].active() && !Main.tile[index2 - 1, index12].active() && !Main.tile[index2 + 1, index12].active())
++index12;
int num8 = index12 - 1;
int index13 = (num5 + num6) / 2;
int index14 = (num7 + num8) / 2;
int num9 = num6 - num5;
int num10 = num8 - num7;
if (num9 > 7 && num10 > 5)
{
bool[] flagArray = new bool[3]
{
true,
false,
false
};
if (num9 > num10 * 3 && num9 > 21)
flagArray[1] = true;
if (num10 > num9 * 3 && num10 > 21)
flagArray[2] = true;
int index15 = WorldGen.genRand.Next(3);
if ((int) Main.tile[index13, index14].wall == roomWall[0])
index15 = 0;
while (!flagArray[index15])
index15 = WorldGen.genRand.Next(3);
if (WorldGen.nearPicture2(index13, index14))
index15 = -1;
switch (index15)
{
case 0:
Vector2 vector2_1 = WorldGen.randPictureTile();
if ((int) Main.tile[index13, index14].wall != roomWall[0])
vector2_1 = WorldGen.randBoneTile();
int x1 = (int) vector2_1.X;
int y1 = (int) vector2_1.Y;
if (!WorldGen.nearPicture(index13, index14))
{
WorldGen.PlaceTile(index13, index14, x1, true, style: y1);
continue;
}
continue;
case 1:
Vector2 vector2_2 = WorldGen.randPictureTile();
if ((int) Main.tile[index13, index14].wall != roomWall[0])
vector2_2 = WorldGen.randBoneTile();
int x2 = (int) vector2_2.X;
int y2 = (int) vector2_2.Y;
if (!Main.tile[index13, index14].active())
WorldGen.PlaceTile(index13, index14, x2, true, style: y2);
int num11 = index13;
int num12 = index14;
int index16 = index14;
for (int index17 = 0; index17 < 2; ++index17)
{
index13 += 7;
int index18 = index16;
int index19 = index16;
while (!Main.tile[index13, index18].active() && !Main.tile[index13 - 1, index18].active() && !Main.tile[index13 + 1, index18].active())
--index18;
int num13 = index18 + 1;
while (!Main.tile[index13, index19].active() && !Main.tile[index13 - 1, index19].active() && !Main.tile[index13 + 1, index19].active())
++index19;
int num14 = index19 - 1;
index16 = (num13 + num14) / 2;
Vector2 vector2_3 = WorldGen.randPictureTile();
if ((int) Main.tile[index13, index16].wall != roomWall[0])
vector2_3 = WorldGen.randBoneTile();
int x3 = (int) vector2_3.X;
int y3 = (int) vector2_3.Y;
if (Math.Abs(num12 - index16) < 4 && !WorldGen.nearPicture(index13, index16))
WorldGen.PlaceTile(index13, index16, x3, true, style: y3);
else
break;
}
int index20 = index14;
int index21 = num11;
for (int index22 = 0; index22 < 2; ++index22)
{
index21 -= 7;
int index23 = index20;
int index24 = index20;
while (!Main.tile[index21, index23].active() && !Main.tile[index21 - 1, index23].active() && !Main.tile[index21 + 1, index23].active())
--index23;
int num15 = index23 + 1;
while (!Main.tile[index21, index24].active() && !Main.tile[index21 - 1, index24].active() && !Main.tile[index21 + 1, index24].active())
++index24;
int num16 = index24 - 1;
index20 = (num15 + num16) / 2;
Vector2 vector2_4 = WorldGen.randPictureTile();
if ((int) Main.tile[index21, index20].wall != roomWall[0])
vector2_4 = WorldGen.randBoneTile();
int x4 = (int) vector2_4.X;
int y4 = (int) vector2_4.Y;
if (Math.Abs(num12 - index20) < 4 && !WorldGen.nearPicture(index21, index20))
WorldGen.PlaceTile(index21, index20, x4, true, style: y4);
else
break;
}
continue;
case 2:
Vector2 vector2_5 = WorldGen.randPictureTile();
if ((int) Main.tile[index13, index14].wall != roomWall[0])
vector2_5 = WorldGen.randBoneTile();
int x5 = (int) vector2_5.X;
int y5 = (int) vector2_5.Y;
if (!Main.tile[index13, index14].active())
WorldGen.PlaceTile(index13, index14, x5, true, style: y5);
int num17 = index14;
int num18 = index13;
int index25 = index13;
for (int index26 = 0; index26 < 3; ++index26)
{
index14 += 7;
int index27 = index25;
int index28 = index25;
while (!Main.tile[index27, index14].active() && !Main.tile[index27, index14 - 1].active() && !Main.tile[index27, index14 + 1].active())
--index27;
int num19 = index27 + 1;
while (!Main.tile[index28, index14].active() && !Main.tile[index28, index14 - 1].active() && !Main.tile[index28, index14 + 1].active())
++index28;
int num20 = index28 - 1;
index25 = (num19 + num20) / 2;
Vector2 vector2_6 = WorldGen.randPictureTile();
if ((int) Main.tile[index25, index14].wall != roomWall[0])
vector2_6 = WorldGen.randBoneTile();
int x6 = (int) vector2_6.X;
int y6 = (int) vector2_6.Y;
if (Math.Abs(num18 - index25) < 4 && !WorldGen.nearPicture(index25, index14))
WorldGen.PlaceTile(index25, index14, x6, true, style: y6);
else
break;
}
int index29 = index13;
int index30 = num17;
for (int index31 = 0; index31 < 3; ++index31)
{
index30 -= 7;
int index32 = index29;
int index33 = index29;
while (!Main.tile[index32, index30].active() && !Main.tile[index32, index30 - 1].active() && !Main.tile[index32, index30 + 1].active())
--index32;
int num21 = index32 + 1;
while (!Main.tile[index33, index30].active() && !Main.tile[index33, index30 - 1].active() && !Main.tile[index33, index30 + 1].active())
++index33;
int num22 = index33 - 1;
index29 = (num21 + num22) / 2;
Vector2 vector2_7 = WorldGen.randPictureTile();
if ((int) Main.tile[index29, index30].wall != roomWall[0])
vector2_7 = WorldGen.randBoneTile();
int x7 = (int) vector2_7.X;
int y7 = (int) vector2_7.Y;
if (Math.Abs(num18 - index29) < 4 && !WorldGen.nearPicture(index29, index30))
WorldGen.PlaceTile(index29, index30, x7, true, style: y7);
else
break;
}
continue;
default:
continue;
}
}
}
return count;
}
private static float MakeDungeon_GroundFurniture(int wallType)
{
float num1 = (float) (2000.0 * (double) Main.maxTilesX / 4200.0);
int num2 = 1 + Main.maxTilesX / 4200;
int num3 = 1 + Main.maxTilesX / 4200;
for (int index1 = 0; (double) index1 < (double) num1; ++index1)
{
if (num2 > 0 || num3 > 0)
--index1;
int i1 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
int j;
for (j = WorldGen.genRand.Next((int) Main.worldSurface + 10, WorldGen.dMaxY); !Main.wallDungeon[(int) Main.tile[i1, j].wall] || Main.tile[i1, j].active(); j = WorldGen.genRand.Next((int) Main.worldSurface + 10, WorldGen.dMaxY))
i1 = WorldGen.genRand.Next(WorldGen.dMinX, WorldGen.dMaxX);
if (Main.wallDungeon[(int) Main.tile[i1, j].wall] && !Main.tile[i1, j].active())
{
while (!WorldGen.SolidTile(i1, j) && j < Main.maxTilesY - 200)
++j;
int index2 = j - 1;
int i2 = i1;
int i3 = i1;
while (!Main.tile[i2, index2].active() && WorldGen.SolidTile(i2, index2 + 1))
--i2;
int num4 = i2 + 1;
while (!Main.tile[i3, index2].active() && WorldGen.SolidTile(i3, index2 + 1))
++i3;
int num5 = i3 - 1;
int num6 = num5 - num4;
int index3 = (num5 + num4) / 2;
if (!Main.tile[index3, index2].active() && Main.wallDungeon[(int) Main.tile[index3, index2].wall] && WorldGen.SolidTile(index3, index2 + 1) && Main.tile[index3, index2 + 1].type != (ushort) 48)
{
int style1 = 13;
int style2 = 10;
int style3 = 11;
int style4 = 1;
int style5 = 46;
int style6 = 1;
int style7 = 5;
int style8 = 11;
int style9 = 5;
int style10 = 6;
int style11 = 21;
int style12 = 22;
int style13 = 24;
int style14 = 30;
switch (wallType)
{
case 8:
style1 = 14;
style2 = 11;
style3 = 12;
style4 = 2;
style5 = 47;
style6 = 2;
style7 = 6;
style8 = 12;
style9 = 6;
style10 = 7;
style11 = 22;
style12 = 23;
style13 = 25;
style14 = 31;
break;
case 9:
style1 = 15;
style2 = 12;
style3 = 13;
style4 = 3;
style5 = 48;
style6 = 3;
style7 = 7;
style8 = 13;
style9 = 7;
style10 = 8;
style11 = 23;
style12 = 24;
style13 = 26;
style14 = 32;
break;
}
if (Main.tile[index3, index2].wall >= (byte) 94 && Main.tile[index3, index2].wall <= (byte) 105)
{
style1 = 17;
style2 = 14;
style3 = 15;
style4 = -1;
style5 = -1;
style6 = 5;
style7 = -1;
style8 = -1;
style9 = -1;
style10 = -1;
style11 = -1;
style12 = -1;
style13 = -1;
style14 = -1;
}
int num7 = WorldGen.genRand.Next(13);
if ((num7 == 10 || num7 == 11 || num7 == 12) && WorldGen.genRand.Next(4) != 0)
num7 = WorldGen.genRand.Next(13);
while (num7 == 2 && style5 == -1 || num7 == 5 && style7 == -1 || num7 == 6 && style8 == -1 || num7 == 7 && style9 == -1 || num7 == 8 && style10 == -1 || num7 == 9 && style11 == -1 || num7 == 10 && style12 == -1 || num7 == 11 && style13 == -1 || num7 == 12 && style14 == -1)
num7 = WorldGen.genRand.Next(13);
int num8 = 0;
int num9 = 0;
if (num7 == 0)
{
num8 = 5;
num9 = 4;
}
if (num7 == 1)
{
num8 = 4;
num9 = 3;
}
if (num7 == 2)
{
num8 = 3;
num9 = 5;
}
if (num7 == 3)
{
num8 = 4;
num9 = 6;
}
if (num7 == 4)
{
num8 = 3;
num9 = 3;
}
if (num7 == 5)
{
num8 = 5;
num9 = 3;
}
if (num7 == 6)
{
num8 = 5;
num9 = 4;
}
if (num7 == 7)
{
num8 = 5;
num9 = 4;
}
if (num7 == 8)
{
num8 = 5;
num9 = 4;
}
if (num7 == 9)
{
num8 = 5;
num9 = 3;
}
if (num7 == 10)
{
num8 = 2;
num9 = 4;
}
if (num7 == 11)
{
num8 = 3;
num9 = 3;
}
if (num7 == 12)
{
num8 = 2;
num9 = 5;
}
for (int index4 = index3 - num8; index4 <= index3 + num8; ++index4)
{
for (int index5 = index2 - num9; index5 <= index2; ++index5)
{
if (Main.tile[index4, index5].active())
{
num7 = -1;
break;
}
}
}
if ((double) num6 < (double) num8 * 1.75)
num7 = -1;
if (num2 > 0 || num3 > 0)
{
if (num2 > 0)
{
WorldGen.PlaceTile(index3, index2, 355, true);
if (Main.tile[index3, index2].type == (ushort) 355)
--num2;
}
else if (num3 > 0)
{
WorldGen.PlaceTile(index3, index2, 354, true);
if (Main.tile[index3, index2].type == (ushort) 354)
--num3;
}
}
else
{
switch (num7)
{
case 0:
WorldGen.PlaceTile(index3, index2, 14, true, style: style2);
if (Main.tile[index3, index2].active())
{
if (!Main.tile[index3 - 2, index2].active())
{
WorldGen.PlaceTile(index3 - 2, index2, 15, true, style: style1);
if (Main.tile[index3 - 2, index2].active())
{
Main.tile[index3 - 2, index2].frameX += (short) 18;
Main.tile[index3 - 2, index2 - 1].frameX += (short) 18;
}
}
if (!Main.tile[index3 + 2, index2].active())
WorldGen.PlaceTile(index3 + 2, index2, 15, true, style: style1);
}
for (int i4 = index3 - 1; i4 <= index3 + 1; ++i4)
{
if (WorldGen.genRand.Next(2) == 0 && !Main.tile[i4, index2 - 2].active())
{
int num10 = WorldGen.genRand.Next(5);
if (style4 != -1 && num10 <= 1 && !Main.tileLighted[(int) Main.tile[i4 - 1, index2 - 2].type])
WorldGen.PlaceTile(i4, index2 - 2, 33, true, style: style4);
if (num10 == 2 && !Main.tileLighted[(int) Main.tile[i4 - 1, index2 - 2].type])
WorldGen.PlaceTile(i4, index2 - 2, 49, true);
if (num10 == 3)
WorldGen.PlaceTile(i4, index2 - 2, 50, true);
if (num10 == 4)
WorldGen.PlaceTile(i4, index2 - 2, 103, true);
}
}
continue;
case 1:
WorldGen.PlaceTile(index3, index2, 18, true, style: style3);
if (Main.tile[index3, index2].active())
{
if (WorldGen.genRand.Next(2) == 0)
{
if (!Main.tile[index3 - 1, index2].active())
{
WorldGen.PlaceTile(index3 - 1, index2, 15, true, style: style1);
if (Main.tile[index3 - 1, index2].active())
{
Main.tile[index3 - 1, index2].frameX += (short) 18;
Main.tile[index3 - 1, index2 - 1].frameX += (short) 18;
}
}
}
else if (!Main.tile[index3 + 2, index2].active())
WorldGen.PlaceTile(index3 + 2, index2, 15, true, style: style1);
for (int i5 = index3; i5 <= index3 + 1; ++i5)
{
if (WorldGen.genRand.Next(2) == 0 && !Main.tile[i5, index2 - 1].active())
{
int num11 = WorldGen.genRand.Next(5);
if (style4 != -1 && num11 <= 1 && !Main.tileLighted[(int) Main.tile[i5 - 1, index2 - 1].type])
WorldGen.PlaceTile(i5, index2 - 1, 33, true, style: style4);
if (num11 == 2 && !Main.tileLighted[(int) Main.tile[i5 - 1, index2 - 1].type])
WorldGen.PlaceTile(i5, index2 - 1, 49, true);
if (num11 == 3)
WorldGen.PlaceTile(i5, index2 - 1, 50, true);
if (num11 == 4)
WorldGen.PlaceTile(i5, index2 - 1, 103, true);
}
}
continue;
}
continue;
case 2:
WorldGen.PlaceTile(index3, index2, 105, true, style: style5);
continue;
case 3:
WorldGen.PlaceTile(index3, index2, 101, true, style: style6);
continue;
case 4:
if (WorldGen.genRand.Next(2) == 0)
{
WorldGen.PlaceTile(index3, index2, 15, true, style: style1);
Main.tile[index3, index2].frameX += (short) 18;
Main.tile[index3, index2 - 1].frameX += (short) 18;
continue;
}
WorldGen.PlaceTile(index3, index2, 15, true, style: style1);
continue;
case 5:
if (WorldGen.genRand.Next(2) == 0)
{
WorldGen.Place4x2(index3, index2, (ushort) 79, 1, style7);
continue;
}
WorldGen.Place4x2(index3, index2, (ushort) 79, style: style7);
continue;
case 6:
WorldGen.PlaceTile(index3, index2, 87, true, style: style8);
continue;
case 7:
WorldGen.PlaceTile(index3, index2, 88, true, style: style9);
continue;
case 8:
WorldGen.PlaceTile(index3, index2, 89, true, style: style10);
continue;
case 9:
if (WorldGen.genRand.Next(2) == 0)
{
WorldGen.Place4x2(index3, index2, (ushort) 90, 1, style11);
continue;
}
WorldGen.Place4x2(index3, index2, (ushort) 90, style: style11);
continue;
case 10:
WorldGen.PlaceTile(index3, index2, 93, true, style: style13);
continue;
case 11:
WorldGen.PlaceTile(index3, index2, 100, true, style: style12);
continue;
case 12:
WorldGen.PlaceTile(index3, index2, 104, true, style: style14);
continue;
default:
continue;
}
}
}
}
}
return num1;
}
public static Vector2 randBoneTile()
{
int num1 = WorldGen.genRand.Next(2);
int num2 = 0;
switch (num1)
{
case 0:
num1 = 240;
num2 = WorldGen.genRand.Next(2);
switch (num2)
{
case 0:
num2 = 16;
break;
case 1:
num2 = 17;
break;
}
break;
case 1:
num1 = 241;
num2 = WorldGen.genRand.Next(9);
break;
}
return new Vector2((float) num1, (float) num2);
}
public static Vector2 randHellPicture()
{
int num1 = WorldGen.genRand.Next(4);
if (num1 == 1)
num1 = WorldGen.genRand.Next(4);
int num2;
int num3;
if (num1 == 0)
{
num2 = 240;
num3 = WorldGen.genRand.Next(5);
switch (num3)
{
case 0:
num3 = 27;
break;
case 1:
num3 = 29;
break;
case 2:
num3 = 30;
break;
case 3:
num3 = 31;
break;
case 4:
num3 = 32;
break;
}
}
else if (num1 == 1)
{
num2 = 242;
num3 = 14;
}
else if (num1 == 2)
{
num2 = 245;
num3 = WorldGen.genRand.Next(3);
switch (num3)
{
case 0:
num3 = 1;
break;
case 1:
num3 = 2;
break;
case 2:
num3 = 4;
break;
}
}
else
{
num2 = 246;
num3 = WorldGen.genRand.Next(3);
switch (num3)
{
case 0:
num3 = 0;
break;
case 1:
num3 = 16;
break;
case 2:
num3 = 17;
break;
}
}
return new Vector2((float) num2, (float) num3);
}
public static Vector2 randHousePicture()
{
int num1 = WorldGen.genRand.Next(4);
int num2;
int num3;
if (num1 <= 1)
{
num2 = 240;
int maxValue = 10;
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 9)
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 5)
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 6)
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 0)
num3 = 26;
else if (num3 == 1)
num3 = 28;
else if (num3 == 2)
num3 = 20;
else if (num3 == 3)
num3 = 21;
else if (num3 == 4)
num3 = 22;
else if (num3 == 5)
num3 = 24;
else if (num3 == 6)
num3 = 25;
else if (num3 == 7)
num3 = 33;
else if (num3 == 8)
num3 = 34;
else if (num3 == 9)
num3 = 35;
}
else if (num1 == 2)
{
int maxValue = 4;
num2 = 245;
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 2)
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 0)
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 0)
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 0)
num3 = WorldGen.genRand.Next(maxValue);
if (num3 == 0)
num3 = 0;
else if (num3 == 1)
num3 = 3;
else if (num3 == 2)
num3 = 5;
else if (num3 == 3)
num3 = 6;
}
else
{
num2 = 246;
num3 = 1;
}
return new Vector2((float) num2, (float) num3);
}
public static Vector2 randPictureTile()
{
int num1 = WorldGen.genRand.Next(3);
int num2 = 0;
if (num1 <= 1)
{
int maxValue = 7;
num1 = 240;
num2 = WorldGen.genRand.Next(maxValue);
if (num2 == 6)
num2 = WorldGen.genRand.Next(maxValue);
if (num2 == 0)
num2 = 12;
else if (num2 == 1)
num2 = 13;
else if (num2 == 2)
num2 = 14;
else if (num2 == 3)
num2 = 15;
else if (num2 == 4)
num2 = 18;
else if (num2 == 5)
num2 = 19;
else if (num2 == 6)
num2 = 23;
}
else if (num1 == 2)
{
num1 = 242;
num2 = WorldGen.genRand.Next(17);
if (num2 > 13)
{
switch (num2)
{
case 14:
num2 = 15;
break;
case 15:
num2 = 16;
break;
case 16:
num2 = 30;
break;
}
}
}
return new Vector2((float) num1, (float) num2);
}
public static void DungeonStairs(int i, int j, ushort tileType, int wallType)
{
Vector2 zero = Vector2.Zero;
double num1 = (double) WorldGen.genRand.Next(5, 9);
Vector2 vector2;
vector2.X = (float) i;
vector2.Y = (float) j;
int num2 = WorldGen.genRand.Next(10, 30);
int num3 = i <= WorldGen.dEnteranceX ? 1 : -1;
if (i > Main.maxTilesX - 400)
num3 = -1;
else if (i < 400)
num3 = 1;
zero.Y = -1f;
zero.X = (float) num3;
if (WorldGen.genRand.Next(3) != 0)
zero.X *= (float) (1.0 + (double) WorldGen.genRand.Next(0, 200) * 0.00999999977648258);
else if (WorldGen.genRand.Next(3) == 0)
zero.X *= (float) WorldGen.genRand.Next(50, 76) * 0.01f;
else if (WorldGen.genRand.Next(6) == 0)
zero.Y *= 2f;
if (WorldGen.dungeonX < Main.maxTilesX / 2 && (double) zero.X < 0.0 && (double) zero.X < 0.5)
zero.X = -0.5f;
if (WorldGen.dungeonX > Main.maxTilesX / 2 && (double) zero.X > 0.0 && (double) zero.X > 0.5)
zero.X = -0.5f;
while (num2 > 0)
{
--num2;
int num4 = (int) ((double) vector2.X - num1 - 4.0 - (double) WorldGen.genRand.Next(6));
int num5 = (int) ((double) vector2.X + num1 + 4.0 + (double) WorldGen.genRand.Next(6));
int num6 = (int) ((double) vector2.Y - num1 - 4.0);
int num7 = (int) ((double) vector2.Y + num1 + 4.0 + (double) WorldGen.genRand.Next(6));
if (num4 < 0)
num4 = 0;
if (num5 > Main.maxTilesX)
num5 = Main.maxTilesX;
if (num6 < 0)
num6 = 0;
if (num7 > Main.maxTilesY)
num7 = Main.maxTilesY;
int num8 = 1;
if ((double) vector2.X > (double) (Main.maxTilesX / 2))
num8 = -1;
int i1 = (int) ((double) vector2.X + WorldGen.dxStrength1 * 0.600000023841858 * (double) num8 + WorldGen.dxStrength2 * (double) num8);
int num9 = (int) (WorldGen.dyStrength2 * 0.5);
if ((double) vector2.Y < Main.worldSurface - 5.0 && Main.tile[i1, (int) ((double) vector2.Y - num1 - 6.0 + (double) num9)].wall == (byte) 0 && Main.tile[i1, (int) ((double) vector2.Y - num1 - 7.0 + (double) num9)].wall == (byte) 0 && Main.tile[i1, (int) ((double) vector2.Y - num1 - 8.0 + (double) num9)].wall == (byte) 0)
{
WorldGen.dSurface = true;
WorldGen.TileRunner(i1, (int) ((double) vector2.Y - num1 - 6.0 + (double) num9), (double) WorldGen.genRand.Next(25, 35), WorldGen.genRand.Next(10, 20), -1, speedY: -1f);
}
for (int index1 = num4; index1 < num5; ++index1)
{
for (int index2 = num6; index2 < num7; ++index2)
{
Main.tile[index1, index2].liquid = (byte) 0;
if (!Main.wallDungeon[(int) Main.tile[index1, index2].wall])
{
Main.tile[index1, index2].wall = (byte) 0;
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].type = tileType;
}
}
}
for (int index3 = num4 + 1; index3 < num5 - 1; ++index3)
{
for (int index4 = num6 + 1; index4 < num7 - 1; ++index4)
Main.tile[index3, index4].wall = (byte) wallType;
}
int num10 = 0;
if (WorldGen.genRand.Next((int) num1) == 0)
num10 = WorldGen.genRand.Next(1, 3);
int num11 = (int) ((double) vector2.X - num1 * 0.5 - (double) num10);
int num12 = (int) ((double) vector2.X + num1 * 0.5 + (double) num10);
int num13 = (int) ((double) vector2.Y - num1 * 0.5 - (double) num10);
int num14 = (int) ((double) vector2.Y + num1 * 0.5 + (double) num10);
if (num11 < 0)
num11 = 0;
if (num12 > Main.maxTilesX)
num12 = Main.maxTilesX;
if (num13 < 0)
num13 = 0;
if (num14 > Main.maxTilesY)
num14 = Main.maxTilesY;
for (int i2 = num11; i2 < num12; ++i2)
{
for (int j1 = num13; j1 < num14; ++j1)
{
Main.tile[i2, j1].active(false);
WorldGen.PlaceWall(i2, j1, wallType, true);
}
}
if (WorldGen.dSurface)
num2 = 0;
vector2 += zero;
if ((double) vector2.Y < Main.worldSurface)
zero.Y *= 0.98f;
}
WorldGen.dungeonX = (int) vector2.X;
WorldGen.dungeonY = (int) vector2.Y;
}
public static void DungeonHalls(int i, int j, ushort tileType, int wallType, bool forceX = false)
{
Vector2 zero1 = Vector2.Zero;
double num1 = (double) WorldGen.genRand.Next(4, 6);
double num2 = num1;
Vector2 zero2 = Vector2.Zero;
Vector2 zero3 = Vector2.Zero;
Vector2 vector2;
vector2.X = (float) i;
vector2.Y = (float) j;
int num3 = WorldGen.genRand.Next(35, 80);
if (forceX)
{
num3 += 20;
WorldGen.lastDungeonHall = Vector2.Zero;
}
else if (WorldGen.genRand.Next(5) == 0)
{
num1 *= 2.0;
num3 /= 2;
}
bool flag1 = false;
bool flag2 = false;
bool flag3 = true;
while (!flag1)
{
bool flag4 = false;
int num4;
if (flag3 && !forceX)
{
bool flag5 = true;
bool flag6 = true;
bool flag7 = true;
bool flag8 = true;
int num5 = num3;
bool flag9 = false;
for (int index1 = j; index1 > j - num5; --index1)
{
int index2 = i;
if ((int) Main.tile[index2, index1].wall == wallType)
{
if (flag9)
{
flag5 = false;
break;
}
}
else
flag9 = true;
}
bool flag10 = false;
for (int index3 = j; index3 < j + num5; ++index3)
{
int index4 = i;
if ((int) Main.tile[index4, index3].wall == wallType)
{
if (flag10)
{
flag6 = false;
break;
}
}
else
flag10 = true;
}
bool flag11 = false;
for (int index5 = i; index5 > i - num5; --index5)
{
int index6 = j;
if ((int) Main.tile[index5, index6].wall == wallType)
{
if (flag11)
{
flag7 = false;
break;
}
}
else
flag11 = true;
}
bool flag12 = false;
for (int index7 = i; index7 < i + num5; ++index7)
{
int index8 = j;
if ((int) Main.tile[index7, index8].wall == wallType)
{
if (flag12)
{
flag8 = false;
break;
}
}
else
flag12 = true;
}
if (!flag7 && !flag8 && !flag5 && !flag6)
{
num4 = WorldGen.genRand.Next(2) != 0 ? 1 : -1;
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
}
else
{
WorldGen.genRand.Next(4);
int num6;
do
{
num6 = WorldGen.genRand.Next(4);
}
while (!(num6 == 0 & flag5) && !(num6 == 1 & flag6) && !(num6 == 2 & flag7) && !(num6 == 3 & flag8));
switch (num6)
{
case 0:
num4 = -1;
break;
case 1:
num4 = 1;
break;
default:
flag4 = true;
num4 = num6 != 2 ? 1 : -1;
break;
}
}
}
else
{
num4 = WorldGen.genRand.Next(2) != 0 ? 1 : -1;
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
}
flag3 = false;
if (forceX)
flag4 = true;
if (flag4)
{
zero2.Y = 0.0f;
zero2.X = (float) num4;
zero3.Y = 0.0f;
zero3.X = (float) -num4;
zero1.Y = 0.0f;
zero1.X = (float) num4;
if (WorldGen.genRand.Next(3) == 0)
zero1.Y = WorldGen.genRand.Next(2) != 0 ? 0.2f : -0.2f;
}
else
{
++num1;
zero1.Y = (float) num4;
zero1.X = 0.0f;
zero2.X = 0.0f;
zero2.Y = (float) num4;
zero3.X = 0.0f;
zero3.Y = (float) -num4;
if (WorldGen.genRand.Next(3) != 0)
{
flag2 = true;
zero1.X = WorldGen.genRand.Next(2) != 0 ? (float) -WorldGen.genRand.Next(10, 20) * 0.1f : (float) WorldGen.genRand.Next(10, 20) * 0.1f;
}
else if (WorldGen.genRand.Next(2) == 0)
zero1.X = WorldGen.genRand.Next(2) != 0 ? (float) -WorldGen.genRand.Next(20, 40) * 0.01f : (float) WorldGen.genRand.Next(20, 40) * 0.01f;
else
num3 /= 2;
}
if (WorldGen.lastDungeonHall != zero3)
flag1 = true;
}
int num7 = 0;
if (!forceX)
{
if ((double) vector2.X > (double) (WorldGen.lastMaxTilesX - 200))
{
int num8 = -1;
zero2.Y = 0.0f;
zero2.X = (float) num8;
zero1.Y = 0.0f;
zero1.X = (float) num8;
if (WorldGen.genRand.Next(3) == 0)
zero1.Y = WorldGen.genRand.Next(2) != 0 ? 0.2f : -0.2f;
}
else if ((double) vector2.X < 200.0)
{
int num9 = 1;
zero2.Y = 0.0f;
zero2.X = (float) num9;
zero1.Y = 0.0f;
zero1.X = (float) num9;
if (WorldGen.genRand.Next(3) == 0)
zero1.Y = WorldGen.genRand.Next(2) != 0 ? 0.2f : -0.2f;
}
else if ((double) vector2.Y > (double) (WorldGen.lastMaxTilesY - 300))
{
int num10 = -1;
++num1;
zero1.Y = (float) num10;
zero1.X = 0.0f;
zero2.X = 0.0f;
zero2.Y = (float) num10;
if (WorldGen.genRand.Next(2) == 0)
zero1.X = WorldGen.genRand.Next(2) != 0 ? (float) -WorldGen.genRand.Next(20, 50) * 0.01f : (float) WorldGen.genRand.Next(20, 50) * 0.01f;
}
else if ((double) vector2.Y < Main.rockLayer + 100.0)
{
int num11 = 1;
++num1;
zero1.Y = (float) num11;
zero1.X = 0.0f;
zero2.X = 0.0f;
zero2.Y = (float) num11;
if (WorldGen.genRand.Next(3) != 0)
{
flag2 = true;
zero1.X = WorldGen.genRand.Next(2) != 0 ? (float) -WorldGen.genRand.Next(10, 20) * 0.1f : (float) WorldGen.genRand.Next(10, 20) * 0.1f;
}
else if (WorldGen.genRand.Next(2) == 0)
zero1.X = WorldGen.genRand.Next(2) != 0 ? (float) WorldGen.genRand.Next(20, 50) * 0.01f : (float) WorldGen.genRand.Next(20, 50) * 0.01f;
}
else if ((double) vector2.X < (double) (Main.maxTilesX / 2) && (double) vector2.X > (double) Main.maxTilesX * 0.25)
{
int num12 = -1;
zero2.Y = 0.0f;
zero2.X = (float) num12;
zero1.Y = 0.0f;
zero1.X = (float) num12;
if (WorldGen.genRand.Next(3) == 0)
zero1.Y = WorldGen.genRand.Next(2) != 0 ? 0.2f : -0.2f;
}
else if ((double) vector2.X > (double) (Main.maxTilesX / 2) && (double) vector2.X < (double) Main.maxTilesX * 0.75)
{
int num13 = 1;
zero2.Y = 0.0f;
zero2.X = (float) num13;
zero1.Y = 0.0f;
zero1.X = (float) num13;
if (WorldGen.genRand.Next(3) == 0)
zero1.Y = WorldGen.genRand.Next(2) != 0 ? 0.2f : -0.2f;
}
}
if ((double) zero2.Y == 0.0)
{
WorldGen.DDoorX[WorldGen.numDDoors] = (int) vector2.X;
WorldGen.DDoorY[WorldGen.numDDoors] = (int) vector2.Y;
WorldGen.DDoorPos[WorldGen.numDDoors] = 0;
++WorldGen.numDDoors;
}
else
{
WorldGen.DPlatX[WorldGen.numDPlats] = (int) vector2.X;
WorldGen.DPlatY[WorldGen.numDPlats] = (int) vector2.Y;
++WorldGen.numDPlats;
}
WorldGen.lastDungeonHall = zero2;
if ((double) Math.Abs(zero1.X) > (double) Math.Abs(zero1.Y) && WorldGen.genRand.Next(3) != 0)
num1 = (double) (int) (num2 * ((double) WorldGen.genRand.Next(110, 150) * 0.01));
while (num3 > 0)
{
++num7;
if ((double) zero2.X > 0.0 && (double) vector2.X > (double) (Main.maxTilesX - 100))
num3 = 0;
else if ((double) zero2.X < 0.0 && (double) vector2.X < 100.0)
num3 = 0;
else if ((double) zero2.Y > 0.0 && (double) vector2.Y > (double) (Main.maxTilesY - 100))
num3 = 0;
else if ((double) zero2.Y < 0.0 && (double) vector2.Y < Main.rockLayer + 50.0)
num3 = 0;
--num3;
int num14 = (int) ((double) vector2.X - num1 - 4.0 - (double) WorldGen.genRand.Next(6));
int num15 = (int) ((double) vector2.X + num1 + 4.0 + (double) WorldGen.genRand.Next(6));
int num16 = (int) ((double) vector2.Y - num1 - 4.0 - (double) WorldGen.genRand.Next(6));
int num17 = (int) ((double) vector2.Y + num1 + 4.0 + (double) WorldGen.genRand.Next(6));
if (num14 < 0)
num14 = 0;
if (num15 > Main.maxTilesX)
num15 = Main.maxTilesX;
if (num16 < 0)
num16 = 0;
if (num17 > Main.maxTilesY)
num17 = Main.maxTilesY;
for (int index9 = num14; index9 < num15; ++index9)
{
for (int index10 = num16; index10 < num17; ++index10)
{
if (index9 < WorldGen.dMinX)
WorldGen.dMinX = index9;
if (index9 > WorldGen.dMaxX)
WorldGen.dMaxX = index9;
if (index10 > WorldGen.dMaxY)
WorldGen.dMaxY = index10;
Main.tile[index9, index10].liquid = (byte) 0;
if (!Main.wallDungeon[(int) Main.tile[index9, index10].wall])
{
Main.tile[index9, index10].active(true);
Main.tile[index9, index10].type = tileType;
}
}
}
for (int index11 = num14 + 1; index11 < num15 - 1; ++index11)
{
for (int index12 = num16 + 1; index12 < num17 - 1; ++index12)
Main.tile[index11, index12].wall = (byte) wallType;
}
int num18 = 0;
if ((double) zero1.Y == 0.0 && WorldGen.genRand.Next((int) num1 + 1) == 0)
num18 = WorldGen.genRand.Next(1, 3);
else if ((double) zero1.X == 0.0 && WorldGen.genRand.Next((int) num1 - 1) == 0)
num18 = WorldGen.genRand.Next(1, 3);
else if (WorldGen.genRand.Next((int) num1 * 3) == 0)
num18 = WorldGen.genRand.Next(1, 3);
int num19 = (int) ((double) vector2.X - num1 * 0.5 - (double) num18);
int num20 = (int) ((double) vector2.X + num1 * 0.5 + (double) num18);
int num21 = (int) ((double) vector2.Y - num1 * 0.5 - (double) num18);
int num22 = (int) ((double) vector2.Y + num1 * 0.5 + (double) num18);
if (num19 < 0)
num19 = 0;
if (num20 > Main.maxTilesX)
num20 = Main.maxTilesX;
if (num21 < 0)
num21 = 0;
if (num22 > Main.maxTilesY)
num22 = Main.maxTilesY;
for (int index13 = num19; index13 < num20; ++index13)
{
for (int index14 = num21; index14 < num22; ++index14)
{
Main.tile[index13, index14].active(false);
Main.tile[index13, index14].wall = (byte) wallType;
}
}
vector2 += zero1;
if (flag2 && num7 > WorldGen.genRand.Next(10, 20))
{
num7 = 0;
zero1.X *= -1f;
}
}
WorldGen.dungeonX = (int) vector2.X;
WorldGen.dungeonY = (int) vector2.Y;
if ((double) zero2.Y == 0.0)
{
WorldGen.DDoorX[WorldGen.numDDoors] = (int) vector2.X;
WorldGen.DDoorY[WorldGen.numDDoors] = (int) vector2.Y;
WorldGen.DDoorPos[WorldGen.numDDoors] = 0;
++WorldGen.numDDoors;
}
else
{
WorldGen.DPlatX[WorldGen.numDPlats] = (int) vector2.X;
WorldGen.DPlatY[WorldGen.numDPlats] = (int) vector2.Y;
++WorldGen.numDPlats;
}
}
public static void DungeonRoom(int i, int j, ushort tileType, int wallType)
{
double num1 = (double) WorldGen.genRand.Next(15, 30);
Vector2 vector2_1;
vector2_1.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_1.Y = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
Vector2 vector2_2;
vector2_2.X = (float) i;
vector2_2.Y = (float) j - (float) num1 / 2f;
int num2 = WorldGen.genRand.Next(10, 20);
double num3 = (double) vector2_2.X;
double num4 = (double) vector2_2.X;
double num5 = (double) vector2_2.Y;
double num6 = (double) vector2_2.Y;
while (num2 > 0)
{
--num2;
int num7 = (int) ((double) vector2_2.X - num1 * 0.800000011920929 - 5.0);
int num8 = (int) ((double) vector2_2.X + num1 * 0.800000011920929 + 5.0);
int num9 = (int) ((double) vector2_2.Y - num1 * 0.800000011920929 - 5.0);
int num10 = (int) ((double) vector2_2.Y + num1 * 0.800000011920929 + 5.0);
if (num7 < 0)
num7 = 0;
if (num8 > Main.maxTilesX)
num8 = Main.maxTilesX;
if (num9 < 0)
num9 = 0;
if (num10 > Main.maxTilesY)
num10 = Main.maxTilesY;
for (int index1 = num7; index1 < num8; ++index1)
{
for (int index2 = num9; index2 < num10; ++index2)
{
if (index1 < WorldGen.dMinX)
WorldGen.dMinX = index1;
if (index1 > WorldGen.dMaxX)
WorldGen.dMaxX = index1;
if (index2 > WorldGen.dMaxY)
WorldGen.dMaxY = index2;
Main.tile[index1, index2].liquid = (byte) 0;
if (!Main.wallDungeon[(int) Main.tile[index1, index2].wall])
{
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].type = tileType;
}
}
}
for (int index3 = num7 + 1; index3 < num8 - 1; ++index3)
{
for (int index4 = num9 + 1; index4 < num10 - 1; ++index4)
Main.tile[index3, index4].wall = (byte) wallType;
}
int num11 = (int) ((double) vector2_2.X - num1 * 0.5);
int num12 = (int) ((double) vector2_2.X + num1 * 0.5);
int num13 = (int) ((double) vector2_2.Y - num1 * 0.5);
int num14 = (int) ((double) vector2_2.Y + num1 * 0.5);
if (num11 < 0)
num11 = 0;
if (num12 > Main.maxTilesX)
num12 = Main.maxTilesX;
if (num13 < 0)
num13 = 0;
if (num14 > Main.maxTilesY)
num14 = Main.maxTilesY;
if ((double) num11 < num3)
num3 = (double) num11;
if ((double) num12 > num4)
num4 = (double) num12;
if ((double) num13 < num5)
num5 = (double) num13;
if ((double) num14 > num6)
num6 = (double) num14;
for (int index5 = num11; index5 < num12; ++index5)
{
for (int index6 = num13; index6 < num14; ++index6)
{
Main.tile[index5, index6].active(false);
Main.tile[index5, index6].wall = (byte) wallType;
}
}
vector2_2 += vector2_1;
vector2_1.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_1.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_1.X > 1.0)
vector2_1.X = 1f;
if ((double) vector2_1.X < -1.0)
vector2_1.X = -1f;
if ((double) vector2_1.Y > 1.0)
vector2_1.Y = 1f;
if ((double) vector2_1.Y < -1.0)
vector2_1.Y = -1f;
}
WorldGen.dRoomX[WorldGen.numDRooms] = (int) vector2_2.X;
WorldGen.dRoomY[WorldGen.numDRooms] = (int) vector2_2.Y;
WorldGen.dRoomSize[WorldGen.numDRooms] = (int) num1;
WorldGen.dRoomL[WorldGen.numDRooms] = (int) num3;
WorldGen.dRoomR[WorldGen.numDRooms] = (int) num4;
WorldGen.dRoomT[WorldGen.numDRooms] = (int) num5;
WorldGen.dRoomB[WorldGen.numDRooms] = (int) num6;
WorldGen.dRoomTreasure[WorldGen.numDRooms] = false;
++WorldGen.numDRooms;
}
public static void DungeonEnt(int i, int j, ushort tileType, int wallType)
{
int num1 = 60;
for (int index1 = i - num1; index1 < i + num1; ++index1)
{
for (int index2 = j - num1; index2 < j + num1; ++index2)
{
Main.tile[index1, index2].liquid = (byte) 0;
Main.tile[index1, index2].lava(false);
}
}
double dxStrength1 = WorldGen.dxStrength1;
double dyStrength1 = WorldGen.dyStrength1;
Vector2 vector2;
vector2.X = (float) i;
vector2.Y = (float) j - (float) dyStrength1 / 2f;
WorldGen.dMinY = (int) vector2.Y;
int num2 = 1;
if (i > Main.maxTilesX / 2)
num2 = -1;
int num3 = (int) ((double) vector2.X - dxStrength1 * 0.600000023841858 - (double) WorldGen.genRand.Next(2, 5));
int num4 = (int) ((double) vector2.X + dxStrength1 * 0.600000023841858 + (double) WorldGen.genRand.Next(2, 5));
int num5 = (int) ((double) vector2.Y - dyStrength1 * 0.600000023841858 - (double) WorldGen.genRand.Next(2, 5));
int num6 = (int) ((double) vector2.Y + dyStrength1 * 0.600000023841858 + (double) WorldGen.genRand.Next(8, 16));
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesX)
num4 = Main.maxTilesX;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY;
for (int index3 = num3; index3 < num4; ++index3)
{
for (int index4 = num5; index4 < num6; ++index4)
{
Main.tile[index3, index4].liquid = (byte) 0;
if ((int) Main.tile[index3, index4].wall != wallType)
{
Main.tile[index3, index4].wall = (byte) 0;
if (index3 > num3 + 1 && index3 < num4 - 2 && index4 > num5 + 1 && index4 < num6 - 2)
Main.tile[index3, index4].wall = (byte) wallType;
Main.tile[index3, index4].active(true);
Main.tile[index3, index4].type = tileType;
}
}
}
int num7 = num3;
int num8 = num3 + 5 + WorldGen.genRand.Next(4);
int num9 = num5 - 3 - WorldGen.genRand.Next(3);
int num10 = num5;
for (int index5 = num7; index5 < num8; ++index5)
{
for (int index6 = num9; index6 < num10; ++index6)
{
if ((int) Main.tile[index5, index6].wall != wallType)
{
Main.tile[index5, index6].active(true);
Main.tile[index5, index6].type = tileType;
}
}
}
int num11 = num4 - 5 - WorldGen.genRand.Next(4);
int num12 = num4;
int num13 = num5 - 3 - WorldGen.genRand.Next(3);
int num14 = num5;
for (int index7 = num11; index7 < num12; ++index7)
{
for (int index8 = num13; index8 < num14; ++index8)
{
if ((int) Main.tile[index7, index8].wall != wallType)
{
Main.tile[index7, index8].active(true);
Main.tile[index7, index8].type = tileType;
}
}
}
int num15 = 1 + WorldGen.genRand.Next(2);
int num16 = 2 + WorldGen.genRand.Next(4);
int num17 = 0;
for (int index9 = num3; index9 < num4; ++index9)
{
for (int index10 = num5 - num15; index10 < num5; ++index10)
{
if ((int) Main.tile[index9, index10].wall != wallType)
{
Main.tile[index9, index10].active(true);
Main.tile[index9, index10].type = tileType;
}
}
++num17;
if (num17 >= num16)
{
index9 += num16;
num17 = 0;
}
}
for (int index11 = num3; index11 < num4; ++index11)
{
for (int index12 = num6; (double) index12 < Main.worldSurface; ++index12)
{
if (!Main.wallDungeon[(int) Main.tile[index11, index12].wall])
{
Main.tile[index11, index12].active(true);
Main.tile[index11, index12].type = tileType;
}
Main.tile[index11, index12].wall = (byte) wallType;
}
}
int num18 = (int) ((double) vector2.X - dxStrength1 * 0.600000023841858);
int num19 = (int) ((double) vector2.X + dxStrength1 * 0.600000023841858);
int num20 = (int) ((double) vector2.Y - dyStrength1 * 0.600000023841858);
int num21 = (int) ((double) vector2.Y + dyStrength1 * 0.600000023841858);
if (num18 < 0)
num18 = 0;
if (num19 > Main.maxTilesX)
num19 = Main.maxTilesX;
if (num20 < 0)
num20 = 0;
if (num21 > Main.maxTilesY)
num21 = Main.maxTilesY;
for (int index13 = num18; index13 < num19; ++index13)
{
for (int index14 = num20; index14 < num21; ++index14)
Main.tile[index13, index14].wall = (byte) wallType;
}
int num22 = (int) ((double) vector2.X - dxStrength1 * 0.6 - 1.0);
int num23 = (int) ((double) vector2.X + dxStrength1 * 0.6 + 1.0);
int num24 = (int) ((double) vector2.Y - dyStrength1 * 0.6 - 1.0);
int num25 = (int) ((double) vector2.Y + dyStrength1 * 0.6 + 1.0);
if (num22 < 0)
num22 = 0;
if (num23 > Main.maxTilesX)
num23 = Main.maxTilesX;
if (num24 < 0)
num24 = 0;
if (num25 > Main.maxTilesY)
num25 = Main.maxTilesY;
for (int index15 = num22; index15 < num23; ++index15)
{
for (int index16 = num24; index16 < num25; ++index16)
Main.tile[index15, index16].wall = (byte) wallType;
}
int num26 = (int) ((double) vector2.X - dxStrength1 * 0.5);
int num27 = (int) ((double) vector2.X + dxStrength1 * 0.5);
int num28 = (int) ((double) vector2.Y - dyStrength1 * 0.5);
int num29 = (int) ((double) vector2.Y + dyStrength1 * 0.5);
if (num26 < 0)
num26 = 0;
if (num27 > Main.maxTilesX)
num27 = Main.maxTilesX;
if (num28 < 0)
num28 = 0;
if (num29 > Main.maxTilesY)
num29 = Main.maxTilesY;
for (int index17 = num26; index17 < num27; ++index17)
{
for (int index18 = num28; index18 < num29; ++index18)
{
Main.tile[index17, index18].active(false);
Main.tile[index17, index18].wall = (byte) wallType;
}
}
int x = (int) vector2.X;
int index19 = num29;
for (int index20 = 0; index20 < 20; ++index20)
{
int index21 = (int) vector2.X - index20;
if (!Main.tile[index21, index19].active() && Main.wallDungeon[(int) Main.tile[index21, index19].wall])
{
WorldGen.DPlatX[WorldGen.numDPlats] = index21;
WorldGen.DPlatY[WorldGen.numDPlats] = index19;
++WorldGen.numDPlats;
break;
}
int index22 = (int) vector2.X + index20;
if (!Main.tile[index22, index19].active() && Main.wallDungeon[(int) Main.tile[index22, index19].wall])
{
WorldGen.DPlatX[WorldGen.numDPlats] = index22;
WorldGen.DPlatY[WorldGen.numDPlats] = index19;
++WorldGen.numDPlats;
break;
}
}
vector2.X += (float) (dxStrength1 * 0.600000023841858) * (float) num2;
vector2.Y += (float) dyStrength1 * 0.5f;
double dxStrength2 = WorldGen.dxStrength2;
double dyStrength2 = WorldGen.dyStrength2;
vector2.X += (float) (dxStrength2 * 0.550000011920929) * (float) num2;
vector2.Y -= (float) dyStrength2 * 0.5f;
int num30 = (int) ((double) vector2.X - dxStrength2 * 0.600000023841858 - (double) WorldGen.genRand.Next(1, 3));
int num31 = (int) ((double) vector2.X + dxStrength2 * 0.600000023841858 + (double) WorldGen.genRand.Next(1, 3));
int num32 = (int) ((double) vector2.Y - dyStrength2 * 0.600000023841858 - (double) WorldGen.genRand.Next(1, 3));
int num33 = (int) ((double) vector2.Y + dyStrength2 * 0.600000023841858 + (double) WorldGen.genRand.Next(6, 16));
if (num30 < 0)
num30 = 0;
if (num31 > Main.maxTilesX)
num31 = Main.maxTilesX;
if (num32 < 0)
num32 = 0;
if (num33 > Main.maxTilesY)
num33 = Main.maxTilesY;
for (int index23 = num30; index23 < num31; ++index23)
{
for (int index24 = num32; index24 < num33; ++index24)
{
if ((int) Main.tile[index23, index24].wall != wallType)
{
bool flag = true;
if (num2 < 0)
{
if ((double) index23 < (double) vector2.X - dxStrength2 * 0.5)
flag = false;
}
else if ((double) index23 > (double) vector2.X + dxStrength2 * 0.5 - 1.0)
flag = false;
if (flag)
{
Main.tile[index23, index24].wall = (byte) 0;
Main.tile[index23, index24].active(true);
Main.tile[index23, index24].type = tileType;
}
}
}
}
for (int index25 = num30; index25 < num31; ++index25)
{
for (int index26 = num33; (double) index26 < Main.worldSurface; ++index26)
{
if (!Main.wallDungeon[(int) Main.tile[index25, index26].wall])
{
Main.tile[index25, index26].active(true);
Main.tile[index25, index26].type = tileType;
}
Main.tile[index25, index26].wall = (byte) wallType;
}
}
int num34 = (int) ((double) vector2.X - dxStrength2 * 0.5);
int num35 = (int) ((double) vector2.X + dxStrength2 * 0.5);
int num36 = num34;
if (num2 < 0)
++num36;
int num37 = num36 + 5 + WorldGen.genRand.Next(4);
int num38 = num32 - 3 - WorldGen.genRand.Next(3);
int num39 = num32;
for (int index27 = num36; index27 < num37; ++index27)
{
for (int index28 = num38; index28 < num39; ++index28)
{
if ((int) Main.tile[index27, index28].wall != wallType)
{
Main.tile[index27, index28].active(true);
Main.tile[index27, index28].type = tileType;
}
}
}
int num40 = num35 - 5 - WorldGen.genRand.Next(4);
int num41 = num35;
int num42 = num32 - 3 - WorldGen.genRand.Next(3);
int num43 = num32;
for (int index29 = num40; index29 < num41; ++index29)
{
for (int index30 = num42; index30 < num43; ++index30)
{
if ((int) Main.tile[index29, index30].wall != wallType)
{
Main.tile[index29, index30].active(true);
Main.tile[index29, index30].type = tileType;
}
}
}
int num44 = 1 + WorldGen.genRand.Next(2);
int num45 = 2 + WorldGen.genRand.Next(4);
int num46 = 0;
if (num2 < 0)
++num35;
for (int index31 = num34 + 1; index31 < num35 - 1; ++index31)
{
for (int index32 = num32 - num44; index32 < num32; ++index32)
{
if ((int) Main.tile[index31, index32].wall != wallType)
{
Main.tile[index31, index32].active(true);
Main.tile[index31, index32].type = tileType;
}
}
++num46;
if (num46 >= num45)
{
index31 += num45;
num46 = 0;
}
}
int num47 = (int) ((double) vector2.X - dxStrength2 * 0.6);
int num48 = (int) ((double) vector2.X + dxStrength2 * 0.6);
int num49 = (int) ((double) vector2.Y - dyStrength2 * 0.6);
int num50 = (int) ((double) vector2.Y + dyStrength2 * 0.6);
if (num47 < 0)
num47 = 0;
if (num48 > Main.maxTilesX)
num48 = Main.maxTilesX;
if (num49 < 0)
num49 = 0;
if (num50 > Main.maxTilesY)
num50 = Main.maxTilesY;
for (int index33 = num47; index33 < num48; ++index33)
{
for (int index34 = num49; index34 < num50; ++index34)
Main.tile[index33, index34].wall = (byte) 0;
}
int num51 = (int) ((double) vector2.X - dxStrength2 * 0.5);
int num52 = (int) ((double) vector2.X + dxStrength2 * 0.5);
int num53 = (int) ((double) vector2.Y - dyStrength2 * 0.5);
int index35 = (int) ((double) vector2.Y + dyStrength2 * 0.5);
if (num51 < 0)
num51 = 0;
if (num52 > Main.maxTilesX)
num52 = Main.maxTilesX;
if (num53 < 0)
num53 = 0;
if (index35 > Main.maxTilesY)
index35 = Main.maxTilesY;
for (int index36 = num51; index36 < num52; ++index36)
{
for (int index37 = num53; index37 < index35; ++index37)
{
Main.tile[index36, index37].active(false);
Main.tile[index36, index37].wall = (byte) 0;
}
}
for (int index38 = num51; index38 < num52; ++index38)
{
if (!Main.tile[index38, index35].active())
{
Main.tile[index38, index35].active(true);
Main.tile[index38, index35].type = (ushort) 19;
if (wallType == 7)
Main.tile[index38, index35].frameY = (short) 108;
if (wallType == 8)
Main.tile[index38, index35].frameY = (short) 144;
if (wallType == 9)
Main.tile[index38, index35].frameY = (short) 126;
}
}
Main.dungeonX = (int) vector2.X;
Main.dungeonY = index35;
int index39 = NPC.NewNPC(Main.dungeonX * 16 + 8, Main.dungeonY * 16, 37);
Main.npc[index39].homeless = false;
Main.npc[index39].homeTileX = Main.dungeonX;
Main.npc[index39].homeTileY = Main.dungeonY;
if (num2 == 1)
{
int num54 = 0;
for (int index40 = num52; index40 < num52 + 50; ++index40)
{
++num54;
for (int index41 = index35 + num54; index41 < index35 + 50; ++index41)
{
if (!Main.wallDungeon[(int) Main.tile[index40, index41].wall])
{
Main.tile[index40, index41].active(true);
Main.tile[index40, index41].type = tileType;
}
}
}
}
else
{
int num55 = 0;
for (int index42 = num51; index42 > num51 - 50; --index42)
{
++num55;
for (int index43 = index35 + num55; index43 < index35 + 50; ++index43)
{
if (!Main.wallDungeon[(int) Main.tile[index42, index43].wall])
{
Main.tile[index42, index43].active(true);
Main.tile[index42, index43].type = tileType;
}
}
}
}
int num56 = 1 + WorldGen.genRand.Next(2);
int num57 = 2 + WorldGen.genRand.Next(4);
int num58 = 0;
int num59 = (int) ((double) vector2.X - dxStrength2 * 0.5);
int num60 = (int) ((double) vector2.X + dxStrength2 * 0.5);
int num61 = num59 + 2;
int num62 = num60 - 2;
for (int i1 = num61; i1 < num62; ++i1)
{
for (int j1 = num53; j1 < index35; ++j1)
WorldGen.PlaceWall(i1, j1, wallType, true);
++num58;
if (num58 >= num57)
{
i1 += num57 * 2;
num58 = 0;
}
}
vector2.X -= (float) (dxStrength2 * 0.600000023841858) * (float) num2;
vector2.Y += (float) dyStrength2 * 0.5f;
double num63 = 15.0;
double num64 = 3.0;
vector2.Y -= (float) num64 * 0.5f;
int num65 = (int) ((double) vector2.X - num63 * 0.5);
int num66 = (int) ((double) vector2.X + num63 * 0.5);
int num67 = (int) ((double) vector2.Y - num64 * 0.5);
int num68 = (int) ((double) vector2.Y + num64 * 0.5);
if (num65 < 0)
num65 = 0;
if (num66 > Main.maxTilesX)
num66 = Main.maxTilesX;
if (num67 < 0)
num67 = 0;
if (num68 > Main.maxTilesY)
num68 = Main.maxTilesY;
for (int index44 = num65; index44 < num66; ++index44)
{
for (int index45 = num67; index45 < num68; ++index45)
Main.tile[index44, index45].active(false);
}
if (num2 < 0)
--vector2.X;
WorldGen.PlaceTile((int) vector2.X, (int) vector2.Y + 1, 10, true, style: 13);
}
public static bool AddBuriedChest(
Point point,
int contain = 0,
bool notNearOtherChests = false,
int Style = -1)
{
return WorldGen.AddBuriedChest(point.X, point.Y, contain, notNearOtherChests, Style);
}
public static bool AddBuriedChest(
int i,
int j,
int contain = 0,
bool notNearOtherChests = false,
int Style = -1)
{
bool flag1 = false;
bool flag2 = false;
for (int j1 = j; j1 < Main.maxTilesY; ++j1)
{
if (WorldGen.SolidTile(i, j1))
{
bool flag3 = false;
int num1 = i;
int num2 = j1;
int style = 0;
if ((double) num2 >= Main.worldSurface + 25.0 || contain > 0)
{
style = 1;
if (Style == 10 || contain == 211 || contain == 212 || contain == 213 || contain == 753)
{
style = 10;
flag2 = true;
}
}
if (Style >= 0)
style = Style;
if (style == 11 || contain == 0 && (double) num2 >= Main.worldSurface + 25.0 && num2 <= Main.maxTilesY - 205 && (Main.tile[i, j1].type == (ushort) 147 || Main.tile[i, j1].type == (ushort) 161 || Main.tile[i, j1].type == (ushort) 162))
{
flag1 = true;
style = 11;
switch (WorldGen.genRand.Next(6))
{
case 0:
contain = 670;
break;
case 1:
contain = 724;
break;
case 2:
contain = 950;
break;
case 3:
contain = 1319;
break;
case 4:
contain = 987;
break;
default:
contain = 1579;
break;
}
if (WorldGen.genRand.Next(20) == 0)
contain = 997;
if (WorldGen.genRand.Next(50) == 0)
contain = 669;
}
if (num2 > Main.maxTilesY - 205 && contain == 0)
{
if (WorldGen.hellChest == WorldGen.hellChestItem[0])
{
contain = 274;
style = 4;
flag3 = true;
}
else if (WorldGen.hellChest == WorldGen.hellChestItem[1])
{
contain = 220;
style = 4;
flag3 = true;
}
else if (WorldGen.hellChest == WorldGen.hellChestItem[2])
{
contain = 112;
style = 4;
flag3 = true;
}
else if (WorldGen.hellChest == WorldGen.hellChestItem[3])
{
contain = 218;
style = 4;
flag3 = true;
}
else
{
contain = 3019;
style = 4;
flag3 = true;
}
}
int index1 = WorldGen.PlaceChest(num1 - 1, num2 - 1, notNearOtherChests: notNearOtherChests, style: style);
if (index1 < 0)
return false;
if (flag3)
{
++WorldGen.hellChest;
if (WorldGen.hellChest > 4)
WorldGen.hellChest = 0;
}
int index2 = 0;
while (index2 == 0)
{
if (style == 0 && (double) num2 < Main.worldSurface + 25.0 || contain == 848)
{
if (contain > 0)
{
Main.chest[index1].item[index2].SetDefaults(contain);
Main.chest[index1].item[index2].Prefix(-1);
switch (contain)
{
case 832:
++index2;
Main.chest[index1].item[index2].SetDefaults(933);
break;
case 848:
++index2;
Main.chest[index1].item[index2].SetDefaults(866);
break;
}
++index2;
}
else
{
int num3 = WorldGen.genRand.Next(11);
if (num3 == 0)
{
Main.chest[index1].item[index2].SetDefaults(280);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num3 == 1)
{
Main.chest[index1].item[index2].SetDefaults(281);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num3 == 2)
{
Main.chest[index1].item[index2].SetDefaults(284);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num3 == 3)
{
Main.chest[index1].item[index2].SetDefaults(282);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(40, 75);
}
if (num3 == 4)
{
Main.chest[index1].item[index2].SetDefaults(279);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(70, 150);
}
if (num3 == 5)
{
Main.chest[index1].item[index2].SetDefaults(285);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num3 == 6)
{
Main.chest[index1].item[index2].SetDefaults(953);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num3 == 7)
{
Main.chest[index1].item[index2].SetDefaults(946);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num3 == 8)
{
Main.chest[index1].item[index2].SetDefaults(3068);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num3 == 9)
{
Main.chest[index1].item[index2].SetDefaults(3069);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num3 == 10)
{
Main.chest[index1].item[index2].SetDefaults(3084);
Main.chest[index1].item[index2].Prefix(-1);
}
++index2;
}
if (WorldGen.genRand.Next(6) == 0)
{
Main.chest[index1].item[index2].SetDefaults(3093);
Main.chest[index1].item[index2].stack = 1;
if (WorldGen.genRand.Next(5) == 0)
Main.chest[index1].item[index2].stack += WorldGen.genRand.Next(2);
if (WorldGen.genRand.Next(10) == 0)
Main.chest[index1].item[index2].stack += WorldGen.genRand.Next(3);
++index2;
}
if (WorldGen.genRand.Next(3) == 0)
{
Main.chest[index1].item[index2].SetDefaults(168);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(3, 6);
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num4 = WorldGen.genRand.Next(2);
int num5 = WorldGen.genRand.Next(8) + 3;
if (num4 == 0)
Main.chest[index1].item[index2].SetDefaults(WorldGen.copperBar);
if (num4 == 1)
Main.chest[index1].item[index2].SetDefaults(WorldGen.ironBar);
Main.chest[index1].item[index2].stack = num5;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num6 = WorldGen.genRand.Next(50, 101);
Main.chest[index1].item[index2].SetDefaults(965);
Main.chest[index1].item[index2].stack = num6;
++index2;
}
if (WorldGen.genRand.Next(3) != 0)
{
int num7 = WorldGen.genRand.Next(2);
int num8 = WorldGen.genRand.Next(26) + 25;
if (num7 == 0)
Main.chest[index1].item[index2].SetDefaults(40);
if (num7 == 1)
Main.chest[index1].item[index2].SetDefaults(42);
Main.chest[index1].item[index2].stack = num8;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num9 = WorldGen.genRand.Next(1);
int num10 = WorldGen.genRand.Next(3) + 3;
if (num9 == 0)
Main.chest[index1].item[index2].SetDefaults(28);
Main.chest[index1].item[index2].stack = num10;
++index2;
}
if (WorldGen.genRand.Next(3) != 0)
{
Main.chest[index1].item[index2].SetDefaults(2350);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(2, 5);
++index2;
}
if (WorldGen.genRand.Next(3) > 0)
{
int num11 = WorldGen.genRand.Next(6);
int num12 = WorldGen.genRand.Next(1, 3);
if (num11 == 0)
Main.chest[index1].item[index2].SetDefaults(292);
if (num11 == 1)
Main.chest[index1].item[index2].SetDefaults(298);
if (num11 == 2)
Main.chest[index1].item[index2].SetDefaults(299);
if (num11 == 3)
Main.chest[index1].item[index2].SetDefaults(290);
if (num11 == 4)
Main.chest[index1].item[index2].SetDefaults(2322);
if (num11 == 5)
Main.chest[index1].item[index2].SetDefaults(2325);
Main.chest[index1].item[index2].stack = num12;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num13 = WorldGen.genRand.Next(2);
int num14 = WorldGen.genRand.Next(11) + 10;
if (num13 == 0)
Main.chest[index1].item[index2].SetDefaults(8);
if (num13 == 1)
Main.chest[index1].item[index2].SetDefaults(31);
Main.chest[index1].item[index2].stack = num14;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
Main.chest[index1].item[index2].SetDefaults(72);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(10, 30);
++index2;
}
}
else if ((double) num2 < Main.rockLayer)
{
if (contain > 0)
{
if (contain == 832)
{
Main.chest[index1].item[index2].SetDefaults(933);
++index2;
}
Main.chest[index1].item[index2].SetDefaults(contain);
Main.chest[index1].item[index2].Prefix(-1);
++index2;
}
else
{
int num15 = WorldGen.genRand.Next(7);
if (WorldGen.genRand.Next(20) == 0)
{
Main.chest[index1].item[index2].SetDefaults(997);
Main.chest[index1].item[index2].Prefix(-1);
}
else
{
if (num15 == 0)
{
Main.chest[index1].item[index2].SetDefaults(49);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num15 == 1)
{
Main.chest[index1].item[index2].SetDefaults(50);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num15 == 2)
{
Main.chest[index1].item[index2].SetDefaults(53);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num15 == 3)
{
Main.chest[index1].item[index2].SetDefaults(54);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num15 == 4)
{
Main.chest[index1].item[index2].SetDefaults(55);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num15 == 5)
{
Main.chest[index1].item[index2].SetDefaults(975);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num15 == 6)
{
Main.chest[index1].item[index2].SetDefaults(930);
Main.chest[index1].item[index2].Prefix(-1);
++index2;
Main.chest[index1].item[index2].SetDefaults(931);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(26) + 25;
}
}
++index2;
}
if (WorldGen.genRand.Next(3) == 0)
{
Main.chest[index1].item[index2].SetDefaults(166);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(10, 20);
++index2;
}
if (WorldGen.genRand.Next(5) == 0)
{
Main.chest[index1].item[index2].SetDefaults(52);
++index2;
}
if (WorldGen.genRand.Next(3) == 0)
{
int num16 = WorldGen.genRand.Next(50, 101);
Main.chest[index1].item[index2].SetDefaults(965);
Main.chest[index1].item[index2].stack = num16;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num17 = WorldGen.genRand.Next(2);
int num18 = WorldGen.genRand.Next(10) + 5;
if (num17 == 0)
Main.chest[index1].item[index2].SetDefaults(WorldGen.ironBar);
if (num17 == 1)
Main.chest[index1].item[index2].SetDefaults(WorldGen.silverBar);
Main.chest[index1].item[index2].stack = num18;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num19 = WorldGen.genRand.Next(2);
int num20 = WorldGen.genRand.Next(25) + 25;
if (num19 == 0)
Main.chest[index1].item[index2].SetDefaults(40);
if (num19 == 1)
Main.chest[index1].item[index2].SetDefaults(42);
Main.chest[index1].item[index2].stack = num20;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num21 = WorldGen.genRand.Next(1);
int num22 = WorldGen.genRand.Next(3) + 3;
if (num21 == 0)
Main.chest[index1].item[index2].SetDefaults(28);
Main.chest[index1].item[index2].stack = num22;
++index2;
}
if (WorldGen.genRand.Next(3) > 0)
{
int num23 = WorldGen.genRand.Next(9);
int num24 = WorldGen.genRand.Next(1, 3);
if (num23 == 0)
Main.chest[index1].item[index2].SetDefaults(289);
if (num23 == 1)
Main.chest[index1].item[index2].SetDefaults(298);
if (num23 == 2)
Main.chest[index1].item[index2].SetDefaults(299);
if (num23 == 3)
Main.chest[index1].item[index2].SetDefaults(290);
if (num23 == 4)
Main.chest[index1].item[index2].SetDefaults(303);
if (num23 == 5)
Main.chest[index1].item[index2].SetDefaults(291);
if (num23 == 6)
Main.chest[index1].item[index2].SetDefaults(304);
if (num23 == 7)
Main.chest[index1].item[index2].SetDefaults(2322);
if (num23 == 8)
Main.chest[index1].item[index2].SetDefaults(2329);
Main.chest[index1].item[index2].stack = num24;
++index2;
}
if (WorldGen.genRand.Next(3) != 0)
{
int num25 = WorldGen.genRand.Next(1, 3);
Main.chest[index1].item[index2].SetDefaults(2350);
Main.chest[index1].item[index2].stack = num25;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num26 = WorldGen.genRand.Next(11) + 10;
if (style == 11)
Main.chest[index1].item[index2].SetDefaults(974);
else
Main.chest[index1].item[index2].SetDefaults(8);
Main.chest[index1].item[index2].stack = num26;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
Main.chest[index1].item[index2].SetDefaults(72);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(50, 90);
++index2;
}
}
else if (num2 < Main.maxTilesY - 250)
{
if (contain > 0)
{
Main.chest[index1].item[index2].SetDefaults(contain);
Main.chest[index1].item[index2].Prefix(-1);
++index2;
if (flag1 && WorldGen.genRand.Next(5) == 0)
{
Main.chest[index1].item[index2].SetDefaults(3199);
++index2;
}
if (flag2 && WorldGen.genRand.Next(6) == 0)
{
Item[] objArray1 = Main.chest[index1].item;
int index3 = index2;
int num27 = index3 + 1;
objArray1[index3].SetDefaults(3360);
Item[] objArray2 = Main.chest[index1].item;
int index4 = num27;
index2 = index4 + 1;
objArray2[index4].SetDefaults(3361);
}
}
else
{
int num28 = WorldGen.genRand.Next(7);
if (WorldGen.genRand.Next(40) == 0)
{
Main.chest[index1].item[index2].SetDefaults(906);
Main.chest[index1].item[index2].Prefix(-1);
}
else if (WorldGen.genRand.Next(15) == 0)
{
Main.chest[index1].item[index2].SetDefaults(997);
Main.chest[index1].item[index2].Prefix(-1);
}
else
{
if (num28 == 0)
{
Main.chest[index1].item[index2].SetDefaults(49);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num28 == 1)
{
Main.chest[index1].item[index2].SetDefaults(50);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num28 == 2)
{
Main.chest[index1].item[index2].SetDefaults(53);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num28 == 3)
{
Main.chest[index1].item[index2].SetDefaults(54);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num28 == 4)
{
Main.chest[index1].item[index2].SetDefaults(55);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num28 == 5)
{
Main.chest[index1].item[index2].SetDefaults(975);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num28 == 6)
{
Main.chest[index1].item[index2].SetDefaults(930);
Main.chest[index1].item[index2].Prefix(-1);
++index2;
Main.chest[index1].item[index2].SetDefaults(931);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(26) + 25;
}
}
++index2;
}
if (WorldGen.genRand.Next(5) == 0)
{
Main.chest[index1].item[index2].SetDefaults(43);
++index2;
}
if (WorldGen.genRand.Next(3) == 0)
{
Main.chest[index1].item[index2].SetDefaults(167);
++index2;
}
if (WorldGen.genRand.Next(4) == 0)
{
Main.chest[index1].item[index2].SetDefaults(51);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(26) + 25;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num29 = WorldGen.genRand.Next(2);
int num30 = WorldGen.genRand.Next(8) + 3;
if (num29 == 0)
Main.chest[index1].item[index2].SetDefaults(WorldGen.goldBar);
if (num29 == 1)
Main.chest[index1].item[index2].SetDefaults(WorldGen.silverBar);
Main.chest[index1].item[index2].stack = num30;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num31 = WorldGen.genRand.Next(2);
int num32 = WorldGen.genRand.Next(26) + 25;
if (num31 == 0)
Main.chest[index1].item[index2].SetDefaults(41);
if (num31 == 1)
Main.chest[index1].item[index2].SetDefaults(279);
Main.chest[index1].item[index2].stack = num32;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num33 = WorldGen.genRand.Next(1);
int num34 = WorldGen.genRand.Next(3) + 3;
if (num33 == 0)
Main.chest[index1].item[index2].SetDefaults(188);
Main.chest[index1].item[index2].stack = num34;
++index2;
}
if (WorldGen.genRand.Next(3) > 0)
{
int num35 = WorldGen.genRand.Next(6);
int num36 = WorldGen.genRand.Next(1, 3);
if (num35 == 0)
Main.chest[index1].item[index2].SetDefaults(296);
if (num35 == 1)
Main.chest[index1].item[index2].SetDefaults(295);
if (num35 == 2)
Main.chest[index1].item[index2].SetDefaults(299);
if (num35 == 3)
Main.chest[index1].item[index2].SetDefaults(302);
if (num35 == 4)
Main.chest[index1].item[index2].SetDefaults(303);
if (num35 == 5)
Main.chest[index1].item[index2].SetDefaults(305);
Main.chest[index1].item[index2].stack = num36;
++index2;
}
if (WorldGen.genRand.Next(3) > 1)
{
int num37 = WorldGen.genRand.Next(7);
int num38 = WorldGen.genRand.Next(1, 3);
if (num37 == 0)
Main.chest[index1].item[index2].SetDefaults(301);
if (num37 == 1)
Main.chest[index1].item[index2].SetDefaults(302);
if (num37 == 2)
Main.chest[index1].item[index2].SetDefaults(297);
if (num37 == 3)
Main.chest[index1].item[index2].SetDefaults(304);
if (num37 == 4)
Main.chest[index1].item[index2].SetDefaults(2329);
if (num37 == 5)
Main.chest[index1].item[index2].SetDefaults(2351);
if (num37 == 6)
Main.chest[index1].item[index2].SetDefaults(2329);
Main.chest[index1].item[index2].stack = num38;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num39 = WorldGen.genRand.Next(1, 3);
Main.chest[index1].item[index2].SetDefaults(2350);
Main.chest[index1].item[index2].stack = num39;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num40 = WorldGen.genRand.Next(2);
int num41 = WorldGen.genRand.Next(15) + 15;
if (num40 == 0)
{
if (style == 11)
Main.chest[index1].item[index2].SetDefaults(974);
else
Main.chest[index1].item[index2].SetDefaults(8);
}
if (num40 == 1)
Main.chest[index1].item[index2].SetDefaults(282);
Main.chest[index1].item[index2].stack = num41;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
Main.chest[index1].item[index2].SetDefaults(73);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(1, 3);
++index2;
}
}
else
{
if (contain > 0)
{
Main.chest[index1].item[index2].SetDefaults(contain);
Main.chest[index1].item[index2].Prefix(-1);
++index2;
}
else
{
int num42 = WorldGen.genRand.Next(4);
if (num42 == 0)
{
Main.chest[index1].item[index2].SetDefaults(49);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num42 == 1)
{
Main.chest[index1].item[index2].SetDefaults(50);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num42 == 2)
{
Main.chest[index1].item[index2].SetDefaults(53);
Main.chest[index1].item[index2].Prefix(-1);
}
if (num42 == 3)
{
Main.chest[index1].item[index2].SetDefaults(54);
Main.chest[index1].item[index2].Prefix(-1);
}
++index2;
}
if (WorldGen.genRand.Next(3) == 0)
{
Main.chest[index1].item[index2].SetDefaults(167);
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num43 = WorldGen.genRand.Next(2);
int num44 = WorldGen.genRand.Next(15) + 15;
if (num43 == 0)
Main.chest[index1].item[index2].SetDefaults(117);
if (num43 == 1)
Main.chest[index1].item[index2].SetDefaults(WorldGen.goldBar);
Main.chest[index1].item[index2].stack = num44;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num45 = WorldGen.genRand.Next(2);
int num46 = WorldGen.genRand.Next(25) + 50;
if (num45 == 0)
Main.chest[index1].item[index2].SetDefaults(265);
if (num45 == 1)
Main.chest[index1].item[index2].SetDefaults(278);
Main.chest[index1].item[index2].stack = num46;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num47 = WorldGen.genRand.Next(2);
int num48 = WorldGen.genRand.Next(6) + 15;
if (num47 == 0)
Main.chest[index1].item[index2].SetDefaults(226);
if (num47 == 1)
Main.chest[index1].item[index2].SetDefaults(227);
Main.chest[index1].item[index2].stack = num48;
++index2;
}
if (WorldGen.genRand.Next(4) > 0)
{
int num49 = WorldGen.genRand.Next(8);
int num50 = WorldGen.genRand.Next(1, 3);
if (num49 == 0)
Main.chest[index1].item[index2].SetDefaults(296);
if (num49 == 1)
Main.chest[index1].item[index2].SetDefaults(295);
if (num49 == 2)
Main.chest[index1].item[index2].SetDefaults(293);
if (num49 == 3)
Main.chest[index1].item[index2].SetDefaults(288);
if (num49 == 4)
Main.chest[index1].item[index2].SetDefaults(294);
if (num49 == 5)
Main.chest[index1].item[index2].SetDefaults(297);
if (num49 == 6)
Main.chest[index1].item[index2].SetDefaults(304);
if (num49 == 7)
Main.chest[index1].item[index2].SetDefaults(2323);
Main.chest[index1].item[index2].stack = num50;
++index2;
}
if (WorldGen.genRand.Next(3) > 0)
{
int num51 = WorldGen.genRand.Next(8);
int num52 = WorldGen.genRand.Next(1, 3);
if (num51 == 0)
Main.chest[index1].item[index2].SetDefaults(305);
if (num51 == 1)
Main.chest[index1].item[index2].SetDefaults(301);
if (num51 == 2)
Main.chest[index1].item[index2].SetDefaults(302);
if (num51 == 3)
Main.chest[index1].item[index2].SetDefaults(288);
if (num51 == 4)
Main.chest[index1].item[index2].SetDefaults(300);
if (num51 == 5)
Main.chest[index1].item[index2].SetDefaults(2351);
if (num51 == 6)
Main.chest[index1].item[index2].SetDefaults(2348);
if (num51 == 7)
Main.chest[index1].item[index2].SetDefaults(2345);
Main.chest[index1].item[index2].stack = num52;
++index2;
}
if (WorldGen.genRand.Next(3) == 0)
{
int num53 = WorldGen.genRand.Next(1, 3);
Main.chest[index1].item[index2].SetDefaults(2350);
Main.chest[index1].item[index2].stack = num53;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
int num54 = WorldGen.genRand.Next(2);
int num55 = WorldGen.genRand.Next(15) + 15;
if (num54 == 0)
Main.chest[index1].item[index2].SetDefaults(8);
if (num54 == 1)
Main.chest[index1].item[index2].SetDefaults(282);
Main.chest[index1].item[index2].stack = num55;
++index2;
}
if (WorldGen.genRand.Next(2) == 0)
{
Main.chest[index1].item[index2].SetDefaults(73);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(2, 5);
++index2;
}
}
if (index2 > 0)
{
if (style == 10 && WorldGen.genRand.Next(4) == 0)
{
Main.chest[index1].item[index2].SetDefaults(2204);
++index2;
}
if (style == 11 && WorldGen.genRand.Next(7) == 0)
{
Main.chest[index1].item[index2].SetDefaults(2198);
++index2;
}
if (style == 12 && WorldGen.genRand.Next(2) == 0)
{
Main.chest[index1].item[index2].SetDefaults(2196);
++index2;
}
if (style == 13 && WorldGen.genRand.Next(3) == 0)
{
Main.chest[index1].item[index2].SetDefaults(2197);
++index2;
}
if (style == 16)
{
Main.chest[index1].item[index2].SetDefaults(2195);
++index2;
}
if (Main.wallDungeon[(int) Main.tile[i, j1].wall] && WorldGen.genRand.Next(8) == 0)
{
Main.chest[index1].item[index2].SetDefaults(2192);
++index2;
}
if (style == 16)
{
if (WorldGen.genRand.Next(5) == 0)
{
Main.chest[index1].item[index2].SetDefaults(2767);
++index2;
}
else
{
Main.chest[index1].item[index2].SetDefaults(2766);
Main.chest[index1].item[index2].stack = WorldGen.genRand.Next(3, 8);
++index2;
}
}
}
}
return true;
}
}
return false;
}
public static void UnlockDoor(int i, int j)
{
int index1 = i;
int index2 = j;
if (Main.tile[index1, index2] == null)
return;
while (Main.tile[index1, index2].frameY != (short) 594)
{
--index2;
if (Main.tile[index1, index2].frameY < (short) 594 || index2 <= 0)
return;
}
Main.PlaySound(22, index1 * 16, index2 * 16 + 16);
for (int index3 = index2; index3 <= index2 + 2; ++index3)
{
if (Main.tile[index1, index3] == null)
Main.tile[index1, index3] = new Tile();
Main.tile[index1, index3].frameY += (short) 54;
for (int index4 = 0; index4 < 4; ++index4)
Dust.NewDust(new Vector2((float) (index1 * 16), (float) (index3 * 16)), 16, 16, 11);
}
}
public static bool OpenDoor(int i, int j, int direction)
{
if (Main.tile[i, j - 1] == null)
Main.tile[i, j - 1] = new Tile();
if (Main.tile[i, j - 2] == null)
Main.tile[i, j - 2] = new Tile();
if (Main.tile[i, j + 1] == null)
Main.tile[i, j + 1] = new Tile();
if (Main.tile[i, j] == null)
Main.tile[i, j] = new Tile();
Tile tile = Main.tile[i, j];
if (tile.type != (ushort) 10 || tile.frameY >= (short) 594 && tile.frameY <= (short) 646 && tile.frameX < (short) 54)
return false;
short num1 = 0;
int frameY = (int) tile.frameY;
int num2 = 0;
while (frameY >= 54)
{
frameY -= 54;
++num2;
}
if (tile.frameX >= (short) 54)
{
int num3 = (int) tile.frameX / 54;
num2 += 36 * num3;
num1 += (short) (72 * num3);
}
int y = j - frameY / 18;
int index = i;
byte color1 = Main.tile[index, y].color();
if (Main.tile[index, y + 1] == null)
Main.tile[index, y + 1] = new Tile();
byte color2 = Main.tile[index, y + 1].color();
if (Main.tile[index, y + 2] == null)
Main.tile[index, y + 2] = new Tile();
byte color3 = Main.tile[index, y + 2].color();
int x;
int i1;
if (direction == -1)
{
x = i - 1;
num1 += (short) 36;
i1 = i - 1;
}
else
{
x = i;
i1 = i + 1;
}
for (int j1 = y; j1 < y + 3; ++j1)
{
if (Main.tile[i1, j1] == null)
Main.tile[i1, j1] = new Tile();
if (Main.tile[i1, j1].active())
{
if (!Main.tileCut[(int) Main.tile[i1, j1].type] && Main.tile[i1, j1].type != (ushort) 3 && Main.tile[i1, j1].type != (ushort) 24 && Main.tile[i1, j1].type != (ushort) 52 && Main.tile[i1, j1].type != (ushort) 61 && Main.tile[i1, j1].type != (ushort) 62 && Main.tile[i1, j1].type != (ushort) 69 && Main.tile[i1, j1].type != (ushort) 71 && Main.tile[i1, j1].type != (ushort) 73 && Main.tile[i1, j1].type != (ushort) 74 && Main.tile[i1, j1].type != (ushort) 110 && Main.tile[i1, j1].type != (ushort) 113 && Main.tile[i1, j1].type != (ushort) 115)
return false;
WorldGen.KillTile(i1, j1);
}
}
if (Main.netMode != 1 && Wiring.running)
{
Wiring.SkipWire(x, y);
Wiring.SkipWire(x, y + 1);
Wiring.SkipWire(x, y + 2);
Wiring.SkipWire(x + 1, y);
Wiring.SkipWire(x + 1, y + 1);
Wiring.SkipWire(x + 1, y + 2);
}
int num4 = num2 % 36 * 54;
Main.PlaySound(8, i * 16, j * 16);
Main.tile[x, y].active(true);
Main.tile[x, y].type = (ushort) 11;
Main.tile[x, y].frameY = (short) num4;
Main.tile[x, y].frameX = num1;
Main.tile[x, y].color(color1);
if (Main.tile[x + 1, y] == null)
Main.tile[x + 1, y] = new Tile();
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].type = (ushort) 11;
Main.tile[x + 1, y].frameY = (short) num4;
Main.tile[x + 1, y].frameX = (short) ((int) num1 + 18);
Main.tile[x + 1, y].color(color1);
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].type = (ushort) 11;
Main.tile[x, y + 1].frameY = (short) (num4 + 18);
Main.tile[x, y + 1].frameX = num1;
Main.tile[x, y + 1].color(color2);
if (Main.tile[x + 1, y + 1] == null)
Main.tile[x + 1, y + 1] = new Tile();
Main.tile[x + 1, y + 1].active(true);
Main.tile[x + 1, y + 1].type = (ushort) 11;
Main.tile[x + 1, y + 1].frameY = (short) (num4 + 18);
Main.tile[x + 1, y + 1].frameX = (short) ((int) num1 + 18);
Main.tile[x + 1, y + 1].color(color2);
if (Main.tile[x, y + 2] == null)
Main.tile[x, y + 2] = new Tile();
Main.tile[x, y + 2].active(true);
Main.tile[x, y + 2].type = (ushort) 11;
Main.tile[x, y + 2].frameY = (short) (num4 + 36);
Main.tile[x, y + 2].frameX = num1;
Main.tile[x, y + 2].color(color3);
if (Main.tile[x + 1, y + 2] == null)
Main.tile[x + 1, y + 2] = new Tile();
Main.tile[x + 1, y + 2].active(true);
Main.tile[x + 1, y + 2].type = (ushort) 11;
Main.tile[x + 1, y + 2].frameY = (short) (num4 + 36);
Main.tile[x + 1, y + 2].frameX = (short) ((int) num1 + 18);
Main.tile[x + 1, y + 2].color(color3);
for (int i2 = x - 1; i2 <= x + 2; ++i2)
{
for (int j2 = y - 1; j2 <= y + 2; ++j2)
WorldGen.TileFrame(i2, j2);
}
return true;
}
public static void Check1xX(int x, int j, short type)
{
if (WorldGen.destroyObject)
return;
int frameX = (int) Main.tile[x, j].frameX;
int num1 = 3;
if (type == (short) 92)
num1 = 6;
int frameY = (int) Main.tile[x, j].frameY;
int num2 = 0;
while (frameY >= 18 * num1)
{
frameY -= 18 * num1;
++num2;
}
int num3 = (int) Main.tile[x, j].frameX / 18;
int num4 = j - frameY / 18;
bool flag = false;
for (int index = 0; index < num1; ++index)
{
if (Main.tile[x, num4 + index] == null)
Main.tile[x, num4 + index] = new Tile();
if (!Main.tile[x, num4 + index].active())
flag = true;
else if ((int) Main.tile[x, num4 + index].type != (int) type)
flag = true;
else if ((int) Main.tile[x, num4 + index].frameY != index * 18 + num2 * num1 * 18)
flag = true;
else if ((int) Main.tile[x, num4 + index].frameX != frameX)
flag = true;
}
if (Main.tile[x, num4 + num1] == null)
Main.tile[x, num4 + num1] = new Tile();
if (!WorldGen.SolidTileAllowBottomSlope(x, num4 + num1))
flag = true;
if (!flag)
return;
WorldGen.destroyObject = true;
for (int index = 0; index < num1; ++index)
{
if ((int) Main.tile[x, num4 + index].type == (int) type)
WorldGen.KillTile(x, num4 + index);
}
if (type == (short) 92)
Item.NewItem(x * 16, j * 16, 32, 32, 341);
if (type == (short) 453)
{
int Type = num3 >= 2 ? (num3 >= 4 ? 3743 : 3745) : 3744;
Item.NewItem(x * 16, j * 16, 16, 32, Type);
}
if (type == (short) 93)
{
int Type = 0;
if (num2 == 0)
Type = 342;
else if (num2 >= 1 && num2 <= 10)
Type = 2082 + num2 - 1;
else if (num2 >= 11 && num2 <= 16)
{
Type = 2129 + num2 - 11;
}
else
{
switch (num2)
{
case 17:
Type = 2225;
break;
case 18:
Type = 2533;
break;
case 19:
Type = 2547;
break;
case 20:
Type = 2563;
break;
case 21:
Type = 2578;
break;
case 22:
Type = 2643;
break;
case 23:
Type = 2644;
break;
case 24:
Type = 2645;
break;
case 25:
Type = 2646;
break;
case 26:
Type = 2647;
break;
case 27:
Type = 2819;
break;
case 28:
Type = 3135;
break;
case 29:
Type = 3137;
break;
case 30:
Type = 3136;
break;
case 31:
Type = 3892;
break;
}
}
Item.NewItem(x * 16, j * 16, 32, 32, Type);
}
WorldGen.destroyObject = false;
}
public static void Check2xX(int i, int j, ushort type)
{
if (WorldGen.destroyObject)
return;
int index1 = i;
int frameX1 = (int) Main.tile[i, j].frameX;
while (frameX1 >= 36)
frameX1 -= 36;
if (frameX1 == 18)
--index1;
if (Main.tile[index1, j] == null)
Main.tile[index1, j] = new Tile();
int num1 = (int) Main.tile[index1, j].frameY / 18;
int num2 = 3;
if (type == (ushort) 104)
num2 = 5;
if (type == (ushort) 207)
num2 = 4;
int num3 = 0;
while (num1 >= num2)
{
num1 -= num2;
num3 += num2 * 18;
}
int y = j - num1;
if (type == (ushort) 410 && num3 != 0)
num3 += 2;
if (Main.tile[index1, y] == null)
Main.tile[index1, y] = new Tile();
int frameX2 = (int) Main.tile[index1, j].frameX;
int frameY = (int) Main.tile[index1, j].frameY;
bool flag = false;
for (int index2 = 0; index2 < num2; ++index2)
{
if (Main.tile[index1, y + index2] == null)
Main.tile[index1, y + index2] = new Tile();
if (!Main.tile[index1, y + index2].active())
flag = true;
else if ((int) Main.tile[index1, y + index2].type != (int) type)
flag = true;
else if ((int) Main.tile[index1, y + index2].frameY != index2 * 18 + num3)
flag = true;
else if ((int) Main.tile[index1, y + index2].frameX != frameX2)
flag = true;
if (Main.tile[index1 + 1, y + index2] == null)
Main.tile[index1 + 1, y + index2] = new Tile();
if (!Main.tile[index1 + 1, y + index2].active())
flag = true;
else if ((int) Main.tile[index1 + 1, y + index2].type != (int) type)
flag = true;
else if ((int) Main.tile[index1 + 1, y + index2].frameY != index2 * 18 + num3)
flag = true;
else if ((int) Main.tile[index1 + 1, y + index2].frameX != frameX2 + 18)
flag = true;
}
if (type == (ushort) 465)
{
for (int index3 = 0; index3 < 2; ++index3)
{
if (Main.tile[index1 + index3, y - 1] == null)
Main.tile[index1 + index3, y - 1] = new Tile();
if (!Main.tile[index1 + index3, y - 1].nactive() || !Main.tileSolid[(int) Main.tile[index1 + index3, y - 1].type] || Main.tileSolidTop[(int) Main.tile[index1 + index3, y - 1].type])
{
flag = true;
break;
}
}
}
else
{
if (!WorldGen.SolidTileAllowBottomSlope(index1, y + num2))
flag = true;
if (!WorldGen.SolidTileAllowBottomSlope(index1 + 1, y + num2))
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int index4 = 0; index4 < num2; ++index4)
{
if ((int) Main.tile[index1, y + index4].type == (int) type)
WorldGen.KillTile(index1, y + index4);
if ((int) Main.tile[index1 + 1, y + index4].type == (int) type)
WorldGen.KillTile(index1 + 1, y + index4);
}
if (type == (ushort) 104)
{
int num4 = frameX2 / 36;
int Type = num4 < 1 || num4 > 5 ? (num4 != 6 ? (num4 != 7 ? (num4 < 8 || num4 > 23 ? (num4 != 24 ? (num4 != 25 ? (num4 != 26 ? (num4 != 27 ? (num4 != 28 ? (num4 != 29 ? (num4 != 30 ? (num4 != 31 ? (num4 != 32 ? 359 : 3902) : 3901) : 3900) : 3899) : 3898) : 3127) : 3128) : 3126) : 2809) : 2591 + num4 - 8) : 2575) : 2560) : 2237 + num4 - 1;
Item.NewItem(index1 * 16, j * 16, 32, 32, Type);
}
if (type == (ushort) 105)
{
int num5 = frameX2 / 36 + frameY / 54 * 55;
int Type = num5 != 0 ? (num5 != 1 ? (num5 != 43 ? (num5 != 44 ? (num5 != 45 ? (num5 != 46 ? (num5 != 47 ? (num5 != 48 ? (num5 != 49 ? (num5 != 50 ? (num5 < 51 || num5 > 62 ? (num5 < 63 || num5 > 75 ? 438 + num5 - 2 : 3708 + num5 - 63) : 3651 + num5 - 51) : 2672) : 1462) : 1410) : 1409) : 1408) : 1154) : 1153) : 1152) : 52) : 360;
Item.NewItem(index1 * 16, j * 16, 32, 32, Type);
}
if (type == (ushort) 356)
Item.NewItem(index1 * 16, j * 16, 32, 32, 3064);
if (type == (ushort) 456)
Item.NewItem(index1 * 16, j * 16, 32, 32, 3748);
if (type == (ushort) 337)
{
int num6 = frameX2 / 36;
Item.NewItem(index1 * 16, j * 16, 32, 32, 2702 + num6);
}
if (type == (ushort) 207)
{
int Type = frameX2 / 36;
switch (Type)
{
case 0:
Type = 909;
break;
case 1:
Type = 910;
break;
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
Type = 938 + Type;
break;
}
Item.NewItem(index1 * 16, j * 16, 32, 32, Type);
}
if (type == (ushort) 410)
{
int num7 = frameX2 / 36;
Item.NewItem(index1 * 16, j * 16, 32, 32, num7 + 3536);
}
if (type == (ushort) 320)
Item.NewItem(index1 * 16, j * 16, 32, 32, 2496);
if (type == (ushort) 349)
Item.NewItem(index1 * 16, j * 16, 32, 32, 470);
if (type == (ushort) 465)
Item.NewItem(index1 * 16, j * 16, 32, 32, 3815);
if (type == (ushort) 378)
{
Item.NewItem(index1 * 16, j * 16, 32, 48, 3202);
TETrainingDummy.Kill(index1, y);
}
WorldGen.destroyObject = false;
}
public static void PlaceTight(int x, int y, ushort type = 165, bool spiders = false)
{
if (Main.tile[x, y - 1] == null)
Main.tile[x, y - 1] = new Tile();
if (Main.tile[x, y] == null)
Main.tile[x, y] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (WorldGen.SolidTile(x, y - 1) && !Main.tile[x, y].active() && !Main.tile[x, y + 1].active())
{
if (spiders)
{
int num = 108 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y + 1].type = type;
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].frameX = (short) num;
Main.tile[x, y + 1].frameY = (short) 18;
}
else
{
if (Main.tile[x, y - 1].type == (ushort) 147 || Main.tile[x, y - 1].type == (ushort) 161 || Main.tile[x, y - 1].type == (ushort) 163 || Main.tile[x, y - 1].type == (ushort) 164 || Main.tile[x, y - 1].type == (ushort) 200)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 72;
}
else
{
int num = WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y + 1].type = type;
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].frameX = (short) num;
Main.tile[x, y + 1].frameY = (short) 18;
}
}
if (Main.tile[x, y - 1].type == (ushort) 1 || Main.tileMoss[(int) Main.tile[x, y - 1].type] || Main.tile[x, y - 1].type == (ushort) 117 || Main.tile[x, y - 1].type == (ushort) 25 || Main.tile[x, y - 1].type == (ushort) 203)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = 54 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 72;
}
else
{
int num = 54 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y + 1].type = type;
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].frameX = (short) num;
Main.tile[x, y + 1].frameY = (short) 18;
}
}
if (Main.tile[x, y - 1].type == (ushort) 225)
{
int num = 162 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 72;
}
if (Main.tile[x, y - 1].type == (ushort) 396 || Main.tile[x, y - 1].type == (ushort) 397)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = 378 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 72;
}
else
{
int num = 378 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y + 1].type = type;
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].frameX = (short) num;
Main.tile[x, y + 1].frameY = (short) 18;
}
}
if (Main.tile[x, y - 1].type == (ushort) 368)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = 432 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 72;
}
else
{
int num = 432 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y + 1].type = type;
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].frameX = (short) num;
Main.tile[x, y + 1].frameY = (short) 18;
}
}
if (Main.tile[x, y - 1].type == (ushort) 367)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = 486 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 72;
}
else
{
int num = 486 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y + 1].type = type;
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].frameX = (short) num;
Main.tile[x, y + 1].frameY = (short) 18;
}
}
}
}
else
{
if (spiders)
return;
if (WorldGen.SolidTile(x, y + 1) && !Main.tile[x, y].active() && !Main.tile[x, y - 1].active())
{
if (Main.tile[x, y + 1].type == (ushort) 1 || Main.tileMoss[(int) Main.tile[x, y + 1].type] || Main.tile[x, y - 1].type == (ushort) 117 || Main.tile[x, y - 1].type == (ushort) 25 || Main.tile[x, y - 1].type == (ushort) 203)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = 54 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 90;
}
else
{
int num = 54 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameX = (short) num;
Main.tile[x, y - 1].frameY = (short) 36;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 54;
}
}
if (Main.tile[x, y + 1].type == (ushort) 225)
{
int num = 162 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 90;
}
if (Main.tile[x, y + 1].type == (ushort) 396 || Main.tile[x, y + 1].type == (ushort) 397)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = 378 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 90;
}
else
{
int num = 378 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameX = (short) num;
Main.tile[x, y - 1].frameY = (short) 36;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 54;
}
}
if (Main.tile[x, y + 1].type == (ushort) 368)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = 432 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 90;
}
else
{
int num = 432 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameX = (short) num;
Main.tile[x, y - 1].frameY = (short) 36;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 54;
}
}
if (Main.tile[x, y + 1].type == (ushort) 367)
{
if (WorldGen.genRand.Next(2) == 0)
{
int num = 486 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 90;
}
else
{
int num = 486 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameX = (short) num;
Main.tile[x, y - 1].frameY = (short) 36;
Main.tile[x, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameX = (short) num;
Main.tile[x, y].frameY = (short) 54;
}
}
}
}
if (Main.tile[x, y].type != (ushort) 165)
return;
WorldGen.CheckTight(x, y);
}
public static void TightBiome(int x, int j)
{
if (Main.netMode == 1 || Main.tile[x, j] == null)
return;
int tileY = j;
int num1 = 1;
int num2;
if (Main.tile[x, tileY].frameX >= (short) 0 && Main.tile[x, tileY].frameX <= (short) 36)
num2 = 7;
else if (Main.tile[x, tileY].frameX >= (short) 54 && Main.tile[x, tileY].frameX <= (short) 90)
num2 = 0;
else if (Main.tile[x, tileY].frameX >= (short) 216 && Main.tile[x, tileY].frameX <= (short) 252)
num2 = 1;
else if (Main.tile[x, tileY].frameX >= (short) 270 && Main.tile[x, tileY].frameX <= (short) 306)
num2 = 2;
else if (Main.tile[x, tileY].frameX >= (short) 324 && Main.tile[x, tileY].frameX <= (short) 360)
num2 = 3;
else if (Main.tile[x, tileY].frameX >= (short) 378 && Main.tile[x, tileY].frameX <= (short) 414)
num2 = 4;
else if (Main.tile[x, tileY].frameX >= (short) 432 && Main.tile[x, tileY].frameX <= (short) 468)
{
num2 = 5;
}
else
{
if (Main.tile[x, tileY].frameX < (short) 486 || Main.tile[x, tileY].frameX > (short) 522)
return;
num2 = 6;
}
int type;
if (Main.tile[x, tileY].frameY == (short) 72)
type = (int) Main.tile[x, tileY - 1].type;
else if (Main.tile[x, tileY].frameY == (short) 90)
type = (int) Main.tile[x, tileY + 1].type;
else if (Main.tile[x, tileY].frameY >= (short) 36)
{
if (Main.tile[x, tileY].frameY == (short) 54)
--tileY;
num1 = 2;
type = (int) Main.tile[x, tileY + 2].type;
}
else
{
if (Main.tile[x, tileY].frameY == (short) 18)
--tileY;
num1 = 2;
type = (int) Main.tile[x, tileY - 1].type;
}
int num3;
switch (type)
{
case 1:
num3 = 0;
break;
case 25:
case 163:
case 398:
case 400:
num3 = 2;
break;
case 117:
case 164:
case 402:
case 403:
num3 = 1;
break;
case 161:
num3 = 7;
break;
case 200:
case 203:
case 399:
case 401:
num3 = 3;
break;
case 367:
num3 = 6;
break;
case 368:
num3 = 5;
break;
case 396:
case 397:
num3 = 4;
break;
default:
return;
}
if (num2 == num3)
return;
int num4 = WorldGen.genRand.Next(3) * 18;
switch (num3)
{
case 0:
num4 += 54;
break;
case 1:
num4 += 216;
break;
case 2:
num4 += 270;
break;
case 3:
num4 += 324;
break;
case 4:
num4 += 378;
break;
case 5:
num4 += 432;
break;
case 6:
num4 += 486;
break;
case 7:
num4 = num4;
break;
}
for (int index = tileY; index < tileY + num1; ++index)
Main.tile[x, index].frameX = (short) num4;
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, x, tileY, 2);
}
public static void CheckTight(int x, int j)
{
if (Main.tile[x, j] == null)
return;
int j1 = j;
if (Main.tile[x, j1].frameY == (short) 72)
{
if (Main.tile[x, j1 - 1] == null)
Main.tile[x, j1 - 1] = new Tile();
if (Main.tile[x, j1] == null)
Main.tile[x, j1] = new Tile();
if (Main.tile[x, j1 + 1] == null)
Main.tile[x, j1 + 1] = new Tile();
bool flag = false;
if (!WorldGen.SolidTile(x, j1 - 1))
flag = true;
if (flag)
{
if ((int) Main.tile[x, j1].type != (int) Main.tile[x, j].type)
return;
WorldGen.KillTile(x, j1);
}
else
WorldGen.TightBiome(x, j1);
}
else if (Main.tile[x, j1].frameY == (short) 90)
{
if (Main.tile[x, j1 - 1] == null)
Main.tile[x, j1 - 1] = new Tile();
if (Main.tile[x, j1] == null)
Main.tile[x, j1] = new Tile();
if (Main.tile[x, j1 + 1] == null)
Main.tile[x, j1 + 1] = new Tile();
bool flag = false;
if (!WorldGen.SolidTile(x, j1 + 1))
flag = true;
if (flag)
{
if ((int) Main.tile[x, j1].type != (int) Main.tile[x, j].type)
return;
WorldGen.KillTile(x, j1);
}
else
WorldGen.TightBiome(x, j1);
}
else if (Main.tile[x, j1].frameY >= (short) 36)
{
if (Main.tile[x, j1].frameY == (short) 54)
--j1;
if (Main.tile[x, j1] == null)
Main.tile[x, j1] = new Tile();
if (Main.tile[x, j1 + 1] == null)
Main.tile[x, j1 + 1] = new Tile();
if (Main.tile[x, j1 + 2] == null)
Main.tile[x, j1 + 2] = new Tile();
bool flag = false;
if (!WorldGen.SolidTile(x, j1 + 2))
flag = true;
if ((int) Main.tile[x, j1 + 1].type != (int) Main.tile[x, j1].type)
flag = true;
if ((int) Main.tile[x, j1 + 1].frameX != (int) Main.tile[x, j1].frameX)
flag = true;
if (flag)
{
if ((int) Main.tile[x, j1].type == (int) Main.tile[x, j].type)
WorldGen.KillTile(x, j1);
if ((int) Main.tile[x, j1 + 1].type != (int) Main.tile[x, j].type)
return;
WorldGen.KillTile(x, j1 + 1);
}
else
WorldGen.TightBiome(x, j1);
}
else
{
if (Main.tile[x, j1].frameY == (short) 18)
--j1;
if (Main.tile[x, j1 - 1] == null)
Main.tile[x, j1 - 1] = new Tile();
if (Main.tile[x, j1] == null)
Main.tile[x, j1] = new Tile();
if (Main.tile[x, j1 + 1] == null)
Main.tile[x, j1 + 1] = new Tile();
bool flag = false;
if (!WorldGen.SolidTile(x, j1 - 1))
flag = true;
if ((int) Main.tile[x, j1 + 1].type != (int) Main.tile[x, j1].type)
flag = true;
if ((int) Main.tile[x, j1 + 1].frameX != (int) Main.tile[x, j1].frameX)
flag = true;
if (flag)
{
if ((int) Main.tile[x, j1].type == (int) Main.tile[x, j].type)
WorldGen.KillTile(x, j1);
if ((int) Main.tile[x, j1 + 1].type != (int) Main.tile[x, j].type)
return;
WorldGen.KillTile(x, j1 + 1);
}
else
WorldGen.TightBiome(x, j1);
}
}
public static void Place1xX(int x, int y, ushort type, int style = 0)
{
int num1 = style * 18;
int num2 = 3;
if (type == (ushort) 92)
num2 = 6;
bool flag = true;
for (int index = y - num2 + 1; index < y + 1; ++index)
{
if (Main.tile[x, index] == null)
Main.tile[x, index] = new Tile();
if (Main.tile[x, index].active())
flag = false;
if (type == (ushort) 93 && Main.tile[x, index].liquid > (byte) 0)
flag = false;
}
if (!flag || !WorldGen.SolidTile2(x, y + 1))
return;
for (int index = 0; index < num2; ++index)
{
Main.tile[x, y - num2 + 1 + index].active(true);
Main.tile[x, y - num2 + 1 + index].frameY = (short) (index * 18 + num2 * num1);
Main.tile[x, y - num2 + 1 + index].frameX = (short) 0;
Main.tile[x, y - num2 + 1 + index].type = type;
}
}
public static int checkXmasTreeDrop(int x, int y, int obj)
{
int index1 = x;
int index2 = y;
if (Main.tile[x, y].frameX < (short) 10)
{
index1 -= (int) Main.tile[x, y].frameX;
index2 -= (int) Main.tile[x, y].frameY;
}
int num1 = 0;
if (((int) Main.tile[index1, index2].frameY & 1) == 1)
++num1;
if (((int) Main.tile[index1, index2].frameY & 2) == 2)
num1 += 2;
if (((int) Main.tile[index1, index2].frameY & 4) == 4)
num1 += 4;
int num2 = 0;
if (((int) Main.tile[index1, index2].frameY & 8) == 8)
++num2;
if (((int) Main.tile[index1, index2].frameY & 16) == 16)
num2 += 2;
if (((int) Main.tile[index1, index2].frameY & 32) == 32)
num2 += 4;
int num3 = 0;
if (((int) Main.tile[index1, index2].frameY & 64) == 64)
++num3;
if (((int) Main.tile[index1, index2].frameY & 128) == 128)
num3 += 2;
if (((int) Main.tile[index1, index2].frameY & 256) == 256)
num3 += 4;
if (((int) Main.tile[index1, index2].frameY & 512) == 512)
num3 += 8;
int num4 = 0;
if (((int) Main.tile[index1, index2].frameY & 1024) == 1024)
++num4;
if (((int) Main.tile[index1, index2].frameY & 2048) == 2048)
num4 += 2;
if (((int) Main.tile[index1, index2].frameY & 4096) == 4096)
num4 += 4;
if (((int) Main.tile[index1, index2].frameY & 8192) == 8192)
num4 += 8;
if (obj == 0 && num1 > 0)
return num1;
if (obj == 1 && num2 > 0)
return num2;
if (obj == 2 && num3 > 0)
return num3;
return obj == 3 && num4 > 0 ? num4 : -1;
}
public static void dropXmasTree(int x, int y, int obj)
{
int index1 = x;
int index2 = y;
if (Main.tile[x, y].frameX < (short) 10)
{
index1 -= (int) Main.tile[x, y].frameX;
index2 -= (int) Main.tile[x, y].frameY;
}
int num1 = 0;
if (((int) Main.tile[index1, index2].frameY & 1) == 1)
++num1;
if (((int) Main.tile[index1, index2].frameY & 2) == 2)
num1 += 2;
if (((int) Main.tile[index1, index2].frameY & 4) == 4)
num1 += 4;
int num2 = 0;
if (((int) Main.tile[index1, index2].frameY & 8) == 8)
++num2;
if (((int) Main.tile[index1, index2].frameY & 16) == 16)
num2 += 2;
if (((int) Main.tile[index1, index2].frameY & 32) == 32)
num2 += 4;
int num3 = 0;
if (((int) Main.tile[index1, index2].frameY & 64) == 64)
++num3;
if (((int) Main.tile[index1, index2].frameY & 128) == 128)
num3 += 2;
if (((int) Main.tile[index1, index2].frameY & 256) == 256)
num3 += 4;
if (((int) Main.tile[index1, index2].frameY & 512) == 512)
num3 += 8;
int num4 = 0;
if (((int) Main.tile[index1, index2].frameY & 1024) == 1024)
++num4;
if (((int) Main.tile[index1, index2].frameY & 2048) == 2048)
num4 += 2;
if (((int) Main.tile[index1, index2].frameY & 4096) == 4096)
num4 += 4;
if (((int) Main.tile[index1, index2].frameY & 8192) == 8192)
num4 += 8;
if (obj == 0 && num1 > 0)
{
int number = Item.NewItem(x * 16, y * 16, 16, 16, 1874 + num1 - 1);
if (Main.netMode != 1)
return;
NetMessage.SendData(21, number: number, number2: 1f);
}
else if (obj == 1 && num2 > 0)
{
int number = Item.NewItem(x * 16, y * 16, 16, 16, 1878 + num2 - 1);
if (Main.netMode != 1)
return;
NetMessage.SendData(21, number: number, number2: 1f);
}
else if (obj == 2 && num3 > 0)
{
int number = Item.NewItem(x * 16, y * 16, 16, 16, 1884 + num3 - 1);
if (Main.netMode != 1)
return;
NetMessage.SendData(21, number: number, number2: 1f);
}
else
{
if (obj != 3 || num4 <= 0)
return;
int number = Item.NewItem(x * 16, y * 16, 16, 16, 1895 + num4 - 1);
if (Main.netMode != 1)
return;
NetMessage.SendData(21, number: number, number2: 1f);
}
}
public static void setXmasTree(int x, int y, int obj, int style)
{
int index1 = x;
int index2 = y;
if (Main.tile[x, y].frameX < (short) 10)
{
index1 -= (int) Main.tile[x, y].frameX;
index2 -= (int) Main.tile[x, y].frameY;
}
if (obj == 0)
{
if ((style & 1) == 1)
Main.tile[index1, index2].frameY |= (short) 1;
else
Main.tile[index1, index2].frameY &= (short) -2;
if ((style & 2) == 2)
Main.tile[index1, index2].frameY |= (short) 2;
else
Main.tile[index1, index2].frameY &= (short) -3;
if ((style & 4) == 4)
Main.tile[index1, index2].frameY |= (short) 4;
else
Main.tile[index1, index2].frameY &= (short) -5;
}
if (obj == 1)
{
if ((style & 1) == 1)
Main.tile[index1, index2].frameY |= (short) 8;
else
Main.tile[index1, index2].frameY &= (short) -9;
if ((style & 2) == 2)
Main.tile[index1, index2].frameY |= (short) 16;
else
Main.tile[index1, index2].frameY &= (short) -17;
if ((style & 4) == 4)
Main.tile[index1, index2].frameY |= (short) 32;
else
Main.tile[index1, index2].frameY &= (short) -33;
}
if (obj == 2)
{
if ((style & 1) == 1)
Main.tile[index1, index2].frameY |= (short) 64;
else
Main.tile[index1, index2].frameY &= (short) -65;
if ((style & 2) == 2)
Main.tile[index1, index2].frameY |= (short) 128;
else
Main.tile[index1, index2].frameY &= (short) -129;
if ((style & 4) == 4)
Main.tile[index1, index2].frameY |= (short) 256;
else
Main.tile[index1, index2].frameY &= (short) -257;
if ((style & 8) == 8)
Main.tile[index1, index2].frameY |= (short) 512;
else
Main.tile[index1, index2].frameY &= (short) -513;
}
if (obj != 3)
return;
if ((style & 1) == 1)
Main.tile[index1, index2].frameY |= (short) 1024;
else
Main.tile[index1, index2].frameY &= (short) -1025;
if ((style & 2) == 2)
Main.tile[index1, index2].frameY |= (short) 2048;
else
Main.tile[index1, index2].frameY &= (short) -2049;
if ((style & 4) == 4)
Main.tile[index1, index2].frameY |= (short) 4096;
else
Main.tile[index1, index2].frameY &= (short) -4097;
if ((style & 8) == 8)
Main.tile[index1, index2].frameY |= (short) 8192;
else
Main.tile[index1, index2].frameY &= (short) -8193;
}
public static int PlaceXmasTree_Direct(int x, int y, int type, int style, int dir)
{
for (short index1 = 0; index1 < (short) 4; ++index1)
{
for (short index2 = 0; index2 < (short) 8; ++index2)
{
Tile tile = Main.tile[x + (int) index1, y + (int) index2];
tile.active(true);
tile.type = (ushort) type;
if (index1 == (short) 0 && index2 == (short) 0)
{
tile.frameX = (short) 10;
tile.frameY = (short) 0;
}
else
{
tile.frameX = index1;
tile.frameY = index2;
}
}
}
return 0;
}
public static void PlaceXmasTree(int x, int y, ushort type = 171)
{
bool flag = true;
int num1 = x - 1;
int num2 = y - 7;
for (int i = num1; i < num1 + 4; ++i)
{
for (int index = num2; index < num2 + 8; ++index)
{
if (Main.tile[i, index].active())
flag = false;
}
if (i > num1 && i < num1 + 3 && !WorldGen.SolidTile(i, num2 + 8))
flag = false;
}
if (!flag)
return;
int num3 = 0;
for (int index1 = num1; index1 < num1 + 4; ++index1)
{
int num4 = 0;
for (int index2 = num2; index2 < num2 + 8; ++index2)
{
Main.tile[index1, index2].active(true);
if (num3 == 0 && num4 == 0)
{
Main.tile[index1, index2].frameX = (short) 10;
Main.tile[index1, index2].frameY = (short) 0;
}
else
{
Main.tile[index1, index2].frameX = (short) num3;
Main.tile[index1, index2].frameY = (short) num4;
}
Main.tile[index1, index2].type = type;
Main.tile[index1, index2].active(true);
++num4;
}
++num3;
}
}
public static void CheckXmasTree(int x, int y)
{
if (WorldGen.destroyObject)
return;
int num1 = x;
int num2 = y;
if (Main.tile[x, y].frameX < (short) 10)
{
num1 -= (int) Main.tile[x, y].frameX;
num2 -= (int) Main.tile[x, y].frameY;
}
bool flag = false;
int num3 = 0;
for (int i = num1; i < num1 + 4; ++i)
{
int num4 = 0;
for (int index = num2; index < num2 + 8; ++index)
{
if (Main.tile[i, index].active() && Main.tile[i, index].type == (ushort) 171)
{
if (num3 != 0 && num4 != 0 && (int) Main.tile[i, index].frameX != num3 && (int) Main.tile[i, index].frameY != num4)
flag = true;
}
else
flag = true;
++num4;
}
++num3;
if (i > num1 && i < num1 + 3 && !WorldGen.SolidTile2(i, num2 + 8))
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i = num1; i < num1 + 4; ++i)
{
for (int j = num2; j < num2 + 8; ++j)
{
if (Main.tile[i, j].type == (ushort) 171)
WorldGen.KillTile(i, j);
}
}
Item.NewItem(x * 16, y * 16, 32, 32, 1873);
WorldGen.destroyObject = false;
}
public static void Place2xX(int x, int y, ushort type, int style = 0)
{
int num1 = style * 36;
int num2 = 0;
int num3 = 3;
if (type == (ushort) 105 && style == 34)
{
type = (ushort) 349;
style = 0;
num1 = 0;
}
if (type == (ushort) 105)
{
int num4 = style / 55;
num1 -= 1980 * num4;
num2 += 54 * num4;
}
if (type == (ushort) 104)
num3 = 5;
if (type == (ushort) 207)
num3 = 4;
bool flag = true;
for (int index = y - num3 + 1; index < y + 1; ++index)
{
if (Main.tile[x, index] == null)
Main.tile[x, index] = new Tile();
if (Main.tile[x, index].active())
flag = false;
if (Main.tile[x + 1, index] == null)
Main.tile[x + 1, index] = new Tile();
if (Main.tile[x + 1, index].active())
flag = false;
}
if (!flag || !WorldGen.SolidTile2(x, y + 1) || !WorldGen.SolidTile2(x + 1, y + 1))
return;
for (int index = 0; index < num3; ++index)
{
Main.tile[x, y - num3 + 1 + index].active(true);
Main.tile[x, y - num3 + 1 + index].frameY = (short) (num2 + index * 18);
Main.tile[x, y - num3 + 1 + index].frameX = (short) num1;
Main.tile[x, y - num3 + 1 + index].type = type;
Main.tile[x + 1, y - num3 + 1 + index].active(true);
Main.tile[x + 1, y - num3 + 1 + index].frameY = (short) (num2 + index * 18);
Main.tile[x + 1, y - num3 + 1 + index].frameX = (short) (num1 + 18);
Main.tile[x + 1, y - num3 + 1 + index].type = type;
}
}
public static void Check1x2(int x, int j, ushort type)
{
if (WorldGen.destroyObject)
return;
int j1 = j;
bool flag = true;
if (Main.tile[x, j1] == null)
Main.tile[x, j1] = new Tile();
if (Main.tile[x, j1 + 1] == null)
Main.tile[x, j1 + 1] = new Tile();
int frameY = (int) Main.tile[x, j1].frameY;
int num1 = 0;
while (frameY >= 40)
{
frameY -= 40;
++num1;
}
if (frameY == 18)
--j1;
if (Main.tile[x, j1] == null)
Main.tile[x, j1] = new Tile();
if ((int) Main.tile[x, j1].frameY == 40 * num1 && (int) Main.tile[x, j1 + 1].frameY == 40 * num1 + 18 && (int) Main.tile[x, j1].type == (int) type && (int) Main.tile[x, j1 + 1].type == (int) type)
flag = false;
if (Main.tile[x, j1 + 2] == null)
Main.tile[x, j1 + 2] = new Tile();
if (!WorldGen.SolidTileAllowBottomSlope(x, j1 + 2) && !TileID.Sets.Platforms[(int) Main.tile[x, j1 + 2].type])
flag = true;
if (Main.tile[x, j1].type == (ushort) 20)
{
int num2 = (int) Main.tile[x, j1].frameX / 54;
int type1 = (int) Main.tile[x, j1 + 2].type;
int num3 = -1;
switch (type1)
{
case 2:
num3 = 0;
break;
case 23:
num3 = 3;
break;
case 53:
num3 = 6;
break;
case 60:
num3 = 2;
break;
case 109:
num3 = 5;
break;
case 112:
num3 = 9;
break;
case 116:
num3 = 7;
break;
case 147:
num3 = 1;
break;
case 199:
num3 = 4;
break;
case 234:
num3 = 8;
break;
default:
flag = true;
break;
}
if (!flag && num2 != num3)
{
int num4 = 54 * num3 + WorldGen.genRand.Next(3) * 18;
Main.tile[x, j1].frameX = (short) num4;
Main.tile[x, j1 + 1].frameX = (short) num4;
}
}
if (!flag)
return;
WorldGen.destroyObject = true;
if ((int) Main.tile[x, j1].type == (int) type)
WorldGen.KillTile(x, j1);
if ((int) Main.tile[x, j1 + 1].type == (int) type)
WorldGen.KillTile(x, j1 + 1);
if (type == (ushort) 216)
Item.NewItem(x * 16, j1 * 16, 32, 32, 970 + num1);
if (type == (ushort) 338)
Item.NewItem(x * 16, j1 * 16, 32, 32, 2738);
if (type == (ushort) 390)
Item.NewItem(x * 16, j1 * 16, 16, 32, 3253);
if (type == (ushort) 15)
{
int Type = num1 < 18 || num1 > 23 ? (num1 != 5 ? (num1 != 6 ? (num1 != 7 ? (num1 != 8 ? (num1 != 9 ? (num1 != 10 ? (num1 != 11 ? (num1 != 13 ? (num1 != 14 ? (num1 != 15 ? (num1 != 12 ? (num1 != 4 ? (num1 != 3 ? (num1 != 2 ? (num1 != 17 ? (num1 != 1 ? (num1 != 24 ? (num1 != 25 ? (num1 != 16 ? (num1 != 26 ? (num1 != 27 ? (num1 != 28 ? (num1 != 29 ? (num1 != 30 ? (num1 != 31 ? (num1 != 32 ? (num1 != 33 ? (num1 != 34 ? (num1 != 35 ? (num1 != 36 ? 34 : 3889) : 3175) : 3176) : 3174) : 2812) : 2572) : 2557) : 2524) : 2288) : 2228) : 1925) : 1459) : 1814) : 1792) : 358) : 1509) : 628) : 629) : 630) : 1143) : 1402) : 1399) : 1396) : 915) : 826) : 810) : 809) : 808) : 807) : 806) : 1703 + num1 - 18;
Item.NewItem(x * 16, j1 * 16, 32, 32, Type);
}
else if (type == (ushort) 134)
{
if (num1 == 1)
Item.NewItem(x * 16, j1 * 16, 32, 32, 1220);
else
Item.NewItem(x * 16, j1 * 16, 32, 32, 525);
}
WorldGen.destroyObject = false;
}
public static void CheckOnTable1x1(int x, int y, int type)
{
if (Main.tile[x, y + 1] == null || Main.tile[x, y + 1].active() && Main.tileTable[(int) Main.tile[x, y + 1].type] && !Main.tile[x, y + 1].topSlope() && !Main.tile[x, y + 1].halfBrick())
return;
if (type == 78)
{
if (WorldGen.SolidTile2(x, y + 1))
return;
WorldGen.KillTile(x, y);
}
else
WorldGen.KillTile(x, y);
}
public static void CheckSign(int x, int y, ushort type)
{
if (WorldGen.destroyObject)
return;
int num1 = x - 2;
int num2 = x + 3;
int num3 = y - 2;
int num4 = y + 3;
if (num1 < 0 || num2 > Main.maxTilesX || num3 < 0 || num4 > Main.maxTilesY)
return;
bool flag = false;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
}
}
int num5 = (int) Main.tile[x, y].frameX / 18;
int num6 = (int) Main.tile[x, y].frameY / 18;
int num7 = num5 % 2;
int x1 = x - num7;
int y1 = y - num6;
int num8 = (int) Main.tile[x1, y1].frameX / 18 / 2;
int num9 = (int) Main.tile[x, y].frameX / 18;
int num10 = 0;
while (num9 > 1)
{
num9 -= 2;
++num10;
}
int num11 = x1;
int num12 = x1 + 2;
int num13 = y1;
int num14 = y1 + 2;
int num15 = 0;
for (int index3 = num11; index3 < num12; ++index3)
{
int num16 = 0;
for (int index4 = num13; index4 < num14; ++index4)
{
if (!Main.tile[index3, index4].active() || (int) Main.tile[index3, index4].type != (int) type)
{
flag = true;
break;
}
if ((int) Main.tile[index3, index4].frameX / 18 != num15 + num8 * 2 || (int) Main.tile[index3, index4].frameY / 18 != num16)
{
flag = true;
break;
}
++num16;
}
++num15;
}
if (!flag)
{
if (type == (ushort) 85)
{
if (Main.tile[x1, y1 + 2].active() && (Main.tileSolid[(int) Main.tile[x1, y1 + 2].type] || Main.tileSolidTop[(int) Main.tile[x1, y1 + 2].type]) && Main.tile[x1 + 1, y1 + 2].active() && (Main.tileSolid[(int) Main.tile[x1 + 1, y1 + 2].type] || Main.tileSolidTop[(int) Main.tile[x1 + 1, y1 + 2].type]))
num8 = num10;
else
flag = true;
}
else if (Main.tile[x1, y1 + 2].active() && (Main.tileSolid[(int) Main.tile[x1, y1 + 2].type] || Main.tileSolidTop[(int) Main.tile[x1, y1 + 2].type] && !Main.tileNoAttach[(int) Main.tile[x1, y1 + 2].type]) && Main.tile[x1 + 1, y1 + 2].active() && (Main.tileSolid[(int) Main.tile[x1 + 1, y1 + 2].type] || Main.tileSolidTop[(int) Main.tile[x1 + 1, y1 + 2].type] && !Main.tileNoAttach[(int) Main.tile[x1 + 1, y1 + 2].type]))
num8 = 0;
else if (Main.tile[x1, y1 - 1].nactive() && Main.tileSolid[(int) Main.tile[x1, y1 - 1].type] && !Main.tileSolidTop[(int) Main.tile[x1, y1 - 1].type] && !Main.tileNoAttach[(int) Main.tile[x1, y1 - 1].type] && Main.tile[x1 + 1, y1 - 1].nactive() && Main.tileSolid[(int) Main.tile[x1 + 1, y1 - 1].type] && !Main.tileSolidTop[(int) Main.tile[x1 + 1, y1 - 1].type] && !Main.tileNoAttach[(int) Main.tile[x1 + 1, y1 - 1].type])
num8 = 1;
else if (Main.tile[x1 - 1, y1].nactive() && Main.tileSolid[(int) Main.tile[x1 - 1, y1].type] && !Main.tileSolidTop[(int) Main.tile[x1 - 1, y1].type] && !Main.tileNoAttach[(int) Main.tile[x1 - 1, y1].type] && Main.tile[x1 - 1, y1 + 1].nactive() && Main.tileSolid[(int) Main.tile[x1 - 1, y1 + 1].type] && !Main.tileSolidTop[(int) Main.tile[x1 - 1, y1 + 1].type] && !Main.tileNoAttach[(int) Main.tile[x1 - 1, y1 + 1].type])
num8 = 2;
else if (Main.tile[x1 + 2, y1].nactive() && Main.tileSolid[(int) Main.tile[x1 + 2, y1].type] && !Main.tileSolidTop[(int) Main.tile[x1 + 2, y1].type] && !Main.tileNoAttach[(int) Main.tile[x1 + 2, y1].type] && Main.tile[x1 + 2, y1 + 1].nactive() && Main.tileSolid[(int) Main.tile[x1 + 2, y1 + 1].type] && !Main.tileSolidTop[(int) Main.tile[x1 + 2, y1 + 1].type] && !Main.tileNoAttach[(int) Main.tile[x1 + 2, y1 + 1].type])
num8 = 3;
else if (Main.tile[x1, y1].wall > (byte) 0 && Main.tile[x1 + 1, y1].wall > (byte) 0 && Main.tile[x1, y1 + 1].wall > (byte) 0 && Main.tile[x1 + 1, y1 + 1].wall > (byte) 0)
num8 = 4;
else
flag = true;
}
if (flag)
{
if (type == (ushort) 395)
{
int key = TEItemFrame.Find(x1, y1);
if (key != -1 && ((TEItemFrame) TileEntity.ByID[key]).item.stack > 0)
{
((TEItemFrame) TileEntity.ByID[key]).DropItem();
if (Main.netMode == 2)
return;
Main.blockMouse = true;
return;
}
}
WorldGen.destroyObject = true;
for (int i = num11; i < num12; ++i)
{
for (int j = num13; j < num14; ++j)
{
if ((int) Main.tile[i, j].type == (int) type)
WorldGen.KillTile(i, j);
}
}
if (type != (ushort) 395)
Sign.KillSign(x1, y1);
if (type == (ushort) 85)
{
int Type = 321;
if (num10 >= 6 && num10 <= 10)
Type = 3229 + num10 - 6;
else if (num10 >= 1 && num10 <= 5)
Type = 1173 + num10 - 1;
Item.NewItem(x * 16, y * 16, 32, 32, Type);
}
else if (type == (ushort) 395)
{
Item.NewItem(x1 * 16, y1 * 16, 32, 32, 3270);
TEItemFrame.Kill(x1, y1);
}
else if (type == (ushort) 425)
Item.NewItem(x1 * 16, y1 * 16, 32, 32, 3617);
else
Item.NewItem(x * 16, y * 16, 32, 32, 171);
WorldGen.destroyObject = false;
}
else
{
int num17 = 36 * num8;
for (int index5 = 0; index5 < 2; ++index5)
{
for (int index6 = 0; index6 < 2; ++index6)
{
Main.tile[x1 + index5, y1 + index6].active(true);
Main.tile[x1 + index5, y1 + index6].type = type;
Main.tile[x1 + index5, y1 + index6].frameX = (short) (num17 + 18 * index5);
Main.tile[x1 + index5, y1 + index6].frameY = (short) (18 * index6);
}
}
}
}
public static bool PlaceSign(int x, int y, ushort type, int Style = 0)
{
int num1 = x - 2;
int num2 = x + 3;
int num3 = y - 2;
int num4 = y + 3;
if (num1 < 0 || num2 > Main.maxTilesX || num3 < 0 || num4 > Main.maxTilesY)
return false;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
}
}
int index3 = x;
int index4 = y;
int num5 = 0;
if (type == (ushort) 55 || type == (ushort) 425)
{
if (WorldGen.SolidTile2(x, y + 1) && WorldGen.SolidTile2(x + 1, y + 1))
{
--index4;
num5 = 0;
}
else if (Main.tile[x, y - 1].nactive() && Main.tileSolid[(int) Main.tile[x, y - 1].type] && !Main.tileSolidTop[(int) Main.tile[x, y - 1].type] && Main.tile[x + 1, y - 1].nactive() && Main.tileSolid[(int) Main.tile[x + 1, y - 1].type] && !Main.tileSolidTop[(int) Main.tile[x + 1, y - 1].type])
num5 = 1;
else if (Main.tile[x - 1, y].nactive() && Main.tileSolid[(int) Main.tile[x - 1, y].type] && !Main.tileSolidTop[(int) Main.tile[x - 1, y].type] && !Main.tileNoAttach[(int) Main.tile[x - 1, y].type] && Main.tile[x - 1, y + 1].nactive() && Main.tileSolid[(int) Main.tile[x - 1, y + 1].type] && !Main.tileSolidTop[(int) Main.tile[x - 1, y + 1].type] && !Main.tileNoAttach[(int) Main.tile[x - 1, y + 1].type])
num5 = 2;
else if (Main.tile[x + 1, y].nactive() && Main.tileSolid[(int) Main.tile[x + 1, y].type] && !Main.tileSolidTop[(int) Main.tile[x + 1, y].type] && !Main.tileNoAttach[(int) Main.tile[x + 1, y].type] && Main.tile[x + 1, y + 1].nactive() && Main.tileSolid[(int) Main.tile[x + 1, y + 1].type] && !Main.tileSolidTop[(int) Main.tile[x + 1, y + 1].type] && !Main.tileNoAttach[(int) Main.tile[x + 1, y + 1].type])
{
--index3;
num5 = 3;
}
else
{
if (Main.tile[index3, index4].wall <= (byte) 0 || Main.tile[index3 + 1, index4].wall <= (byte) 0 || Main.tile[index3, index4 + 1].wall <= (byte) 0 || Main.tile[index3 + 1, index4 + 1].wall <= (byte) 0)
return false;
num5 = 4;
}
}
if (Main.tile[index3, index4].active() || Main.tile[index3 + 1, index4].active() || Main.tile[index3, index4 + 1].active() || Main.tile[index3 + 1, index4 + 1].active())
return false;
int num6 = 36 * num5;
for (int index5 = 0; index5 < 2; ++index5)
{
for (int index6 = 0; index6 < 2; ++index6)
{
Main.tile[index3 + index5, index4 + index6].active(true);
Main.tile[index3 + index5, index4 + index6].type = type;
Main.tile[index3 + index5, index4 + index6].frameX = (short) (num6 + 18 * index5);
Main.tile[index3 + index5, index4 + index6].frameY = (short) (18 * index6);
}
}
return true;
}
public static bool Place2x2Horizontal(int x, int y, ushort type, int Style = 0)
{
int num1 = x - 2;
int num2 = x + 3;
int num3 = y - 2;
int num4 = y + 3;
if (num1 < 0 || num2 > Main.maxTilesX || num3 < 0 || num4 > Main.maxTilesY)
return false;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
}
}
int index3 = x;
int num5 = y;
if (!WorldGen.SolidTile2(x, y + 1) || !WorldGen.SolidTile2(x + 1, y + 1))
return false;
int index4 = num5 - 1;
int num6 = Style;
if (Main.tile[index3, index4].active() || Main.tile[index3 + 1, index4].active() || Main.tile[index3, index4 + 1].active() || Main.tile[index3 + 1, index4 + 1].active())
return false;
int num7 = 36 * num6;
for (int index5 = 0; index5 < 2; ++index5)
{
for (int index6 = 0; index6 < 2; ++index6)
{
Main.tile[index3 + index5, index4 + index6].active(true);
Main.tile[index3 + index5, index4 + index6].type = type;
Main.tile[index3 + index5, index4 + index6].frameX = (short) (num7 + 18 * index5);
Main.tile[index3 + index5, index4 + index6].frameY = (short) (18 * index6);
}
}
return true;
}
public static Color paintColor(int color)
{
Color white = Color.White;
int num = color;
if (num == 1 || num == 13)
{
white.R = byte.MaxValue;
white.G = (byte) 0;
white.B = (byte) 0;
}
if (num == 2 || num == 14)
{
white.R = byte.MaxValue;
white.G = (byte) 127;
white.B = (byte) 0;
}
if (num == 3 || num == 15)
{
white.R = byte.MaxValue;
white.G = byte.MaxValue;
white.B = (byte) 0;
}
if (num == 4 || num == 16)
{
white.R = (byte) 127;
white.G = byte.MaxValue;
white.B = (byte) 0;
}
if (num == 5 || num == 17)
{
white.R = (byte) 0;
white.G = byte.MaxValue;
white.B = (byte) 0;
}
if (num == 6 || num == 18)
{
white.R = (byte) 0;
white.G = byte.MaxValue;
white.B = (byte) 127;
}
if (num == 7 || num == 19)
{
white.R = (byte) 0;
white.G = byte.MaxValue;
white.B = byte.MaxValue;
}
if (num == 8 || num == 20)
{
white.R = (byte) 0;
white.G = (byte) 127;
white.B = byte.MaxValue;
}
if (num == 9 || num == 21)
{
white.R = (byte) 0;
white.G = (byte) 0;
white.B = byte.MaxValue;
}
if (num == 10 || num == 22)
{
white.R = (byte) 127;
white.G = (byte) 0;
white.B = byte.MaxValue;
}
if (num == 11 || num == 23)
{
white.R = byte.MaxValue;
white.G = (byte) 0;
white.B = byte.MaxValue;
}
if (num == 12 || num == 24)
{
white.R = byte.MaxValue;
white.G = (byte) 0;
white.B = (byte) 127;
}
if (num == 25)
{
white.R = (byte) 75;
white.G = (byte) 75;
white.B = (byte) 75;
}
if (num == 26)
{
white.R = byte.MaxValue;
white.G = byte.MaxValue;
white.B = byte.MaxValue;
}
if (num == 27)
{
white.R = (byte) 175;
white.G = (byte) 175;
white.B = (byte) 175;
}
if (num == 28)
{
white.R = byte.MaxValue;
white.G = (byte) 178;
white.B = (byte) 125;
}
if (num == 29)
{
white.R = (byte) 25;
white.G = (byte) 25;
white.B = (byte) 25;
}
if (num == 30)
{
white.R = (byte) 200;
white.G = (byte) 200;
white.B = (byte) 200;
white.A = (byte) 150;
}
return white;
}
public static void paintEffect(int x, int y, byte color, byte oldColor)
{
int color1 = (int) color;
if (color == (byte) 0)
color1 = (int) oldColor;
Color newColor = WorldGen.paintColor(color1);
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(new Vector2((float) (x * 16), (float) (y * 16)), 16, 16, 143, Alpha: 50, newColor: newColor);
if (WorldGen.genRand.Next(2) == 0)
{
Main.dust[index2].noGravity = true;
Main.dust[index2].scale *= 1.2f;
}
else
Main.dust[index2].scale *= 0.5f;
}
}
public static bool paintTile(int x, int y, byte color, bool broadCast = false)
{
if (Main.tile[x, y] == null || !Main.tile[x, y].active())
return false;
byte oldColor = Main.tile[x, y].color();
Main.tile[x, y].color(color);
if (broadCast)
NetMessage.SendData(63, number: x, number2: ((float) y), number3: ((float) color));
WorldGen.paintEffect(x, y, color, oldColor);
return true;
}
public static bool paintWall(int x, int y, byte color, bool broadCast = false)
{
if (Main.tile[x, y] == null || Main.tile[x, y].wall == (byte) 0)
return false;
byte oldColor = Main.tile[x, y].wallColor();
Main.tile[x, y].wallColor(color);
if (broadCast)
NetMessage.SendData(64, number: x, number2: ((float) y), number3: ((float) color));
WorldGen.paintEffect(x, y, color, oldColor);
return true;
}
public static void Place3x3Wall(int x, int y, ushort type, int style)
{
int num1 = x - 1;
int num2 = y - 1;
bool flag = true;
for (int index1 = num1; index1 < num1 + 3; ++index1)
{
for (int index2 = num2; index2 < num2 + 3; ++index2)
{
if (Main.tile[index1, index2].active() || Main.tile[index1, index2].wall == (byte) 0)
{
flag = false;
break;
}
}
}
if (!flag)
return;
int num3 = 0;
for (; style > 35; style -= 36)
++num3;
int num4 = style * 54;
int num5 = num3 * 54;
for (int index3 = num1; index3 < num1 + 3; ++index3)
{
for (int index4 = num2; index4 < num2 + 3; ++index4)
{
Main.tile[index3, index4].active(true);
Main.tile[index3, index4].type = type;
Main.tile[index3, index4].frameX = (short) (num4 + 18 * (index3 - num1));
Main.tile[index3, index4].frameY = (short) (num5 + 18 * (index4 - num2));
}
}
}
public static void Check3x3Wall(int x, int y)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int type = (int) Main.tile[x, y].type;
int num1 = 0;
int num2 = 0;
int num3 = (int) Main.tile[x, y].frameX / 18;
while (num3 >= 3)
{
num3 -= 3;
++num1;
}
int num4 = x - num3;
int num5 = (int) Main.tile[x, y].frameY / 18;
while (num5 >= 3)
{
num5 -= 3;
++num2;
}
int num6 = y - num5;
int num7 = num2 * 54;
int num8 = num1 * 54;
for (int index1 = num4; index1 < num4 + 3; ++index1)
{
for (int index2 = num6; index2 < num6 + 3; ++index2)
{
if ((int) Main.tile[index1, index2].type != type || !Main.tile[index1, index2].active() || Main.tile[index1, index2].wall <= (byte) 0 || (int) Main.tile[index1, index2].frameX != num8 + (index1 - num4) * 18 || (int) Main.tile[index1, index2].frameY != num7 + (index2 - num6) * 18)
{
flag = true;
break;
}
}
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i = num4; i < num4 + 3; ++i)
{
for (int j = num6; j < num6 + 3; ++j)
{
if ((int) Main.tile[i, j].type == type && Main.tile[i, j].active())
WorldGen.KillTile(i, j);
}
}
switch (type)
{
case 240:
int num9 = num1 + num2 * 36;
switch (num9)
{
case 18:
Item.NewItem(x * 16, y * 16, 32, 32, 1419);
break;
case 19:
Item.NewItem(x * 16, y * 16, 32, 32, 1420);
break;
case 20:
Item.NewItem(x * 16, y * 16, 32, 32, 1427);
break;
case 21:
Item.NewItem(x * 16, y * 16, 32, 32, 1428);
break;
case 33:
Item.NewItem(x * 16, y * 16, 32, 32, 1574);
break;
case 34:
Item.NewItem(x * 16, y * 16, 32, 32, 1575);
break;
case 35:
Item.NewItem(x * 16, y * 16, 32, 32, 1576);
break;
case 36:
Item.NewItem(x * 16, y * 16, 32, 32, 1855);
break;
case 37:
Item.NewItem(x * 16, y * 16, 32, 32, 1856);
break;
case 38:
Item.NewItem(x * 16, y * 16, 32, 32, 1960);
break;
case 39:
Item.NewItem(x * 16, y * 16, 32, 32, 1961);
break;
case 40:
Item.NewItem(x * 16, y * 16, 32, 32, 1962);
break;
case 54:
Item.NewItem(x * 16, y * 16, 32, 32, 2489);
break;
case 55:
Item.NewItem(x * 16, y * 16, 32, 32, 2589);
break;
case 56:
Item.NewItem(x * 16, y * 16, 32, 32, 3357);
break;
case 57:
Item.NewItem(x * 16, y * 16, 32, 32, 3358);
break;
case 58:
Item.NewItem(x * 16, y * 16, 32, 32, 3359);
break;
case 59:
Item.NewItem(x * 16, y * 16, 32, 32, 3595);
break;
case 60:
Item.NewItem(x * 16, y * 16, 32, 32, 3867);
break;
case 61:
Item.NewItem(x * 16, y * 16, 32, 32, 3866);
break;
case 62:
Item.NewItem(x * 16, y * 16, 32, 32, 3868);
break;
default:
if (num9 >= 41 && num9 <= 45)
{
Item.NewItem(x * 16, y * 16, 32, 32, 2114 + num9 - 41);
break;
}
if (num9 >= 46 && num9 <= 53)
{
Item.NewItem(x * 16, y * 16, 32, 32, 2442 + num9 - 46);
break;
}
if (num9 >= 22 && num9 <= 25)
{
Item.NewItem(x * 16, y * 16, 32, 32, 1440 + num9 - 22);
break;
}
if (num9 >= 26 && num9 <= 29)
{
Item.NewItem(x * 16, y * 16, 32, 32, 1496 + num9 - 26);
break;
}
if (num9 >= 30 && num9 <= 32)
{
Item.NewItem(x * 16, y * 16, 32, 32, 1538 + num9 - 30);
break;
}
Item.NewItem(x * 16, y * 16, 32, 32, 1360 + num9);
break;
}
break;
case 440:
int Type1 = -1;
int Type2 = -1;
switch (num1)
{
case 0:
Type1 = 3644;
Type2 = 1526;
break;
case 1:
Type1 = 3645;
Type2 = 1524;
break;
case 2:
Type1 = 3646;
Type2 = 1525;
break;
case 3:
Type1 = 3647;
Type2 = 1523;
break;
case 4:
Type1 = 3648;
Type2 = 1522;
break;
case 5:
Type1 = 3649;
Type2 = 1527;
break;
case 6:
Type1 = 3650;
Type2 = 3643;
break;
}
if (Type1 != -1)
Item.NewItem(x * 16, y * 16, 32, 32, Type1);
if (Type2 != -1 && num2 == 1)
{
Item.NewItem(x * 16, y * 16, 32, 32, Type2);
break;
}
break;
}
WorldGen.destroyObject = false;
}
public static void Place2x3Wall(int x, int y, ushort type, int style)
{
int num1 = x;
int num2 = y - 1;
bool flag = true;
for (int index1 = num1; index1 < num1 + 2; ++index1)
{
for (int index2 = num2; index2 < num2 + 3; ++index2)
{
if (Main.tile[index1, index2].active() || Main.tile[index1, index2].wall == (byte) 0)
{
flag = false;
break;
}
}
}
if (!flag)
return;
int num3 = style * 36;
int num4 = 0;
for (int index3 = num1; index3 < num1 + 2; ++index3)
{
for (int index4 = num2; index4 < num2 + 3; ++index4)
{
Main.tile[index3, index4].active(true);
Main.tile[index3, index4].type = type;
Main.tile[index3, index4].frameX = (short) (num3 + 18 * (index3 - num1));
Main.tile[index3, index4].frameY = (short) (num4 + 18 * (index4 - num2));
}
}
}
public static void Check2x3Wall(int x, int y)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int type = (int) Main.tile[x, y].type;
int num1 = 0;
int num2 = (int) Main.tile[x, y].frameX / 18;
while (num2 >= 2)
{
num2 -= 2;
++num1;
}
int num3 = x - num2;
int num4 = y - (int) Main.tile[x, y].frameY / 18;
int num5 = num1 * 36;
for (int index1 = num3; index1 < num3 + 2; ++index1)
{
for (int index2 = num4; index2 < num4 + 3; ++index2)
{
if ((int) Main.tile[index1, index2].type != type || !Main.tile[index1, index2].active() || Main.tile[index1, index2].wall <= (byte) 0 || (int) Main.tile[index1, index2].frameX != num5 + (index1 - num3) * 18 || (int) Main.tile[index1, index2].frameY != (index2 - num4) * 18)
{
flag = true;
break;
}
}
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i = num3; i < num3 + 2; ++i)
{
for (int j = num4; j < num4 + 3; ++j)
{
if ((int) Main.tile[i, j].type == type && Main.tile[i, j].active())
WorldGen.KillTile(i, j);
}
}
if (type == 245)
{
switch (num1)
{
case 5:
Item.NewItem(x * 16, y * 16, 32, 32, 1495);
break;
case 6:
Item.NewItem(x * 16, y * 16, 32, 32, 1577);
break;
default:
Item.NewItem(x * 16, y * 16, 32, 32, 1474 + num1);
break;
}
}
WorldGen.destroyObject = false;
}
public static void Place3x2Wall(int x, int y, ushort type, int style)
{
int num1 = x - 1;
int num2 = y;
bool flag = true;
for (int index1 = num1; index1 < num1 + 3; ++index1)
{
for (int index2 = num2; index2 < num2 + 2; ++index2)
{
if (Main.tile[index1, index2].active() || Main.tile[index1, index2].wall == (byte) 0)
{
flag = false;
break;
}
}
}
if (!flag)
return;
int num3 = 0;
int num4 = style * 36;
for (int index3 = num1; index3 < num1 + 3; ++index3)
{
for (int index4 = num2; index4 < num2 + 2; ++index4)
{
Main.tile[index3, index4].active(true);
Main.tile[index3, index4].type = type;
Main.tile[index3, index4].frameX = (short) (num3 + 18 * (index3 - num1));
Main.tile[index3, index4].frameY = (short) (num4 + 18 * (index4 - num2));
}
}
}
public static void Check3x2Wall(int x, int y)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int type = (int) Main.tile[x, y].type;
int num1 = 0;
int num2 = (int) Main.tile[x, y].frameY / 18;
while (num2 >= 2)
{
num2 -= 2;
++num1;
}
int num3 = y - num2;
int num4 = x - (int) Main.tile[x, y].frameX / 18;
int num5 = num1 * 36;
for (int index1 = num4; index1 < num4 + 3; ++index1)
{
for (int index2 = num3; index2 < num3 + 2; ++index2)
{
if ((int) Main.tile[index1, index2].type != type || !Main.tile[index1, index2].active() || Main.tile[index1, index2].wall <= (byte) 0 || (int) Main.tile[index1, index2].frameY != num5 + (index2 - num3) * 18 || (int) Main.tile[index1, index2].frameX != (index1 - num4) * 18)
{
flag = true;
break;
}
}
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i = num4; i < num4 + 3; ++i)
{
for (int j = num3; j < num3 + 2; ++j)
{
if ((int) Main.tile[i, j].type == type && Main.tile[i, j].active())
WorldGen.KillTile(i, j);
}
}
if (type == 246)
{
switch (num1)
{
case 16:
Item.NewItem(x * 16, y * 16, 32, 32, 1541);
break;
case 17:
Item.NewItem(x * 16, y * 16, 32, 32, 1542);
break;
case 18:
Item.NewItem(x * 16, y * 16, 32, 32, 1908);
break;
default:
Item.NewItem(x * 16, y * 16, 32, 32, 1479 + num1);
break;
}
}
WorldGen.destroyObject = false;
}
public static void Place4x3Wall(int x, int y, ushort type, int style)
{
int num1 = x - 1;
int num2 = y - 1;
bool flag = true;
for (int index1 = num1; index1 < num1 + 4; ++index1)
{
for (int index2 = num2; index2 < num2 + 3; ++index2)
{
if (Main.tile[index1, index2].active() || Main.tile[index1, index2].wall == (byte) 0)
{
flag = false;
break;
}
}
}
if (!flag)
return;
int num3 = 0;
int num4 = style * 54;
for (int index3 = num1; index3 < num1 + 4; ++index3)
{
for (int index4 = num2; index4 < num2 + 3; ++index4)
{
Main.tile[index3, index4].active(true);
Main.tile[index3, index4].type = type;
Main.tile[index3, index4].frameX = (short) (num3 + 18 * (index3 - num1));
Main.tile[index3, index4].frameY = (short) (num4 + 18 * (index4 - num2));
}
}
}
public static void Check4x3Wall(int x, int y)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int type = (int) Main.tile[x, y].type;
int num1 = 0;
int num2 = (int) Main.tile[x, y].frameY / 18;
while (num2 >= 3)
{
num2 -= 3;
++num1;
}
int num3 = y - num2;
int num4 = x - (int) Main.tile[x, y].frameX / 18;
int num5 = num1 * 54;
for (int index1 = num4; index1 < num4 + 4; ++index1)
{
for (int index2 = num3; index2 < num3 + 3; ++index2)
{
if ((int) Main.tile[index1, index2].type != type || !Main.tile[index1, index2].active() || Main.tile[index1, index2].wall <= (byte) 0 || (int) Main.tile[index1, index2].frameY != num5 + (index2 - num3) * 18 || (int) Main.tile[index1, index2].frameX != (index1 - num4) * 18)
{
flag = true;
break;
}
}
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i = num4; i < num4 + 4; ++i)
{
for (int j = num3; j < num3 + 3; ++j)
{
if ((int) Main.tile[i, j].type == type && Main.tile[i, j].active())
WorldGen.KillTile(i, j);
}
}
if (type == 241)
Item.NewItem(x * 16, y * 16, 32, 32, 1417);
WorldGen.destroyObject = false;
}
public static void Place6x4Wall(int x, int y, ushort type, int style)
{
int num1 = x - 2;
int num2 = y - 2;
bool flag = true;
for (int index1 = num1; index1 < num1 + 6; ++index1)
{
for (int index2 = num2; index2 < num2 + 4; ++index2)
{
if (Main.tile[index1, index2].active() || Main.tile[index1, index2].wall == (byte) 0)
{
flag = false;
break;
}
}
}
if (!flag)
return;
int num3 = 27;
int num4 = style / num3 * 108;
int num5 = style % num3 * 72;
for (int index3 = num1; index3 < num1 + 6; ++index3)
{
for (int index4 = num2; index4 < num2 + 4; ++index4)
{
Main.tile[index3, index4].active(true);
Main.tile[index3, index4].type = type;
Main.tile[index3, index4].frameX = (short) (num4 + 18 * (index3 - num1));
Main.tile[index3, index4].frameY = (short) (num5 + 18 * (index4 - num2));
}
}
}
public static void Check6x4Wall(int x, int y)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int type = (int) Main.tile[x, y].type;
int num1 = (int) Main.tile[x, y].frameY / 18;
int num2 = (int) Main.tile[x, y].frameX / 18;
int num3 = 27 * (num2 / 6) + (num1 >> 2);
int num4 = num1 % 4;
int num5 = num2 % 6;
int num6 = y - num4;
int num7 = x - (int) Main.tile[x, y].frameX / 18 % 6;
int num8 = num3 % 27 * 72;
int num9 = num3 / 27 * 108;
for (int index1 = num7; index1 < num7 + 6; ++index1)
{
for (int index2 = num6; index2 < num6 + 4; ++index2)
{
if ((int) Main.tile[index1, index2].type != type || !Main.tile[index1, index2].active() || Main.tile[index1, index2].wall <= (byte) 0 || (int) Main.tile[index1, index2].frameY != num8 + (index2 - num6) * 18 || (int) Main.tile[index1, index2].frameX != num9 + (index1 - num7) * 18)
{
flag = true;
break;
}
}
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i = num7; i < num7 + 6; ++i)
{
for (int j = num6; j < num6 + 4; ++j)
{
if ((int) Main.tile[i, j].type == type && Main.tile[i, j].active())
WorldGen.KillTile(i, j);
}
}
if (type == 242)
{
if (num3 == 30)
Item.NewItem(x * 16, y * 16, 32, 32, 2995);
else if (num3 >= 31 && num3 <= 35)
Item.NewItem(x * 16, y * 16, 32, 32, 3055 + num3 - 31);
else if (num3 >= 27 && num3 <= 29)
Item.NewItem(x * 16, y * 16, 32, 32, 2865 + num3 - 27);
else if (num3 == 36)
Item.NewItem(x * 16, y * 16, 32, 32, 3596);
else if (num3 == 26)
Item.NewItem(x * 16, y * 16, 32, 32, 2497);
else if (num3 == 25)
Item.NewItem(x * 16, y * 16, 32, 32, 2495);
else if (num3 >= 22)
Item.NewItem(x * 16, y * 16, 32, 32, 2281 + num3 - 22);
else if (num3 >= 17)
Item.NewItem(x * 16, y * 16, 32, 32, 1846 + num3 - 17);
else if (num3 == 16)
Item.NewItem(x * 16, y * 16, 32, 32, 1573);
else if (num3 >= 13)
Item.NewItem(x * 16, y * 16, 32, 32, 1500 + num3 - 13);
else if (num3 >= 6)
Item.NewItem(x * 16, y * 16, 32, 32, 1433 + num3 - 6);
else
Item.NewItem(x * 16, y * 16, 32, 32, 1421 + num3);
}
WorldGen.destroyObject = false;
}
public static void Place1x1(int x, int y, int type, int style = 0)
{
Tile tile = Main.tile[x, y];
if (Main.tile[x, y] == null)
{
tile = new Tile();
Main.tile[x, y] = tile;
}
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (type == 324)
{
if (!WorldGen.SolidTile2(x, y + 1) && (!Main.tile[x, y + 1].nactive() || !Main.tileTable[(int) Main.tile[x, y + 1].type]))
return;
tile.active(true);
tile.type = (ushort) type;
tile.frameX = (short) (22 * WorldGen.genRand.Next(2));
tile.frameY = (short) (22 * style);
}
else
{
if (!WorldGen.SolidTile2(x, y + 1) || tile.active())
return;
tile.active(true);
tile.type = (ushort) type;
switch (type)
{
case 36:
case 144:
case 239:
tile.frameX = (short) (style * 18);
tile.frameY = (short) 0;
break;
case 324:
tile.frameX = (short) (22 * WorldGen.genRand.Next(2));
tile.frameY = (short) (22 * style);
break;
default:
tile.frameY = (short) (style * 18);
break;
}
}
}
public static void Check1x1(int x, int y, int type)
{
if (Main.tile[x, y + 1] == null || WorldGen.SolidTileAllowBottomSlope(x, y + 1))
return;
WorldGen.KillTile(x, y);
}
public static void CheckLogicTiles(int x, int y, int type)
{
if (type == 419)
{
Tile tile = Main.tile[x, y + 1];
if (tile != null && (!tile.active() || tile.type != (ushort) 420 && tile.type != (ushort) 419))
{
WorldGen.KillTile(x, y);
return;
}
}
Tile tile1 = Main.tile[x, y];
bool flag = false;
if ((int) tile1.frameX % 18 != 0)
flag = true;
if ((int) tile1.frameY % 18 != 0)
flag = true;
if (!flag)
return;
WorldGen.KillTile(x, y);
}
public static void PlaceLogicTiles(int x, int y, int type, int style = 0)
{
Tile tile = Main.tile[x, y];
if (Main.tile[x, y] == null)
{
tile = new Tile();
Main.tile[x, y] = tile;
}
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (type == 419)
{
if (!Main.tile[x, y + 1].active() || Main.tile[x, y + 1].type != (ushort) 419 && Main.tile[x, y + 1].type != (ushort) 420)
return;
tile.active(true);
tile.type = (ushort) type;
tile.frameX = (short) (style * 18);
tile.frameY = (short) 0;
}
else
{
if (tile.active())
return;
tile.active(true);
tile.type = (ushort) type;
tile.frameX = (short) 0;
tile.frameY = (short) (18 * style);
}
}
public static void PlaceOnTable1x1(int x, int y, int type, int style = 0)
{
bool flag = false;
if (Main.tile[x, y] == null)
Main.tile[x, y] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (!Main.tile[x, y].active() && Main.tile[x, y + 1].nactive() && Main.tileTable[(int) Main.tile[x, y + 1].type])
flag = true;
if (type == 78 && !Main.tile[x, y].active() && Main.tile[x, y + 1].nactive() && Main.tileSolid[(int) Main.tile[x, y + 1].type] && !Main.tile[x, y + 1].halfBrick() && Main.tile[x, y + 1].slope() == (byte) 0)
flag = true;
if (!flag)
return;
Main.tile[x, y].active(true);
Main.tile[x, y].type = (ushort) type;
if (type == 33)
{
Main.tile[x, y].frameX = (short) 0;
Main.tile[x, y].frameY = (short) (style * 22);
}
else
{
Main.tile[x, y].frameX = (short) (style * 18);
Main.tile[x, y].frameY = (short) 0;
}
if (type != 50)
return;
Main.tile[x, y].frameX = (short) (18 * WorldGen.genRand.Next(5));
}
public static bool PlaceAlch(int x, int y, int style)
{
if (Main.tile[x, y] == null)
Main.tile[x, y] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (!Main.tile[x, y].active() && Main.tile[x, y + 1].nactive() && !Main.tile[x, y + 1].halfBrick() && Main.tile[x, y + 1].slope() == (byte) 0)
{
bool flag = false;
switch (style)
{
case 0:
if (Main.tile[x, y + 1].type != (ushort) 2 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380 && Main.tile[x, y + 1].type != (ushort) 109)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0)
{
flag = true;
break;
}
break;
case 1:
if (Main.tile[x, y + 1].type != (ushort) 60 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0)
{
flag = true;
break;
}
break;
case 2:
if (Main.tile[x, y + 1].type != (ushort) 0 && Main.tile[x, y + 1].type != (ushort) 59 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0)
{
flag = true;
break;
}
break;
case 3:
if (Main.tile[x, y + 1].type != (ushort) 203 && Main.tile[x, y + 1].type != (ushort) 199 && Main.tile[x, y + 1].type != (ushort) 23 && Main.tile[x, y + 1].type != (ushort) 25 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0)
{
flag = true;
break;
}
break;
case 4:
if (Main.tile[x, y + 1].type != (ushort) 53 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380 && Main.tile[x, y + 1].type != (ushort) 116)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
case 5:
if (Main.tile[x, y + 1].type != (ushort) 57 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && !Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
case 6:
if (Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380 && Main.tile[x, y + 1].type != (ushort) 147 && Main.tile[x, y + 1].type != (ushort) 161 && Main.tile[x, y + 1].type != (ushort) 163 && Main.tile[x, y + 1].type != (ushort) 164 && Main.tile[x, y + 1].type != (ushort) 200)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
}
if (!flag)
{
Main.tile[x, y].active(true);
Main.tile[x, y].type = (ushort) 82;
Main.tile[x, y].frameX = (short) (18 * style);
Main.tile[x, y].frameY = (short) 0;
return true;
}
}
return false;
}
public static void GrowSpike(int i, int j, ushort spikeType, ushort landType)
{
int index1 = i;
int index2 = j;
int num1 = 0;
if (Main.tile[index1 + 1, index2].active() && (int) Main.tile[index1 + 1, index2].type == (int) spikeType)
++num1;
if (Main.tile[index1 - 1, index2].active() && (int) Main.tile[index1 - 1, index2].type == (int) spikeType)
++num1;
if (Main.tile[index1, index2 + 1].active() && (int) Main.tile[index1, index2 + 1].type == (int) spikeType)
++num1;
if (Main.tile[index1, index2 - 1].active() && (int) Main.tile[index1, index2 - 1].type == (int) spikeType)
++num1;
if (num1 >= 3 && (int) Main.tile[i, j].type != (int) landType)
return;
switch (WorldGen.genRand.Next(4))
{
case 0:
--index2;
break;
case 1:
++index2;
break;
case 2:
--index1;
break;
case 3:
++index1;
break;
}
if (Main.tile[index1, index2].active())
return;
int num2 = 0;
if (Main.tile[index1 + 1, index2].active() && (int) Main.tile[index1 + 1, index2].type == (int) spikeType)
++num2;
if (Main.tile[index1 - 1, index2].active() && (int) Main.tile[index1 - 1, index2].type == (int) spikeType)
++num2;
if (Main.tile[index1, index2 + 1].active() && (int) Main.tile[index1, index2 + 1].type == (int) spikeType)
++num2;
if (Main.tile[index1, index2 - 1].active() && (int) Main.tile[index1, index2 - 1].type == (int) spikeType)
++num2;
if (num2 >= 2)
return;
int num3 = 7;
int num4 = index1 - num3;
int num5 = index1 + num3;
int num6 = index2 - num3;
int num7 = index2 + num3;
bool flag = false;
for (int index3 = num4; index3 < num5; ++index3)
{
for (int index4 = num6; index4 < num7; ++index4)
{
if (Math.Abs(index3 - index1) * 2 + Math.Abs(index4 - index2) < 9 && Main.tile[index3, index4].active() && (int) Main.tile[index3, index4].type == (int) landType && Main.tile[index3, index4 - 1].active() && (int) Main.tile[index3, index4 - 1].type == (int) spikeType && Main.tile[index3, index4 - 1].liquid == (byte) 0)
{
flag = true;
break;
}
}
}
if (!flag)
return;
Main.tile[index1, index2].type = spikeType;
Main.tile[index1, index2].active(true);
WorldGen.SquareTileFrame(index1, index2);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, index1, index2, 3);
}
public static void GrowAlch(int x, int y)
{
if (!Main.tile[x, y].active())
return;
if (Main.tile[x, y].type == (ushort) 82 && WorldGen.genRand.Next(50) == 0)
{
bool flag = false;
if (Main.tile[x, y].frameX == (short) 108)
{
if (WorldGen.genRand.Next(3) != 0)
flag = true;
}
else
flag = true;
if (!flag)
return;
Main.tile[x, y].type = (ushort) 83;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, x, y, 1);
WorldGen.SquareTileFrame(x, y);
}
else if (Main.dayTime && Main.tile[x, y].type == (ushort) 82 && Main.tile[x, y].frameX == (short) 0 && WorldGen.genRand.Next(50) == 0)
{
Main.tile[x, y].type = (ushort) 83;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, x, y, 1);
WorldGen.SquareTileFrame(x, y);
}
else if (!Main.dayTime && Main.tile[x, y].type == (ushort) 82 && Main.tile[x, y].frameX == (short) 18 && WorldGen.genRand.Next(50) == 0)
{
Main.tile[x, y].type = (ushort) 83;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, x, y, 1);
WorldGen.SquareTileFrame(x, y);
}
else if (Main.tile[x, y].frameX == (short) 36 && WorldGen.genRand.Next(3) != 0)
{
if (Main.tile[x, y].type == (ushort) 83)
{
if (WorldGen.genRand.Next(2) != 0)
return;
Main.tile[x, y].type = (ushort) 84;
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, x, y, 1);
}
else
{
if (WorldGen.genRand.Next(5) != 0 && Main.tile[x, y].type != (ushort) 84)
return;
Main.tile[x, y].type = (ushort) 83;
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, x, y, 1);
}
}
else
{
if (Main.tile[x, y].frameX != (short) 108 || Main.tile[x, y].type != (ushort) 83 || WorldGen.genRand.Next(80) != 0)
return;
Main.tile[x, y].type = (ushort) 84;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, x, y, 1);
WorldGen.SquareTileFrame(x, y);
}
}
public static void PlantAlch()
{
int index1 = WorldGen.genRand.Next(20, Main.maxTilesX - 20);
int index2 = WorldGen.genRand.Next(40) != 0 ? (WorldGen.genRand.Next(10) != 0 ? WorldGen.genRand.Next((int) Main.worldSurface, Main.maxTilesY - 20) : WorldGen.genRand.Next(0, Main.maxTilesY - 20)) : WorldGen.genRand.Next((int) (Main.rockLayer + (double) Main.maxTilesY) / 2, Main.maxTilesY - 20);
while (index2 < Main.maxTilesY - 20 && !Main.tile[index1, index2].active())
++index2;
if (!Main.tile[index1, index2].nactive() || Main.tile[index1, index2 - 1].active() || Main.tile[index1, index2 - 1].liquid != (byte) 0)
return;
int num1 = 15;
int num2 = 5;
int num3 = 0;
int num4 = (int) ((double) num1 * ((double) Main.maxTilesX / 4200.0));
int num5 = Utils.Clamp<int>(index1 - num4, 4, Main.maxTilesX - 4);
int num6 = Utils.Clamp<int>(index1 + num4, 4, Main.maxTilesX - 4);
int num7 = Utils.Clamp<int>(index2 - num4, 4, Main.maxTilesY - 4);
int num8 = Utils.Clamp<int>(index2 + num4, 4, Main.maxTilesY - 4);
for (int index3 = num5; index3 <= num6; ++index3)
{
for (int index4 = num7; index4 <= num8; ++index4)
{
if (Main.tileAlch[(int) Main.tile[index3, index4].type])
++num3;
}
}
if (num3 >= num2)
return;
if (Main.tile[index1, index2].type == (ushort) 2 || Main.tile[index1, index2].type == (ushort) 109)
WorldGen.PlaceAlch(index1, index2 - 1, 0);
if (Main.tile[index1, index2].type == (ushort) 60)
WorldGen.PlaceAlch(index1, index2 - 1, 1);
if (Main.tile[index1, index2].type == (ushort) 0 || Main.tile[index1, index2].type == (ushort) 59)
WorldGen.PlaceAlch(index1, index2 - 1, 2);
if (Main.tile[index1, index2].type == (ushort) 23 || Main.tile[index1, index2].type == (ushort) 25 || Main.tile[index1, index2].type == (ushort) 203 || Main.tile[index1, index2].type == (ushort) 199)
WorldGen.PlaceAlch(index1, index2 - 1, 3);
if (Main.tile[index1, index2].type == (ushort) 53 || Main.tile[index1, index2].type == (ushort) 116)
WorldGen.PlaceAlch(index1, index2 - 1, 4);
if (Main.tile[index1, index2].type == (ushort) 57)
WorldGen.PlaceAlch(index1, index2 - 1, 5);
if (Main.tile[index1, index2].type == (ushort) 147 || Main.tile[index1, index2].type == (ushort) 163 || Main.tile[index1, index2].type == (ushort) 164 || Main.tile[index1, index2].type == (ushort) 161 || Main.tile[index1, index2].type == (ushort) 200)
WorldGen.PlaceAlch(index1, index2 - 1, 6);
if (!Main.tile[index1, index2 - 1].active() || Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, index1, index2 - 1, 1);
}
public static void CheckAlch(int x, int y)
{
if (Main.tile[x, y] == null)
Main.tile[x, y] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
bool flag = false;
if (!Main.tile[x, y + 1].active())
flag = true;
if (Main.tile[x, y + 1].halfBrick())
flag = true;
int num = (int) Main.tile[x, y].frameX / 18;
Main.tile[x, y].frameY = (short) 0;
if (!flag)
{
switch (num)
{
case 0:
if (Main.tile[x, y + 1].type != (ushort) 109 && Main.tile[x, y + 1].type != (ushort) 2 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
case 1:
if (Main.tile[x, y + 1].type != (ushort) 60 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
case 2:
if (Main.tile[x, y + 1].type != (ushort) 0 && Main.tile[x, y + 1].type != (ushort) 59 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
case 3:
if (Main.tile[x, y + 1].type != (ushort) 199 && Main.tile[x, y + 1].type != (ushort) 203 && Main.tile[x, y + 1].type != (ushort) 23 && Main.tile[x, y + 1].type != (ushort) 25 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
case 4:
if (Main.tile[x, y + 1].type != (ushort) 53 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380 && Main.tile[x, y + 1].type != (ushort) 116)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
case 5:
if (Main.tile[x, y + 1].type != (ushort) 57 && Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && !Main.tile[x, y].lava())
flag = true;
if (Main.tile[x, y].type != (ushort) 82 && Main.tile[x, y].lava() && Main.tile[x, y].type != (ushort) 82 && Main.tile[x, y].lava() && Main.netMode != 1)
{
if (Main.tile[x, y].liquid > (byte) 16)
{
if (Main.tile[x, y].type == (ushort) 83)
{
Main.tile[x, y].type = (ushort) 84;
if (Main.netMode == 2)
{
NetMessage.SendTileSquare(-1, x, y, 1);
break;
}
break;
}
break;
}
if (Main.tile[x, y].type == (ushort) 84)
{
Main.tile[x, y].type = (ushort) 83;
if (Main.netMode == 2)
{
NetMessage.SendTileSquare(-1, x, y, 1);
break;
}
break;
}
break;
}
break;
case 6:
if (Main.tile[x, y + 1].type != (ushort) 78 && Main.tile[x, y + 1].type != (ushort) 380 && Main.tile[x, y + 1].type != (ushort) 147 && Main.tile[x, y + 1].type != (ushort) 161 && Main.tile[x, y + 1].type != (ushort) 163 && Main.tile[x, y + 1].type != (ushort) 164 && Main.tile[x, y + 1].type != (ushort) 200)
flag = true;
if (Main.tile[x, y].liquid > (byte) 0 && Main.tile[x, y].lava())
{
flag = true;
break;
}
break;
}
}
if (!flag)
return;
WorldGen.KillTile(x, y);
}
public static void CheckBanner(int x, int j, byte type)
{
if (WorldGen.destroyObject)
return;
int num1 = (int) Main.tile[x, j].frameY / 18;
int num2 = 0;
while (num1 >= 3)
{
num1 -= 3;
++num2;
}
int num3 = j - num1;
int frameX = (int) Main.tile[x, j].frameX;
bool flag = false;
for (int index = 0; index < 3; ++index)
{
if (Main.tile[x, num3 + index] == null)
Main.tile[x, num3 + index] = new Tile();
if (!Main.tile[x, num3 + index].active())
flag = true;
else if ((int) Main.tile[x, num3 + index].type != (int) type)
flag = true;
else if ((int) Main.tile[x, num3 + index].frameY != index * 18 + num2 * 18 * 3)
flag = true;
else if ((int) Main.tile[x, num3 + index].frameX != frameX)
flag = true;
}
if (Main.tile[x, num3 - 1] == null)
Main.tile[x, num3 - 1] = new Tile();
if (!Main.tile[x, num3 - 1].nactive())
flag = true;
if (!Main.tile[x, num3 - 1].topSlope() && !Main.tile[x, num3 - 1].halfBrick() && !Main.tileSolid[(int) Main.tile[x, num3 - 1].type] || Main.tileSolidTop[(int) Main.tile[x, num3 - 1].type] && (!TileID.Sets.Platforms[(int) Main.tile[x, num3 - 1].type] || !Main.tile[x, num3 - 1].halfBrick() && !Main.tile[x, num3 - 1].topSlope()) || TileID.Sets.NotReallySolid[(int) Main.tile[x, num3 - 1].type] || Main.tile[x, num3 - 1].bottomSlope())
flag = true;
if (!flag)
return;
WorldGen.destroyObject = true;
for (int index = 0; index < 3; ++index)
{
if ((int) Main.tile[x, num3 + index].type == (int) type)
WorldGen.KillTile(x, num3 + index);
}
if (type == (byte) 91)
{
int num4 = frameX / 18 + num2 * 111;
if (num4 >= 278)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 3559 + num4);
else if (num4 >= 273)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 3516 + num4);
else if (num4 >= 272)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 3780);
else if (num4 >= 270)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 3323 + num4);
else if (num4 >= 207)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 3183 + num4);
else if (num4 >= 109)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 2788 + num4);
else if (num4 >= 22)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 1593 + num4);
else if (num4 >= 10 && num4 <= 15)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 1441 + num4);
else if (num4 >= 16 && num4 <= 21)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 1448 + num4);
else if (num4 >= 7 && num4 <= 9)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 838 + num4);
else if (num4 >= 4 && num4 <= 6)
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 785 + num4);
else
Item.NewItem(x * 16, (num3 + 1) * 16, 32, 32, 337 + num4);
}
WorldGen.destroyObject = false;
}
public static void PlaceBanner(int x, int y, ushort type, int style = 0)
{
int num1 = style * 18;
int num2 = 0;
if (style >= 90)
{
num1 -= 1620;
num2 += 54;
}
if (Main.tile[x, y - 1] == null)
Main.tile[x, y - 1] = new Tile();
if (Main.tile[x, y] == null)
Main.tile[x, y] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (Main.tile[x, y + 2] == null)
Main.tile[x, y + 2] = new Tile();
if (!Main.tile[x, y - 1].nactive() || !Main.tileSolid[(int) Main.tile[x, y - 1].type] || Main.tileSolidTop[(int) Main.tile[x, y - 1].type] || Main.tile[x, y].active() || Main.tile[x, y + 1].active() || Main.tile[x, y + 2].active())
return;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) num2;
Main.tile[x, y].frameX = (short) num1;
Main.tile[x, y].type = type;
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].frameY = (short) (num2 + 18);
Main.tile[x, y + 1].frameX = (short) num1;
Main.tile[x, y + 1].type = type;
Main.tile[x, y + 2].active(true);
Main.tile[x, y + 2].frameY = (short) (num2 + 36);
Main.tile[x, y + 2].frameX = (short) num1;
Main.tile[x, y + 2].type = type;
}
public static void PlaceMan(int i, int j, int dir)
{
for (int index1 = i; index1 <= i + 1; ++index1)
{
for (int index2 = j - 2; index2 <= j; ++index2)
{
if (Main.tile[index1, index2].active())
return;
}
}
if (!WorldGen.SolidTile2(i, j + 1) || !WorldGen.SolidTile2(i + 1, j + 1))
return;
byte num = 0;
if (dir == 1)
num = (byte) 36;
Main.tile[i, j - 2].active(true);
Main.tile[i, j - 2].frameY = (short) 0;
Main.tile[i, j - 2].frameX = (short) num;
Main.tile[i, j - 2].type = (ushort) 128;
Main.tile[i, j - 1].active(true);
Main.tile[i, j - 1].frameY = (short) 18;
Main.tile[i, j - 1].frameX = (short) num;
Main.tile[i, j - 1].type = (ushort) 128;
Main.tile[i, j].active(true);
Main.tile[i, j].frameY = (short) 36;
Main.tile[i, j].frameX = (short) num;
Main.tile[i, j].type = (ushort) 128;
Main.tile[i + 1, j - 2].active(true);
Main.tile[i + 1, j - 2].frameY = (short) 0;
Main.tile[i + 1, j - 2].frameX = (short) (byte) (18U + (uint) num);
Main.tile[i + 1, j - 2].type = (ushort) 128;
Main.tile[i + 1, j - 1].active(true);
Main.tile[i + 1, j - 1].frameY = (short) 18;
Main.tile[i + 1, j - 1].frameX = (short) (byte) (18U + (uint) num);
Main.tile[i + 1, j - 1].type = (ushort) 128;
Main.tile[i + 1, j].active(true);
Main.tile[i + 1, j].frameY = (short) 36;
Main.tile[i + 1, j].frameX = (short) (byte) (18U + (uint) num);
Main.tile[i + 1, j].type = (ushort) 128;
}
public static void PlaceWoman(int i, int j, int dir)
{
for (int index1 = i; index1 <= i + 1; ++index1)
{
for (int index2 = j - 2; index2 <= j; ++index2)
{
if (Main.tile[index1, index2].active())
return;
}
}
if (!WorldGen.SolidTile2(i, j + 1) || !WorldGen.SolidTile2(i + 1, j + 1))
return;
byte num = 0;
if (dir == 1)
num = (byte) 36;
Main.tile[i, j - 2].active(true);
Main.tile[i, j - 2].frameY = (short) 0;
Main.tile[i, j - 2].frameX = (short) num;
Main.tile[i, j - 2].type = (ushort) 269;
Main.tile[i, j - 1].active(true);
Main.tile[i, j - 1].frameY = (short) 18;
Main.tile[i, j - 1].frameX = (short) num;
Main.tile[i, j - 1].type = (ushort) 269;
Main.tile[i, j].active(true);
Main.tile[i, j].frameY = (short) 36;
Main.tile[i, j].frameX = (short) num;
Main.tile[i, j].type = (ushort) 269;
Main.tile[i + 1, j - 2].active(true);
Main.tile[i + 1, j - 2].frameY = (short) 0;
Main.tile[i + 1, j - 2].frameX = (short) (byte) (18U + (uint) num);
Main.tile[i + 1, j - 2].type = (ushort) 269;
Main.tile[i + 1, j - 1].active(true);
Main.tile[i + 1, j - 1].frameY = (short) 18;
Main.tile[i + 1, j - 1].frameX = (short) (byte) (18U + (uint) num);
Main.tile[i + 1, j - 1].type = (ushort) 269;
Main.tile[i + 1, j].active(true);
Main.tile[i + 1, j].frameY = (short) 36;
Main.tile[i + 1, j].frameX = (short) (byte) (18U + (uint) num);
Main.tile[i + 1, j].type = (ushort) 269;
}
public static void CheckWeaponsRack(int i, int j)
{
if (WorldGen.destroyObject)
return;
int num1 = i;
int num2 = j - (int) Main.tile[i, j].frameY / 18;
int num3 = (int) Main.tile[i, j].frameX;
int num4 = 0;
while (num3 >= 5000)
{
num3 -= 5000;
++num4;
}
if (num4 != 0)
num3 = (num4 - 1) * 18;
int num5 = num3 % 54;
int num6 = num1 - num5 / 18;
bool flag = false;
for (int index1 = 0; index1 < 3; ++index1)
{
for (int index2 = 0; index2 < 3; ++index2)
{
int index3 = num6 + index1;
int index4 = num2 + index2;
int num7 = (int) Main.tile[index3, index4].frameX;
int num8 = 0;
while (num7 >= 5000)
{
num7 -= 5000;
++num8;
}
if (num8 != 0)
num7 = (num8 - 1) * 18;
int num9 = num7 % 54;
if (!Main.tile[index3, index4].active() || Main.tile[index3, index4].type != (ushort) 334 || Main.tile[index3, index4].wall <= (byte) 0 || (int) Main.tile[index3, index4].frameY != index2 * 18 || num9 != index1 * 18)
flag = true;
}
}
if (!flag)
return;
WorldGen.destroyObject = true;
Item.NewItem(i * 16, j * 16, 48, 48, 2699);
for (int index5 = 0; index5 < 3; ++index5)
{
for (int index6 = 0; index6 < 3; ++index6)
{
int i1 = num6 + index5;
int j1 = num2 + index6;
if (Main.tile[i1, j1].active() && Main.tile[i1, j1].type == (ushort) 334)
WorldGen.KillTile(i1, j1);
}
}
WorldGen.destroyObject = false;
}
public static void ToggleGemLock(int i, int j, bool on)
{
Tile tileSafely = Framing.GetTileSafely(i, j);
if (!tileSafely.active() || tileSafely.type != (ushort) 440 || tileSafely.frameY < (short) 54 && !on)
return;
bool flag = false;
int Type = -1;
if (tileSafely.frameY >= (short) 54)
flag = true;
int num1 = (int) Main.tile[i, j].frameX / 54;
int num2 = (int) Main.tile[i, j].frameX % 54 / 18;
int num3 = (int) Main.tile[i, j].frameY % 54 / 18;
switch (num1)
{
case 0:
Type = 1526;
break;
case 1:
Type = 1524;
break;
case 2:
Type = 1525;
break;
case 3:
Type = 1523;
break;
case 4:
Type = 1522;
break;
case 5:
Type = 1527;
break;
case 6:
Type = 3643;
break;
}
for (int index1 = i - num2; index1 < i - num2 + 3; ++index1)
{
for (int index2 = j - num3; index2 < j - num3 + 3; ++index2)
Main.tile[index1, index2].frameY = (short) ((on ? 54 : 0) + (index2 - j + num3) * 18);
}
if (Type != -1 & flag)
Item.NewItem(i * 16, j * 16, 32, 32, Type);
WorldGen.SquareTileFrame(i, j);
NetMessage.SendTileSquare(-1, i - num2 + 1, j - num3 + 1, 3);
Wiring.HitSwitch(i - num2, j - num3);
NetMessage.SendData(59, number: (i - num2), number2: ((float) (j - num3)));
}
public static void CheckMan(int i, int j)
{
if (WorldGen.destroyObject)
return;
int num1 = i;
int num2 = j - (int) Main.tile[i, j].frameY / 18;
int frameX1 = (int) Main.tile[i, j].frameX;
while (frameX1 >= 100)
frameX1 -= 100;
while (frameX1 >= 36)
frameX1 -= 36;
int i1 = num1 - frameX1 / 18;
bool flag = false;
for (int index1 = 0; index1 <= 1; ++index1)
{
for (int index2 = 0; index2 <= 2; ++index2)
{
int index3 = i1 + index1;
int index4 = num2 + index2;
int frameX2 = (int) Main.tile[index3, index4].frameX;
while (frameX2 >= 100)
frameX2 -= 100;
if (frameX2 >= 36)
frameX2 -= 36;
if (!Main.tile[index3, index4].active() || Main.tile[index3, index4].type != (ushort) 128 || (int) Main.tile[index3, index4].frameY != index2 * 18 || frameX2 != index1 * 18)
flag = true;
}
}
if (!WorldGen.SolidTileAllowBottomSlope(i1, num2 + 3) || !WorldGen.SolidTileAllowBottomSlope(i1 + 1, num2 + 3))
flag = true;
if (!flag)
return;
WorldGen.destroyObject = true;
Item.NewItem(i * 16, j * 16, 32, 32, 498);
for (int index5 = 0; index5 <= 1; ++index5)
{
for (int index6 = 0; index6 <= 2; ++index6)
{
int i2 = i1 + index5;
int j1 = num2 + index6;
if (Main.tile[i2, j1].active() && Main.tile[i2, j1].type == (ushort) 128)
WorldGen.KillTile(i2, j1);
}
}
WorldGen.destroyObject = false;
}
public static void CheckWoman(int i, int j)
{
if (WorldGen.destroyObject)
return;
int num1 = i;
int num2 = j - (int) Main.tile[i, j].frameY / 18;
int frameX1 = (int) Main.tile[i, j].frameX;
while (frameX1 >= 100)
frameX1 -= 100;
while (frameX1 >= 36)
frameX1 -= 36;
int i1 = num1 - frameX1 / 18;
bool flag = false;
for (int index1 = 0; index1 <= 1; ++index1)
{
for (int index2 = 0; index2 <= 2; ++index2)
{
int index3 = i1 + index1;
int index4 = num2 + index2;
int frameX2 = (int) Main.tile[index3, index4].frameX;
while (frameX2 >= 100)
frameX2 -= 100;
if (frameX2 >= 36)
frameX2 -= 36;
if (!Main.tile[index3, index4].active() || Main.tile[index3, index4].type != (ushort) 269 || (int) Main.tile[index3, index4].frameY != index2 * 18 || frameX2 != index1 * 18)
flag = true;
}
}
if (!WorldGen.SolidTileAllowBottomSlope(i1, num2 + 3) || !WorldGen.SolidTileAllowBottomSlope(i1 + 1, num2 + 3))
flag = true;
if (!flag)
return;
WorldGen.destroyObject = true;
Item.NewItem(i * 16, j * 16, 32, 32, 1989);
for (int index5 = 0; index5 <= 1; ++index5)
{
for (int index6 = 0; index6 <= 2; ++index6)
{
int i2 = i1 + index5;
int j1 = num2 + index6;
if (Main.tile[i2, j1].active() && Main.tile[i2, j1].type == (ushort) 269)
WorldGen.KillTile(i2, j1);
}
}
WorldGen.destroyObject = false;
}
public static void Place1x2(int x, int y, ushort type, int style)
{
short num1 = 0;
if (type == (ushort) 20)
num1 = (short) (WorldGen.genRand.Next(3) * 18);
if (Main.tile[x, y - 1] == null)
Main.tile[x, y - 1] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (!(WorldGen.SolidTile2(x, y + 1) & !Main.tile[x, y - 1].active()))
return;
short num2 = (short) (style * 40);
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameY = num2;
Main.tile[x, y - 1].frameX = num1;
Main.tile[x, y - 1].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) ((int) num2 + 18);
Main.tile[x, y].frameX = num1;
Main.tile[x, y].type = type;
}
public static void Place1x2Top(int x, int y, ushort type, int style)
{
short num1 = 0;
if (Main.tile[x, y - 1] == null)
Main.tile[x, y - 1] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (!Main.tile[x, y - 1].nactive() || !Main.tileSolid[(int) Main.tile[x, y - 1].type] || Main.tileSolidTop[(int) Main.tile[x, y - 1].type] || Main.tile[x, y + 1].active())
return;
short num2 = (short) (style * 36);
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = num2;
Main.tile[x, y].frameX = num1;
Main.tile[x, y].type = type;
Main.tile[x, y + 1].active(true);
Main.tile[x, y + 1].frameY = (short) ((int) num2 + 18);
Main.tile[x, y + 1].frameX = num1;
Main.tile[x, y + 1].type = type;
}
public static void Check1x2Top(int x, int j, ushort type)
{
if (WorldGen.destroyObject)
return;
int index = j;
bool flag = true;
int num1 = (int) Main.tile[x, index].frameY / 18;
int num2 = 0;
while (num1 >= 2)
{
num1 -= 2;
++num2;
}
int j1 = index - num1;
int num3 = num2 * 36;
if (Main.tile[x, j1] == null)
Main.tile[x, j1] = new Tile();
if (Main.tile[x, j1 + 1] == null)
Main.tile[x, j1 + 1] = new Tile();
if (Main.tile[x, j1] == null)
Main.tile[x, j1] = new Tile();
if ((int) Main.tile[x, j1].frameY == num3 && (int) Main.tile[x, j1 + 1].frameY == num3 + 18 && (int) Main.tile[x, j1].type == (int) type && (int) Main.tile[x, j1 + 1].type == (int) type)
flag = false;
if (Main.tile[x, j1 - 1] == null)
Main.tile[x, j1 - 1] = new Tile();
if (!Main.tile[x, j1 - 1].nactive() || !Main.tileSolid[(int) Main.tile[x, j1 - 1].type] || Main.tileSolidTop[(int) Main.tile[x, j1 - 1].type])
flag = true;
if (!flag)
return;
WorldGen.destroyObject = true;
if ((int) Main.tile[x, j1].type == (int) type)
WorldGen.KillTile(x, j1);
if ((int) Main.tile[x, j1 + 1].type == (int) type)
WorldGen.KillTile(x, j1 + 1);
switch (type)
{
case 42:
int Type = 0;
switch (num2)
{
case 0:
Type = 136;
break;
case 7:
Type = 1431;
break;
case 8:
Type = 1808;
break;
case 9:
Type = 1859;
break;
default:
if (num2 < 10)
{
Type = 1389 + num2;
break;
}
switch (num2)
{
case 10:
Type = 2032;
break;
case 11:
Type = 2033;
break;
case 12:
Type = 2034;
break;
case 13:
Type = 2035;
break;
case 14:
Type = 2036;
break;
case 15:
Type = 2037;
break;
case 16:
Type = 2038;
break;
case 17:
Type = 2039;
break;
case 18:
Type = 2040;
break;
case 19:
Type = 2041;
break;
case 20:
Type = 2042;
break;
case 21:
Type = 2043;
break;
default:
if (num2 >= 22 && num2 <= 25)
{
Type = 2145 + num2 - 22;
break;
}
switch (num2)
{
case 26:
Type = 2226;
break;
case 27:
Type = 2530;
break;
case 28:
Type = 2546;
break;
case 29:
Type = 2564;
break;
case 30:
Type = 2579;
break;
case 31:
Type = 2641;
break;
case 32:
Type = 2642;
break;
case 33:
Type = 2820;
break;
case 34:
Type = 3138;
break;
case 35:
Type = 3140;
break;
case 36:
Type = 3139;
break;
case 37:
Type = 3891;
break;
}
break;
}
break;
}
Item.NewItem(x * 16, j1 * 16, 32, 32, Type);
break;
case 270:
Item.NewItem(x * 16, j1 * 16, 32, 32, 1993);
break;
case 271:
Item.NewItem(x * 16, j1 * 16, 32, 32, 2005);
break;
}
WorldGen.destroyObject = false;
}
public static bool PlaceSmallPile(int i, int j, int X, int Y, ushort type = 185)
{
int i1 = i;
int index = j;
short num1 = (short) (Y * 18);
short num2 = (short) (X * 18);
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (Main.tile[i1 + 1, index] == null)
Main.tile[i1 + 1, index] = new Tile();
if (Main.tile[i1, index + 1] == null)
Main.tile[i1, index + 1] = new Tile();
if (Main.tile[i1 + 1, index + 1] == null)
Main.tile[i1 + 1, index + 1] = new Tile();
if (Main.tile[i1, index].lava())
return false;
if (Y == 1)
{
short num3 = (short) (X * 36);
bool flag = false;
if (WorldGen.SolidTile2(i1, index + 1) && WorldGen.SolidTile2(i1 + 1, index + 1) && !Main.tile[i1, index].active() && !Main.tile[i1 + 1, index].active())
flag = true;
if (flag)
{
Main.tile[i1, index].active(true);
Main.tile[i1, index].frameY = num1;
Main.tile[i1, index].frameX = num3;
Main.tile[i1, index].type = type;
Main.tile[i1 + 1, index].active(true);
Main.tile[i1 + 1, index].frameY = num1;
Main.tile[i1 + 1, index].frameX = (short) ((int) num3 + 18);
Main.tile[i1 + 1, index].type = type;
return true;
}
}
else if (WorldGen.SolidTile2(i1, index + 1) && !Main.tile[i1, index].active())
{
Main.tile[i1, index].active(true);
Main.tile[i1, index].frameY = num1;
Main.tile[i1, index].frameX = num2;
Main.tile[i1, index].type = type;
return true;
}
return false;
}
public static void CheckPile(int i, int y)
{
int i1 = i;
if (Main.tile[i1, y] == null)
Main.tile[i1, y] = new Tile();
if (Main.tile[i1 + 1, y] == null)
Main.tile[i1 + 1, y] = new Tile();
if (Main.tile[i1, y + 1] == null)
Main.tile[i1, y + 1] = new Tile();
if (Main.tile[i1 + 1, y + 1] == null)
Main.tile[i1 + 1, y + 1] = new Tile();
if (Main.tile[i1, y].frameY == (short) 18)
{
WorldGen.Check2x1(i1, y, Main.tile[i1, y].type);
}
else
{
if (WorldGen.SolidTile(i1, y + 1))
return;
WorldGen.KillTile(i1, y);
}
}
public static void Check2x1(int i, int y, ushort type)
{
if (WorldGen.destroyObject)
return;
int index = i;
bool flag = true;
if (Main.tile[index, y] == null)
Main.tile[index, y] = new Tile();
int num1 = (int) Main.tile[index, y].frameX / 18;
int num2 = num1 >> 1;
int num3 = num1 % 2;
int i1 = index - num3;
if (Main.tile[i1, y] == null)
Main.tile[i1, y] = new Tile();
if (Main.tile[i1 + 1, y] == null)
Main.tile[i1 + 1, y] = new Tile();
if (Main.tile[i1, y + 1] == null)
Main.tile[i1, y + 1] = new Tile();
if (Main.tile[i1 + 1, y + 1] == null)
Main.tile[i1 + 1, y + 1] = new Tile();
if ((int) Main.tile[i1 + 1, y].frameX == (int) Main.tile[i1, y].frameX + 18 && (int) Main.tile[i1, y].type == (int) type && (int) Main.tile[i1 + 1, y].type == (int) type)
flag = false;
if (type == (ushort) 29 || type == (ushort) 103 || type == (ushort) 462)
{
if (!Main.tile[i1, y + 1].active() || !Main.tileTable[(int) Main.tile[i1, y + 1].type])
flag = true;
if (!Main.tile[i1 + 1, y + 1].active() || !Main.tileTable[(int) Main.tile[i1 + 1, y + 1].type])
flag = true;
}
else
{
if (!WorldGen.SolidTileAllowBottomSlope(i1, y + 1))
flag = true;
if (!WorldGen.SolidTileAllowBottomSlope(i1 + 1, y + 1))
flag = true;
}
if (type == (ushort) 185 && Main.tile[i1, y].frameX >= (short) 1368 && Main.tile[i1, y].frameX <= (short) 1458 && Main.tile[i1, y + 1].type != (ushort) 2 && Main.tile[i1 + 1, y + 1].type != (ushort) 2)
{
Main.tile[i1, y].frameX -= (short) 1368;
Main.tile[i1 + 1, y].frameX -= (short) 1368;
}
if (!flag)
return;
int frameX = (int) Main.tile[i1, y].frameX;
if (!Main.tile[i1, y].active())
frameX = (int) Main.tile[i1 + 1, y].frameX;
WorldGen.destroyObject = true;
if ((int) Main.tile[i1, y].type == (int) type)
WorldGen.KillTile(i1, y);
if ((int) Main.tile[i1 + 1, y].type == (int) type)
WorldGen.KillTile(i1 + 1, y);
if (type == (ushort) 16)
{
if (num2 == 1)
Item.NewItem(i1 * 16, y * 16, 32, 32, 716);
else
Item.NewItem(i1 * 16, y * 16, 32, 32, 35);
}
if (type == (ushort) 18)
{
int Type = 36;
if (num2 >= 1 && num2 <= 3)
Type = 634 + num2;
else if (num2 >= 4 && num2 <= 8)
{
Type = 807 + num2;
}
else
{
switch (num2)
{
case 9:
Type = 916;
break;
case 10:
Type = 1145;
break;
case 11:
Type = 1398;
break;
case 12:
Type = 1401;
break;
case 13:
Type = 1404;
break;
case 14:
Type = 1461;
break;
case 15:
Type = 1511;
break;
case 16:
Type = 1795;
break;
case 17:
Type = 1817;
break;
case 18:
Type = 2229;
break;
case 19:
Type = 2251;
break;
case 20:
Type = 2252;
break;
case 21:
Type = 2253;
break;
case 22:
Type = 2534;
break;
case 23:
Type = 673;
break;
case 24:
Type = 2631;
break;
case 25:
Type = 2632;
break;
case 26:
Type = 2633;
break;
case 27:
Type = 2826;
break;
case 28:
Type = 3156;
break;
case 29:
Type = 3158;
break;
case 30:
Type = 3157;
break;
case 31:
Type = 3909;
break;
case 32:
Type = 3910;
break;
}
}
Item.NewItem(i1 * 16, y * 16, 32, 32, Type);
}
if (type == (ushort) 185)
{
if (frameX >= 576 && frameX <= 610)
{
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(10, 100));
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(3) != 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(10, 100));
if (WorldGen.genRand.Next(3) != 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(10, 100));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(10, 100));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(4) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(10, 100));
if (WorldGen.genRand.Next(4) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(5) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(10, 100));
if (WorldGen.genRand.Next(5) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
}
if (frameX >= 612 && frameX <= 646)
{
Item.NewItem(i1 * 16, y * 16, 32, 32, 72, WorldGen.genRand.Next(10, 100));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 72, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 72, WorldGen.genRand.Next(30, 100));
}
if (frameX >= 648 && frameX <= 682)
{
Item.NewItem(i1 * 16, y * 16, 32, 32, 73, WorldGen.genRand.Next(1, 6));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 73, WorldGen.genRand.Next(2, 6));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i1 * 16, y * 16, 32, 32, 73, WorldGen.genRand.Next(3, 6));
}
if (frameX >= 684 && frameX <= 718)
Item.NewItem(i1 * 16, y * 16, 32, 32, 181, WorldGen.genRand.Next(1, 4));
if (frameX >= 720 && frameX <= 754)
Item.NewItem(i1 * 16, y * 16, 32, 32, 180, WorldGen.genRand.Next(1, 4));
if (frameX >= 756 && frameX <= 790)
Item.NewItem(i1 * 16, y * 16, 32, 32, 177, WorldGen.genRand.Next(1, 4));
if (frameX >= 792 && frameX <= 826)
Item.NewItem(i1 * 16, y * 16, 32, 32, 179, WorldGen.genRand.Next(1, 4));
if (frameX >= 828 && frameX <= 862)
Item.NewItem(i1 * 16, y * 16, 32, 32, 178, WorldGen.genRand.Next(1, 4));
if (frameX >= 864 && frameX <= 898)
Item.NewItem(i1 * 16, y * 16, 32, 32, 182, WorldGen.genRand.Next(1, 4));
}
if (type == (ushort) 462)
Item.NewItem(i1 * 16, y * 16, 32, 32, 3795);
if (type == (ushort) 29)
{
Item.NewItem(i1 * 16, y * 16, 32, 32, 87);
Main.PlaySound(13, i * 16, y * 16);
}
if (type == (ushort) 103)
{
int Type = 356;
if (num2 == 1)
Type = 2235;
if (num2 == 2)
Type = 2242;
if (num2 == 3)
Type = 2243;
Item.NewItem(i1 * 16, y * 16, 32, 32, Type);
Main.PlaySound(13, i * 16, y * 16);
}
else if (type == (ushort) 134)
{
if (num2 == 1)
Item.NewItem(i1 * 16, y * 16, 32, 32, 1220);
else
Item.NewItem(i1 * 16, y * 16, 32, 32, 525);
}
WorldGen.destroyObject = false;
WorldGen.SquareTileFrame(i1, y);
WorldGen.SquareTileFrame(i1 + 1, y);
}
public static void Place2x1(int x, int y, ushort type, int style = 0)
{
if (Main.tile[x, y] == null)
Main.tile[x, y] = new Tile();
if (Main.tile[x + 1, y] == null)
Main.tile[x + 1, y] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (Main.tile[x + 1, y + 1] == null)
Main.tile[x + 1, y + 1] = new Tile();
bool flag = false;
if (type != (ushort) 29 && type != (ushort) 103 && WorldGen.SolidTile2(x, y + 1) && WorldGen.SolidTile2(x + 1, y + 1) && !Main.tile[x, y].active() && !Main.tile[x + 1, y].active())
flag = true;
else if ((type == (ushort) 29 || type == (ushort) 103) && Main.tile[x, y + 1].active() && Main.tile[x + 1, y + 1].active() && Main.tileTable[(int) Main.tile[x, y + 1].type] && Main.tileTable[(int) Main.tile[x + 1, y + 1].type] && !Main.tile[x, y].active() && !Main.tile[x + 1, y].active())
flag = true;
if (!flag)
return;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y].frameX = (short) (36 * style);
Main.tile[x, y].type = type;
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].frameY = (short) 0;
Main.tile[x + 1, y].frameX = (short) (36 * style + 18);
Main.tile[x + 1, y].type = type;
}
public static void Check4x2(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = i + (int) Main.tile[i, j].frameX / 18 * -1;
if ((type == 79 || type == 90) && Main.tile[i, j].frameX >= (short) 72)
num1 += 4;
int num2 = (int) Main.tile[i, j].frameY / 18;
int num3 = 0;
while (num2 > 1)
{
num2 -= 2;
++num3;
}
int num4 = j - num2;
for (int i1 = num1; i1 < num1 + 4; ++i1)
{
for (int index = num4; index < num4 + 2; ++index)
{
int num5 = (i1 - num1) * 18;
if ((type == 79 || type == 90) && Main.tile[i, j].frameX >= (short) 72)
num5 = (i1 - num1 + 4) * 18;
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != num5 || (int) Main.tile[i1, index].frameY != (index - num4) * 18 + num3 * 36)
flag = true;
}
if (Main.tile[i1, num4 + 2] == null)
Main.tile[i1, num4 + 2] = new Tile();
if (!WorldGen.SolidTileAllowBottomSlope(i1, num4 + 2) && (!Main.tile[i1, num4 + 2].active() || !TileID.Sets.Platforms[(int) Main.tile[i1, num4 + 2].type]))
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i2 = num1; i2 < num1 + 4; ++i2)
{
for (int j1 = num4; j1 < num4 + 3; ++j1)
{
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
if (type == 79)
{
int Type = num3 != 0 ? (num3 != 4 ? (num3 < 9 || num3 > 12 ? (num3 < 5 || num3 > 8 ? (num3 < 13 || num3 > 18 ? (num3 != 19 ? (num3 != 20 ? (num3 != 21 ? (num3 != 22 ? (num3 != 23 ? (num3 != 24 ? (num3 != 25 ? (num3 != 26 ? (num3 != 27 ? (num3 != 28 ? (num3 != 29 ? (num3 != 30 ? (num3 != 31 ? num3 + 643 : 3897) : 3163) : 3164) : 3162) : 2811) : 2669) : 2568) : 2553) : 2538) : 2520) : 2231) : 2140) : 2139) : 2066 + num3 - 13) : 1465 + num3) : 1710 + num3) : 920) : 224;
Item.NewItem(i * 16, j * 16, 32, 32, Type);
}
if (type == 90)
{
int Type = 0;
if (num3 == 0)
Type = 336;
else if (num3 >= 1 && num3 <= 10)
Type = 2072 + num3 - 1;
else if (num3 >= 11 && num3 <= 15)
{
Type = 2124 + num3 - 11;
}
else
{
switch (num3)
{
case 16:
Type = 2232;
break;
case 17:
Type = 2519;
break;
case 18:
Type = 2537;
break;
case 19:
Type = 2552;
break;
case 20:
Type = 2567;
break;
case 21:
Type = 2658;
break;
case 22:
Type = 2659;
break;
case 23:
Type = 2660;
break;
case 24:
Type = 2661;
break;
case 25:
Type = 2662;
break;
case 26:
Type = 2663;
break;
case 27:
Type = 2810;
break;
case 28:
Type = 3159;
break;
case 29:
Type = 3161;
break;
case 30:
Type = 3160;
break;
case 31:
Type = 3895;
break;
}
}
Item.NewItem(i * 16, j * 16, 32, 32, Type);
}
WorldGen.destroyObject = false;
for (int i3 = num1 - 1; i3 < num1 + 4; ++i3)
{
for (int j2 = num4 - 1; j2 < num4 + 4; ++j2)
WorldGen.TileFrame(i3, j2);
}
}
public static void PlaceJunglePlant(int X2, int Y2, ushort type, int styleX, int styleY)
{
if (styleY > 0 || type == (ushort) 236 || type == (ushort) 238)
{
int index1 = Y2;
int index2 = X2;
if (type == (ushort) 95 || type == (ushort) 126)
++index1;
if (X2 < 5 || X2 > Main.maxTilesX - 5 || index1 < 5 || index1 > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = index2 - 1; i < index2 + 1; ++i)
{
for (int index3 = index1 - 1; index3 < index1 + 1; ++index3)
{
if (Main.tile[i, index3] == null)
Main.tile[i, index3] = new Tile();
if (Main.tile[i, index3].active() && Main.tile[i, index3].type != (ushort) 61 && Main.tile[i, index3].type != (ushort) 62 && Main.tile[i, index3].type != (ushort) 69 && Main.tile[i, index3].type != (ushort) 74 && (type != (ushort) 236 || Main.tile[i, index3].type != (ushort) 233) && (type != (ushort) 238 || Main.tile[i, index3].type != (ushort) 233) && (Main.tile[i, index3].type != (ushort) 185 || Main.tile[i, index3].frameY != (short) 0))
flag = false;
if (type == (ushort) 98 && Main.tile[i, index3].liquid > (byte) 0)
flag = false;
}
if (Main.tile[i, index1 + 1] == null)
Main.tile[i, index1 + 1] = new Tile();
if (!WorldGen.SolidTile(i, index1 + 1) || Main.tile[i, index1 + 1].type != (ushort) 60)
flag = false;
}
if (!flag)
return;
short num1 = 36;
if (type == (ushort) 236 || type == (ushort) 238)
num1 = (short) 0;
short num2 = (short) (36 * styleX);
Main.tile[index2 - 1, index1 - 1].active(true);
Main.tile[index2 - 1, index1 - 1].frameY = num1;
Main.tile[index2 - 1, index1 - 1].frameX = num2;
Main.tile[index2 - 1, index1 - 1].type = type;
Main.tile[index2, index1 - 1].active(true);
Main.tile[index2, index1 - 1].frameY = num1;
Main.tile[index2, index1 - 1].frameX = (short) (18 + (int) num2);
Main.tile[index2, index1 - 1].type = type;
Main.tile[index2 - 1, index1].active(true);
Main.tile[index2 - 1, index1].frameY = (short) ((int) num1 + 18);
Main.tile[index2 - 1, index1].frameX = num2;
Main.tile[index2 - 1, index1].type = type;
Main.tile[index2, index1].active(true);
Main.tile[index2, index1].frameY = (short) ((int) num1 + 18);
Main.tile[index2, index1].frameX = (short) (18 + (int) num2);
Main.tile[index2, index1].type = type;
}
else
{
int num3 = styleX;
int index4 = X2;
int index5 = Y2;
if (index4 < 5 || index4 > Main.maxTilesX - 5 || index5 < 5 || index5 > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = index4 - 1; i < index4 + 2; ++i)
{
for (int index6 = index5 - 1; index6 < index5 + 1; ++index6)
{
if (Main.tile[i, index6] == null)
Main.tile[i, index6] = new Tile();
if (Main.tile[i, index6].active() && Main.tile[i, index6].type != (ushort) 61 && Main.tile[i, index6].type != (ushort) 62 && Main.tile[i, index6].type != (ushort) 69 && Main.tile[i, index6].type != (ushort) 74 && (Main.tile[i, index6].type != (ushort) 185 || Main.tile[i, index6].frameY != (short) 0))
flag = false;
}
if (Main.tile[i, index5 + 1] == null)
Main.tile[i, index5 + 1] = new Tile();
if (!WorldGen.SolidTile(i, index5 + 1) || Main.tile[i, index5 + 1].type != (ushort) 60)
flag = false;
}
if (!flag)
return;
short num4 = (short) (54 * num3);
Main.tile[index4 - 1, index5 - 1].active(true);
Main.tile[index4 - 1, index5 - 1].frameY = (short) 0;
Main.tile[index4 - 1, index5 - 1].frameX = num4;
Main.tile[index4 - 1, index5 - 1].type = type;
Main.tile[index4, index5 - 1].active(true);
Main.tile[index4, index5 - 1].frameY = (short) 0;
Main.tile[index4, index5 - 1].frameX = (short) ((int) num4 + 18);
Main.tile[index4, index5 - 1].type = type;
Main.tile[index4 + 1, index5 - 1].active(true);
Main.tile[index4 + 1, index5 - 1].frameY = (short) 0;
Main.tile[index4 + 1, index5 - 1].frameX = (short) ((int) num4 + 36);
Main.tile[index4 + 1, index5 - 1].type = type;
Main.tile[index4 - 1, index5].active(true);
Main.tile[index4 - 1, index5].frameY = (short) 18;
Main.tile[index4 - 1, index5].frameX = num4;
Main.tile[index4 - 1, index5].type = type;
Main.tile[index4, index5].active(true);
Main.tile[index4, index5].frameY = (short) 18;
Main.tile[index4, index5].frameX = (short) ((int) num4 + 18);
Main.tile[index4, index5].type = type;
Main.tile[index4 + 1, index5].active(true);
Main.tile[index4 + 1, index5].frameY = (short) 18;
Main.tile[index4 + 1, index5].frameX = (short) ((int) num4 + 36);
Main.tile[index4 + 1, index5].type = type;
}
}
public static void CheckJunglePlant(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
if (Main.tile[i, j].frameY >= (short) 36 || Main.tile[i, j].type == (ushort) 236 || Main.tile[i, j].type == (ushort) 238)
{
bool flag = false;
int num1 = (int) Main.tile[i, j].frameX / 18;
int num2 = 0;
while (num1 > 1)
{
num1 -= 2;
++num2;
}
int num3 = i - num1;
int num4 = 36;
if (type == 236 || type == 238)
num4 = 0;
int num5 = (int) Main.tile[i, j].frameY / 18;
while (num5 > 1)
num5 -= 2;
int num6 = j - num5;
int num7 = num2 * 36;
for (int i1 = num3; i1 < num3 + 2; ++i1)
{
for (int index = num6; index < num6 + 2; ++index)
{
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != (i1 - num3) * 18 + num7 || (int) Main.tile[i1, index].frameY != (index - num6) * 18 + num4)
flag = true;
}
if (Main.tile[i1, num6 + 2] == null)
Main.tile[i1, num6 + 2] = new Tile();
if (!WorldGen.SolidTile(i1, num6 + 2) || Main.tile[i1, num6 + 2].type != (ushort) 60)
flag = true;
}
if (!flag)
return;
if (type == 238)
{
float num8 = (float) (i * 16);
float num9 = (float) (j * 16);
float num10 = -1f;
int plr = 0;
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
float num11 = Math.Abs(Main.player[index].position.X - num8) + Math.Abs(Main.player[index].position.Y - num9);
if ((double) num11 < (double) num10 || (double) num10 == -1.0)
{
plr = index;
num10 = num11;
}
}
if ((double) num10 / 16.0 < 50.0)
NPC.SpawnOnPlayer(plr, 262);
}
if (type == 236)
Item.NewItem(i * 16, j * 16, 32, 32, 1291);
int frameX = (int) Main.tile[i, j].frameX;
WorldGen.destroyObject = true;
for (int i2 = num3; i2 < num3 + 2; ++i2)
{
for (int j1 = num6; j1 < num6 + 2; ++j1)
{
if (Main.tile[i2, j1] == null)
Main.tile[i2, j1] = new Tile();
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
}
else
{
bool flag = false;
int num12 = j + (int) Main.tile[i, j].frameY / 18 * -1;
int num13 = (int) Main.tile[i, j].frameX / 18;
int num14 = 0;
while (num13 > 2)
{
num13 -= 3;
++num14;
}
int num15 = i - num13;
int num16 = num14 * 54;
for (int i3 = num15; i3 < num15 + 3; ++i3)
{
for (int index = num12; index < num12 + 2; ++index)
{
if (Main.tile[i3, index] == null)
Main.tile[i3, index] = new Tile();
if (!Main.tile[i3, index].active() || (int) Main.tile[i3, index].type != type || (int) Main.tile[i3, index].frameX != (i3 - num15) * 18 + num16 || (int) Main.tile[i3, index].frameY != (index - num12) * 18)
flag = true;
}
if (Main.tile[i3, num12 + 2] == null)
Main.tile[i3, num12 + 2] = new Tile();
if (!WorldGen.SolidTile(i3, num12 + 2) || Main.tile[i3, num12 + 2].type != (ushort) 60)
flag = true;
}
if (!flag)
return;
int frameX = (int) Main.tile[i, j].frameX;
WorldGen.destroyObject = true;
for (int i4 = num15; i4 < num15 + 3; ++i4)
{
for (int j2 = num12; j2 < num12 + 3; ++j2)
{
if (Main.tile[i4, j2] == null)
Main.tile[i4, j2] = new Tile();
if ((int) Main.tile[i4, j2].type == type && Main.tile[i4, j2].active())
WorldGen.KillTile(i4, j2);
}
}
}
}
public static void CheckSuper(int x, int y, int type)
{
if (WorldGen.destroyObject)
return;
Tile tile = Main.tile[x, y];
int style = 0;
if (type == 376)
style = (int) tile.frameX / 36;
if (type == 443)
style = (int) tile.frameX / 36;
bool flag1 = type == 376;
bool flag2 = type == 443;
bool flag3 = type == 444;
TileObjectData tileData = TileObjectData.GetTileData(type, style);
int num1 = tileData.StyleHorizontal ? 1 : 0;
int width = tileData.Width;
int height = tileData.Height;
int num2 = x;
int num3 = y;
int num4 = num2 - (int) tile.frameX / 18 % width;
int j = num3 - (int) tile.frameY / 18 % height;
int num5 = 0;
int num6 = 0;
if (num1 != 0)
num5 = (int) tile.frameX / tileData.CoordinateFullWidth;
else
num6 = (int) tile.frameY / tileData.CoordinateFullHeight;
bool flag4 = false;
bool flag5 = false;
for (int index1 = 0; index1 < width; ++index1)
{
for (int index2 = 0; index2 < height; ++index2)
{
Tile tileSafely = Framing.GetTileSafely(num4 + index1, j + index2);
if (!tileSafely.active() || (int) tileSafely.type != type || (int) tileSafely.frameX != num5 * tileData.CoordinateFullWidth + index1 * (tileData.CoordinateWidth + 2) || (int) tileSafely.frameY != num6 * tileData.CoordinateFullHeight + index2 * (tileData.CoordinateHeights[0] + 2))
flag4 = true;
}
}
if (flag1)
{
for (int index = 0; index < width; ++index)
{
Tile tileSafely = Framing.GetTileSafely(num4 + index, j + height);
if (!tileSafely.active() || !Main.tileSolid[(int) tileSafely.type] && !Main.tileTable[(int) tileSafely.type])
flag4 = true;
if (tileSafely.halfBrick())
flag4 = true;
}
}
if (flag2)
{
bool flag6 = true;
bool flag7 = true;
for (int index = 0; index < width; ++index)
{
if (!WorldGen.AnchorValid(Framing.GetTileSafely(num4 + index, j + height), AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide))
flag7 = false;
if (!WorldGen.AnchorValid(Framing.GetTileSafely(num4 + index, j - 1), AnchorType.SolidBottom))
flag6 = false;
}
if (!flag6 && !flag7)
flag4 = true;
if (!flag4)
{
int num7 = 0;
if (Main.netMode != 1)
{
if (flag7)
{
for (int index = 0; index < width; ++index)
Framing.GetTileSafely(num4 + index, j).frameX = (short) (index * 18 + style / 2 * 36 + num7 * 36);
}
else
{
for (int index = 0; index < width; ++index)
Framing.GetTileSafely(num4 + index, j).frameX = (short) (index * 18 + (style - 2) / 2 * 36 + 72 + num7 * 36);
}
}
}
}
if (flag3)
{
bool flag8 = true;
for (int index = 0; index < width; ++index)
{
if (!WorldGen.AnchorValid(Framing.GetTileSafely(num4 + index, j - 1), AnchorType.SolidTile))
flag8 = false;
}
if (!flag8)
flag4 = true;
for (int index3 = 0; index3 < width; ++index3)
{
for (int index4 = 0; index4 < height; ++index4)
{
if (Framing.GetTileSafely(num4 + index3, j + index4).liquid > (byte) 0)
{
flag4 = true;
flag5 = true;
}
}
}
}
if (!flag4)
return;
WorldGen.destroyObject = true;
for (int index5 = 0; index5 < width; ++index5)
{
for (int index6 = 0; index6 < height; ++index6)
{
if ((int) Main.tile[num4 + index5, j + index6].type == type && Main.tile[num4 + index5, j + index6].active())
WorldGen.KillTile(num4 + index5, j + index6);
}
}
int Type = 0;
if (type == 376)
Type = style <= 2 ? 2334 + style : 3203 + style - 3;
if (type == 443)
Type = 3722;
if (type == 444 && Main.netMode != 1 && !flag5)
Projectile.NewProjectile((float) (num4 * 16 + 16), (float) (j * 16 + 16), 0.0f, 0.0f, 655, 0, 0.0f, Main.myPlayer);
if (Type != 0)
Item.NewItem(num4 * 16, j * 16, tileData.CoordinateFullWidth, tileData.CoordinateFullHeight, Type);
WorldGen.destroyObject = false;
for (int index7 = -1; index7 < width + 1; ++index7)
{
for (int index8 = -1; index8 < height + 1; ++index8)
WorldGen.TileFrame(num4 + index7, j + index8);
}
}
public static void Check2x2(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag1 = false;
int num1 = 0;
int num2 = (int) Main.tile[i, j].frameX / 18 * -1;
if (num2 < -1)
{
num2 += 2;
num1 = 36;
}
int i1 = num2 + i;
int num3 = type == 172 ? 38 : 36;
int frameY = (int) Main.tile[i, j].frameY;
int num4 = 0;
while (frameY >= num3)
{
frameY -= num3;
++num4;
}
int index1 = j - frameY / 18;
for (int i2 = i1; i2 < i1 + 2; ++i2)
{
for (int j1 = index1; j1 < index1 + 2; ++j1)
{
Tile tileSafely = Framing.GetTileSafely(i2, j1);
if (!tileSafely.active() || (int) tileSafely.type != type || (int) tileSafely.frameX != (i2 - i1) * 18 + num1 || (int) tileSafely.frameY != (j1 - index1) * 18 + num4 * num3)
flag1 = true;
}
switch (type)
{
case 95:
case 126:
Framing.GetTileSafely(i2, index1 - 1);
if (!Main.tile[i2, index1 - 1].active() || !Main.tileSolid[(int) Main.tile[i2, index1 - 1].type] || Main.tileSolidTop[(int) Main.tile[i2, index1 - 1].type])
{
flag1 = true;
continue;
}
continue;
case 132:
case 138:
continue;
default:
Tile tileSafely1 = Framing.GetTileSafely(i2, index1 + 2);
if (!tileSafely1.active() || !Main.tileSolid[(int) tileSafely1.type] && !Main.tileTable[(int) tileSafely1.type])
flag1 = true;
if (tileSafely1.halfBrick())
{
flag1 = true;
continue;
}
continue;
}
}
switch (type)
{
case 132:
flag1 = false;
index1 = (int) Main.tile[i, j].frameY / 18 * -1 + j;
int num5 = 0;
int num6 = (int) Main.tile[i, j].frameX / 18 * -1;
while (num6 < -1)
{
num6 += 2;
num5 += 36;
}
i1 = num6 + i;
for (int index2 = i1; index2 < i1 + 2; ++index2)
{
for (int index3 = index1; index3 < index1 + 2; ++index3)
{
if (Main.tile[index2, index3] == null)
Main.tile[index2, index3] = new Tile();
if (!Main.tile[index2, index3].active() || (int) Main.tile[index2, index3].type != type || (int) Main.tile[index2, index3].frameX != (index2 - i1) * 18 + num5 || (int) Main.tile[index2, index3].frameY != (index3 - index1) * 18)
flag1 = true;
}
}
if (Main.tile[i1, index1 + 2] == null)
Main.tile[i1, index1 + 2] = new Tile();
if (Main.tile[i1 + 1, index1 + 2] == null)
Main.tile[i1 + 1, index1 + 2] = new Tile();
bool flag2 = false;
ushort type1 = Main.tile[i1, index1 + 2].type;
ushort type2 = Main.tile[i1 + 1, index1 + 2].type;
if (!Main.tile[i1, index1 + 2].active() || !Main.tileSolid[(int) type1] && !Main.tileSolidTop[(int) type1] || Main.tile[i1, index1 + 2].halfBrick() || Main.tile[i1, index1 + 2].slope() != (byte) 0 && !Main.tile[i1, index1 + 2].bottomSlope())
flag2 = true;
if (!Main.tile[i1 + 1, index1 + 2].active() || !Main.tileSolid[(int) type2] && !Main.tileSolidTop[(int) type2] || Main.tile[i1 + 1, index1 + 2].halfBrick() || Main.tile[i1 + 1, index1 + 2].slope() != (byte) 0 && !Main.tile[i1 + 1, index1 + 2].bottomSlope())
flag2 = true;
if (flag2)
{
if (Main.tile[i1, index1].wall < (byte) 1 || Main.tile[i1 + 1, index1].wall < (byte) 1 || Main.tile[i1, index1 + 1].wall < (byte) 1 || Main.tile[i1 + 1, index1 + 1].wall < (byte) 1)
{
flag1 = true;
break;
}
if (num5 < 72)
{
for (int index4 = i1; index4 < i1 + 2; ++index4)
{
for (int index5 = index1; index5 < index1 + 2; ++index5)
Main.tile[index4, index5].frameX += (short) 72;
}
break;
}
break;
}
if (num5 >= 72)
{
for (int index6 = i1; index6 < i1 + 2; ++index6)
{
for (int index7 = index1; index7 < index1 + 2; ++index7)
Main.tile[index6, index7].frameX -= (short) 72;
}
break;
}
break;
case 138:
ushort type3 = Main.tile[i1, index1 - 1].type;
ushort type4 = Main.tile[i1 + 1, index1 - 1].type;
if ((TileID.Sets.BasicChest[(int) type3] || TileID.Sets.BasicChest[(int) type4] || type3 == (ushort) 88 || type4 == (ushort) 88 || TileID.Sets.BasicChestFake[(int) type3] ? 1 : (TileID.Sets.BasicChestFake[(int) type4] ? 1 : 0)) == 0 && !WorldGen.SolidTileAllowBottomSlope(i1, index1 + 2) && !WorldGen.SolidTileAllowBottomSlope(i1 + 1, index1 + 2))
{
flag1 = true;
break;
}
break;
}
if (!flag1)
return;
WorldGen.destroyObject = true;
for (int i3 = i1; i3 < i1 + 2; ++i3)
{
for (int j2 = index1; j2 < index1 + 2; ++j2)
{
if ((int) Main.tile[i3, j2].type == type && Main.tile[i3, j2].active())
WorldGen.KillTile(i3, j2);
}
}
int Type = 0;
if (type == 360)
Type = 3072;
if (type >= 288 && type <= 295)
Type = 2178 + type - 288;
if (type >= 316 && type <= 318)
Type = 2439 + type - 316;
if (type == 85)
Type = 321;
if (type == 94)
Type = 352;
if (type == 95)
Type = 344;
if (type == 96)
Type = 345;
if (type == 97)
Type = 346;
if (type == 98)
Type = 347;
if (type == 99)
Type = 348;
if (type == 335)
Type = 2700;
if (type == 411)
Type = 3545;
if (type == 100)
{
if (num4 == 0)
Type = 349;
else if (num4 >= 1 && num4 <= 12)
Type = 2092 + num4 - 1;
else if (num4 >= 13 && num4 <= 16)
{
Type = 2149 + num4 - 13;
}
else
{
switch (num4)
{
case 17:
Type = 2227;
break;
case 18:
Type = 2522;
break;
case 19:
Type = 2541;
break;
case 20:
Type = 2555;
break;
case 21:
Type = 2570;
break;
case 22:
Type = 2664;
break;
case 23:
Type = 2665;
break;
case 24:
Type = 2666;
break;
case 25:
Type = 2667;
break;
case 26:
Type = 2668;
break;
case 27:
Type = 2825;
break;
case 28:
Type = 3168;
break;
case 29:
Type = 3170;
break;
case 30:
Type = 3169;
break;
case 31:
Type = 3893;
break;
}
}
}
if (type == 173)
Type = 714;
if (type == 125)
Type = 487;
if (type == 287)
Type = 2177;
if (type == 126)
Type = 488;
if (type == 132)
Type = 513;
if (type == 142)
Type = 581;
if (type == 143)
Type = 582;
if (type == 282)
Type = 250;
if (type == 319)
Type = 2490;
if (type == 172)
{
Type = 2827 + num4;
switch (num4)
{
case 29:
Type = 3147;
break;
case 30:
Type = 3149;
break;
case 31:
Type = 3148;
break;
case 32:
Type = 3896;
break;
}
}
if (Type != 0)
Item.NewItem(i * 16, j * 16, 32, 32, Type);
if (type == 138 && !WorldGen.gen && Main.netMode != 1)
Projectile.NewProjectile((float) (i1 * 16) + 15.5f, (float) (index1 * 16 + 16), 0.0f, 0.0f, 99, 70, 10f, Main.myPlayer);
WorldGen.destroyObject = false;
for (int i4 = i1 - 1; i4 < i1 + 3; ++i4)
{
for (int j3 = index1 - 1; j3 < index1 + 3; ++j3)
WorldGen.TileFrame(i4, j3);
}
}
public static bool CheckBoulderChest(int i, int j)
{
int num1 = (int) Main.tile[i, j].frameX / 18 * -1;
if (num1 < -1)
num1 += 2;
int index = num1 + i;
int frameY = (int) Main.tile[i, j].frameY;
while (frameY >= 36)
frameY -= 36;
int num2 = j - frameY / 18;
return TileID.Sets.BasicChest[(int) Main.tile[index, num2 - 1].type] || TileID.Sets.BasicChest[(int) Main.tile[index + 1, num2 - 1].type] || TileID.Sets.BasicChestFake[(int) Main.tile[index, num2 - 1].type] || TileID.Sets.BasicChestFake[(int) Main.tile[index + 1, num2 - 1].type] || Main.tile[index, num2 - 1].type == (ushort) 88 || Main.tile[index + 1, num2 - 1].type == (ushort) 88;
}
public static void OreRunner(int i, int j, double strength, int steps, ushort type)
{
double num1 = strength;
float num2 = (float) steps;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
while (num1 > 0.0 && (double) num2 > 0.0)
{
if ((double) vector2_1.Y < 0.0 && (double) num2 > 0.0 && type == (ushort) 59)
num2 = 0.0f;
num1 = strength * ((double) num2 / (double) steps);
--num2;
int num3 = (int) ((double) vector2_1.X - num1 * 0.5);
int num4 = (int) ((double) vector2_1.X + num1 * 0.5);
int num5 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num6 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesX)
num4 = Main.maxTilesX;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY;
for (int index1 = num3; index1 < num4; ++index1)
{
for (int index2 = num5; index2 < num6; ++index2)
{
if ((double) Math.Abs((float) index1 - vector2_1.X) + (double) Math.Abs((float) index2 - vector2_1.Y) < strength * 0.5 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015) && Main.tile[index1, index2].active() && (Main.tile[index1, index2].type == (ushort) 0 || Main.tile[index1, index2].type == (ushort) 1 || Main.tile[index1, index2].type == (ushort) 23 || Main.tile[index1, index2].type == (ushort) 25 || Main.tile[index1, index2].type == (ushort) 40 || Main.tile[index1, index2].type == (ushort) 53 || Main.tile[index1, index2].type == (ushort) 57 || Main.tile[index1, index2].type == (ushort) 59 || Main.tile[index1, index2].type == (ushort) 60 || Main.tile[index1, index2].type == (ushort) 70 || Main.tile[index1, index2].type == (ushort) 109 || Main.tile[index1, index2].type == (ushort) 112 || Main.tile[index1, index2].type == (ushort) 116 || Main.tile[index1, index2].type == (ushort) 117 || Main.tile[index1, index2].type == (ushort) 147 || Main.tile[index1, index2].type == (ushort) 161 || Main.tile[index1, index2].type == (ushort) 163 || Main.tile[index1, index2].type == (ushort) 164 || Main.tileMoss[(int) Main.tile[index1, index2].type] || Main.tile[index1, index2].type == (ushort) 199 || Main.tile[index1, index2].type == (ushort) 200 || Main.tile[index1, index2].type == (ushort) 203 || Main.tile[index1, index2].type == (ushort) 234))
{
Main.tile[index1, index2].type = type;
WorldGen.SquareTileFrame(index1, index2);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
}
}
public static void SmashAltar(int i, int j)
{
if (Main.netMode == 1 || !Main.hardMode || WorldGen.noTileActions || WorldGen.gen)
return;
int num1 = WorldGen.altarCount % 3;
int num2 = WorldGen.altarCount / 3 + 1;
float num3 = (float) (Main.maxTilesX / 4200);
int num4 = 1 - num1;
float num5 = (num3 * 310f - (float) (85 * num1)) * 0.85f / (float) num2;
int num6;
switch (num1)
{
case 0:
if (WorldGen.oreTier1 == -1)
{
WorldGen.oreTier1 = 107;
if (WorldGen.genRand.Next(2) == 0)
WorldGen.oreTier1 = 221;
}
int index1 = 12;
if (WorldGen.oreTier1 == 221)
{
index1 += 9;
num5 *= 0.9f;
}
switch (Main.netMode)
{
case 0:
Main.NewText(Lang.misc[index1].Value, (byte) 50, B: (byte) 130);
break;
case 2:
NetMessage.BroadcastChatMessage(NetworkText.FromKey(Lang.misc[index1].Key), new Color(50, (int) byte.MaxValue, 130));
break;
}
num6 = WorldGen.oreTier1;
num5 *= 1.05f;
break;
case 1:
if (WorldGen.oreTier2 == -1)
{
WorldGen.oreTier2 = 108;
if (WorldGen.genRand.Next(2) == 0)
WorldGen.oreTier2 = 222;
}
int index2 = 13;
if (WorldGen.oreTier2 == 222)
{
index2 += 9;
num5 *= 0.9f;
}
switch (Main.netMode)
{
case 0:
Main.NewText(Lang.misc[index2].Value, (byte) 50, B: (byte) 130);
break;
case 2:
NetMessage.BroadcastChatMessage(NetworkText.FromKey(Lang.misc[index2].Key), new Color(50, (int) byte.MaxValue, 130));
break;
}
num6 = WorldGen.oreTier2;
break;
default:
if (WorldGen.oreTier3 == -1)
{
WorldGen.oreTier3 = 111;
if (WorldGen.genRand.Next(2) == 0)
WorldGen.oreTier3 = 223;
}
int index3 = 14;
if (WorldGen.oreTier3 == 223)
{
index3 += 9;
num5 *= 0.9f;
}
switch (Main.netMode)
{
case 0:
Main.NewText(Lang.misc[index3].Value, (byte) 50, B: (byte) 130);
break;
case 2:
NetMessage.BroadcastChatMessage(NetworkText.FromKey(Lang.misc[index3].Key), new Color(50, (int) byte.MaxValue, 130));
break;
}
num6 = WorldGen.oreTier3;
break;
}
for (int index4 = 0; (double) index4 < (double) num5; ++index4)
{
int i1 = WorldGen.genRand.Next(100, Main.maxTilesX - 100);
double num7 = Main.worldSurface;
if (num6 == 108 || num6 == 222)
num7 = Main.rockLayer;
if (num6 == 111 || num6 == 223)
num7 = (Main.rockLayer + Main.rockLayer + (double) Main.maxTilesY) / 3.0;
int j1 = WorldGen.genRand.Next((int) num7, Main.maxTilesY - 150);
double strength = (double) WorldGen.genRand.Next(5, 9 + num4);
int steps = WorldGen.genRand.Next(5, 9 + num4);
int num8 = (int) (ushort) num6;
WorldGen.OreRunner(i1, j1, strength, steps, (ushort) num8);
}
int num9 = WorldGen.genRand.Next(3);
int num10 = 0;
while (num9 != 2 && num10++ < 1000)
{
int tileX = WorldGen.genRand.Next(100, Main.maxTilesX - 100);
int tileY = WorldGen.genRand.Next((int) Main.rockLayer + 50, Main.maxTilesY - 300);
if (Main.tile[tileX, tileY].active() && Main.tile[tileX, tileY].type == (ushort) 1)
{
Main.tile[tileX, tileY].type = num9 != 0 ? (ushort) 117 : (!WorldGen.crimson ? (ushort) 25 : (ushort) 203);
if (Main.netMode == 2)
{
NetMessage.SendTileSquare(-1, tileX, tileY, 1);
break;
}
break;
}
}
if (Main.netMode != 1)
{
int num11 = Main.rand.Next(2) + 1;
for (int index5 = 0; index5 < num11; ++index5)
NPC.SpawnOnPlayer((int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16), 82);
}
++WorldGen.altarCount;
AchievementsHelper.NotifyProgressionEvent(6);
}
public static void Check3x1(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = (int) Main.tile[i, j].frameX / 18;
int num2 = 0;
while (num1 > 2)
{
num1 -= 3;
++num2;
}
int num3 = i - num1;
int num4 = num2 * 54;
for (int i1 = num3; i1 < num3 + 3; ++i1)
{
int index = j;
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != (i1 - num3) * 18 + num4 || Main.tile[i1, index].frameY != (short) 0)
flag = true;
if (Main.tile[i1, index - 1].active() && (TileID.Sets.BasicChest[(int) Main.tile[i1, index - 1].type] || TileID.Sets.BasicChestFake[(int) Main.tile[i1, index - 1].type] || Main.tile[i1, index - 1].type == (ushort) 88))
return;
if (!WorldGen.SolidTileAllowBottomSlope(i1, index + 1))
flag = true;
}
if (!flag)
return;
int frameX = (int) Main.tile[i, j].frameX;
WorldGen.destroyObject = true;
if (type == 235)
Item.NewItem(i * 16, j * 16, 32, 32, 1263);
for (int i2 = num3; i2 < num3 + 3; ++i2)
{
int j1 = j;
if (Main.tile[i2, j1] == null)
Main.tile[i2, j1] = new Tile();
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
WorldGen.destroyObject = false;
for (int i3 = num3 - 1; i3 < num3 + 4; ++i3)
{
int j2 = j;
WorldGen.TileFrame(i3, j2);
}
}
public static void Check3x2(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag1 = false;
bool flag2 = false;
int num1 = j;
int num2 = 36;
int num3 = (int) Main.tile[i, j].frameY / num2;
int num4 = (int) Main.tile[i, j].frameY % num2;
int index1 = num1 - num4 / 18;
int num5 = (int) Main.tile[i, j].frameX / 18;
int num6 = 0;
while (num5 > 2)
{
num5 -= 3;
++num6;
}
int index2 = i - num5;
int num7 = num6 * 54;
if (type == 14 && num6 == 25)
flag2 = true;
int j1 = index1 + 2;
if (flag2)
--j1;
for (int i1 = index2; i1 < index2 + 3; ++i1)
{
for (int index3 = index1; index3 < j1; ++index3)
{
if (Main.tile[i1, index3] == null)
Main.tile[i1, index3] = new Tile();
if (!Main.tile[i1, index3].active() || (int) Main.tile[i1, index3].type != type || (int) Main.tile[i1, index3].frameX != (i1 - index2) * 18 + num7 || (int) Main.tile[i1, index3].frameY != (index3 - index1) * 18 + num3 * 36)
flag1 = true;
}
if (type == 285 || type == 286 || type == 298 || type == 299 || type == 310 || type == 339 || type >= 361 && type <= 364)
{
if (!WorldGen.SolidTileAllowBottomSlope(i1, j1) && (!Main.tile[i1, j1].nactive() || !Main.tileSolidTop[(int) Main.tile[i1, j1].type] || Main.tile[i1, j1].frameY != (short) 0) && (!Main.tile[i1, j1].active() || !TileID.Sets.Platforms[(int) Main.tile[i1, j1].type]))
flag1 = true;
}
else if (!WorldGen.SolidTileAllowBottomSlope(i1, j1))
flag1 = true;
}
if (type == 187 && Main.tile[index2, index1].frameX >= (short) 756 && Main.tile[index2, index1].frameX <= (short) 900 && Main.tile[index2, index1 + 2].type != (ushort) 2 && Main.tile[index2 + 1, index1 + 2].type != (ushort) 2 && Main.tile[index2 + 2, index1 + 2].type != (ushort) 2)
{
Main.tile[index2, index1].frameX -= (short) 378;
Main.tile[index2 + 1, index1].frameX -= (short) 378;
Main.tile[index2 + 2, index1].frameX -= (short) 378;
Main.tile[index2, index1 + 1].frameX -= (short) 378;
Main.tile[index2 + 1, index1 + 1].frameX -= (short) 378;
Main.tile[index2 + 2, index1 + 1].frameX -= (short) 378;
Main.tile[index2, index1].type = (ushort) 186;
Main.tile[index2 + 1, index1].type = (ushort) 186;
Main.tile[index2 + 2, index1].type = (ushort) 186;
Main.tile[index2, index1 + 1].type = (ushort) 186;
Main.tile[index2 + 1, index1 + 1].type = (ushort) 186;
Main.tile[index2 + 2, index1 + 1].type = (ushort) 186;
}
if (!flag1)
return;
int frameX = (int) Main.tile[i, j].frameX;
WorldGen.destroyObject = true;
int num8 = index1 + 3;
if (flag2)
{
int num9 = num8 - 1;
}
for (int i2 = index2; i2 < index2 + 3; ++i2)
{
for (int j2 = index1; j2 < index1 + 3; ++j2)
{
if (Main.tile[i2, j2] == null)
Main.tile[i2, j2] = new Tile();
if ((int) Main.tile[i2, j2].type == type && Main.tile[i2, j2].active())
WorldGen.KillTile(i2, j2);
}
}
if (type == 14)
{
int Type = num6 < 1 || num6 > 3 ? (num6 < 15 || num6 > 20 ? (num6 < 4 || num6 > 7 ? (num6 != 8 ? (num6 != 9 ? (num6 != 10 ? (num6 != 11 ? (num6 != 12 ? (num6 != 13 ? (num6 != 14 ? (num6 != 23 ? (num6 != 21 ? (num6 != 22 ? (num6 != 24 ? (num6 != 25 ? (num6 != 26 ? (num6 != 27 ? (num6 != 28 ? (num6 != 29 ? (num6 != 30 ? (num6 != 31 ? (num6 != 32 ? (num6 != 33 ? (num6 != 34 ? 32 : 3154) : 3155) : 3153) : 2824) : 2743) : 2583) : 677) : 2550) : 2532) : 2259) : 2248) : 1816) : 1794) : 1926) : 1510) : 1460) : 1403) : 1400) : 1397) : 1144) : 917) : 823 + num6) : 1698 + num6) : 637 + num6;
Item.NewItem(i * 16, j * 16, 32, 32, Type);
}
if (type == 469)
{
int Type = 3920;
Item.NewItem(i * 16, j * 16, 32, 32, Type);
}
else if (type == 114)
Item.NewItem(i * 16, j * 16, 32, 32, 398);
else if (type == 26)
{
if (!WorldGen.noTileActions && !WorldGen.IsGeneratingHardMode)
WorldGen.SmashAltar(i, j);
}
else if (type == 298)
Item.NewItem(i * 16, j * 16, 32, 32, 2190);
else if (type == 299)
Item.NewItem(i * 16, j * 16, 32, 32, 2191);
else if (type >= 361 && type <= 364)
Item.NewItem(i * 16, j * 16, 32, 32, 3073 + type - 361);
else if (type >= 391 && type <= 394)
{
Item.NewItem(i * 16, j * 16, 48, 32, 3254 + type - 391);
}
else
{
switch (type)
{
case 17:
Item.NewItem(i * 16, j * 16, 32, 32, 33);
break;
case 77:
Item.NewItem(i * 16, j * 16, 32, 32, 221);
break;
case 86:
Item.NewItem(i * 16, j * 16, 32, 32, 332);
break;
case 87:
int Type1 = num6 < 1 || num6 > 3 ? (num6 != 4 ? (num6 < 5 || num6 > 7 ? (num6 < 8 || num6 > 10 ? (num6 < 11 || num6 > 20 ? (num6 != 21 ? (num6 != 22 ? (num6 != 23 ? (num6 != 24 ? (num6 != 25 ? (num6 != 26 ? (num6 != 27 ? (num6 != 28 ? (num6 != 29 ? (num6 != 30 ? (num6 != 31 ? 333 : 3916) : 3915) : 3142) : 3143) : 3141) : 2821) : 2671) : 2580) : 2565) : 2548) : 2531) : 2376 + num6 - 11) : 2254 + num6 - 8) : 2245 + num6 - 5) : 919) : 640 + num6;
Item.NewItem(i * 16, j * 16, 32, 32, Type1);
break;
case 88:
int Type2 = num6 < 1 || num6 > 3 ? (num6 != 4 ? (num6 < 5 || num6 > 15 ? (num6 != 16 ? (num6 != 17 ? (num6 != 18 ? (num6 != 19 ? (num6 != 20 ? (num6 != 21 ? (num6 != 22 ? (num6 != 23 ? (num6 != 24 ? (num6 != 25 ? (num6 != 26 ? (num6 != 27 ? (num6 != 28 ? (num6 != 29 ? (num6 != 30 ? (num6 != 31 ? 334 : 3914) : 3913) : 3912) : 3911) : 3133) : 3134) : 3132) : 2816) : 2640) : 2639) : 2638) : 2637) : 2577) : 2562) : 2545) : 2529) : 2386 + num6 - 5) : 918) : 646 + num6;
Item.NewItem(i * 16, j * 16, 32, 32, Type2);
break;
case 89:
int Type3 = num6 < 1 || num6 > 20 ? (num6 != 21 ? (num6 != 22 ? (num6 != 23 ? (num6 != 24 ? (num6 != 25 ? (num6 != 26 ? (num6 != 27 ? (num6 != 28 ? (num6 != 29 ? (num6 != 30 ? (num6 != 31 ? (num6 != 32 ? (num6 != 33 ? (num6 != 34 ? 335 : 3919) : 3918) : 3151) : 3152) : 3150) : 2823) : 2636) : 2635) : 2634) : 2582) : 858) : 2539) : 2527) : 2521) : 2397 + num6 - 1;
Item.NewItem(i * 16, j * 16, 32, 32, Type3);
break;
case 133:
if (frameX >= 54)
{
Item.NewItem(i * 16, j * 16, 32, 32, 1221);
break;
}
Item.NewItem(i * 16, j * 16, 32, 32, 524);
break;
case 186:
if (frameX >= 864)
{
if (frameX <= 954)
{
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(30, 100));
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(40, 100));
if (WorldGen.genRand.Next(3) != 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(3) != 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(30, 100));
if (WorldGen.genRand.Next(3) != 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(40, 100));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(30, 100));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(40, 100));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(30, 100));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(40, 100));
if (WorldGen.genRand.Next(4) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(4) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(30, 100));
if (WorldGen.genRand.Next(4) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(40, 100));
if (WorldGen.genRand.Next(5) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(5) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(30, 100));
if (WorldGen.genRand.Next(5) == 0)
{
Item.NewItem(i * 16, j * 16, 32, 32, 71, WorldGen.genRand.Next(40, 100));
break;
}
break;
}
if (frameX <= 1062)
{
Item.NewItem(i * 16, j * 16, 32, 32, 72, WorldGen.genRand.Next(10, 100));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 72, WorldGen.genRand.Next(20, 100));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 72, WorldGen.genRand.Next(30, 100));
if (WorldGen.genRand.Next(4) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 72, WorldGen.genRand.Next(40, 100));
if (WorldGen.genRand.Next(5) == 0)
{
Item.NewItem(i * 16, j * 16, 32, 32, 72, WorldGen.genRand.Next(50, 100));
break;
}
break;
}
if (frameX <= 1170)
{
Item.NewItem(i * 16, j * 16, 32, 32, 73, WorldGen.genRand.Next(1, 7));
if (WorldGen.genRand.Next(2) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 73, WorldGen.genRand.Next(2, 7));
if (WorldGen.genRand.Next(3) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 73, WorldGen.genRand.Next(3, 7));
if (WorldGen.genRand.Next(4) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 73, WorldGen.genRand.Next(4, 7));
if (WorldGen.genRand.Next(5) == 0)
{
Item.NewItem(i * 16, j * 16, 32, 32, 73, WorldGen.genRand.Next(5, 7));
break;
}
break;
}
break;
}
break;
case 215:
switch (num6)
{
case 0:
Item.NewItem(i * 16, j * 16, 32, 32, 966);
break;
case 6:
Item.NewItem(i * 16, j * 16, 32, 32, 3723);
break;
case 7:
Item.NewItem(i * 16, j * 16, 32, 32, 3724);
break;
default:
Item.NewItem(i * 16, j * 16, 32, 32, 3046 + num6 - 1);
break;
}
break;
case 217:
Item.NewItem(i * 16, j * 16, 32, 32, 995);
break;
case 218:
Item.NewItem(i * 16, j * 16, 32, 32, 996);
break;
case 219:
Item.NewItem(i * 16, j * 16, 32, 32, 997);
break;
case 220:
Item.NewItem(i * 16, j * 16, 32, 32, 998);
break;
case 228:
Item.NewItem(i * 16, j * 16, 32, 32, 1120);
break;
case 237:
Item.NewItem(i * 16, j * 16, 32, 32, 1292);
break;
case 244:
Item.NewItem(i * 16, j * 16, 32, 32, 1449);
break;
case 285:
Item.NewItem(i * 16, j * 16, 32, 32, 2174);
break;
case 286:
Item.NewItem(i * 16, j * 16, 32, 32, 2175);
break;
case 310:
Item.NewItem(i * 16, j * 16, 32, 32, 2207);
break;
case 339:
Item.NewItem(i * 16, j * 16, 32, 32, 2741);
break;
case 377:
Item.NewItem(i * 16, j * 16, 32, 32, 3198);
break;
case 405:
Item.NewItem(i * 16, j * 16, 32, 32, 3364);
break;
default:
if (type == 187 && frameX >= 918 && frameX <= 970)
{
if (Main.rand.Next(10) == 0)
{
Item.NewItem(i * 16, j * 16, 32, 32, 3368);
break;
}
Item.NewItem(i * 16, j * 16, 32, 32, 989);
break;
}
break;
}
}
WorldGen.destroyObject = false;
for (int i3 = index2 - 1; i3 < index2 + 4; ++i3)
{
for (int j3 = index1 - 1; j3 < index1 + 4; ++j3)
WorldGen.TileFrame(i3, j3);
}
}
public static void Check3x4(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = i;
int num2 = j;
int num3 = 0;
int num4;
for (num4 = (int) Main.tile[i, j].frameX / 18; num4 >= 3; num4 -= 3)
++num3;
int num5 = num1 - num4;
int num6 = num2 + (int) Main.tile[i, j].frameY / 18 * -1;
for (int i1 = num5; i1 < num5 + 3; ++i1)
{
for (int index = num6; index < num6 + 4; ++index)
{
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != num3 * 54 + (i1 - num5) * 18 || (int) Main.tile[i1, index].frameY != (index - num6) * 18)
flag = true;
}
if (Main.tile[i1, num6 + 4] == null)
Main.tile[i1, num6 + 4] = new Tile();
if (!WorldGen.SolidTileAllowBottomSlope(i1, num6 + 4))
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i2 = num5; i2 < num5 + 3; ++i2)
{
for (int j1 = num6; j1 < num6 + 4; ++j1)
{
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
switch (type)
{
case 101:
int Type = num3 != 1 ? (num3 != 2 ? (num3 != 3 ? (num3 != 4 ? (num3 != 5 ? (num3 != 6 ? (num3 != 7 ? (num3 != 8 ? (num3 != 9 ? (num3 != 10 ? (num3 != 11 ? (num3 != 12 ? (num3 != 13 ? (num3 != 14 ? (num3 != 15 ? (num3 != 16 ? (num3 != 17 ? (num3 < 18 || num3 > 21 ? (num3 != 22 ? (num3 != 23 ? (num3 != 24 ? (num3 != 25 ? (num3 != 26 ? (num3 != 27 ? (num3 != 28 ? (num3 != 29 ? (num3 != 30 ? (num3 != 31 ? (num3 != 32 ? 354 : 3917) : 3166) : 3167) : 3165) : 2817) : 2670) : 2569) : 2554) : 2540) : 2536) : 2233) : 2135 + num3 - 18) : 2031) : 2030) : 2029) : 2028) : 2027) : 2026) : 2025) : 2024) : 2023) : 2022) : 2021) : 2020) : 1512) : 1463) : 1416) : 1415) : 1414;
Item.NewItem(i * 16, j * 16, 32, 32, Type);
break;
case 102:
Item.NewItem(i * 16, j * 16, 32, 32, 355);
break;
case 463:
Item.NewItem(i * 16, j * 16, 32, 32, 3813);
break;
}
WorldGen.destroyObject = false;
for (int i3 = num5 - 1; i3 < num5 + 4; ++i3)
{
for (int j2 = num6 - 1; j2 < num6 + 4; ++j2)
WorldGen.TileFrame(i3, j2);
}
}
public static void Check5x4(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = i;
int num2 = j;
int num3 = 0;
int num4;
for (num4 = (int) Main.tile[i, j].frameX / 18; num4 >= 5; num4 -= 5)
++num3;
int num5 = num1 - num4;
int num6 = num2 + (int) Main.tile[i, j].frameY / 18 * -1;
for (int i1 = num5; i1 < num5 + 5; ++i1)
{
for (int index = num6; index < num6 + 4; ++index)
{
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != num3 * 90 + (i1 - num5) * 18 || (int) Main.tile[i1, index].frameY != (index - num6) * 18)
flag = true;
}
if (Main.tile[i1, num6 + 4] == null)
Main.tile[i1, num6 + 4] = new Tile();
if (!WorldGen.SolidTileAllowBottomSlope(i1, num6 + 4))
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i2 = num5; i2 < num5 + 5; ++i2)
{
for (int j1 = num6; j1 < num6 + 4; ++j1)
{
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
if (type == 464)
Item.NewItem(i * 16, j * 16, 32, 32, 3814);
if (type == 466)
Item.NewItem(i * 16, j * 16, 32, 32, 3816);
WorldGen.destroyObject = false;
for (int i3 = num5 - 1; i3 < num5 + 6; ++i3)
{
for (int j2 = num6 - 1; j2 < num6 + 5; ++j2)
WorldGen.TileFrame(i3, j2);
}
}
public static void Check6x3(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = i;
int num2 = j;
int num3 = num1 + (int) Main.tile[i, j].frameX / 18 * -1;
int num4 = num2 + (int) Main.tile[i, j].frameY / 18 * -1;
for (int i1 = num3; i1 < num3 + 6; ++i1)
{
for (int index = num4; index < num4 + 3; ++index)
{
int num5 = (i1 - num3) * 18;
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != num5 || (int) Main.tile[i1, index].frameY != (index - num4) * 18)
flag = true;
}
if (Main.tile[i1, num4 + 3] == null)
Main.tile[i1, num4 + 3] = new Tile();
if (!WorldGen.SolidTileAllowBottomSlope(i1, num4 + 3) && (!Main.tile[i1, num4 + 3].nactive() || !Main.tileSolidTop[(int) Main.tile[i1, num4 + 3].type] || Main.tile[i1, num4 + 3].frameY != (short) 0))
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i2 = num3; i2 < num3 + 6; ++i2)
{
for (int j1 = num4; j1 < num4 + 3; ++j1)
{
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
if (type == 275)
Item.NewItem(i * 16, j * 16, 32, 32, 2162);
if (type == 413)
Item.NewItem(i * 16, j * 16, 32, 32, 3565);
if (type == 414)
Item.NewItem(i * 16, j * 16, 32, 32, 3566);
if (type == 276)
Item.NewItem(i * 16, j * 16, 32, 32, 2163);
if (type == 277)
Item.NewItem(i * 16, j * 16, 32, 32, 2164);
if (type == 278)
Item.NewItem(i * 16, j * 16, 32, 32, 2165);
if (type == 279)
Item.NewItem(i * 16, j * 16, 32, 32, 2166);
if (type == 280)
Item.NewItem(i * 16, j * 16, 32, 32, 2167);
if (type == 281)
Item.NewItem(i * 16, j * 16, 32, 32, 2168);
if (type == 296)
Item.NewItem(i * 16, j * 16, 32, 32, 2186);
if (type == 297)
Item.NewItem(i * 16, j * 16, 32, 32, 2187);
if (type == 309)
Item.NewItem(i * 16, j * 16, 32, 32, 2206);
if (type == 358)
Item.NewItem(i * 16, j * 16, 32, 32, 3070);
if (type == 359)
Item.NewItem(i * 16, j * 16, 32, 32, 3071);
WorldGen.destroyObject = false;
for (int i3 = num3 - 1; i3 < num3 + 7; ++i3)
{
for (int j2 = num4 - 1; j2 < num4 + 4; ++j2)
WorldGen.TileFrame(i3, j2);
}
}
public static void Place6x3(int x, int y, ushort type, int direction = -1, int style = 0)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = x - 3; i < x + 3; ++i)
{
for (int index = y - 2; index <= y; ++index)
{
if (Main.tile[i, index] == null)
Main.tile[i, index] = new Tile();
if (Main.tile[i, index].active())
flag = false;
}
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (!WorldGen.SolidTile2(i, y + 1) && (!Main.tile[i, y + 1].nactive() || !Main.tileSolidTop[(int) Main.tile[i, y + 1].type] || Main.tile[i, y + 1].frameY != (short) 0))
flag = false;
}
if (!flag)
return;
int num1 = 0;
for (int index1 = x - 3; index1 < x + 3; ++index1)
{
int num2 = 0;
for (int index2 = y - 2; index2 <= y; ++index2)
{
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].frameY = (short) num2;
Main.tile[index1, index2].frameX = (short) num1;
Main.tile[index1, index2].type = type;
num2 += 18;
}
num1 += 18;
}
}
public static void Place4x2(int x, int y, ushort type, int direction = -1, int style = 0)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = x - 1; i < x + 3; ++i)
{
for (int index = y - 1; index < y + 1; ++index)
{
if (Main.tile[i, index] == null)
Main.tile[i, index] = new Tile();
if (Main.tile[i, index].active())
flag = false;
}
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (!WorldGen.SolidTile2(i, y + 1))
flag = false;
}
short num1 = 0;
if (direction == 1)
num1 = (short) 72;
int num2 = 36 * style;
if (!flag)
return;
Main.tile[x - 1, y - 1].active(true);
Main.tile[x - 1, y - 1].frameY = (short) num2;
Main.tile[x - 1, y - 1].frameX = num1;
Main.tile[x - 1, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameY = (short) num2;
Main.tile[x, y - 1].frameX = (short) (18 + (int) num1);
Main.tile[x, y - 1].type = type;
Main.tile[x + 1, y - 1].active(true);
Main.tile[x + 1, y - 1].frameY = (short) num2;
Main.tile[x + 1, y - 1].frameX = (short) (36 + (int) num1);
Main.tile[x + 1, y - 1].type = type;
Main.tile[x + 2, y - 1].active(true);
Main.tile[x + 2, y - 1].frameY = (short) num2;
Main.tile[x + 2, y - 1].frameX = (short) (54 + (int) num1);
Main.tile[x + 2, y - 1].type = type;
Main.tile[x - 1, y].active(true);
Main.tile[x - 1, y].frameY = (short) (num2 + 18);
Main.tile[x - 1, y].frameX = num1;
Main.tile[x - 1, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) (num2 + 18);
Main.tile[x, y].frameX = (short) (18 + (int) num1);
Main.tile[x, y].type = type;
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].frameY = (short) (num2 + 18);
Main.tile[x + 1, y].frameX = (short) (36 + (int) num1);
Main.tile[x + 1, y].type = type;
Main.tile[x + 2, y].active(true);
Main.tile[x + 2, y].frameY = (short) (num2 + 18);
Main.tile[x + 2, y].frameX = (short) (54 + (int) num1);
Main.tile[x + 2, y].type = type;
}
public static void ShootFromCannon(
int x,
int y,
int angle,
int ammo,
int Damage,
float KnockBack,
int owner)
{
float num1 = 14f;
float num2 = 0.0f;
float num3 = 0.0f;
int Type = 162;
if (ammo == 2)
Type = 281;
if (ammo == 3)
Type = 178;
if (ammo == 4)
{
Type = 601;
num1 = 3f;
}
if (ammo == 5)
{
Type = 601;
num1 = 3f;
}
int num4 = 0;
if (ammo == 5)
num4 = 1;
if (angle == 0)
{
num2 = 10f;
num3 = 0.0f;
}
if (angle == 1)
{
num2 = 7.5f;
num3 = -2.5f;
}
if (angle == 2)
{
num2 = 5f;
num3 = -5f;
}
if (angle == 3)
{
num2 = 2.75f;
num3 = -6f;
}
if (angle == 4)
{
num2 = 0.0f;
num3 = -10f;
}
if (angle == 5)
{
num2 = -2.75f;
num3 = -6f;
}
if (angle == 6)
{
num2 = -5f;
num3 = -5f;
}
if (angle == 7)
{
num2 = -7.5f;
num3 = -2.5f;
}
if (angle == 8)
{
num2 = -10f;
num3 = 0.0f;
}
Vector2 vector2 = new Vector2((float) ((x + 2) * 16), (float) ((y + 2) * 16));
float num5 = num2;
float num6 = num3;
float num7 = (float) Math.Sqrt((double) num5 * (double) num5 + (double) num6 * (double) num6);
if (ammo == 4 || ammo == 5)
{
if (angle == 4)
vector2.X += 5f;
vector2.Y += 5f;
}
float num8 = num1 / num7;
float SpeedX = num5 * num8;
float SpeedY = num6 * num8;
if (Main.myPlayer != owner && Main.netMode == 2 && (ammo == 4 || ammo == 5))
{
NetMessage.SendData(108, owner, number: Damage, number2: KnockBack, number3: ((float) x), number4: ((float) y), number5: angle, number6: ammo, number7: owner);
}
else
{
if (Main.netMode == 2)
owner = Main.myPlayer;
Projectile.NewProjectile(vector2.X, vector2.Y, SpeedX, SpeedY, Type, Damage, KnockBack, owner, (float) num4);
}
}
public static void SwitchCannon(int i, int j)
{
int num1 = (int) Main.tile[i, j].frameX / 18;
while (num1 >= 4)
num1 -= 4;
int num2 = (int) Main.tile[i, j].frameY / 18;
while (num2 >= 3)
num2 -= 3;
int num3 = 1;
if (num1 < 2)
num3 = -1;
int index1 = i - num1;
int index2 = j - num2;
if (num3 == 1 && Main.tile[index1, index2].frameY <= (short) 52 || num3 == -1 && Main.tile[index1, index2].frameY >= (short) 432)
return;
int num4 = num3 * -54;
for (int index3 = index1; index3 < index1 + 4; ++index3)
{
for (int index4 = index2; index4 < index2 + 3; ++index4)
{
if (Main.tile[index3, index4] == null)
Main.tile[index3, index4] = new Tile();
if (Main.tile[index3, index4].active() && Main.tile[index3, index4].type == (ushort) 209)
Main.tile[index3, index4].frameY += (short) num4;
}
}
NetMessage.SendTileSquare(-1, index1 + 1, index2 + 1, 4);
}
public static void CheckCannon(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = (int) Main.tile[i, j].frameX / 18;
int num2 = 0;
for (; num1 >= 4; num1 -= 4)
++num2;
int num3 = i - num1;
int num4 = (int) Main.tile[i, j].frameY / 18;
int num5 = 0;
for (; num4 >= 3; num4 -= 3)
num5 += 54;
int num6 = j - num4;
int num7 = 72 * num2;
for (int i1 = num3; i1 < num3 + 4; ++i1)
{
int num8 = num5;
for (int index = num6; index < num6 + 3; ++index)
{
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != num7 || (int) Main.tile[i1, index].frameY != num8)
flag = true;
num8 += 18;
}
if (Main.tile[i1, num6 + 3] == null)
Main.tile[i1, num6 + 3] = new Tile();
if (!WorldGen.SolidTileAllowBottomSlope(i1, num6 + 3) && i1 != num3 && i1 != num3 + 3)
flag = true;
num7 += 18;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i2 = num3; i2 < num3 + 4; ++i2)
{
for (int j1 = num6; j1 < num6 + 3; ++j1)
{
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
int Type = 928;
switch (num2)
{
case 1:
Type = 1337;
break;
case 2:
Type = 3369;
break;
case 3:
case 4:
Type = 3664;
break;
}
Item.NewItem(i * 16, j * 16, 32, 32, Type);
WorldGen.destroyObject = false;
for (int i3 = num3; i3 < num3 + 4; ++i3)
{
for (int j2 = num6; j2 < num6 + 3; ++j2)
WorldGen.TileFrame(i3, j2);
}
}
public static void PlaceCannon(int x, int y, ushort type, int style = 0)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = x - 1; i < x + 3; ++i)
{
for (int index = y - 2; index < y + 1; ++index)
{
if (Main.tile[i, index] == null)
Main.tile[i, index] = new Tile();
if (Main.tile[i, index].active())
flag = false;
}
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (!WorldGen.SolidTile2(i, y + 1) && i != x - 1 && i != x + 2)
flag = false;
}
int num1 = 72 * style;
int num2 = 0;
if (!flag)
return;
Main.tile[x - 1, y - 2].active(true);
Main.tile[x - 1, y - 2].frameY = (short) num2;
Main.tile[x - 1, y - 2].frameX = (short) num1;
Main.tile[x - 1, y - 2].type = type;
Main.tile[x, y - 2].active(true);
Main.tile[x, y - 2].frameY = (short) num2;
Main.tile[x, y - 2].frameX = (short) (18 + num1);
Main.tile[x, y - 2].type = type;
Main.tile[x + 1, y - 2].active(true);
Main.tile[x + 1, y - 2].frameY = (short) num2;
Main.tile[x + 1, y - 2].frameX = (short) (36 + num1);
Main.tile[x + 1, y - 2].type = type;
Main.tile[x + 2, y - 2].active(true);
Main.tile[x + 2, y - 2].frameY = (short) num2;
Main.tile[x + 2, y - 2].frameX = (short) (54 + num1);
Main.tile[x + 2, y - 2].type = type;
Main.tile[x - 1, y - 1].active(true);
Main.tile[x - 1, y - 1].frameY = (short) (num2 + 18);
Main.tile[x - 1, y - 1].frameX = (short) num1;
Main.tile[x - 1, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameY = (short) (num2 + 18);
Main.tile[x, y - 1].frameX = (short) (18 + num1);
Main.tile[x, y - 1].type = type;
Main.tile[x + 1, y - 1].active(true);
Main.tile[x + 1, y - 1].frameY = (short) (num2 + 18);
Main.tile[x + 1, y - 1].frameX = (short) (36 + num1);
Main.tile[x + 1, y - 1].type = type;
Main.tile[x + 2, y - 1].active(true);
Main.tile[x + 2, y - 1].frameY = (short) (num2 + 18);
Main.tile[x + 2, y - 1].frameX = (short) (54 + num1);
Main.tile[x + 2, y - 1].type = type;
Main.tile[x - 1, y].active(true);
Main.tile[x - 1, y].frameY = (short) (num2 + 36);
Main.tile[x - 1, y].frameX = (short) num1;
Main.tile[x - 1, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) (num2 + 36);
Main.tile[x, y].frameX = (short) (18 + num1);
Main.tile[x, y].type = type;
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].frameY = (short) (num2 + 36);
Main.tile[x + 1, y].frameX = (short) (36 + num1);
Main.tile[x + 1, y].type = type;
Main.tile[x + 2, y].active(true);
Main.tile[x + 2, y].frameY = (short) (num2 + 36);
Main.tile[x + 2, y].frameX = (short) (54 + num1);
Main.tile[x + 2, y].type = type;
}
public static void SwitchMB(int i, int j)
{
int num1 = (int) Main.tile[i, j].frameY / 18;
while (num1 >= 2)
num1 -= 2;
int num2 = (int) Main.tile[i, j].frameX / 18;
if (num2 >= 2)
num2 -= 2;
int num3 = i - num2;
int num4 = j - num1;
for (int index1 = num3; index1 < num3 + 2; ++index1)
{
for (int index2 = num4; index2 < num4 + 2; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].active() && (Main.tile[index1, index2].type == (ushort) 139 || Main.tile[index1, index2].type == (ushort) 35))
{
if (Main.tile[index1, index2].frameX < (short) 36)
Main.tile[index1, index2].frameX += (short) 36;
else
Main.tile[index1, index2].frameX -= (short) 36;
}
}
}
if (Wiring.running)
{
Wiring.SkipWire(num3, num4);
Wiring.SkipWire(num3 + 1, num4);
Wiring.SkipWire(num3, num4 + 1);
Wiring.SkipWire(num3 + 1, num4 + 1);
}
NetMessage.SendTileSquare(-1, num3, num4, 3);
}
public static void SwitchMonolith(int i, int j)
{
int num1 = (int) Main.tile[i, j].frameX / 18;
while (num1 >= 2)
num1 -= 2;
int num2 = (int) Main.tile[i, j].frameY / 18;
if (num2 >= 3)
num2 -= 3;
int num3 = i - num1;
int y = j - num2;
for (int index1 = num3; index1 < num3 + 2; ++index1)
{
for (int index2 = y; index2 < y + 3; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 410)
{
if (Main.tile[index1, index2].frameY < (short) 56)
Main.tile[index1, index2].frameY += (short) 56;
else
Main.tile[index1, index2].frameY -= (short) 56;
}
}
}
if (Wiring.running)
{
Wiring.SkipWire(num3, y);
Wiring.SkipWire(num3, y + 1);
Wiring.SkipWire(num3, y + 2);
Wiring.SkipWire(num3 + 1, y);
Wiring.SkipWire(num3 + 1, y + 1);
Wiring.SkipWire(num3 + 1, y + 2);
}
NetMessage.SendTileSquare(-1, num3, y + 1, 3);
}
public static void SwitchFountain(int i, int j)
{
int num1 = (int) Main.tile[i, j].frameX / 18;
while (num1 >= 2)
num1 -= 2;
int num2 = (int) Main.tile[i, j].frameY / 18;
if (num2 >= 4)
num2 -= 4;
int num3 = i - num1;
int y = j - num2;
for (int index1 = num3; index1 < num3 + 2; ++index1)
{
for (int index2 = y; index2 < y + 4; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 207)
{
if (Main.tile[index1, index2].frameY < (short) 72)
Main.tile[index1, index2].frameY += (short) 72;
else
Main.tile[index1, index2].frameY -= (short) 72;
}
}
}
if (Wiring.running)
{
Wiring.SkipWire(num3, y);
Wiring.SkipWire(num3, y + 1);
Wiring.SkipWire(num3, y + 2);
Wiring.SkipWire(num3, y + 3);
Wiring.SkipWire(num3 + 1, y);
Wiring.SkipWire(num3 + 1, y + 1);
Wiring.SkipWire(num3 + 1, y + 2);
Wiring.SkipWire(num3 + 1, y + 3);
}
NetMessage.SendTileSquare(-1, num3, y + 1, 4);
}
public static void CheckMB(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = 0;
int num2;
for (num2 = (int) Main.tile[i, j].frameY / 18; num2 >= 2; num2 -= 2)
++num1;
int num3 = (int) Main.tile[i, j].frameX / 18;
int num4 = 0;
if (num3 >= 2)
{
num3 -= 2;
++num4;
}
int num5 = i - num3;
int num6 = j - num2;
for (int index1 = num5; index1 < num5 + 2; ++index1)
{
for (int index2 = num6; index2 < num6 + 2; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (!Main.tile[index1, index2].active() || (int) Main.tile[index1, index2].type != type || (int) Main.tile[index1, index2].frameX != (index1 - num5) * 18 + num4 * 36 || (int) Main.tile[index1, index2].frameY != (index2 - num6) * 18 + num1 * 36)
flag = true;
}
if (!Main.tile[index1, num6 + 2].nactive())
flag = true;
else if (!Main.tileSolid[(int) Main.tile[index1, num6 + 2].type] && !Main.tileTable[(int) Main.tile[index1, num6 + 2].type])
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i1 = num5; i1 < num5 + 2; ++i1)
{
for (int j1 = num6; j1 < num6 + 3; ++j1)
{
if ((int) Main.tile[i1, j1].type == type && Main.tile[i1, j1].active())
WorldGen.KillTile(i1, j1);
}
}
if (type == 35)
Item.NewItem(i * 16, j * 16, 32, 32, 1813);
else if (num1 == 28)
Item.NewItem(i * 16, j * 16, 32, 32, 1963);
else if (num1 == 29)
Item.NewItem(i * 16, j * 16, 32, 32, 1964);
else if (num1 == 30)
Item.NewItem(i * 16, j * 16, 32, 32, 1965);
else if (num1 == 31)
Item.NewItem(i * 16, j * 16, 32, 32, 2742);
else if (num1 == 32)
Item.NewItem(i * 16, j * 16, 32, 32, 3044);
else if (num1 == 33)
Item.NewItem(i * 16, j * 16, 32, 32, 3235);
else if (num1 == 34)
Item.NewItem(i * 16, j * 16, 32, 32, 3236);
else if (num1 == 35)
Item.NewItem(i * 16, j * 16, 32, 32, 3237);
else if (num1 == 36)
Item.NewItem(i * 16, j * 16, 32, 32, 3370);
else if (num1 == 37)
Item.NewItem(i * 16, j * 16, 32, 32, 3371);
else if (num1 == 38)
Item.NewItem(i * 16, j * 16, 32, 32, 3796);
else if (num1 == 39)
Item.NewItem(i * 16, j * 16, 32, 32, 3869);
else if (num1 >= 13)
Item.NewItem(i * 16, j * 16, 32, 32, 1596 + num1 - 13);
else
Item.NewItem(i * 16, j * 16, 32, 32, 562 + num1);
for (int i2 = num5 - 1; i2 < num5 + 3; ++i2)
{
for (int j2 = num6 - 1; j2 < num6 + 3; ++j2)
WorldGen.TileFrame(i2, j2);
}
WorldGen.destroyObject = false;
}
public static void PlaceMB(int X, int y, ushort type, int style)
{
int index1 = X + 1;
if (index1 < 5 || index1 > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
bool flag = true;
for (int index2 = index1 - 1; index2 < index1 + 1; ++index2)
{
for (int index3 = y - 1; index3 < y + 1; ++index3)
{
if (Main.tile[index2, index3] == null)
Main.tile[index2, index3] = new Tile();
if (Main.tile[index2, index3].active())
flag = false;
}
if (Main.tile[index2, y + 1] == null)
Main.tile[index2, y + 1] = new Tile();
if (!Main.tile[index2, y + 1].active() || Main.tile[index2, y + 1].halfBrick() || !Main.tileSolid[(int) Main.tile[index2, y + 1].type] && !Main.tileTable[(int) Main.tile[index2, y + 1].type])
flag = false;
}
if (!flag)
return;
Main.tile[index1 - 1, y - 1].active(true);
Main.tile[index1 - 1, y - 1].frameY = (short) (style * 36);
Main.tile[index1 - 1, y - 1].frameX = (short) 0;
Main.tile[index1 - 1, y - 1].type = type;
Main.tile[index1, y - 1].active(true);
Main.tile[index1, y - 1].frameY = (short) (style * 36);
Main.tile[index1, y - 1].frameX = (short) 18;
Main.tile[index1, y - 1].type = type;
Main.tile[index1 - 1, y].active(true);
Main.tile[index1 - 1, y].frameY = (short) (style * 36 + 18);
Main.tile[index1 - 1, y].frameX = (short) 0;
Main.tile[index1 - 1, y].type = type;
Main.tile[index1, y].active(true);
Main.tile[index1, y].frameY = (short) (style * 36 + 18);
Main.tile[index1, y].frameX = (short) 18;
Main.tile[index1, y].type = type;
}
public static void Place2x2(int x, int y, ushort type, int style)
{
if (type == (ushort) 95 || type == (ushort) 126)
++y;
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
if (type == (ushort) 172)
{
if (!WorldGen.CanPlaceSink(x, y, type, style))
return;
}
else
{
for (int i = x - 1; i < x + 1; ++i)
{
for (int j = y - 1; j < y + 1; ++j)
{
Tile tileSafely = Framing.GetTileSafely(i, j);
if (tileSafely.active() || type == (ushort) 98 && tileSafely.liquid > (byte) 0)
return;
}
switch (type)
{
case 95:
case 126:
Tile tileSafely1 = Framing.GetTileSafely(i, y - 2);
if (!tileSafely1.nactive() || !Main.tileSolid[(int) tileSafely1.type] || Main.tileSolidTop[(int) tileSafely1.type])
return;
continue;
case 132:
continue;
default:
Tile tileSafely2 = Framing.GetTileSafely(i, y + 1);
if (!tileSafely2.nactive() || !WorldGen.SolidTile2(tileSafely2) && !Main.tileTable[(int) tileSafely2.type])
return;
continue;
}
}
}
if (type == (ushort) 132)
{
bool flag = true;
if (Main.tile[x - 1, y + 1] == null)
Main.tile[x - 1, y + 1] = new Tile();
if (Main.tile[x, y + 1] == null)
Main.tile[x, y + 1] = new Tile();
if (!Main.tile[x - 1, y + 1].nactive() || !WorldGen.SolidTile2(x - 1, y + 1) && !Main.tileTable[(int) Main.tile[x - 1, y + 1].type])
flag = false;
if (!Main.tile[x, y + 1].nactive() || !WorldGen.SolidTile2(x, y + 1) && !Main.tileTable[(int) Main.tile[x, y + 1].type])
flag = false;
if (!flag && (Main.tile[x - 1, y - 1].wall < (byte) 1 || Main.tile[x, y - 1].wall < (byte) 1 || Main.tile[x - 1, y].wall < (byte) 1 || Main.tile[x - 1, y].wall < (byte) 1))
return;
}
--x;
--y;
int num = type == (ushort) 172 ? 38 : 36;
for (int index1 = 0; index1 < 2; ++index1)
{
for (int index2 = 0; index2 < 2; ++index2)
{
Tile tile = Main.tile[x + index1, y + index2];
tile.active(true);
tile.frameX = (short) (index1 * 18);
tile.frameY = (short) (style * num + index2 * 18);
tile.type = type;
}
}
}
public static bool PlaceObject(
int x,
int y,
int type,
bool mute = false,
int style = 0,
int alternate = 0,
int random = -1,
int direction = -1)
{
TileObject objectData;
if (type >= 470 || !TileObject.CanPlace(x, y, type, style, direction, out objectData))
return false;
objectData.random = random;
if (TileObject.Place(objectData) && !mute)
{
WorldGen.SquareTileFrame(x, y);
Main.PlaySound(0, x * 16, y * 16);
}
return false;
}
public static bool ShiftTrapdoor(int x, int y, bool playerAbove, int onlyCloseOrOpen = -1)
{
Tile tileSafely1 = Framing.GetTileSafely(x, y);
if (tileSafely1.type == (ushort) 386 && onlyCloseOrOpen != 1)
{
Point topLeftAndStyles = WorldGen.GetTopLeftAndStyles(ref x, ref y, 2, 2, 18, 18);
if (topLeftAndStyles.X == 0)
{
if (Main.netMode != 1 && Wiring.running)
{
Wiring.SkipWire(x, y);
Wiring.SkipWire(x, y + 1);
Wiring.SkipWire(x + 1, y);
Wiring.SkipWire(x + 1, y + 1);
}
if (!Collision.EmptyTile(x, y + 1, true) || !Collision.EmptyTile(x + 1, y + 1, true))
return false;
Main.PlaySound(8, x * 16 + 16, y * 16 + 16);
for (int index = 0; index < 2; ++index)
Framing.GetTileSafely(x + index, y).ClearTile();
for (int index = 0; index < 2; ++index)
{
Tile tileSafely2 = Framing.GetTileSafely(x + index, y + 1);
tileSafely2.type = (ushort) 387;
tileSafely2.frameX = (short) (index * 18);
tileSafely2.frameY = (short) (topLeftAndStyles.Y * 18);
}
for (int index1 = -1; index1 < 3; ++index1)
{
for (int index2 = 0; index2 < 3; ++index2)
WorldGen.TileFrame(x + index1, y + index2);
}
return true;
}
if (topLeftAndStyles.X == 1)
{
if (Main.netMode != 1 && Wiring.running)
{
Wiring.SkipWire(x, y - 1);
Wiring.SkipWire(x, y);
Wiring.SkipWire(x + 1, y - 1);
Wiring.SkipWire(x + 1, y);
}
if (!Collision.EmptyTile(x, y, true) || !Collision.EmptyTile(x + 1, y, true))
return false;
Main.PlaySound(8, x * 16 + 16, y * 16);
for (int index = 0; index < 2; ++index)
Framing.GetTileSafely(x + index, y + 1).ClearTile();
for (int index = 0; index < 2; ++index)
{
Tile tileSafely3 = Framing.GetTileSafely(x + index, y);
tileSafely3.type = (ushort) 387;
tileSafely3.frameX = (short) (index * 18);
tileSafely3.frameY = (short) (topLeftAndStyles.Y * 18);
}
for (int index3 = -1; index3 < 3; ++index3)
{
for (int index4 = -1; index4 < 2; ++index4)
WorldGen.TileFrame(x + index3, y + index4);
}
return true;
}
}
if (tileSafely1.type == (ushort) 387 && onlyCloseOrOpen != 0)
{
WorldGen.GetTopLeftAndStyles(ref x, ref y, 2, 1, 18, 18);
int directionInt = playerAbove.ToDirectionInt();
for (int index = 0; index < 2; ++index)
{
Tile tileSafely4 = Framing.GetTileSafely(x + index, y + directionInt);
if (tileSafely4.active() && !Main.tileCut[(int) tileSafely4.type])
return false;
}
if (Main.netMode != 1 && Wiring.running)
{
Wiring.SkipWire(x, y);
Wiring.SkipWire(x, y + directionInt);
Wiring.SkipWire(x + 1, y);
Wiring.SkipWire(x + 1, y + directionInt);
}
Main.PlaySound(8, x * 16 + 16, y * 16);
for (int index = 0; index < 2; ++index)
{
Tile tileSafely5 = Framing.GetTileSafely(x + index, y + directionInt);
if (tileSafely5.active() && Main.tileCut[(int) tileSafely5.type])
WorldGen.KillTile(x + index, y + directionInt);
}
for (int index5 = 0; index5 < 2; ++index5)
{
byte color = Framing.GetTileSafely(x + index5, y).color();
for (int index6 = 0; index6 < 2; ++index6)
{
Tile tileSafely6 = Framing.GetTileSafely(x + index5, y + index6 - (!playerAbove).ToInt());
tileSafely6.type = (ushort) 386;
tileSafely6.frameX = (short) (index5 * 18 + playerAbove.ToInt() * 36);
tileSafely6.frameY = (short) (index6 * 18);
tileSafely6.color(color);
tileSafely6.active(true);
}
}
for (int index7 = -1; index7 < 3; ++index7)
{
for (int index8 = -1; index8 < 3; ++index8)
WorldGen.TileFrame(x + index7, y + index8 - (!playerAbove).ToInt() * 2);
}
return true;
}
Main.PlaySound(9, x * 16, y * 16);
return false;
}
public static void CheckTrapDoor(int x, int y, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int w = 0;
int h = 0;
Point point = new Point();
if (type == 387)
{
w = 2;
h = 1;
point = WorldGen.GetTopLeftAndStyles(ref x, ref y, w, h, 18, 18);
flag = flag || !WorldGen.CheckTileFrames(type, x, y, w, h, point.X, 18, point.Y, 18) || !WorldGen.CheckTileAnchors(x, y, w, h, 1, AnchorType.SolidTile);
}
if (type == 386)
{
w = 2;
h = 2;
point = WorldGen.GetTopLeftAndStyles(ref x, ref y, w, h, 18, 18);
flag = flag || !WorldGen.CheckTileFrames(type, x, y, w, h, point.X, 18, point.Y, 18);
if (point.X == 0)
flag = flag || !WorldGen.CheckTileAnchors(x, y + 1, w, 1, 1, AnchorType.SolidTile);
else if (point.X == 1)
flag = flag || !WorldGen.CheckTileAnchors(x, y, w, 1, 1, AnchorType.SolidTile);
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i = x; i < x + w; ++i)
{
for (int j = y; j < y + h; ++j)
WorldGen.KillTile(i, j);
}
int Type = 3239;
if (point.Y == 0)
Type = 3239;
Item.NewItem(x * 16, y * 16, w * 16, h * 16, Type);
for (int i = x - 1; i < x + w + 1; ++i)
{
for (int j = y - 1; j < y + h + 1; ++j)
WorldGen.TileFrame(i, j);
}
WorldGen.destroyObject = false;
}
public static void CheckTallGate(int x, int y, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
Tile tileSafely1 = Framing.GetTileSafely(x, y);
Point point = new Point((int) tileSafely1.frameX / 18, 0);
TileObjectData tileData = TileObjectData.GetTileData(type, point.X);
point.Y = (int) tileSafely1.frameY / tileData.CoordinateFullHeight;
int width = tileData.Width;
int height = tileData.Height;
int index1 = 0;
for (int index2 = (int) tileSafely1.frameY % tileData.CoordinateFullHeight; index1 < height && index2 - tileData.CoordinateHeights[index1] >= 0; ++index1)
index2 -= tileData.CoordinateHeights[index1];
int coordinateFullHeight = tileData.CoordinateFullHeight;
y -= index1;
int num = point.Y * tileData.CoordinateFullHeight;
for (int index3 = 0; index3 < height; ++index3)
{
Tile tileSafely2 = Framing.GetTileSafely(x, y + index3);
if ((int) tileSafely2.frameX != point.X * tileData.CoordinateFullWidth || (int) tileSafely2.frameY != num)
{
flag = true;
break;
}
num += tileData.CoordinateHeights[index3] + tileData.CoordinatePadding;
}
if (!flag && WorldGen.CheckTileAnchors(x, y, width, height, 2, AnchorType.SolidTile))
return;
WorldGen.destroyObject = true;
for (int i = x; i < x + width; ++i)
{
for (int j = y; j < y + height; ++j)
WorldGen.KillTile(i, j);
}
int Type = 3240;
if (point.Y == 0)
Type = 3240;
Item.NewItem(x * 16, y * 16, width * 16, height * 16, Type);
for (int i = x - 1; i < x + width + 1; ++i)
{
for (int j = y - 1; j < y + height + 1; ++j)
WorldGen.TileFrame(i, j);
}
WorldGen.destroyObject = false;
}
public static bool ShiftTallGate(int x, int y, bool closing)
{
ushort num1 = closing ? (ushort) 388 : (ushort) 389;
ushort num2 = closing ? (ushort) 389 : (ushort) 388;
Tile tileSafely = Framing.GetTileSafely(x, y);
if ((int) tileSafely.type != (int) num2)
return false;
Point point = new Point((int) tileSafely.frameX / 18, 0);
TileObjectData tileData = TileObjectData.GetTileData(388, point.X);
point.Y = (int) tileSafely.frameY / tileData.CoordinateFullHeight;
int width = tileData.Width;
int height = tileData.Height;
int index1 = 0;
for (int index2 = (int) tileSafely.frameY % tileData.CoordinateFullHeight; index1 < height && index2 - tileData.CoordinateHeights[index1] >= 0; ++index1)
index2 -= tileData.CoordinateHeights[index1];
int coordinateFullHeight = tileData.CoordinateFullHeight;
y -= index1;
if (Main.netMode != 1 && Wiring.running)
{
for (int index3 = 0; index3 < height; ++index3)
Wiring.SkipWire(x, y + index3);
}
for (int index4 = 0; index4 < height; ++index4)
{
if (!Collision.EmptyTile(x, y + index4, true))
return false;
}
Main.PlaySound(8, x * 16 + 16, y * 16 + 16);
for (int index5 = 0; index5 < height; ++index5)
Framing.GetTileSafely(x, y + index5).type = num1;
for (int index6 = -1; index6 < 2; ++index6)
{
for (int index7 = -1; index7 < height + 1; ++index7)
WorldGen.TileFrame(x + index6, y + index7);
}
return true;
}
public static Point GetTopLeftAndStyles(
ref int x,
ref int y,
int w,
int h,
int frameXinc,
int frameYinc)
{
Tile tileSafely = Framing.GetTileSafely(x, y);
Point point = new Point((int) tileSafely.frameX / (w * frameXinc), (int) tileSafely.frameY / (h * frameYinc));
if (frameXinc != 0)
x -= (int) tileSafely.frameX / frameXinc % w;
if (frameYinc == 0)
return point;
y -= (int) tileSafely.frameY / frameYinc % h;
return point;
}
public static bool CheckTileFrames(
int type,
int sx,
int sy,
int w,
int h,
int styleX,
int frameXinc,
int styleY,
int frameYinc)
{
for (int index1 = 0; index1 < w; ++index1)
{
for (int index2 = 0; index2 < h; ++index2)
{
Tile tileSafely = Framing.GetTileSafely(sx + index1, sy + index2);
if (!tileSafely.active() || (int) tileSafely.type != type || (int) tileSafely.frameX != styleX * w * frameXinc + index1 * frameXinc || (int) tileSafely.frameY != styleY * h * frameYinc + index2 * frameYinc)
return false;
}
}
return true;
}
public static bool CheckTileAnchors(
int sx,
int sy,
int w,
int h,
int mode,
AnchorType anchor)
{
if ((mode & 1) == 1)
{
for (int j = sy; j < sy + h; ++j)
{
if (!WorldGen.AnchorValid(Framing.GetTileSafely(sx - 1, j), anchor) || !WorldGen.AnchorValid(Framing.GetTileSafely(sx + w, j), anchor))
return false;
}
}
if ((mode & 2) == 2)
{
for (int i = sx; i < sx + w; ++i)
{
if (!WorldGen.AnchorValid(Framing.GetTileSafely(i, sy - 1), anchor) || !WorldGen.AnchorValid(Framing.GetTileSafely(i, sy + h), anchor))
return false;
}
}
return true;
}
public static bool AnchorValid(Tile tileCache, AnchorType anchor)
{
bool flag = false;
if (tileCache.nactive())
{
if ((anchor & AnchorType.SolidTile) == AnchorType.SolidTile && Main.tileSolid[(int) tileCache.type] && !Main.tileSolidTop[(int) tileCache.type] && !Main.tileNoAttach[(int) tileCache.type] && tileCache.blockType() == 0)
flag = true;
if ((anchor & AnchorType.SolidBottom) == AnchorType.SolidBottom && (Main.tileSolid[(int) tileCache.type] && (!Main.tileSolidTop[(int) tileCache.type] || TileID.Sets.Platforms[(int) tileCache.type] && (tileCache.halfBrick() || tileCache.topSlope())) || tileCache.topSlope() || tileCache.halfBrick()) && !TileID.Sets.NotReallySolid[(int) tileCache.type] && !tileCache.bottomSlope())
flag = true;
if (!flag && ((anchor & AnchorType.SolidWithTop) == AnchorType.SolidWithTop || (anchor & AnchorType.Table) == AnchorType.Table))
{
if (TileID.Sets.Platforms[(int) tileCache.type])
{
int num = (int) tileCache.frameX / TileObjectData.PlatformFrameWidth();
if (!tileCache.halfBrick() && num >= 0 && num <= 7 || num >= 12 && num <= 16 || num >= 25 && num <= 26)
flag = true;
}
else if (Main.tileSolid[(int) tileCache.type] && Main.tileSolidTop[(int) tileCache.type])
flag = true;
}
if (!flag && (anchor & AnchorType.Table) == AnchorType.Table && !TileID.Sets.Platforms[(int) tileCache.type] && Main.tileTable[(int) tileCache.type] && tileCache.blockType() == 0)
flag = true;
if (!flag && (anchor & AnchorType.SolidSide) == AnchorType.SolidSide && Main.tileSolid[(int) tileCache.type] && !Main.tileSolidTop[(int) tileCache.type])
{
switch (tileCache.blockType())
{
case 4:
case 5:
flag = true;
break;
}
}
}
else if (!flag && (anchor & AnchorType.EmptyTile) == AnchorType.EmptyTile)
flag = true;
return flag;
}
public static bool CanPlaceSink(int x, int y, ushort type, int style)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return false;
bool flag = true;
--x;
--y;
for (int index1 = 0; index1 < 2; ++index1)
{
for (int index2 = 0; index2 < 2; ++index2)
{
if (Framing.GetTileSafely(x + index1, y + index2).active())
flag = false;
}
Tile tileSafely = Framing.GetTileSafely(x + index1, y + 2);
if (!tileSafely.nactive() || !WorldGen.SolidTile(tileSafely))
flag = false;
}
return flag;
}
public static void Place3x4(int x, int y, ushort type, int style)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = x - 1; i < x + 2; ++i)
{
for (int index = y - 3; index < y + 1; ++index)
{
if (Main.tile[i, index] == null)
Main.tile[i, index] = new Tile();
if (Main.tile[i, index].active())
flag = false;
}
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (!WorldGen.SolidTile2(i, y + 1))
flag = false;
}
if (!flag)
return;
int num1 = style * 54;
for (int index = -3; index <= 0; ++index)
{
short num2 = (short) ((3 + index) * 18);
Main.tile[x - 1, y + index].active(true);
Main.tile[x - 1, y + index].frameY = num2;
Main.tile[x - 1, y + index].frameX = (short) num1;
Main.tile[x - 1, y + index].type = type;
Main.tile[x, y + index].active(true);
Main.tile[x, y + index].frameY = num2;
Main.tile[x, y + index].frameX = (short) (num1 + 18);
Main.tile[x, y + index].type = type;
Main.tile[x + 1, y + index].active(true);
Main.tile[x + 1, y + index].frameY = num2;
Main.tile[x + 1, y + index].frameX = (short) (num1 + 36);
Main.tile[x + 1, y + index].type = type;
}
}
public static void Place5x4(int x, int y, ushort type, int style)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = x - 2; i < x + 3; ++i)
{
for (int index = y - 3; index < y + 1; ++index)
{
if (Main.tile[i, index] == null)
Main.tile[i, index] = new Tile();
if (Main.tile[i, index].active())
flag = false;
}
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (!WorldGen.SolidTile2(i, y + 1))
flag = false;
}
if (!flag)
return;
int num1 = style * 54;
for (int index = -3; index <= 0; ++index)
{
short num2 = (short) ((3 + index) * 18);
Main.tile[x - 2, y + index].active(true);
Main.tile[x - 2, y + index].frameY = num2;
Main.tile[x - 2, y + index].frameX = (short) (num1 - 36);
Main.tile[x - 2, y + index].type = type;
Main.tile[x - 1, y + index].active(true);
Main.tile[x - 1, y + index].frameY = num2;
Main.tile[x - 1, y + index].frameX = (short) (num1 - 18);
Main.tile[x - 1, y + index].type = type;
Main.tile[x, y + index].active(true);
Main.tile[x, y + index].frameY = num2;
Main.tile[x, y + index].frameX = (short) num1;
Main.tile[x, y + index].type = type;
Main.tile[x + 1, y + index].active(true);
Main.tile[x + 1, y + index].frameY = num2;
Main.tile[x + 1, y + index].frameX = (short) (num1 + 18);
Main.tile[x + 1, y + index].type = type;
Main.tile[x + 1, y + index].active(true);
Main.tile[x + 1, y + index].frameY = num2;
Main.tile[x + 1, y + index].frameX = (short) (num1 + 36);
Main.tile[x + 1, y + index].type = type;
}
}
public static void Place3x1(int x, int y, ushort type, int style = 0)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = x - 1; i < x + 2; ++i)
{
int index = y;
if (Main.tile[i, index] == null)
Main.tile[i, index] = new Tile();
if (Main.tile[i, index].active())
flag = false;
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (!WorldGen.SolidTile2(i, y + 1))
flag = false;
}
if (!flag)
return;
short num = (short) (54 * style);
Main.tile[x - 1, y].active(true);
Main.tile[x - 1, y].frameY = (short) 0;
Main.tile[x - 1, y].frameX = num;
Main.tile[x - 1, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y].frameX = (short) ((int) num + 18);
Main.tile[x, y].type = type;
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].frameY = (short) 0;
Main.tile[x + 1, y].frameX = (short) ((int) num + 36);
Main.tile[x + 1, y].type = type;
}
public static void Place3x2(int x, int y, ushort type, int style = 0)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
bool flag1 = false;
bool flag2 = true;
if (type == (ushort) 14 && style == 25)
flag1 = true;
int num1 = y - 1;
if (flag1)
num1 = y;
for (int i = x - 1; i < x + 2; ++i)
{
for (int index = num1; index < y + 1; ++index)
{
if (Main.tile[i, index] == null)
Main.tile[i, index] = new Tile();
if (Main.tile[i, index].active())
flag2 = false;
if (type == (ushort) 215 && Main.tile[i, index].liquid > (byte) 0)
flag2 = false;
}
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (type == (ushort) 285 || type == (ushort) 286 || type == (ushort) 298 || type == (ushort) 299 || type == (ushort) 310 || type >= (ushort) 361 && type <= (ushort) 364)
{
if (!WorldGen.SolidTile2(i, y + 1) && (!Main.tile[i, y + 1].nactive() || !Main.tileSolidTop[(int) Main.tile[i, y + 1].type] || Main.tile[i, y + 1].frameY != (short) 0))
flag2 = false;
}
else if (!WorldGen.SolidTile2(i, y + 1))
flag2 = false;
}
if (type == (ushort) 88)
{
if (Chest.CreateChest(x - 1, y - 1) == -1)
flag2 = false;
else if (Main.netMode == 1)
NetMessage.SendData(34, number: 2, number2: ((float) x), number3: ((float) y), number4: ((float) style));
}
if (!flag2)
return;
short num2 = (short) (54 * style);
if (flag1)
{
Main.tile[x - 1, y].active(true);
Main.tile[x - 1, y].frameY = (short) 0;
Main.tile[x - 1, y].frameX = num2;
Main.tile[x - 1, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y].frameX = (short) ((int) num2 + 18);
Main.tile[x, y].type = type;
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].frameY = (short) 0;
Main.tile[x + 1, y].frameX = (short) ((int) num2 + 36);
Main.tile[x + 1, y].type = type;
}
else
{
Main.tile[x - 1, y - 1].active(true);
Main.tile[x - 1, y - 1].frameY = (short) 0;
Main.tile[x - 1, y - 1].frameX = num2;
Main.tile[x - 1, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameY = (short) 0;
Main.tile[x, y - 1].frameX = (short) ((int) num2 + 18);
Main.tile[x, y - 1].type = type;
Main.tile[x + 1, y - 1].active(true);
Main.tile[x + 1, y - 1].frameY = (short) 0;
Main.tile[x + 1, y - 1].frameX = (short) ((int) num2 + 36);
Main.tile[x + 1, y - 1].type = type;
Main.tile[x - 1, y].active(true);
Main.tile[x - 1, y].frameY = (short) 18;
Main.tile[x - 1, y].frameX = num2;
Main.tile[x - 1, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) 18;
Main.tile[x, y].frameX = (short) ((int) num2 + 18);
Main.tile[x, y].type = type;
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].frameY = (short) 18;
Main.tile[x + 1, y].frameX = (short) ((int) num2 + 36);
Main.tile[x + 1, y].type = type;
}
}
public static void Place2x2Style(int x, int y, ushort type, int style = 0)
{
if (x < 5 || x > Main.maxTilesX - 5 || y < 5 || y > Main.maxTilesY - 5)
return;
short num1 = 0;
if (type == (ushort) 254)
num1 = (short) ((int) (short) (x % 12 / 2) * 36);
bool flag = true;
for (int i = x - 1; i < x + 1; ++i)
{
for (int index = y - 1; index < y + 1; ++index)
{
if (Main.tile[i, index] == null)
Main.tile[i, index] = new Tile();
if (Main.tile[i, index].active())
flag = false;
}
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (!WorldGen.SolidTile(i, y + 1))
flag = false;
if (type == (ushort) 254 && Main.tile[i, y + 1].type != (ushort) 2 && Main.tile[i, y + 1].type != (ushort) 109)
flag = false;
}
if (!flag)
return;
short num2 = (short) (36 * style);
Main.tile[x - 1, y - 1].active(true);
Main.tile[x - 1, y - 1].frameY = num1;
Main.tile[x - 1, y - 1].frameX = num2;
Main.tile[x - 1, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameY = num1;
Main.tile[x, y - 1].frameX = (short) ((int) num2 + 18);
Main.tile[x, y - 1].type = type;
Main.tile[x - 1, y].active(true);
Main.tile[x - 1, y].frameY = (short) ((int) num1 + 18);
Main.tile[x - 1, y].frameX = num2;
Main.tile[x - 1, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) ((int) num1 + 18);
Main.tile[x, y].frameX = (short) ((int) num2 + 18);
Main.tile[x, y].type = type;
}
public static bool NearFriendlyWall(int x, int y)
{
try
{
if (x < 2 || x >= Main.maxTilesX - 2 || y < 2 || y >= Main.maxTilesY - 2 || Main.tile[x, y].wall == (byte) 0 || Main.wallHouse[(int) Main.tile[x, y].wall] || Main.tile[x - 1, y].wall == (byte) 0 || Main.wallHouse[(int) Main.tile[x - 1, y].wall] || Main.tile[x + 1, y].wall == (byte) 0 || Main.wallHouse[(int) Main.tile[x + 1, y].wall] || Main.tile[x, y - 1].wall == (byte) 0 || Main.wallHouse[(int) Main.tile[x, y - 1].wall] || Main.tile[x, y + 1].wall == (byte) 0)
return true;
if (Main.wallHouse[(int) Main.tile[x, y + 1].wall])
return true;
}
catch
{
}
return false;
}
public static void Check2x2Style(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = j;
int num2 = (int) Main.tile[i, j].frameY / 18;
while (num2 > 1)
num2 -= 2;
int num3 = num1 - num2;
int num4 = (int) Main.tile[i, j].frameX / 18;
int num5 = 0;
while (num4 > 1)
{
num4 -= 2;
++num5;
}
int num6 = i - num4;
int num7 = num5 * 36;
for (int i1 = num6; i1 < num6 + 2; ++i1)
{
for (int index = num3; index < num3 + 2; ++index)
{
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != (i1 - num6) * 18 + num7)
flag = true;
}
if (!WorldGen.SolidTileAllowBottomSlope(i1, num3 + 2))
flag = true;
}
if (!flag)
return;
int frameX = (int) Main.tile[i, j].frameX;
WorldGen.destroyObject = true;
for (int i2 = num6; i2 < num6 + 2; ++i2)
{
for (int j1 = num3; j1 < num3 + 2; ++j1)
{
if (Main.tile[i2, j1] == null)
Main.tile[i2, j1] = new Tile();
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
switch (type)
{
case 96:
if (num5 == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 345);
if (num5 == 1)
{
Item.NewItem(i * 16, j * 16, 32, 32, 1791);
break;
}
break;
case 254:
if (frameX >= 72)
{
if (frameX < 108)
{
if (WorldGen.genRand.Next(2) == 0)
{
Item.NewItem(i * 16, j * 16, 32, 32, 1725, WorldGen.genRand.Next(1, 3));
break;
}
break;
}
if (frameX < 144)
{
Item.NewItem(i * 16, j * 16, 32, 32, 1725, WorldGen.genRand.Next(2, 6));
break;
}
Item.NewItem(i * 16, j * 16, 32, 32, 1725, WorldGen.genRand.Next(5, 11));
if (Main.halloween && WorldGen.genRand.Next(200) == 0)
{
Item.NewItem(i * 16, j * 16, 32, 32, 1799);
break;
}
break;
}
break;
case 441:
int Type1 = -1;
switch (num5)
{
case 0:
Type1 = 3665;
break;
case 1:
Type1 = 3666;
break;
case 3:
Type1 = 3667;
break;
case 7:
Type1 = 3668;
break;
case 8:
Type1 = 3669;
break;
case 9:
Type1 = 3670;
break;
case 10:
Type1 = 3671;
break;
case 11:
Type1 = 3672;
break;
case 12:
Type1 = 3673;
break;
case 13:
Type1 = 3674;
break;
case 14:
Type1 = 3675;
break;
case 15:
Type1 = 3676;
break;
case 16:
Type1 = 3677;
break;
case 17:
Type1 = 3678;
break;
case 18:
Type1 = 3679;
break;
case 19:
Type1 = 3680;
break;
case 20:
Type1 = 3681;
break;
case 21:
Type1 = 3682;
break;
case 22:
Type1 = 3683;
break;
case 28:
Type1 = 3684;
break;
case 29:
Type1 = 3685;
break;
case 30:
Type1 = 3686;
break;
case 31:
Type1 = 3687;
break;
case 32:
Type1 = 3688;
break;
case 33:
Type1 = 3689;
break;
case 34:
Type1 = 3690;
break;
case 35:
Type1 = 3691;
break;
case 37:
Type1 = 3692;
break;
case 39:
Type1 = 3693;
break;
case 41:
Type1 = 3694;
break;
case 42:
Type1 = 3695;
break;
case 43:
Type1 = 3696;
break;
case 44:
Type1 = 3697;
break;
case 45:
Type1 = 3698;
break;
case 46:
Type1 = 3699;
break;
case 47:
Type1 = 3700;
break;
case 48:
Type1 = 3701;
break;
case 49:
Type1 = 3702;
break;
case 50:
Type1 = 3703;
break;
case 51:
Type1 = 3704;
break;
}
if (Type1 != -1)
{
Item.NewItem(i * 16, j * 16, 32, 32, Type1);
break;
}
break;
case 457:
Item.NewItem(i * 16, j * 16, 32, 32, 3749);
break;
case 468:
int Type2 = -1;
switch (num5)
{
case 0:
Type2 = 3886;
break;
case 1:
Type2 = 3887;
break;
}
if (Type2 != -1)
{
Item.NewItem(i * 16, j * 16, 32, 32, Type2);
break;
}
break;
}
WorldGen.destroyObject = false;
for (int i3 = num6 - 1; i3 < num6 + 3; ++i3)
{
for (int j2 = num3 - 1; j2 < num3 + 3; ++j2)
WorldGen.TileFrame(i3, j2);
}
}
public static void PlacePumpkin(int x, int superY)
{
ushort num1 = 254;
int index1 = superY;
int num2 = WorldGen.genRand.Next(6) * 36;
if (x < 5 || x > Main.maxTilesX - 5 || index1 < 5 || index1 > Main.maxTilesY - 5)
return;
bool flag = true;
for (int i = x - 1; i < x + 1; ++i)
{
for (int index2 = index1 - 1; index2 < index1 + 1; ++index2)
{
if (Main.tile[i, index2] == null)
Main.tile[i, index2] = new Tile();
if (Main.tile[i, index2].active() && Main.tile[i, index2].type != (ushort) 3 && Main.tile[i, index2].type != (ushort) 73 && Main.tile[i, index2].type != (ushort) 113 && Main.tile[i, index2].type != (ushort) 110 && (Main.tile[i, index2].type != (ushort) 185 || Main.tile[i, index2].frameY != (short) 0))
flag = false;
if (Main.tile[i, index2].liquid > (byte) 0)
flag = false;
}
if (!WorldGen.SolidTile(i, index1 + 1) || Main.tile[i, index1 + 1].type != (ushort) 2 && Main.tile[i, index1 + 1].type != (ushort) 109)
flag = false;
}
if (!flag)
return;
Main.tile[x - 1, index1 - 1].active(true);
Main.tile[x - 1, index1 - 1].frameY = (short) num2;
Main.tile[x - 1, index1 - 1].frameX = (short) 0;
Main.tile[x - 1, index1 - 1].type = num1;
Main.tile[x, index1 - 1].active(true);
Main.tile[x, index1 - 1].frameY = (short) num2;
Main.tile[x, index1 - 1].frameX = (short) 18;
Main.tile[x, index1 - 1].type = num1;
Main.tile[x - 1, index1].active(true);
Main.tile[x - 1, index1].frameY = (short) (num2 + 18);
Main.tile[x - 1, index1].frameX = (short) 0;
Main.tile[x - 1, index1].type = num1;
Main.tile[x, index1].active(true);
Main.tile[x, index1].frameY = (short) (num2 + 18);
Main.tile[x, index1].frameX = (short) 18;
Main.tile[x, index1].type = num1;
}
public static void GrowPumpkin(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = j;
int num2 = (int) Main.tile[i, j].frameY / 18;
while (num2 > 1)
num2 -= 2;
int tileY = num1 - num2;
int num3 = (int) Main.tile[i, j].frameX / 18;
int num4 = 0;
while (num3 > 1)
{
num3 -= 2;
++num4;
}
int tileX = i - num3;
int num5 = num4 * 36;
if (num4 >= 4)
return;
for (int i1 = tileX; i1 < tileX + 2; ++i1)
{
for (int index = tileY; index < tileY + 2; ++index)
{
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || (int) Main.tile[i1, index].frameX != (i1 - tileX) * 18 + num5)
flag = true;
}
if (!WorldGen.SolidTile(i1, tileY + 2) || Main.tile[i1, tileY + 2].type != (ushort) 2 && Main.tile[i1, tileY + 2].type != (ushort) 109)
flag = true;
}
if (!flag)
{
for (int index1 = tileX; index1 < tileX + 2; ++index1)
{
for (int index2 = tileY; index2 < tileY + 2; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if ((int) Main.tile[index1, index2].type == type && Main.tile[index1, index2].active())
Main.tile[index1, index2].frameX += (short) 36;
}
}
}
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, tileX, tileY, 4);
}
public static void FixHearts()
{
for (int i = 0; i < Main.maxTilesX; ++i)
{
for (int j = 0; j < Main.maxTilesY; ++j)
{
Tile tile = Main.tile[i, j];
if (tile.active() && tile.type == (ushort) 12 && tile.frameX == (short) 0 && tile.frameY == (short) 0)
WorldGen.FixHeart(i, j);
}
}
}
public static void DestroyHeart(int i, int j)
{
WorldGen.destroyObject = true;
for (int i1 = i; i1 < i + 2; ++i1)
{
for (int j1 = j; j1 < j + 2; ++j1)
{
if (i1 < Main.maxTilesX && j1 < Main.maxTilesY)
{
Tile tile = Main.tile[i1, j1];
if (tile.active() && tile.type == (ushort) 12)
WorldGen.KillTile(i1, j1);
}
}
}
WorldGen.destroyObject = false;
}
public static void FixHeart(int i, int j)
{
if (i < 40 || i >= Main.maxTilesX - 40 || j < 40 || j >= Main.maxTilesY - 40)
{
WorldGen.DestroyHeart(i, j);
}
else
{
Tile tile1 = Main.tile[i, j + 2];
Tile tile2 = Main.tile[i + 1, j + 2];
if (tile1.active() && !Main.tileSolid[(int) tile1.type] && Main.tileCut[(int) tile1.type])
WorldGen.KillTile(i, j + 2);
if (tile2.active() && !Main.tileSolid[(int) tile2.type] && Main.tileCut[(int) tile2.type])
WorldGen.KillTile(i + 1, j + 2);
if (!tile1.active())
{
if (!tile2.active())
{
WorldGen.DestroyHeart(i, j);
return;
}
if (Main.tileSolid[(int) tile2.type])
{
tile1.type = tile2.type;
tile1.active(true);
}
}
if (!tile2.active() && Main.tileSolid[(int) tile1.type])
{
tile2.type = tile1.type;
tile2.active(true);
}
if (!tile1.nactive() || !Main.tileSolid[(int) tile1.type] || !tile2.nactive() || !Main.tileSolid[(int) tile2.type])
{
WorldGen.DestroyHeart(i, j);
}
else
{
if (tile1.blockType() != 0)
{
tile1.slope((byte) 0);
tile1.halfBrick(false);
}
if (tile2.blockType() == 0)
return;
tile2.slope((byte) 0);
tile2.halfBrick(false);
}
}
}
public static void FixChands()
{
for (int i = 5; i < Main.maxTilesX - 5; ++i)
{
for (int j = 5; j < Main.maxTilesY - 5; ++j)
{
if (Main.tile[i, j].active())
{
int type = (int) Main.tile[i, j].type;
if (Main.tile[i, j].active() && (type == 35 || type == 36 || type == 170 || type == 171 || type == 172))
WorldGen.FixChand(i, j);
}
}
}
}
public static void FixChand(int i, int j)
{
int num1 = 0;
int type = (int) Main.tile[i, j].type;
if (Main.tile[i, j].active())
{
if (type == 35)
num1 = 1;
if (type == 36)
num1 = 2;
if (type == 170)
num1 = 3;
if (type == 171)
num1 = 4;
if (type == 172)
num1 = 5;
}
if (num1 <= 0)
return;
int num2 = j;
int num3 = (int) Main.tile[i, j].frameX / 18;
while (num3 >= 3)
num3 -= 3;
if (num3 >= 3)
num3 -= 3;
int num4 = i - num3;
int num5 = num2 + (int) Main.tile[i, j].frameY / 18 * -1;
for (int index1 = num4; index1 < num4 + 3; ++index1)
{
for (int index2 = num5; index2 < num5 + 3; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].active() && (int) Main.tile[index1, index2].type == type)
{
Main.tile[index1, index2].type = (ushort) 34;
Main.tile[index1, index2].frameY += (short) (num1 * 54);
}
}
}
}
public static void PlaceChand(int x, int y, ushort type, int style = 0)
{
bool flag = true;
int num1 = 0;
for (int index1 = x - 1; index1 < x + 2; ++index1)
{
for (int index2 = y; index2 < y + 3; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].active())
flag = false;
}
}
if (Main.tile[x, y - 1] == null)
Main.tile[x, y - 1] = new Tile();
if (!Main.tile[x, y - 1].nactive() || !Main.tileSolid[(int) Main.tile[x, y - 1].type] || Main.tileSolidTop[(int) Main.tile[x, y - 1].type])
flag = false;
if (!flag)
return;
int num2 = style / 36 * 108;
int num3 = style * 18 * 3;
Main.tile[x - 1, y + num1].active(true);
Main.tile[x - 1, y + num1].frameY = (short) num3;
Main.tile[x - 1, y + num1].frameX = (short) num2;
Main.tile[x - 1, y + num1].type = type;
Main.tile[x, y + num1].active(true);
Main.tile[x, y + num1].frameY = (short) num3;
Main.tile[x, y + num1].frameX = (short) (num2 + 18);
Main.tile[x, y + num1].type = type;
Main.tile[x + 1, y + num1].active(true);
Main.tile[x + 1, y + num1].frameY = (short) num3;
Main.tile[x + 1, y + num1].frameX = (short) (num2 + 36);
Main.tile[x + 1, y + num1].type = type;
Main.tile[x - 1, y + 1 + num1].active(true);
Main.tile[x - 1, y + 1 + num1].frameY = (short) (num3 + 18);
Main.tile[x - 1, y + 1 + num1].frameX = (short) num2;
Main.tile[x - 1, y + 1 + num1].type = type;
Main.tile[x, y + 1 + num1].active(true);
Main.tile[x, y + 1 + num1].frameY = (short) (num3 + 18);
Main.tile[x, y + 1 + num1].frameX = (short) (num2 + 18);
Main.tile[x, y + 1 + num1].type = type;
Main.tile[x + 1, y + 1 + num1].active(true);
Main.tile[x + 1, y + 1 + num1].frameY = (short) (num3 + 18);
Main.tile[x + 1, y + 1 + num1].frameX = (short) (num2 + 36);
Main.tile[x + 1, y + 1 + num1].type = type;
Main.tile[x - 1, y + 2 + num1].active(true);
Main.tile[x - 1, y + 2 + num1].frameY = (short) (num3 + 36);
Main.tile[x - 1, y + 2 + num1].frameX = (short) num2;
Main.tile[x - 1, y + 2 + num1].type = type;
Main.tile[x, y + 2 + num1].active(true);
Main.tile[x, y + 2 + num1].frameY = (short) (num3 + 36);
Main.tile[x, y + 2 + num1].frameX = (short) (num2 + 18);
Main.tile[x, y + 2 + num1].type = type;
Main.tile[x + 1, y + 2 + num1].active(true);
Main.tile[x + 1, y + 2 + num1].frameY = (short) (num3 + 36);
Main.tile[x + 1, y + 2 + num1].frameX = (short) (num2 + 36);
Main.tile[x + 1, y + 2 + num1].type = type;
}
public static void CheckChand(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = 3;
if (type == 454)
num1 = 4;
int num2 = (int) Main.tile[i, j].frameX / 18;
int num3 = 0;
for (; num2 >= num1; num2 -= num1)
++num3;
int num4 = i - num2;
int num5 = 18 * num1 * num3;
if (num2 >= num1)
num2 -= num1;
int num6 = i - num2;
int num7 = (int) Main.tile[i, j].frameY / 18;
int num8 = 0;
for (; num7 >= 3; num7 -= 3)
++num8;
if (num5 >= 108)
num8 += 37 * (num5 / 108);
int num9 = 54 * num8;
if (num5 >= 108)
num9 -= 54 * (num5 / 108) * 37;
if (num7 >= 3)
num7 -= 3;
int num10 = j - num7;
for (int index1 = num6; index1 < num6 + num1; ++index1)
{
for (int index2 = num10; index2 < num10 + 3; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (!Main.tile[index1, index2].active() || (int) Main.tile[index1, index2].type != type || (int) Main.tile[index1, index2].frameX != (index1 - num4) * 18 + num5 || (int) Main.tile[index1, index2].frameY != (index2 - num10) * 18 + num9)
flag = true;
}
}
if (Main.tile[num6 + 1, num10 - 1] == null)
Main.tile[num6 + 1, num10 - 1] = new Tile();
if (!Main.tile[num6 + 1, num10 - 1].nactive() || !Main.tileSolid[(int) Main.tile[num6 + 1, num10 - 1].type] || Main.tileSolidTop[(int) Main.tile[num6 + 1, num10 - 1].type])
flag = true;
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i1 = num6; i1 < num6 + num1; ++i1)
{
for (int j1 = num10; j1 < num10 + 3; ++j1)
{
if ((int) Main.tile[i1, j1].type == type && Main.tile[i1, j1].active())
WorldGen.KillTile(i1, j1);
}
}
if (type == 454)
{
switch (Main.rand.Next(9))
{
case 2:
case 3:
case 4:
int num11 = Main.rand.Next(10, 31);
while (num11 > 0)
{
int Stack = Main.rand.Next(2, 11);
if (Stack > num11)
Stack = num11;
num11 -= Stack;
Item.NewItem(i * 16, j * 16, 32, 32, 72, Stack);
}
break;
case 5:
case 6:
int num12 = Main.rand.Next(60, 80);
while (num12 > 0)
{
int Stack = Main.rand.Next(3, 16);
if (Stack > num12)
Stack = num12;
num12 -= Stack;
Item.NewItem(i * 16 - 10, j * 16 - 10, 52, 52, 72, Stack);
}
Item.NewItem(i * 16, j * 16, 32, 32, 1358);
break;
case 7:
int num13 = Main.rand.Next(10, 31);
while (num13 > 0)
{
int Stack = Main.rand.Next(2, 9);
if (Stack > num13)
Stack = num13;
num13 -= Stack;
Item.NewItem(i * 16 - 10, j * 16 - 10, 52, 52, 72, Stack);
}
if (Main.rand.Next(8) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 3532);
if (Main.rand.Next(8) == 0)
Item.NewItem(i * 16, j * 16, 32, 32, 3532);
Item.NewItem(i * 16, j * 16, 32, 32, 73);
break;
case 8:
int num14 = 100;
while (num14 > 0)
{
int Stack = Main.rand.Next(3, 16);
if (Stack > num14)
Stack = num14;
num14 -= Stack;
Item.NewItem(i * 16 - 10, j * 16 - 10, 52, 52, 72, Stack);
}
int num15 = Main.rand.Next(30, 91);
while (num15 > 0)
{
int Stack = Main.rand.Next(7, 14);
if (Stack > num15)
Stack = num15;
num15 -= Stack;
Item.NewItem(i * 16 - 10, j * 16 - 10, 52, 52, 1349, Stack);
}
Item.NewItem(i * 16, j * 16, 32, 32, 1358);
Item.NewItem(i * 16, j * 16, 32, 32, 73);
break;
}
}
if (type == 34)
{
int Type = num8 != 1 ? (num8 != 2 ? (num8 != 3 ? (num8 != 4 ? (num8 != 5 ? (num8 != 6 ? (num8 < 7 || num8 > 17 ? (num8 < 18 || num8 > 21 ? (num8 != 22 ? (num8 != 23 ? (num8 != 24 ? (num8 != 25 ? (num8 != 26 ? (num8 != 27 ? (num8 != 28 ? (num8 != 29 ? (num8 != 30 ? (num8 != 31 ? (num8 != 32 ? (num8 != 33 ? (num8 != 34 ? (num8 != 35 ? (num8 != 36 ? (num8 != 37 ? 106 : 3894) : 3178) : 3179) : 3177) : 2813) : 2657) : 2656) : 2655) : 2654) : 2653) : 2652) : 2573) : 2558) : 2543) : 2525) : 2224) : 2141 + num8 - 18) : 2055 + num8 - 7) : 1812) : 712) : 711) : 710) : 108) : 107;
Item.NewItem(i * 16, j * 16, 32, 32, Type);
}
WorldGen.destroyObject = false;
for (int i2 = num6 - 1; i2 < num6 + num1 + 1; ++i2)
{
for (int j2 = num10 - 1; j2 < num10 + 4; ++j2)
WorldGen.TileFrame(i2, j2);
}
}
public static void Check3x3(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = j;
int num2 = (int) Main.tile[i, j].frameX / 18;
int num3 = 0;
for (; num2 >= 3; num2 -= 3)
++num3;
int num4 = i - num2;
int num5 = 54 * num3;
int num6 = (int) Main.tile[i, j].frameY / 54;
int num7 = (int) Main.tile[i, j].frameY % 54 / 18;
if (num2 >= 3)
num2 -= 3;
int num8 = i - num2;
int num9 = num1 - num7;
for (int index1 = num8; index1 < num8 + 3; ++index1)
{
for (int index2 = num9; index2 < num9 + 3; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (!Main.tile[index1, index2].active() || (int) Main.tile[index1, index2].type != type || (int) Main.tile[index1, index2].frameX != (index1 - num4) * 18 + num5 || (int) Main.tile[index1, index2].frameY != (index2 - num9) * 18 + num6 * 54)
flag = true;
}
}
if (type == 106 || type == 212 || type == 219 || type == 220 || type == 228 || type == 231 || type == 243 || type == 247 || type == 283 || type >= 300 && type <= 308 || type == 354 || type == 355 || type == 406 || type == 412 || type == 452 || type == 455)
{
for (int i1 = num8; i1 < num8 + 3; ++i1)
{
if (Main.tile[i1, num9 + 3] == null)
Main.tile[i1, num9 + 3] = new Tile();
if (!WorldGen.SolidTileAllowBottomSlope(i1, num9 + 3))
{
flag = true;
break;
}
}
}
else
{
if (Main.tile[num8 + 1, num9 - 1] == null)
Main.tile[num8 + 1, num9 - 1] = new Tile();
if (!Main.tile[num8 + 1, num9 - 1].nactive() || !Main.tileSolid[(int) Main.tile[num8 + 1, num9 - 1].type] || Main.tileSolidTop[(int) Main.tile[num8 + 1, num9 - 1].type])
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i2 = num8; i2 < num8 + 3; ++i2)
{
for (int j1 = num9; j1 < num9 + 3; ++j1)
{
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
switch (type)
{
case 106:
Item.NewItem(i * 16, j * 16, 32, 32, 363);
break;
case 212:
Item.NewItem(i * 16, j * 16, 32, 32, 951);
break;
case 219:
Item.NewItem(i * 16, j * 16, 32, 32, 997);
break;
case 220:
Item.NewItem(i * 16, j * 16, 32, 32, 998);
break;
case 228:
Item.NewItem(i * 16, j * 16, 32, 32, 1120);
break;
case 243:
Item.NewItem(i * 16, j * 16, 32, 32, 1430);
break;
case 247:
Item.NewItem(i * 16, j * 16, 32, 32, 1551);
break;
case 283:
Item.NewItem(i * 16, j * 16, 32, 32, 2172);
break;
default:
if (type >= 300 && type <= 306)
{
Item.NewItem(i * 16, j * 16, 32, 32, 2192 + type - 300);
break;
}
switch (type)
{
case 231:
int num10 = (i + 1) * 16 + 8;
int num11 = j * 16;
Gore.NewGore(new Vector2((float) num10, (float) num11), new Vector2(), 300);
Gore.NewGore(new Vector2((float) num10, (float) (num11 + 8)), new Vector2(), 301);
Gore.NewGore(new Vector2((float) num10, (float) (num11 + 16)), new Vector2(), 302);
float num12 = (float) (i * 16);
float num13 = (float) (j * 16);
float num14 = -1f;
int plr = 0;
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active && !Main.player[index].dead)
{
float num15 = Math.Abs(Main.player[index].position.X - num12) + Math.Abs(Main.player[index].position.Y - num13);
if ((double) num15 < (double) num14 || (double) num14 == -1.0)
{
plr = index;
num14 = num15;
}
}
}
NPC.SpawnOnPlayer(plr, 222);
break;
case 307:
Item.NewItem(i * 16, j * 16, 32, 32, 2203);
break;
case 308:
Item.NewItem(i * 16, j * 16, 32, 32, 2204);
break;
case 354:
Item.NewItem(i * 16, j * 16, 32, 32, 2999);
break;
case 355:
Item.NewItem(i * 16, j * 16, 32, 32, 3000);
break;
case 406:
Item.NewItem(i * 16, j * 16, 32, 32, 3365);
break;
case 412:
Item.NewItem(i * 16, j * 16, 32, 32, 3549);
break;
case 452:
Item.NewItem(i * 16, j * 16, 32, 32, 3742);
break;
case 455:
Item.NewItem(i * 16, j * 16, 32, 32, 3747);
break;
}
break;
}
WorldGen.destroyObject = false;
for (int i3 = num8 - 1; i3 < num8 + 4; ++i3)
{
for (int j2 = num9 - 1; j2 < num9 + 4; ++j2)
WorldGen.TileFrame(i3, j2);
}
}
public static void Place3x3(int x, int y, ushort type, int style = 0)
{
bool flag = true;
int num1 = 0;
if (type == (ushort) 106 || type == (ushort) 212 || type == (ushort) 219 || type == (ushort) 220 || type == (ushort) 228 || type == (ushort) 231 || type == (ushort) 243 || type == (ushort) 247 || type == (ushort) 283 || type >= (ushort) 300 && type <= (ushort) 308 || type == (ushort) 354 || type == (ushort) 355)
{
num1 = -2;
for (int index1 = x - 1; index1 < x + 2; ++index1)
{
for (int index2 = y - 2; index2 < y + 1; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].active())
flag = false;
}
}
for (int i = x - 1; i < x + 2; ++i)
{
if (Main.tile[i, y + 1] == null)
Main.tile[i, y + 1] = new Tile();
if (!WorldGen.SolidTile2(i, y + 1))
{
flag = false;
break;
}
}
}
else
{
for (int index3 = x - 1; index3 < x + 2; ++index3)
{
for (int index4 = y; index4 < y + 3; ++index4)
{
if (Main.tile[index3, index4] == null)
Main.tile[index3, index4] = new Tile();
if (Main.tile[index3, index4].active())
flag = false;
}
}
if (Main.tile[x, y - 1] == null)
Main.tile[x, y - 1] = new Tile();
if (!Main.tile[x, y - 1].nactive() || !Main.tileSolid[(int) Main.tile[x, y - 1].type] || Main.tileSolidTop[(int) Main.tile[x, y - 1].type])
flag = false;
}
if (!flag)
return;
int num2 = style * 18 * 3;
Main.tile[x - 1, y + num1].active(true);
Main.tile[x - 1, y + num1].frameY = (short) 0;
Main.tile[x - 1, y + num1].frameX = (short) num2;
Main.tile[x - 1, y + num1].type = type;
Main.tile[x, y + num1].active(true);
Main.tile[x, y + num1].frameY = (short) 0;
Main.tile[x, y + num1].frameX = (short) (num2 + 18);
Main.tile[x, y + num1].type = type;
Main.tile[x + 1, y + num1].active(true);
Main.tile[x + 1, y + num1].frameY = (short) 0;
Main.tile[x + 1, y + num1].frameX = (short) (num2 + 36);
Main.tile[x + 1, y + num1].type = type;
Main.tile[x - 1, y + 1 + num1].active(true);
Main.tile[x - 1, y + 1 + num1].frameY = (short) 18;
Main.tile[x - 1, y + 1 + num1].frameX = (short) num2;
Main.tile[x - 1, y + 1 + num1].type = type;
Main.tile[x, y + 1 + num1].active(true);
Main.tile[x, y + 1 + num1].frameY = (short) 18;
Main.tile[x, y + 1 + num1].frameX = (short) (num2 + 18);
Main.tile[x, y + 1 + num1].type = type;
Main.tile[x + 1, y + 1 + num1].active(true);
Main.tile[x + 1, y + 1 + num1].frameY = (short) 18;
Main.tile[x + 1, y + 1 + num1].frameX = (short) (num2 + 36);
Main.tile[x + 1, y + 1 + num1].type = type;
Main.tile[x - 1, y + 2 + num1].active(true);
Main.tile[x - 1, y + 2 + num1].frameY = (short) 36;
Main.tile[x - 1, y + 2 + num1].frameX = (short) num2;
Main.tile[x - 1, y + 2 + num1].type = type;
Main.tile[x, y + 2 + num1].active(true);
Main.tile[x, y + 2 + num1].frameY = (short) 36;
Main.tile[x, y + 2 + num1].frameX = (short) (num2 + 18);
Main.tile[x, y + 2 + num1].type = type;
Main.tile[x + 1, y + 2 + num1].active(true);
Main.tile[x + 1, y + 2 + num1].frameY = (short) 36;
Main.tile[x + 1, y + 2 + num1].frameX = (short) (num2 + 36);
Main.tile[x + 1, y + 2 + num1].type = type;
}
public static void PlaceSunflower(int x, int y, ushort type = 27)
{
if ((double) y > Main.worldSurface - 1.0)
return;
bool flag = true;
for (int index1 = x; index1 < x + 2; ++index1)
{
for (int index2 = y - 3; index2 < y + 1; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].active() || Main.tile[index1, index2].wall > (byte) 0)
flag = false;
}
if (Main.tile[index1, y + 1] == null)
Main.tile[index1, y + 1] = new Tile();
if (!Main.tile[index1, y + 1].nactive() || Main.tile[index1, y + 1].halfBrick() || Main.tile[index1, y + 1].slope() != (byte) 0 || Main.tile[index1, y + 1].type != (ushort) 2 && Main.tile[index1, y + 1].type != (ushort) 109)
flag = false;
}
if (!flag)
return;
int num1 = WorldGen.genRand.Next(3);
for (int index3 = 0; index3 < 2; ++index3)
{
for (int index4 = -3; index4 < 1; ++index4)
{
int num2 = index3 * 18 + WorldGen.genRand.Next(3) * 36;
if (index4 <= -2)
num2 = index3 * 18 + num1 * 36;
int num3 = (index4 + 3) * 18;
Main.tile[x + index3, y + index4].active(true);
Main.tile[x + index3, y + index4].frameX = (short) num2;
Main.tile[x + index3, y + index4].frameY = (short) num3;
Main.tile[x + index3, y + index4].type = type;
}
}
}
public static void FixSunflowers()
{
for (int i = 5; i < Main.maxTilesX - 5; ++i)
{
for (int j = 5; (double) j < Main.worldSurface; ++j)
{
if (Main.tile[i, j].active() && Main.tile[i, j].type == (ushort) 27)
WorldGen.FixSunflower(i, j);
}
}
}
public static void FixSunflower(int i, int j)
{
if (Main.tile[i, j].type != (ushort) 27)
return;
int num1 = 0;
int num2 = j;
int num3 = num1 + (int) Main.tile[i, j].frameX / 18;
int num4 = num2 + (int) Main.tile[i, j].frameY / 18 * -1;
while (num3 > 1)
num3 -= 2;
int num5 = num3 * -1 + i;
int num6 = WorldGen.genRand.Next(3) * 36;
int num7 = 0;
for (int index1 = num5; index1 < num5 + 2; ++index1)
{
for (int index2 = num4; index2 < num4 + 4; ++index2)
Main.tile[index1, index2].frameX = (short) (num7 + num6);
num7 += 18;
}
}
public static void CheckSunflower(int i, int j, int type = 27)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = 0;
int num2 = j;
int num3 = num1 + (int) Main.tile[i, j].frameX / 18;
int num4 = num2 + (int) Main.tile[i, j].frameY / 18 * -1;
while (num3 > 1)
num3 -= 2;
int num5 = num3 * -1 + i;
for (int i1 = num5; i1 < num5 + 2; ++i1)
{
for (int index = num4; index < num4 + 4; ++index)
{
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
int num6 = (int) Main.tile[i1, index].frameX / 18;
while (num6 > 1)
num6 -= 2;
if (!Main.tile[i1, index].nactive() || (int) Main.tile[i1, index].type != type || num6 != i1 - num5 || (int) Main.tile[i1, index].frameY != (index - num4) * 18)
flag = true;
}
if (Main.tile[i1, num4 + 4] == null)
Main.tile[i1, num4 + 4] = new Tile();
if (!Main.tile[i1, num4 + 4].nactive() || Main.tile[i1, num4 + 4].type != (ushort) 2 && Main.tile[i1, num4 + 4].type != (ushort) 109)
flag = true;
if (!WorldGen.SolidTile(i1, num4 + 4))
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
for (int i2 = num5; i2 < num5 + 2; ++i2)
{
for (int j1 = num4; j1 < num4 + 4; ++j1)
{
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
Item.NewItem(i * 16, j * 16, 32, 32, 63);
WorldGen.destroyObject = false;
}
public static void CheckDye(int x, int y)
{
switch ((int) Main.tile[x, y].frameX / 34)
{
case 6:
if (Main.tile[x, y + 1].nactive() && Main.tile[x, y + 1].type == (ushort) 80)
break;
WorldGen.KillTile(x, y);
break;
case 7:
if (WorldGen.SolidTile(x, y - 1))
break;
WorldGen.KillTile(x, y);
break;
default:
if (WorldGen.SolidTile(x, y + 1))
break;
WorldGen.KillTile(x, y);
break;
}
}
public static void PlaceDye(int x, int y, int style)
{
bool flag = false;
if (style == 7)
{
if (Main.tile[x, y + 1].active() && Main.tile[x, y + 1].type != (ushort) 3 && Main.tile[x, y + 1].type != (ushort) 51 && Main.tile[x, y + 1].type != (ushort) 61 && Main.tile[x, y + 1].type != (ushort) 73 && Main.tile[x, y + 1].type != (ushort) 74 && Main.tile[x, y + 1].type != (ushort) 184)
return;
if (WorldGen.SolidTile(x, y - 1) && !Main.tile[x, y + 1].active())
flag = true;
}
else
{
if (Main.tile[x, y - 1].active() && Main.tile[x, y - 1].type != (ushort) 3 && Main.tile[x, y - 1].type != (ushort) 51 && Main.tile[x, y - 1].type != (ushort) 61 && Main.tile[x, y - 1].type != (ushort) 73 && Main.tile[x, y - 1].type != (ushort) 74 && Main.tile[x, y - 1].type != (ushort) 184)
return;
if (style == 6)
{
if (Main.tile[x, y + 1].nactive() && Main.tile[x, y + 1].type == (ushort) 80 && !Main.tile[x - 1, y + 1].active() && !Main.tile[x + 1, y + 1].active())
flag = true;
}
else if (WorldGen.SolidTile(x, y + 1) && !Main.tile[x, y - 1].active())
{
switch (style)
{
case 5:
if (Main.tile[x, y].liquid == byte.MaxValue)
{
flag = true;
break;
}
break;
case 8:
case 9:
case 10:
case 11:
flag = true;
break;
default:
if (Main.tile[x, y].liquid == (byte) 0)
{
if (style == 3 || style == 4)
{
if (Main.tile[x, y].wall == (byte) 0)
{
flag = true;
break;
}
break;
}
flag = true;
break;
}
break;
}
}
}
if (!flag)
return;
Main.tile[x, y].type = (ushort) 227;
Main.tile[x, y].active(true);
Main.tile[x, y].halfBrick(false);
Main.tile[x, y].slope((byte) 0);
Main.tile[x, y].frameY = (short) 0;
Main.tile[x, y].frameX = (short) (34 * style);
}
public static bool PlacePot(int x, int y, ushort type = 28, int style = 0)
{
bool flag = true;
for (int index1 = x; index1 < x + 2; ++index1)
{
for (int index2 = y - 1; index2 < y + 1; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].active())
flag = false;
}
if (Main.tile[index1, y + 1] == null)
Main.tile[index1, y + 1] = new Tile();
if (!Main.tile[index1, y + 1].nactive() || Main.tile[index1, y + 1].halfBrick() || Main.tile[index1, y + 1].slope() != (byte) 0 || !Main.tileSolid[(int) Main.tile[index1, y + 1].type])
flag = false;
}
if (!flag)
return false;
int num1 = WorldGen.genRand.Next(3) * 36;
for (int index3 = 0; index3 < 2; ++index3)
{
for (int index4 = -1; index4 < 1; ++index4)
{
int num2 = index3 * 18 + num1;
int num3 = (index4 + 1) * 18;
Main.tile[x + index3, y + index4].active(true);
Main.tile[x + index3, y + index4].frameX = (short) num2;
Main.tile[x + index3, y + index4].frameY = (short) (num3 + style * 36);
Main.tile[x + index3, y + index4].type = type;
Main.tile[x + index3, y + index4].halfBrick(false);
}
}
return true;
}
public static bool CheckCactus(int i, int j)
{
int index1 = j;
int index2 = i;
while (Main.tile[index2, index1] != null && Main.tile[index2, index1].active() && Main.tile[index2, index1].type == (ushort) 80)
{
++index1;
if (Main.tile[index2, index1] == null)
return false;
if (!Main.tile[index2, index1].active() || Main.tile[index2, index1].type != (ushort) 80)
{
if (Main.tile[index2 - 1, index1] != null && Main.tile[index2 - 1, index1].active() && Main.tile[index2 - 1, index1].type == (ushort) 80 && Main.tile[index2 - 1, index1 - 1] != null && Main.tile[index2 - 1, index1 - 1].active() && Main.tile[index2 - 1, index1 - 1].type == (ushort) 80 && index2 >= i)
--index2;
if (Main.tile[index2 + 1, index1] != null && Main.tile[index2 + 1, index1].active() && Main.tile[index2 + 1, index1].type == (ushort) 80 && Main.tile[index2 + 1, index1 - 1] != null && Main.tile[index2 + 1, index1 - 1].active() && Main.tile[index2 + 1, index1 - 1].type == (ushort) 80 && index2 <= i)
++index2;
}
}
if (!Main.tile[index2, index1].nactive() || Main.tile[index2, index1].halfBrick() || Main.tile[index2, index1].slope() != (byte) 0 || Main.tile[index2, index1].type != (ushort) 53 && Main.tile[index2, index1].type != (ushort) 112 && Main.tile[index2, index1].type != (ushort) 116 && Main.tile[index2, index1].type != (ushort) 234)
{
WorldGen.KillTile(i, j);
return true;
}
if (i != index2)
{
if ((!Main.tile[i, j + 1].active() || Main.tile[i, j + 1].type != (ushort) 80) && (!Main.tile[i - 1, j].active() || Main.tile[i - 1, j].type != (ushort) 80) && (!Main.tile[i + 1, j].active() || Main.tile[i + 1, j].type != (ushort) 80))
{
WorldGen.KillTile(i, j);
return true;
}
}
else if (i == index2 && (!Main.tile[i, j + 1].active() || Main.tile[i, j + 1].type != (ushort) 80 && Main.tile[i, j + 1].type != (ushort) 53 && Main.tile[i, j + 1].type != (ushort) 112 && Main.tile[i, j + 1].type != (ushort) 116 && Main.tile[i, j + 1].type != (ushort) 234))
{
WorldGen.KillTile(i, j);
return true;
}
return false;
}
public static void PlantCactus(int i, int j)
{
WorldGen.GrowCactus(i, j);
for (int index = 0; index < 150; ++index)
WorldGen.GrowCactus(WorldGen.genRand.Next(i - 1, i + 2), WorldGen.genRand.Next(j - 10, j + 2));
}
public static void CheckOrb(int i, int j, int type)
{
int frameX = (int) Main.tile[i, j].frameX;
bool flag = false;
if (frameX >= 36)
flag = true;
if (WorldGen.destroyObject)
return;
int num1 = Main.tile[i, j].frameX == (short) 0 || Main.tile[i, j].frameX == (short) 36 ? i : i - 1;
int num2 = Main.tile[i, j].frameY != (short) 0 ? j - 1 : j;
for (int index1 = 0; index1 < 2; ++index1)
{
for (int index2 = 0; index2 < 2; ++index2)
{
Tile tile = Main.tile[num1 + index1, num2 + index2];
if (tile != null && (!tile.nactive() || (int) tile.type != type))
{
WorldGen.destroyObject = true;
break;
}
}
if (!WorldGen.destroyObject)
{
if (type == 12)
{
Tile tile = Main.tile[num1 + index1, num2 + 2];
if (tile != null && (!tile.nactive() || !Main.tileSolid[(int) tile.type] || tile.blockType() != 0))
{
WorldGen.destroyObject = true;
break;
}
}
}
else
break;
}
if (!WorldGen.destroyObject)
return;
for (int i1 = num1; i1 < num1 + 2; ++i1)
{
for (int j1 = num2; j1 < num2 + 2; ++j1)
{
if ((int) Main.tile[i1, j1].type == type)
WorldGen.KillTile(i1, j1);
}
}
if (Main.netMode != 1 && !WorldGen.noTileActions)
{
switch (type)
{
case 12:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 29);
break;
case 31:
if (WorldGen.genRand.Next(2) == 0)
WorldGen.spawnMeteor = true;
if (flag)
{
int num3 = Main.rand.Next(5);
if (!WorldGen.shadowOrbSmashed)
num3 = 0;
switch (num3)
{
case 0:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 800, pfix: -1);
int Stack = WorldGen.genRand.Next(100, 101);
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 97, Stack);
break;
case 1:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 1256, pfix: -1);
break;
case 2:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 802, pfix: -1);
break;
case 3:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 3062, pfix: -1);
break;
case 4:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 1290, pfix: -1);
break;
}
}
else
{
int num4 = Main.rand.Next(5);
if (!WorldGen.shadowOrbSmashed)
num4 = 0;
switch (num4)
{
case 0:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 96, pfix: -1);
int Stack = WorldGen.genRand.Next(100, 101);
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 97, Stack);
break;
case 1:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 64, pfix: -1);
break;
case 2:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 162, pfix: -1);
break;
case 3:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 115, pfix: -1);
break;
case 4:
Item.NewItem(num1 * 16, num2 * 16, 32, 32, 111, pfix: -1);
break;
}
}
WorldGen.shadowOrbSmashed = true;
++WorldGen.shadowOrbCount;
if (WorldGen.shadowOrbCount >= 3)
{
WorldGen.shadowOrbCount = 0;
float num5 = (float) (num1 * 16);
float num6 = (float) (num2 * 16);
float num7 = -1f;
int plr = 0;
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
float num8 = Math.Abs(Main.player[index].position.X - num5) + Math.Abs(Main.player[index].position.Y - num6);
if ((double) num8 < (double) num7 || (double) num7 == -1.0)
{
plr = index;
num7 = num8;
}
}
if (flag)
NPC.SpawnOnPlayer(plr, 266);
else
NPC.SpawnOnPlayer(plr, 13);
}
else
{
LocalizedText localizedText = Lang.misc[10];
if (WorldGen.shadowOrbCount == 2)
localizedText = Lang.misc[11];
switch (Main.netMode)
{
case 0:
Main.NewText(localizedText.ToString(), (byte) 50, B: (byte) 130);
break;
case 2:
NetMessage.BroadcastChatMessage(NetworkText.FromKey(localizedText.Key), new Color(50, (int) byte.MaxValue, 130));
break;
}
}
AchievementsHelper.NotifyProgressionEvent(7);
break;
}
}
if (flag)
Main.PlaySound(4, i * 16, j * 16);
else
Main.PlaySound(13, i * 16, j * 16);
WorldGen.destroyObject = false;
}
public static void CheckPalmTree(int i, int j)
{
int num1 = -1;
int num2 = -1;
int type = (int) Main.tile[i, j].type;
int frameX = (int) Main.tile[i, j].frameX;
int frameY = (int) Main.tile[i, j].frameY;
if (Main.tile[i, j - 1] != null && Main.tile[i, j - 1].active())
num1 = (int) Main.tile[i, j - 1].type;
if (Main.tile[i, j + 1] != null && Main.tile[i, j + 1].active())
num2 = (int) Main.tile[i, j + 1].type;
if (num2 == 53)
num2 = 53;
if (num2 == 234)
num2 = 53;
if (num2 == 116)
num2 = 53;
if (num2 == 112)
num2 = 53;
if (num2 != 53 && num2 != type)
WorldGen.KillTile(i, j);
if ((Main.tile[i, j].frameX == (short) 66 || Main.tile[i, j].frameX == (short) 220) && num2 != 53)
WorldGen.KillTile(i, j);
if (num1 != type && Main.tile[i, j].frameX <= (short) 44)
Main.tile[i, j].frameX = (short) (WorldGen.genRand.Next(7, 10) * 22);
else if (num1 != type && Main.tile[i, j].frameX == (short) 66)
Main.tile[i, j].frameX = (short) 220;
if ((int) Main.tile[i, j].frameX == frameX || (int) Main.tile[i, j].frameY == frameY || frameX < 0 || frameY < 0)
return;
WorldGen.TileFrame(i - 1, j);
WorldGen.TileFrame(i + 1, j);
WorldGen.TileFrame(i, j - 1);
WorldGen.TileFrame(i, j + 1);
}
public static void CheckTree(int i, int j)
{
int num1 = -1;
int num2 = -1;
int num3 = -1;
int num4 = -1;
int type1 = (int) Main.tile[i, j].type;
int frameX = (int) Main.tile[i, j].frameX;
int frameY = (int) Main.tile[i, j].frameY;
if (Main.tile[i - 1, j] != null && Main.tile[i - 1, j].active())
num2 = (int) Main.tile[i - 1, j].type;
if (Main.tile[i + 1, j] != null && Main.tile[i + 1, j].active())
num3 = (int) Main.tile[i + 1, j].type;
if (Main.tile[i, j - 1] != null && Main.tile[i, j - 1].active())
num1 = (int) Main.tile[i, j - 1].type;
if (Main.tile[i, j + 1] != null && Main.tile[i, j + 1].active())
num4 = (int) Main.tile[i, j + 1].type;
if (Main.tile[i - 1, j - 1] != null && Main.tile[i - 1, j - 1].active())
{
int type2 = (int) Main.tile[i - 1, j - 1].type;
}
if (Main.tile[i + 1, j - 1] != null && Main.tile[i + 1, j - 1].active())
{
int type3 = (int) Main.tile[i + 1, j - 1].type;
}
if (Main.tile[i - 1, j + 1] != null && Main.tile[i - 1, j + 1].active())
{
int type4 = (int) Main.tile[i - 1, j + 1].type;
}
if (Main.tile[i + 1, j + 1] != null && Main.tile[i + 1, j + 1].active())
{
int type5 = (int) Main.tile[i + 1, j + 1].type;
}
if (num4 == 23)
num4 = 2;
if (num4 == 60)
num4 = 2;
if (num4 == 70)
num4 = 2;
if (num4 == 109)
num4 = 2;
if (num4 == 147)
num4 = 2;
if (num4 == 199)
num4 = 2;
if (num4 != 2 && num4 != type1 && (Main.tile[i, j].frameX == (short) 0 && Main.tile[i, j].frameY <= (short) 130 || Main.tile[i, j].frameX == (short) 22 && Main.tile[i, j].frameY <= (short) 130 || Main.tile[i, j].frameX == (short) 44 && Main.tile[i, j].frameY <= (short) 130))
WorldGen.KillTile(i, j);
if (Main.tile[i, j].frameX >= (short) 22 && Main.tile[i, j].frameX <= (short) 44 && Main.tile[i, j].frameY >= (short) 132 && Main.tile[i, j].frameY <= (short) 176)
{
if (num4 != 2)
WorldGen.KillTile(i, j);
else if ((Main.tile[i, j].frameX != (short) 22 || num2 != type1) && (Main.tile[i, j].frameX != (short) 44 || num3 != type1))
WorldGen.KillTile(i, j);
}
else if (Main.tile[i, j].frameX == (short) 88 && Main.tile[i, j].frameY >= (short) 0 && Main.tile[i, j].frameY <= (short) 44 || Main.tile[i, j].frameX == (short) 66 && Main.tile[i, j].frameY >= (short) 66 && Main.tile[i, j].frameY <= (short) 130 || Main.tile[i, j].frameX == (short) 110 && Main.tile[i, j].frameY >= (short) 66 && Main.tile[i, j].frameY <= (short) 110 || Main.tile[i, j].frameX == (short) 132 && Main.tile[i, j].frameY >= (short) 0 && Main.tile[i, j].frameY <= (short) 176)
{
if (num2 == type1 && num3 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 110;
Main.tile[i, j].frameY = (short) 66;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 110;
Main.tile[i, j].frameY = (short) 88;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 110;
Main.tile[i, j].frameY = (short) 110;
}
}
else if (num2 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 88;
Main.tile[i, j].frameY = (short) 0;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 88;
Main.tile[i, j].frameY = (short) 22;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 88;
Main.tile[i, j].frameY = (short) 44;
}
}
else if (num3 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 66;
Main.tile[i, j].frameY = (short) 66;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 66;
Main.tile[i, j].frameY = (short) 88;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 66;
Main.tile[i, j].frameY = (short) 110;
}
}
else
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 0;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 22;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 44;
}
}
}
if (Main.tile[i, j].frameY >= (short) 132 && Main.tile[i, j].frameY <= (short) 176 && (Main.tile[i, j].frameX == (short) 0 || Main.tile[i, j].frameX == (short) 66 || Main.tile[i, j].frameX == (short) 88))
{
if (num4 != 2)
WorldGen.KillTile(i, j);
if (num2 != type1 && num3 != type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 0;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 22;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 44;
}
}
else if (num2 != type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 132;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 154;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 176;
}
}
else if (num3 != type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 66;
Main.tile[i, j].frameY = (short) 132;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 66;
Main.tile[i, j].frameY = (short) 154;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 66;
Main.tile[i, j].frameY = (short) 176;
}
}
else
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 88;
Main.tile[i, j].frameY = (short) 132;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 88;
Main.tile[i, j].frameY = (short) 154;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 88;
Main.tile[i, j].frameY = (short) 176;
}
}
}
if (Main.tile[i, j].frameX == (short) 66 && (Main.tile[i, j].frameY == (short) 0 || Main.tile[i, j].frameY == (short) 22 || Main.tile[i, j].frameY == (short) 44) || Main.tile[i, j].frameX == (short) 44 && (Main.tile[i, j].frameY == (short) 198 || Main.tile[i, j].frameY == (short) 220 || Main.tile[i, j].frameY == (short) 242))
{
if (num3 != type1)
WorldGen.KillTile(i, j);
}
else if (Main.tile[i, j].frameX == (short) 88 && (Main.tile[i, j].frameY == (short) 66 || Main.tile[i, j].frameY == (short) 88 || Main.tile[i, j].frameY == (short) 110) || Main.tile[i, j].frameX == (short) 66 && (Main.tile[i, j].frameY == (short) 198 || Main.tile[i, j].frameY == (short) 220 || Main.tile[i, j].frameY == (short) 242))
{
if (num2 != type1)
WorldGen.KillTile(i, j);
}
else if (num4 == -1 || num4 == 23)
WorldGen.KillTile(i, j);
else if (num1 != type1 && Main.tile[i, j].frameY < (short) 198 && (Main.tile[i, j].frameX != (short) 22 && Main.tile[i, j].frameX != (short) 44 || Main.tile[i, j].frameY < (short) 132))
{
if (num2 == type1 || num3 == type1)
{
if (num4 == type1)
{
if (num2 == type1 && num3 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 132;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 154;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 176;
}
}
else if (num2 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 0;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 22;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 44;
}
}
else if (num3 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 66;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 88;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 132;
Main.tile[i, j].frameY = (short) 110;
}
}
}
else if (num2 == type1 && num3 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 132;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 154;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 176;
}
}
else if (num2 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 0;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 22;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 44;
}
}
else if (num3 == type1)
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 66;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 88;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 154;
Main.tile[i, j].frameY = (short) 110;
}
}
}
else
{
if (Main.tile[i, j].frameNumber() == (byte) 0)
{
Main.tile[i, j].frameX = (short) 110;
Main.tile[i, j].frameY = (short) 0;
}
if (Main.tile[i, j].frameNumber() == (byte) 1)
{
Main.tile[i, j].frameX = (short) 110;
Main.tile[i, j].frameY = (short) 22;
}
if (Main.tile[i, j].frameNumber() == (byte) 2)
{
Main.tile[i, j].frameX = (short) 110;
Main.tile[i, j].frameY = (short) 44;
}
}
}
if ((int) Main.tile[i, j].frameX == frameX || (int) Main.tile[i, j].frameY == frameY || frameX < 0 || frameY < 0)
return;
WorldGen.TileFrame(i - 1, j);
WorldGen.TileFrame(i + 1, j);
WorldGen.TileFrame(i, j - 1);
WorldGen.TileFrame(i, j + 1);
}
public static void Convert(int i, int j, int conversionType, int size = 4)
{
for (int index1 = i - size; index1 <= i + size; ++index1)
{
for (int index2 = j - size; index2 <= j + size; ++index2)
{
if (WorldGen.InWorld(index1, index2, 1) && Math.Abs(index1 - i) + Math.Abs(index2 - j) < 6)
{
int type = (int) Main.tile[index1, index2].type;
int wall = (int) Main.tile[index1, index2].wall;
switch (conversionType)
{
case 1:
if (type <= 470 && wall <= 231)
{
if (WallID.Sets.Conversion.Grass[wall] && wall != 69)
{
Main.tile[index1, index2].wall = (byte) 69;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.Stone[wall] && wall != 3)
{
Main.tile[index1, index2].wall = (byte) 3;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.HardenedSand[wall] && wall != 217)
{
Main.tile[index1, index2].wall = (byte) 217;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.Sandstone[wall] && wall != 220)
{
Main.tile[index1, index2].wall = (byte) 220;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
if ((Main.tileMoss[type] || TileID.Sets.Conversion.Stone[type]) && type != 25)
{
Main.tile[index1, index2].type = (ushort) 25;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Grass[type] && type != 23)
{
Main.tile[index1, index2].type = (ushort) 23;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Ice[type] && type != 163)
{
Main.tile[index1, index2].type = (ushort) 163;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Sand[type] && type != 112)
{
Main.tile[index1, index2].type = (ushort) 112;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.HardenedSand[type] && type != 398)
{
Main.tile[index1, index2].type = (ushort) 398;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Sandstone[type] && type != 400)
{
Main.tile[index1, index2].type = (ushort) 400;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Thorn[type] && type != 32)
{
Main.tile[index1, index2].type = (ushort) 32;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
if (type == 59 && (Main.tile[index1 - 1, index2].type == (ushort) 23 || Main.tile[index1 + 1, index2].type == (ushort) 23 || Main.tile[index1, index2 - 1].type == (ushort) 23 || Main.tile[index1, index2 + 1].type == (ushort) 23))
{
Main.tile[index1, index2].type = (ushort) 0;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
continue;
}
continue;
case 2:
if (type <= 470 && wall <= 231)
{
if (WallID.Sets.Conversion.Grass[wall] && wall != 70)
{
Main.tile[index1, index2].wall = (byte) 70;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.Stone[wall] && wall != 28)
{
Main.tile[index1, index2].wall = (byte) 28;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.HardenedSand[wall] && wall != 219)
{
Main.tile[index1, index2].wall = (byte) 219;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.Sandstone[wall] && wall != 222)
{
Main.tile[index1, index2].wall = (byte) 222;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
if ((Main.tileMoss[type] || TileID.Sets.Conversion.Stone[type]) && type != 117)
{
Main.tile[index1, index2].type = (ushort) 117;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Grass[type] && type != 109)
{
Main.tile[index1, index2].type = (ushort) 109;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Ice[type] && type != 164)
{
Main.tile[index1, index2].type = (ushort) 164;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Sand[type] && type != 116)
{
Main.tile[index1, index2].type = (ushort) 116;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.HardenedSand[type] && type != 402)
{
Main.tile[index1, index2].type = (ushort) 402;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Sandstone[type] && type != 403)
{
Main.tile[index1, index2].type = (ushort) 403;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Thorn[type])
{
WorldGen.KillTile(index1, index2);
if (Main.netMode == 1)
NetMessage.SendData(17, number2: ((float) index1), number3: ((float) index2));
}
if (type == 59 && (Main.tile[index1 - 1, index2].type == (ushort) 109 || Main.tile[index1 + 1, index2].type == (ushort) 109 || Main.tile[index1, index2 - 1].type == (ushort) 109 || Main.tile[index1, index2 + 1].type == (ushort) 109))
{
Main.tile[index1, index2].type = (ushort) 0;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
continue;
}
continue;
case 3:
if (Main.tile[index1, index2].wall == (byte) 64 || Main.tile[index1, index2].wall == (byte) 15)
{
Main.tile[index1, index2].wall = (byte) 80;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 3);
}
if (Main.tile[index1, index2].type == (ushort) 60)
{
Main.tile[index1, index2].type = (ushort) 70;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 3);
continue;
}
if (TileID.Sets.Conversion.Thorn[type])
{
WorldGen.KillTile(index1, index2);
if (Main.netMode == 1)
{
NetMessage.SendData(17, number2: ((float) index1), number3: ((float) index2));
continue;
}
continue;
}
continue;
case 4:
if (type <= 470 && wall <= 231)
{
if (WallID.Sets.Conversion.Grass[wall] && wall != 81)
{
Main.tile[index1, index2].wall = (byte) 81;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.Stone[wall] && wall != 83)
{
Main.tile[index1, index2].wall = (byte) 83;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.HardenedSand[wall] && wall != 218)
{
Main.tile[index1, index2].wall = (byte) 218;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.Sandstone[wall] && wall != 221)
{
Main.tile[index1, index2].wall = (byte) 221;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
if ((Main.tileMoss[type] || TileID.Sets.Conversion.Stone[type]) && type != 203)
{
Main.tile[index1, index2].type = (ushort) 203;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Grass[type] && type != 199)
{
Main.tile[index1, index2].type = (ushort) 199;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Ice[type] && type != 200)
{
Main.tile[index1, index2].type = (ushort) 200;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Sand[type] && type != 234)
{
Main.tile[index1, index2].type = (ushort) 234;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.HardenedSand[type] && type != 399)
{
Main.tile[index1, index2].type = (ushort) 399;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Sandstone[type] && type != 401)
{
Main.tile[index1, index2].type = (ushort) 401;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (TileID.Sets.Conversion.Thorn[type] && type != 352)
{
Main.tile[index1, index2].type = (ushort) 352;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
if (type == 59 && (Main.tile[index1 - 1, index2].type == (ushort) 199 || Main.tile[index1 + 1, index2].type == (ushort) 199 || Main.tile[index1, index2 - 1].type == (ushort) 199 || Main.tile[index1, index2 + 1].type == (ushort) 199))
{
Main.tile[index1, index2].type = (ushort) 0;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
continue;
}
continue;
default:
if (Main.tile[index1, index2].wall == (byte) 69 || Main.tile[index1, index2].wall == (byte) 70 || Main.tile[index1, index2].wall == (byte) 81)
{
Main.tile[index1, index2].wall = (double) index2 >= Main.worldSurface ? (byte) 64 : (WorldGen.genRand.Next(10) != 0 ? (byte) 63 : (byte) 65);
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (Main.tile[index1, index2].wall == (byte) 3 || Main.tile[index1, index2].wall == (byte) 28 || Main.tile[index1, index2].wall == (byte) 83)
{
Main.tile[index1, index2].wall = (byte) 1;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (Main.tile[index1, index2].wall == (byte) 80)
{
if ((double) index2 < Main.worldSurface + 4.0 + (double) WorldGen.genRand.Next(3) || (double) index2 > ((double) Main.maxTilesY + Main.rockLayer) / 2.0 - 3.0 + (double) WorldGen.genRand.Next(3))
{
Main.tile[index1, index2].wall = (byte) 15;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 3);
}
else
{
Main.tile[index1, index2].wall = (byte) 64;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 3);
}
}
else if (WallID.Sets.Conversion.HardenedSand[wall] && wall != 216)
{
Main.tile[index1, index2].wall = (byte) 216;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
else if (WallID.Sets.Conversion.Sandstone[wall] && wall != 187)
{
Main.tile[index1, index2].wall = (byte) 187;
WorldGen.SquareWallFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
}
if (Main.tile[index1, index2].type == (ushort) 23 || Main.tile[index1, index2].type == (ushort) 109 || Main.tile[index1, index2].type == (ushort) 199)
{
Main.tile[index1, index2].type = (ushort) 2;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
if (Main.tile[index1, index2].type == (ushort) 117 || Main.tile[index1, index2].type == (ushort) 25 || Main.tile[index1, index2].type == (ushort) 203)
{
Main.tile[index1, index2].type = (ushort) 1;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
if (Main.tile[index1, index2].type == (ushort) 112 || Main.tile[index1, index2].type == (ushort) 116 || Main.tile[index1, index2].type == (ushort) 234)
{
Main.tile[index1, index2].type = (ushort) 53;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
if (Main.tile[index1, index2].type == (ushort) 398 || Main.tile[index1, index2].type == (ushort) 402 || Main.tile[index1, index2].type == (ushort) 399)
{
Main.tile[index1, index2].type = (ushort) 397;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
if (Main.tile[index1, index2].type == (ushort) 400 || Main.tile[index1, index2].type == (ushort) 403 || Main.tile[index1, index2].type == (ushort) 401)
{
Main.tile[index1, index2].type = (ushort) 396;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
if (Main.tile[index1, index2].type == (ushort) 164 || Main.tile[index1, index2].type == (ushort) 163 || Main.tile[index1, index2].type == (ushort) 200)
{
Main.tile[index1, index2].type = (ushort) 161;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
if (Main.tile[index1, index2].type == (ushort) 70)
{
Main.tile[index1, index2].type = (ushort) 60;
WorldGen.SquareTileFrame(index1, index2);
NetMessage.SendTileSquare(-1, index1, index2, 1);
continue;
}
if (Main.tile[index1, index2].type == (ushort) 32 || Main.tile[index1, index2].type == (ushort) 352)
{
WorldGen.KillTile(index1, index2);
if (Main.netMode == 1)
{
NetMessage.SendData(17, number2: ((float) index1), number3: ((float) index2));
continue;
}
continue;
}
continue;
}
}
}
}
}
public static void CactusFrame(int i, int j)
{
try
{
int index1 = j;
int index2 = i;
if (WorldGen.CheckCactus(i, j))
return;
while (Main.tile[index2, index1].active() && Main.tile[index2, index1].type == (ushort) 80)
{
++index1;
if (Main.tile[index2, index1] == null)
return;
if (!Main.tile[index2, index1].active() || Main.tile[index2, index1].type != (ushort) 80)
{
if (Main.tile[index2 - 1, index1] != null && Main.tile[index2 - 1, index1].active() && Main.tile[index2 - 1, index1].type == (ushort) 80 && Main.tile[index2 - 1, index1 - 1].active() && Main.tile[index2 - 1, index1 - 1].type == (ushort) 80 && index2 >= i)
--index2;
if (Main.tile[index2 + 1, index1] != null && Main.tile[index2 + 1, index1].active() && Main.tile[index2 + 1, index1].type == (ushort) 80 && Main.tile[index2 + 1, index1 - 1].active() && Main.tile[index2 + 1, index1 - 1].type == (ushort) 80 && index2 <= i)
++index2;
}
}
int num1 = index1 - 1;
int num2 = i - index2;
num1 = j;
if (Main.tile[i - 2, j] == null)
return;
int type = (int) Main.tile[i - 2, j].type;
if (Main.tile[i - 1, j] == null)
return;
int num3 = (int) Main.tile[i - 1, j].type;
if (Main.tile[i + 1, j] == null)
return;
int num4 = (int) Main.tile[i + 1, j].type;
int num5 = (int) Main.tile[i, j - 1].type;
if (num5 == 227)
num5 = 80;
int index3 = (int) Main.tile[i, j + 1].type;
int num6 = (int) Main.tile[i - 1, j + 1].type;
int num7 = (int) Main.tile[i + 1, j + 1].type;
if (!Main.tile[i - 1, j].active())
num3 = -1;
if (!Main.tile[i + 1, j].active())
num4 = -1;
if (!Main.tile[i, j - 1].active())
num5 = -1;
if (!Main.tile[i, j + 1].active())
index3 = -1;
if (!Main.tile[i - 1, j + 1].active())
num6 = -1;
if (!Main.tile[i + 1, j + 1].active())
num7 = -1;
short num8 = Main.tile[i, j].frameX;
short num9 = Main.tile[i, j].frameY;
switch (num2)
{
case -1:
if (num4 == 80)
{
if (num5 != 80 && index3 != 80)
{
num8 = (short) 108;
num9 = (short) 36;
break;
}
if (index3 != 80)
{
num8 = (short) 54;
num9 = (short) 36;
break;
}
if (num5 != 80)
{
num8 = (short) 54;
num9 = (short) 0;
break;
}
num8 = (short) 54;
num9 = (short) 18;
break;
}
if (num5 != 80)
{
num8 = (short) 54;
num9 = (short) 0;
break;
}
num8 = (short) 54;
num9 = (short) 18;
break;
case 0:
if (num5 != 80)
{
if (num3 == 80 && num4 == 80 && num6 != 80 && num7 != 80 && type != 80)
{
num8 = (short) 90;
num9 = (short) 0;
break;
}
if (num3 == 80 && num6 != 80 && type != 80)
{
num8 = (short) 72;
num9 = (short) 0;
break;
}
if (num4 == 80 && num7 != 80)
{
num8 = (short) 18;
num9 = (short) 0;
break;
}
num8 = (short) 0;
num9 = (short) 0;
break;
}
if (num3 == 80 && num4 == 80 && num6 != 80 && num7 != 80 && type != 80)
{
num8 = (short) 90;
num9 = (short) 36;
break;
}
if (num3 == 80 && num6 != 80 && type != 80)
{
num8 = (short) 72;
num9 = (short) 36;
break;
}
if (num4 == 80 && num7 != 80)
{
num8 = (short) 18;
num9 = (short) 36;
break;
}
if (index3 >= 0 && Main.tileSolid[index3])
{
num8 = (short) 0;
num9 = (short) 36;
break;
}
num8 = (short) 0;
num9 = (short) 18;
break;
case 1:
if (num3 == 80)
{
if (num5 != 80 && index3 != 80)
{
num8 = (short) 108;
num9 = (short) 18;
break;
}
if (index3 != 80)
{
num8 = (short) 36;
num9 = (short) 36;
break;
}
if (num5 != 80)
{
num8 = (short) 36;
num9 = (short) 0;
break;
}
num8 = (short) 36;
num9 = (short) 18;
break;
}
if (num5 != 80)
{
num8 = (short) 36;
num9 = (short) 0;
break;
}
num8 = (short) 36;
num9 = (short) 18;
break;
}
if ((int) num8 == (int) Main.tile[i, j].frameX && (int) num9 == (int) Main.tile[i, j].frameY)
return;
Main.tile[i, j].frameX = num8;
Main.tile[i, j].frameY = num9;
WorldGen.DiamondTileFrame(i, j);
}
catch
{
Main.tile[i, j].frameX = (short) 0;
Main.tile[i, j].frameY = (short) 0;
}
}
public static void GrowCactus(int i, int j)
{
int index1 = j;
int i1 = i;
if (!Main.tile[i, j].nactive() || Main.tile[i, j].halfBrick() || Main.tile[i, j].slope() != (byte) 0 || Main.tile[i, j - 1].liquid > (byte) 0 || Main.tile[i, j].type != (ushort) 53 && Main.tile[i, j].type != (ushort) 80 && Main.tile[i, j].type != (ushort) 234 && Main.tile[i, j].type != (ushort) 112 && Main.tile[i, j].type != (ushort) 116)
return;
if (Main.tile[i, j].type == (ushort) 53 || Main.tile[i, j].type == (ushort) 112 || Main.tile[i, j].type == (ushort) 116 || Main.tile[i, j].type == (ushort) 234)
{
if (Main.tile[i, j - 1].active() || Main.tile[i - 1, j - 1].active() || Main.tile[i + 1, j - 1].active())
return;
int num1 = 0;
int num2 = 0;
for (int index2 = i - 6; index2 <= i + 6; ++index2)
{
for (int index3 = j - 3; index3 <= j + 1; ++index3)
{
try
{
if (Main.tile[index2, index3].active())
{
if (Main.tile[index2, index3].type == (ushort) 80)
{
++num1;
if (num1 >= 4)
return;
}
if (Main.tile[index2, index3].type != (ushort) 53 && Main.tile[index2, index3].type != (ushort) 112 && Main.tile[index2, index3].type != (ushort) 116)
{
if (Main.tile[index2, index3].type != (ushort) 234)
continue;
}
++num2;
}
}
catch
{
}
}
}
if (num2 <= 10)
return;
Main.tile[i, j - 1].active(true);
Main.tile[i, j - 1].type = (ushort) 80;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, i, j - 1, 1);
WorldGen.SquareTileFrame(i1, index1 - 1);
}
else
{
if (Main.tile[i, j].type != (ushort) 80)
return;
while (Main.tile[i1, index1].active() && Main.tile[i1, index1].type == (ushort) 80)
{
++index1;
if (!Main.tile[i1, index1].active() || Main.tile[i1, index1].type != (ushort) 80)
{
if (Main.tile[i1 - 1, index1].active() && Main.tile[i1 - 1, index1].type == (ushort) 80 && Main.tile[i1 - 1, index1 - 1].active() && Main.tile[i1 - 1, index1 - 1].type == (ushort) 80 && i1 >= i)
--i1;
if (Main.tile[i1 + 1, index1].active() && Main.tile[i1 + 1, index1].type == (ushort) 80 && Main.tile[i1 + 1, index1 - 1].active() && Main.tile[i1 + 1, index1 - 1].type == (ushort) 80 && i1 <= i)
++i1;
}
}
int num3 = index1 - 1 - j;
int num4 = i - i1;
int num5 = i - num4;
int num6 = j;
int num7 = 11 - num3;
int num8 = 0;
for (int index4 = num5 - 2; index4 <= num5 + 2; ++index4)
{
for (int index5 = num6 - num7; index5 <= num6 + num3; ++index5)
{
if (Main.tile[index4, index5].active() && Main.tile[index4, index5].type == (ushort) 80)
++num8;
}
}
if (num8 >= WorldGen.genRand.Next(11, 13))
return;
int index6 = i;
int index7 = j;
if (num4 == 0)
{
if (num3 == 0)
{
if (Main.tile[index6, index7 - 1].active())
return;
Main.tile[index6, index7 - 1].active(true);
Main.tile[index6, index7 - 1].type = (ushort) 80;
WorldGen.SquareTileFrame(index6, index7 - 1);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, index6, index7 - 1, 1);
}
else
{
bool flag1 = false;
bool flag2 = false;
if (Main.tile[index6, index7 - 1].active() && Main.tile[index6, index7 - 1].type == (ushort) 80)
{
if (!Main.tile[index6 - 1, index7].active() && !Main.tile[index6 - 2, index7 + 1].active() && !Main.tile[index6 - 1, index7 - 1].active() && !Main.tile[index6 - 1, index7 + 1].active() && !Main.tile[index6 - 2, index7].active())
flag1 = true;
if (!Main.tile[index6 + 1, index7].active() && !Main.tile[index6 + 2, index7 + 1].active() && !Main.tile[index6 + 1, index7 - 1].active() && !Main.tile[index6 + 1, index7 + 1].active() && !Main.tile[index6 + 2, index7].active())
flag2 = true;
}
int num9 = WorldGen.genRand.Next(3);
if (num9 == 0 & flag1)
{
Main.tile[index6 - 1, index7].active(true);
Main.tile[index6 - 1, index7].type = (ushort) 80;
WorldGen.SquareTileFrame(index6 - 1, index7);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, index6 - 1, index7, 1);
}
else if (num9 == 1 & flag2)
{
Main.tile[index6 + 1, index7].active(true);
Main.tile[index6 + 1, index7].type = (ushort) 80;
WorldGen.SquareTileFrame(index6 + 1, index7);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, index6 + 1, index7, 1);
}
else
{
if (num3 >= WorldGen.genRand.Next(2, 8))
return;
if (Main.tile[index6 - 1, index7 - 1].active())
{
int type = (int) Main.tile[index6 - 1, index7 - 1].type;
}
if (Main.tile[index6 + 1, index7 - 1].active() && Main.tile[index6 + 1, index7 - 1].type == (ushort) 80 || Main.tile[index6, index7 - 1].active())
return;
Main.tile[index6, index7 - 1].active(true);
Main.tile[index6, index7 - 1].type = (ushort) 80;
WorldGen.SquareTileFrame(index6, index7 - 1);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, index6, index7 - 1, 1);
}
}
}
else
{
if (Main.tile[index6, index7 - 1].active() || Main.tile[index6, index7 - 2].active() || Main.tile[index6 + num4, index7 - 1].active() || !Main.tile[index6 - num4, index7 - 1].active() || Main.tile[index6 - num4, index7 - 1].type != (ushort) 80)
return;
Main.tile[index6, index7 - 1].active(true);
Main.tile[index6, index7 - 1].type = (ushort) 80;
WorldGen.SquareTileFrame(index6, index7 - 1);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, index6, index7 - 1, 1);
}
}
}
public static void CheckPot(int i, int j, int type = 28)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = 0;
int num2 = j;
int num3 = num1 + (int) Main.tile[i, j].frameX / 18;
while (num3 > 1)
num3 -= 2;
int num4 = num3 * -1 + i;
int num5 = (int) Main.tile[i, j].frameY / 18;
int num6 = 0;
while (num5 > 1)
{
num5 -= 2;
++num6;
}
int num7 = num2 - num5;
for (int i1 = num4; i1 < num4 + 2; ++i1)
{
for (int index = num7; index < num7 + 2; ++index)
{
if (Main.tile[i1, index] == null)
Main.tile[i1, index] = new Tile();
int num8 = (int) Main.tile[i1, index].frameX / 18;
while (num8 > 1)
num8 -= 2;
if (!Main.tile[i1, index].active() || (int) Main.tile[i1, index].type != type || num8 != i1 - num4 || (int) Main.tile[i1, index].frameY != (index - num7) * 18 + num6 * 36)
flag = true;
}
if (Main.tile[i1, num7 + 2] == null)
Main.tile[i1, num7 + 2] = new Tile();
if (!WorldGen.SolidTile2(i1, num7 + 2))
flag = true;
}
if (!flag)
return;
WorldGen.destroyObject = true;
if (num6 >= 7 && num6 <= 9)
Main.PlaySound(6, i * 16, j * 16);
else if (num6 >= 16 && num6 <= 24)
Main.PlaySound(4, i * 16, j * 16);
else
Main.PlaySound(13, i * 16, j * 16);
for (int i2 = num4; i2 < num4 + 2; ++i2)
{
for (int j1 = num7; j1 < num7 + 2; ++j1)
{
if ((int) Main.tile[i2, j1].type == type && Main.tile[i2, j1].active())
WorldGen.KillTile(i2, j1);
}
}
float num9 = 1f;
switch (num6)
{
case 0:
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 51);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 52);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 53);
break;
case 1:
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 166);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 167);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 168);
break;
case 2:
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 169);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 170);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 171);
break;
case 3:
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 172);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 173);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 174);
break;
default:
if (num6 >= 4 && num6 <= 6)
{
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 197);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 198);
num9 = 1.25f;
break;
}
if (num6 >= 7 && num6 <= 9)
{
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 199);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 200);
num9 = 1.75f;
break;
}
if (num6 >= 10 && num6 <= 12)
{
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 201);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 202);
num9 = 1.9f;
break;
}
if (num6 >= 13 && num6 <= 15)
{
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 203);
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 204);
num9 = 2.1f;
break;
}
if (num6 >= 16 && num6 <= 18)
{
num9 = 1.6f;
break;
}
if (num6 >= 19 && num6 <= 21)
{
num9 = 3.5f;
break;
}
if (num6 >= 22 && num6 <= 24)
{
num9 = 1.6f;
break;
}
if (num6 >= 25 && num6 <= 27)
{
num9 = 10f;
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), WorldGen.genRand.Next(217, 220));
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), WorldGen.genRand.Next(217, 220));
break;
}
if (num6 >= 28 && num6 <= 30)
{
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), WorldGen.genRand.Next(315, 317));
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), WorldGen.genRand.Next(315, 317));
if (Main.hardMode)
{
num9 = 4f;
break;
}
break;
}
if (num6 >= 31 && num6 <= 33)
{
int num10 = WorldGen.genRand.Next(2, 5);
for (int index = 0; index < num10; ++index)
Gore.NewGore(new Vector2((float) (i * 16), (float) (j * 16)), new Vector2(), 698 + WorldGen.genRand.Next(6));
num9 = 2f;
break;
}
break;
}
float num11 = (float) (((double) num9 * 2.0 + 1.0) / 3.0);
int maxValue = (int) (250.0 / (((double) num11 + 1.0) / 2.0));
if (!WorldGen.gen)
{
if (Main.rand.Next(maxValue) == 0)
{
if (Main.netMode != 1)
Projectile.NewProjectile((float) (i * 16 + 16), (float) (j * 16 + 16), 0.0f, -12f, 518, 0, 0.0f, Main.myPlayer);
}
else if (WorldGen.genRand.Next(40) == 0 && Main.wallDungeon[(int) Main.tile[i, j].wall] && (double) j > Main.worldSurface)
Item.NewItem(i * 16, j * 16, 16, 16, 327);
else if (WorldGen.genRand.Next(45) == 0 || Main.rand.Next(45) == 0 && Main.expertMode)
{
if ((double) j < Main.worldSurface)
{
int num12 = WorldGen.genRand.Next(10);
if (num12 == 0)
Item.NewItem(i * 16, j * 16, 16, 16, 292);
if (num12 == 1)
Item.NewItem(i * 16, j * 16, 16, 16, 298);
if (num12 == 2)
Item.NewItem(i * 16, j * 16, 16, 16, 299);
if (num12 == 3)
Item.NewItem(i * 16, j * 16, 16, 16, 290);
if (num12 == 4)
Item.NewItem(i * 16, j * 16, 16, 16, 2322);
if (num12 == 5)
Item.NewItem(i * 16, j * 16, 16, 16, 2324);
if (num12 == 6)
Item.NewItem(i * 16, j * 16, 16, 16, 2325);
if (num12 >= 7)
Item.NewItem(i * 16, j * 16, 16, 16, 2350);
}
else if ((double) j < Main.rockLayer)
{
int num13 = WorldGen.genRand.Next(11);
if (num13 == 0)
Item.NewItem(i * 16, j * 16, 16, 16, 289);
if (num13 == 1)
Item.NewItem(i * 16, j * 16, 16, 16, 298);
if (num13 == 2)
Item.NewItem(i * 16, j * 16, 16, 16, 299);
if (num13 == 3)
Item.NewItem(i * 16, j * 16, 16, 16, 290);
if (num13 == 4)
Item.NewItem(i * 16, j * 16, 16, 16, 303);
if (num13 == 5)
Item.NewItem(i * 16, j * 16, 16, 16, 291);
if (num13 == 6)
Item.NewItem(i * 16, j * 16, 16, 16, 304);
if (num13 == 7)
Item.NewItem(i * 16, j * 16, 16, 16, 2322);
if (num13 == 8)
Item.NewItem(i * 16, j * 16, 16, 16, 2329);
if (num13 >= 9)
Item.NewItem(i * 16, j * 16, 16, 16, 2350);
}
else if (j < Main.maxTilesY - 200)
{
int num14 = WorldGen.genRand.Next(15);
if (num14 == 0)
Item.NewItem(i * 16, j * 16, 16, 16, 296);
if (num14 == 1)
Item.NewItem(i * 16, j * 16, 16, 16, 295);
if (num14 == 2)
Item.NewItem(i * 16, j * 16, 16, 16, 299);
if (num14 == 3)
Item.NewItem(i * 16, j * 16, 16, 16, 302);
if (num14 == 4)
Item.NewItem(i * 16, j * 16, 16, 16, 303);
if (num14 == 5)
Item.NewItem(i * 16, j * 16, 16, 16, 305);
if (num14 == 6)
Item.NewItem(i * 16, j * 16, 16, 16, 301);
if (num14 == 7)
Item.NewItem(i * 16, j * 16, 16, 16, 302);
if (num14 == 8)
Item.NewItem(i * 16, j * 16, 16, 16, 297);
if (num14 == 9)
Item.NewItem(i * 16, j * 16, 16, 16, 304);
if (num14 == 10)
Item.NewItem(i * 16, j * 16, 16, 16, 2322);
if (num14 == 11)
Item.NewItem(i * 16, j * 16, 16, 16, 2323);
if (num14 == 12)
Item.NewItem(i * 16, j * 16, 16, 16, 2327);
if (num14 == 13)
Item.NewItem(i * 16, j * 16, 16, 16, 2329);
if (num14 == 14)
Item.NewItem(i * 16, j * 16, 16, 16, 2350);
}
else
{
int num15 = WorldGen.genRand.Next(14);
if (num15 == 0)
Item.NewItem(i * 16, j * 16, 16, 16, 296);
if (num15 == 1)
Item.NewItem(i * 16, j * 16, 16, 16, 295);
if (num15 == 2)
Item.NewItem(i * 16, j * 16, 16, 16, 293);
if (num15 == 3)
Item.NewItem(i * 16, j * 16, 16, 16, 288);
if (num15 == 4)
Item.NewItem(i * 16, j * 16, 16, 16, 294);
if (num15 == 5)
Item.NewItem(i * 16, j * 16, 16, 16, 297);
if (num15 == 6)
Item.NewItem(i * 16, j * 16, 16, 16, 304);
if (num15 == 7)
Item.NewItem(i * 16, j * 16, 16, 16, 305);
if (num15 == 8)
Item.NewItem(i * 16, j * 16, 16, 16, 301);
if (num15 == 9)
Item.NewItem(i * 16, j * 16, 16, 16, 302);
if (num15 == 10)
Item.NewItem(i * 16, j * 16, 16, 16, 288);
if (num15 == 11)
Item.NewItem(i * 16, j * 16, 16, 16, 300);
if (num15 == 12)
Item.NewItem(i * 16, j * 16, 16, 16, 2323);
if (num15 == 13)
Item.NewItem(i * 16, j * 16, 16, 16, 2326);
}
}
else if (Main.netMode == 2 && Main.rand.Next(30) == 0)
{
Item.NewItem(i * 16, j * 16, 16, 16, 2997);
}
else
{
int num16 = Main.rand.Next(8);
if (Main.expertMode)
--num16;
if (num16 == 0 && Main.player[(int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16)].statLife < Main.player[(int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16)].statLifeMax2)
{
Item.NewItem(i * 16, j * 16, 16, 16, 58);
if (Main.rand.Next(2) == 0)
Item.NewItem(i * 16, j * 16, 16, 16, 58);
if (Main.expertMode)
{
if (Main.rand.Next(2) == 0)
Item.NewItem(i * 16, j * 16, 16, 16, 58);
if (Main.rand.Next(2) == 0)
Item.NewItem(i * 16, j * 16, 16, 16, 58);
}
}
else if (num16 == 1 && Main.player[(int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16)].statMana < Main.player[(int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16)].statManaMax2)
{
Item.NewItem(i * 16, j * 16, 16, 16, 184);
}
else
{
switch (num16)
{
case 2:
int Stack1 = Main.rand.Next(2, 6);
if (Main.expertMode)
Stack1 += Main.rand.Next(1, 7);
if (Main.tile[i, j].liquid > (byte) 0)
{
Item.NewItem(i * 16, j * 16, 16, 16, 282, Stack1);
break;
}
Item.NewItem(i * 16, j * 16, 16, 16, 8, Stack1);
break;
case 3:
int Stack2 = Main.rand.Next(10, 21);
int Type1 = 40;
if ((double) j < Main.rockLayer && WorldGen.genRand.Next(2) == 0)
Type1 = !Main.hardMode ? 42 : 168;
if (j > Main.maxTilesY - 200)
Type1 = 265;
else if (Main.hardMode)
Type1 = Main.rand.Next(2) != 0 ? 47 : 278;
Item.NewItem(i * 16, j * 16, 16, 16, Type1, Stack2);
break;
case 4:
int Type2 = 28;
if (j > Main.maxTilesY - 200 || Main.hardMode)
Type2 = 188;
int Stack3 = 1;
if (Main.expertMode && Main.rand.Next(3) != 0)
++Stack3;
Item.NewItem(i * 16, j * 16, 16, 16, Type2, Stack3);
break;
default:
if (num16 == 5 && (double) j > Main.rockLayer)
{
int Stack4 = Main.rand.Next(4) + 1;
if (Main.expertMode)
Stack4 += Main.rand.Next(4);
Item.NewItem(i * 16, j * 16, 16, 16, 166, Stack4);
break;
}
if ((num16 == 5 || num16 == 6) && j < Main.maxTilesY - 200 && !Main.hardMode)
{
int Stack5 = Main.rand.Next(20, 41);
Item.NewItem(i * 16, j * 16, 16, 16, 965, Stack5);
break;
}
float num17 = (float) (200 + WorldGen.genRand.Next(-100, 101));
if ((double) j < Main.worldSurface)
num17 *= 0.5f;
else if ((double) j < Main.rockLayer)
num17 *= 0.75f;
else if (j > Main.maxTilesY - 250)
num17 *= 1.25f;
float num18 = num17 * (float) (1.0 + (double) Main.rand.Next(-20, 21) * 0.00999999977648258);
if (Main.rand.Next(4) == 0)
num18 *= (float) (1.0 + (double) Main.rand.Next(5, 11) * 0.00999999977648258);
if (Main.rand.Next(8) == 0)
num18 *= (float) (1.0 + (double) Main.rand.Next(10, 21) * 0.00999999977648258);
if (Main.rand.Next(12) == 0)
num18 *= (float) (1.0 + (double) Main.rand.Next(20, 41) * 0.00999999977648258);
if (Main.rand.Next(16) == 0)
num18 *= (float) (1.0 + (double) Main.rand.Next(40, 81) * 0.00999999977648258);
if (Main.rand.Next(20) == 0)
num18 *= (float) (1.0 + (double) Main.rand.Next(50, 101) * 0.00999999977648258);
if (Main.expertMode)
num18 *= 2.5f;
if (Main.expertMode && Main.rand.Next(2) == 0)
num18 *= 1.25f;
if (Main.expertMode && Main.rand.Next(3) == 0)
num18 *= 1.5f;
if (Main.expertMode && Main.rand.Next(4) == 0)
num18 *= 1.75f;
float num19 = num18 * num11;
if (NPC.downedBoss1)
num19 *= 1.1f;
if (NPC.downedBoss2)
num19 *= 1.1f;
if (NPC.downedBoss3)
num19 *= 1.1f;
if (NPC.downedMechBoss1)
num19 *= 1.1f;
if (NPC.downedMechBoss2)
num19 *= 1.1f;
if (NPC.downedMechBoss3)
num19 *= 1.1f;
if (NPC.downedPlantBoss)
num19 *= 1.1f;
if (NPC.downedQueenBee)
num19 *= 1.1f;
if (NPC.downedGolemBoss)
num19 *= 1.1f;
if (NPC.downedPirates)
num19 *= 1.1f;
if (NPC.downedGoblins)
num19 *= 1.1f;
if (NPC.downedFrost)
num19 *= 1.1f;
while ((int) num19 > 0)
{
if ((double) num19 > 1000000.0)
{
int Stack6 = (int) ((double) num19 / 1000000.0);
if (Stack6 > 50 && Main.rand.Next(2) == 0)
Stack6 /= Main.rand.Next(3) + 1;
if (Main.rand.Next(2) == 0)
Stack6 /= Main.rand.Next(3) + 1;
num19 -= (float) (1000000 * Stack6);
Item.NewItem(i * 16, j * 16, 16, 16, 74, Stack6);
}
else if ((double) num19 > 10000.0)
{
int Stack7 = (int) ((double) num19 / 10000.0);
if (Stack7 > 50 && Main.rand.Next(2) == 0)
Stack7 /= Main.rand.Next(3) + 1;
if (Main.rand.Next(2) == 0)
Stack7 /= Main.rand.Next(3) + 1;
num19 -= (float) (10000 * Stack7);
Item.NewItem(i * 16, j * 16, 16, 16, 73, Stack7);
}
else if ((double) num19 > 100.0)
{
int Stack8 = (int) ((double) num19 / 100.0);
if (Stack8 > 50 && Main.rand.Next(2) == 0)
Stack8 /= Main.rand.Next(3) + 1;
if (Main.rand.Next(2) == 0)
Stack8 /= Main.rand.Next(3) + 1;
num19 -= (float) (100 * Stack8);
Item.NewItem(i * 16, j * 16, 16, 16, 72, Stack8);
}
else
{
int Stack9 = (int) num19;
if (Stack9 > 50 && Main.rand.Next(2) == 0)
Stack9 /= Main.rand.Next(3) + 1;
if (Main.rand.Next(2) == 0)
Stack9 /= Main.rand.Next(4) + 1;
if (Stack9 < 1)
Stack9 = 1;
num19 -= (float) Stack9;
Item.NewItem(i * 16, j * 16, 16, 16, 71, Stack9);
}
}
break;
}
}
}
}
WorldGen.destroyObject = false;
}
public static int PlaceChest(int x, int y, ushort type = 21, bool notNearOtherChests = false, int style = 0)
{
int num = -1;
TileObject objectData;
if (TileObject.CanPlace(x, y, (int) type, style, 1, out objectData))
{
bool flag = true;
if (notNearOtherChests && Chest.NearOtherChests(x - 1, y - 1))
flag = false;
if (flag)
{
TileObject.Place(objectData);
num = Chest.CreateChest(objectData.xCoord, objectData.yCoord);
}
}
else
num = -1;
if (num != -1 && Main.netMode == 1 && type == (ushort) 21)
NetMessage.SendData(34, number2: ((float) x), number3: ((float) y), number4: ((float) style));
if (num != -1 && Main.netMode == 1 && type == (ushort) 467)
NetMessage.SendData(34, number: 4, number2: ((float) x), number3: ((float) y), number4: ((float) style));
return num;
}
public static void PlaceChestDirect(int x, int y, ushort type, int style, int id)
{
Chest.CreateChest(x, y - 1, id);
for (int index1 = 0; index1 <= 1; ++index1)
{
for (int index2 = -1; index2 <= 0; ++index2)
{
if (Main.tile[x + index1, y + index2] == null)
Main.tile[x + index1, y + index2] = new Tile();
}
}
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameY = (short) 0;
Main.tile[x, y - 1].frameX = (short) (36 * style);
Main.tile[x, y - 1].type = type;
Main.tile[x, y - 1].halfBrick(false);
Main.tile[x + 1, y - 1].active(true);
Main.tile[x + 1, y - 1].frameY = (short) 0;
Main.tile[x + 1, y - 1].frameX = (short) (18 + 36 * style);
Main.tile[x + 1, y - 1].type = type;
Main.tile[x + 1, y - 1].halfBrick(false);
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) 18;
Main.tile[x, y].frameX = (short) (36 * style);
Main.tile[x, y].type = type;
Main.tile[x, y].halfBrick(false);
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].frameY = (short) 18;
Main.tile[x + 1, y].frameX = (short) (18 + 36 * style);
Main.tile[x + 1, y].type = type;
Main.tile[x + 1, y].halfBrick(false);
}
public static void PlaceDresserDirect(int x, int y, ushort type, int style, int id)
{
Chest.CreateChest(x - 1, y - 1, id);
for (int index1 = -1; index1 <= 1; ++index1)
{
for (int index2 = -1; index2 <= 0; ++index2)
{
if (Main.tile[x + index1, y + index2] == null)
Main.tile[x + index1, y + index2] = new Tile();
}
}
short num = (short) (style * 54);
Main.tile[x - 1, y - 1].active(true);
Main.tile[x - 1, y - 1].frameY = (short) 0;
Main.tile[x - 1, y - 1].frameX = num;
Main.tile[x - 1, y - 1].type = type;
Main.tile[x, y - 1].active(true);
Main.tile[x, y - 1].frameY = (short) 0;
Main.tile[x, y - 1].frameX = (short) ((int) num + 18);
Main.tile[x, y - 1].type = type;
Main.tile[x + 1, y - 1].active(true);
Main.tile[x + 1, y - 1].frameY = (short) 0;
Main.tile[x + 1, y - 1].frameX = (short) ((int) num + 36);
Main.tile[x + 1, y - 1].type = type;
Main.tile[x - 1, y].active(true);
Main.tile[x - 1, y].frameY = (short) 18;
Main.tile[x - 1, y].frameX = num;
Main.tile[x - 1, y].type = type;
Main.tile[x, y].active(true);
Main.tile[x, y].frameY = (short) 18;
Main.tile[x, y].frameX = (short) ((int) num + 18);
Main.tile[x, y].type = type;
Main.tile[x + 1, y].active(true);
Main.tile[x + 1, y].frameY = (short) 18;
Main.tile[x + 1, y].frameX = (short) ((int) num + 36);
Main.tile[x + 1, y].type = type;
}
public static void CheckChest(int i, int j, int type)
{
if (WorldGen.destroyObject)
return;
bool flag = false;
int num1 = 0;
int num2 = j;
int num3 = num1 + (int) Main.tile[i, j].frameX / 18;
int num4 = num2 + (int) Main.tile[i, j].frameY / 18 * -1;
while (num3 > 1)
num3 -= 2;
int i1 = num3 * -1 + i;
for (int index1 = i1; index1 < i1 + 2; ++index1)
{
for (int index2 = num4; index2 < num4 + 2; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
int num5 = (int) Main.tile[index1, index2].frameX / 18;
while (num5 > 1)
num5 -= 2;
if (!Main.tile[index1, index2].active() || (int) Main.tile[index1, index2].type != type || num5 != index1 - i1 || (int) Main.tile[index1, index2].frameY != (index2 - num4) * 18)
flag = true;
}
if (Main.tile[index1, num4 + 2] == null)
Main.tile[index1, num4 + 2] = new Tile();
if (!Main.tile[index1, num4 + 2].active() || !Main.tileSolid[(int) Main.tile[index1, num4 + 2].type])
flag = true;
}
if (!flag)
return;
int index3 = (int) Main.tile[i, j].frameX / 36;
int Type = type != 467 ? Chest.chestItemSpawn[index3] : Chest.chestItemSpawn2[index3];
WorldGen.destroyObject = true;
for (int index4 = i1; index4 < i1 + 2; ++index4)
{
for (int index5 = num4; index5 < num4 + 3; ++index5)
{
if ((int) Main.tile[index4, index5].type == type && Main.tile[index4, index5].active())
{
Chest.DestroyChest(index4, index5);
WorldGen.KillTile(index4, index5);
}
}
}
Item.NewItem(i * 16, j * 16, 32, 32, Type);
WorldGen.destroyObject = false;
if (Main.tile[i1, num4 + 2].type != (ushort) 138 && Main.tile[i1 + 1, num4 + 2].type != (ushort) 138)
return;
WorldGen.SquareTileFrame(i1, num4 + 2);
}
public static bool PlaceActuator(int i, int j)
{
if (Main.tile[i, j].actuator())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].actuator(true);
return true;
}
public static bool KillActuator(int i, int j)
{
if (!Main.tile[i, j].actuator())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].actuator(false);
if (Main.netMode != 1)
Item.NewItem(i * 16, j * 16, 16, 16, 849);
for (int index = 0; index < 5; ++index)
Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 50);
return true;
}
public static bool PlaceWire(int i, int j)
{
if (Main.tile[i, j].wire())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].wire(true);
return true;
}
public static bool KillWire(int i, int j)
{
if (!Main.tile[i, j].wire())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].wire(false);
if (Main.netMode != 1)
Item.NewItem(i * 16, j * 16, 16, 16, 530);
for (int index = 0; index < 5; ++index)
Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 50);
return true;
}
public static bool PlaceWire2(int i, int j)
{
if (Main.tile[i, j].wire2())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].wire2(true);
return true;
}
public static bool KillWire2(int i, int j)
{
if (!Main.tile[i, j].wire2())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].wire2(false);
if (Main.netMode != 1)
Item.NewItem(i * 16, j * 16, 16, 16, 530);
for (int index = 0; index < 5; ++index)
Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 50);
return true;
}
public static bool PlaceWire3(int i, int j)
{
if (Main.tile[i, j].wire3())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].wire3(true);
return true;
}
public static bool KillWire3(int i, int j)
{
if (!Main.tile[i, j].wire3())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].wire3(false);
if (Main.netMode != 1)
Item.NewItem(i * 16, j * 16, 16, 16, 530);
for (int index = 0; index < 5; ++index)
Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 50);
return true;
}
public static bool PlaceWire4(int i, int j)
{
if (Main.tile[i, j].wire4())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].wire4(true);
return true;
}
public static bool KillWire4(int i, int j)
{
if (!Main.tile[i, j].wire4())
return false;
Main.PlaySound(0, i * 16, j * 16);
Main.tile[i, j].wire4(false);
if (Main.netMode != 1)
Item.NewItem(i * 16, j * 16, 16, 16, 530);
for (int index = 0; index < 5; ++index)
Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 50);
return true;
}
public static bool PlaceTile(
int i,
int j,
int type,
bool mute = false,
bool forced = false,
int plr = -1,
int style = 0)
{
if (type >= 470)
return false;
bool flag = false;
if (i >= 0 && j >= 0 && i < Main.maxTilesX && j < Main.maxTilesY)
{
Tile trackCache = Main.tile[i, j];
if (trackCache == null)
{
trackCache = new Tile();
Main.tile[i, j] = trackCache;
}
if (forced || Collision.EmptyTile(i, j) || !Main.tileSolid[type] || type == 23 && trackCache.type == (ushort) 0 && trackCache.active() || type == 199 && trackCache.type == (ushort) 0 && trackCache.active() || type == 2 && trackCache.type == (ushort) 0 && trackCache.active() || type == 109 && trackCache.type == (ushort) 0 && trackCache.active() || type == 60 && trackCache.type == (ushort) 59 && trackCache.active() || type == 70 && trackCache.type == (ushort) 59 && trackCache.active())
{
if (type == 23 && (trackCache.type != (ushort) 0 || !trackCache.active()) || type == 2 && (trackCache.type != (ushort) 0 || !trackCache.active()) || type == 109 && (trackCache.type != (ushort) 0 || !trackCache.active()) || type == 60 && (trackCache.type != (ushort) 59 || !trackCache.active()))
return false;
if (type == 81)
{
if (Main.tile[i, j - 1] == null)
Main.tile[i, j - 1] = new Tile();
if (Main.tile[i, j + 1] == null)
Main.tile[i, j + 1] = new Tile();
if (Main.tile[i, j - 1].active() || !Main.tile[i, j + 1].active() || !Main.tileSolid[(int) Main.tile[i, j + 1].type] || Main.tile[i, j + 1].halfBrick() || Main.tile[i, j + 1].slope() != (byte) 0)
return false;
}
if ((type == 373 || type == 375 || type == 374 || type == 461) && (Main.tile[i, j - 1] == null || Main.tile[i, j - 1].bottomSlope()))
return false;
if (trackCache.liquid > (byte) 0)
{
if (type == 4)
{
if (style != 8 && style != 11)
return false;
}
else if (type == 3 || type == 20 || type == 24 || type == 27 || type == 32 || type == 51 || type == 69 || type == 72 || type == 201 || type == 352)
return false;
}
if (type != 2 || Main.tile[i, j].type != (ushort) 0)
{
trackCache.halfBrick(false);
trackCache.frameY = (short) 0;
trackCache.frameX = (short) 0;
}
if (type == 3 || type == 24 || type == 110 || type == 201)
{
if (j + 1 < Main.maxTilesY && Main.tile[i, j + 1].active() && Main.tile[i, j + 1].slope() == (byte) 0 && !Main.tile[i, j + 1].halfBrick() && (Main.tile[i, j + 1].type == (ushort) 2 && type == 3 || Main.tile[i, j + 1].type == (ushort) 23 && type == 24 || Main.tile[i, j + 1].type == (ushort) 199 && type == 201 || (Main.tile[i, j + 1].type == (ushort) 78 || Main.tile[i, j + 1].type == (ushort) 380) && type == 3 || Main.tile[i, j + 1].type == (ushort) 109 && type == 110))
{
if (type == 24 && WorldGen.genRand.Next(13) == 0)
{
trackCache.active(true);
trackCache.type = (ushort) 32;
WorldGen.SquareTileFrame(i, j);
}
else if (type == 201 && WorldGen.genRand.Next(13) == 0)
{
trackCache.active(true);
trackCache.type = (ushort) 352;
WorldGen.SquareTileFrame(i, j);
}
else if (Main.tile[i, j + 1].type == (ushort) 78 || Main.tile[i, j + 1].type == (ushort) 380)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (WorldGen.genRand.Next(2) * 18 + 108);
}
else if ((trackCache.wall == (byte) 0 || trackCache.wall == (byte) 106 || trackCache.wall == (byte) 107 || trackCache.wall >= (byte) 63 && trackCache.wall <= (byte) 70) && (Main.tile[i, j + 1].wall == (byte) 0 || Main.tile[i, j + 1].wall == (byte) 106 || Main.tile[i, j + 1].wall == (byte) 107 || Main.tile[i, j + 1].wall >= (byte) 63 && Main.tile[i, j + 1].wall <= (byte) 70))
{
if (type == 3 && WorldGen.genRand.Next(35) == 0)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (WorldGen.genRand.Next(2) * 18 + 162);
}
else if (WorldGen.genRand.Next(50) == 0 || (type == 24 || type == 201) && WorldGen.genRand.Next(40) == 0)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = type != 201 ? (short) 144 : (short) 270;
}
else if (WorldGen.genRand.Next(35) == 0)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (WorldGen.genRand.Next(2) * 18 + 108);
}
else
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (WorldGen.genRand.Next(6) * 18);
}
}
}
}
else
{
switch (type)
{
case 61:
if (j + 1 < Main.maxTilesY && Main.tile[i, j + 1].active() && Main.tile[i, j + 1].slope() == (byte) 0 && !Main.tile[i, j + 1].halfBrick() && Main.tile[i, j + 1].type == (ushort) 60)
{
if (WorldGen.genRand.Next(16) == 0 && (double) j > Main.worldSurface)
{
trackCache.active(true);
trackCache.type = (ushort) 69;
WorldGen.SquareTileFrame(i, j);
break;
}
if (WorldGen.genRand.Next(60) == 0 && (double) j > Main.rockLayer)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) 144;
break;
}
if (WorldGen.genRand.Next(300) == 0 && (double) j > Main.rockLayer)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) 162;
break;
}
if (WorldGen.genRand.Next(15) == 0)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = WorldGen.genRand.Next(3) == 0 ? (short) (WorldGen.genRand.Next(13) * 18 + 180) : (short) (WorldGen.genRand.Next(2) * 18 + 108);
break;
}
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (WorldGen.genRand.Next(6) * 18);
break;
}
break;
case 71:
if (j + 1 < Main.maxTilesY && Main.tile[i, j + 1].active() && Main.tile[i, j + 1].slope() == (byte) 0 && !Main.tile[i, j + 1].halfBrick() && Main.tile[i, j + 1].type == (ushort) 70)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (WorldGen.genRand.Next(5) * 18);
break;
}
break;
case 129:
if (WorldGen.SolidTile(i - 1, j) || WorldGen.SolidTile(i + 1, j) || WorldGen.SolidTile(i, j - 1) || WorldGen.SolidTile(i, j + 1))
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (WorldGen.genRand.Next(18) * 18);
WorldGen.SquareTileFrame(i, j);
break;
}
break;
case 171:
WorldGen.PlaceXmasTree(i, j);
break;
case 178:
if (WorldGen.SolidTile(i - 1, j) || WorldGen.SolidTile(i + 1, j) || WorldGen.SolidTile(i, j - 1) || WorldGen.SolidTile(i, j + 1))
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (style * 18);
trackCache.frameY = (short) (WorldGen.genRand.Next(3) * 18);
WorldGen.SquareTileFrame(i, j);
break;
}
break;
case 184:
if (Main.tileMoss[(int) Main.tile[i - 1, j].type] && WorldGen.SolidTile(i - 1, j) || Main.tileMoss[(int) Main.tile[i + 1, j].type] && WorldGen.SolidTile(i + 1, j) || Main.tileMoss[(int) Main.tile[i, j - 1].type] && WorldGen.SolidTile(i, j - 1) || Main.tileMoss[(int) Main.tile[i, j + 1].type] && WorldGen.SolidTile(i, j + 1))
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameX = (short) (style * 18);
trackCache.frameY = (short) (WorldGen.genRand.Next(3) * 18);
WorldGen.SquareTileFrame(i, j);
break;
}
break;
case 254:
WorldGen.Place2x2Style(i, j, (ushort) type, style);
break;
case 335:
WorldGen.Place2x2(i, j, (ushort) type, 0);
break;
default:
if (type == 319 || type == 132 || type == 138 || type == 142 || type == 143 || type == 282 || type >= 288 && type <= 295 || type >= 316 && type <= 318)
{
WorldGen.Place2x2(i, j, (ushort) type, 0);
break;
}
switch (type)
{
case 4:
if (Main.tile[i - 1, j] == null)
Main.tile[i - 1, j] = new Tile();
if (Main.tile[i + 1, j] == null)
Main.tile[i + 1, j] = new Tile();
if (Main.tile[i, j + 1] == null)
Main.tile[i, j + 1] = new Tile();
Tile tile1 = Main.tile[i - 1, j];
Tile tile2 = Main.tile[i + 1, j];
Tile tile3 = Main.tile[i, j + 1];
if (trackCache.wall > (byte) 0 || tile1.active() && (tile1.slope() == (byte) 0 || (int) tile1.slope() % 2 != 1) && (Main.tileSolid[(int) tile1.type] && !Main.tileSolidTop[(int) tile1.type] && !TileID.Sets.NotReallySolid[(int) tile1.type] || tile1.type == (ushort) 124 || tile1.type == (ushort) 5 && Main.tile[i - 1, j - 1].type == (ushort) 5 && Main.tile[i - 1, j + 1].type == (ushort) 5) || tile2.active() && (tile2.slope() == (byte) 0 || (int) tile2.slope() % 2 != 0) && (Main.tileSolid[(int) tile2.type] && !Main.tileSolidTop[(int) tile2.type] && !TileID.Sets.NotReallySolid[(int) tile2.type] || tile2.type == (ushort) 124 || tile2.type == (ushort) 5 && Main.tile[i + 1, j - 1].type == (ushort) 5 && Main.tile[i + 1, j + 1].type == (ushort) 5) || tile3.active() && Main.tileSolid[(int) tile3.type] && (!Main.tileSolidTop[(int) tile3.type] || TileID.Sets.Platforms[(int) tile3.type] && tile3.slope() == (byte) 0) && !TileID.Sets.NotReallySolid[(int) tile3.type] && !tile3.halfBrick() && tile3.slope() == (byte) 0)
{
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameY = (short) (22 * style);
WorldGen.SquareTileFrame(i, j);
break;
}
break;
case 10:
if (Main.tile[i, j - 1] == null)
Main.tile[i, j - 1] = new Tile();
if (Main.tile[i, j - 2] == null)
Main.tile[i, j - 2] = new Tile();
if (Main.tile[i, j - 3] == null)
Main.tile[i, j - 3] = new Tile();
if (Main.tile[i, j + 1] == null)
Main.tile[i, j + 1] = new Tile();
if (Main.tile[i, j + 2] == null)
Main.tile[i, j + 2] = new Tile();
if (Main.tile[i, j + 3] == null)
Main.tile[i, j + 3] = new Tile();
if (!Main.tile[i, j - 1].active() && !Main.tile[i, j - 2].active() && Main.tile[i, j - 3].active() && Main.tileSolid[(int) Main.tile[i, j - 3].type])
{
WorldGen.PlaceDoor(i, j - 1, type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
if (Main.tile[i, j + 1].active() || Main.tile[i, j + 2].active() || !Main.tile[i, j + 3].active() || !Main.tileSolid[(int) Main.tile[i, j + 3].type])
return false;
WorldGen.PlaceDoor(i, j + 1, type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 136:
if (Main.tile[i - 1, j] == null)
Main.tile[i - 1, j] = new Tile();
if (Main.tile[i + 1, j] == null)
Main.tile[i + 1, j] = new Tile();
if (Main.tile[i, j + 1] == null)
Main.tile[i, j + 1] = new Tile();
if (Main.tile[i - 1, j].nactive() && !Main.tile[i - 1, j].halfBrick() && !TileID.Sets.NotReallySolid[(int) Main.tile[i - 1, j].type] && Main.tile[i - 1, j].slope() == (byte) 0 && (WorldGen.SolidTile(i - 1, j) || Main.tile[i - 1, j].type == (ushort) 124 || Main.tile[i - 1, j].type == (ushort) 5 && Main.tile[i - 1, j - 1].type == (ushort) 5 && Main.tile[i - 1, j + 1].type == (ushort) 5) || Main.tile[i + 1, j].nactive() && !Main.tile[i + 1, j].halfBrick() && !TileID.Sets.NotReallySolid[(int) Main.tile[i + 1, j].type] && Main.tile[i + 1, j].slope() == (byte) 0 && (WorldGen.SolidTile(i + 1, j) || Main.tile[i + 1, j].type == (ushort) 124 || Main.tile[i + 1, j].type == (ushort) 5 && Main.tile[i + 1, j - 1].type == (ushort) 5 && Main.tile[i + 1, j + 1].type == (ushort) 5) || Main.tile[i, j + 1].nactive() && !Main.tile[i, j + 1].halfBrick() && WorldGen.SolidTile(i, j + 1) && Main.tile[i, j + 1].slope() == (byte) 0 || trackCache.wall > (byte) 0)
{
trackCache.active(true);
trackCache.type = (ushort) type;
WorldGen.SquareTileFrame(i, j);
break;
}
break;
case 137:
trackCache.active(true);
trackCache.type = (ushort) type;
trackCache.frameY = (short) (18 * style);
break;
case 411:
WorldGen.Place2x2(i, j, (ushort) type, 0);
break;
case 442:
if (Main.tile[i - 1, j] == null)
Main.tile[i - 1, j] = new Tile();
if (Main.tile[i + 1, j] == null)
Main.tile[i + 1, j] = new Tile();
if (Main.tile[i, j + 1] == null)
Main.tile[i, j + 1] = new Tile();
if (Main.tile[i - 1, j].nactive() && !Main.tile[i - 1, j].halfBrick() && !TileID.Sets.NotReallySolid[(int) Main.tile[i - 1, j].type] && Main.tile[i - 1, j].slope() == (byte) 0 && (WorldGen.SolidTile(i - 1, j) || Main.tile[i - 1, j].type == (ushort) 124 || Main.tile[i - 1, j].type == (ushort) 5 && Main.tile[i - 1, j - 1].type == (ushort) 5 && Main.tile[i - 1, j + 1].type == (ushort) 5) || Main.tile[i + 1, j].nactive() && !Main.tile[i + 1, j].halfBrick() && !TileID.Sets.NotReallySolid[(int) Main.tile[i + 1, j].type] && Main.tile[i + 1, j].slope() == (byte) 0 && (WorldGen.SolidTile(i + 1, j) || Main.tile[i + 1, j].type == (ushort) 124 || Main.tile[i + 1, j].type == (ushort) 5 && Main.tile[i + 1, j - 1].type == (ushort) 5 && Main.tile[i + 1, j + 1].type == (ushort) 5) || Main.tile[i, j + 1].nactive() && !Main.tile[i, j + 1].halfBrick() && WorldGen.SolidTile(i, j + 1) && Main.tile[i, j + 1].slope() == (byte) 0)
{
trackCache.active(true);
trackCache.type = (ushort) type;
WorldGen.SquareTileFrame(i, j);
break;
}
break;
case 457:
WorldGen.Place2x2Horizontal(i, j, (ushort) 457, style);
break;
default:
if (type >= 275 && type <= 281 || type == 296 || type == 297 || type == 309 || type == 358 || type == 359 || type == 413 || type == 414)
{
WorldGen.Place6x3(i, j, (ushort) type);
break;
}
if (type == 237 || type == 244 || type == 285 || type == 286 || type == 298 || type == 299 || type == 310 || type == 339 || type >= 361 && type <= 364)
{
WorldGen.Place3x2(i, j, (ushort) type);
break;
}
switch (type)
{
case 128:
WorldGen.PlaceMan(i, j, style);
WorldGen.SquareTileFrame(i, j);
break;
case 149:
if (WorldGen.SolidTile(i - 1, j) || WorldGen.SolidTile(i + 1, j) || WorldGen.SolidTile(i, j - 1) || WorldGen.SolidTile(i, j + 1))
{
trackCache.frameX = (short) (18 * style);
trackCache.active(true);
trackCache.type = (ushort) type;
WorldGen.SquareTileFrame(i, j);
break;
}
break;
case 269:
WorldGen.PlaceWoman(i, j, style);
WorldGen.SquareTileFrame(i, j);
break;
case 334:
int style1 = 0;
if (style == -1)
style1 = 1;
WorldGen.Place3x3Wall(i, j, (ushort) 334, style1);
WorldGen.SquareTileFrame(i, j);
break;
default:
if (type == 139 || type == 35)
{
WorldGen.PlaceMB(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
switch (type)
{
case 34:
WorldGen.PlaceChand(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 165:
WorldGen.PlaceTight(i, j, (ushort) type);
WorldGen.SquareTileFrame(i, j);
break;
case 235:
WorldGen.Place3x1(i, j, (ushort) type);
WorldGen.SquareTileFrame(i, j);
break;
case 240:
WorldGen.Place3x3Wall(i, j, (ushort) type, style);
break;
case 241:
WorldGen.Place4x3Wall(i, j, (ushort) type, style);
break;
case 242:
WorldGen.Place6x4Wall(i, j, (ushort) type, style);
break;
case 245:
WorldGen.Place2x3Wall(i, j, (ushort) type, style);
break;
case 246:
WorldGen.Place3x2Wall(i, j, (ushort) type, style);
break;
case 440:
WorldGen.Place3x3Wall(i, j, (ushort) type, style);
break;
default:
if (type == 106 || type == 212 || type == 219 || type == 220 || type == 228 || type == 231 || type == 243 || type == 247 || type == 283 || type >= 300 && type <= 308 || type == 354 || type == 355)
{
WorldGen.Place3x3(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
if (type == 13 || type == 33 || type == 49 || type == 50 || type == 78 || type == 174 || type == 372)
{
WorldGen.PlaceOnTable1x1(i, j, type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
if (type == 14 || type == 26 || type == 86 || type == 87 || type == 88 || type == 89 || type == 114 || type == 186 || type == 187 || type == 215 || type == 217 || type == 218 || type == 377)
{
WorldGen.Place3x2(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
switch (type)
{
case 20:
if (Main.tile[i, j + 1] == null)
Main.tile[i, j + 1] = new Tile();
int type1 = (int) Main.tile[i, j + 1].type;
if (Main.tile[i, j + 1].active() && (type1 == 2 || type1 == 109 || type1 == 147 || type1 == 60 || type1 == 23 || type1 == 199 || type1 == 53 || type1 == 234 || type1 == 116 || type1 == 112))
{
WorldGen.Place1x2(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
break;
case 236:
WorldGen.PlaceJunglePlant(i, j, (ushort) type, WorldGen.genRand.Next(3), 0);
WorldGen.SquareTileFrame(i, j);
break;
case 238:
WorldGen.PlaceJunglePlant(i, j, (ushort) type, 0, 0);
WorldGen.SquareTileFrame(i, j);
break;
default:
if (type == 15 || type == 216 || type == 338 || type == 390)
{
if (Main.tile[i, j - 1] == null)
Main.tile[i, j - 1] = new Tile();
if (Main.tile[i, j] == null)
Main.tile[i, j] = new Tile();
WorldGen.Place1x2(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
if (type == 227)
{
WorldGen.PlaceDye(i, j, style);
WorldGen.SquareTileFrame(i, j);
break;
}
if (type == 16 || type == 18 || type == 29 || type == 103 || type == 134 || type == 462)
{
WorldGen.Place2x1(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
if (type == 92 || type == 93 || type == 453)
{
WorldGen.Place1xX(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
if (type == 104 || type == 105 || type == 320 || type == 337 || type == 349 || type == 356 || type == 378 || type == 456)
{
WorldGen.Place2xX(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
if (type == 17 || type == 77 || type == 133)
{
WorldGen.Place3x2(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
}
switch (type)
{
case 207:
WorldGen.Place2xX(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 410:
WorldGen.Place2xX(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 465:
WorldGen.Place2xX(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
default:
if (TileID.Sets.BasicChest[type])
{
WorldGen.PlaceChest(i, j, (ushort) type, style: style);
WorldGen.SquareTileFrame(i, j);
break;
}
switch (type)
{
case 27:
WorldGen.PlaceSunflower(i, j);
WorldGen.SquareTileFrame(i, j);
break;
case 28:
WorldGen.PlacePot(i, j, style: WorldGen.genRand.Next(4));
WorldGen.SquareTileFrame(i, j);
break;
case 36:
case 135:
case 141:
case 144:
case 210:
case 239:
case 324:
WorldGen.Place1x1(i, j, type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 42:
case 270:
case 271:
WorldGen.Place1x2Top(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 55:
case 425:
WorldGen.PlaceSign(i, j, (ushort) type, style);
break;
case 85:
case 376:
WorldGen.Place2x2Horizontal(i, j, (ushort) type, style);
break;
case 91:
WorldGen.PlaceBanner(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 101:
case 102:
case 463:
WorldGen.Place3x4(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 419:
case 420:
case 423:
case 424:
case 429:
case 445:
WorldGen.PlaceLogicTiles(i, j, type, style);
WorldGen.SquareTileFrame(i, j);
break;
case 464:
case 466:
WorldGen.Place5x4(i, j, (ushort) type, style);
WorldGen.SquareTileFrame(i, j);
break;
default:
if (Main.tileAlch[type])
{
WorldGen.PlaceAlch(i, j, style);
break;
}
switch (type)
{
case 19:
trackCache.frameY = (short) (18 * style);
trackCache.active(true);
trackCache.type = (ushort) type;
break;
case 79:
case 90:
int direction = 1;
if (plr > -1)
direction = Main.player[plr].direction;
WorldGen.Place4x2(i, j, (ushort) type, direction, style);
break;
case 81:
trackCache.frameX = (short) (26 * WorldGen.genRand.Next(6));
trackCache.active(true);
trackCache.type = (ushort) type;
break;
case 94:
case 95:
case 97:
case 98:
case 99:
case 100:
case 125:
case 126:
case 172:
case 173:
case 287:
WorldGen.Place2x2(i, j, (ushort) type, style);
break;
case 96:
WorldGen.Place2x2Style(i, j, (ushort) type, style);
break;
case 209:
WorldGen.PlaceCannon(i, j, (ushort) type, style);
break;
case 314:
Minecart.PlaceTrack(trackCache, style);
break;
case 380:
trackCache.frameY = (short) (18 * style);
trackCache.active(true);
trackCache.type = (ushort) type;
break;
default:
trackCache.active(true);
trackCache.type = (ushort) type;
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
break;
}
}
if (trackCache.active())
{
if (trackCache.type == (ushort) 54)
WorldGen.SquareWallFrame(i, j);
WorldGen.SquareTileFrame(i, j);
flag = true;
if (!mute)
{
switch (type)
{
case (int) sbyte.MaxValue:
Main.PlaySound(SoundID.Item30, i * 16, j * 16);
break;
case 314:
Main.PlaySound(SoundID.Item52, i * 16, j * 16);
break;
case 330:
case 331:
case 332:
case 333:
Main.PlaySound(18, i * 16, j * 16);
break;
default:
Main.PlaySound(0, i * 16, j * 16);
break;
}
if (type == 22 || type == 140)
{
for (int index = 0; index < 3; ++index)
Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 14);
}
}
}
}
}
return flag;
}
public static void KillWall(int i, int j, bool fail = false)
{
if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY)
return;
Tile tile = Main.tile[i, j];
if (tile == null)
{
tile = new Tile();
Main.tile[i, j] = tile;
}
if (tile.wall <= (byte) 0)
return;
if (Main.wallDungeon[(int) tile.wall] && !NPC.downedBoss3)
fail = true;
if (tile.wall == (byte) 87 && !NPC.downedGolemBoss)
fail = true;
if (tile.wall == (byte) 21 || tile.wall == (byte) 186 || tile.wall == (byte) 136 || tile.wall == (byte) 137 || tile.wall == (byte) 168 || tile.wall == (byte) 169 || tile.wall == (byte) 172 || tile.wall == (byte) 226 || tile.wall == (byte) 227)
Main.PlaySound(13, i * 16, j * 16);
else if (tile.wall >= (byte) 63 && tile.wall <= (byte) 70)
Main.PlaySound(6, i * 16, j * 16);
else
Main.PlaySound(0, i * 16, j * 16);
int num = 10;
if (fail)
num = 3;
for (int index1 = 0; index1 < num; ++index1)
{
int Type = 0;
if (tile.wall == (byte) 148)
Type = -1;
if (tile.wall == (byte) 1 || tile.wall == (byte) 5 || tile.wall == (byte) 6 || tile.wall == (byte) 7 || tile.wall == (byte) 107 || tile.wall == (byte) 8 || tile.wall == (byte) 9 || tile.wall >= (byte) 48 && tile.wall <= (byte) 53 || tile.wall >= (byte) 54 && tile.wall <= (byte) 58 || tile.wall == (byte) 185)
Type = 1;
if (tile.wall >= (byte) 94 && tile.wall <= (byte) 105)
Type = 1;
if (tile.wall == (byte) 3)
Type = WorldGen.genRand.Next(2) != 0 ? 1 : 14;
if (tile.wall == (byte) 35)
Type = 37;
if (tile.wall == (byte) 4 || tile.wall == (byte) 106)
Type = 7;
if (tile.wall == (byte) 12)
Type = 9;
if (tile.wall == (byte) 10)
Type = 10;
if (tile.wall == (byte) 11)
Type = 11;
if (tile.wall == (byte) 21)
Type = 13;
if (tile.wall == (byte) 34)
Type = 32;
if (tile.wall == (byte) 225)
Type = 1;
if (tile.wall == (byte) 145)
Type = 8;
if (tile.wall == (byte) 22 || tile.wall == (byte) 28)
Type = 51;
if (tile.wall == (byte) 23)
Type = 38;
if (tile.wall == (byte) 24)
Type = 36;
if (tile.wall == (byte) 25)
Type = 48;
if (tile.wall == (byte) 179 || tile.wall == (byte) 178 || tile.wall == (byte) 183)
Type = 236;
if (tile.wall == (byte) 181 || tile.wall == (byte) 180 || tile.wall == (byte) 184)
Type = 240;
if (tile.wall == (byte) 113)
Type = 189;
if (tile.wall == (byte) 114)
Type = 190;
if (tile.wall == (byte) 115)
Type = 191;
if (tile.wall == (byte) 177 || tile.wall == (byte) 13)
Type = 25;
if (tile.wall == (byte) 186)
Type = WorldGen.genRand.Next(68, 71);
if (tile.wall == (byte) 142)
Type = 210;
if (tile.wall == (byte) 143)
Type = 210;
if (tile.wall == (byte) 224)
Type = 265;
if (tile.wall == (byte) 173)
Type = 128;
if (tile.wall == (byte) 174)
Type = 117;
if (tile.wall == (byte) 175)
Type = 42;
if (tile.wall == (byte) 176)
Type = 226;
if (tile.wall == (byte) 182)
Type = WorldGen.genRand.Next(2) != 0 ? 23 : 6;
if (tile.wall >= (byte) 153 && tile.wall <= (byte) 166)
{
switch (tile.wall)
{
case 153:
case 157:
Type = 138;
break;
case 154:
case 158:
Type = 86;
break;
case 155:
case 159:
Type = 91;
break;
case 156:
case 160:
Type = 89;
break;
case 161:
case 164:
Type = 90;
break;
case 162:
case 165:
Type = 88;
break;
case 163:
case 166:
Type = 87;
break;
}
}
if (tile.wall == (byte) 26 || tile.wall == (byte) 30)
Type = 49;
if (tile.wall == (byte) 29 || tile.wall == (byte) 32)
Type = 50;
if (tile.wall == (byte) 31)
Type = 51;
if (tile.wall == (byte) 14 || tile.wall == (byte) 20)
Type = 109;
if (tile.wall >= (byte) 88 && tile.wall <= (byte) 93)
{
Type = 86 + (int) tile.wall - 88;
if (tile.wall == (byte) 93)
Type = WorldGen.genRand.Next(88, 94);
}
if (tile.wall == (byte) 33)
Type = 14;
if (tile.wall == (byte) 41)
Type = 77;
if (tile.wall == (byte) 42)
Type = 78;
if (tile.wall == (byte) 43)
Type = 78;
if (tile.wall == (byte) 43)
Type = 78;
if (tile.wall == (byte) 36)
Type = 26;
if (tile.wall == (byte) 37)
Type = 32;
if (tile.wall == (byte) 38)
Type = 2;
if (tile.wall == (byte) 39)
Type = 1;
if (tile.wall == (byte) 40)
Type = 51;
if (tile.wall == (byte) 45)
Type = 81;
if (tile.wall == (byte) 46)
Type = 83;
if (tile.wall == (byte) 47)
Type = 84;
if (tile.wall == (byte) 85)
Type = 126;
if (tile.wall == (byte) 59)
Type = 0;
if (tile.wall == (byte) 61)
Type = 0;
if (tile.wall == (byte) 62)
Type = 0;
if (tile.wall == (byte) 63)
Type = 3;
if (tile.wall == (byte) 65)
Type = 3;
if (tile.wall == (byte) 66)
Type = 3;
if (tile.wall == (byte) 68)
Type = 3;
if (tile.wall == (byte) 64)
Type = 40;
if (tile.wall == (byte) 67)
Type = 40;
if (tile.wall == (byte) 84)
Type = 80;
if (tile.wall == (byte) 71)
Type = 80;
if (tile.wall == (byte) 60)
Type = 3;
if (tile.wall == (byte) 71)
Type = 80;
if (tile.wall == (byte) 167)
Type = 81;
if (tile.wall == (byte) 147)
Type = 51;
if (tile.wall == (byte) 146)
Type = 9;
if (tile.wall == (byte) 109)
Type = 144;
if (tile.wall == (byte) 110)
Type = 145;
if (tile.wall == (byte) 111)
Type = 146;
if (tile.wall == (byte) 86 || tile.wall == (byte) 108)
Type = 147;
if (tile.wall == (byte) 87)
Type = 148;
if (tile.wall == (byte) 83)
{
Type = 117;
if (WorldGen.genRand.Next(2) == 0)
Type = 1;
}
if (tile.wall == (byte) 81)
Type = 123;
if (tile.wall == (byte) 136)
Type = 13;
if (tile.wall == (byte) 137)
Type = 13;
if (tile.wall == (byte) 168)
Type = 13;
if (tile.wall == (byte) 169)
Type = 13;
if (tile.wall == (byte) 172)
Type = 13;
if (tile.wall == (byte) 226)
Type = 13;
if (tile.wall == (byte) 227)
Type = 13;
if (tile.wall == (byte) 72)
Type = 40;
if (tile.wall == (byte) 73)
Type = 16;
if (tile.wall == (byte) 74 || tile.wall == (byte) 80)
Type = 26;
if (tile.wall == (byte) 144)
Type = WorldGen.genRand.Next(2) != 0 ? 118 : 10;
if (tile.wall == (byte) 75)
Type = 26;
if (tile.wall == (byte) 76)
Type = 4;
if (tile.wall == (byte) 77 || tile.wall == (byte) 81)
Type = 5;
if (tile.wall == (byte) 78)
Type = 7;
if (tile.wall == (byte) 79)
Type = 37;
if (tile.wall == (byte) 82)
Type = 36;
if (tile.wall == (byte) 69)
Type = WorldGen.genRand.Next(2) != 0 ? 17 : 14;
if (tile.wall == (byte) 70)
Type = 47;
if (tile.wall == (byte) 27)
Type = WorldGen.genRand.Next(2) != 0 ? 1 : 7;
if (tile.wall == (byte) 138)
Type = 77;
if (tile.wall == (byte) 139)
Type = 78;
if (tile.wall == (byte) 140)
Type = 79;
if (tile.wall == (byte) 141)
Type = 126;
if (tile.wall == (byte) 149 || tile.wall == (byte) 150)
Type = 214;
if (tile.wall == (byte) 151 || tile.wall == (byte) 152)
Type = 215;
else if (tile.wall == (byte) 17 || tile.wall == (byte) 18 || tile.wall == (byte) 19)
Type = 1;
if (tile.wall == (byte) 44)
{
int index2 = Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 66, Alpha: 100, newColor: new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), Scale: 0.75f);
Main.dust[index2].noGravity = true;
}
else if ((tile.wall < (byte) 133 || tile.wall > (byte) 135) && (tile.wall < (byte) 116 || tile.wall > (byte) 125) && (tile.wall < (byte) 126 || tile.wall > (byte) 132))
{
if (tile.wall == (byte) 76)
Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type, Alpha: 75, newColor: new Color(0, 80, (int) byte.MaxValue, 100), Scale: 0.75f);
else if (Type >= 0)
Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type);
}
}
if (fail)
{
WorldGen.SquareWallFrame(i, j);
}
else
{
int Type = 0;
if (tile.wall == (byte) 168)
Type = 2696;
if (tile.wall == (byte) 169)
Type = 2698;
if (tile.wall == (byte) 226)
Type = 3752;
if (tile.wall == (byte) 227)
Type = 3753;
if (tile.wall == (byte) 228)
Type = 3760;
if (tile.wall == (byte) 229)
Type = 3761;
if (tile.wall == (byte) 230)
Type = 3762;
if (tile.wall == (byte) 142)
Type = 2263;
if (tile.wall == (byte) 143)
Type = 2264;
if (tile.wall == (byte) 144)
Type = 2271;
if (tile.wall == (byte) 149)
Type = 2505;
if (tile.wall == (byte) 150)
Type = 2507;
if (tile.wall == (byte) 151)
Type = 2506;
if (tile.wall == (byte) 152)
Type = 2508;
if (tile.wall == (byte) 1)
Type = 26;
if (tile.wall == (byte) 4)
Type = 93;
if (tile.wall == (byte) 5)
Type = 130;
if (tile.wall == (byte) 6)
Type = 132;
if (tile.wall == (byte) 7)
Type = 135;
if (tile.wall == (byte) 8)
Type = 138;
if (tile.wall == (byte) 9)
Type = 140;
if (tile.wall == (byte) 10)
Type = 142;
if (tile.wall == (byte) 11)
Type = 144;
if (tile.wall == (byte) 12)
Type = 146;
if (tile.wall == (byte) 14)
Type = 330;
if (tile.wall == (byte) 224)
Type = 3472;
if (tile.wall == (byte) 177)
Type = 3067;
if (tile.wall == (byte) 167)
Type = 2691;
if (tile.wall == (byte) 60)
Type = 3584;
if (tile.wall == (byte) 225)
Type = 3751;
if (tile.wall == (byte) 179)
Type = 3083;
if (tile.wall == (byte) 183)
Type = 3082;
if (tile.wall == (byte) 181)
Type = 3089;
if (tile.wall == (byte) 184)
Type = 3088;
if (tile.wall == (byte) 186)
Type = 3238;
if (tile.wall >= (byte) 153 && tile.wall <= (byte) 166)
{
switch (tile.wall)
{
case 153:
Type = 2677;
break;
case 154:
Type = 2679;
break;
case 155:
Type = 2681;
break;
case 156:
Type = 2683;
break;
case 157:
Type = 2678;
break;
case 158:
Type = 2680;
break;
case 159:
Type = 2682;
break;
case 160:
Type = 2684;
break;
case 161:
Type = 2686;
break;
case 162:
Type = 2688;
break;
case 163:
Type = 2690;
break;
case 164:
Type = 2685;
break;
case 165:
Type = 2687;
break;
case 166:
Type = 2689;
break;
}
}
if (tile.wall == (byte) 136)
Type = 2169;
if (tile.wall == (byte) 137)
Type = 2170;
if (tile.wall == (byte) 172)
Type = 2788;
if (tile.wall == (byte) 145)
Type = 2333;
if (tile.wall == (byte) 16)
Type = 30;
if (tile.wall == (byte) 17)
Type = 135;
if (tile.wall == (byte) 18)
Type = 138;
if (tile.wall == (byte) 19)
Type = 140;
if (tile.wall == (byte) 20)
Type = 330;
if (tile.wall == (byte) 21)
Type = 392;
if (tile.wall == (byte) 86 || tile.wall == (byte) 108)
Type = 1126;
if (tile.wall == (byte) 173)
Type = 2789;
if (tile.wall == (byte) 174)
Type = 2790;
if (tile.wall == (byte) 175)
Type = 2791;
if (tile.wall == (byte) 176)
Type = 2861;
if (tile.wall == (byte) 182)
Type = 3101;
if (tile.wall == (byte) 133)
Type = 2158;
if (tile.wall == (byte) 134)
Type = 2159;
if (tile.wall == (byte) 135)
Type = 2160;
else if (tile.wall == (byte) 113)
Type = 1726;
else if (tile.wall == (byte) 114)
Type = 1728;
else if (tile.wall == (byte) 115)
Type = 1730;
else if (tile.wall == (byte) 146)
Type = 2432;
else if (tile.wall == (byte) 147)
Type = 2433;
else if (tile.wall == (byte) 148)
Type = 2434;
if (tile.wall >= (byte) 116 && tile.wall <= (byte) 125)
Type = 1948 + (int) tile.wall - 116;
if (tile.wall >= (byte) 126 && tile.wall <= (byte) 132)
Type = 2008 + (int) tile.wall - 126;
if (tile.wall == (byte) 22)
Type = 417;
if (tile.wall == (byte) 23)
Type = 418;
if (tile.wall == (byte) 24)
Type = 419;
if (tile.wall == (byte) 25)
Type = 420;
if (tile.wall == (byte) 26)
Type = 421;
if (tile.wall == (byte) 29)
Type = 587;
if (tile.wall == (byte) 30)
Type = 592;
if (tile.wall == (byte) 31)
Type = 595;
if (tile.wall == (byte) 32)
Type = 605;
if (tile.wall == (byte) 33)
Type = 606;
if (tile.wall == (byte) 34)
Type = 608;
if (tile.wall == (byte) 35)
Type = 610;
if (tile.wall == (byte) 36)
Type = 615;
if (tile.wall == (byte) 37)
Type = 616;
if (tile.wall == (byte) 38)
Type = 617;
if (tile.wall == (byte) 39)
Type = 618;
if (tile.wall == (byte) 41)
Type = 622;
if (tile.wall == (byte) 42)
Type = 623;
if (tile.wall == (byte) 43)
Type = 624;
if (tile.wall == (byte) 44)
Type = 663;
if (tile.wall == (byte) 45)
Type = 720;
if (tile.wall == (byte) 46)
Type = 721;
if (tile.wall == (byte) 47)
Type = 722;
if (tile.wall == (byte) 66)
Type = 745;
if (tile.wall == (byte) 67)
Type = 746;
if (tile.wall == (byte) 68)
Type = 747;
if (tile.wall == (byte) 84)
Type = 884;
if (tile.wall == (byte) 72)
Type = 750;
if (tile.wall == (byte) 73)
Type = 752;
if (tile.wall == (byte) 74)
Type = 764;
if (tile.wall == (byte) 85)
Type = 927;
if (tile.wall == (byte) 75)
Type = 768;
if (tile.wall == (byte) 76)
Type = 769;
if (tile.wall == (byte) 77)
Type = 770;
if (tile.wall == (byte) 82)
Type = 825;
if (tile.wall == (byte) 27)
Type = 479;
if (tile.wall == (byte) 106)
Type = 1447;
if (tile.wall == (byte) 107)
Type = 1448;
if (tile.wall == (byte) 109)
Type = 1590;
if (tile.wall == (byte) 110)
Type = 1592;
if (tile.wall == (byte) 111)
Type = 1594;
if (tile.wall == (byte) 78)
Type = 1723;
if (tile.wall == (byte) 87 || tile.wall == (byte) 112)
Type = 1102;
if (tile.wall == (byte) 94 || tile.wall == (byte) 100)
Type = 1378;
if (tile.wall == (byte) 95 || tile.wall == (byte) 101)
Type = 1379;
if (tile.wall == (byte) 96 || tile.wall == (byte) 102)
Type = 1380;
if (tile.wall == (byte) 97 || tile.wall == (byte) 103)
Type = 1381;
if (tile.wall == (byte) 98 || tile.wall == (byte) 104)
Type = 1382;
if (tile.wall == (byte) 99 || tile.wall == (byte) 105)
Type = 1383;
if (tile.wall >= (byte) 88 && tile.wall <= (byte) 93)
Type = 1267 + (int) tile.wall - 88;
if (tile.wall >= (byte) 138 && tile.wall <= (byte) 141)
Type = 2210 + (int) tile.wall - 138;
if (Type > 0)
Item.NewItem(i * 16, j * 16, 16, 16, Type);
tile.wall = (byte) 0;
tile.wallColor((byte) 0);
WorldGen.SquareWallFrame(i, j);
if (tile.type < (ushort) 0 || tile.type >= (ushort) 470 || !TileID.Sets.FramesOnKillWall[(int) tile.type])
return;
WorldGen.TileFrame(i, j);
}
}
public static void LaunchRocket(int x, int y)
{
int frameY = (int) Main.tile[x, y].frameY;
int num1 = 0;
while (frameY >= 40)
{
frameY -= 40;
++num1;
}
if (frameY == 18)
--y;
Vector2 vector2 = new Vector2((float) (x * 16 + 8), (float) (y * 16 + 4));
int Type = 167 + num1;
int Damage = 150;
int num2 = 7;
Projectile.NewProjectile(vector2.X, vector2.Y + 2f, 0.0f, -8f, Type, Damage, (float) num2, Main.myPlayer);
Main.tile[x, y].active(false);
Main.tile[x, y + 1].active(false);
NetMessage.SendTileSquare(-1, x - 1, y, 3);
}
public static void LaunchRocketSmall(int x, int y)
{
if (Main.tile[x, y].frameX == (short) 18)
--x;
if (Main.tile[x, y].frameY == (short) 18)
--y;
Vector2 vector2 = new Vector2((float) (x * 16 + 16), (float) (y * 16));
int Type = 415 + Main.rand.Next(4);
int Damage = 0;
int num = 0;
Projectile.NewProjectile(vector2.X, vector2.Y + 2f, 0.0f, -8f, Type, Damage, (float) num, Main.myPlayer);
}
public static bool CanKillTile(int i, int j) => WorldGen.CanKillTile(i, j, out bool _);
public static bool CanKillTile(int i, int j, out bool blockDamaged)
{
blockDamaged = false;
if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY)
return false;
Tile tile1 = Main.tile[i, j];
Tile tile2 = (Tile) null;
if (tile1 == null || !tile1.active())
return false;
if (j >= 1)
tile2 = Main.tile[i, j - 1];
if (tile2 != null && tile2.active())
{
int type = (int) tile2.type;
switch (type)
{
case 5:
if ((int) tile1.type != type && (tile2.frameX != (short) 66 || tile2.frameY < (short) 0 || tile2.frameY > (short) 44) && (tile2.frameX != (short) 88 || tile2.frameY < (short) 66 || tile2.frameY > (short) 110) && tile2.frameY < (short) 198)
return false;
break;
case 21:
case 26:
case 72:
case 88:
if ((int) tile1.type != type)
return false;
break;
case 323:
if ((int) tile1.type != type && (tile2.frameX == (short) 66 || tile2.frameX == (short) 220))
return false;
break;
}
}
switch (tile1.type)
{
case 10:
if (tile1.type == (ushort) 10 && tile1.frameY >= (short) 594 && tile1.frameY <= (short) 646)
{
blockDamaged = true;
return false;
}
break;
case 21:
if (!Chest.CanDestroyChest(i - (int) tile1.frameX / 18 % 2, j - (int) tile1.frameY / 18))
return false;
break;
case 88:
if (!Chest.CanDestroyChest(i - (int) tile1.frameX / 18 % 3, j - (int) tile1.frameY / 18))
return false;
break;
case 138:
if (WorldGen.CheckBoulderChest(i, j))
{
blockDamaged = true;
return false;
}
break;
case 235:
int num = i - (int) tile1.frameX % 54 / 18;
for (int index = 0; index < 3; ++index)
{
if (Main.tile[num + index, j - 1].active() && (TileID.Sets.BasicChest[(int) Main.tile[num + index, j - 1].type] || TileID.Sets.BasicChestFake[(int) Main.tile[num + index, j - 1].type]))
{
blockDamaged = true;
return false;
}
}
break;
}
return true;
}
public static void KillTile(int i, int j, bool fail = false, bool effectOnly = false, bool noItem = false)
{
if (i < 0 || j < 0 || i >= Main.maxTilesX || j >= Main.maxTilesY)
return;
Tile tile = Main.tile[i, j];
if (tile == null)
{
tile = new Tile();
Main.tile[i, j] = tile;
}
if (!tile.active())
return;
if (j >= 1 && Main.tile[i, j - 1] == null)
Main.tile[i, j - 1] = new Tile();
if (j >= 1 && Main.tile[i, j - 1].active() && (Main.tile[i, j - 1].type == (ushort) 5 && tile.type != (ushort) 5 || Main.tile[i, j - 1].type == (ushort) 323 && tile.type != (ushort) 323 || TileID.Sets.BasicChest[(int) Main.tile[i, j - 1].type] && !TileID.Sets.BasicChest[(int) tile.type] || Main.tile[i, j - 1].type == (ushort) 323 && tile.type != (ushort) 323 || Main.tile[i, j - 1].type == (ushort) 88 && tile.type != (ushort) 88 || Main.tile[i, j - 1].type == (ushort) 26 && tile.type != (ushort) 26 || Main.tile[i, j - 1].type == (ushort) 72 && tile.type != (ushort) 72))
{
if (Main.tile[i, j - 1].type == (ushort) 5)
{
if ((Main.tile[i, j - 1].frameX != (short) 66 || Main.tile[i, j - 1].frameY < (short) 0 || Main.tile[i, j - 1].frameY > (short) 44) && (Main.tile[i, j - 1].frameX != (short) 88 || Main.tile[i, j - 1].frameY < (short) 66 || Main.tile[i, j - 1].frameY > (short) 110) && Main.tile[i, j - 1].frameY < (short) 198)
return;
}
else if (Main.tile[i, j - 1].type != (ushort) 323 || Main.tile[i, j - 1].frameX == (short) 66 || Main.tile[i, j - 1].frameX == (short) 220)
return;
}
if (tile.type == (ushort) 10 && tile.frameY >= (short) 594 && tile.frameY <= (short) 646)
fail = true;
if (tile.type == (ushort) 138)
fail = WorldGen.CheckBoulderChest(i, j);
if (tile.type == (ushort) 235)
{
int frameX = (int) tile.frameX;
int num = i - frameX % 54 / 18;
for (int index = 0; index < 3; ++index)
{
if (Main.tile[num + index, j - 1].active() && (TileID.Sets.BasicChest[(int) Main.tile[num + index, j - 1].type] || TileID.Sets.BasicChestFake[(int) Main.tile[num + index, j - 1].type] || Main.tile[num + index, j - 1].type == (ushort) 88))
{
fail = true;
break;
}
}
}
if (!effectOnly && !WorldGen.stopDrops)
{
if (!noItem && FixExploitManEaters.SpotProtected(i, j))
return;
if (tile.type == (ushort) sbyte.MaxValue)
Main.PlaySound(SoundID.Item27, i * 16, j * 16);
else if (tile.type == (ushort) 147 || tile.type == (ushort) 224)
{
if (WorldGen.genRand.Next(2) == 0)
Main.PlaySound(SoundID.Item48, i * 16, j * 16);
else
Main.PlaySound(SoundID.Item49, i * 16, j * 16);
}
else if (tile.type == (ushort) 161 || tile.type == (ushort) 163 || tile.type == (ushort) 164 || tile.type == (ushort) 200)
Main.PlaySound(SoundID.Item50, i * 16, j * 16);
else if (tile.type == (ushort) 3 || tile.type == (ushort) 110)
{
Main.PlaySound(6, i * 16, j * 16);
if (tile.frameX == (short) 144)
Item.NewItem(i * 16, j * 16, 16, 16, 5);
}
else if (tile.type == (ushort) 254)
Main.PlaySound(6, i * 16, j * 16);
else if (tile.type == (ushort) 24)
{
Main.PlaySound(6, i * 16, j * 16);
if (tile.frameX == (short) 144)
Item.NewItem(i * 16, j * 16, 16, 16, 60);
}
else if (Main.tileAlch[(int) tile.type] || tile.type == (ushort) 384 || tile.type == (ushort) 227 || tile.type == (ushort) 32 || tile.type == (ushort) 51 || tile.type == (ushort) 52 || tile.type == (ushort) 61 || tile.type == (ushort) 62 || tile.type == (ushort) 69 || tile.type == (ushort) 71 || tile.type == (ushort) 73 || tile.type == (ushort) 74 || tile.type == (ushort) 113 || tile.type == (ushort) 115 || tile.type == (ushort) 184 || tile.type == (ushort) 192 || tile.type == (ushort) 205 || tile.type == (ushort) 233 || tile.type == (ushort) 352 || tile.type == (ushort) 382)
Main.PlaySound(6, i * 16, j * 16);
else if (tile.type == (ushort) 201)
{
Main.PlaySound(6, i * 16, j * 16);
if (tile.frameX == (short) 270)
Item.NewItem(i * 16, j * 16, 16, 16, 2887);
}
else if (tile.type == (ushort) 1 || tile.type == (ushort) 6 || tile.type == (ushort) 7 || tile.type == (ushort) 8 || tile.type == (ushort) 9 || tile.type == (ushort) 22 || tile.type == (ushort) 140 || tile.type == (ushort) 25 || tile.type == (ushort) 37 || tile.type == (ushort) 38 || tile.type == (ushort) 39 || tile.type == (ushort) 41 || tile.type == (ushort) 43 || tile.type == (ushort) 44 || tile.type == (ushort) 45 || tile.type == (ushort) 46 || tile.type == (ushort) 47 || tile.type == (ushort) 48 || tile.type == (ushort) 56 || tile.type == (ushort) 58 || tile.type == (ushort) 63 || tile.type == (ushort) 64 || tile.type == (ushort) 65 || tile.type == (ushort) 66 || tile.type == (ushort) 67 || tile.type == (ushort) 68 || tile.type == (ushort) 75 || tile.type == (ushort) 76 || tile.type == (ushort) 107 || tile.type == (ushort) 108 || tile.type == (ushort) 111 || tile.type == (ushort) 117 || tile.type == (ushort) 118 || tile.type == (ushort) 119 || tile.type == (ushort) 120 || tile.type == (ushort) 121 || tile.type == (ushort) 122 || tile.type == (ushort) 150 || tile.type == (ushort) 151 || tile.type == (ushort) 152 || tile.type == (ushort) 153 || tile.type == (ushort) 154 || tile.type == (ushort) 155 || tile.type == (ushort) 156 || tile.type == (ushort) 160 || tile.type == (ushort) 161 || tile.type == (ushort) 166 || tile.type == (ushort) 167 || tile.type == (ushort) 168 || tile.type == (ushort) 169 || tile.type == (ushort) 175 || tile.type == (ushort) 176 || tile.type == (ushort) 177 || tile.type == (ushort) 203 || tile.type == (ushort) 202 || tile.type == (ushort) 204 || tile.type == (ushort) 206 || tile.type == (ushort) 211 || tile.type == (ushort) 221 || tile.type == (ushort) 222 || tile.type == (ushort) 223 || tile.type == (ushort) 226 || tile.type == (ushort) 248 || tile.type == (ushort) 249 || tile.type == (ushort) 250 || tile.type == (ushort) 272 || tile.type == (ushort) 273 || tile.type == (ushort) 274 || tile.type == (ushort) 284 || tile.type == (ushort) 325 || tile.type == (ushort) 346 || tile.type == (ushort) 347 || tile.type == (ushort) 348 || tile.type == (ushort) 350 || tile.type == (ushort) 367 || tile.type == (ushort) 357 || tile.type == (ushort) 368 || tile.type == (ushort) 369 || tile.type == (ushort) 370 || tile.type == (ushort) 407)
Main.PlaySound(21, i * 16, j * 16);
else if (tile.type == (ushort) 231 || tile.type == (ushort) 195)
Main.PlaySound(4, i * 16, j * 16);
else if (tile.type == (ushort) 26 && tile.frameX >= (short) 54)
Main.PlaySound(4, i * 16, j * 16);
else if (tile.type == (ushort) 314)
Main.PlaySound(SoundID.Item52, i * 16, j * 16);
else if (tile.type >= (ushort) 330 && tile.type <= (ushort) 333)
Main.PlaySound(18, i * 16, j * 16);
else if (tile.type != (ushort) 138)
Main.PlaySound(0, i * 16, j * 16);
if ((tile.type == (ushort) 162 || tile.type == (ushort) 385 || tile.type == (ushort) 129 || tile.type == (ushort) 165 && tile.frameX < (short) 54) && !fail)
Main.PlaySound(SoundID.Item27, i * 16, j * 16);
}
if (tile.type == (ushort) 128 || tile.type == (ushort) 269)
{
int index1 = i;
int frameX1 = (int) tile.frameX;
int frameX2 = (int) tile.frameX;
while (frameX2 >= 100)
frameX2 -= 100;
while (frameX2 >= 36)
frameX2 -= 36;
if (frameX2 == 18)
{
frameX1 = (int) Main.tile[i - 1, j].frameX;
--index1;
}
if (frameX1 >= 100)
{
int index2 = 0;
while (frameX1 >= 100)
{
frameX1 -= 100;
++index2;
}
int num = (int) Main.tile[index1, j].frameY / 18;
if (num == 0)
Item.NewItem(i * 16, j * 16, 16, 16, Item.headType[index2]);
if (num == 1)
Item.NewItem(i * 16, j * 16, 16, 16, Item.bodyType[index2]);
if (num == 2)
Item.NewItem(i * 16, j * 16, 16, 16, Item.legType[index2]);
int frameX3 = (int) Main.tile[index1, j].frameX;
while (frameX3 >= 100)
frameX3 -= 100;
Main.tile[index1, j].frameX = (short) frameX3;
}
}
if (tile.type == (ushort) 334)
{
int index = i;
int frameX4 = (int) tile.frameX;
int num1 = (int) tile.frameX;
int num2 = 0;
while (num1 >= 5000)
{
num1 -= 5000;
++num2;
}
if (num2 != 0)
num1 = (num2 - 1) * 18;
int num3 = num1 % 54;
if (num3 == 18)
{
frameX4 = (int) Main.tile[i - 1, j].frameX;
--index;
}
if (num3 == 36)
{
frameX4 = (int) Main.tile[i - 2, j].frameX;
index -= 2;
}
if (frameX4 >= 5000)
{
int num4 = frameX4 % 5000 - 100;
int frameX5 = (int) Main.tile[index + 1, j].frameX;
int pre = frameX5 < 25000 ? frameX5 - 10000 : frameX5 - 25000;
if (Main.netMode != 1)
{
Item obj = new Item();
obj.netDefaults(num4);
obj.Prefix(pre);
int number = Item.NewItem(i * 16, j * 16, 16, 16, num4, noBroadcast: true);
obj.position = Main.item[number].position;
Main.item[number] = obj;
NetMessage.SendData(21, number: number);
}
int num5 = (int) Main.tile[index, j].frameX;
int num6 = 0;
while (num5 >= 5000)
{
num5 -= 5000;
++num6;
}
if (num6 != 0)
num5 = (num6 - 1) * 18;
Main.tile[index, j].frameX = (short) num5;
Main.tile[index + 1, j].frameX = (short) (num5 + 18);
}
}
if (tile.type == (ushort) 395)
{
int key = TEItemFrame.Find(i - (int) tile.frameX % 36 / 18, j - (int) tile.frameY % 36 / 18);
if (key != -1 && ((TEItemFrame) TileEntity.ByID[key]).item.stack > 0)
{
((TEItemFrame) TileEntity.ByID[key]).DropItem();
if (Main.netMode == 2)
return;
Main.blockMouse = true;
return;
}
}
int tileDustAmount = WorldGen.KillTile_GetTileDustAmount(fail, tile);
for (int index = 0; index < tileDustAmount; ++index)
WorldGen.KillTile_MakeTileDust(i, j, tile);
if (effectOnly)
return;
if (fail)
{
if (tile.type == (ushort) 2 || tile.type == (ushort) 23 || tile.type == (ushort) 109 || tile.type == (ushort) 199)
tile.type = (ushort) 0;
if (tile.type == (ushort) 60 || tile.type == (ushort) 70)
tile.type = (ushort) 59;
if (Main.tileMoss[(int) tile.type])
tile.type = (ushort) 1;
WorldGen.SquareTileFrame(i, j);
}
else
{
if (TileID.Sets.BasicChest[(int) tile.type] && Main.netMode != 1)
{
int num = (int) tile.frameX / 18;
int Y = j - (int) tile.frameY / 18;
while (num > 1)
num -= 2;
if (!Chest.DestroyChest(i - num, Y))
return;
}
if (tile.type == (ushort) 88 && Main.netMode != 1)
{
int num7 = (int) tile.frameX / 18;
int Y = j - (int) tile.frameY / 18;
int num8 = num7 % 3;
if (!Chest.DestroyChest(i - num8, Y))
return;
}
if (tile.type == (ushort) 51 && tile.wall == (byte) 62 && WorldGen.genRand.Next(4) != 0)
noItem = true;
if (!noItem && !WorldGen.stopDrops && Main.netMode != 1)
{
bool flag1 = false;
int maxValue1 = -1;
int maxValue2 = -1;
int maxValue3 = -1;
if (tile.type == (ushort) 3)
{
maxValue1 = 400;
maxValue2 = 100;
if (tile.frameX >= (short) 108)
{
maxValue1 *= 3;
maxValue2 *= 3;
}
}
if (tile.type == (ushort) 73)
{
maxValue1 = 200;
maxValue2 = 50;
if (tile.frameX >= (short) 108)
{
maxValue1 *= 3;
maxValue2 *= 3;
}
}
if (tile.type == (ushort) 61)
{
maxValue3 = 80;
if (tile.frameX >= (short) 108)
maxValue3 *= 3;
}
if (tile.type == (ushort) 74)
{
maxValue3 = 40;
if (tile.frameX >= (short) 108)
maxValue3 *= 3;
}
if (tile.type == (ushort) 62)
maxValue3 = 250;
if (tile.type == (ushort) 185)
{
if (tile.frameY == (short) 0 && tile.frameX < (short) 214)
maxValue1 = 6;
if (tile.frameY == (short) 18 && (tile.frameX < (short) 214 || tile.frameX >= (short) 1368))
maxValue1 = 6;
}
else if (tile.type == (ushort) 186)
{
if (tile.frameX >= (short) 378 && tile.frameX <= (short) 700)
maxValue1 = 6;
}
else if (tile.type == (ushort) 187)
{
if (tile.frameX >= (short) 756 && tile.frameX <= (short) 916)
maxValue1 = 6;
if (tile.frameX <= (short) 322)
maxValue1 = 6;
}
else if (tile.type == (ushort) 233)
maxValue3 = 10;
if (maxValue1 > 0 && NPC.CountNPCS(357) < 5 && WorldGen.genRand.Next(maxValue1) == 0)
{
int Type = 357;
if (WorldGen.genRand.Next(NPC.goldCritterChance) == 0)
Type = 448;
int index = NPC.NewNPC(i * 16 + 10, j * 16, Type);
Main.npc[index].TargetClosest();
Main.npc[index].velocity.Y = (float) WorldGen.genRand.Next(-50, -21) * 0.1f;
Main.npc[index].velocity.X = (float) WorldGen.genRand.Next(0, 26) * 0.1f * (float) -Main.npc[index].direction;
Main.npc[index].direction *= -1;
Main.npc[index].netUpdate = true;
}
if (maxValue2 > 0 && NPC.CountNPCS(377) < 5 && WorldGen.genRand.Next(maxValue2) == 0)
{
int Type = 377;
if (WorldGen.genRand.Next(NPC.goldCritterChance) == 0)
Type = 446;
int index = NPC.NewNPC(i * 16 + 10, j * 16, Type);
Main.npc[index].TargetClosest();
Main.npc[index].velocity.Y = (float) WorldGen.genRand.Next(-50, -21) * 0.1f;
Main.npc[index].velocity.X = (float) WorldGen.genRand.Next(0, 26) * 0.1f * (float) -Main.npc[index].direction;
Main.npc[index].direction *= -1;
Main.npc[index].netUpdate = true;
}
if (maxValue3 > 0 && NPC.CountNPCS(485) + NPC.CountNPCS(486) + NPC.CountNPCS(487) < 8 && WorldGen.genRand.Next(maxValue3) == 0)
{
int Type = 485;
if (WorldGen.genRand.Next(4) == 0)
Type = 486;
if (WorldGen.genRand.Next(12) == 0)
Type = 487;
int index = NPC.NewNPC(i * 16 + 10, j * 16, Type);
Main.npc[index].TargetClosest();
Main.npc[index].velocity.Y = (float) WorldGen.genRand.Next(-50, -21) * 0.1f;
Main.npc[index].velocity.X = (float) WorldGen.genRand.Next(0, 26) * 0.1f * (float) -Main.npc[index].direction;
Main.npc[index].direction *= -1;
Main.npc[index].netUpdate = true;
}
int Type1 = 0;
int Type2 = 0;
if (tile.type == (ushort) 0 || tile.type == (ushort) 2 || tile.type == (ushort) 109)
Type1 = 2;
else if (tile.type == (ushort) 426)
Type1 = 3621;
else if (tile.type == (ushort) 430)
Type1 = 3633;
else if (tile.type == (ushort) 431)
Type1 = 3634;
else if (tile.type == (ushort) 432)
Type1 = 3635;
else if (tile.type == (ushort) 433)
Type1 = 3636;
else if (tile.type == (ushort) 434)
Type1 = 3637;
else if (tile.type == (ushort) 427)
Type1 = 3622;
else if (tile.type == (ushort) 435)
Type1 = 3638;
else if (tile.type == (ushort) 436)
Type1 = 3639;
else if (tile.type == (ushort) 437)
Type1 = 3640;
else if (tile.type == (ushort) 438)
Type1 = 3641;
else if (tile.type == (ushort) 439)
Type1 = 3642;
else if (tile.type == (ushort) 446)
Type1 = 3736;
else if (tile.type == (ushort) 447)
Type1 = 3737;
else if (tile.type == (ushort) 448)
Type1 = 3738;
else if (tile.type == (ushort) 449)
Type1 = 3739;
else if (tile.type == (ushort) 450)
Type1 = 3740;
else if (tile.type == (ushort) 451)
Type1 = 3741;
else if (tile.type == (ushort) 368)
Type1 = 3086;
else if (tile.type == (ushort) 369)
Type1 = 3087;
else if (tile.type == (ushort) 367)
Type1 = 3081;
else if (tile.type == (ushort) 379)
Type1 = 3214;
else if (tile.type == (ushort) 353)
Type1 = 2996;
else if (tile.type == (ushort) 365)
Type1 = 3077;
else if (tile.type == (ushort) 366)
Type1 = 3078;
else if ((tile.type == (ushort) 52 || tile.type == (ushort) 62) && WorldGen.genRand.Next(2) == 0 && Main.player[(int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16)].cordage)
Type1 = 2996;
else if (tile.type == (ushort) 357)
Type1 = 3066;
else if (tile.type == (ushort) 1)
Type1 = 3;
else if (tile.type == (ushort) 3 || tile.type == (ushort) 73)
{
if (WorldGen.genRand.Next(2) == 0 && (Main.player[(int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16)].HasItem(281) || Main.player[(int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16)].HasItem(986)))
Type1 = 283;
}
else if (tile.type == (ushort) 227)
{
int num = (int) tile.frameX / 34;
Type1 = 1107 + num;
if (num >= 8 && num <= 11)
Type1 = 3385 + num - 8;
}
else if (tile.type == (ushort) 4)
{
int num = (int) tile.frameY / 22;
switch (num)
{
case 0:
Type1 = 8;
break;
case 8:
Type1 = 523;
break;
case 9:
Type1 = 974;
break;
case 10:
Type1 = 1245;
break;
case 11:
Type1 = 1333;
break;
case 12:
Type1 = 2274;
break;
case 13:
Type1 = 3004;
break;
case 14:
Type1 = 3045;
break;
case 15:
Type1 = 3114;
break;
default:
Type1 = 426 + num;
break;
}
}
else if (tile.type == (ushort) 239)
{
int num = (int) tile.frameX / 18;
if (num == 0)
Type1 = 20;
if (num == 1)
Type1 = 703;
if (num == 2)
Type1 = 22;
if (num == 3)
Type1 = 704;
if (num == 4)
Type1 = 21;
if (num == 5)
Type1 = 705;
if (num == 6)
Type1 = 19;
if (num == 7)
Type1 = 706;
if (num == 8)
Type1 = 57;
if (num == 9)
Type1 = 117;
if (num == 10)
Type1 = 175;
if (num == 11)
Type1 = 381;
if (num == 12)
Type1 = 1184;
if (num == 13)
Type1 = 382;
if (num == 14)
Type1 = 1191;
if (num == 15)
Type1 = 391;
if (num == 16)
Type1 = 1198;
if (num == 17)
Type1 = 1006;
if (num == 18)
Type1 = 1225;
if (num == 19)
Type1 = 1257;
if (num == 20)
Type1 = 1552;
if (num == 21)
Type1 = 3261;
if (num == 22)
Type1 = 3467;
}
else if (tile.type == (ushort) 380)
Type1 = 3215 + (int) tile.frameY / 18;
else if (tile.type == (ushort) 442)
Type1 = 3707;
else if (tile.type == (ushort) 383)
Type1 = 620;
else if (tile.type == (ushort) 315)
Type1 = 2435;
else if (tile.type == (ushort) 330)
Type1 = 71;
else if (tile.type == (ushort) 331)
Type1 = 72;
else if (tile.type == (ushort) 332)
Type1 = 73;
else if (tile.type == (ushort) 333)
Type1 = 74;
else if (tile.type == (ushort) 5)
{
if (tile.frameX >= (short) 22 && tile.frameY >= (short) 198)
{
if (Main.netMode != 1)
{
if (WorldGen.genRand.Next(2) == 0)
{
int index = j;
while (Main.tile[i, index] != null && (!Main.tile[i, index].active() || !Main.tileSolid[(int) Main.tile[i, index].type] || Main.tileSolidTop[(int) Main.tile[i, index].type]))
++index;
if (Main.tile[i, index] != null)
{
if (Main.tile[i, index].type == (ushort) 2 || Main.tile[i, index].type == (ushort) 109 || Main.tile[i, index].type == (ushort) 147 || Main.tile[i, index].type == (ushort) 199 || Main.tile[i, index].type == (ushort) 23)
{
Type1 = 9;
Type2 = 27;
}
else
Type1 = 9;
}
}
else
Type1 = 9;
}
}
else
Type1 = 9;
if (Type1 == 9)
{
int index3 = i;
int index4 = j;
if (tile.frameX == (short) 66 && tile.frameY <= (short) 45)
++index3;
if (tile.frameX == (short) 88 && tile.frameY >= (short) 66 && tile.frameY <= (short) 110)
--index3;
if (tile.frameX == (short) 22 && tile.frameY >= (short) 132 && tile.frameY <= (short) 176)
--index3;
if (tile.frameX == (short) 44 && tile.frameY >= (short) 132 && tile.frameY <= (short) 176)
++index3;
if (tile.frameX == (short) 44 && tile.frameY >= (short) 198)
++index3;
if (tile.frameX == (short) 66 && tile.frameY >= (short) 198)
--index3;
while (!Main.tile[index3, index4].active() || !Main.tileSolid[(int) Main.tile[index3, index4].type])
++index4;
if (Main.tile[index3, index4].active())
{
switch (Main.tile[index3, index4].type)
{
case 23:
Type1 = 619;
break;
case 60:
Type1 = 620;
break;
case 70:
Type1 = 183;
break;
case 109:
Type1 = 621;
break;
case 147:
Type1 = 2503;
break;
case 199:
Type1 = 911;
break;
}
}
int closest = (int) Player.FindClosest(new Vector2((float) (index3 * 16), (float) (index4 * 16)), 16, 16);
int axe = Main.player[closest].inventory[Main.player[closest].selectedItem].axe;
if (WorldGen.genRand.Next(100) < axe || Main.rand.Next(3) == 0)
flag1 = true;
}
}
else if (tile.type == (ushort) 323)
{
Type1 = 2504;
if (tile.frameX <= (short) 132 && tile.frameX >= (short) 88)
Type2 = 27;
int index5 = i;
int index6 = j;
while (!Main.tile[index5, index6].active() || !Main.tileSolid[(int) Main.tile[index5, index6].type])
++index6;
if (Main.tile[index5, index6].active())
{
switch (Main.tile[index5, index6].type)
{
case 112:
Type1 = 619;
break;
case 116:
Type1 = 621;
break;
case 234:
Type1 = 911;
break;
}
}
}
else if (tile.type == (ushort) 408)
Type1 = 3460;
else if (tile.type == (ushort) 409)
Type1 = 3461;
else if (tile.type == (ushort) 415)
Type1 = 3573;
else if (tile.type == (ushort) 416)
Type1 = 3574;
else if (tile.type == (ushort) 417)
Type1 = 3575;
else if (tile.type == (ushort) 418)
Type1 = 3576;
else if (tile.type >= (ushort) byte.MaxValue && tile.type <= (ushort) 261)
Type1 = 1970 + (int) tile.type - (int) byte.MaxValue;
else if (tile.type >= (ushort) 262 && tile.type <= (ushort) 268)
Type1 = 1970 + (int) tile.type - 262;
else if (tile.type == (ushort) 171)
{
if (tile.frameX >= (short) 10)
{
WorldGen.dropXmasTree(i, j, 0);
WorldGen.dropXmasTree(i, j, 1);
WorldGen.dropXmasTree(i, j, 2);
WorldGen.dropXmasTree(i, j, 3);
}
}
else if (tile.type == (ushort) 324)
{
switch ((int) tile.frameY / 22)
{
case 0:
Type1 = 2625;
break;
case 1:
Type1 = 2626;
break;
}
}
else if (tile.type == (ushort) 421)
Type1 = 3609;
else if (tile.type == (ushort) 422)
Type1 = 3610;
else if (tile.type == (ushort) 419)
{
switch ((int) tile.frameX / 18)
{
case 0:
Type1 = 3602;
break;
case 1:
Type1 = 3618;
break;
case 2:
Type1 = 3663;
break;
}
}
else if (tile.type == (ushort) 428)
{
switch ((int) tile.frameY / 18)
{
case 0:
Type1 = 3630;
break;
case 1:
Type1 = 3632;
break;
case 2:
Type1 = 3631;
break;
case 3:
Type1 = 3626;
break;
}
PressurePlateHelper.DestroyPlate(new Point(i, j));
}
else if (tile.type == (ushort) 420)
{
switch ((int) tile.frameY / 18)
{
case 0:
Type1 = 3603;
break;
case 1:
Type1 = 3604;
break;
case 2:
Type1 = 3605;
break;
case 3:
Type1 = 3606;
break;
case 4:
Type1 = 3607;
break;
case 5:
Type1 = 3608;
break;
}
}
else if (tile.type == (ushort) 423)
{
TELogicSensor.Kill(i, j);
switch ((int) tile.frameY / 18)
{
case 0:
Type1 = 3613;
break;
case 1:
Type1 = 3614;
break;
case 2:
Type1 = 3615;
break;
case 3:
Type1 = 3726;
break;
case 4:
Type1 = 3727;
break;
case 5:
Type1 = 3728;
break;
case 6:
Type1 = 3729;
break;
}
}
else if (tile.type == (ushort) 424)
Type1 = 3616;
else if (tile.type == (ushort) 445)
Type1 = 3725;
else if (tile.type == (ushort) 429)
Type1 = 3629;
else if (tile.type == (ushort) 272)
Type1 = 1344;
else if (tile.type == (ushort) 273)
Type1 = 2119;
else if (tile.type == (ushort) 274)
Type1 = 2120;
else if (tile.type == (ushort) 460)
Type1 = 3756;
else if (tile.type == (ushort) 326)
{
Type1 = 2693;
Main.PlaySound(13, i * 16, j * 16);
}
else if (tile.type == (ushort) 327)
{
Type1 = 2694;
Main.PlaySound(13, i * 16, j * 16);
}
else if (tile.type == (ushort) 458)
{
Type1 = 3754;
Main.PlaySound(13, i * 16, j * 16);
}
else if (tile.type == (ushort) 459)
{
Type1 = 3755;
Main.PlaySound(13, i * 16, j * 16);
}
else if (tile.type == (ushort) 345)
{
Type1 = 2787;
Main.PlaySound(13, i * 16, j * 16);
}
else if (tile.type == (ushort) 328)
{
Type1 = 2695;
Main.PlaySound(13, i * 16, j * 16);
}
else if (tile.type == (ushort) 329)
{
Type1 = 2697;
Main.PlaySound(13, i * 16, j * 16);
}
else if (tile.type == (ushort) 346)
Type1 = 2792;
else if (tile.type == (ushort) 347)
Type1 = 2793;
else if (tile.type == (ushort) 348)
Type1 = 2794;
else if (tile.type == (ushort) 350)
Type1 = 2860;
else if (tile.type == (ushort) 336)
Type1 = 2701;
else if (tile.type == (ushort) 340)
Type1 = 2751;
else if (tile.type == (ushort) 341)
Type1 = 2752;
else if (tile.type == (ushort) 342)
Type1 = 2753;
else if (tile.type == (ushort) 343)
Type1 = 2754;
else if (tile.type == (ushort) 344)
Type1 = 2755;
else if (tile.type == (ushort) 351)
Type1 = 2868;
else if (tile.type == (ushort) 251)
Type1 = 1725;
else if (tile.type == (ushort) 252)
Type1 = 1727;
else if (tile.type == (ushort) 253)
Type1 = 1729;
else if (tile.type == (ushort) 325)
Type1 = 2692;
else if (tile.type == (ushort) 370)
Type1 = 3100;
else if (tile.type == (ushort) 396)
Type1 = 3271;
else if (tile.type == (ushort) 400)
Type1 = 3276;
else if (tile.type == (ushort) 401)
Type1 = 3277;
else if (tile.type == (ushort) 403)
Type1 = 3339;
else if (tile.type == (ushort) 397)
Type1 = 3272;
else if (tile.type == (ushort) 398)
Type1 = 3274;
else if (tile.type == (ushort) 399)
Type1 = 3275;
else if (tile.type == (ushort) 402)
Type1 = 3338;
else if (tile.type == (ushort) 404)
Type1 = 3347;
else if (tile.type == (ushort) 407)
Type1 = 3380;
else if (tile.type == (ushort) 170)
Type1 = 1872;
else if (tile.type == (ushort) 284)
Type1 = 2173;
else if (tile.type == (ushort) 214)
Type1 = 85;
else if (tile.type == (ushort) 213)
Type1 = 965;
else if (tile.type == (ushort) 211)
Type1 = 947;
else if (tile.type == (ushort) 6)
Type1 = 11;
else if (tile.type == (ushort) 7)
Type1 = 12;
else if (tile.type == (ushort) 8)
Type1 = 13;
else if (tile.type == (ushort) 9)
Type1 = 14;
else if (tile.type == (ushort) 202)
Type1 = 824;
else if (tile.type == (ushort) 234)
Type1 = 1246;
else if (tile.type == (ushort) 226)
Type1 = 1101;
else if (tile.type == (ushort) 224)
Type1 = 1103;
else if (tile.type == (ushort) 36)
Type1 = 1869;
else if (tile.type == (ushort) 311)
Type1 = 2260;
else if (tile.type == (ushort) 312)
Type1 = 2261;
else if (tile.type == (ushort) 313)
Type1 = 2262;
else if (tile.type == (ushort) 229)
Type1 = 1125;
else if (tile.type == (ushort) 230)
Type1 = 1127;
else if (tile.type == (ushort) 225)
{
if (WorldGen.genRand.Next(3) == 0)
{
tile.honey(true);
tile.liquid = byte.MaxValue;
}
else
{
Type1 = 1124;
if (Main.netMode != 1 && WorldGen.genRand.Next(2) == 0)
{
int num = 1;
if (WorldGen.genRand.Next(3) == 0)
num = 2;
for (int index7 = 0; index7 < num; ++index7)
{
int Type3 = WorldGen.genRand.Next(210, 212);
int index8 = NPC.NewNPC(i * 16 + 8, j * 16 + 15, Type3, 1);
Main.npc[index8].velocity.X = (float) WorldGen.genRand.Next(-200, 201) * (1f / 500f);
Main.npc[index8].velocity.Y = (float) WorldGen.genRand.Next(-200, 201) * (1f / 500f);
Main.npc[index8].netUpdate = true;
}
}
}
}
else if (tile.type == (ushort) 221)
Type1 = 1104;
else if (tile.type == (ushort) 222)
Type1 = 1105;
else if (tile.type == (ushort) 223)
Type1 = 1106;
else if (tile.type == (ushort) 248)
Type1 = 1589;
else if (tile.type == (ushort) 249)
Type1 = 1591;
else if (tile.type == (ushort) 250)
Type1 = 1593;
else if (tile.type == (ushort) 191)
Type1 = 9;
else if (tile.type == (ushort) 203)
Type1 = 836;
else if (tile.type == (ushort) 204)
Type1 = 880;
else if (tile.type == (ushort) 166)
Type1 = 699;
else if (tile.type == (ushort) 167)
Type1 = 700;
else if (tile.type == (ushort) 168)
Type1 = 701;
else if (tile.type == (ushort) 169)
Type1 = 702;
else if (tile.type == (ushort) 123)
Type1 = 424;
else if (tile.type == (ushort) 124)
Type1 = 480;
else if (tile.type == (ushort) 157)
Type1 = 619;
else if (tile.type == (ushort) 158)
Type1 = 620;
else if (tile.type == (ushort) 159)
Type1 = 621;
else if (tile.type == (ushort) 161)
Type1 = 664;
else if (tile.type == (ushort) 206)
Type1 = 883;
else if (tile.type == (ushort) 232)
Type1 = 1150;
else if (tile.type == (ushort) 198)
Type1 = 775;
else if (tile.type == (ushort) 314)
Type1 = Minecart.GetTrackItem(tile);
else if (tile.type == (ushort) 189)
Type1 = 751;
else if (tile.type == (ushort) 195)
Type1 = 763;
else if (tile.type == (ushort) 194)
Type1 = 766;
else if (tile.type == (ushort) 193)
Type1 = 762;
else if (tile.type == (ushort) 196)
Type1 = 765;
else if (tile.type == (ushort) 197)
Type1 = 767;
else if (tile.type == (ushort) 178)
{
switch ((int) tile.frameX / 18)
{
case 0:
Type1 = 181;
break;
case 1:
Type1 = 180;
break;
case 2:
Type1 = 177;
break;
case 3:
Type1 = 179;
break;
case 4:
Type1 = 178;
break;
case 5:
Type1 = 182;
break;
case 6:
Type1 = 999;
break;
}
}
else if (tile.type == (ushort) 149)
{
if (tile.frameX == (short) 0 || tile.frameX == (short) 54)
Type1 = 596;
else if (tile.frameX == (short) 18 || tile.frameX == (short) 72)
Type1 = 597;
else if (tile.frameX == (short) 36 || tile.frameX == (short) 90)
Type1 = 598;
}
else if (tile.type == (ushort) 13)
{
Main.PlaySound(13, i * 16, j * 16);
switch ((int) tile.frameX / 18)
{
case 1:
Type1 = 28;
break;
case 2:
Type1 = 110;
break;
case 3:
Type1 = 350;
break;
case 4:
Type1 = 351;
break;
case 5:
Type1 = 2234;
break;
case 6:
Type1 = 2244;
break;
case 7:
Type1 = 2257;
break;
case 8:
Type1 = 2258;
break;
default:
Type1 = 31;
break;
}
}
else if (tile.type == (ushort) 19)
{
int num = (int) tile.frameY / 18;
switch (num)
{
case 0:
Type1 = 94;
break;
case 1:
Type1 = 631;
break;
case 2:
Type1 = 632;
break;
case 3:
Type1 = 633;
break;
case 4:
Type1 = 634;
break;
case 5:
Type1 = 913;
break;
case 6:
Type1 = 1384;
break;
case 7:
Type1 = 1385;
break;
case 8:
Type1 = 1386;
break;
case 9:
Type1 = 1387;
break;
case 10:
Type1 = 1388;
break;
case 11:
Type1 = 1389;
break;
case 12:
Type1 = 1418;
break;
case 13:
Type1 = 1457;
break;
case 14:
Type1 = 1702;
break;
case 15:
Type1 = 1796;
break;
case 16:
Type1 = 1818;
break;
case 17:
Type1 = 2518;
break;
case 18:
Type1 = 2549;
break;
case 19:
Type1 = 2566;
break;
case 20:
Type1 = 2581;
break;
case 21:
Type1 = 2627;
break;
case 22:
Type1 = 2628;
break;
case 23:
Type1 = 2629;
break;
case 24:
Type1 = 2630;
break;
case 25:
Type1 = 2744;
break;
case 26:
Type1 = 2822;
break;
case 27:
Type1 = 3144;
break;
case 28:
Type1 = 3146;
break;
case 29:
Type1 = 3145;
break;
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
Type1 = 3903 + num - 30;
break;
}
}
else if (tile.type == (ushort) 22)
Type1 = 56;
else if (tile.type == (ushort) 140)
Type1 = 577;
else if (tile.type == (ushort) 23)
Type1 = 2;
else if (tile.type == (ushort) 25)
Type1 = 61;
else if (tile.type == (ushort) 30)
Type1 = 9;
else if (tile.type == (ushort) 191)
Type1 = 9;
else if (tile.type == (ushort) 208)
Type1 = 911;
else if (tile.type == (ushort) 33)
{
int num = (int) tile.frameY / 22;
Type1 = 105;
switch (num)
{
case 1:
Type1 = 1405;
break;
case 2:
Type1 = 1406;
break;
case 3:
Type1 = 1407;
break;
default:
if (num >= 4 && num <= 13)
{
Type1 = 2045 + num - 4;
break;
}
if (num >= 14 && num <= 16)
{
Type1 = 2153 + num - 14;
break;
}
switch (num)
{
case 17:
Type1 = 2236;
break;
case 18:
Type1 = 2523;
break;
case 19:
Type1 = 2542;
break;
case 20:
Type1 = 2556;
break;
case 21:
Type1 = 2571;
break;
case 22:
Type1 = 2648;
break;
case 23:
Type1 = 2649;
break;
case 24:
Type1 = 2650;
break;
case 25:
Type1 = 2651;
break;
case 26:
Type1 = 2818;
break;
case 27:
Type1 = 3171;
break;
case 28:
Type1 = 3173;
break;
case 29:
Type1 = 3172;
break;
case 30:
Type1 = 3890;
break;
}
break;
}
}
else if (tile.type == (ushort) 372)
Type1 = 3117;
else if (tile.type == (ushort) 371)
Type1 = 3113;
else if (tile.type == (ushort) 174)
Type1 = 713;
else if (tile.type == (ushort) 37)
Type1 = 116;
else if (tile.type == (ushort) 38)
Type1 = 129;
else if (tile.type == (ushort) 39)
Type1 = 131;
else if (tile.type == (ushort) 40)
Type1 = 133;
else if (tile.type == (ushort) 41)
Type1 = 134;
else if (tile.type == (ushort) 43)
Type1 = 137;
else if (tile.type == (ushort) 44)
Type1 = 139;
else if (tile.type == (ushort) 45)
Type1 = 141;
else if (tile.type == (ushort) 46)
Type1 = 143;
else if (tile.type == (ushort) 47)
Type1 = 145;
else if (tile.type == (ushort) 48)
Type1 = 147;
else if (tile.type == (ushort) 49)
Type1 = 148;
else if (tile.type == (ushort) 51)
Type1 = 150;
else if (tile.type == (ushort) 53)
Type1 = 169;
else if (tile.type == (ushort) 151)
Type1 = 607;
else if (tile.type == (ushort) 152)
Type1 = 609;
else if (tile.type == (ushort) 54)
{
Type1 = 170;
Main.PlaySound(13, i * 16, j * 16);
}
else if (tile.type == (ushort) 56)
Type1 = 173;
else if (tile.type == (ushort) 57)
Type1 = 172;
else if (tile.type == (ushort) 58)
Type1 = 174;
else if (tile.type == (ushort) 60)
Type1 = 176;
else if (tile.type == (ushort) 70)
Type1 = 176;
else if (tile.type == (ushort) 75)
Type1 = 192;
else if (tile.type == (ushort) 76)
Type1 = 214;
else if (tile.type == (ushort) 78)
Type1 = 222;
else if (tile.type == (ushort) 81)
Type1 = 275;
else if (tile.type == (ushort) 80)
Type1 = 276;
else if (tile.type == (ushort) 188)
Type1 = 276;
else if (tile.type == (ushort) 107)
Type1 = 364;
else if (tile.type == (ushort) 108)
Type1 = 365;
else if (tile.type == (ushort) 111)
Type1 = 366;
else if (tile.type == (ushort) 150)
Type1 = 604;
else if (tile.type == (ushort) 112)
Type1 = 370;
else if (tile.type == (ushort) 116)
Type1 = 408;
else if (tile.type == (ushort) 117)
Type1 = 409;
else if (tile.type == (ushort) 129)
Type1 = 502;
else if (tile.type == (ushort) 118)
Type1 = 412;
else if (tile.type == (ushort) 119)
Type1 = 413;
else if (tile.type == (ushort) 120)
Type1 = 414;
else if (tile.type == (ushort) 121)
Type1 = 415;
else if (tile.type == (ushort) 122)
Type1 = 416;
else if (tile.type == (ushort) 136)
Type1 = 538;
else if (tile.type == (ushort) 385)
Type1 = 3234;
else if (tile.type == (ushort) 137)
{
int num = (int) tile.frameY / 18;
if (num == 0)
Type1 = 539;
if (num == 1)
Type1 = 1146;
if (num == 2)
Type1 = 1147;
if (num == 3)
Type1 = 1148;
if (num == 4)
Type1 = 1149;
}
else if (tile.type == (ushort) 141)
Type1 = 580;
else if (tile.type == (ushort) 145)
Type1 = 586;
else if (tile.type == (ushort) 146)
Type1 = 591;
else if (tile.type == (ushort) 147)
Type1 = 593;
else if (tile.type == (ushort) 148)
Type1 = 594;
else if (tile.type == (ushort) 153)
Type1 = 611;
else if (tile.type == (ushort) 154)
Type1 = 612;
else if (tile.type == (ushort) 155)
Type1 = 613;
else if (tile.type == (ushort) 156)
Type1 = 614;
else if (tile.type == (ushort) 160)
Type1 = 662;
else if (tile.type == (ushort) 175)
Type1 = 717;
else if (tile.type == (ushort) 176)
Type1 = 718;
else if (tile.type == (ushort) 177)
Type1 = 719;
else if (tile.type == (ushort) 163)
Type1 = 833;
else if (tile.type == (ushort) 164)
Type1 = 834;
else if (tile.type == (ushort) 200)
Type1 = 835;
else if (tile.type == (ushort) 210)
Type1 = 937;
else if (tile.type == (ushort) 135)
{
int num = (int) tile.frameY / 18;
if (num == 0)
Type1 = 529;
if (num == 1)
Type1 = 541;
if (num == 2)
Type1 = 542;
if (num == 3)
Type1 = 543;
if (num == 4)
Type1 = 852;
if (num == 5)
Type1 = 853;
if (num == 6)
Type1 = 1151;
}
else if (tile.type == (ushort) 144)
{
if (tile.frameX == (short) 0)
Type1 = 583;
if (tile.frameX == (short) 18)
Type1 = 584;
if (tile.frameX == (short) 36)
Type1 = 585;
}
else if (tile.type == (ushort) 130)
Type1 = 511;
else if (tile.type == (ushort) 131)
Type1 = 512;
else if (tile.type == (ushort) 61 || tile.type == (ushort) 74)
{
if (tile.frameX == (short) 144 && tile.type == (ushort) 61)
Item.NewItem(i * 16, j * 16, 16, 16, 331, WorldGen.genRand.Next(2, 4));
else if (tile.frameX == (short) 162 && tile.type == (ushort) 61)
Type1 = 223;
else if (tile.frameX >= (short) 108 && tile.frameX <= (short) 126 && tile.type == (ushort) 61 && WorldGen.genRand.Next(20) == 0)
Type1 = 208;
else if (WorldGen.genRand.Next(100) == 0)
Type1 = 195;
}
else if (tile.type == (ushort) 59 || tile.type == (ushort) 60)
Type1 = 176;
else if (tile.type == (ushort) 190)
Type1 = 183;
else if (tile.type == (ushort) 71 || tile.type == (ushort) 72)
{
if (WorldGen.genRand.Next(50) == 0)
Type1 = 194;
else if (WorldGen.genRand.Next(2) == 0)
Type1 = 183;
}
else if (tile.type >= (ushort) 63 && tile.type <= (ushort) 68)
Type1 = (int) tile.type - 63 + 177;
else if (tile.type == (ushort) 50)
Type1 = tile.frameX != (short) 90 ? 149 : 165;
else if (Main.tileAlch[(int) tile.type])
{
if (tile.type > (ushort) 82)
{
int num = (int) tile.frameX / 18;
bool flag2 = false;
Type1 = 313 + num;
int Type4 = 307 + num;
if (tile.type == (ushort) 84)
flag2 = true;
if (num == 0 && Main.dayTime)
flag2 = true;
if (num == 1 && !Main.dayTime)
flag2 = true;
if (num == 3 && !Main.dayTime && (Main.bloodMoon || Main.moonPhase == 0))
flag2 = true;
if (num == 4 && (Main.raining || (double) Main.cloudAlpha > 0.0))
flag2 = true;
if (num == 5 && !Main.raining && Main.dayTime && Main.time > 40500.0)
flag2 = true;
if (num == 6)
{
Type1 = 2358;
Type4 = 2357;
}
int closest = (int) Player.FindClosest(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16);
if (Main.player[closest].inventory[Main.player[closest].selectedItem].type == 213)
{
Item.NewItem(i * 16, j * 16, 16, 16, Type4, WorldGen.genRand.Next(1, 6));
Item.NewItem(i * 16, j * 16, 16, 16, Type1, WorldGen.genRand.Next(1, 3));
Type1 = -1;
}
else if (flag2)
{
int Stack = WorldGen.genRand.Next(1, 4);
Item.NewItem(i * 16, j * 16, 16, 16, Type4, Stack);
}
}
}
else if (tile.type == (ushort) 321)
Type1 = 2503;
else if (tile.type == (ushort) 322)
Type1 = 2504;
if (Type1 > 0)
{
int Stack = 1;
if (flag1)
++Stack;
Item.NewItem(i * 16, j * 16, 16, 16, Type1, Stack, pfix: -1);
}
if (Type2 > 0)
Item.NewItem(i * 16, j * 16, 16, 16, Type2, pfix: -1);
}
if (Main.netMode != 2)
AchievementsHelper.NotifyTileDestroyed(Main.player[Main.myPlayer], tile.type);
tile.active(false);
tile.halfBrick(false);
tile.frameX = (short) -1;
tile.frameY = (short) -1;
tile.color((byte) 0);
tile.frameNumber((byte) 0);
if (tile.type == (ushort) 58 && j > Main.maxTilesY - 200)
{
tile.lava(true);
tile.liquid = (byte) 128;
}
else if (tile.type == (ushort) 419)
Wiring.PokeLogicGate(i, j + 1);
else if (tile.type == (ushort) 54)
WorldGen.SquareWallFrame(i, j);
tile.type = (ushort) 0;
tile.inActive(false);
WorldGen.SquareTileFrame(i, j);
}
}
public static int KillTile_GetTileDustAmount(bool fail, Tile tileCache)
{
int num = 10;
if (tileCache.type == (ushort) 231)
num = 6;
if (fail)
num = 3;
if (tileCache.type == (ushort) 138)
num = 0;
if (tileCache.type == (ushort) 373)
num = 0;
if (tileCache.type == (ushort) 374)
num = 0;
if (tileCache.type == (ushort) 375)
num = 0;
if (tileCache.type == (ushort) 461)
num = 0;
if (tileCache.type >= (ushort) 300 && tileCache.type <= (ushort) 308)
num = 0;
if (tileCache.type == (ushort) 125)
num = 0;
if (tileCache.type == (ushort) 287)
num = 0;
if (tileCache.type == (ushort) 354)
num = 0;
if (tileCache.type == (ushort) 355)
num = 0;
if (tileCache.type == (ushort) 376)
num = 0;
return num;
}
public static int KillTile_MakeTileDust(int i, int j, Tile tileCache)
{
int Type1 = 0;
if (tileCache.type == (ushort) 216)
Type1 = -1;
if (tileCache.type == (ushort) 335)
Type1 = -1;
if (tileCache.type == (ushort) 338)
Type1 = -1;
if (tileCache.type == (ushort) 0)
Type1 = 0;
if (tileCache.type == (ushort) 192)
Type1 = 3;
if (tileCache.type == (ushort) 208)
Type1 = 126;
else if (tileCache.type == (ushort) 408 || tileCache.type == (ushort) 409)
Type1 = 265;
if (tileCache.type == (ushort) 16)
{
Type1 = 1;
if (tileCache.frameX >= (short) 36)
Type1 = 82;
}
else if (tileCache.type == (ushort) 415)
Type1 = 6;
else if (tileCache.type == (ushort) 416)
Type1 = 61;
else if (tileCache.type == (ushort) 417)
Type1 = 242;
else if (tileCache.type == (ushort) 418)
Type1 = 135;
if (tileCache.type == (ushort) 1 || tileCache.type == (ushort) 17 || tileCache.type == (ushort) 38 || tileCache.type == (ushort) 39 || tileCache.type == (ushort) 41 || tileCache.type == (ushort) 43 || tileCache.type == (ushort) 44 || tileCache.type == (ushort) 48 || Main.tileStone[(int) tileCache.type] || tileCache.type == (ushort) 85 || tileCache.type == (ushort) 90 || tileCache.type == (ushort) 92 || tileCache.type == (ushort) 96 || tileCache.type == (ushort) 97 || tileCache.type == (ushort) 99 || tileCache.type == (ushort) 117 || tileCache.type == (ushort) 130 || tileCache.type == (ushort) 131 || tileCache.type == (ushort) 132 || tileCache.type == (ushort) 135 || tileCache.type == (ushort) 135 || tileCache.type == (ushort) 142 || tileCache.type == (ushort) 143 || tileCache.type == (ushort) 144 || tileCache.type == (ushort) 210 || tileCache.type == (ushort) 207 || tileCache.type == (ushort) 235 || tileCache.type == (ushort) 247 || tileCache.type == (ushort) 272 || tileCache.type == (ushort) 273 || tileCache.type == (ushort) 283 || tileCache.type == (ushort) 410)
Type1 = 1;
if (tileCache.type == (ushort) 379)
Type1 = 257;
if (tileCache.type == (ushort) 311)
Type1 = 207;
if (tileCache.type == (ushort) 312)
Type1 = 208;
if (tileCache.type == (ushort) 313)
Type1 = 209;
if (tileCache.type == (ushort) 104)
Type1 = -1;
if (tileCache.type == (ushort) 95 || tileCache.type == (ushort) 98 || tileCache.type == (ushort) 100 || tileCache.type == (ushort) 174 || tileCache.type == (ushort) 173)
Type1 = 6;
if (tileCache.type == (ushort) 30 || tileCache.type == (ushort) 86 || tileCache.type == (ushort) 94 || tileCache.type == (ushort) 106 || tileCache.type == (ushort) 114 || tileCache.type == (ushort) 124 || tileCache.type == (ushort) 128 || tileCache.type == (ushort) 269)
Type1 = 7;
if (tileCache.type == (ushort) 372)
Type1 = 242;
if (tileCache.type == (ushort) 371)
Type1 = 243;
if (tileCache.type == (ushort) 334)
Type1 = 7;
switch (tileCache.type)
{
case 10:
case 11:
case 87:
case 89:
case 93:
case 139:
case 209:
case 319:
case 320:
case 386:
case 387:
case 390:
case 405:
case 406:
case 411:
case 412:
case 419:
case 420:
case 421:
case 422:
case 423:
case 424:
case 425:
case 428:
case 429:
case 441:
case 442:
case 445:
case 446:
case 447:
case 448:
case 449:
case 450:
case 451:
case 452:
case 453:
case 455:
case 456:
case 457:
case 462:
case 463:
case 464:
case 465:
case 466:
case 468:
Type1 = -1;
break;
case 407:
Type1 = 10;
break;
case 454:
Type1 = 139;
break;
}
if (tileCache.type == (ushort) 240)
{
int num = (int) tileCache.frameX / 54;
if (tileCache.frameY >= (short) 54)
num += 36;
Type1 = 7;
if (num == 16 || num == 17)
Type1 = 26;
if (num >= 46 && num <= 49)
Type1 = -1;
}
if (tileCache.type == (ushort) 241)
Type1 = 1;
if (tileCache.type == (ushort) 242)
Type1 = -1;
if (tileCache.type == (ushort) 356)
Type1 = -1;
if (tileCache.type == (ushort) 351)
Type1 = -1;
if (tileCache.type == (ushort) 246)
Type1 = -1;
if (tileCache.type == (ushort) 36)
Type1 = -1;
if (tileCache.type == (ushort) 365)
Type1 = 239;
if (tileCache.type == (ushort) 366)
Type1 = 30;
if (tileCache.type == (ushort) 357 || tileCache.type == (ushort) 367)
Type1 = 236;
if (tileCache.type == (ushort) 368 || tileCache.type == (ushort) 369)
Type1 = 240;
if (tileCache.type == (ushort) 170)
Type1 = 196;
if (tileCache.type == (ushort) 315)
Type1 = 225;
if (tileCache.type == (ushort) 346)
Type1 = 128;
if (tileCache.type == (ushort) 347)
Type1 = 117;
if (tileCache.type == (ushort) 348)
Type1 = 42;
if (tileCache.type == (ushort) 350)
Type1 = 226;
if (tileCache.type == (ushort) 370)
Type1 = WorldGen.genRand.Next(2) != 0 ? 23 : 6;
if (tileCache.type == (ushort) 171)
Type1 = WorldGen.genRand.Next(2) != 0 ? -1 : 196;
if (tileCache.type == (ushort) 326)
Type1 = 13;
if (tileCache.type == (ushort) 327)
Type1 = 13;
if (tileCache.type == (ushort) 345)
Type1 = 13;
if (tileCache.type == (ushort) 458)
Type1 = 13;
if (tileCache.type == (ushort) 459)
Type1 = 13;
if (tileCache.type == (ushort) 336)
Type1 = 6;
if (tileCache.type == (ushort) 340)
Type1 = 75;
if (tileCache.type == (ushort) 341)
Type1 = 65;
if (tileCache.type == (ushort) 342)
Type1 = 135;
if (tileCache.type == (ushort) 343)
Type1 = 169;
if (tileCache.type == (ushort) 344)
Type1 = 156;
if (tileCache.type == (ushort) 328)
Type1 = 13;
if (tileCache.type == (ushort) 329)
Type1 = 13;
if (tileCache.type == (ushort) 330)
Type1 = 9;
if (tileCache.type == (ushort) 331)
Type1 = 11;
if (tileCache.type == (ushort) 332)
Type1 = 19;
if (tileCache.type == (ushort) 333)
Type1 = 11;
if (tileCache.type == (ushort) 101)
Type1 = -1;
if (tileCache.type == (ushort) 19)
{
int num = (int) tileCache.frameY / 18;
Type1 = num == 0 || num == 9 || num == 10 || num == 11 || num == 12 ? 7 : (num != 1 ? (num != 2 ? (num != 3 ? (num != 4 ? (num != 5 ? (num != 13 ? (num != 14 ? (num < 15 || num > 16 ? (num != 17 ? (num != 18 ? (num != 19 ? (num != 20 ? (num != 21 ? (num != 22 ? (num != 23 ? (num != 24 ? (num != 25 ? (num != 26 ? (num != 27 ? (num != 28 ? (num != 29 ? (num != 30 ? (num != 31 ? (num != 32 ? (num != 33 ? (num != 34 ? (num != 35 ? 1 : 80) : 5) : 148) : 78) : 10) : 68 + Main.rand.Next(3)) : 236) : 240) : 23) : 226) : 40) : 147) : 78) : 8) : 1) : 4) : 214) : 214) : 215) : -1) : 13) : 109) : 126) : 26) : 79) : 78) : 77);
}
if (tileCache.type == (ushort) 79)
{
int num = (int) tileCache.frameY / 36;
Type1 = num != 0 ? (num != 1 ? (num != 2 ? (num != 3 ? (num != 4 ? (num != 8 ? (num < 9 ? 1 : -1) : 109) : 126) : 79) : 78) : 77) : 7;
}
if (tileCache.type == (ushort) 18)
{
switch ((int) tileCache.frameX / 36)
{
case 0:
Type1 = 7;
break;
case 1:
Type1 = 77;
break;
case 2:
Type1 = 78;
break;
case 3:
Type1 = 79;
break;
case 4:
Type1 = 26;
break;
case 5:
Type1 = 40;
break;
case 6:
Type1 = 5;
break;
case 7:
Type1 = 26;
break;
case 8:
Type1 = 4;
break;
case 9:
Type1 = 126;
break;
case 10:
Type1 = 148;
break;
case 11:
case 12:
case 13:
Type1 = 1;
break;
case 14:
Type1 = 109;
break;
case 15:
Type1 = 126;
break;
default:
Type1 = -1;
break;
}
}
if (tileCache.type == (ushort) 14 || tileCache.type == (ushort) 87 || tileCache.type == (ushort) 88)
Type1 = -1;
if (tileCache.type >= (ushort) byte.MaxValue && tileCache.type <= (ushort) 261)
{
int num = (int) tileCache.type - (int) byte.MaxValue;
Type1 = 86 + num;
if (num == 6)
Type1 = 138;
}
if (tileCache.type >= (ushort) 262 && tileCache.type <= (ushort) 268)
{
int num = (int) tileCache.type - 262;
Type1 = 86 + num;
if (num == 6)
Type1 = 138;
}
if (tileCache.type == (ushort) 178)
{
int num = (int) tileCache.frameX / 18;
Type1 = 86 + num;
if (num == 6)
Type1 = 138;
}
if (tileCache.type == (ushort) 440)
{
switch ((int) tileCache.frameX / 54)
{
case 0:
Type1 = 90;
break;
case 1:
Type1 = 88;
break;
case 2:
Type1 = 89;
break;
case 3:
Type1 = 87;
break;
case 4:
Type1 = 86;
break;
case 5:
Type1 = 91;
break;
case 6:
Type1 = 138;
break;
default:
Type1 = -1;
break;
}
if (tileCache.frameY < (short) 54)
Type1 = -1;
}
switch (tileCache.type)
{
case 426:
case 427:
Type1 = 90;
break;
case 430:
case 435:
Type1 = 89;
break;
case 431:
case 436:
Type1 = 88;
break;
case 432:
case 437:
Type1 = 87;
break;
case 433:
case 438:
Type1 = 86;
break;
case 434:
case 439:
Type1 = 91;
break;
}
if (tileCache.type == (ushort) 186)
Type1 = tileCache.frameX > (short) 360 ? (tileCache.frameX > (short) 846 ? (tileCache.frameX > (short) 954 ? (tileCache.frameX > (short) 1062 ? (tileCache.frameX > (short) 1170 ? (tileCache.frameX > (short) 1332 ? (tileCache.frameX > (short) 1386 ? 80 : 10) : 0) : 10) : 11) : 9) : 1) : 26;
if (tileCache.type == (ushort) 187)
{
if (tileCache.frameX <= (short) 144)
Type1 = 1;
else if (tileCache.frameX <= (short) 306)
Type1 = 38;
else if (tileCache.frameX <= (short) 468)
Type1 = 36;
else if (tileCache.frameX <= (short) 738)
Type1 = 30;
else if (tileCache.frameX <= (short) 970)
Type1 = 1;
else if (tileCache.frameX <= (short) 1132)
Type1 = 148;
else if (tileCache.frameX <= (short) 1132)
Type1 = 155;
else if (tileCache.frameX <= (short) 1348)
Type1 = 1;
else if (tileCache.frameX <= (short) 1564)
Type1 = 0;
}
if (tileCache.type == (ushort) 105)
{
Type1 = 1;
if (tileCache.frameX >= (short) 1548 && tileCache.frameX <= (short) 1654 && tileCache.frameY < (short) 54)
Type1 = 148;
}
if (tileCache.type == (ushort) 349)
Type1 = 1;
if (tileCache.type == (ushort) 337)
Type1 = 1;
if (tileCache.type == (ushort) 239)
{
int num = (int) tileCache.frameX / 18;
if (num == 0)
Type1 = 9;
if (num == 1)
Type1 = 81;
if (num == 2)
Type1 = 8;
if (num == 3)
Type1 = 82;
if (num == 4)
Type1 = 11;
if (num == 5)
Type1 = 83;
if (num == 6)
Type1 = 10;
if (num == 7)
Type1 = 84;
if (num == 8)
Type1 = 14;
if (num == 9)
Type1 = 23;
if (num == 10)
Type1 = 25;
if (num == 11)
Type1 = 48;
if (num == 12)
Type1 = 144;
if (num == 13)
Type1 = 49;
if (num == 14)
Type1 = 145;
if (num == 15)
Type1 = 50;
if (num == 16)
Type1 = 146;
if (num == 17)
Type1 = 128;
if (num == 18)
Type1 = 84;
if (num == 19)
Type1 = 117;
if (num == 20)
Type1 = 42;
if (num == 21)
Type1 = -1;
if (num == 22)
Type1 = 265;
}
if (tileCache.type == (ushort) 185)
{
if (tileCache.frameY == (short) 18)
{
int num = (int) tileCache.frameX / 36;
if (num < 6)
Type1 = 1;
else if (num < 16)
{
Type1 = 26;
}
else
{
switch (num)
{
case 16:
Type1 = 9;
break;
case 17:
Type1 = 11;
break;
case 18:
Type1 = 10;
break;
case 19:
Type1 = 86;
break;
case 20:
Type1 = 87;
break;
case 21:
Type1 = 88;
break;
case 22:
Type1 = 89;
break;
case 23:
Type1 = 90;
break;
case 24:
Type1 = 91;
break;
default:
if (num < 31)
{
Type1 = 80;
break;
}
if (num < 33)
{
Type1 = 7;
break;
}
if (num < 34)
{
Type1 = 8;
break;
}
if (num < 39)
{
Type1 = 30;
break;
}
if (num < 42)
{
Type1 = 1;
break;
}
break;
}
}
}
else
{
int num = (int) tileCache.frameX / 18;
if (num < 6)
Type1 = 1;
else if (num < 12)
Type1 = 0;
else if (num < 27)
Type1 = 26;
else if (num < 32)
Type1 = 1;
else if (num < 35)
Type1 = 0;
else if (num < 46)
Type1 = 80;
else if (num < 52)
Type1 = 30;
}
}
if (tileCache.type == (ushort) 184)
{
int num = (int) tileCache.frameX / 22;
Type1 = num != 5 ? 93 + num : 258;
}
if (tileCache.type == (ushort) 237)
Type1 = 148;
if (tileCache.type == (ushort) 157)
Type1 = 77;
if (tileCache.type == (ushort) 158 || tileCache.type == (ushort) 232 || tileCache.type == (ushort) 383)
Type1 = 78;
if (tileCache.type == (ushort) 159)
Type1 = 78;
if (tileCache.type == (ushort) 15)
Type1 = -1;
if (tileCache.type == (ushort) 191)
Type1 = 7;
if (tileCache.type == (ushort) 5)
{
Type1 = 7;
if (i > 5 && i < Main.maxTilesX - 5)
{
int index1 = i;
int index2 = j;
if (tileCache.frameX == (short) 66 && tileCache.frameY <= (short) 45)
++index1;
if (tileCache.frameX == (short) 88 && tileCache.frameY >= (short) 66 && tileCache.frameY <= (short) 110)
--index1;
if (tileCache.frameX == (short) 22 && tileCache.frameY >= (short) 132 && tileCache.frameY <= (short) 176)
--index1;
if (tileCache.frameX == (short) 44 && tileCache.frameY >= (short) 132 && tileCache.frameY <= (short) 176)
++index1;
if (tileCache.frameX == (short) 44 && tileCache.frameY >= (short) 132 && tileCache.frameY <= (short) 176)
++index1;
if (tileCache.frameX == (short) 44 && tileCache.frameY >= (short) 198)
++index1;
if (tileCache.frameX == (short) 66 && tileCache.frameY >= (short) 198)
--index1;
while (Main.tile[index1, index2] != null && (!Main.tile[index1, index2].active() || !Main.tileSolid[(int) Main.tile[index1, index2].type]))
++index2;
if (Main.tile[index1, index2] != null)
{
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 23)
Type1 = 77;
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 60)
Type1 = 78;
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 70)
Type1 = 26;
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 109)
Type1 = 79;
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 199)
Type1 = 121;
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 147)
Type1 = 122;
}
}
}
if (tileCache.type == (ushort) 323)
{
Type1 = 215;
if (i > 5 && i < Main.maxTilesX - 5)
{
int index3 = i;
int index4 = j;
while (Main.tile[index3, index4] != null && (!Main.tile[index3, index4].active() || !Main.tileSolid[(int) Main.tile[index3, index4].type]))
++index4;
if (Main.tile[index3, index4] != null)
{
if (Main.tile[index3, index4].active() && Main.tile[index3, index4].type == (ushort) 234)
Type1 = 121;
if (Main.tile[index3, index4].active() && Main.tile[index3, index4].type == (ushort) 116)
Type1 = 79;
if (Main.tile[index3, index4].active() && Main.tile[index3, index4].type == (ushort) 112)
Type1 = 77;
}
}
}
if (tileCache.type == (ushort) 137)
{
Type1 = 1;
if ((int) tileCache.frameY / 18 > 0)
Type1 = 148;
}
if (tileCache.type == (ushort) 443)
Type1 = 1;
if (tileCache.type == (ushort) 444)
Type1 = -1;
if (tileCache.type == (ushort) 212)
Type1 = -1;
if (tileCache.type == (ushort) 213)
Type1 = 129;
if (tileCache.type == (ushort) 214)
Type1 = 1;
if (tileCache.type == (ushort) 215)
Type1 = -6;
if (tileCache.type == (ushort) 325)
Type1 = 81;
if (tileCache.type == (ushort) 251)
Type1 = 189;
if (tileCache.type == (ushort) 252)
Type1 = 190;
if (tileCache.type == (ushort) 253)
Type1 = 191;
if (tileCache.type == (ushort) 254)
{
if (tileCache.frameX < (short) 72)
Type1 = 3;
else if (tileCache.frameX < (short) 108)
{
Type1 = 3;
if (WorldGen.genRand.Next(3) == 0)
Type1 = 189;
}
else if (tileCache.frameX < (short) 144)
{
Type1 = 3;
if (WorldGen.genRand.Next(2) == 0)
Type1 = 189;
}
else
{
Type1 = 3;
if (WorldGen.genRand.Next(4) != 0)
Type1 = 189;
}
}
if (tileCache.type == (ushort) 467)
Type1 = -1;
if (tileCache.type == (ushort) 21)
Type1 = tileCache.frameX < (short) 1008 ? (tileCache.frameX < (short) 612 ? (tileCache.frameX < (short) 576 ? (tileCache.frameX < (short) 540 ? (tileCache.frameX < (short) 504 ? (tileCache.frameX < (short) 468 ? (tileCache.frameX < (short) 432 ? (tileCache.frameX < (short) 396 ? (tileCache.frameX < (short) 360 ? (tileCache.frameX < (short) 324 ? (tileCache.frameX < (short) 288 ? (tileCache.frameX < (short) 252 ? (tileCache.frameX < (short) 216 ? (tileCache.frameX < (short) 180 ? (tileCache.frameX < (short) 108 ? (tileCache.frameX < (short) 36 ? 7 : 10) : 37) : 7) : 1) : 77) : 78) : 79) : 10) : 11) : 7) : 116) : 126) : 26) : 148) : 11) : -1;
if (tileCache.type == (ushort) 2)
Type1 = WorldGen.genRand.Next(2) != 0 ? 2 : 0;
if (Main.tileMoss[(int) tileCache.type])
Type1 = tileCache.type != (ushort) 381 ? (int) tileCache.type - 179 + 93 : 258;
if (tileCache.type == (ushort) sbyte.MaxValue)
Type1 = 67;
if (tileCache.type == (ushort) 91)
Type1 = -1;
if (tileCache.type == (ushort) 198)
Type1 = 109;
if (tileCache.type == (ushort) 26)
Type1 = tileCache.frameX < (short) 54 ? 8 : 5;
if (tileCache.type == (ushort) 34)
Type1 = -1;
if (tileCache.type == (ushort) 6)
Type1 = 8;
if (tileCache.type == (ushort) 7 || tileCache.type == (ushort) 47 || tileCache.type == (ushort) 284)
Type1 = 9;
if (tileCache.type == (ushort) 8 || tileCache.type == (ushort) 45 || tileCache.type == (ushort) 102)
Type1 = 10;
if (tileCache.type == (ushort) 9 || tileCache.type == (ushort) 42 || tileCache.type == (ushort) 46 || tileCache.type == (ushort) 126 || tileCache.type == (ushort) 136)
Type1 = 11;
if (tileCache.type == (ushort) 166 || tileCache.type == (ushort) 175)
Type1 = 81;
if (tileCache.type == (ushort) 167)
Type1 = 82;
if (tileCache.type == (ushort) 168 || tileCache.type == (ushort) 176)
Type1 = 83;
if (tileCache.type == (ushort) 169 || tileCache.type == (ushort) 177)
Type1 = 84;
if (tileCache.type == (ushort) 199)
Type1 = 117;
if (tileCache.type == (ushort) 205)
Type1 = 125;
if (tileCache.type == (ushort) 201)
Type1 = 125;
if (tileCache.type == (ushort) 211)
Type1 = 128;
if (tileCache.type == (ushort) 227)
{
switch ((int) tileCache.frameX / 34)
{
case 0:
case 1:
Type1 = 26;
break;
case 2:
case 4:
case 5:
case 6:
Type1 = 40;
break;
case 3:
Type1 = 3;
break;
case 7:
Type1 = 117;
break;
case 8:
Type1 = 17;
break;
case 9:
Type1 = 6;
break;
case 10:
Type1 = 3;
break;
case 11:
Type1 = 26;
break;
}
}
if (tileCache.type == (ushort) 204)
{
Type1 = 117;
if (WorldGen.genRand.Next(2) == 0)
Type1 = 1;
}
if (tileCache.type == (ushort) 203)
Type1 = 117;
if (tileCache.type == (ushort) 243)
Type1 = WorldGen.genRand.Next(2) != 0 ? 13 : 7;
if (tileCache.type == (ushort) 244)
Type1 = WorldGen.genRand.Next(2) != 0 ? 13 : 1;
else if (tileCache.type >= (ushort) 358 && tileCache.type <= (ushort) 364 || tileCache.type >= (ushort) 275 && tileCache.type <= (ushort) 282 || tileCache.type == (ushort) 285 || tileCache.type == (ushort) 286 || tileCache.type >= (ushort) 288 && tileCache.type <= (ushort) 297 || tileCache.type >= (ushort) 316 && tileCache.type <= (ushort) 318 || tileCache.type == (ushort) 298 || tileCache.type == (ushort) 299 || tileCache.type == (ushort) 309 || tileCache.type == (ushort) 310 || tileCache.type == (ushort) 339 || tileCache.type == (ushort) 413 || tileCache.type == (ushort) 414)
{
Type1 = 13;
if (WorldGen.genRand.Next(3) != 0)
Type1 = -1;
}
if (tileCache.type == (ushort) 13)
Type1 = tileCache.frameX < (short) 90 ? 13 : -1;
if (tileCache.type == (ushort) 189)
Type1 = 16;
if (tileCache.type == (ushort) 460)
Type1 = 16;
if (tileCache.type == (ushort) 12)
Type1 = 12;
if (tileCache.type == (ushort) 3 || tileCache.type == (ushort) 73)
Type1 = 3;
if (tileCache.type == (ushort) 54)
Type1 = 13;
if (tileCache.type == (ushort) 22 || tileCache.type == (ushort) 140)
Type1 = 14;
if (tileCache.type == (ushort) 78)
Type1 = 22;
if (tileCache.type == (ushort) 28)
{
Type1 = 22;
if (tileCache.frameY >= (short) 72 && tileCache.frameY <= (short) 90)
Type1 = 1;
if (tileCache.frameY >= (short) 144 && tileCache.frameY <= (short) 234)
Type1 = 48;
if (tileCache.frameY >= (short) 252 && tileCache.frameY <= (short) 358)
Type1 = 85;
if (tileCache.frameY >= (short) 360 && tileCache.frameY <= (short) 466)
Type1 = 26;
if (tileCache.frameY >= (short) 468 && tileCache.frameY <= (short) 574)
Type1 = 36;
if (tileCache.frameY >= (short) 576 && tileCache.frameY <= (short) 790)
Type1 = 18;
if (tileCache.frameY >= (short) 792 && tileCache.frameY <= (short) 898)
Type1 = 5;
if (tileCache.frameY >= (short) 900 && tileCache.frameY <= (short) 1006)
Type1 = 0;
if (tileCache.frameY >= (short) 1008 && tileCache.frameY <= (short) 1114)
Type1 = 148;
if (tileCache.frameY >= (short) 1116 && tileCache.frameY <= (short) 1222)
Type1 = 241;
}
if (tileCache.type == (ushort) 163)
Type1 = 118;
if (tileCache.type == (ushort) 164)
Type1 = 119;
if (tileCache.type == (ushort) 200)
Type1 = 120;
if (tileCache.type == (ushort) 221 || tileCache.type == (ushort) 248)
Type1 = 144;
if (tileCache.type == (ushort) 222 || tileCache.type == (ushort) 249)
Type1 = 145;
if (tileCache.type == (ushort) 223 || tileCache.type == (ushort) 250)
Type1 = 146;
if (tileCache.type == (ushort) 224)
Type1 = 149;
if (tileCache.type == (ushort) 225)
Type1 = 147;
if (tileCache.type == (ushort) 229)
Type1 = 153;
if (tileCache.type == (ushort) 231)
{
Type1 = 153;
if (WorldGen.genRand.Next(3) == 0)
Type1 = 26;
}
if (tileCache.type == (ushort) 226)
Type1 = 148;
if (tileCache.type == (ushort) 103)
Type1 = -1;
if (tileCache.type == (ushort) 29)
Type1 = 23;
if (tileCache.type == (ushort) 40)
Type1 = 28;
if (tileCache.type == (ushort) 49)
Type1 = 29;
if (tileCache.type == (ushort) 50)
Type1 = 22;
if (tileCache.type == (ushort) 51)
Type1 = 30;
if (tileCache.type == (ushort) 52 || tileCache.type == (ushort) 353)
Type1 = 3;
if (tileCache.type == (ushort) 53 || tileCache.type == (ushort) 81 || tileCache.type == (ushort) 151 || tileCache.type == (ushort) 202 || tileCache.type == (ushort) 274)
Type1 = 32;
if (tileCache.type == (ushort) 56 || tileCache.type == (ushort) 152)
Type1 = 37;
if (tileCache.type == (ushort) 75)
Type1 = 109;
if (tileCache.type == (ushort) 57 || tileCache.type == (ushort) 119 || tileCache.type == (ushort) 141 || tileCache.type == (ushort) 234)
Type1 = 36;
if (tileCache.type == (ushort) 59 || tileCache.type == (ushort) 120)
Type1 = 38;
if (tileCache.type == (ushort) 61 || tileCache.type == (ushort) 62 || tileCache.type == (ushort) 74 || tileCache.type == (ushort) 80 || tileCache.type == (ushort) 188 || tileCache.type == (ushort) 233 || tileCache.type == (ushort) 236 || tileCache.type == (ushort) 384)
Type1 = 40;
if (tileCache.type == (ushort) 238)
Type1 = WorldGen.genRand.Next(3) != 0 ? 166 : 167;
if (tileCache.type == (ushort) 69)
Type1 = 7;
if (tileCache.type == (ushort) 71 || tileCache.type == (ushort) 72 || tileCache.type == (ushort) 190)
Type1 = 26;
if (tileCache.type == (ushort) 70)
Type1 = 17;
if (tileCache.type == (ushort) 112)
Type1 = 14;
if (tileCache.type == (ushort) 123)
Type1 = 53;
if (tileCache.type == (ushort) 161)
Type1 = 80;
if (tileCache.type == (ushort) 206)
Type1 = 80;
if (tileCache.type == (ushort) 162)
Type1 = 80;
if (tileCache.type == (ushort) 165)
{
switch ((int) tileCache.frameX / 54)
{
case 0:
Type1 = 80;
break;
case 1:
Type1 = 1;
break;
case 2:
Type1 = 30;
break;
case 3:
Type1 = 147;
break;
case 4:
Type1 = 1;
break;
case 5:
Type1 = 14;
break;
case 6:
Type1 = 117;
break;
case 7:
Type1 = 250;
break;
case 8:
Type1 = 240;
break;
case 9:
Type1 = 236;
break;
default:
Type1 = 1;
break;
}
}
if (tileCache.type == (ushort) 193)
Type1 = 4;
if (tileCache.type == (ushort) 194)
Type1 = 26;
if (tileCache.type == (ushort) 195)
Type1 = 5;
if (tileCache.type == (ushort) 196)
Type1 = 108;
if (tileCache.type == (ushort) 197)
Type1 = 4;
if (tileCache.type == (ushort) 153)
Type1 = 26;
if (tileCache.type == (ushort) 154)
Type1 = 32;
if (tileCache.type == (ushort) 155)
Type1 = 2;
if (tileCache.type == (ushort) 156)
Type1 = 1;
if (tileCache.type == (ushort) 116 || tileCache.type == (ushort) 118 || tileCache.type == (ushort) 147 || tileCache.type == (ushort) 148)
Type1 = 51;
if (tileCache.type == (ushort) 109)
Type1 = WorldGen.genRand.Next(2) != 0 ? 47 : 0;
if (tileCache.type == (ushort) 110 || tileCache.type == (ushort) 113 || tileCache.type == (ushort) 115)
Type1 = 47;
if (tileCache.type == (ushort) 107 || tileCache.type == (ushort) 121)
Type1 = 48;
if (tileCache.type == (ushort) 108 || tileCache.type == (ushort) 122 || tileCache.type == (ushort) 146)
Type1 = 49;
if (tileCache.type == (ushort) 111 || tileCache.type == (ushort) 145 || tileCache.type == (ushort) 150)
Type1 = 50;
if (tileCache.type == (ushort) 133)
{
Type1 = 50;
if (tileCache.frameX >= (short) 54)
Type1 = 146;
}
if (tileCache.type == (ushort) 134)
{
Type1 = 49;
if (tileCache.frameX >= (short) 36)
Type1 = 145;
}
if (tileCache.type == (ushort) 149)
Type1 = 49;
if (Main.tileAlch[(int) tileCache.type])
{
int num = (int) tileCache.frameX / 18;
if (num == 0)
Type1 = 3;
if (num == 1)
Type1 = 3;
if (num == 2)
Type1 = 7;
if (num == 3)
Type1 = 17;
if (num == 4)
Type1 = 3;
if (num == 5)
Type1 = 6;
if (num == 6)
Type1 = 224;
}
if (tileCache.type == (ushort) 58 || tileCache.type == (ushort) 76 || tileCache.type == (ushort) 77)
Type1 = WorldGen.genRand.Next(2) != 0 ? 25 : 6;
if (tileCache.type == (ushort) 37)
Type1 = WorldGen.genRand.Next(2) != 0 ? 23 : 6;
if (tileCache.type == (ushort) 32)
Type1 = WorldGen.genRand.Next(2) != 0 ? 24 : 14;
if (tileCache.type == (ushort) 352)
Type1 = WorldGen.genRand.Next(3) != 0 ? 125 : 5;
if (tileCache.type == (ushort) 23 || tileCache.type == (ushort) 24)
Type1 = WorldGen.genRand.Next(2) != 0 ? 17 : 14;
if (tileCache.type == (ushort) 25 || tileCache.type == (ushort) 31)
Type1 = tileCache.type != (ushort) 31 || tileCache.frameX < (short) 36 ? (WorldGen.genRand.Next(2) != 0 ? 1 : 14) : 5;
if (tileCache.type == (ushort) 20)
{
switch ((int) tileCache.frameX / 54)
{
case 1:
Type1 = 122;
break;
case 2:
Type1 = 78;
break;
case 3:
Type1 = 77;
break;
case 4:
Type1 = 121;
break;
case 5:
Type1 = 79;
break;
default:
Type1 = 7;
break;
}
}
if (tileCache.type == (ushort) 27)
Type1 = WorldGen.genRand.Next(2) != 0 ? 19 : 3;
if (tileCache.type == (ushort) 129)
Type1 = tileCache.frameX == (short) 0 || tileCache.frameX == (short) 54 || tileCache.frameX == (short) 108 ? 68 : (tileCache.frameX == (short) 18 || tileCache.frameX == (short) 72 || tileCache.frameX == (short) 126 ? 69 : 70);
if (tileCache.type == (ushort) 385)
Type1 = WorldGen.genRand.Next(68, 71);
if (tileCache.type == (ushort) 4)
{
int num = (int) tileCache.frameY / 22;
switch (num)
{
case 0:
Type1 = 6;
break;
case 8:
Type1 = 75;
break;
case 9:
Type1 = 135;
break;
case 10:
Type1 = 158;
break;
case 11:
Type1 = 169;
break;
case 12:
Type1 = 156;
break;
case 13:
Type1 = 234;
break;
case 14:
Type1 = 66;
break;
case 15:
Type1 = 242;
break;
default:
Type1 = 58 + num;
break;
}
}
if (tileCache.type == (ushort) 35)
{
Type1 = 189;
if (tileCache.frameX < (short) 36 && WorldGen.genRand.Next(2) == 0)
Type1 = 6;
}
if ((tileCache.type == (ushort) 34 || tileCache.type == (ushort) 42) && WorldGen.genRand.Next(2) == 0)
Type1 = 6;
if (tileCache.type == (ushort) 270)
Type1 = -1;
if (tileCache.type == (ushort) 271)
Type1 = -1;
if (tileCache.type == (ushort) 79 || tileCache.type == (ushort) 90 || tileCache.type == (ushort) 101)
Type1 = -1;
if (tileCache.type == (ushort) 33 || tileCache.type == (ushort) 34 || tileCache.type == (ushort) 42 || tileCache.type == (ushort) 93 || tileCache.type == (ushort) 100)
Type1 = -1;
if (tileCache.type == (ushort) 321)
Type1 = 214;
if (tileCache.type == (ushort) 322)
Type1 = 215;
bool flag = tileCache.type == (ushort) 178 || tileCache.type == (ushort) 440;
switch (tileCache.type)
{
case 178:
case 426:
case 427:
case 430:
case 431:
case 432:
case 433:
case 434:
case 435:
case 436:
case 437:
case 438:
case 439:
case 440:
flag = true;
break;
}
if (Type1 < 0)
return 6000;
if (tileCache.type == (ushort) 352 && Type1 == 5)
{
int index = Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 5, Alpha: 100);
Main.dust[index].scale = 1.5f;
Main.dust[index].noGravity = true;
Main.dust[index].velocity *= 1.65f;
Main.dust[index].fadeIn = 1.6f;
return index;
}
if (tileCache.type == (ushort) 160)
{
int index = Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 66, Alpha: 100, newColor: new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), Scale: 0.75f);
Main.dust[index].noGravity = true;
return index;
}
if (tileCache.type == (ushort) 323)
{
int frameY = (int) tileCache.frameY;
return Dust.NewDust(new Vector2((float) (i * 16 + frameY), (float) (j * 16)), 16, 16, Type1);
}
if (tileCache.type == (ushort) 314)
{
int index = Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, 213, (float) WorldGen.genRand.Next(-2, 3), (float) WorldGen.genRand.Next(-2, 3));
Main.dust[index].noGravity = true;
Main.dust[index].fadeIn = (float) ((double) Main.dust[index].scale + 1.0 + 0.00999999977648258 * (double) WorldGen.genRand.Next(0, 51));
Main.dust[index].noGravity = true;
return index;
}
if (flag)
{
int index = Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type1, Alpha: 75, Scale: 0.75f);
Main.dust[index].noLight = true;
return index;
}
if (tileCache.type == (ushort) 193 || tileCache.type == (ushort) 18 && Type1 == 4)
return Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type1, Alpha: 75, newColor: new Color(0, 80, (int) byte.MaxValue, 100), Scale: 0.75f);
if (tileCache.type == (ushort) 197)
return Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type1, Alpha: 75, newColor: new Color(97, 200, (int) byte.MaxValue, 100), Scale: 0.75f);
if (tileCache.type == (ushort) 185 && Type1 >= 86 && Type1 <= 91)
{
int index = Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type1, Alpha: 75, Scale: 0.75f);
Main.dust[index].noLight = true;
return index;
}
if (tileCache.type == (ushort) 4 && Type1 == 66)
{
int index = Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type1, newColor: new Color((float) Main.DiscoR / (float) byte.MaxValue, (float) Main.DiscoG / (float) byte.MaxValue, (float) Main.DiscoB / (float) byte.MaxValue));
Main.dust[index].noGravity = true;
return index;
}
if (Type1 != 139)
return Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type1);
int Type2 = Type1 + Main.rand.Next(4);
return Dust.NewDust(new Vector2((float) (i * 16), (float) (j * 16)), 16, 16, Type2);
}
public static bool IsOpenDoorAnchorFrame(int x, int y)
{
Tile tile = Main.tile[x, y];
if (!tile.active() || tile.type != (ushort) 11)
return false;
int num = (int) tile.frameX % 72;
return num >= 18 && num < 54;
}
public static bool IsLockedDoor(int x, int y)
{
Tile tile = Main.tile[x, y];
return tile.type == (ushort) 10 && tile.frameY >= (short) 594 && tile.frameY <= (short) 646 && tile.frameX < (short) 54;
}
public static void DropDoorItem(int x, int y, int doorStyle)
{
int Type = 0;
switch (doorStyle)
{
case 0:
Type = 25;
break;
case 9:
Type = 837;
break;
case 10:
Type = 912;
break;
case 12:
Type = 1137;
break;
case 13:
Type = 1138;
break;
case 14:
Type = 1139;
break;
case 15:
Type = 1140;
break;
case 16:
Type = 1411;
break;
case 17:
Type = 1412;
break;
case 18:
Type = 1413;
break;
case 19:
Type = 1458;
break;
default:
if (doorStyle >= 20 && doorStyle <= 23)
{
Type = 1709 + doorStyle - 20;
break;
}
switch (doorStyle)
{
case 24:
Type = 1793;
break;
case 25:
Type = 1815;
break;
case 26:
Type = 1924;
break;
case 27:
Type = 2044;
break;
case 28:
Type = 2265;
break;
case 29:
Type = 2528;
break;
case 30:
Type = 2561;
break;
case 31:
Type = 2576;
break;
case 32:
Type = 2815;
break;
case 33:
Type = 3129;
break;
case 34:
Type = 3131;
break;
case 35:
Type = 3130;
break;
case 36:
Type = 3888;
break;
default:
if (doorStyle >= 4 && doorStyle <= 8)
{
Type = 812 + doorStyle;
break;
}
if (doorStyle != 11)
{
Type = 649 + doorStyle;
break;
}
break;
}
break;
}
if (Type == 0)
return;
Item.NewItem(x * 16, y * 16, 16, 16, Type);
}
public static bool PlayerLOS(int x, int y)
{
Microsoft.Xna.Framework.Rectangle rectangle1 = new Microsoft.Xna.Framework.Rectangle(x * 16, y * 16, 16, 16);
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active)
{
Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle((int) ((double) Main.player[index].position.X + (double) Main.player[index].width * 0.5 - (double) NPC.sWidth * 0.6), (int) ((double) Main.player[index].position.Y + (double) Main.player[index].height * 0.5 - (double) NPC.sHeight * 0.6), (int) ((double) NPC.sWidth * 1.2), (int) ((double) NPC.sHeight * 1.2));
if (rectangle1.Intersects(rectangle2))
return true;
}
}
return false;
}
public static bool Chlorophyte(int i, int j)
{
int num1 = 40;
int num2 = 130;
int num3 = 35;
int num4 = 85;
if ((double) j < Main.rockLayer)
{
num1 /= 2;
num2 /= 2;
num3 = (int) ((double) num3 * 1.5);
num4 = (int) ((double) num4 * 1.5);
}
int num5 = 0;
for (int index1 = i - num3; index1 < i + num3; ++index1)
{
for (int index2 = j - num3; index2 < j + num3; ++index2)
{
if (index1 < Main.maxTilesX - 10 && index1 > 10 && Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 211)
++num5;
}
}
if (num5 > num1)
return false;
int num6 = 0;
for (int index3 = i - num4; index3 < i + num4; ++index3)
{
for (int index4 = j - num4; index4 < j + num4; ++index4)
{
if (index3 < Main.maxTilesX - 10 && index3 > 10 && Main.tile[index3, index4].active() && Main.tile[index3, index4].type == (ushort) 211)
++num6;
}
}
return num6 <= num2;
}
private static bool nearbyChlorophyte(int i, int j)
{
float num1 = 0.0f;
int num2 = 10;
if (i <= num2 + 5 || i >= Main.maxTilesX - num2 - 5 || j <= num2 + 5 || j >= Main.maxTilesY - num2 - 5)
return false;
for (int index1 = i - num2; index1 < i + num2; ++index1)
{
for (int index2 = j - num2; index2 < j + num2; ++index2)
{
if (Main.tile[index1, index2].active() && (Main.tile[index1, index2].type == (ushort) 211 || Main.tile[index1, index2].type == (ushort) 346))
{
++num1;
if ((double) num1 == 5.0)
return true;
}
}
}
return (double) num1 > 0.0 && (double) WorldGen.genRand.Next(5) < (double) num1;
}
private static int CountNearBlocksTypes(
int i,
int j,
int radius,
int cap = 0,
params int[] tiletypes)
{
if (tiletypes.Length == 0)
return 0;
int num1 = i - radius;
int num2 = i + radius;
int num3 = j - radius;
int num4 = j + radius;
int max = Main.maxTilesX - 1;
int num5 = Utils.Clamp<int>(num1, 0, max);
int num6 = Utils.Clamp<int>(num2, 0, Main.maxTilesX - 1);
int num7 = Utils.Clamp<int>(num3, 0, Main.maxTilesY - 1);
int num8 = Utils.Clamp<int>(num4, 0, Main.maxTilesY - 1);
int num9 = 0;
for (int index1 = num5; index1 < num6; ++index1)
{
for (int index2 = num7; index2 < num8; ++index2)
{
if (Main.tile[index1, index2].active())
{
foreach (int tiletype in tiletypes)
{
if (tiletype == (int) Main.tile[index1, index2].type)
{
++num9;
if (cap > 0 && num9 >= cap)
return num9;
break;
}
}
}
}
}
return num9;
}
public static void hardUpdateWorld(int i, int j)
{
if (!Main.hardMode || Main.tile[i, j].inActive())
return;
int type = (int) Main.tile[i, j].type;
switch (type)
{
case 117:
case 164:
if ((double) j > Main.rockLayer && WorldGen.genRand.Next(110) == 0)
{
int num1 = WorldGen.genRand.Next(4);
int num2 = 0;
int num3 = 0;
switch (num1)
{
case 0:
num2 = -1;
break;
case 1:
num2 = 1;
break;
default:
num3 = num1 != 0 ? 1 : -1;
break;
}
if (!Main.tile[i + num2, j + num3].active())
{
int num4 = 0;
int num5 = 6;
for (int index1 = i - num5; index1 <= i + num5; ++index1)
{
for (int index2 = j - num5; index2 <= j + num5; ++index2)
{
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 129)
++num4;
}
}
if (num4 < 2)
{
WorldGen.PlaceTile(i + num2, j + num3, 129, true);
NetMessage.SendTileSquare(-1, i + num2, j + num3, 1);
break;
}
break;
}
break;
}
break;
}
if ((double) j > (Main.worldSurface + Main.rockLayer) / 2.0)
{
if (type == 60 && WorldGen.genRand.Next(300) == 0)
{
int index3 = i + WorldGen.genRand.Next(-10, 11);
int index4 = j + WorldGen.genRand.Next(-10, 11);
if (WorldGen.InWorld(index3, index4, 2) && Main.tile[index3, index4].active() && Main.tile[index3, index4].type == (ushort) 59 && (!Main.tile[index3, index4 - 1].active() || Main.tile[index3, index4 - 1].type != (ushort) 5 && Main.tile[index3, index4 - 1].type != (ushort) 236 && Main.tile[index3, index4 - 1].type != (ushort) 238) && WorldGen.Chlorophyte(index3, index4))
{
Main.tile[index3, index4].type = (ushort) 211;
WorldGen.SquareTileFrame(index3, index4);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index3, index4, 1);
}
}
if (type == 211 && WorldGen.genRand.Next(3) != 0)
{
int index5 = i;
int index6 = j;
int num = WorldGen.genRand.Next(4);
if (num == 0)
++index5;
if (num == 1)
--index5;
if (num == 2)
++index6;
if (num == 3)
--index6;
if (WorldGen.InWorld(index5, index6, 2) && Main.tile[index5, index6].active() && (Main.tile[index5, index6].type == (ushort) 59 || Main.tile[index5, index6].type == (ushort) 60) && WorldGen.Chlorophyte(index5, index6))
{
Main.tile[index5, index6].type = (ushort) 211;
WorldGen.SquareTileFrame(index5, index6);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index5, index6, 1);
}
bool flag = true;
while (flag)
{
flag = false;
int index7 = i + Main.rand.Next(-5, 6);
int index8 = j + Main.rand.Next(-5, 6);
if (WorldGen.InWorld(index7, index8, 2) && Main.tile[index7, index8].active())
{
if (Main.tile[index7, index8].type == (ushort) 23 || Main.tile[index7, index8].type == (ushort) 199 || Main.tile[index7, index8].type == (ushort) 2 || Main.tile[index7, index8].type == (ushort) 109)
{
Main.tile[index7, index8].type = (ushort) 60;
WorldGen.SquareTileFrame(index7, index8);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index7, index8, 1);
flag = true;
}
else if (Main.tile[index7, index8].type == (ushort) 0)
{
Main.tile[index7, index8].type = (ushort) 59;
WorldGen.SquareTileFrame(index7, index8);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index7, index8, 1);
flag = true;
}
}
}
}
}
if (NPC.downedPlantBoss && WorldGen.genRand.Next(2) != 0)
return;
if (type == 23 || type == 25 || type == 32 || type == 112 || type == 163 || type == 400 || type == 398)
{
bool flag1 = true;
while (flag1)
{
flag1 = false;
int index9 = i + WorldGen.genRand.Next(-3, 4);
int index10 = j + WorldGen.genRand.Next(-3, 4);
bool flag2 = false;
switch (Main.tile[index9, index10].type)
{
case 59:
case 60:
flag2 = WorldGen.nearbyChlorophyte(index9, index10);
break;
default:
bool flag3 = false;
int index11 = index9;
int index12 = index10;
for (int index13 = 0; index13 < 4; ++index13)
{
switch (index13)
{
case 0:
index11 = index9 - 1;
index12 = index10;
break;
case 1:
index11 = index9 + 1;
index12 = index10;
break;
case 2:
index11 = index9;
index12 = index10 - 1;
break;
case 3:
index11 = index9;
index12 = index10 + 1;
break;
}
if (Main.tile[index11, index12].active() && (Main.tile[index11, index12].type == (ushort) 59 || Main.tile[index11, index12].type == (ushort) 60))
{
flag3 = true;
break;
}
}
if (flag3)
{
flag2 = WorldGen.nearbyChlorophyte(index9, index10);
break;
}
break;
}
if (!(Main.tile[index9, index10 - 1].type == (ushort) 27 | flag2))
{
if (Main.tile[index9, index10].type == (ushort) 2)
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 23;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
else if (Main.tile[index9, index10].type == (ushort) 1 || Main.tileMoss[(int) Main.tile[index9, index10].type])
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 25;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
else if (Main.tile[index9, index10].type == (ushort) 53)
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 112;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
else if (Main.tile[index9, index10].type == (ushort) 396)
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 400;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
else if (Main.tile[index9, index10].type == (ushort) 397)
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 398;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
else if (Main.tile[index9, index10].type == (ushort) 59)
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 0;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
else if (Main.tile[index9, index10].type == (ushort) 60)
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 23;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
else if (Main.tile[index9, index10].type == (ushort) 69)
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 32;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
else if (Main.tile[index9, index10].type == (ushort) 161)
{
if (WorldGen.genRand.Next(2) == 0)
flag1 = true;
Main.tile[index9, index10].type = (ushort) 163;
WorldGen.SquareTileFrame(index9, index10);
NetMessage.SendTileSquare(-1, index9, index10, 1);
}
}
}
}
if (type == 199 || type == 200 || type == 201 || type == 203 || type == 205 || type == 234 || type == 352 || type == 401 || type == 399)
{
bool flag4 = true;
while (flag4)
{
flag4 = false;
int index14 = i + WorldGen.genRand.Next(-3, 4);
int index15 = j + WorldGen.genRand.Next(-3, 4);
bool flag5 = WorldGen.nearbyChlorophyte(index14, index15);
if (!(Main.tile[index14, index15 - 1].type == (ushort) 27 | flag5))
{
if (Main.tile[index14, index15].type == (ushort) 2)
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 199;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
else if (Main.tile[index14, index15].type == (ushort) 1 || Main.tileMoss[(int) Main.tile[index14, index15].type])
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 203;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
else if (Main.tile[index14, index15].type == (ushort) 53)
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 234;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
else if (Main.tile[index14, index15].type == (ushort) 396)
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 401;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
else if (Main.tile[index14, index15].type == (ushort) 397)
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 399;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
else if (Main.tile[index14, index15].type == (ushort) 59)
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 0;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
else if (Main.tile[index14, index15].type == (ushort) 60)
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 199;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
else if (Main.tile[index14, index15].type == (ushort) 69)
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 352;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
else if (Main.tile[index14, index15].type == (ushort) 161)
{
if (WorldGen.genRand.Next(2) == 0)
flag4 = true;
Main.tile[index14, index15].type = (ushort) 200;
WorldGen.SquareTileFrame(index14, index15);
NetMessage.SendTileSquare(-1, index14, index15, 1);
}
}
}
}
if (type != 109 && type != 110 && type != 113 && type != 115 && type != 116 && type != 117 && type != 164 && type != 402 && type != 403)
return;
bool flag6 = true;
while (flag6)
{
flag6 = false;
int index16 = i + WorldGen.genRand.Next(-3, 4);
int index17 = j + WorldGen.genRand.Next(-3, 4);
if (Main.tile[index16, index17].type == (ushort) 2)
{
if (WorldGen.genRand.Next(2) == 0)
flag6 = true;
Main.tile[index16, index17].type = (ushort) 109;
WorldGen.SquareTileFrame(index16, index17);
NetMessage.SendTileSquare(-1, index16, index17, 1);
}
else if (Main.tile[index16, index17].type == (ushort) 1 || Main.tileMoss[(int) Main.tile[index16, index17].type])
{
if (WorldGen.genRand.Next(2) == 0)
flag6 = true;
Main.tile[index16, index17].type = (ushort) 117;
WorldGen.SquareTileFrame(index16, index17);
NetMessage.SendTileSquare(-1, index16, index17, 1);
}
else if (Main.tile[index16, index17].type == (ushort) 53)
{
if (WorldGen.genRand.Next(2) == 0)
flag6 = true;
Main.tile[index16, index17].type = (ushort) 116;
WorldGen.SquareTileFrame(index16, index17);
NetMessage.SendTileSquare(-1, index16, index17, 1);
}
else if (Main.tile[index16, index17].type == (ushort) 396)
{
if (WorldGen.genRand.Next(2) == 0)
flag6 = true;
Main.tile[index16, index17].type = (ushort) 403;
WorldGen.SquareTileFrame(index16, index17);
NetMessage.SendTileSquare(-1, index16, index17, 1);
}
else if (Main.tile[index16, index17].type == (ushort) 397)
{
if (WorldGen.genRand.Next(2) == 0)
flag6 = true;
Main.tile[index16, index17].type = (ushort) 402;
WorldGen.SquareTileFrame(index16, index17);
NetMessage.SendTileSquare(-1, index16, index17, 1);
}
else if (Main.tile[index16, index17].type == (ushort) 161)
{
if (WorldGen.genRand.Next(2) == 0)
flag6 = true;
Main.tile[index16, index17].type = (ushort) 164;
WorldGen.SquareTileFrame(index16, index17);
NetMessage.SendTileSquare(-1, index16, index17, 1);
}
}
}
public static bool SolidTile(Tile testTile)
{
try
{
if (testTile == null)
return true;
if (testTile.active())
{
if (Main.tileSolid[(int) testTile.type])
{
if (!Main.tileSolidTop[(int) testTile.type])
{
if (!testTile.halfBrick())
{
if (testTile.slope() == (byte) 0)
{
if (!testTile.inActive())
return true;
}
}
}
}
}
}
catch
{
}
return false;
}
public static bool TileEmpty(int i, int j) => Main.tile[i, j] == null || !Main.tile[i, j].active() || Main.tile[i, j].inActive();
public static bool SolidOrSlopedTile(Tile tile) => tile != null && tile.active() && Main.tileSolid[(int) tile.type] && !Main.tileSolidTop[(int) tile.type] && !tile.inActive();
public static bool SolidOrSlopedTile(int x, int y) => WorldGen.SolidOrSlopedTile(Main.tile[x, y]);
public static bool SolidTile(int i, int j)
{
try
{
if (Main.tile[i, j] == null)
return true;
if (Main.tile[i, j].active())
{
if (Main.tileSolid[(int) Main.tile[i, j].type])
{
if (!Main.tileSolidTop[(int) Main.tile[i, j].type])
{
if (!Main.tile[i, j].halfBrick())
{
if (Main.tile[i, j].slope() == (byte) 0)
{
if (!Main.tile[i, j].inActive())
return true;
}
}
}
}
}
}
catch
{
}
return false;
}
public static bool SolidTile2(Tile testTile)
{
try
{
if (testTile == null)
return true;
if (testTile.active())
{
if (Main.tileSolid[(int) testTile.type])
{
if (testTile.slope() == (byte) 0)
{
if (!testTile.halfBrick())
{
if (!testTile.inActive())
return true;
}
}
}
}
}
catch
{
}
return false;
}
public static bool PlatformProperTopFrame(short frameX)
{
int num = (int) frameX / TileObjectData.PlatformFrameWidth();
if (num >= 0 && num <= 7 || num >= 12 && num <= 16)
return true;
return num >= 25 && num <= 26;
}
public static bool SolidTileAllowBottomSlope(int i, int j)
{
try
{
Tile tile = Main.tile[i, j];
if (tile == null)
return true;
if (tile.active())
{
if (!Main.tileSolid[(int) tile.type])
{
if (!Main.tileSolidTop[(int) tile.type])
goto label_12;
}
if (tile.topSlope())
{
if (TileID.Sets.Platforms[(int) tile.type])
{
if (!WorldGen.PlatformProperTopFrame(tile.frameX))
goto label_12;
}
else
goto label_12;
}
if (!tile.halfBrick())
{
if (!tile.inActive())
return true;
}
}
}
catch
{
}
label_12:
return false;
}
public static bool SolidTile3(int i, int j) => WorldGen.InWorld(i, j, 1) && WorldGen.SolidTile3(Main.tile[i, j]);
public static bool SolidTile3(Tile t) => t != null && t.active() && !t.inActive() && Main.tileSolid[(int) t.type] && !Main.tileSolidTop[(int) t.type];
public static bool SolidTile2(int i, int j)
{
try
{
if (Main.tile[i, j] == null)
return true;
if (Main.tile[i, j].active())
{
if (Main.tileSolid[(int) Main.tile[i, j].type])
{
if (Main.tile[i, j].slope() == (byte) 0)
{
if (!Main.tile[i, j].halfBrick())
{
if (!Main.tile[i, j].inActive())
return true;
}
}
}
}
}
catch
{
}
return false;
}
public static bool SolidTileNoAttach(int i, int j)
{
try
{
if (Main.tile[i, j] == null)
return true;
if (Main.tile[i, j].active())
{
if (Main.tileSolid[(int) Main.tile[i, j].type])
{
if (!Main.tileNoAttach[(int) Main.tile[i, j].type])
{
if (Main.tile[i, j].slope() == (byte) 0)
{
if (!Main.tile[i, j].halfBrick())
{
if (!Main.tile[i, j].inActive())
return true;
}
}
}
}
}
}
catch
{
}
return false;
}
public static Vector2 Hive(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(12, 21);
double num2 = num1;
float num3 = (float) WorldGen.genRand.Next(10, 21);
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.2f;
vector2_2.Y = (float) WorldGen.genRand.Next(-10, 11) * 0.2f;
while (num1 > 0.0 && (double) num3 > 0.0)
{
num1 = num2 * (1.0 + (double) WorldGen.genRand.Next(-20, 20) * 0.00999999977648258);
float num4 = num3 - 1f;
int num5 = (int) ((double) vector2_1.X - num1);
int num6 = (int) ((double) vector2_1.X + num1);
int num7 = (int) ((double) vector2_1.Y - num1);
int num8 = (int) ((double) vector2_1.Y + num1);
if (num5 < 1)
num5 = 1;
if (num6 > Main.maxTilesX - 1)
num6 = Main.maxTilesX - 1;
if (num7 < 1)
num7 = 1;
if (num8 > Main.maxTilesY - 1)
num8 = Main.maxTilesY - 1;
for (int i1 = num5; i1 < num6; ++i1)
{
for (int j1 = num7; j1 < num8; ++j1)
{
double num9 = (double) Math.Abs((float) i1 - vector2_1.X);
float num10 = Math.Abs((float) j1 - vector2_1.Y);
double num11 = Math.Sqrt(num9 * num9 + (double) num10 * (double) num10);
if (num11 < num2 * 0.4 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.005))
{
if (WorldGen.genRand.Next(3) == 0)
Main.tile[i1, j1].liquid = byte.MaxValue;
Main.tile[i1, j1].honey(true);
Main.tile[i1, j1].wall = (byte) 86;
Main.tile[i1, j1].active(false);
Main.tile[i1, j1].halfBrick(false);
Main.tile[i1, j1].slope((byte) 0);
WorldGen.SquareWallFrame(i1, j1);
}
else if (num11 < num2 * 0.75 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.005))
{
Main.tile[i1, j1].liquid = (byte) 0;
if (Main.tile[i1, j1].wall != (byte) 86)
{
Main.tile[i1, j1].active(true);
Main.tile[i1, j1].halfBrick(false);
Main.tile[i1, j1].slope((byte) 0);
Main.tile[i1, j1].type = (ushort) 225;
}
}
if (num11 < num2 * 0.6 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.005))
Main.tile[i1, j1].wall = (byte) 86;
WorldGen.SquareWallFrame(i1, j1);
WorldGen.SquareTileFrame(i1, j1);
}
}
vector2_1 += vector2_2;
num3 = num4 - 1f;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
}
return new Vector2(vector2_1.X, vector2_1.Y);
}
public static void MineHouse(int i, int j)
{
if (i < 50 || i > Main.maxTilesX - 50 || j < 50 || j > Main.maxTilesY - 50)
return;
int num1 = WorldGen.genRand.Next(6, 12);
int num2 = WorldGen.genRand.Next(3, 6);
int num3 = WorldGen.genRand.Next(15, 30);
int num4 = WorldGen.genRand.Next(15, 30);
if (WorldGen.SolidTile(i, j) || Main.tile[i, j].wall > (byte) 0)
return;
int num5 = j - num1;
int num6 = j + num2;
for (int index1 = 0; index1 < 2; ++index1)
{
bool flag1 = true;
int i1 = i;
int j1 = j;
int num7 = -1;
int num8 = num3;
if (index1 == 1)
{
num7 = 1;
num8 = num4;
++i1;
}
while (flag1)
{
if (j1 - num1 < num5)
num5 = j1 - num1;
if (j1 + num2 > num6)
num6 = j1 + num2;
for (int index2 = 0; index2 < 2; ++index2)
{
int j2 = j1;
bool flag2 = true;
int num9 = num1;
int num10 = -1;
if (index2 == 1)
{
++j2;
num9 = num2;
num10 = 1;
}
while (flag2)
{
if (i1 != i && Main.tile[i1 - num7, j2].wall != (byte) 27 && (WorldGen.SolidTile(i1 - num7, j2) || !Main.tile[i1 - num7, j2].active() || Main.tile[i1 - num7, j2].halfBrick() || Main.tile[i1 - num7, j2].slope() != (byte) 0))
{
Main.tile[i1 - num7, j2].active(true);
Main.tile[i1 - num7, j2].type = (ushort) 30;
}
if (WorldGen.SolidTile(i1 - 1, j2) || Main.tile[i1 - 1, j2].halfBrick() || Main.tile[i1 - 1, j2].slope() != (byte) 0)
Main.tile[i1 - 1, j2].type = (ushort) 30;
if (WorldGen.SolidTile(i1 + 1, j2) || Main.tile[i1 + 1, j2].halfBrick() || Main.tile[i1 + 1, j2].slope() != (byte) 0)
Main.tile[i1 + 1, j2].type = (ushort) 30;
if (WorldGen.SolidTile(i1, j2) || Main.tile[i1, j2].halfBrick() || Main.tile[i1, j2].slope() != (byte) 0)
{
int num11 = 0;
if (WorldGen.SolidTile(i1 - 1, j2))
++num11;
if (WorldGen.SolidTile(i1 + 1, j2))
++num11;
if (WorldGen.SolidTile(i1, j2 - 1))
++num11;
if (WorldGen.SolidTile(i1, j2 + 1))
++num11;
if (num11 < 2)
{
Main.tile[i1, j2].active(false);
}
else
{
flag2 = false;
Main.tile[i1, j2].type = (ushort) 30;
}
}
else
{
Main.tile[i1, j2].wall = (byte) 27;
Main.tile[i1, j2].liquid = (byte) 0;
Main.tile[i1, j2].lava(false);
}
j2 += num10;
--num9;
if (num9 <= 0)
{
if (!Main.tile[i1, j2].active())
{
Main.tile[i1, j2].active(true);
Main.tile[i1, j2].type = (ushort) 30;
}
flag2 = false;
}
}
}
--num8;
i1 += num7;
if (WorldGen.SolidTile(i1, j1))
{
int num12 = 0;
int num13 = 0;
int j3 = j1;
bool flag3 = true;
while (flag3)
{
--j3;
++num12;
if (WorldGen.SolidTile(i1 - num7, j3))
{
num12 = 999;
flag3 = false;
}
else if (!WorldGen.SolidTile(i1, j3))
flag3 = false;
}
int j4 = j1;
bool flag4 = true;
while (flag4)
{
++j4;
++num13;
if (WorldGen.SolidTile(i1 - num7, j4))
{
num13 = 999;
flag4 = false;
}
else if (!WorldGen.SolidTile(i1, j4))
flag4 = false;
}
if (num13 <= num12)
{
if (num13 > num2)
num8 = 0;
else
j1 += num13 + 1;
}
else if (num12 > num1)
num8 = 0;
else
j1 -= num12 + 1;
}
if (num8 <= 0)
flag1 = false;
}
}
int minValue1 = i - num3 - 1;
int maxValue1 = i + num4 + 2;
int minValue2 = num5 - 1;
int maxValue2 = num6 + 2;
for (int i2 = minValue1; i2 < maxValue1; ++i2)
{
for (int j5 = minValue2; j5 < maxValue2; ++j5)
{
if (Main.tile[i2, j5].wall == (byte) 27 && !Main.tile[i2, j5].active())
{
if (Main.tile[i2 - 1, j5].wall != (byte) 27 && i2 < i && !WorldGen.SolidTile(i2 - 1, j5))
{
WorldGen.PlaceTile(i2, j5, 30, true);
Main.tile[i2, j5].wall = (byte) 0;
}
if (Main.tile[i2 + 1, j5].wall != (byte) 27 && i2 > i && !WorldGen.SolidTile(i2 + 1, j5))
{
WorldGen.PlaceTile(i2, j5, 30, true);
Main.tile[i2, j5].wall = (byte) 0;
}
for (int i3 = i2 - 1; i3 <= i2 + 1; ++i3)
{
for (int j6 = j5 - 1; j6 <= j5 + 1; ++j6)
{
if (WorldGen.SolidTile(i3, j6))
Main.tile[i3, j6].type = (ushort) 30;
}
}
}
if (Main.tile[i2, j5].type == (ushort) 30 && Main.tile[i2 - 1, j5].wall == (byte) 27 && Main.tile[i2 + 1, j5].wall == (byte) 27 && (Main.tile[i2, j5 - 1].wall == (byte) 27 || Main.tile[i2, j5 - 1].active()) && (Main.tile[i2, j5 + 1].wall == (byte) 27 || Main.tile[i2, j5 + 1].active()))
{
Main.tile[i2, j5].active(false);
Main.tile[i2, j5].wall = (byte) 27;
}
}
}
for (int index3 = minValue1; index3 < maxValue1; ++index3)
{
for (int index4 = minValue2; index4 < maxValue2; ++index4)
{
if (Main.tile[index3, index4].type == (ushort) 30)
{
if (Main.tile[index3 - 1, index4].wall == (byte) 27 && Main.tile[index3 + 1, index4].wall == (byte) 27 && !Main.tile[index3 - 1, index4].active() && !Main.tile[index3 + 1, index4].active())
{
Main.tile[index3, index4].active(false);
Main.tile[index3, index4].wall = (byte) 27;
}
if (!TileID.Sets.BasicChest[(int) Main.tile[index3, index4 - 1].type] && Main.tile[index3 - 1, index4].wall == (byte) 27 && Main.tile[index3 + 1, index4].type == (ushort) 30 && Main.tile[index3 + 2, index4].wall == (byte) 27 && !Main.tile[index3 - 1, index4].active() && !Main.tile[index3 + 2, index4].active())
{
Main.tile[index3, index4].active(false);
Main.tile[index3, index4].wall = (byte) 27;
Main.tile[index3 + 1, index4].active(false);
Main.tile[index3 + 1, index4].wall = (byte) 27;
}
if (Main.tile[index3, index4 - 1].wall == (byte) 27 && Main.tile[index3, index4 + 1].wall == (byte) 27 && !Main.tile[index3, index4 - 1].active() && !Main.tile[index3, index4 + 1].active())
{
Main.tile[index3, index4].active(false);
Main.tile[index3, index4].wall = (byte) 27;
}
}
}
}
for (int i4 = minValue1; i4 < maxValue1; ++i4)
{
for (int j7 = maxValue2; j7 > minValue2; --j7)
{
bool flag5 = false;
if (Main.tile[i4, j7].active() && Main.tile[i4, j7].type == (ushort) 30)
{
int num14 = -1;
for (int index5 = 0; index5 < 2; ++index5)
{
if (!WorldGen.SolidTile(i4 + num14, j7) && Main.tile[i4 + num14, j7].wall == (byte) 0)
{
int num15 = 0;
int j8 = j7;
int num16 = j7;
while (Main.tile[i4, j8].active() && Main.tile[i4, j8].type == (ushort) 30 && !WorldGen.SolidTile(i4 + num14, j8) && Main.tile[i4 + num14, j8].wall == (byte) 0)
{
--j8;
++num15;
}
int num17 = j8 + 1 + 1;
if (num15 > 4)
{
if (WorldGen.genRand.Next(2) == 0)
{
int j9 = num16 - 1;
bool flag6 = true;
for (int index6 = i4 - 2; index6 <= i4 + 2; ++index6)
{
for (int index7 = j9 - 2; index7 <= j9; ++index7)
{
if (index6 != i4 && Main.tile[index6, index7].active())
flag6 = false;
}
}
if (flag6)
{
Main.tile[i4, j9].active(false);
Main.tile[i4, j9 - 1].active(false);
Main.tile[i4, j9 - 2].active(false);
WorldGen.PlaceTile(i4, j9, 10, true);
flag5 = true;
}
}
if (!flag5)
{
for (int index8 = num17; index8 < num16; ++index8)
Main.tile[i4, index8].type = (ushort) 124;
}
}
}
num14 = 1;
}
}
if (flag5)
break;
}
}
int num18 = WorldGen.genRand.Next(1, 2);
if (WorldGen.genRand.Next(4) == 0)
num18 = 0;
if (WorldGen.genRand.Next(6) == 0)
++num18;
if (WorldGen.genRand.Next(10) == 0)
++num18;
for (int index9 = 0; index9 < num18; ++index9)
{
int num19 = 0;
int index10 = WorldGen.genRand.Next(minValue1, maxValue1);
int index11;
for (index11 = WorldGen.genRand.Next(minValue2, maxValue2); !Main.wallHouse[(int) Main.tile[index10, index11].wall] || Main.tile[index10, index11].active(); index11 = WorldGen.genRand.Next(minValue2, maxValue2))
{
++num19;
if (num19 <= 1000)
index10 = WorldGen.genRand.Next(minValue1, maxValue1);
else
break;
}
if (num19 <= 1000)
{
for (int index12 = 0; index12 < 2; ++index12)
{
int index13 = index10;
int index14 = index10;
while (!Main.tile[index13, index11].active() && Main.wallHouse[(int) Main.tile[index13, index11].wall])
--index13;
int num20 = index13 + 1;
while (!Main.tile[index14, index11].active() && Main.wallHouse[(int) Main.tile[index14, index11].wall])
++index14;
int num21 = index14 - 1;
i = (num20 + num21) / 2;
int index15 = index11;
int index16 = index11;
while (!Main.tile[index10, index15].active() && Main.wallHouse[(int) Main.tile[index10, index15].wall])
--index15;
int num22 = index15 + 1;
while (!Main.tile[index10, index16].active() && Main.wallHouse[(int) Main.tile[index10, index16].wall])
++index16;
int num23 = index16 - 1;
index11 = (num22 + num23) / 2;
}
int index17 = index10;
int index18 = index10;
while (!Main.tile[index17, index11].active() && !Main.tile[index17, index11 - 1].active() && !Main.tile[index17, index11 + 1].active())
--index17;
int num24 = index17 + 1;
while (!Main.tile[index18, index11].active() && !Main.tile[index18, index11 - 1].active() && !Main.tile[index18, index11 + 1].active())
++index18;
int num25 = index18 - 1;
int index19 = index11;
int index20 = index11;
while (!Main.tile[index10, index19].active() && !Main.tile[index10 - 1, index19].active() && !Main.tile[index10 + 1, index19].active())
--index19;
int num26 = index19 + 1;
while (!Main.tile[index10, index20].active() && !Main.tile[index10 - 1, index20].active() && !Main.tile[index10 + 1, index20].active())
++index20;
int num27 = index20 - 1;
int num28 = (num24 + num25) / 2;
int num29 = (num26 + num27) / 2;
int num30 = num25 - num24;
int num31 = num27 - num26;
if (num30 > 7 && num31 > 5)
{
int num32 = 0;
if (WorldGen.nearPicture2(i, num29))
num32 = -1;
if (num32 == 0)
{
Vector2 vector2 = WorldGen.randHousePicture();
int x = (int) vector2.X;
int y = (int) vector2.Y;
if (!WorldGen.nearPicture(num28, num29))
WorldGen.PlaceTile(num28, num29, x, true, style: y);
}
}
}
else
break;
}
for (int i5 = minValue1; i5 < maxValue1; i5 = i5 + WorldGen.genRand.Next(4) + 1)
{
bool flag = true;
for (int j10 = minValue2; j10 < maxValue2; ++j10)
{
for (int i6 = i5 - 3; i6 <= i5 + 3; ++i6)
{
if (Main.tile[i6, j10].active() && (!WorldGen.SolidTile(i6, j10) || Main.tile[i6, j10].type == (ushort) 10))
flag = false;
}
}
if (flag)
{
for (int j11 = minValue2; j11 < maxValue2; ++j11)
{
if (Main.tile[i5, j11].wall == (byte) 27 && !Main.tile[i5, j11].active())
WorldGen.PlaceTile(i5, j11, 124, true);
}
}
}
for (int index21 = 0; index21 < 4; ++index21)
{
int i7 = WorldGen.genRand.Next(minValue1 + 2, maxValue1 - 1);
int index22;
for (index22 = WorldGen.genRand.Next(minValue2 + 2, maxValue2 - 1); Main.tile[i7, index22].wall != (byte) 27; index22 = WorldGen.genRand.Next(minValue2 + 2, maxValue2 - 1))
i7 = WorldGen.genRand.Next(minValue1 + 2, maxValue1 - 1);
while (Main.tile[i7, index22].active())
--index22;
while (!Main.tile[i7, index22].active())
++index22;
int j12 = index22 - 1;
if (Main.tile[i7, j12].wall == (byte) 27)
{
if (WorldGen.genRand.Next(3) == 0)
{
int type = WorldGen.genRand.Next(9);
if (type == 0)
type = 14;
if (type == 1)
type = 16;
if (type == 2)
type = 18;
if (type == 3)
type = 86;
if (type == 4)
type = 87;
if (type == 5)
type = 94;
if (type == 6)
type = 101;
if (type == 7)
type = 104;
if (type == 8)
type = 106;
WorldGen.PlaceTile(i7, j12, type, true);
}
else
{
int index23 = WorldGen.genRand.Next(2, WorldGen.statueList.Length);
WorldGen.PlaceTile(i7, j12, (int) WorldGen.statueList[index23].X, true, true, style: ((int) WorldGen.statueList[index23].Y));
}
}
}
for (int index24 = 0; index24 < 40; ++index24)
{
int i8 = WorldGen.genRand.Next(minValue1 + 2, maxValue1 - 1);
int index25;
for (index25 = WorldGen.genRand.Next(minValue2 + 2, maxValue2 - 1); Main.tile[i8, index25].wall != (byte) 27; index25 = WorldGen.genRand.Next(minValue2 + 2, maxValue2 - 1))
i8 = WorldGen.genRand.Next(minValue1 + 2, maxValue1 - 1);
while (Main.tile[i8, index25].active())
--index25;
while (!Main.tile[i8, index25].active())
++index25;
int j13 = index25 - 1;
if (Main.tile[i8, j13].wall == (byte) 27 && WorldGen.genRand.Next(2) == 0)
{
int style = WorldGen.genRand.Next(22, 26);
WorldGen.PlaceTile(i8, j13, 186, true, style: style);
}
}
for (int index26 = 0; index26 < 20; ++index26)
{
int i9 = WorldGen.genRand.Next(minValue1 + 2, maxValue1 - 1);
int index27;
for (index27 = WorldGen.genRand.Next(minValue2 + 2, maxValue2 - 1); Main.tile[i9, index27].wall != (byte) 27; index27 = WorldGen.genRand.Next(minValue2 + 2, maxValue2 - 1))
i9 = WorldGen.genRand.Next(minValue1 + 2, maxValue1 - 1);
while (Main.tile[i9, index27].active())
--index27;
while (!Main.tile[i9, index27].active())
++index27;
int j14 = index27 - 1;
if (Main.tile[i9, j14].wall == (byte) 27 && WorldGen.genRand.Next(2) == 0)
{
int X = WorldGen.genRand.Next(31, 34);
WorldGen.PlaceSmallPile(i9, j14, X, 1);
}
}
for (int index28 = 0; index28 < 15; ++index28)
{
int i10 = WorldGen.genRand.Next(minValue1 + 2, maxValue1 - 1);
int j15;
for (j15 = WorldGen.genRand.Next(minValue2 + 2, maxValue2 - 1); Main.tile[i10, j15].wall != (byte) 27; j15 = WorldGen.genRand.Next(minValue2 + 2, maxValue2 - 1))
i10 = WorldGen.genRand.Next(minValue1 + 2, maxValue1 - 1);
while (Main.tile[i10, j15].active())
--j15;
while (j15 > 0 && !Main.tile[i10, j15 - 1].active())
--j15;
if (Main.tile[i10, j15].wall == (byte) 27)
{
int style = 0;
int type;
if (WorldGen.genRand.Next(10) < 9)
{
type = -1;
}
else
{
type = 34;
style = WorldGen.genRand.Next(6);
}
if (type > 0)
{
WorldGen.PlaceTile(i10, j15, type, true, style: style);
if ((int) Main.tile[i10, j15].type == type)
{
if (type == 4)
{
Main.tile[i10, j15].frameX += (short) 54;
}
else
{
int index29 = i10;
int index30 = j15;
int index31 = index30 - (int) Main.tile[index29, index30].frameY % 54 / 18;
int num33 = (int) Main.tile[index29, index30].frameX / 18;
if (num33 > 2)
num33 -= 3;
int index32 = index29 - num33;
short num34 = 54;
if (Main.tile[index32, index31].frameX > (short) 0)
num34 = (short) -54;
for (int index33 = index32; index33 < index32 + 3; ++index33)
{
for (int index34 = index31; index34 < index31 + 3; ++index34)
Main.tile[index33, index34].frameX += num34;
}
}
}
}
}
}
}
public static void CountTiles(int X)
{
if (X == 0)
{
WorldGen.totalEvil = WorldGen.totalEvil2;
WorldGen.totalBlood = WorldGen.totalBlood2;
WorldGen.totalSolid = WorldGen.totalSolid2;
WorldGen.totalGood = WorldGen.totalGood2;
WorldGen.tGood = (byte) Math.Round((double) WorldGen.totalGood / (double) WorldGen.totalSolid * 100.0);
WorldGen.tEvil = (byte) Math.Round((double) WorldGen.totalEvil / (double) WorldGen.totalSolid * 100.0);
WorldGen.tBlood = (byte) Math.Round((double) WorldGen.totalBlood / (double) WorldGen.totalSolid * 100.0);
if (WorldGen.tGood == (byte) 0 && WorldGen.totalGood > 0)
WorldGen.tGood = (byte) 1;
if (WorldGen.tEvil == (byte) 0 && WorldGen.totalEvil > 0)
WorldGen.tEvil = (byte) 1;
if (WorldGen.tBlood == (byte) 0 && WorldGen.totalBlood > 0)
WorldGen.tBlood = (byte) 1;
if (Main.netMode == 2)
NetMessage.SendData(57);
WorldGen.totalEvil2 = 0;
WorldGen.totalSolid2 = 0;
WorldGen.totalGood2 = 0;
WorldGen.totalBlood2 = 0;
}
ushort num1 = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
do
{
int num5;
int num6;
if (num3 == 0)
{
num5 = 0;
num4 = (int) (Main.worldSurface + 1.0);
num6 = 5;
}
else
{
num5 = num4;
num4 = Main.maxTilesY;
num6 = 1;
}
for (int index = num5; index < num4; ++index)
{
Tile tile = Main.tile[X, index] ?? (Main.tile[X, index] = new Tile());
ushort type = tile.type;
if (type != (ushort) 0 || tile.active())
{
if ((int) type == (int) num1)
{
num2 += num6;
}
else
{
WorldGen.tileCounts[(int) num1] += num2;
num1 = type;
num2 = num6;
}
}
}
WorldGen.tileCounts[(int) num1] += num2;
num2 = 0;
++num3;
}
while (num3 < 2);
WorldGen.AddUpAlignmentCounts();
}
public static void AddUpAlignmentCounts(bool clearCounts = false)
{
if (clearCounts)
{
WorldGen.totalEvil2 = 0;
WorldGen.totalSolid2 = 0;
WorldGen.totalGood2 = 0;
WorldGen.totalBlood2 = 0;
}
WorldGen.totalGood2 += WorldGen.tileCounts[164] + WorldGen.tileCounts[109] + WorldGen.tileCounts[117] + WorldGen.tileCounts[116];
WorldGen.totalEvil2 += WorldGen.tileCounts[23] + WorldGen.tileCounts[163] + WorldGen.tileCounts[112] + WorldGen.tileCounts[25];
WorldGen.totalBlood2 += WorldGen.tileCounts[199] + WorldGen.tileCounts[234] + WorldGen.tileCounts[203] + WorldGen.tileCounts[200];
WorldGen.totalSolid2 += WorldGen.tileCounts[2] + WorldGen.tileCounts[1] + WorldGen.tileCounts[60] + WorldGen.tileCounts[53] + WorldGen.tileCounts[161];
WorldGen.totalSolid2 += WorldGen.tileCounts[164] + WorldGen.tileCounts[109] + WorldGen.tileCounts[117] + WorldGen.tileCounts[116];
WorldGen.totalSolid2 += WorldGen.tileCounts[23] + WorldGen.tileCounts[163] + WorldGen.tileCounts[112] + WorldGen.tileCounts[25];
WorldGen.totalSolid2 += WorldGen.tileCounts[199] + WorldGen.tileCounts[234] + WorldGen.tileCounts[203] + WorldGen.tileCounts[200];
Array.Clear((Array) WorldGen.tileCounts, 0, WorldGen.tileCounts.Length);
}
public static void plantDye(int i, int j, bool exoticPlant = false)
{
UnifiedRandom unifiedRandom = WorldGen.gen ? WorldGen.genRand : Main.rand;
if (!Main.tile[i, j].active() || i < 95 || i > Main.maxTilesX - 95 || j < 95 || j > Main.maxTilesY - 95)
return;
int num1 = 90;
if (exoticPlant)
num1 = 240;
if ((double) j < Main.worldSurface)
{
if (Main.tile[i, j - 1].active() && Main.tile[i, j - 1].type != (ushort) 3 && Main.tile[i, j - 1].type != (ushort) 51 && Main.tile[i, j - 1].type != (ushort) 61 && Main.tile[i, j - 1].type != (ushort) 73 && Main.tile[i, j - 1].type != (ushort) 74 && Main.tile[i, j - 1].type != (ushort) 184)
return;
int num2 = Utils.Clamp<int>(i - num1, 1, Main.maxTilesX - 1 - 1);
int num3 = Utils.Clamp<int>(i + num1, 1, Main.maxTilesX - 1 - 1);
int num4 = Utils.Clamp<int>(j - num1, 1, Main.maxTilesY - 1 - 1);
int num5 = Utils.Clamp<int>(j + num1, 1, Main.maxTilesY - 1 - 1);
for (int index1 = num2; index1 < num3; ++index1)
{
for (int index2 = num4; index2 < num5; ++index2)
{
if (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 227 && (!exoticPlant || Main.tile[index1, index2].frameX >= (short) 272) && (exoticPlant || Main.tile[index1, index2].frameX < (short) 272))
return;
}
}
if (exoticPlant)
{
int type = (int) Main.tile[i, j].type;
bool flag = TileID.Sets.Conversion.Grass[type] || TileID.Sets.Conversion.Moss[type] || type == 0;
if (Main.tile[i, j - 1].liquid > (byte) 0 && Main.tile[i, j - 1].lava())
flag = false;
if (!flag)
return;
WorldGen.PlaceTile(i, j - 1, 227, true, style: WorldGen.genRand.Next(8, 12));
}
else if (Main.tile[i, j].type == (ushort) 2 || Main.tile[i, j].type == (ushort) 109)
{
if (unifiedRandom.Next(4) == 0)
WorldGen.PlaceTile(i, j - 1, 227, true, style: 4);
else
WorldGen.PlaceTile(i, j - 1, 227, true, style: 3);
}
else if (Main.tile[i, j].type == (ushort) 60)
{
if (unifiedRandom.Next(2) == 0)
WorldGen.PlaceTile(i, j - 1, 227, true, style: 2);
else
WorldGen.PlaceTile(i, j - 1, 227, true, style: 4);
}
else if (Main.tile[i, j].type == (ushort) 53 && Main.tile[i, j - 1].liquid == byte.MaxValue && Main.tile[i, j - 2].liquid == byte.MaxValue)
{
WorldGen.PlaceTile(i, j - 1, 227, true, style: 2);
}
else
{
if (Main.tile[i, j].type != (ushort) 80 || Main.tile[i - 1, j - 1].active())
return;
if (Main.tile[i + 1, j - 1].active())
return;
try
{
bool flag = true;
for (int index3 = i - 5; index3 <= i + 5; ++index3)
{
for (int index4 = j - 5; index4 <= j + 15; ++index4)
{
if (Main.tile[index3, index4].active() && (Main.tile[index3, index4].type == (ushort) 112 || Main.tile[index3, index4].type == (ushort) 234))
flag = false;
}
}
if (!flag)
return;
WorldGen.PlaceTile(i, j - 1, 227, true, style: 6);
}
catch
{
}
}
}
else
{
if (j >= Main.maxTilesY - 200)
return;
if (!Main.tile[i, j - 1].active() || Main.tile[i, j - 1].type == (ushort) 3 || Main.tile[i, j - 1].type == (ushort) 51 || Main.tile[i, j - 1].type == (ushort) 61 || Main.tile[i, j - 1].type == (ushort) 73 || Main.tile[i, j - 1].type == (ushort) 74 || Main.tile[i, j - 1].type == (ushort) 184)
{
int num6 = Utils.Clamp<int>(i - num1, 1, Main.maxTilesX - 1 - 1);
int num7 = Utils.Clamp<int>(i + num1, 1, Main.maxTilesX - 1 - 1);
int num8 = Utils.Clamp<int>(j - num1, 1, Main.maxTilesY - 1 - 1);
int num9 = Utils.Clamp<int>(j + num1, 1, Main.maxTilesY - 1 - 1);
for (int index5 = num6; index5 < num7; ++index5)
{
for (int index6 = num8; index6 < num9; ++index6)
{
if (Main.tile[index5, index6].active() && Main.tile[index5, index6].type == (ushort) 227 && (!exoticPlant || Main.tile[index5, index6].frameX >= (short) 272) && (exoticPlant || Main.tile[index5, index6].frameX < (short) 272))
return;
}
}
if (exoticPlant)
{
int type = (int) Main.tile[i, j].type;
if ((TileID.Sets.Conversion.Grass[type] || TileID.Sets.Conversion.Moss[type] ? 1 : (type == 0 ? 1 : 0)) != 0)
WorldGen.PlaceTile(i, j - 1, 227, true, style: WorldGen.genRand.Next(8, 12));
}
else if (Main.tile[i, j].type == (ushort) 60)
{
if (unifiedRandom.Next(2) == 0)
WorldGen.PlaceTile(i, j - 1, 227, true, style: 2);
else if (unifiedRandom.Next(2) == 0)
WorldGen.PlaceTile(i, j - 1, 227, true);
else
WorldGen.PlaceTile(i, j - 1, 227, true, style: 1);
}
else if (Main.tile[i, j].type == (ushort) 0 || Main.tile[i, j].type == (ushort) 1 || Main.tile[i, j].type == (ushort) 59)
{
if (unifiedRandom.Next(2) == 0)
WorldGen.PlaceTile(i, j - 1, 227, true);
else
WorldGen.PlaceTile(i, j - 1, 227, true, style: 1);
}
else if (Main.tile[i, j - 1].liquid == byte.MaxValue && Main.tile[i, j - 2].liquid == byte.MaxValue)
WorldGen.PlaceTile(i, j - 1, 227, true, style: 5);
}
if (Main.tile[i, j + 1].active() || exoticPlant)
return;
for (int index7 = i - num1; index7 < i + num1; ++index7)
{
for (int index8 = j - num1; index8 < j + num1; ++index8)
{
if (Main.tile[index7, index8].active() && Main.tile[index7, index8].type == (ushort) 227)
return;
}
}
if (Main.tile[i, j].type != (ushort) 0)
return;
WorldGen.PlaceTile(i, j + 1, 227, true, style: 7);
}
}
public static void UpdateWorld()
{
int wallDist = 20;
int maxValue1 = 40;
if (Main.expertMode)
maxValue1 = 30;
Wiring.UpdateMech();
TileEntity.UpdateStart();
foreach (TileEntity tileEntity in TileEntity.ByID.Values)
tileEntity.Update();
TileEntity.UpdateEnd();
WorldGen.UpdateLunarApocalypse();
if (Main.netMode != 1)
{
++WorldGen.totalD;
if (WorldGen.totalD >= 30)
{
WorldGen.totalD = 0;
WorldGen.CountTiles(WorldGen.totalX);
++WorldGen.totalX;
if (WorldGen.totalX >= Main.maxTilesX)
WorldGen.totalX = 0;
}
}
if (Main.worldRate == 0)
return;
++Liquid.skipCount;
if (Liquid.skipCount > 1)
{
Liquid.UpdateLiquid();
Liquid.skipCount = 0;
}
float num1 = 3E-05f * (float) Main.worldRate;
float num2 = 1.5E-05f * (float) Main.worldRate;
bool flag1 = false;
++WorldGen.spawnDelay;
if (Main.invasionType > 0 || Main.eclipse)
WorldGen.spawnDelay = 0;
if (WorldGen.spawnDelay >= 20)
{
flag1 = true;
WorldGen.spawnDelay = 0;
if (WorldGen.prioritizedTownNPC != 37)
{
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && Main.npc[index].homeless && Main.npc[index].townNPC && Main.npc[index].type != 368)
{
WorldGen.prioritizedTownNPC = Main.npc[index].type;
break;
}
}
}
}
float num3 = (float) (Main.maxTilesX * Main.maxTilesY) * num1;
int num4 = 151;
int maxValue2 = (int) MathHelper.Lerp((float) num4, (float) num4 * 2.8f, MathHelper.Clamp((float) ((double) Main.maxTilesX / 4200.0 - 1.0), 0.0f, 1f));
for (int index1 = 0; (double) index1 < (double) num3; ++index1)
{
if (Main.rand.Next(100) == 0 && Main.rand.Next(maxValue2) == 0)
WorldGen.PlantAlch();
int index2 = WorldGen.genRand.Next(10, Main.maxTilesX - 10);
int index3 = WorldGen.genRand.Next(10, (int) Main.worldSurface - 1);
int num5 = index2 - 1;
int num6 = index2 + 2;
int index4 = index3 - 1;
int num7 = index3 + 2;
if (num5 < 10)
num5 = 10;
if (num6 > Main.maxTilesX - 10)
num6 = Main.maxTilesX - 10;
if (index4 < 10)
index4 = 10;
if (num7 > Main.maxTilesY - 10)
num7 = Main.maxTilesY - 10;
if (Main.tile[index2, index3] != null)
{
if (Main.tileAlch[(int) Main.tile[index2, index3].type])
WorldGen.GrowAlch(index2, index3);
if (Main.tile[index2, index3].liquid > (byte) 32)
{
if (Main.tile[index2, index3].active() && (Main.tile[index2, index3].type == (ushort) 3 || Main.tile[index2, index3].type == (ushort) 20 || Main.tile[index2, index3].type == (ushort) 24 || Main.tile[index2, index3].type == (ushort) 27 || Main.tile[index2, index3].type == (ushort) 73 || Main.tile[index2, index3].type == (ushort) 201))
{
WorldGen.KillTile(index2, index3);
if (Main.netMode == 2)
NetMessage.SendData(17, number2: ((float) index2), number3: ((float) index3));
}
}
else if (Main.tile[index2, index3].nactive())
{
WorldGen.hardUpdateWorld(index2, index3);
if (Main.rand.Next(3000) == 0)
WorldGen.plantDye(index2, index3);
if (Main.rand.Next(9001) == 0)
WorldGen.plantDye(index2, index3, true);
if (Main.tile[index2, index3].type == (ushort) 80)
{
if (WorldGen.genRand.Next(15) == 0)
WorldGen.GrowCactus(index2, index3);
}
else if (TileID.Sets.Conversion.Sand[(int) Main.tile[index2, index3].type])
{
if (!Main.tile[index2, index4].active())
{
if (index2 < 250 || index2 > Main.maxTilesX - 250)
{
if (WorldGen.genRand.Next(500) == 0)
{
int num8 = 7;
int num9 = 6;
int num10 = 0;
for (int index5 = index2 - num8; index5 <= index2 + num8; ++index5)
{
for (int index6 = index4 - num8; index6 <= index4 + num8; ++index6)
{
if (Main.tile[index5, index6].active() && Main.tile[index5, index6].type == (ushort) 81)
++num10;
}
}
if (num10 < num9 && Main.tile[index2, index4].liquid == byte.MaxValue && Main.tile[index2, index4 - 1].liquid == byte.MaxValue && Main.tile[index2, index4 - 2].liquid == byte.MaxValue && Main.tile[index2, index4 - 3].liquid == byte.MaxValue && Main.tile[index2, index4 - 4].liquid == byte.MaxValue)
{
WorldGen.PlaceTile(index2, index4, 81, true);
if (Main.netMode == 2 && Main.tile[index2, index4].active())
NetMessage.SendTileSquare(-1, index2, index4, 1);
}
}
}
else if (index2 > 400 && index2 < Main.maxTilesX - 400 && WorldGen.genRand.Next(300) == 0)
WorldGen.GrowCactus(index2, index3);
}
}
else if (Main.tile[index2, index3].type == (ushort) 116 || Main.tile[index2, index3].type == (ushort) 112 || Main.tile[index2, index3].type == (ushort) 234)
{
if (!Main.tile[index2, index4].active() && index2 > 400 && index2 < Main.maxTilesX - 400 && WorldGen.genRand.Next(300) == 0)
WorldGen.GrowCactus(index2, index3);
}
else if (Main.tile[index2, index3].type == (ushort) 147 || Main.tile[index2, index3].type == (ushort) 161 || Main.tile[index2, index3].type == (ushort) 163 || Main.tile[index2, index3].type == (ushort) 164 || Main.tile[index2, index3].type == (ushort) 200)
{
if (Main.rand.Next(10) == 0 && !Main.tile[index2, index3 + 1].active() && !Main.tile[index2, index3 + 2].active())
{
int num11 = index2 - 3;
int num12 = index2 + 4;
int num13 = 0;
for (int index7 = num11; index7 < num12; ++index7)
{
if (Main.tile[index7, index3].type == (ushort) 165 && Main.tile[index7, index3].active())
++num13;
if (Main.tile[index7, index3 + 1].type == (ushort) 165 && Main.tile[index7, index3 + 1].active())
++num13;
if (Main.tile[index7, index3 + 2].type == (ushort) 165 && Main.tile[index7, index3 + 2].active())
++num13;
if (Main.tile[index7, index3 + 3].type == (ushort) 165 && Main.tile[index7, index3 + 3].active())
++num13;
}
if (num13 < 2)
{
WorldGen.PlaceTight(index2, index3 + 1);
WorldGen.SquareTileFrame(index2, index3 + 1);
if (Main.netMode == 2 && Main.tile[index2, index3 + 1].active())
NetMessage.SendTileSquare(-1, index2, index3 + 1, 3);
}
}
}
else if (Main.tile[index2, index3].type == (ushort) 254)
{
if (Main.rand.Next(((int) Main.tile[index2, index3].frameX + 10) / 10) == 0)
WorldGen.GrowPumpkin(index2, index3, 254);
}
else if (Main.tile[index2, index3].type == (ushort) 78 || Main.tile[index2, index3].type == (ushort) 380)
{
if (!Main.tile[index2, index4].active() && WorldGen.genRand.Next(2) == 0)
{
WorldGen.PlaceTile(index2, index4, 3, true);
if (Main.netMode == 2 && Main.tile[index2, index4].active())
NetMessage.SendTileSquare(-1, index2, index4, 1);
}
}
else if (Main.tile[index2, index3].type == (ushort) 2 || Main.tile[index2, index3].type == (ushort) 23 || Main.tile[index2, index3].type == (ushort) 32 || Main.tile[index2, index3].type == (ushort) 109 || Main.tile[index2, index3].type == (ushort) 199 || Main.tile[index2, index3].type == (ushort) 352)
{
int grass = (int) Main.tile[index2, index3].type;
if (Main.halloween && WorldGen.genRand.Next(75) == 0 && (grass == 2 || grass == 109))
{
int num14 = 100;
int num15 = 0;
for (int index8 = index2 - num14; index8 < index2 + num14; index8 += 2)
{
for (int index9 = index3 - num14; index9 < index3 + num14; index9 += 2)
{
if (index8 > 1 && index8 < Main.maxTilesX - 2 && index9 > 1 && index9 < Main.maxTilesY - 2 && Main.tile[index8, index9].active() && Main.tile[index8, index9].type == (ushort) 254)
++num15;
}
}
if (num15 < 6)
{
WorldGen.PlacePumpkin(index2, index4);
if (Main.netMode == 2 && Main.tile[index2, index4].type == (ushort) 254)
NetMessage.SendTileSquare(-1, index2, index4, 4);
}
}
if (!Main.tile[index2, index4].active() && WorldGen.genRand.Next(12) == 0 && grass == 2 && WorldGen.PlaceTile(index2, index4, 3, true))
{
Main.tile[index2, index4].color(Main.tile[index2, index3].color());
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index2, index4, 1);
}
if (!Main.tile[index2, index4].active() && WorldGen.genRand.Next(10) == 0 && grass == 23 && WorldGen.PlaceTile(index2, index4, 24, true))
{
Main.tile[index2, index4].color(Main.tile[index2, index3].color());
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index2, index4, 1);
}
if (!Main.tile[index2, index4].active() && WorldGen.genRand.Next(10) == 0 && grass == 109 && WorldGen.PlaceTile(index2, index4, 110, true))
{
Main.tile[index2, index4].color(Main.tile[index2, index3].color());
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index2, index4, 1);
}
if (!Main.tile[index2, index4].active() && WorldGen.genRand.Next(10) == 0 && grass == 199 && WorldGen.PlaceTile(index2, index4, 201, true))
{
Main.tile[index2, index4].color(Main.tile[index2, index3].color());
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index2, index4, 1);
}
bool flag2 = false;
for (int i = num5; i < num6; ++i)
{
for (int j = index4; j < num7; ++j)
{
if ((index2 != i || index3 != j) && Main.tile[i, j].active())
{
if (grass == 32)
grass = 23;
if (grass == 352)
grass = 199;
if (Main.tile[i, j].type == (ushort) 0 || grass == 23 && Main.tile[i, j].type == (ushort) 2 || grass == 199 && Main.tile[i, j].type == (ushort) 2 || grass == 23 && Main.tile[i, j].type == (ushort) 109)
{
WorldGen.SpreadGrass(i, j, grass: grass, repeat: false, color: Main.tile[index2, index3].color());
if (grass == 23)
WorldGen.SpreadGrass(i, j, 2, grass, false, Main.tile[index2, index3].color());
if (grass == 23)
WorldGen.SpreadGrass(i, j, 109, grass, false, Main.tile[index2, index3].color());
if (grass == 199)
WorldGen.SpreadGrass(i, j, 2, grass, false, Main.tile[index2, index3].color());
if (grass == 199)
WorldGen.SpreadGrass(i, j, 109, grass, false, Main.tile[index2, index3].color());
if ((int) Main.tile[i, j].type == grass)
{
WorldGen.SquareTileFrame(i, j);
flag2 = true;
}
}
if (Main.tile[i, j].type == (ushort) 0 || grass == 109 && Main.tile[i, j].type == (ushort) 2 || grass == 109 && Main.tile[i, j].type == (ushort) 23 || grass == 109 && Main.tile[i, j].type == (ushort) 199)
{
WorldGen.SpreadGrass(i, j, grass: grass, repeat: false, color: Main.tile[index2, index3].color());
if (grass == 109)
WorldGen.SpreadGrass(i, j, 2, grass, false, Main.tile[index2, index3].color());
if (grass == 109)
WorldGen.SpreadGrass(i, j, 23, grass, false, Main.tile[index2, index3].color());
if (grass == 109)
WorldGen.SpreadGrass(i, j, 199, grass, false, Main.tile[index2, index3].color());
if ((int) Main.tile[i, j].type == grass)
{
WorldGen.SquareTileFrame(i, j);
flag2 = true;
}
}
}
}
}
if (Main.netMode == 2 & flag2)
NetMessage.SendTileSquare(-1, index2, index3, 3);
}
else if (Main.tile[index2, index3].type == (ushort) 20 && WorldGen.genRand.Next(20) == 0)
{
bool flag3 = WorldGen.PlayerLOS(index2, index3);
if ((Main.tile[index2, index3].frameX < (short) 324 || Main.tile[index2, index3].frameX >= (short) 540 ? WorldGen.GrowTree(index2, index3) : WorldGen.GrowPalmTree(index2, index3)) & flag3)
WorldGen.TreeGrowFXCheck(index2, index3);
}
if (Main.tile[index2, index3].type == (ushort) 3 && WorldGen.genRand.Next(20) == 0 && Main.tile[index2, index3].frameX != (short) 144)
{
if (Main.tile[index2, index3].frameX < (short) 144 && Main.rand.Next(10) == 0 || (Main.tile[index2, index3 + 1].type == (ushort) 78 || Main.tile[index2, index3 + 1].type == (ushort) 380) && Main.rand.Next(2) == 0)
Main.tile[index2, index3].frameX = (short) (198 + WorldGen.genRand.Next(10) * 18);
Main.tile[index2, index3].type = (ushort) 73;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index2, index3, 3);
}
if (Main.tile[index2, index3].type == (ushort) 110 && WorldGen.genRand.Next(20) == 0 && Main.tile[index2, index3].frameX < (short) 144)
{
Main.tile[index2, index3].type = (ushort) 113;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index2, index3, 3);
}
if (Main.tile[index2, index3].type == (ushort) 32 && WorldGen.genRand.Next(3) == 0)
{
int index10 = index2;
int index11 = index3;
int num16 = 0;
if (Main.tile[index10 + 1, index11].active() && Main.tile[index10 + 1, index11].type == (ushort) 32)
++num16;
if (Main.tile[index10 - 1, index11].active() && Main.tile[index10 - 1, index11].type == (ushort) 32)
++num16;
if (Main.tile[index10, index11 + 1].active() && Main.tile[index10, index11 + 1].type == (ushort) 32)
++num16;
if (Main.tile[index10, index11 - 1].active() && Main.tile[index10, index11 - 1].type == (ushort) 32)
++num16;
if (num16 < 3 || Main.tile[index2, index3].type == (ushort) 23)
{
switch (WorldGen.genRand.Next(4))
{
case 0:
--index11;
break;
case 1:
++index11;
break;
case 2:
--index10;
break;
case 3:
++index10;
break;
}
if (!Main.tile[index10, index11].active())
{
int num17 = 0;
if (Main.tile[index10 + 1, index11].active() && Main.tile[index10 + 1, index11].type == (ushort) 32)
++num17;
if (Main.tile[index10 - 1, index11].active() && Main.tile[index10 - 1, index11].type == (ushort) 32)
++num17;
if (Main.tile[index10, index11 + 1].active() && Main.tile[index10, index11 + 1].type == (ushort) 32)
++num17;
if (Main.tile[index10, index11 - 1].active() && Main.tile[index10, index11 - 1].type == (ushort) 32)
++num17;
if (num17 < 2)
{
int num18 = 7;
int num19 = index10 - num18;
int num20 = index10 + num18;
int num21 = index11 - num18;
int num22 = index11 + num18;
bool flag4 = false;
for (int index12 = num19; index12 < num20; ++index12)
{
for (int index13 = num21; index13 < num22; ++index13)
{
if (Math.Abs(index12 - index10) * 2 + Math.Abs(index13 - index11) < 9 && Main.tile[index12, index13].active() && Main.tile[index12, index13].type == (ushort) 23 && Main.tile[index12, index13 - 1].active() && Main.tile[index12, index13 - 1].type == (ushort) 32 && Main.tile[index12, index13 - 1].liquid == (byte) 0)
{
flag4 = true;
break;
}
}
}
if (flag4)
{
Main.tile[index10, index11].type = (ushort) 32;
Main.tile[index10, index11].active(true);
WorldGen.SquareTileFrame(index10, index11);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index10, index11, 3);
}
}
}
}
}
if (Main.tile[index2, index3].type == (ushort) 352 && WorldGen.genRand.Next(3) == 0)
WorldGen.GrowSpike(index2, index3, (ushort) 352, (ushort) 199);
}
else if (flag1)
WorldGen.TrySpawningTownNPC(index2, index3);
if (Main.tile[index2, index3].wall == (byte) 81 || Main.tile[index2, index3].wall == (byte) 83 || Main.tile[index2, index3].type == (ushort) 199 && Main.tile[index2, index3].active())
{
int tileX = index2 + WorldGen.genRand.Next(-2, 3);
int tileY = index3 + WorldGen.genRand.Next(-2, 3);
if (Main.tile[tileX, tileY].wall >= (byte) 63 && Main.tile[tileX, tileY].wall <= (byte) 68)
{
bool flag5 = false;
label_213:
for (int index14 = index2 - wallDist; index14 < index2 + wallDist; ++index14)
{
for (int index15 = index3 - wallDist; index15 < index3 + wallDist; ++index15)
{
if (Main.tile[index2, index3].active())
{
switch (Main.tile[index2, index3].type)
{
case 199:
case 200:
case 201:
case 203:
case 205:
case 234:
case 352:
flag5 = true;
goto label_213;
default:
continue;
}
}
}
}
if (flag5)
{
Main.tile[tileX, tileY].wall = (byte) 81;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, tileX, tileY, 3);
}
}
}
if (Main.tile[index2, index3].wall == (byte) 69 || Main.tile[index2, index3].wall == (byte) 3 || Main.tile[index2, index3].type == (ushort) 23 && Main.tile[index2, index3].active())
{
int tileX = index2 + WorldGen.genRand.Next(-2, 3);
int tileY = index3 + WorldGen.genRand.Next(-2, 3);
if (Main.tile[tileX, tileY].wall >= (byte) 63 && Main.tile[tileX, tileY].wall <= (byte) 68)
{
bool flag6 = false;
label_227:
for (int index16 = index2 - wallDist; index16 < index2 + wallDist; ++index16)
{
for (int index17 = index3 - wallDist; index17 < index3 + wallDist; ++index17)
{
if (Main.tile[index16, index17].active())
{
switch (Main.tile[index16, index17].type)
{
case 22:
case 23:
case 24:
case 25:
case 32:
case 112:
case 163:
flag6 = true;
goto label_227;
default:
continue;
}
}
}
}
if (flag6)
{
Main.tile[tileX, tileY].wall = (byte) 69;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, tileX, tileY, 3);
}
}
}
if (Main.tile[index2, index3].wall == (byte) 70 || Main.tile[index2, index3].type == (ushort) 109 && Main.tile[index2, index3].active())
{
int tileX = index2 + WorldGen.genRand.Next(-2, 3);
int tileY = index3 + WorldGen.genRand.Next(-2, 3);
if (Main.tile[tileX, tileY].wall == (byte) 63 || Main.tile[tileX, tileY].wall == (byte) 65 || Main.tile[tileX, tileY].wall == (byte) 66 || Main.tile[tileX, tileY].wall == (byte) 68)
{
bool flag7 = false;
label_241:
for (int index18 = index2 - wallDist; index18 < index2 + wallDist; ++index18)
{
for (int index19 = index3 - wallDist; index19 < index3 + wallDist; ++index19)
{
if (Main.tile[index18, index19].active())
{
switch (Main.tile[index18, index19].type)
{
case 109:
case 110:
case 113:
case 115:
case 116:
case 117:
case 164:
flag7 = true;
goto label_241;
default:
continue;
}
}
}
}
if (flag7)
{
Main.tile[tileX, tileY].wall = (byte) 70;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, tileX, tileY, 3);
}
}
}
WorldGen.SpreadDesertWalls(wallDist, index2, index3);
if (Main.tile[index2, index3].active())
{
if ((Main.tile[index2, index3].type == (ushort) 2 || Main.tile[index2, index3].type == (ushort) 52 || Main.tile[index2, index3].type == (ushort) 192 && WorldGen.genRand.Next(10) == 0) && WorldGen.genRand.Next(40) == 0 && !Main.tile[index2, index3 + 1].active() && !Main.tile[index2, index3 + 1].lava())
{
bool flag8 = false;
for (int index20 = index3; index20 > index3 - 10; --index20)
{
if (Main.tile[index2, index20].bottomSlope())
{
flag8 = false;
break;
}
if (Main.tile[index2, index20].active() && Main.tile[index2, index20].type == (ushort) 2 && !Main.tile[index2, index20].bottomSlope())
{
flag8 = true;
break;
}
}
if (flag8)
{
int index21 = index2;
int index22 = index3 + 1;
Main.tile[index21, index22].type = (ushort) 52;
Main.tile[index21, index22].active(true);
Main.tile[index21, index22].color(Main.tile[index2, index3].color());
WorldGen.SquareTileFrame(index21, index22);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index21, index22, 3);
}
}
if (Main.tile[index2, index3].type == (ushort) 70)
{
int type = (int) Main.tile[index2, index3].type;
if (!Main.tile[index2, index4].active() && WorldGen.genRand.Next(10) == 0)
{
WorldGen.PlaceTile(index2, index4, 71, true);
if (Main.tile[index2, index4].active())
Main.tile[index2, index4].color(Main.tile[index2, index3].color());
if (Main.netMode == 2 && Main.tile[index2, index4].active())
NetMessage.SendTileSquare(-1, index2, index4, 1);
}
if (WorldGen.genRand.Next(100) == 0)
{
bool flag9 = WorldGen.PlayerLOS(index2, index3);
if (WorldGen.GrowTree(index2, index3) & flag9)
WorldGen.TreeGrowFXCheck(index2, index3 - 1);
}
bool flag10 = false;
for (int i = num5; i < num6; ++i)
{
for (int j = index4; j < num7; ++j)
{
if ((index2 != i || index3 != j) && Main.tile[i, j].active() && Main.tile[i, j].type == (ushort) 59)
{
WorldGen.SpreadGrass(i, j, 59, type, false, Main.tile[index2, index3].color());
if ((int) Main.tile[i, j].type == type)
{
WorldGen.SquareTileFrame(i, j);
flag10 = true;
}
}
}
}
if (Main.netMode == 2 & flag10)
NetMessage.SendTileSquare(-1, index2, index3, 3);
}
if (Main.tile[index2, index3].type == (ushort) 60)
{
int type = (int) Main.tile[index2, index3].type;
if (!Main.tile[index2, index4].active() && WorldGen.genRand.Next(7) == 0)
{
WorldGen.PlaceTile(index2, index4, 61, true);
if (Main.tile[index2, index4].active())
Main.tile[index2, index4].color(Main.tile[index2, index3].color());
if (Main.netMode == 2 && Main.tile[index2, index4].active())
NetMessage.SendTileSquare(-1, index2, index4, 1);
}
else if (WorldGen.genRand.Next(500) == 0 && (!Main.tile[index2, index4].active() || Main.tile[index2, index4].type == (ushort) 61 || Main.tile[index2, index4].type == (ushort) 74 || Main.tile[index2, index4].type == (ushort) 69))
{
if (WorldGen.GrowTree(index2, index3) && WorldGen.PlayerLOS(index2, index3))
WorldGen.TreeGrowFXCheck(index2, index3 - 1);
}
else if (WorldGen.genRand.Next(25) == 0 && Main.tile[index2, index4].liquid == (byte) 0)
{
WorldGen.PlaceJunglePlant(index2, index4, (ushort) 233, WorldGen.genRand.Next(8), 0);
if (Main.tile[index2, index4].type == (ushort) 233)
{
if (Main.netMode == 2)
{
NetMessage.SendTileSquare(-1, index2, index4, 4);
}
else
{
WorldGen.PlaceJunglePlant(index2, index4, (ushort) 233, WorldGen.genRand.Next(12), 1);
if (Main.tile[index2, index4].type == (ushort) 233 && Main.netMode == 2)
NetMessage.SendTileSquare(-1, index2, index4, 3);
}
}
}
bool flag11 = false;
for (int i = num5; i < num6; ++i)
{
for (int j = index4; j < num7; ++j)
{
if ((index2 != i || index3 != j) && Main.tile[i, j].active() && Main.tile[i, j].type == (ushort) 59)
{
WorldGen.SpreadGrass(i, j, 59, type, false, Main.tile[index2, index3].color());
if ((int) Main.tile[i, j].type == type)
{
WorldGen.SquareTileFrame(i, j);
flag11 = true;
}
}
}
}
if (Main.netMode == 2 & flag11)
NetMessage.SendTileSquare(-1, index2, index3, 3);
}
if (Main.tile[index2, index3].type == (ushort) 61 && WorldGen.genRand.Next(3) == 0 && Main.tile[index2, index3].frameX < (short) 144)
{
if (Main.rand.Next(4) == 0)
Main.tile[index2, index3].frameX = (short) (162 + WorldGen.genRand.Next(8) * 18);
Main.tile[index2, index3].type = (ushort) 74;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index2, index3, 3);
}
if ((Main.tile[index2, index3].type == (ushort) 60 || Main.tile[index2, index3].type == (ushort) 62) && WorldGen.genRand.Next(15) == 0 && !Main.tile[index2, index3 + 1].active() && !Main.tile[index2, index3 + 1].lava())
{
bool flag12 = false;
for (int index23 = index3; index23 > index3 - 10; --index23)
{
if (Main.tile[index2, index23].bottomSlope())
{
flag12 = false;
break;
}
if (Main.tile[index2, index23].active() && Main.tile[index2, index23].type == (ushort) 60 && !Main.tile[index2, index23].bottomSlope())
{
flag12 = true;
break;
}
}
if (flag12)
{
int index24 = index2;
int index25 = index3 + 1;
Main.tile[index24, index25].type = (ushort) 62;
Main.tile[index24, index25].active(true);
WorldGen.SquareTileFrame(index24, index25);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index24, index25, 3);
}
}
if ((Main.tile[index2, index3].type == (ushort) 109 || Main.tile[index2, index3].type == (ushort) 115) && WorldGen.genRand.Next(15) == 0 && !Main.tile[index2, index3 + 1].active() && !Main.tile[index2, index3 + 1].lava())
{
bool flag13 = false;
for (int index26 = index3; index26 > index3 - 10; --index26)
{
if (Main.tile[index2, index26].bottomSlope())
{
flag13 = false;
break;
}
if (Main.tile[index2, index26].active() && Main.tile[index2, index26].type == (ushort) 109 && !Main.tile[index2, index26].bottomSlope())
{
flag13 = true;
break;
}
}
if (flag13)
{
int index27 = index2;
int index28 = index3 + 1;
Main.tile[index27, index28].type = (ushort) 115;
Main.tile[index27, index28].active(true);
WorldGen.SquareTileFrame(index27, index28);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index27, index28, 3);
}
}
if ((Main.tile[index2, index3].type == (ushort) 199 || Main.tile[index2, index3].type == (ushort) 205) && WorldGen.genRand.Next(15) == 0 && !Main.tile[index2, index3 + 1].active() && !Main.tile[index2, index3 + 1].lava())
{
bool flag14 = false;
for (int index29 = index3; index29 > index3 - 10; --index29)
{
if (Main.tile[index2, index29].bottomSlope())
{
flag14 = false;
break;
}
if (Main.tile[index2, index29].active() && Main.tile[index2, index29].type == (ushort) 199 && !Main.tile[index2, index29].bottomSlope())
{
flag14 = true;
break;
}
}
if (flag14)
{
int index30 = index2;
int index31 = index3 + 1;
Main.tile[index30, index31].type = (ushort) 205;
Main.tile[index30, index31].active(true);
WorldGen.SquareTileFrame(index30, index31);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index30, index31, 3);
}
}
}
}
}
for (int index32 = 0; (double) index32 < (double) (Main.maxTilesX * Main.maxTilesY) * (double) num2; ++index32)
{
int index33 = WorldGen.genRand.Next(10, Main.maxTilesX - 10);
int index34 = WorldGen.genRand.Next((int) Main.worldSurface - 1, Main.maxTilesY - 20);
int num23 = index33 - 1;
int num24 = index33 + 2;
int index35 = index34 - 1;
int num25 = index34 + 2;
if (num23 < 10)
num23 = 10;
if (num24 > Main.maxTilesX - 10)
num24 = Main.maxTilesX - 10;
if (index35 < 10)
index35 = 10;
if (num25 > Main.maxTilesY - 10)
num25 = Main.maxTilesY - 10;
if (Main.tile[index33, index34] != null)
{
if (Main.tileAlch[(int) Main.tile[index33, index34].type])
WorldGen.GrowAlch(index33, index34);
if (Main.tile[index33, index34].liquid <= (byte) 32)
{
if (Main.tile[index33, index34].nactive())
{
WorldGen.hardUpdateWorld(index33, index34);
if (Main.rand.Next(3000) == 0)
WorldGen.plantDye(index33, index34);
if (Main.rand.Next(4500) == 0)
WorldGen.plantDye(index33, index34, true);
if (Main.tile[index33, index34].type == (ushort) 23 && !Main.tile[index33, index35].active() && WorldGen.genRand.Next(1) == 0)
{
WorldGen.PlaceTile(index33, index35, 24, true);
if (Main.netMode == 2 && Main.tile[index33, index35].active())
NetMessage.SendTileSquare(-1, index33, index35, 1);
}
if (Main.tile[index33, index34].type == (ushort) 32 && WorldGen.genRand.Next(3) == 0)
{
int index36 = index33;
int index37 = index34;
int num26 = 0;
if (Main.tile[index36 + 1, index37].active() && Main.tile[index36 + 1, index37].type == (ushort) 32)
++num26;
if (Main.tile[index36 - 1, index37].active() && Main.tile[index36 - 1, index37].type == (ushort) 32)
++num26;
if (Main.tile[index36, index37 + 1].active() && Main.tile[index36, index37 + 1].type == (ushort) 32)
++num26;
if (Main.tile[index36, index37 - 1].active() && Main.tile[index36, index37 - 1].type == (ushort) 32)
++num26;
if (num26 < 3 || Main.tile[index33, index34].type == (ushort) 23)
{
switch (WorldGen.genRand.Next(4))
{
case 0:
--index37;
break;
case 1:
++index37;
break;
case 2:
--index36;
break;
case 3:
++index36;
break;
}
if (!Main.tile[index36, index37].active())
{
int num27 = 0;
if (Main.tile[index36 + 1, index37].active() && Main.tile[index36 + 1, index37].type == (ushort) 32)
++num27;
if (Main.tile[index36 - 1, index37].active() && Main.tile[index36 - 1, index37].type == (ushort) 32)
++num27;
if (Main.tile[index36, index37 + 1].active() && Main.tile[index36, index37 + 1].type == (ushort) 32)
++num27;
if (Main.tile[index36, index37 - 1].active() && Main.tile[index36, index37 - 1].type == (ushort) 32)
++num27;
if (num27 < 2)
{
int num28 = 7;
int num29 = index36 - num28;
int num30 = index36 + num28;
int num31 = index37 - num28;
int num32 = index37 + num28;
bool flag15 = false;
for (int index38 = num29; index38 < num30; ++index38)
{
for (int index39 = num31; index39 < num32; ++index39)
{
if (Math.Abs(index38 - index36) * 2 + Math.Abs(index39 - index37) < 9 && Main.tile[index38, index39].active() && Main.tile[index38, index39].type == (ushort) 23 && Main.tile[index38, index39 - 1].active() && Main.tile[index38, index39 - 1].type == (ushort) 32 && Main.tile[index38, index39 - 1].liquid == (byte) 0)
{
flag15 = true;
break;
}
}
}
if (flag15)
{
Main.tile[index36, index37].type = (ushort) 32;
Main.tile[index36, index37].active(true);
WorldGen.SquareTileFrame(index36, index37);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index36, index37, 3);
}
}
}
}
}
if (Main.tile[index33, index34].type == (ushort) 352 && WorldGen.genRand.Next(3) == 0)
WorldGen.GrowSpike(index33, index34, (ushort) 352, (ushort) 199);
if (Main.tile[index33, index34].type == (ushort) 199)
{
int type = (int) Main.tile[index33, index34].type;
bool flag16 = false;
for (int i = num23; i < num24; ++i)
{
for (int j = index35; j < num25; ++j)
{
if ((index33 != i || index34 != j) && Main.tile[i, j].active() && Main.tile[i, j].type == (ushort) 0)
{
WorldGen.SpreadGrass(i, j, grass: type, repeat: false, color: Main.tile[index33, index34].color());
if ((int) Main.tile[i, j].type == type)
{
WorldGen.SquareTileFrame(i, j);
flag16 = true;
}
}
}
}
if (Main.netMode == 2 & flag16)
NetMessage.SendTileSquare(-1, index33, index34, 3);
}
if (Main.tile[index33, index34].type == (ushort) 60)
{
int type = (int) Main.tile[index33, index34].type;
if (!Main.tile[index33, index35].active() && WorldGen.genRand.Next(10) == 0)
{
WorldGen.PlaceTile(index33, index35, 61, true);
if (Main.netMode == 2 && Main.tile[index33, index35].active())
NetMessage.SendTileSquare(-1, index33, index35, 1);
}
else if (WorldGen.genRand.Next(25) == 0 && Main.tile[index33, index35].liquid == (byte) 0)
{
if (Main.hardMode && NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3 && WorldGen.genRand.Next(60) == 0)
{
bool flag17 = true;
int num33 = 150;
for (int index40 = index33 - num33; index40 < index33 + num33; index40 += 2)
{
for (int index41 = index34 - num33; index41 < index34 + num33; index41 += 2)
{
if (index40 > 1 && index40 < Main.maxTilesX - 2 && index41 > 1 && index41 < Main.maxTilesY - 2 && Main.tile[index40, index41].active() && Main.tile[index40, index41].type == (ushort) 238)
{
flag17 = false;
break;
}
}
}
if (flag17)
{
WorldGen.PlaceJunglePlant(index33, index35, (ushort) 238, 0, 0);
WorldGen.SquareTileFrame(index33, index35);
WorldGen.SquareTileFrame(index33 + 1, index35 + 1);
if (Main.tile[index33, index35].type == (ushort) 238 && Main.netMode == 2)
NetMessage.SendTileSquare(-1, index33, index35, 4);
}
}
if (Main.hardMode && NPC.downedMechBossAny && WorldGen.genRand.Next(maxValue1) == 0)
{
bool flag18 = true;
int num34 = 60;
if (Main.expertMode)
num34 -= 10;
for (int index42 = index33 - num34; index42 < index33 + num34; index42 += 2)
{
for (int index43 = index34 - num34; index43 < index34 + num34; index43 += 2)
{
if (index42 > 1 && index42 < Main.maxTilesX - 2 && index43 > 1 && index43 < Main.maxTilesY - 2 && Main.tile[index42, index43].active() && Main.tile[index42, index43].type == (ushort) 236)
{
flag18 = false;
break;
}
}
}
if (flag18)
{
WorldGen.PlaceJunglePlant(index33, index35, (ushort) 236, WorldGen.genRand.Next(3), 0);
WorldGen.SquareTileFrame(index33, index35);
WorldGen.SquareTileFrame(index33 + 1, index35 + 1);
if (Main.tile[index33, index35].type == (ushort) 236 && Main.netMode == 2)
NetMessage.SendTileSquare(-1, index33, index35, 4);
}
}
else
{
WorldGen.PlaceJunglePlant(index33, index35, (ushort) 233, WorldGen.genRand.Next(8), 0);
if (Main.tile[index33, index35].type == (ushort) 233)
{
if (Main.netMode == 2)
{
NetMessage.SendTileSquare(-1, index33, index35, 4);
}
else
{
WorldGen.PlaceJunglePlant(index33, index35, (ushort) 233, WorldGen.genRand.Next(12), 1);
if (Main.tile[index33, index35].type == (ushort) 233 && Main.netMode == 2)
NetMessage.SendTileSquare(-1, index33, index35, 3);
}
}
}
}
bool flag19 = false;
for (int i = num23; i < num24; ++i)
{
for (int j = index35; j < num25; ++j)
{
if ((index33 != i || index34 != j) && Main.tile[i, j].active() && Main.tile[i, j].type == (ushort) 59)
{
WorldGen.SpreadGrass(i, j, 59, type, false, Main.tile[index33, index34].color());
if ((int) Main.tile[i, j].type == type)
{
WorldGen.SquareTileFrame(i, j);
flag19 = true;
}
}
}
}
if (Main.netMode == 2 & flag19)
NetMessage.SendTileSquare(-1, index33, index34, 3);
}
if (Main.tile[index33, index34].type == (ushort) 61 && WorldGen.genRand.Next(3) == 0 && Main.tile[index33, index34].frameX < (short) 144)
{
if (Main.rand.Next(4) == 0)
Main.tile[index33, index34].frameX = (short) (162 + WorldGen.genRand.Next(8) * 18);
Main.tile[index33, index34].type = (ushort) 74;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index33, index34, 3);
}
if ((Main.tile[index33, index34].type == (ushort) 60 || Main.tile[index33, index34].type == (ushort) 62) && WorldGen.genRand.Next(5) == 0 && !Main.tile[index33, index34 + 1].active() && !Main.tile[index33, index34 + 1].lava())
{
bool flag20 = false;
for (int index44 = index34; index44 > index34 - 10; --index44)
{
if (Main.tile[index33, index44].bottomSlope())
{
flag20 = false;
break;
}
if (Main.tile[index33, index44].active() && Main.tile[index33, index44].type == (ushort) 60 && !Main.tile[index33, index44].bottomSlope())
{
flag20 = true;
break;
}
}
if (flag20)
{
int index45 = index33;
int index46 = index34 + 1;
Main.tile[index45, index46].type = (ushort) 62;
Main.tile[index45, index46].active(true);
WorldGen.SquareTileFrame(index45, index46);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index45, index46, 3);
}
}
if ((Main.tile[index33, index34].type == (ushort) 60 || Main.tile[index33, index34].type == (ushort) 62) && WorldGen.genRand.Next(80) == 0 && !WorldGen.PlayerLOS(index33, index34))
{
bool flag21 = true;
int tileY = index34;
if (Main.tile[index33, index34].type == (ushort) 60)
++tileY;
for (int i = index33; i < index33 + 2; ++i)
{
int j = tileY - 1;
if (!WorldGen.AnchorValid(Framing.GetTileSafely(i, j), AnchorType.SolidTile) || Main.tile[i, j].bottomSlope())
flag21 = false;
if (Main.tile[i, j].liquid > (byte) 0 || Main.wallHouse[(int) Main.tile[i, j].wall])
flag21 = false;
if (flag21)
{
for (int index47 = tileY; index47 < tileY + 2; ++index47)
{
if ((!Main.tile[i, index47].active() || Main.tileCut[(int) Main.tile[i, index47].type] && Main.tile[i, index47].type != (ushort) 444 ? (!Main.tile[i, index47].lava() ? 1 : 0) : 0) == 0)
flag21 = false;
if (!flag21)
break;
}
if (!flag21)
break;
}
else
break;
}
if (flag21)
{
if (WorldGen.CountNearBlocksTypes(index33, index34, 20, 1, 444) > 0)
flag21 = false;
}
if (flag21)
{
for (int i = index33; i < index33 + 2; ++i)
{
Main.tile[i, tileY - 1].slope((byte) 0);
Main.tile[i, tileY - 1].halfBrick(false);
for (int j = tileY; j < tileY + 2; ++j)
{
if (Main.tile[i, j].active())
WorldGen.KillTile(i, j);
}
}
for (int index48 = index33; index48 < index33 + 2; ++index48)
{
for (int index49 = tileY; index49 < tileY + 2; ++index49)
{
Main.tile[index48, index49].active(true);
Main.tile[index48, index49].type = (ushort) 444;
Main.tile[index48, index49].frameX = (short) ((index48 - index33) * 18);
Main.tile[index48, index49].frameY = (short) ((index49 - tileY) * 18);
}
}
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index33, tileY, 3);
}
}
if (Main.tile[index33, index34].type == (ushort) 69 && WorldGen.genRand.Next(3) == 0)
{
int index50 = index33;
int index51 = index34;
int num35 = 0;
if (Main.tile[index50 + 1, index51].active() && Main.tile[index50 + 1, index51].type == (ushort) 69)
++num35;
if (Main.tile[index50 - 1, index51].active() && Main.tile[index50 - 1, index51].type == (ushort) 69)
++num35;
if (Main.tile[index50, index51 + 1].active() && Main.tile[index50, index51 + 1].type == (ushort) 69)
++num35;
if (Main.tile[index50, index51 - 1].active() && Main.tile[index50, index51 - 1].type == (ushort) 69)
++num35;
if (num35 < 3 || Main.tile[index33, index34].type == (ushort) 60)
{
switch (WorldGen.genRand.Next(4))
{
case 0:
--index51;
break;
case 1:
++index51;
break;
case 2:
--index50;
break;
case 3:
++index50;
break;
}
if (!Main.tile[index50, index51].active())
{
int num36 = 0;
if (Main.tile[index50 + 1, index51].active() && Main.tile[index50 + 1, index51].type == (ushort) 69)
++num36;
if (Main.tile[index50 - 1, index51].active() && Main.tile[index50 - 1, index51].type == (ushort) 69)
++num36;
if (Main.tile[index50, index51 + 1].active() && Main.tile[index50, index51 + 1].type == (ushort) 69)
++num36;
if (Main.tile[index50, index51 - 1].active() && Main.tile[index50, index51 - 1].type == (ushort) 69)
++num36;
if (num36 < 2)
{
int num37 = 7;
int num38 = index50 - num37;
int num39 = index50 + num37;
int num40 = index51 - num37;
int num41 = index51 + num37;
bool flag22 = false;
for (int index52 = num38; index52 < num39; ++index52)
{
for (int index53 = num40; index53 < num41; ++index53)
{
if (Math.Abs(index52 - index50) * 2 + Math.Abs(index53 - index51) < 9 && Main.tile[index52, index53].active() && Main.tile[index52, index53].type == (ushort) 60 && Main.tile[index52, index53 - 1].active() && Main.tile[index52, index53 - 1].type == (ushort) 69 && Main.tile[index52, index53 - 1].liquid == (byte) 0)
{
flag22 = true;
break;
}
}
}
if (flag22)
{
Main.tile[index50, index51].type = (ushort) 69;
Main.tile[index50, index51].active(true);
WorldGen.SquareTileFrame(index50, index51);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index50, index51, 3);
}
}
}
}
}
else if (Main.tile[index33, index34].type == (ushort) 147 || Main.tile[index33, index34].type == (ushort) 161 || Main.tile[index33, index34].type == (ushort) 163 || Main.tile[index33, index34].type == (ushort) 164 || Main.tile[index33, index34].type == (ushort) 200)
{
if (Main.rand.Next(10) == 0 && !Main.tile[index33, index34 + 1].active() && !Main.tile[index33, index34 + 2].active())
{
int num42 = index33 - 3;
int num43 = index33 + 4;
int num44 = 0;
for (int index54 = num42; index54 < num43; ++index54)
{
if (Main.tile[index54, index34].type == (ushort) 165 && Main.tile[index54, index34].active())
++num44;
if (Main.tile[index54, index34 + 1].type == (ushort) 165 && Main.tile[index54, index34 + 1].active())
++num44;
if (Main.tile[index54, index34 + 2].type == (ushort) 165 && Main.tile[index54, index34 + 2].active())
++num44;
if (Main.tile[index54, index34 + 3].type == (ushort) 165 && Main.tile[index54, index34 + 3].active())
++num44;
}
if (num44 < 2)
{
WorldGen.PlaceTight(index33, index34 + 1);
WorldGen.SquareTileFrame(index33, index34 + 1);
if (Main.netMode == 2 && Main.tile[index33, index34 + 1].active())
NetMessage.SendTileSquare(-1, index33, index34 + 1, 3);
}
}
}
else if (Main.tileMoss[(int) Main.tile[index33, index34].type])
{
int type = (int) Main.tile[index33, index34].type;
bool flag23 = false;
for (int i = num23; i < num24; ++i)
{
for (int j = index35; j < num25; ++j)
{
if ((index33 != i || index34 != j) && Main.tile[i, j].active() && Main.tile[i, j].type == (ushort) 1)
{
WorldGen.SpreadGrass(i, j, 1, type, false, Main.tile[index33, index34].color());
if ((int) Main.tile[i, j].type == type)
{
WorldGen.SquareTileFrame(i, j);
flag23 = true;
}
}
}
}
if (Main.netMode == 2 & flag23)
NetMessage.SendTileSquare(-1, index33, index34, 3);
if (WorldGen.genRand.Next(6) == 0)
{
int index55 = index33;
int index56 = index34;
switch (WorldGen.genRand.Next(4))
{
case 0:
--index55;
break;
case 1:
++index55;
break;
case 2:
--index56;
break;
default:
++index56;
break;
}
if (!Main.tile[index55, index56].active())
{
WorldGen.PlaceTile(index55, index56, 184, true);
if (Main.netMode == 2 && Main.tile[index55, index56].active())
NetMessage.SendTileSquare(-1, index55, index56, 1);
}
}
}
if (Main.tile[index33, index34].type == (ushort) 70)
{
int type = (int) Main.tile[index33, index34].type;
if (!Main.tile[index33, index35].active() && WorldGen.genRand.Next(10) == 0)
{
WorldGen.PlaceTile(index33, index35, 71, true);
if (Main.netMode == 2 && Main.tile[index33, index35].active())
NetMessage.SendTileSquare(-1, index33, index35, 1);
}
if (WorldGen.genRand.Next(200) == 0 && WorldGen.GrowShroom(index33, index34) && WorldGen.PlayerLOS(index33, index34))
WorldGen.TreeGrowFXCheck(index33, index34 - 1);
bool flag24 = false;
for (int i = num23; i < num24; ++i)
{
for (int j = index35; j < num25; ++j)
{
if ((index33 != i || index34 != j) && Main.tile[i, j].active() && Main.tile[i, j].type == (ushort) 59)
{
WorldGen.SpreadGrass(i, j, 59, type, false, Main.tile[index33, index34].color());
if ((int) Main.tile[i, j].type == type)
{
WorldGen.SquareTileFrame(i, j);
flag24 = true;
}
}
}
}
if (Main.netMode == 2 & flag24)
NetMessage.SendTileSquare(-1, index33, index34, 3);
}
}
else
{
if (Main.tile[index33, index34].wall == (byte) 62 && Main.tile[index33, index34].liquid == (byte) 0 && WorldGen.genRand.Next(10) == 0)
{
int num45 = WorldGen.genRand.Next(2, 4);
int num46 = index33 - num45;
int num47 = index33 + num45;
int num48 = index34 - num45;
int num49 = index34 + num45;
bool flag25 = false;
for (int i = num46; i <= num47; ++i)
{
for (int j = num48; j <= num49; ++j)
{
if (WorldGen.SolidTile(i, j))
{
flag25 = true;
break;
}
}
}
if (flag25 && !Main.tile[index33, index34].active())
{
WorldGen.PlaceTile(index33, index34, 51, true);
WorldGen.TileFrame(index33, index34, true);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, index33, index34, 3);
}
}
if (flag1)
WorldGen.TrySpawningTownNPC(index33, index34);
}
}
if (Main.tile[index33, index34].wall == (byte) 81 || Main.tile[index33, index34].wall == (byte) 83 || Main.tile[index33, index34].type == (ushort) 199 && Main.tile[index33, index34].active())
{
int tileX = index33 + WorldGen.genRand.Next(-2, 3);
int tileY = index34 + WorldGen.genRand.Next(-2, 3);
if (Main.tile[tileX, tileY].wall >= (byte) 63 && Main.tile[tileX, tileY].wall <= (byte) 68)
{
bool flag26 = false;
label_629:
for (int index57 = index33 - wallDist; index57 < index33 + wallDist; ++index57)
{
for (int index58 = index34 - wallDist; index58 < index34 + wallDist; ++index58)
{
if (Main.tile[index33, index34].active())
{
switch (Main.tile[index33, index34].type)
{
case 199:
case 200:
case 201:
case 203:
case 205:
case 234:
case 352:
flag26 = true;
goto label_629;
default:
continue;
}
}
}
}
if (flag26)
{
Main.tile[tileX, tileY].wall = (byte) 81;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, tileX, tileY, 3);
}
}
}
if (Main.tile[index33, index34].wall == (byte) 69 || Main.tile[index33, index34].wall == (byte) 3 || Main.tile[index33, index34].type == (ushort) 23 && Main.tile[index33, index34].active())
{
int tileX = index33 + WorldGen.genRand.Next(-2, 3);
int tileY = index34 + WorldGen.genRand.Next(-2, 3);
if (Main.tile[tileX, tileY].wall >= (byte) 63 && Main.tile[tileX, tileY].wall <= (byte) 68)
{
bool flag27 = false;
label_643:
for (int index59 = index33 - wallDist; index59 < index33 + wallDist; ++index59)
{
for (int index60 = index34 - wallDist; index60 < index34 + wallDist; ++index60)
{
if (Main.tile[index33, index34].active())
{
switch (Main.tile[index33, index34].type)
{
case 22:
case 23:
case 24:
case 25:
case 32:
case 112:
case 163:
flag27 = true;
goto label_643;
default:
continue;
}
}
}
}
if (flag27)
{
Main.tile[tileX, tileY].wall = (byte) 69;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, tileX, tileY, 3);
}
}
}
if (Main.tile[index33, index34].wall == (byte) 70 || Main.tile[index33, index34].type == (ushort) 109 && Main.tile[index33, index34].active())
{
int tileX = index33 + WorldGen.genRand.Next(-2, 3);
int tileY = index34 + WorldGen.genRand.Next(-2, 3);
if (Main.tile[tileX, tileY].wall == (byte) 63 || Main.tile[tileX, tileY].wall == (byte) 65 || Main.tile[tileX, tileY].wall == (byte) 66 || Main.tile[tileX, tileY].wall == (byte) 68)
{
bool flag28 = false;
label_657:
for (int index61 = index33 - wallDist; index61 < index33 + wallDist; ++index61)
{
for (int index62 = index34 - wallDist; index62 < index34 + wallDist; ++index62)
{
if (Main.tile[index33, index34].active())
{
switch (Main.tile[index33, index34].type)
{
case 109:
case 110:
case 113:
case 115:
case 116:
case 117:
case 164:
flag28 = true;
goto label_657;
default:
continue;
}
}
}
}
if (flag28)
{
Main.tile[tileX, tileY].wall = (byte) 70;
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, tileX, tileY, 3);
}
}
}
WorldGen.SpreadDesertWalls(wallDist, index33, index34);
}
}
if (Main.dayTime)
return;
float num50 = (float) (Main.maxTilesX / 4200);
if ((double) Main.rand.Next(8000) >= 10.0 * (double) num50)
return;
Vector2 vector2 = new Vector2((float) ((Main.rand.Next(Main.maxTilesX - 50) + 100) * 16), (float) (Main.rand.Next((int) ((double) Main.maxTilesY * 0.05)) * 16));
float num51 = (float) Main.rand.Next(-100, 101);
float num52 = (float) (Main.rand.Next(200) + 100);
float num53 = 12f / (float) Math.Sqrt((double) num51 * (double) num51 + (double) num52 * (double) num52);
float SpeedX = num51 * num53;
float SpeedY = num52 * num53;
Projectile.NewProjectile(vector2.X, vector2.Y, SpeedX, SpeedY, 12, 1000, 10f, Main.myPlayer);
}
private static void TrySpawningTownNPC(int x, int y)
{
if (WorldGen.prioritizedTownNPC <= 0)
return;
if (Main.tile[x, y].wall == (byte) 34)
{
if (Main.rand.Next(4) != 0)
return;
int num = (int) WorldGen.SpawnTownNPC(x, y);
}
else
{
int num1 = (int) WorldGen.SpawnTownNPC(x, y);
}
}
public static void SpreadDesertWalls(int wallDist, int i, int j)
{
if (!WallID.Sets.Conversion.Sandstone[(int) Main.tile[i, j].wall] && (!Main.tile[i, j].active() || !TileID.Sets.Conversion.Sandstone[(int) Main.tile[i, j].type]) && !WallID.Sets.Conversion.HardenedSand[(int) Main.tile[i, j].wall])
return;
int num = 0;
int wall = (int) Main.tile[i, j].wall;
int type = (int) Main.tile[i, j].type;
if (WallID.Sets.Corrupt[wall] || TileID.Sets.Corrupt[type])
num = 1;
if (WallID.Sets.Hallow[wall] || TileID.Sets.Hallow[type])
num = 2;
if (WallID.Sets.Crimson[wall] || TileID.Sets.Crimson[type])
num = 3;
if (num == 0)
return;
int tileX = i + WorldGen.genRand.Next(-2, 3);
int tileY = j + WorldGen.genRand.Next(-2, 3);
bool flag = false;
if (WallID.Sets.Conversion.Sandstone[(int) Main.tile[tileX, tileY].wall] || WallID.Sets.Conversion.HardenedSand[(int) Main.tile[tileX, tileY].wall])
{
switch (num)
{
case 1:
for (int index1 = i - wallDist; index1 < i + wallDist; ++index1)
{
for (int index2 = j - wallDist; index2 < j + wallDist; ++index2)
{
if (Main.tile[index1, index2].active() && TileID.Sets.Corrupt[(int) Main.tile[index1, index2].type])
{
flag = true;
break;
}
}
if (flag)
break;
}
break;
case 2:
for (int index3 = i - wallDist; index3 < i + wallDist; ++index3)
{
for (int index4 = j - wallDist; index4 < j + wallDist; ++index4)
{
if (Main.tile[index3, index4].active() && TileID.Sets.Hallow[(int) Main.tile[index3, index4].type])
{
flag = true;
break;
}
}
if (flag)
break;
}
break;
case 3:
for (int index5 = i - wallDist; index5 < i + wallDist; ++index5)
{
for (int index6 = j - wallDist; index6 < j + wallDist; ++index6)
{
if (Main.tile[index5, index6].active() && TileID.Sets.Crimson[(int) Main.tile[index5, index6].type])
{
flag = true;
break;
}
}
if (flag)
break;
}
break;
}
}
if (!flag)
return;
byte? nullable = new byte?();
if (WallID.Sets.Conversion.Sandstone[(int) Main.tile[tileX, tileY].wall])
{
switch (num)
{
case 1:
nullable = new byte?((byte) 220);
break;
case 2:
nullable = new byte?((byte) 222);
break;
case 3:
nullable = new byte?((byte) 221);
break;
}
}
if (WallID.Sets.Conversion.HardenedSand[(int) Main.tile[tileX, tileY].wall])
{
switch (num)
{
case 1:
nullable = new byte?((byte) 217);
break;
case 2:
nullable = new byte?((byte) 219);
break;
case 3:
nullable = new byte?((byte) 218);
break;
}
}
if (!nullable.HasValue || (int) Main.tile[tileX, tileY].wall == (int) nullable.Value)
return;
Main.tile[tileX, tileY].wall = nullable.Value;
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, tileX, tileY, 3);
}
public static void PlaceWall(int i, int j, int type, bool mute = false)
{
if (i <= 1 || j <= 1 || i >= Main.maxTilesX - 2 || j >= Main.maxTilesY - 2)
return;
if (Main.tile[i, j] == null)
Main.tile[i, j] = new Tile();
if (Main.tile[i, j].wall != (byte) 0)
return;
Main.tile[i, j].wall = (byte) type;
WorldGen.SquareWallFrame(i, j);
if (mute)
return;
Main.PlaySound(0, i * 16, j * 16);
}
public static void AddPlants()
{
for (int i = 0; i < Main.maxTilesX; ++i)
{
for (int index = 1; index < Main.maxTilesY; ++index)
{
if (Main.tile[i, index].type == (ushort) 2 && Main.tile[i, index].nactive())
{
if (!Main.tile[i, index - 1].active())
WorldGen.PlaceTile(i, index - 1, 3, true);
}
else if (Main.tile[i, index].type == (ushort) 23 && Main.tile[i, index].nactive())
{
if (!Main.tile[i, index - 1].active())
WorldGen.PlaceTile(i, index - 1, 24, true);
}
else if (Main.tile[i, index].type == (ushort) 199 && Main.tile[i, index].nactive() && !Main.tile[i, index - 1].active())
WorldGen.PlaceTile(i, index - 1, 201, true);
}
}
}
public static void SpreadGrass(int i, int j, int dirt = 0, int grass = 2, bool repeat = true, byte color = 0)
{
try
{
if (!WorldGen.InWorld(i, j, 1) || (int) Main.tile[i, j].type != dirt || !Main.tile[i, j].active() || (double) j >= Main.worldSurface && dirt == 0)
return;
int num1 = i - 1;
int num2 = i + 2;
int num3 = j - 1;
int num4 = j + 2;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
bool flag = true;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (!Main.tile[index1, index2].active() || !Main.tileSolid[(int) Main.tile[index1, index2].type])
flag = false;
if (Main.tile[index1, index2].lava() && Main.tile[index1, index2].liquid > (byte) 0)
{
flag = true;
break;
}
}
}
if (flag || !TileID.Sets.CanBeClearedDuringGeneration[(int) Main.tile[i, j].type] || grass == 23 && Main.tile[i, j - 1].type == (ushort) 27 || grass == 199 && Main.tile[i, j - 1].type == (ushort) 27)
return;
Main.tile[i, j].type = (ushort) grass;
Main.tile[i, j].color(color);
for (int i1 = num1; i1 < num2; ++i1)
{
for (int j1 = num3; j1 < num4; ++j1)
{
if (Main.tile[i1, j1].active())
{
if ((int) Main.tile[i1, j1].type == dirt)
{
try
{
if (repeat)
{
if (WorldGen.grassSpread < 1000)
{
++WorldGen.grassSpread;
WorldGen.SpreadGrass(i1, j1, dirt, grass);
--WorldGen.grassSpread;
}
}
}
catch
{
}
}
}
}
}
}
catch
{
}
}
public static void ChasmRunnerSideways(int i, int j, int direction, int steps)
{
float num1 = (float) steps;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(10, 21) * 0.1f * (float) direction;
vector2_2.Y = (float) WorldGen.genRand.Next(-10, 10) * 0.01f;
double num2 = (double) (WorldGen.genRand.Next(5) + 7);
while (num2 > 0.0)
{
if ((double) num1 > 0.0)
{
num2 = num2 + (double) WorldGen.genRand.Next(3) - (double) WorldGen.genRand.Next(3);
if (num2 < 7.0)
num2 = 7.0;
if (num2 > 20.0)
num2 = 20.0;
if ((double) num1 == 1.0 && num2 < 10.0)
num2 = 10.0;
}
else
num2 -= (double) WorldGen.genRand.Next(4);
if ((double) vector2_1.Y > Main.rockLayer && (double) num1 > 0.0)
num1 = 0.0f;
--num1;
int num3 = (int) ((double) vector2_1.X - num2 * 0.5);
int num4 = (int) ((double) vector2_1.X + num2 * 0.5);
int num5 = (int) ((double) vector2_1.Y - num2 * 0.5);
int num6 = (int) ((double) vector2_1.Y + num2 * 0.5);
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesX - 1)
num4 = Main.maxTilesX - 1;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY;
for (int index1 = num3; index1 < num4; ++index1)
{
for (int index2 = num5; index2 < num6; ++index2)
{
if ((double) Math.Abs((float) index1 - vector2_1.X) + (double) Math.Abs((float) index2 - vector2_1.Y) < num2 * 0.5 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015) && Main.tile[index1, index2].type != (ushort) 31 && Main.tile[index1, index2].type != (ushort) 22)
Main.tile[index1, index2].active(false);
}
}
vector2_1 += vector2_2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 10) * 0.1f;
if ((double) vector2_1.Y < (double) (j - 20))
vector2_2.Y += (float) WorldGen.genRand.Next(20) * 0.01f;
if ((double) vector2_1.Y > (double) (j + 20))
vector2_2.Y -= (float) WorldGen.genRand.Next(20) * 0.01f;
if ((double) vector2_2.Y < -0.5)
vector2_2.Y = -0.5f;
if ((double) vector2_2.Y > 0.5)
vector2_2.Y = 0.5f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.01f;
switch (direction)
{
case -1:
if ((double) vector2_2.X > -0.5)
vector2_2.X = -0.5f;
if ((double) vector2_2.X < -2.0)
{
vector2_2.X = -2f;
break;
}
break;
case 1:
if ((double) vector2_2.X < 0.5)
vector2_2.X = 0.5f;
if ((double) vector2_2.X > 2.0)
{
vector2_2.X = 2f;
break;
}
break;
}
int num7 = (int) ((double) vector2_1.X - num2 * 1.1);
int num8 = (int) ((double) vector2_1.X + num2 * 1.1);
int num9 = (int) ((double) vector2_1.Y - num2 * 1.1);
int num10 = (int) ((double) vector2_1.Y + num2 * 1.1);
if (num7 < 1)
num7 = 1;
if (num8 > Main.maxTilesX - 1)
num8 = Main.maxTilesX - 1;
if (num9 < 0)
num9 = 0;
if (num10 > Main.maxTilesY)
num10 = Main.maxTilesY;
for (int index3 = num7; index3 < num8; ++index3)
{
for (int index4 = num9; index4 < num10; ++index4)
{
if ((double) Math.Abs((float) index3 - vector2_1.X) + (double) Math.Abs((float) index4 - vector2_1.Y) < num2 * 1.1 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015) && Main.tile[index3, index4].wall != (byte) 3)
{
if (Main.tile[index3, index4].type != (ushort) 25 && index4 > j + WorldGen.genRand.Next(3, 20))
Main.tile[index3, index4].active(true);
Main.tile[index3, index4].active(true);
if (Main.tile[index3, index4].type != (ushort) 31 && Main.tile[index3, index4].type != (ushort) 22)
Main.tile[index3, index4].type = (ushort) 25;
if (Main.tile[index3, index4].wall == (byte) 2)
Main.tile[index3, index4].wall = (byte) 0;
}
}
}
for (int i1 = num7; i1 < num8; ++i1)
{
for (int j1 = num9; j1 < num10; ++j1)
{
if ((double) Math.Abs((float) i1 - vector2_1.X) + (double) Math.Abs((float) j1 - vector2_1.Y) < num2 * 1.1 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015) && Main.tile[i1, j1].wall != (byte) 3)
{
if (Main.tile[i1, j1].type != (ushort) 31 && Main.tile[i1, j1].type != (ushort) 22)
Main.tile[i1, j1].type = (ushort) 25;
Main.tile[i1, j1].active(true);
WorldGen.PlaceWall(i1, j1, 3, true);
}
}
}
}
if (WorldGen.genRand.Next(3) != 0)
return;
int x = (int) vector2_1.X;
int y = (int) vector2_1.Y;
while (!Main.tile[x, y].active())
++y;
WorldGen.TileRunner(x, y, (double) WorldGen.genRand.Next(2, 6), WorldGen.genRand.Next(3, 7), 22);
}
public static void CrimStart(int i, int j)
{
int crimDir = 1;
WorldGen.heartCount = 0;
WorldGen.crimson = true;
int i1 = i;
int j1 = j;
if ((double) j1 > Main.worldSurface)
j1 = (int) Main.worldSurface;
while (!WorldGen.SolidTile(i1, j1))
++j1;
int num1 = i1;
int num2 = j1;
Vector2 position = new Vector2((float) i1, (float) j1);
Vector2 vector2 = new Vector2((float) WorldGen.genRand.Next(-20, 21) * 0.1f, (float) WorldGen.genRand.Next(20, 201) * 0.01f);
if ((double) vector2.X < 0.0)
crimDir = -1;
float num3 = (float) WorldGen.genRand.Next(15, 26);
bool flag1 = true;
int num4 = 0;
while (flag1)
{
num3 += (float) WorldGen.genRand.Next(-50, 51) * 0.01f;
if ((double) num3 < 15.0)
num3 = 15f;
if ((double) num3 > 25.0)
num3 = 25f;
for (int index1 = (int) ((double) position.X - (double) num3 / 2.0); (double) index1 < (double) position.X + (double) num3 / 2.0; ++index1)
{
for (int index2 = (int) ((double) position.Y - (double) num3 / 2.0); (double) index2 < (double) position.Y + (double) num3 / 2.0; ++index2)
{
if (index2 > num2)
{
if ((double) Math.Abs((float) index1 - position.X) + (double) Math.Abs((float) index2 - position.Y) < (double) num3 * 0.3)
{
Main.tile[index1, index2].active(false);
Main.tile[index1, index2].wall = (byte) 83;
}
else if ((double) Math.Abs((float) index1 - position.X) + (double) Math.Abs((float) index2 - position.Y) < (double) num3 * 0.8 && Main.tile[index1, index2].wall != (byte) 83)
{
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].type = (ushort) 203;
if ((double) Math.Abs((float) index1 - position.X) + (double) Math.Abs((float) index2 - position.Y) < (double) num3 * 0.6)
Main.tile[index1, index2].wall = (byte) 83;
}
}
else if ((double) Math.Abs((float) index1 - position.X) + (double) Math.Abs((float) index2 - position.Y) < (double) num3 * 0.3 && Main.tile[index1, index2].active())
{
Main.tile[index1, index2].active(false);
Main.tile[index1, index2].wall = (byte) 83;
}
}
}
if ((double) position.X > (double) (num1 + 50))
num4 = -100;
if ((double) position.X < (double) (num1 - 50))
num4 = 100;
if (num4 < 0)
vector2.X -= (float) WorldGen.genRand.Next(20, 51) * 0.01f;
else if (num4 > 0)
vector2.X += (float) WorldGen.genRand.Next(20, 51) * 0.01f;
else
vector2.X += (float) WorldGen.genRand.Next(-50, 51) * 0.01f;
vector2.Y += (float) WorldGen.genRand.Next(-50, 51) * 0.01f;
if ((double) vector2.Y < 0.25)
vector2.Y = 0.25f;
if ((double) vector2.Y > 2.0)
vector2.Y = 2f;
if ((double) vector2.X < -2.0)
vector2.X = -2f;
if ((double) vector2.X > 2.0)
vector2.X = 2f;
position += vector2;
if ((double) position.Y > Main.worldSurface + 100.0)
flag1 = false;
}
float num5 = (float) WorldGen.genRand.Next(40, 55);
for (int index3 = 0; index3 < 50; ++index3)
{
int num6 = (int) position.X + WorldGen.genRand.Next(-20, 21);
int num7 = (int) position.Y + WorldGen.genRand.Next(-20, 21);
for (int index4 = (int) ((double) num6 - (double) num5 / 2.0); (double) index4 < (double) num6 + (double) num5 / 2.0; ++index4)
{
for (int index5 = (int) ((double) num7 - (double) num5 / 2.0); (double) index5 < (double) num7 + (double) num5 / 2.0; ++index5)
{
double num8 = (double) Math.Abs(index4 - num6);
float num9 = (float) Math.Abs(index5 - num7);
float num10 = (float) (1.0 + (double) WorldGen.genRand.Next(-20, 21) * 0.00999999977648258);
float num11 = (float) (1.0 + (double) WorldGen.genRand.Next(-20, 21) * 0.00999999977648258);
double num12 = (double) num10;
double num13 = num8 * num12;
float num14 = num9 * num11;
double num15 = Math.Sqrt(num13 * num13 + (double) num14 * (double) num14);
if (num15 < (double) num5 * 0.25)
{
Main.tile[index4, index5].active(false);
Main.tile[index4, index5].wall = (byte) 83;
}
else if (num15 < (double) num5 * 0.4 && Main.tile[index4, index5].wall != (byte) 83)
{
Main.tile[index4, index5].active(true);
Main.tile[index4, index5].type = (ushort) 203;
if (num15 < (double) num5 * 0.35)
Main.tile[index4, index5].wall = (byte) 83;
}
}
}
}
int length = WorldGen.genRand.Next(5, 9);
Vector2[] vector2Array = new Vector2[length];
for (int index6 = 0; index6 < length; ++index6)
{
int x = (int) position.X;
int y = (int) position.Y;
int num16 = 0;
bool flag2 = true;
Vector2 velocity = new Vector2((float) WorldGen.genRand.Next(-20, 21) * 0.15f, (float) WorldGen.genRand.Next(0, 21) * 0.15f);
while (flag2)
{
velocity = new Vector2((float) WorldGen.genRand.Next(-20, 21) * 0.15f, (float) WorldGen.genRand.Next(0, 21) * 0.15f);
while ((double) Math.Abs(velocity.X) + (double) Math.Abs(velocity.Y) < 1.5)
velocity = new Vector2((float) WorldGen.genRand.Next(-20, 21) * 0.15f, (float) WorldGen.genRand.Next(0, 21) * 0.15f);
flag2 = false;
for (int index7 = 0; index7 < index6; ++index7)
{
if ((double) vector2.X > (double) vector2Array[index7].X - 0.75 && (double) vector2.X < (double) vector2Array[index7].X + 0.75 && (double) vector2.Y > (double) vector2Array[index7].Y - 0.75 && (double) vector2.Y < (double) vector2Array[index7].Y + 0.75)
{
flag2 = true;
++num16;
break;
}
}
if (num16 > 10000)
break;
}
vector2Array[index6] = velocity;
WorldGen.CrimVein(new Vector2((float) x, (float) y), velocity);
}
for (int index8 = 0; index8 < WorldGen.heartCount; ++index8)
{
float num17 = (float) WorldGen.genRand.Next(16, 21);
int x = (int) WorldGen.heartPos[index8].X;
int y = (int) WorldGen.heartPos[index8].Y;
for (int index9 = (int) ((double) x - (double) num17 / 2.0); (double) index9 < (double) x + (double) num17 / 2.0; ++index9)
{
for (int index10 = (int) ((double) y - (double) num17 / 2.0); (double) index10 < (double) y + (double) num17 / 2.0; ++index10)
{
double num18 = (double) Math.Abs(index9 - x);
float num19 = (float) Math.Abs(index10 - y);
if (Math.Sqrt(num18 * num18 + (double) num19 * (double) num19) < (double) num17 * 0.4)
{
Main.tile[index9, index10].active(true);
Main.tile[index9, index10].type = (ushort) 203;
Main.tile[index9, index10].wall = (byte) 83;
}
}
}
}
for (int index11 = 0; index11 < WorldGen.heartCount; ++index11)
{
float num20 = (float) WorldGen.genRand.Next(10, 14);
int x = (int) WorldGen.heartPos[index11].X;
int y = (int) WorldGen.heartPos[index11].Y;
for (int index12 = (int) ((double) x - (double) num20 / 2.0); (double) index12 < (double) x + (double) num20 / 2.0; ++index12)
{
for (int index13 = (int) ((double) y - (double) num20 / 2.0); (double) index13 < (double) y + (double) num20 / 2.0; ++index13)
{
double num21 = (double) Math.Abs(index12 - x);
float num22 = (float) Math.Abs(index13 - y);
if (Math.Sqrt(num21 * num21 + (double) num22 * (double) num22) < (double) num20 * 0.3)
{
Main.tile[index12, index13].active(false);
Main.tile[index12, index13].wall = (byte) 83;
}
}
}
}
for (int index = 0; index < WorldGen.heartCount; ++index)
WorldGen.AddShadowOrb((int) WorldGen.heartPos[index].X, (int) WorldGen.heartPos[index].Y);
int num23 = Main.maxTilesX;
int num24 = 0;
position.X = (float) num1;
position.Y = (float) num2;
float num25 = (float) WorldGen.genRand.Next(25, 35);
float num26 = (float) WorldGen.genRand.Next(0, 6);
for (int index14 = 0; index14 < 50; ++index14)
{
if ((double) num26 > 0.0)
{
float num27 = (float) WorldGen.genRand.Next(10, 30) * 0.01f;
num26 -= num27;
position.Y -= num27;
}
int num28 = (int) position.X + WorldGen.genRand.Next(-2, 3);
int num29 = (int) position.Y + WorldGen.genRand.Next(-2, 3);
for (int index15 = (int) ((double) num28 - (double) num25 / 2.0); (double) index15 < (double) num28 + (double) num25 / 2.0; ++index15)
{
for (int index16 = (int) ((double) num29 - (double) num25 / 2.0); (double) index16 < (double) num29 + (double) num25 / 2.0; ++index16)
{
double num30 = (double) Math.Abs(index15 - num28);
float num31 = (float) Math.Abs(index16 - num29);
float num32 = (float) (1.0 + (double) WorldGen.genRand.Next(-20, 21) * 0.00499999988824129);
float num33 = (float) (1.0 + (double) WorldGen.genRand.Next(-20, 21) * 0.00499999988824129);
double num34 = (double) num32;
double num35 = num30 * num34;
float num36 = num31 * num33;
double num37 = Math.Sqrt(num35 * num35 + (double) num36 * (double) num36);
if (num37 < (double) num25 * 0.2 * ((double) WorldGen.genRand.Next(90, 111) * 0.01))
{
Main.tile[index15, index16].active(false);
Main.tile[index15, index16].wall = (byte) 83;
}
else if (num37 < (double) num25 * 0.45)
{
if (index15 < num23)
num23 = index15;
if (index15 > num24)
num24 = index15;
if (Main.tile[index15, index16].wall != (byte) 83)
{
Main.tile[index15, index16].active(true);
Main.tile[index15, index16].type = (ushort) 203;
if (num37 < (double) num25 * 0.35)
Main.tile[index15, index16].wall = (byte) 83;
}
}
}
}
}
for (int index17 = num23; index17 <= num24; ++index17)
{
int index18 = num2;
while (Main.tile[index17, index18].type == (ushort) 203 && Main.tile[index17, index18].active() || Main.tile[index17, index18].wall == (byte) 83)
++index18;
for (int index19 = WorldGen.genRand.Next(15, 20); !Main.tile[index17, index18].active() && index19 > 0 && Main.tile[index17, index18].wall != (byte) 83; ++index18)
{
--index19;
Main.tile[index17, index18].type = (ushort) 203;
Main.tile[index17, index18].active(true);
}
}
WorldGen.CrimEnt(position, crimDir);
}
public static void CrimEnt(Vector2 position, int crimDir)
{
float num1 = 0.0f;
float num2 = (float) WorldGen.genRand.Next(6, 11);
bool flag = true;
Vector2 vector2 = new Vector2(2f, (float) WorldGen.genRand.Next(-20, 0) * 0.01f);
vector2.X *= (float) -crimDir;
while (flag)
{
++num1;
if ((double) num1 >= 20.0)
flag = false;
num2 += (float) WorldGen.genRand.Next(-10, 11) * 0.02f;
if ((double) num2 < 6.0)
num2 = 6f;
if ((double) num2 > 10.0)
num2 = 10f;
for (int index1 = (int) ((double) position.X - (double) num2 / 2.0); (double) index1 < (double) position.X + (double) num2 / 2.0; ++index1)
{
for (int index2 = (int) ((double) position.Y - (double) num2 / 2.0); (double) index2 < (double) position.Y + (double) num2 / 2.0; ++index2)
{
double num3 = (double) Math.Abs((float) index1 - position.X);
float num4 = Math.Abs((float) index2 - position.Y);
if (Math.Sqrt(num3 * num3 + (double) num4 * (double) num4) < (double) num2 * 0.5 && Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 203)
{
Main.tile[index1, index2].active(false);
flag = true;
num1 = 0.0f;
}
}
}
position += vector2;
}
}
public static void CrimVein(Vector2 position, Vector2 velocity)
{
float num1 = (float) WorldGen.genRand.Next(15, 26);
bool flag = true;
Vector2 vector2_1 = velocity;
Vector2 vector2_2 = position;
int num2 = WorldGen.genRand.Next(100, 150);
if ((double) velocity.Y < 0.0)
num2 -= 25;
while (flag)
{
num1 += (float) WorldGen.genRand.Next(-50, 51) * 0.02f;
if ((double) num1 < 15.0)
num1 = 15f;
if ((double) num1 > 25.0)
num1 = 25f;
for (int index1 = (int) ((double) position.X - (double) num1 / 2.0); (double) index1 < (double) position.X + (double) num1 / 2.0; ++index1)
{
for (int index2 = (int) ((double) position.Y - (double) num1 / 2.0); (double) index2 < (double) position.Y + (double) num1 / 2.0; ++index2)
{
double num3 = (double) Math.Abs((float) index1 - position.X);
float num4 = Math.Abs((float) index2 - position.Y);
double num5 = Math.Sqrt(num3 * num3 + (double) num4 * (double) num4);
if (num5 < (double) num1 * 0.2)
{
Main.tile[index1, index2].active(false);
Main.tile[index1, index2].wall = (byte) 83;
}
else if (num5 < (double) num1 * 0.5 && Main.tile[index1, index2].wall != (byte) 83)
{
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].type = (ushort) 203;
if (num5 < (double) num1 * 0.4)
Main.tile[index1, index2].wall = (byte) 83;
}
}
}
velocity.X += (float) WorldGen.genRand.Next(-50, 51) * 0.05f;
velocity.Y += (float) WorldGen.genRand.Next(-50, 51) * 0.05f;
if ((double) velocity.Y < (double) vector2_1.Y - 0.75)
velocity.Y = vector2_1.Y - 0.75f;
if ((double) velocity.Y > (double) vector2_1.Y + 0.75)
velocity.Y = vector2_1.Y + 0.75f;
if ((double) velocity.X < (double) vector2_1.X - 0.75)
velocity.X = vector2_1.X - 0.75f;
if ((double) velocity.X > (double) vector2_1.X + 0.75)
velocity.X = vector2_1.X + 0.75f;
position += velocity;
if ((double) Math.Abs(position.X - vector2_2.X) + (double) Math.Abs(position.Y - vector2_2.Y) > (double) num2)
flag = false;
}
WorldGen.heartPos[WorldGen.heartCount] = position;
++WorldGen.heartCount;
}
public static void ChasmRunner(int i, int j, int steps, bool makeOrb = false)
{
bool flag1 = false;
bool flag2 = false;
bool flag3 = false;
if (!makeOrb)
flag2 = true;
float num1 = (float) steps;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) ((double) WorldGen.genRand.Next(11) * 0.200000002980232 + 0.5);
int num2 = 5;
double num3 = (double) (WorldGen.genRand.Next(5) + 7);
while (num3 > 0.0)
{
if ((double) num1 > 0.0)
{
num3 = num3 + (double) WorldGen.genRand.Next(3) - (double) WorldGen.genRand.Next(3);
if (num3 < 7.0)
num3 = 7.0;
if (num3 > 20.0)
num3 = 20.0;
if ((double) num1 == 1.0 && num3 < 10.0)
num3 = 10.0;
}
else if ((double) vector2_1.Y > Main.worldSurface + 45.0)
num3 -= (double) WorldGen.genRand.Next(4);
if ((double) vector2_1.Y > Main.rockLayer && (double) num1 > 0.0)
num1 = 0.0f;
--num1;
if (!flag1 && (double) vector2_1.Y > Main.worldSurface + 20.0)
{
flag1 = true;
WorldGen.ChasmRunnerSideways((int) vector2_1.X, (int) vector2_1.Y, -1, WorldGen.genRand.Next(20, 40));
WorldGen.ChasmRunnerSideways((int) vector2_1.X, (int) vector2_1.Y, 1, WorldGen.genRand.Next(20, 40));
}
if ((double) num1 > (double) num2)
{
int num4 = (int) ((double) vector2_1.X - num3 * 0.5);
int num5 = (int) ((double) vector2_1.X + num3 * 0.5);
int num6 = (int) ((double) vector2_1.Y - num3 * 0.5);
int num7 = (int) ((double) vector2_1.Y + num3 * 0.5);
if (num4 < 0)
num4 = 0;
if (num5 > Main.maxTilesX - 1)
num5 = Main.maxTilesX - 1;
if (num6 < 0)
num6 = 0;
if (num7 > Main.maxTilesY)
num7 = Main.maxTilesY;
for (int index1 = num4; index1 < num5; ++index1)
{
for (int index2 = num6; index2 < num7; ++index2)
{
if ((double) Math.Abs((float) index1 - vector2_1.X) + (double) Math.Abs((float) index2 - vector2_1.Y) < num3 * 0.5 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015) && Main.tile[index1, index2].type != (ushort) 31 && Main.tile[index1, index2].type != (ushort) 22)
Main.tile[index1, index2].active(false);
}
}
}
if ((double) num1 <= 2.0 && (double) vector2_1.Y < Main.worldSurface + 45.0)
num1 = 2f;
if ((double) num1 <= 0.0)
{
if (!flag2)
{
flag2 = true;
WorldGen.AddShadowOrb((int) vector2_1.X, (int) vector2_1.Y);
}
else if (!flag3)
{
flag3 = false;
bool flag4 = false;
int num8 = 0;
while (!flag4)
{
int x = WorldGen.genRand.Next((int) vector2_1.X - 25, (int) vector2_1.X + 25);
int y = WorldGen.genRand.Next((int) vector2_1.Y - 50, (int) vector2_1.Y);
if (x < 5)
x = 5;
if (x > Main.maxTilesX - 5)
x = Main.maxTilesX - 5;
if (y < 5)
y = 5;
if (y > Main.maxTilesY - 5)
y = Main.maxTilesY - 5;
if ((double) y > Main.worldSurface)
{
WorldGen.Place3x2(x, y, (ushort) 26);
if (Main.tile[x, y].type == (ushort) 26)
{
flag4 = true;
}
else
{
++num8;
if (num8 >= 10000)
flag4 = true;
}
}
else
flag4 = true;
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.01f;
if ((double) vector2_2.X > 0.3)
vector2_2.X = 0.3f;
if ((double) vector2_2.X < -0.3)
vector2_2.X = -0.3f;
int num9 = (int) ((double) vector2_1.X - num3 * 1.1);
int num10 = (int) ((double) vector2_1.X + num3 * 1.1);
int num11 = (int) ((double) vector2_1.Y - num3 * 1.1);
int num12 = (int) ((double) vector2_1.Y + num3 * 1.1);
if (num9 < 1)
num9 = 1;
if (num10 > Main.maxTilesX - 1)
num10 = Main.maxTilesX - 1;
if (num11 < 0)
num11 = 0;
if (num12 > Main.maxTilesY)
num12 = Main.maxTilesY;
for (int index3 = num9; index3 < num10; ++index3)
{
for (int index4 = num11; index4 < num12; ++index4)
{
if ((double) Math.Abs((float) index3 - vector2_1.X) + (double) Math.Abs((float) index4 - vector2_1.Y) < num3 * 1.1 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015))
{
if (Main.tile[index3, index4].type != (ushort) 25 && index4 > j + WorldGen.genRand.Next(3, 20))
Main.tile[index3, index4].active(true);
if (steps <= num2)
Main.tile[index3, index4].active(true);
if (Main.tile[index3, index4].type != (ushort) 31)
Main.tile[index3, index4].type = (ushort) 25;
}
}
}
for (int index5 = num9; index5 < num10; ++index5)
{
for (int index6 = num11; index6 < num12; ++index6)
{
if ((double) Math.Abs((float) index5 - vector2_1.X) + (double) Math.Abs((float) index6 - vector2_1.Y) < num3 * 1.1 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015))
{
if (Main.tile[index5, index6].type != (ushort) 31)
Main.tile[index5, index6].type = (ushort) 25;
if (steps <= num2)
Main.tile[index5, index6].active(true);
if (index6 > j + WorldGen.genRand.Next(3, 20))
Main.tile[index5, index6].wall = (byte) 3;
}
}
}
}
}
public static void JungleRunner(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(5, 11);
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(10, 20) * 0.1f;
int num2 = 0;
bool flag = true;
while (flag)
{
if ((double) vector2_1.Y < Main.worldSurface)
{
int x = (int) vector2_1.X;
int y = (int) vector2_1.Y;
int index1 = Utils.Clamp<int>(x, 10, Main.maxTilesX - 10);
int index2 = Utils.Clamp<int>(y, 10, Main.maxTilesY - 10);
if (index2 < 5)
index2 = 5;
if (Main.tile[index1, index2].wall == (byte) 0 && !Main.tile[index1, index2].active() && Main.tile[index1, index2 - 3].wall == (byte) 0 && !Main.tile[index1, index2 - 3].active() && Main.tile[index1, index2 - 1].wall == (byte) 0 && !Main.tile[index1, index2 - 1].active() && Main.tile[index1, index2 - 4].wall == (byte) 0 && !Main.tile[index1, index2 - 4].active() && Main.tile[index1, index2 - 2].wall == (byte) 0 && !Main.tile[index1, index2 - 2].active() && Main.tile[index1, index2 - 5].wall == (byte) 0 && !Main.tile[index1, index2 - 5].active())
flag = false;
}
WorldGen.JungleX = (int) vector2_1.X;
num1 += (double) WorldGen.genRand.Next(-20, 21) * 0.100000001490116;
if (num1 < 5.0)
num1 = 5.0;
if (num1 > 10.0)
num1 = 10.0;
int num3 = (int) ((double) vector2_1.X - num1 * 0.5);
int num4 = (int) ((double) vector2_1.X + num1 * 0.5);
int num5 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num6 = (int) ((double) vector2_1.Y + num1 * 0.5);
int max = Main.maxTilesX - 10;
int num7 = Utils.Clamp<int>(num3, 10, max);
int num8 = Utils.Clamp<int>(num4, 10, Main.maxTilesX - 10);
int num9 = Utils.Clamp<int>(num5, 10, Main.maxTilesY - 10);
int num10 = Utils.Clamp<int>(num6, 10, Main.maxTilesY - 10);
for (int i1 = num7; i1 < num8; ++i1)
{
for (int j1 = num9; j1 < num10; ++j1)
{
if ((double) Math.Abs((float) i1 - vector2_1.X) + (double) Math.Abs((float) j1 - vector2_1.Y) < num1 * 0.5 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015))
WorldGen.KillTile(i1, j1);
}
}
++num2;
if (num2 > 10 && WorldGen.genRand.Next(50) < num2)
{
num2 = 0;
int num11 = -2;
if (WorldGen.genRand.Next(2) == 0)
num11 = 2;
WorldGen.TileRunner((int) vector2_1.X, (int) vector2_1.Y, (double) WorldGen.genRand.Next(3, 20), WorldGen.genRand.Next(10, 100), -1, speedX: ((float) num11));
}
vector2_1 += vector2_2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.01f;
if ((double) vector2_2.Y > 0.0)
vector2_2.Y = 0.0f;
if ((double) vector2_2.Y < -2.0)
vector2_2.Y = -2f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
if ((double) vector2_1.X < (double) (i - 200))
vector2_2.X += (float) WorldGen.genRand.Next(5, 21) * 0.1f;
if ((double) vector2_1.X > (double) (i + 200))
vector2_2.X -= (float) WorldGen.genRand.Next(5, 21) * 0.1f;
if ((double) vector2_2.X > 1.5)
vector2_2.X = 1.5f;
if ((double) vector2_2.X < -1.5)
vector2_2.X = -1.5f;
}
}
public static void GERunner(int i, int j, float speedX = 0.0f, float speedY = 0.0f, bool good = true)
{
int num1 = (int) ((double) WorldGen.genRand.Next(200, 250) * (double) (Main.maxTilesX / 4200));
double num2 = (double) num1;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
if ((double) speedX != 0.0 || (double) speedY != 0.0)
{
vector2_2.X = speedX;
vector2_2.Y = speedY;
}
bool flag = true;
while (flag)
{
int num3 = (int) ((double) vector2_1.X - num2 * 0.5);
int num4 = (int) ((double) vector2_1.X + num2 * 0.5);
int num5 = (int) ((double) vector2_1.Y - num2 * 0.5);
int num6 = (int) ((double) vector2_1.Y + num2 * 0.5);
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesX)
num4 = Main.maxTilesX;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY;
for (int i1 = num3; i1 < num4; ++i1)
{
for (int j1 = num5; j1 < num6; ++j1)
{
if ((double) Math.Abs((float) i1 - vector2_1.X) + (double) Math.Abs((float) j1 - vector2_1.Y) < (double) num1 * 0.5 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015))
{
if (good)
{
if (Main.tile[i1, j1].wall == (byte) 63 || Main.tile[i1, j1].wall == (byte) 65 || Main.tile[i1, j1].wall == (byte) 66 || Main.tile[i1, j1].wall == (byte) 68 || Main.tile[i1, j1].wall == (byte) 69 || Main.tile[i1, j1].wall == (byte) 81)
Main.tile[i1, j1].wall = (byte) 70;
else if (Main.tile[i1, j1].wall == (byte) 216)
Main.tile[i1, j1].wall = (byte) 219;
else if (Main.tile[i1, j1].wall == (byte) 187)
Main.tile[i1, j1].wall = (byte) 222;
if (Main.tile[i1, j1].wall == (byte) 3 || Main.tile[i1, j1].wall == (byte) 83)
Main.tile[i1, j1].wall = (byte) 28;
if (Main.tile[i1, j1].type == (ushort) 2)
{
Main.tile[i1, j1].type = (ushort) 109;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 1)
{
Main.tile[i1, j1].type = (ushort) 117;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 53 || Main.tile[i1, j1].type == (ushort) 123)
{
Main.tile[i1, j1].type = (ushort) 116;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 23 || Main.tile[i1, j1].type == (ushort) 199)
{
Main.tile[i1, j1].type = (ushort) 109;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 25 || Main.tile[i1, j1].type == (ushort) 203)
{
Main.tile[i1, j1].type = (ushort) 117;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 112 || Main.tile[i1, j1].type == (ushort) 234)
{
Main.tile[i1, j1].type = (ushort) 116;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 161 || Main.tile[i1, j1].type == (ushort) 163 || Main.tile[i1, j1].type == (ushort) 200)
{
Main.tile[i1, j1].type = (ushort) 164;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 396)
{
Main.tile[i1, j1].type = (ushort) 403;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 397)
{
Main.tile[i1, j1].type = (ushort) 402;
WorldGen.SquareTileFrame(i1, j1);
}
}
else if (WorldGen.crimson)
{
if (Main.tile[i1, j1].wall == (byte) 63 || Main.tile[i1, j1].wall == (byte) 65 || Main.tile[i1, j1].wall == (byte) 66 || Main.tile[i1, j1].wall == (byte) 68)
Main.tile[i1, j1].wall = (byte) 81;
else if (Main.tile[i1, j1].wall == (byte) 216)
Main.tile[i1, j1].wall = (byte) 218;
else if (Main.tile[i1, j1].wall == (byte) 187)
Main.tile[i1, j1].wall = (byte) 221;
if (Main.tile[i1, j1].type == (ushort) 2)
{
Main.tile[i1, j1].type = (ushort) 199;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 1)
{
Main.tile[i1, j1].type = (ushort) 203;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 53 || Main.tile[i1, j1].type == (ushort) 123)
{
Main.tile[i1, j1].type = (ushort) 234;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 109)
{
Main.tile[i1, j1].type = (ushort) 199;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 117)
{
Main.tile[i1, j1].type = (ushort) 203;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 116)
{
Main.tile[i1, j1].type = (ushort) 234;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 161 || Main.tile[i1, j1].type == (ushort) 164)
{
Main.tile[i1, j1].type = (ushort) 200;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 396)
{
Main.tile[i1, j1].type = (ushort) 401;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 397)
{
Main.tile[i1, j1].type = (ushort) 399;
WorldGen.SquareTileFrame(i1, j1);
}
}
else
{
if (Main.tile[i1, j1].wall == (byte) 63 || Main.tile[i1, j1].wall == (byte) 65 || Main.tile[i1, j1].wall == (byte) 66 || Main.tile[i1, j1].wall == (byte) 68)
Main.tile[i1, j1].wall = (byte) 69;
else if (Main.tile[i1, j1].wall == (byte) 216)
Main.tile[i1, j1].wall = (byte) 217;
else if (Main.tile[i1, j1].wall == (byte) 187)
Main.tile[i1, j1].wall = (byte) 220;
if (Main.tile[i1, j1].type == (ushort) 2)
{
Main.tile[i1, j1].type = (ushort) 23;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 1)
{
Main.tile[i1, j1].type = (ushort) 25;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 53 || Main.tile[i1, j1].type == (ushort) 123)
{
Main.tile[i1, j1].type = (ushort) 112;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 109)
{
Main.tile[i1, j1].type = (ushort) 23;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 117)
{
Main.tile[i1, j1].type = (ushort) 25;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 116)
{
Main.tile[i1, j1].type = (ushort) 112;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 161 || Main.tile[i1, j1].type == (ushort) 164)
{
Main.tile[i1, j1].type = (ushort) 163;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 396)
{
Main.tile[i1, j1].type = (ushort) 400;
WorldGen.SquareTileFrame(i1, j1);
}
else if (Main.tile[i1, j1].type == (ushort) 397)
{
Main.tile[i1, j1].type = (ushort) 398;
WorldGen.SquareTileFrame(i1, j1);
}
}
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > (double) speedX + 1.0)
vector2_2.X = speedX + 1f;
if ((double) vector2_2.X < (double) speedX - 1.0)
vector2_2.X = speedX - 1f;
if ((double) vector2_1.X < (double) -num1 || (double) vector2_1.Y < (double) -num1 || (double) vector2_1.X > (double) (Main.maxTilesX + num1) || (double) vector2_1.Y > (double) (Main.maxTilesX + num1))
flag = false;
}
}
public static void TileRunner(
int i,
int j,
double strength,
int steps,
int type,
bool addTile = false,
float speedX = 0.0f,
float speedY = 0.0f,
bool noYChange = false,
bool overRide = true)
{
double num1 = strength;
float num2 = (float) steps;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
if ((double) speedX != 0.0 || (double) speedY != 0.0)
{
vector2_2.X = speedX;
vector2_2.Y = speedY;
}
bool flag1 = type == 368;
bool flag2 = type == 367;
while (num1 > 0.0 && (double) num2 > 0.0)
{
if ((double) vector2_1.Y < 0.0 && (double) num2 > 0.0 && type == 59)
num2 = 0.0f;
num1 = strength * ((double) num2 / (double) steps);
--num2;
int num3 = (int) ((double) vector2_1.X - num1 * 0.5);
int num4 = (int) ((double) vector2_1.X + num1 * 0.5);
int num5 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num6 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num3 < 1)
num3 = 1;
if (num4 > Main.maxTilesX - 1)
num4 = Main.maxTilesX - 1;
if (num5 < 1)
num5 = 1;
if (num6 > Main.maxTilesY - 1)
num6 = Main.maxTilesY - 1;
for (int i1 = num3; i1 < num4; ++i1)
{
for (int j1 = num5; j1 < num6; ++j1)
{
if ((double) Math.Abs((float) i1 - vector2_1.X) + (double) Math.Abs((float) j1 - vector2_1.Y) < strength * 0.5 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015))
{
if (WorldGen.mudWall && (double) j1 > Main.worldSurface && Main.tile[i1, j1 - 1].wall != (byte) 2 && j1 < Main.maxTilesY - 210 - WorldGen.genRand.Next(3))
{
if (j1 > WorldGen.lavaLine - WorldGen.genRand.Next(0, 4) - 50)
{
if (Main.tile[i1, j1 - 1].wall != (byte) 64 && Main.tile[i1, j1 + 1].wall != (byte) 64 && Main.tile[i1 - 1, j1].wall != (byte) 64 && Main.tile[i1, j1 + 1].wall != (byte) 64)
WorldGen.PlaceWall(i1, j1, 15, true);
}
else if (Main.tile[i1, j1 - 1].wall != (byte) 15 && Main.tile[i1, j1 + 1].wall != (byte) 15 && Main.tile[i1 - 1, j1].wall != (byte) 15 && Main.tile[i1, j1 + 1].wall != (byte) 15)
WorldGen.PlaceWall(i1, j1, 64, true);
}
if (type < 0)
{
if (type == -2 && Main.tile[i1, j1].active() && (j1 < WorldGen.waterLine || j1 > WorldGen.lavaLine))
{
Main.tile[i1, j1].liquid = byte.MaxValue;
if (j1 > WorldGen.lavaLine)
Main.tile[i1, j1].lava(true);
}
Main.tile[i1, j1].active(false);
}
else
{
if (flag1 && (double) Math.Abs((float) i1 - vector2_1.X) + (double) Math.Abs((float) j1 - vector2_1.Y) < strength * 0.3 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.01))
WorldGen.PlaceWall(i1, j1, 180, true);
if (flag2 && (double) Math.Abs((float) i1 - vector2_1.X) + (double) Math.Abs((float) j1 - vector2_1.Y) < strength * 0.3 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.01))
WorldGen.PlaceWall(i1, j1, 178, true);
if (overRide || !Main.tile[i1, j1].active())
{
Tile tile = Main.tile[i1, j1];
bool flag3 = Main.tileStone[type] && tile.type != (ushort) 1;
if (!TileID.Sets.CanBeClearedDuringGeneration[(int) tile.type])
flag3 = true;
switch (tile.type)
{
case 1:
if (type == 59 && (double) j1 < Main.worldSurface + (double) WorldGen.genRand.Next(-50, 50))
{
flag3 = true;
break;
}
break;
case 45:
case 147:
case 189:
case 190:
case 196:
flag3 = true;
break;
case 53:
if (type == 40)
flag3 = true;
if ((double) j1 < Main.worldSurface && type != 59)
{
flag3 = true;
break;
}
break;
case 367:
case 368:
if (type == 59)
{
flag3 = true;
break;
}
break;
case 396:
case 397:
flag3 = !TileID.Sets.Ore[type];
break;
}
if (!flag3)
tile.type = (ushort) type;
}
if (addTile)
{
Main.tile[i1, j1].active(true);
Main.tile[i1, j1].liquid = (byte) 0;
Main.tile[i1, j1].lava(false);
}
if (noYChange && (double) j1 < Main.worldSurface && type != 59)
Main.tile[i1, j1].wall = (byte) 2;
if (type == 59 && j1 > WorldGen.waterLine && Main.tile[i1, j1].liquid > (byte) 0)
{
Main.tile[i1, j1].lava(false);
Main.tile[i1, j1].liquid = (byte) 0;
}
}
}
}
}
vector2_1 += vector2_2;
if (num1 > 50.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 100.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 150.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 200.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 250.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 300.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 400.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 500.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 600.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 700.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 800.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if (num1 > 900.0)
{
vector2_1 += vector2_2;
--num2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
}
}
}
}
}
}
}
}
}
}
}
}
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
if (!noYChange)
{
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.Y > 1.0)
vector2_2.Y = 1f;
if ((double) vector2_2.Y < -1.0)
vector2_2.Y = -1f;
}
else if (type != 59 && num1 < 3.0)
{
if ((double) vector2_2.Y > 1.0)
vector2_2.Y = 1f;
if ((double) vector2_2.Y < -1.0)
vector2_2.Y = -1f;
}
if (type == 59 && !noYChange)
{
if ((double) vector2_2.Y > 0.5)
vector2_2.Y = 0.5f;
if ((double) vector2_2.Y < -0.5)
vector2_2.Y = -0.5f;
if ((double) vector2_1.Y < Main.rockLayer + 100.0)
vector2_2.Y = 1f;
if ((double) vector2_1.Y > (double) (Main.maxTilesY - 300))
vector2_2.Y = -1f;
}
}
}
public static void DirtyRockRunner(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(2, 6);
float num2 = (float) WorldGen.genRand.Next(5, 50);
float num3 = num2;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
while (num1 > 0.0 && (double) num3 > 0.0)
{
double num4 = num1 * ((double) num3 / (double) num2);
--num3;
int num5 = (int) ((double) vector2_1.X - num4 * 0.5);
int num6 = (int) ((double) vector2_1.X + num4 * 0.5);
int num7 = (int) ((double) vector2_1.Y - num4 * 0.5);
int num8 = (int) ((double) vector2_1.Y + num4 * 0.5);
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesX)
num6 = Main.maxTilesX;
if (num7 < 0)
num7 = 0;
if (num8 > Main.maxTilesY)
num8 = Main.maxTilesY;
for (int index1 = num5; index1 < num6; ++index1)
{
for (int index2 = num7; index2 < num8; ++index2)
{
if ((double) Math.Abs((float) index1 - vector2_1.X) + (double) Math.Abs((float) index2 - vector2_1.Y) < num1 * 0.5 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015) && Main.tile[index1, index2].wall == (byte) 2)
Main.tile[index1, index2].wall = (byte) 59;
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.Y > 1.0)
vector2_2.Y = 1f;
if ((double) vector2_2.Y < -1.0)
vector2_2.Y = -1f;
}
}
public static void MudWallRunner(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(8, 21);
float num2 = (float) WorldGen.genRand.Next(8, 33);
float num3 = num2;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
while (num1 > 0.0 && (double) num3 > 0.0)
{
double num4 = num1 * ((double) num3 / (double) num2);
--num3;
int num5 = (int) ((double) vector2_1.X - num4 * 0.5);
int num6 = (int) ((double) vector2_1.X + num4 * 0.5);
int num7 = (int) ((double) vector2_1.Y - num4 * 0.5);
int num8 = (int) ((double) vector2_1.Y + num4 * 0.5);
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesX)
num6 = Main.maxTilesX;
if (num7 < 0)
num7 = 0;
if (num8 > Main.maxTilesY)
num8 = Main.maxTilesY;
for (int index1 = num5; index1 < num6; ++index1)
{
for (int index2 = num7; index2 < num8; ++index2)
{
if ((double) Math.Abs((float) index1 - vector2_1.X) + (double) Math.Abs((float) index2 - vector2_1.Y) < num1 * 0.5 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.015) && (double) index2 > Main.worldSurface)
Main.tile[index1, index2].wall = (byte) 0;
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.Y > 1.0)
vector2_2.Y = 1f;
if ((double) vector2_2.Y < -1.0)
vector2_2.Y = -1f;
}
}
public static void CloudIsland(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(100, 150);
double num2 = num1;
float num3 = (float) WorldGen.genRand.Next(20, 30);
int num4 = i;
int num5 = i;
int num6 = i;
int num7 = j;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
while ((double) vector2_2.X > -2.0 && (double) vector2_2.X < 2.0)
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
vector2_2.Y = (float) WorldGen.genRand.Next(-20, -10) * 0.02f;
while (num1 > 0.0 && (double) num3 > 0.0)
{
num1 -= (double) WorldGen.genRand.Next(4);
--num3;
int num8 = (int) ((double) vector2_1.X - num1 * 0.5);
int num9 = (int) ((double) vector2_1.X + num1 * 0.5);
int num10 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num11 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num8 < 0)
num8 = 0;
if (num9 > Main.maxTilesX)
num9 = Main.maxTilesX;
if (num10 < 0)
num10 = 0;
if (num11 > Main.maxTilesY)
num11 = Main.maxTilesY;
double num12 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
float num13 = vector2_1.Y + 1f;
for (int i1 = num8; i1 < num9; ++i1)
{
if (WorldGen.genRand.Next(2) == 0)
num13 += (float) WorldGen.genRand.Next(-1, 2);
if ((double) num13 < (double) vector2_1.Y)
num13 = vector2_1.Y;
if ((double) num13 > (double) vector2_1.Y + 2.0)
num13 = vector2_1.Y + 2f;
for (int j1 = num10; j1 < num11; ++j1)
{
if ((double) j1 > (double) num13)
{
double num14 = (double) Math.Abs((float) i1 - vector2_1.X);
float num15 = Math.Abs((float) j1 - vector2_1.Y) * 3f;
if (Math.Sqrt(num14 * num14 + (double) num15 * (double) num15) < num12 * 0.4)
{
if (i1 < num4)
num4 = i1;
if (i1 > num5)
num5 = i1;
if (j1 < num6)
num6 = j1;
if (j1 > num7)
num7 = j1;
Main.tile[i1, j1].active(true);
Main.tile[i1, j1].type = (ushort) 189;
WorldGen.SquareTileFrame(i1, j1);
}
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-20, 21) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
if ((double) vector2_2.Y > 0.2)
vector2_2.Y = -0.2f;
if ((double) vector2_2.Y < -0.2)
vector2_2.Y = -0.2f;
}
int minValue1;
for (int index1 = num4 + WorldGen.genRand.Next(5); index1 < num5; index1 += WorldGen.genRand.Next(minValue1, (int) ((double) minValue1 * 1.5)))
{
int index2 = num7;
while (!Main.tile[index1, index2].active())
--index2;
int num16 = index2 + WorldGen.genRand.Next(-3, 4);
minValue1 = WorldGen.genRand.Next(4, 8);
int num17 = 189;
if (WorldGen.genRand.Next(4) == 0)
num17 = 196;
for (int i2 = index1 - minValue1; i2 <= index1 + minValue1; ++i2)
{
for (int j2 = num16 - minValue1; j2 <= num16 + minValue1; ++j2)
{
if (j2 > num6)
{
double num18 = (double) Math.Abs(i2 - index1);
float num19 = (float) (Math.Abs(j2 - num16) * 2);
if (Math.Sqrt(num18 * num18 + (double) num19 * (double) num19) < (double) (minValue1 + WorldGen.genRand.Next(2)))
{
Main.tile[i2, j2].active(true);
Main.tile[i2, j2].type = (ushort) num17;
WorldGen.SquareTileFrame(i2, j2);
}
}
}
}
}
double num20 = (double) WorldGen.genRand.Next(80, 95);
num2 = num20;
float num21 = (float) WorldGen.genRand.Next(10, 15);
vector2_1.X = (float) i;
vector2_1.Y = (float) num6;
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
while ((double) vector2_2.X > -2.0 && (double) vector2_2.X < 2.0)
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
vector2_2.Y = (float) WorldGen.genRand.Next(-20, -10) * 0.02f;
while (num20 > 0.0 && (double) num21 > 0.0)
{
num20 -= (double) WorldGen.genRand.Next(4);
--num21;
int num22 = (int) ((double) vector2_1.X - num20 * 0.5);
int num23 = (int) ((double) vector2_1.X + num20 * 0.5);
int num24 = num6 - 1;
int num25 = (int) ((double) vector2_1.Y + num20 * 0.5);
if (num22 < 0)
num22 = 0;
if (num23 > Main.maxTilesX)
num23 = Main.maxTilesX;
if (num24 < 0)
num24 = 0;
if (num25 > Main.maxTilesY)
num25 = Main.maxTilesY;
double num26 = num20 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
float num27 = vector2_1.Y + 1f;
for (int i3 = num22; i3 < num23; ++i3)
{
if (WorldGen.genRand.Next(2) == 0)
num27 += (float) WorldGen.genRand.Next(-1, 2);
if ((double) num27 < (double) vector2_1.Y)
num27 = vector2_1.Y;
if ((double) num27 > (double) vector2_1.Y + 2.0)
num27 = vector2_1.Y + 2f;
for (int j3 = num24; j3 < num25; ++j3)
{
if ((double) j3 > (double) num27)
{
double num28 = (double) Math.Abs((float) i3 - vector2_1.X);
float num29 = Math.Abs((float) j3 - vector2_1.Y) * 3f;
if (Math.Sqrt(num28 * num28 + (double) num29 * (double) num29) < num26 * 0.4 && Main.tile[i3, j3].type == (ushort) 189)
{
Main.tile[i3, j3].type = (ushort) 0;
WorldGen.SquareTileFrame(i3, j3);
}
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-20, 21) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
if ((double) vector2_2.Y > 0.2)
vector2_2.Y = -0.2f;
if ((double) vector2_2.Y < -0.2)
vector2_2.Y = -0.2f;
}
int index3 = num4 + WorldGen.genRand.Next(5);
while (index3 < num5)
{
int index4 = num7;
while ((!Main.tile[index3, index4].active() || Main.tile[index3, index4].type != (ushort) 0) && index3 < num5)
{
--index4;
if (index4 < num6)
{
index4 = num7;
index3 += WorldGen.genRand.Next(1, 4);
}
}
if (index3 < num5)
{
int num30 = index4 + WorldGen.genRand.Next(0, 4);
int minValue2 = WorldGen.genRand.Next(2, 5);
int num31 = 189;
for (int i4 = index3 - minValue2; i4 <= index3 + minValue2; ++i4)
{
for (int j4 = num30 - minValue2; j4 <= num30 + minValue2; ++j4)
{
if (j4 > num6)
{
double num32 = (double) Math.Abs(i4 - index3);
float num33 = (float) (Math.Abs(j4 - num30) * 2);
if (Math.Sqrt(num32 * num32 + (double) num33 * (double) num33) < (double) minValue2)
{
Main.tile[i4, j4].type = (ushort) num31;
WorldGen.SquareTileFrame(i4, j4);
}
}
}
}
index3 += WorldGen.genRand.Next(minValue2, (int) ((double) minValue2 * 1.5));
}
}
for (int i5 = num4 - 20; i5 <= num5 + 20; ++i5)
{
for (int j5 = num6 - 20; j5 <= num7 + 20; ++j5)
{
bool flag = true;
for (int index5 = i5 - 1; index5 <= i5 + 1; ++index5)
{
for (int index6 = j5 - 1; index6 <= j5 + 1; ++index6)
{
if (!Main.tile[index5, index6].active())
flag = false;
}
}
if (flag)
{
Main.tile[i5, j5].wall = (byte) 73;
WorldGen.SquareWallFrame(i5, j5);
}
}
}
for (int i6 = num4; i6 <= num5; ++i6)
{
int j6 = num6 - 10;
while (!Main.tile[i6, j6 + 1].active())
++j6;
if (j6 < num7 && Main.tile[i6, j6 + 1].type == (ushort) 189)
{
if (WorldGen.genRand.Next(10) == 0)
{
int num34 = WorldGen.genRand.Next(1, 3);
for (int index7 = i6 - num34; index7 <= i6 + num34; ++index7)
{
if (Main.tile[index7, j6].type == (ushort) 189)
{
Main.tile[index7, j6].active(false);
Main.tile[index7, j6].liquid = byte.MaxValue;
Main.tile[index7, j6].lava(false);
WorldGen.SquareTileFrame(i6, j6);
}
if (Main.tile[index7, j6 + 1].type == (ushort) 189)
{
Main.tile[index7, j6 + 1].active(false);
Main.tile[index7, j6 + 1].liquid = byte.MaxValue;
Main.tile[index7, j6 + 1].lava(false);
WorldGen.SquareTileFrame(i6, j6 + 1);
}
if (index7 > i6 - num34 && index7 < i6 + 2 && Main.tile[index7, j6 + 2].type == (ushort) 189)
{
Main.tile[index7, j6 + 2].active(false);
Main.tile[index7, j6 + 2].liquid = byte.MaxValue;
Main.tile[index7, j6 + 2].lava(false);
WorldGen.SquareTileFrame(i6, j6 + 2);
}
}
}
if (WorldGen.genRand.Next(5) == 0)
Main.tile[i6, j6].liquid = byte.MaxValue;
Main.tile[i6, j6].lava(false);
WorldGen.SquareTileFrame(i6, j6);
}
}
int num35 = WorldGen.genRand.Next(4);
for (int index8 = 0; index8 <= num35; ++index8)
{
int num36 = WorldGen.genRand.Next(num4 - 5, num5 + 5);
int num37 = num6 - WorldGen.genRand.Next(20, 40);
int num38 = WorldGen.genRand.Next(4, 8);
int num39 = 189;
if (WorldGen.genRand.Next(2) == 0)
num39 = 196;
for (int i7 = num36 - num38; i7 <= num36 + num38; ++i7)
{
for (int j7 = num37 - num38; j7 <= num37 + num38; ++j7)
{
double num40 = (double) Math.Abs(i7 - num36);
float num41 = (float) (Math.Abs(j7 - num37) * 2);
if (Math.Sqrt(num40 * num40 + (double) num41 * (double) num41) < (double) (num38 + WorldGen.genRand.Next(-1, 2)))
{
Main.tile[i7, j7].active(true);
Main.tile[i7, j7].type = (ushort) num39;
WorldGen.SquareTileFrame(i7, j7);
}
}
}
for (int i8 = num36 - num38 + 2; i8 <= num36 + num38 - 2; ++i8)
{
int j8 = num37 - num38;
while (!Main.tile[i8, j8].active())
++j8;
Main.tile[i8, j8].active(false);
Main.tile[i8, j8].liquid = byte.MaxValue;
WorldGen.SquareTileFrame(i8, j8);
}
}
}
public static void CloudLake(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(100, 150);
double num2 = num1;
float num3 = (float) WorldGen.genRand.Next(20, 30);
int num4 = i;
int num5 = i;
int num6 = i;
int num7 = j;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
while ((double) vector2_2.X > -2.0 && (double) vector2_2.X < 2.0)
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
vector2_2.Y = (float) WorldGen.genRand.Next(-20, -10) * 0.02f;
while (num1 > 0.0 && (double) num3 > 0.0)
{
num1 -= (double) WorldGen.genRand.Next(4);
--num3;
int num8 = (int) ((double) vector2_1.X - num1 * 0.5);
int num9 = (int) ((double) vector2_1.X + num1 * 0.5);
int num10 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num11 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num8 < 0)
num8 = 0;
if (num9 > Main.maxTilesX)
num9 = Main.maxTilesX;
if (num10 < 0)
num10 = 0;
if (num11 > Main.maxTilesY)
num11 = Main.maxTilesY;
double num12 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
float num13 = vector2_1.Y + 1f;
for (int i1 = num8; i1 < num9; ++i1)
{
if (WorldGen.genRand.Next(2) == 0)
num13 += (float) WorldGen.genRand.Next(-1, 2);
if ((double) num13 < (double) vector2_1.Y)
num13 = vector2_1.Y;
if ((double) num13 > (double) vector2_1.Y + 2.0)
num13 = vector2_1.Y + 2f;
for (int j1 = num10; j1 < num11; ++j1)
{
if ((double) j1 > (double) num13)
{
double num14 = (double) Math.Abs((float) i1 - vector2_1.X);
float num15 = Math.Abs((float) j1 - vector2_1.Y) * 3f;
if (Math.Sqrt(num14 * num14 + (double) num15 * (double) num15) < num12 * 0.4)
{
if (i1 < num4)
num4 = i1;
if (i1 > num5)
num5 = i1;
if (j1 < num6)
num6 = j1;
if (j1 > num7)
num7 = j1;
Main.tile[i1, j1].active(true);
Main.tile[i1, j1].type = (ushort) 189;
WorldGen.SquareTileFrame(i1, j1);
}
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-20, 21) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
if ((double) vector2_2.Y > 0.2)
vector2_2.Y = -0.2f;
if ((double) vector2_2.Y < -0.2)
vector2_2.Y = -0.2f;
}
int minValue;
for (int index1 = num4 + WorldGen.genRand.Next(5); index1 < num5; index1 += WorldGen.genRand.Next(minValue, (int) ((double) minValue * 1.5)))
{
int index2 = num7;
while (!Main.tile[index1, index2].active())
--index2;
int num16 = index2 + WorldGen.genRand.Next(-3, 4);
minValue = WorldGen.genRand.Next(4, 8);
int num17 = 189;
if (WorldGen.genRand.Next(4) == 0)
num17 = 196;
for (int i2 = index1 - minValue; i2 <= index1 + minValue; ++i2)
{
for (int j2 = num16 - minValue; j2 <= num16 + minValue; ++j2)
{
if (j2 > num6)
{
double num18 = (double) Math.Abs(i2 - index1);
float num19 = (float) (Math.Abs(j2 - num16) * 2);
if (Math.Sqrt(num18 * num18 + (double) num19 * (double) num19) < (double) (minValue + WorldGen.genRand.Next(2)))
{
Main.tile[i2, j2].active(true);
Main.tile[i2, j2].type = (ushort) num17;
WorldGen.SquareTileFrame(i2, j2);
}
}
}
}
}
double num20 = (double) WorldGen.genRand.Next(80, 95);
num2 = num20;
float num21 = (float) WorldGen.genRand.Next(10, 15);
vector2_1.X = (float) i;
vector2_1.Y = (float) num6;
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
while ((double) vector2_2.X > -2.0 && (double) vector2_2.X < 2.0)
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
vector2_2.Y = (float) WorldGen.genRand.Next(-20, -10) * 0.02f;
while (num20 > 0.0 && (double) num21 > 0.0)
{
num20 -= (double) WorldGen.genRand.Next(4);
--num21;
int num22 = (int) ((double) vector2_1.X - num20 * 0.5);
int num23 = (int) ((double) vector2_1.X + num20 * 0.5);
int num24 = num6 - 1;
int num25 = (int) ((double) vector2_1.Y + num20 * 0.5);
if (num22 < 0)
num22 = 0;
if (num23 > Main.maxTilesX)
num23 = Main.maxTilesX;
if (num24 < 0)
num24 = 0;
if (num25 > Main.maxTilesY)
num25 = Main.maxTilesY;
double num26 = num20 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
float num27 = vector2_1.Y + 1f;
for (int index3 = num22; index3 < num23; ++index3)
{
if (WorldGen.genRand.Next(2) == 0)
num27 += (float) WorldGen.genRand.Next(-1, 2);
if ((double) num27 < (double) vector2_1.Y)
num27 = vector2_1.Y;
if ((double) num27 > (double) vector2_1.Y + 2.0)
num27 = vector2_1.Y + 2f;
for (int index4 = num24; index4 < num25; ++index4)
{
if ((double) index4 > (double) num27)
{
double num28 = (double) Math.Abs((float) index3 - vector2_1.X);
float num29 = Math.Abs((float) index4 - vector2_1.Y) * 3f;
if (Math.Sqrt(num28 * num28 + (double) num29 * (double) num29) < num26 * 0.4 && Main.tile[index3, index4].type == (ushort) 189)
{
Main.tile[index3, index4].active(false);
Main.tile[index3, index4].liquid = byte.MaxValue;
Main.tile[index3, index4].honey(false);
Main.tile[index3, index4].lava(false);
}
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-20, 21) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
if ((double) vector2_2.Y > 0.2)
vector2_2.Y = -0.2f;
if ((double) vector2_2.Y < -0.2)
vector2_2.Y = -0.2f;
}
for (int index5 = num4 - 20; index5 <= num5 + 20; ++index5)
{
for (int index6 = num6 - 20; index6 <= num7 + 20; ++index6)
{
bool flag = true;
for (int index7 = index5 - 1; index7 <= index5 + 1; ++index7)
{
for (int index8 = index6 - 1; index8 <= index6 + 1; ++index8)
{
if (!Main.tile[index7, index8].active())
flag = false;
}
}
if (flag)
Main.tile[index5, index6].wall = (byte) 73;
}
}
for (int i3 = num4; i3 <= num5; ++i3)
{
int j3 = num6 - 10;
while (!Main.tile[i3, j3 + 1].active())
++j3;
if (j3 < num7 && Main.tile[i3, j3 + 1].type == (ushort) 189)
{
if (WorldGen.genRand.Next(10) == 0)
{
int num30 = WorldGen.genRand.Next(1, 3);
for (int index = i3 - num30; index <= i3 + num30; ++index)
{
if (Main.tile[index, j3].type == (ushort) 189)
{
Main.tile[index, j3].active(false);
Main.tile[index, j3].liquid = byte.MaxValue;
Main.tile[index, j3].lava(false);
WorldGen.SquareTileFrame(i3, j3);
}
if (Main.tile[index, j3 + 1].type == (ushort) 189)
{
Main.tile[index, j3 + 1].active(false);
Main.tile[index, j3 + 1].liquid = byte.MaxValue;
Main.tile[index, j3 + 1].lava(false);
WorldGen.SquareTileFrame(i3, j3 + 1);
}
if (index > i3 - num30 && index < i3 + 2 && Main.tile[index, j3 + 2].type == (ushort) 189)
{
Main.tile[index, j3 + 2].active(false);
Main.tile[index, j3 + 2].liquid = byte.MaxValue;
Main.tile[index, j3 + 2].lava(false);
WorldGen.SquareTileFrame(i3, j3 + 2);
}
}
}
if (WorldGen.genRand.Next(5) == 0)
Main.tile[i3, j3].liquid = byte.MaxValue;
Main.tile[i3, j3].lava(false);
WorldGen.SquareTileFrame(i3, j3);
}
}
int num31 = WorldGen.genRand.Next(1, 4);
for (int index = 0; index <= num31; ++index)
{
int num32 = WorldGen.genRand.Next(num4 - 5, num5 + 5);
int num33 = num6 - WorldGen.genRand.Next(20, 40);
int num34 = WorldGen.genRand.Next(4, 8);
int num35 = 189;
if (WorldGen.genRand.Next(4) != 0)
num35 = 196;
for (int i4 = num32 - num34; i4 <= num32 + num34; ++i4)
{
for (int j4 = num33 - num34; j4 <= num33 + num34; ++j4)
{
double num36 = (double) Math.Abs(i4 - num32);
float num37 = (float) (Math.Abs(j4 - num33) * 2);
if (Math.Sqrt(num36 * num36 + (double) num37 * (double) num37) < (double) (num34 + WorldGen.genRand.Next(-1, 2)))
{
Main.tile[i4, j4].active(true);
Main.tile[i4, j4].type = (ushort) num35;
WorldGen.SquareTileFrame(i4, j4);
}
}
}
for (int i5 = num32 - num34 + 2; i5 <= num32 + num34 - 2; ++i5)
{
int j5 = num33 - num34;
while (!Main.tile[i5, j5].active())
++j5;
Main.tile[i5, j5].active(false);
Main.tile[i5, j5].liquid = byte.MaxValue;
WorldGen.SquareTileFrame(i5, j5);
}
}
}
public static void FloatingIsland(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(80, 120);
float num2 = (float) WorldGen.genRand.Next(20, 25);
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
while ((double) vector2_2.X > -2.0 && (double) vector2_2.X < 2.0)
vector2_2.X = (float) WorldGen.genRand.Next(-20, 21) * 0.2f;
vector2_2.Y = (float) WorldGen.genRand.Next(-20, -10) * 0.02f;
while (num1 > 0.0 && (double) num2 > 0.0)
{
num1 -= (double) WorldGen.genRand.Next(4);
--num2;
int num3 = (int) ((double) vector2_1.X - num1 * 0.5);
int num4 = (int) ((double) vector2_1.X + num1 * 0.5);
int num5 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num6 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesX)
num4 = Main.maxTilesX;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY;
double num7 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
float num8 = vector2_1.Y + 1f;
for (int index1 = num3; index1 < num4; ++index1)
{
if (WorldGen.genRand.Next(2) == 0)
num8 += (float) WorldGen.genRand.Next(-1, 2);
if ((double) num8 < (double) vector2_1.Y)
num8 = vector2_1.Y;
if ((double) num8 > (double) vector2_1.Y + 2.0)
num8 = vector2_1.Y + 2f;
for (int index2 = num5; index2 < num6; ++index2)
{
if ((double) index2 > (double) num8)
{
double num9 = (double) Math.Abs((float) index1 - vector2_1.X);
float num10 = Math.Abs((float) index2 - vector2_1.Y) * 2f;
if (Math.Sqrt(num9 * num9 + (double) num10 * (double) num10) < num7 * 0.4)
{
Main.tile[index1, index2].active(true);
if (Main.tile[index1, index2].type == (ushort) 59)
Main.tile[index1, index2].type = (ushort) 0;
}
}
}
}
int num11 = (int) ((double) vector2_1.X - num1 * 0.4);
int num12 = (int) ((double) vector2_1.X + num1 * 0.4);
int num13 = (int) ((double) vector2_1.Y - num1 * 0.4);
int num14 = (int) ((double) vector2_1.Y + num1 * 0.4);
if (num11 < 0)
num11 = 0;
if (num12 > Main.maxTilesX)
num12 = Main.maxTilesX;
if (num13 < 0)
num13 = 0;
if (num14 > Main.maxTilesY)
num14 = Main.maxTilesY;
double num15 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
for (int index3 = num11; index3 < num12; ++index3)
{
for (int index4 = num13; index4 < num14; ++index4)
{
if ((double) index4 > (double) vector2_1.Y + 2.0)
{
double num16 = (double) Math.Abs((float) index3 - vector2_1.X);
float num17 = Math.Abs((float) index4 - vector2_1.Y) * 2f;
if (Math.Sqrt(num16 * num16 + (double) num17 * (double) num17) < num15 * 0.4)
Main.tile[index3, index4].wall = (byte) 2;
}
}
}
vector2_1 += vector2_2;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > 1.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -1.0)
vector2_2.X = -1f;
if ((double) vector2_2.Y > 0.2)
vector2_2.Y = -0.2f;
if ((double) vector2_2.Y < -0.2)
vector2_2.Y = -0.2f;
}
}
public static void Caverer(int X, int Y)
{
switch (WorldGen.genRand.Next(2))
{
case 0:
int num1 = WorldGen.genRand.Next(7, 9);
float xDir1 = (float) WorldGen.genRand.Next(100) * 0.01f;
float yDir1 = 1f - xDir1;
if (WorldGen.genRand.Next(2) == 0)
xDir1 = -xDir1;
if (WorldGen.genRand.Next(2) == 0)
yDir1 = -yDir1;
Vector2 vector2_1 = new Vector2((float) X, (float) Y);
for (int index = 0; index < num1; ++index)
{
vector2_1 = WorldGen.digTunnel(vector2_1.X, vector2_1.Y, xDir1, yDir1, WorldGen.genRand.Next(6, 20), WorldGen.genRand.Next(4, 9));
xDir1 += (float) WorldGen.genRand.Next(-20, 21) * 0.1f;
yDir1 += (float) WorldGen.genRand.Next(-20, 21) * 0.1f;
if ((double) xDir1 < -1.5)
xDir1 = -1.5f;
if ((double) xDir1 > 1.5)
xDir1 = 1.5f;
if ((double) yDir1 < -1.5)
yDir1 = -1.5f;
if ((double) yDir1 > 1.5)
yDir1 = 1.5f;
float xDir2 = (float) WorldGen.genRand.Next(100) * 0.01f;
float yDir2 = 1f - xDir2;
if (WorldGen.genRand.Next(2) == 0)
xDir2 = -xDir2;
if (WorldGen.genRand.Next(2) == 0)
yDir2 = -yDir2;
Vector2 vector2_2 = WorldGen.digTunnel(vector2_1.X, vector2_1.Y, xDir2, yDir2, WorldGen.genRand.Next(30, 50), WorldGen.genRand.Next(3, 6));
WorldGen.TileRunner((int) vector2_2.X, (int) vector2_2.Y, (double) WorldGen.genRand.Next(10, 20), WorldGen.genRand.Next(5, 10), -1);
}
break;
case 1:
int num2 = WorldGen.genRand.Next(15, 30);
float xDir3 = (float) WorldGen.genRand.Next(100) * 0.01f;
float yDir3 = 1f - xDir3;
if (WorldGen.genRand.Next(2) == 0)
xDir3 = -xDir3;
if (WorldGen.genRand.Next(2) == 0)
yDir3 = -yDir3;
Vector2 vector2_3 = new Vector2((float) X, (float) Y);
for (int index = 0; index < num2; ++index)
{
vector2_3 = WorldGen.digTunnel(vector2_3.X, vector2_3.Y, xDir3, yDir3, WorldGen.genRand.Next(5, 15), WorldGen.genRand.Next(2, 6), true);
xDir3 += (float) WorldGen.genRand.Next(-20, 21) * 0.1f;
yDir3 += (float) WorldGen.genRand.Next(-20, 21) * 0.1f;
if ((double) xDir3 < -1.5)
xDir3 = -1.5f;
if ((double) xDir3 > 1.5)
xDir3 = 1.5f;
if ((double) yDir3 < -1.5)
yDir3 = -1.5f;
if ((double) yDir3 > 1.5)
yDir3 = 1.5f;
}
break;
}
}
public static Vector2 digTunnel(
float X,
float Y,
float xDir,
float yDir,
int Steps,
int Size,
bool Wet = false)
{
float x = X;
float y = Y;
try
{
float num1 = 0.0f;
float num2 = 0.0f;
int num3 = Steps;
float num4 = (float) Size;
x = MathHelper.Clamp(x, num4 + 1f, (float) ((double) Main.maxTilesX - (double) num4 - 1.0));
y = MathHelper.Clamp(y, num4 + 1f, (float) ((double) Main.maxTilesY - (double) num4 - 1.0));
for (int index1 = 0; index1 < num3; ++index1)
{
for (int index2 = (int) ((double) x - (double) num4); (double) index2 <= (double) x + (double) num4; ++index2)
{
for (int index3 = (int) ((double) y - (double) num4); (double) index3 <= (double) y + (double) num4; ++index3)
{
if ((double) Math.Abs((float) index2 - x) + (double) Math.Abs((float) index3 - y) < (double) num4 * (1.0 + (double) WorldGen.genRand.Next(-10, 11) * 0.005) && index2 >= 0 && index2 < Main.maxTilesX && index3 >= 0 && index3 < Main.maxTilesY)
{
Main.tile[index2, index3].active(false);
if (Wet)
Main.tile[index2, index3].liquid = byte.MaxValue;
}
}
}
num4 += (float) WorldGen.genRand.Next(-50, 51) * 0.03f;
if ((double) num4 < (double) Size * 0.6)
num4 = (float) Size * 0.6f;
if ((double) num4 > (double) (Size * 2))
num4 = (float) Size * 2f;
num1 += (float) WorldGen.genRand.Next(-20, 21) * 0.01f;
num2 += (float) WorldGen.genRand.Next(-20, 21) * 0.01f;
if ((double) num1 < -1.0)
num1 = -1f;
if ((double) num1 > 1.0)
num1 = 1f;
if ((double) num2 < -1.0)
num2 = -1f;
if ((double) num2 > 1.0)
num2 = 1f;
x += (float) (((double) xDir + (double) num1) * 0.600000023841858);
y += (float) (((double) yDir + (double) num2) * 0.600000023841858);
}
}
catch
{
}
return new Vector2(x, y);
}
public static void IslandHouse(int i, int j)
{
byte num1 = 202;
byte num2 = 82;
Vector2 vector2 = new Vector2((float) i, (float) j);
int num3 = 1;
if (WorldGen.genRand.Next(2) == 0)
num3 = -1;
int num4 = WorldGen.genRand.Next(7, 12);
int num5 = WorldGen.genRand.Next(5, 7);
vector2.X = (float) (i + (num4 + 2) * num3);
for (int index = j - 15; index < j + 30; ++index)
{
if (Main.tile[(int) vector2.X, index].active())
{
vector2.Y = (float) (index - 1);
break;
}
}
vector2.X = (float) i;
int num6 = (int) ((double) vector2.X - (double) num4 - 1.0);
int num7 = (int) ((double) vector2.X + (double) num4 + 1.0);
int num8 = (int) ((double) vector2.Y - (double) num5 - 1.0);
int num9 = (int) ((double) vector2.Y + 2.0);
if (num6 < 0)
num6 = 0;
if (num7 > Main.maxTilesX)
num7 = Main.maxTilesX;
if (num8 < 0)
num8 = 0;
if (num9 > Main.maxTilesY)
num9 = Main.maxTilesY;
for (int index1 = num6; index1 <= num7; ++index1)
{
for (int index2 = num8 - 1; index2 < num9 + 1; ++index2)
{
if (index2 != num8 - 1 || index1 != num6 && index1 != num7)
{
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].liquid = (byte) 0;
Main.tile[index1, index2].type = (ushort) num1;
Main.tile[index1, index2].wall = (byte) 0;
Main.tile[index1, index2].halfBrick(false);
Main.tile[index1, index2].slope((byte) 0);
}
}
}
int num10 = (int) ((double) vector2.X - (double) num4);
int num11 = (int) ((double) vector2.X + (double) num4);
int j1 = (int) ((double) vector2.Y - (double) num5);
int num12 = (int) ((double) vector2.Y + 1.0);
if (num10 < 0)
num10 = 0;
if (num11 > Main.maxTilesX)
num11 = Main.maxTilesX;
if (j1 < 0)
j1 = 0;
if (num12 > Main.maxTilesY)
num12 = Main.maxTilesY;
for (int index3 = num10; index3 <= num11; ++index3)
{
for (int index4 = j1; index4 < num12; ++index4)
{
if ((index4 != j1 || index3 != num10 && index3 != num11) && Main.tile[index3, index4].wall == (byte) 0)
{
Main.tile[index3, index4].active(false);
Main.tile[index3, index4].wall = num2;
}
}
}
int i1 = i + (num4 + 1) * num3;
int y = (int) vector2.Y;
for (int index = i1 - 2; index <= i1 + 2; ++index)
{
Main.tile[index, y].active(false);
Main.tile[index, y - 1].active(false);
Main.tile[index, y - 2].active(false);
}
WorldGen.PlaceTile(i1, y, 10, true, style: 9);
int index5 = i + (num4 + 1) * -num3 - num3;
for (int index6 = j1; index6 <= num12 + 1; ++index6)
{
Main.tile[index5, index6].active(true);
Main.tile[index5, index6].liquid = (byte) 0;
Main.tile[index5, index6].type = (ushort) num1;
Main.tile[index5, index6].wall = (byte) 0;
Main.tile[index5, index6].halfBrick(false);
Main.tile[index5, index6].slope((byte) 0);
}
int contain = 0;
int num13 = WorldGen.houseCount;
if (num13 > 2)
num13 = WorldGen.genRand.Next(3);
switch (num13)
{
case 0:
contain = 159;
break;
case 1:
contain = 65;
break;
case 2:
contain = 158;
break;
}
WorldGen.AddBuriedChest(i, y - 3, contain, Style: 13);
++WorldGen.houseCount;
int num14 = i - num4 / 2 + 1;
int num15 = i + num4 / 2 - 1;
int num16 = 1;
if (num4 > 10)
num16 = 2;
int num17 = (j1 + num12) / 2 - 1;
for (int index7 = num14 - num16; index7 <= num14 + num16; ++index7)
{
for (int index8 = num17 - 1; index8 <= num17 + 1; ++index8)
Main.tile[index7, index8].wall = (byte) 21;
}
for (int index9 = num15 - num16; index9 <= num15 + num16; ++index9)
{
for (int index10 = num17 - 1; index10 <= num17 + 1; ++index10)
Main.tile[index9, index10].wall = (byte) 21;
}
int i2 = i + (num4 / 2 + 1) * -num3;
WorldGen.PlaceTile(i2, num12 - 1, 14, true, style: 7);
WorldGen.PlaceTile(i2 - 2, num12 - 1, 15, true, plr: 0, style: 10);
Main.tile[i2 - 2, num12 - 1].frameX += (short) 18;
Main.tile[i2 - 2, num12 - 2].frameX += (short) 18;
WorldGen.PlaceTile(i2 + 2, num12 - 1, 15, true, plr: 0, style: 10);
WorldGen.PlaceTile(num10 + 1, j1, 91, true, style: WorldGen.genRand.Next(7, 10));
WorldGen.PlaceTile(num11 - 1, j1, 91, true, style: WorldGen.genRand.Next(7, 10));
int i3;
int j2;
if (num3 > 0)
{
i3 = num10;
j2 = j1 + 1;
}
else
{
i3 = num11;
j2 = j1 + 1;
}
WorldGen.PlaceTile(i3, j2, 91, true, style: WorldGen.genRand.Next(7, 10));
}
public static void Mountinater(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(80, 120);
float num2 = (float) WorldGen.genRand.Next(40, 55);
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j + num2 / 2f;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(-20, -10) * 0.1f;
while (num1 > 0.0 && (double) num2 > 0.0)
{
num1 -= (double) WorldGen.genRand.Next(4);
--num2;
int num3 = (int) ((double) vector2_1.X - num1 * 0.5);
int num4 = (int) ((double) vector2_1.X + num1 * 0.5);
int num5 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num6 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesX)
num4 = Main.maxTilesX;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY;
double num7 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
for (int index1 = num3; index1 < num4; ++index1)
{
for (int index2 = num5; index2 < num6; ++index2)
{
double num8 = (double) Math.Abs((float) index1 - vector2_1.X);
float num9 = Math.Abs((float) index2 - vector2_1.Y);
if (Math.Sqrt(num8 * num8 + (double) num9 * (double) num9) < num7 * 0.4 && !Main.tile[index1, index2].active())
{
Main.tile[index1, index2].active(true);
Main.tile[index1, index2].type = (ushort) 0;
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > 0.5)
vector2_2.X = 0.5f;
if ((double) vector2_2.X < -0.5)
vector2_2.X = -0.5f;
if ((double) vector2_2.Y > -0.5)
vector2_2.Y = -0.5f;
if ((double) vector2_2.Y < -1.5)
vector2_2.Y = -1.5f;
}
}
public static void MakeWateryIceThing(int i, int j)
{
if (Main.tile[i, j].liquid <= (byte) 0 || Main.tile[i, j].active() || Main.tile[i, j].lava())
return;
int index1 = j;
while (!Main.tile[i, index1].active() && Main.tile[i, index1].liquid > (byte) 0)
{
++index1;
if (index1 > Main.maxTilesY - 50)
return;
}
if (Main.tile[i, index1].type != (ushort) 147 && Main.tile[i, index1].type != (ushort) 161)
return;
int index2 = index1 - 1;
while (Main.tile[i, index2].liquid > (byte) 0)
{
--index2;
if (index2 < 10)
return;
}
if (Main.tile[i, index2].active())
return;
int j1 = index2 + 1;
if (Main.tile[i, j1].active())
return;
for (int i1 = i; !Main.tile[i1, j1].active() && Main.tile[i1, j1].liquid > (byte) 0 && Main.tile[i1, j1 - 1].liquid == (byte) 0 && !Main.tile[i1, j1 - 1].active() && !Main.tile[i1 - 1, j1].halfBrick(); --i1)
WorldGen.PlaceTile(i1, j1, 162, true);
for (int i2 = i + 1; !Main.tile[i2, j1].active() && Main.tile[i2, j1].liquid > (byte) 0 && Main.tile[i2, j1 - 1].liquid == (byte) 0 && !Main.tile[i2, j1 - 1].active() && !Main.tile[i2 + 1, j1].halfBrick(); ++i2)
WorldGen.PlaceTile(i2, j1, 162, true);
}
public static void Lakinater(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(25, 50);
double num2 = num1;
float num3 = (float) WorldGen.genRand.Next(30, 80);
if (WorldGen.genRand.Next(5) == 0)
{
num1 *= 1.5;
num2 *= 1.5;
num3 *= 1.2f;
}
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j - num3 * 0.3f;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(-20, -10) * 0.1f;
while (num1 > 0.0 && (double) num3 > 0.0)
{
if ((double) vector2_1.Y + num2 * 0.5 > Main.worldSurface)
num3 = 0.0f;
num1 -= (double) WorldGen.genRand.Next(3);
--num3;
int num4 = (int) ((double) vector2_1.X - num1 * 0.5);
int num5 = (int) ((double) vector2_1.X + num1 * 0.5);
int num6 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num7 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num4 < 0)
num4 = 0;
if (num5 > Main.maxTilesX)
num5 = Main.maxTilesX;
if (num6 < 0)
num6 = 0;
if (num7 > Main.maxTilesY)
num7 = Main.maxTilesY;
num2 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
for (int index1 = num4; index1 < num5; ++index1)
{
for (int index2 = num6; index2 < num7; ++index2)
{
double num8 = (double) Math.Abs((float) index1 - vector2_1.X);
float num9 = Math.Abs((float) index2 - vector2_1.Y);
if (Math.Sqrt(num8 * num8 + (double) num9 * (double) num9) < num2 * 0.4)
{
if (Main.tile[index1, index2].active())
Main.tile[index1, index2].liquid = byte.MaxValue;
Main.tile[index1, index2].active(false);
}
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > 0.5)
vector2_2.X = 0.5f;
if ((double) vector2_2.X < -0.5)
vector2_2.X = -0.5f;
if ((double) vector2_2.Y > 1.5)
vector2_2.Y = 1.5f;
if ((double) vector2_2.Y < 0.5)
vector2_2.Y = 0.5f;
}
}
public static void ShroomPatch(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(40, 70);
double num2 = num1;
float num3 = (float) WorldGen.genRand.Next(20, 30);
if (WorldGen.genRand.Next(5) == 0)
{
num1 *= 1.5;
double num4 = num2 * 1.5;
num3 *= 1.2f;
}
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j - num3 * 0.3f;
Vector2 vector2_2;
vector2_2.X = (float) WorldGen.genRand.Next(-10, 11) * 0.1f;
vector2_2.Y = (float) WorldGen.genRand.Next(-20, -10) * 0.1f;
while (num1 > 0.0 && (double) num3 > 0.0)
{
num1 -= (double) WorldGen.genRand.Next(3);
--num3;
int num5 = (int) ((double) vector2_1.X - num1 * 0.5);
int num6 = (int) ((double) vector2_1.X + num1 * 0.5);
int num7 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num8 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesX)
num6 = Main.maxTilesX;
if (num7 < 0)
num7 = 0;
if (num8 > Main.maxTilesY)
num8 = Main.maxTilesY;
double num9 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
for (int index1 = num5; index1 < num6; ++index1)
{
for (int index2 = num7; index2 < num8; ++index2)
{
double num10 = (double) Math.Abs((float) index1 - vector2_1.X);
float num11 = Math.Abs((float) (((double) index2 - (double) vector2_1.Y) * 2.29999995231628));
if (Math.Sqrt(num10 * num10 + (double) num11 * (double) num11) < num9 * 0.4)
{
if ((double) index2 < (double) vector2_1.Y + num9 * 0.02)
{
if (Main.tile[index1, index2].type != (ushort) 59)
Main.tile[index1, index2].active(false);
}
else
Main.tile[index1, index2].type = (ushort) 59;
Main.tile[index1, index2].liquid = (byte) 0;
Main.tile[index1, index2].lava(false);
}
}
}
vector2_1 += vector2_2;
vector2_1.X += vector2_2.X;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.Y -= (float) WorldGen.genRand.Next(11) * 0.05f;
if ((double) vector2_2.X > -0.5 && (double) vector2_2.X < 0.5)
vector2_2.X = (double) vector2_2.X >= 0.0 ? 0.5f : -0.5f;
if ((double) vector2_2.X > 2.0)
vector2_2.X = 1f;
if ((double) vector2_2.X < -2.0)
vector2_2.X = -1f;
if ((double) vector2_2.Y > 1.0)
vector2_2.Y = 1f;
if ((double) vector2_2.Y < -1.0)
vector2_2.Y = -1f;
for (int index = 0; index < 2; ++index)
{
int i1 = (int) vector2_1.X + WorldGen.genRand.Next(-20, 20);
int j1;
for (j1 = (int) vector2_1.Y + WorldGen.genRand.Next(0, 20); !Main.tile[i1, j1].active() && Main.tile[i1, j1].type != (ushort) 59; j1 = (int) vector2_1.Y + WorldGen.genRand.Next(0, 20))
i1 = (int) vector2_1.X + WorldGen.genRand.Next(-20, 20);
int num12 = WorldGen.genRand.Next(7, 10);
int steps = WorldGen.genRand.Next(7, 10);
WorldGen.TileRunner(i1, j1, (double) num12, steps, 59, speedY: 2f, noYChange: true);
if (WorldGen.genRand.Next(3) == 0)
WorldGen.TileRunner(i1, j1, (double) (num12 - 3), steps - 3, -1, speedY: 2f, noYChange: true);
}
}
}
public static void Cavinator(int i, int j, int steps)
{
double num1 = (double) WorldGen.genRand.Next(7, 15);
int num2 = 1;
if (WorldGen.genRand.Next(2) == 0)
num2 = -1;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
int num3 = WorldGen.genRand.Next(20, 40);
Vector2 vector2_2;
vector2_2.Y = (float) WorldGen.genRand.Next(10, 20) * 0.01f;
vector2_2.X = (float) num2;
while (num3 > 0)
{
--num3;
int num4 = (int) ((double) vector2_1.X - num1 * 0.5);
int num5 = (int) ((double) vector2_1.X + num1 * 0.5);
int num6 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num7 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num4 < 0)
num4 = 0;
if (num5 > Main.maxTilesX)
num5 = Main.maxTilesX;
if (num6 < 0)
num6 = 0;
if (num7 > Main.maxTilesY)
num7 = Main.maxTilesY;
double num8 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
for (int index1 = num4; index1 < num5; ++index1)
{
for (int index2 = num6; index2 < num7; ++index2)
{
double num9 = (double) Math.Abs((float) index1 - vector2_1.X);
float num10 = Math.Abs((float) index2 - vector2_1.Y);
if (Math.Sqrt(num9 * num9 + (double) num10 * (double) num10) < num8 * 0.4 && TileID.Sets.CanBeClearedDuringGeneration[(int) Main.tile[index1, index2].type])
Main.tile[index1, index2].active(false);
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > (double) num2 + 0.5)
vector2_2.X = (float) num2 + 0.5f;
if ((double) vector2_2.X < (double) num2 - 0.5)
vector2_2.X = (float) num2 - 0.5f;
if ((double) vector2_2.Y > 2.0)
vector2_2.Y = 2f;
if ((double) vector2_2.Y < 0.0)
vector2_2.Y = 0.0f;
}
if (steps <= 0 || (double) (int) vector2_1.Y >= Main.rockLayer + 50.0)
return;
WorldGen.Cavinator((int) vector2_1.X, (int) vector2_1.Y, steps - 1);
}
public static void CaveOpenater(int i, int j)
{
double num1 = (double) WorldGen.genRand.Next(7, 12);
int num2 = 1;
if (WorldGen.genRand.Next(2) == 0)
num2 = -1;
Vector2 vector2_1;
vector2_1.X = (float) i;
vector2_1.Y = (float) j;
int num3 = 100;
Vector2 vector2_2;
vector2_2.Y = 0.0f;
vector2_2.X = (float) num2;
while (num3 > 0)
{
if (Main.tile[(int) vector2_1.X, (int) vector2_1.Y].wall == (byte) 0)
num3 = 0;
--num3;
int num4 = (int) ((double) vector2_1.X - num1 * 0.5);
int num5 = (int) ((double) vector2_1.X + num1 * 0.5);
int num6 = (int) ((double) vector2_1.Y - num1 * 0.5);
int num7 = (int) ((double) vector2_1.Y + num1 * 0.5);
if (num4 < 0)
num4 = 0;
if (num5 > Main.maxTilesX)
num5 = Main.maxTilesX;
if (num6 < 0)
num6 = 0;
if (num7 > Main.maxTilesY)
num7 = Main.maxTilesY;
double num8 = num1 * (double) WorldGen.genRand.Next(80, 120) * 0.01;
for (int index1 = num4; index1 < num5; ++index1)
{
for (int index2 = num6; index2 < num7; ++index2)
{
double num9 = (double) Math.Abs((float) index1 - vector2_1.X);
float num10 = Math.Abs((float) index2 - vector2_1.Y);
if (Math.Sqrt(num9 * num9 + (double) num10 * (double) num10) < num8 * 0.4)
Main.tile[index1, index2].active(false);
}
}
vector2_1 += vector2_2;
vector2_2.X += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
vector2_2.Y += (float) WorldGen.genRand.Next(-10, 11) * 0.05f;
if ((double) vector2_2.X > (double) num2 + 0.5)
vector2_2.X = (float) num2 + 0.5f;
if ((double) vector2_2.X < (double) num2 - 0.5)
vector2_2.X = (float) num2 - 0.5f;
if ((double) vector2_2.Y > 0.0)
vector2_2.Y = 0.0f;
if ((double) vector2_2.Y < -0.5)
vector2_2.Y = -0.5f;
}
}
public static void DiamondTileFrame(int i, int j)
{
WorldGen.TileFrame(i - 1, j);
WorldGen.TileFrame(i, j - 1);
WorldGen.TileFrame(i, j + 1);
WorldGen.TileFrame(i + 1, j);
}
public static void SquareTileFrame(int i, int j, bool resetFrame = true)
{
WorldGen.TileFrame(i - 1, j - 1);
WorldGen.TileFrame(i - 1, j);
WorldGen.TileFrame(i - 1, j + 1);
WorldGen.TileFrame(i, j - 1);
WorldGen.TileFrame(i, j, resetFrame);
WorldGen.TileFrame(i, j + 1);
WorldGen.TileFrame(i + 1, j - 1);
WorldGen.TileFrame(i + 1, j);
WorldGen.TileFrame(i + 1, j + 1);
}
public static void SquareWallFrame(int i, int j, bool resetFrame = true)
{
Framing.WallFrame(i - 1, j - 1);
Framing.WallFrame(i - 1, j);
Framing.WallFrame(i - 1, j + 1);
Framing.WallFrame(i, j - 1);
Framing.WallFrame(i, j, resetFrame);
Framing.WallFrame(i, j + 1);
Framing.WallFrame(i + 1, j - 1);
Framing.WallFrame(i + 1, j);
Framing.WallFrame(i + 1, j + 1);
}
public static void SectionTileFrameWithCheck(int startX, int startY, int endX, int endY)
{
int sectionX1 = Netplay.GetSectionX(startX);
int sectionY1 = Netplay.GetSectionY(startY);
int sectionX2 = Netplay.GetSectionX(endX);
int sectionY2 = Netplay.GetSectionY(endY);
for (int index1 = sectionX1; index1 <= sectionX2; ++index1)
{
for (int index2 = sectionY1; index2 <= sectionY2; ++index2)
{
if (Main.sectionManager.SectionLoaded(index1, index2) && !Main.sectionManager.SectionFramed(index1, index2))
{
WorldGen.SectionTileFrame(index1, index2, index1, index2);
if (Main.sectionManager.FrameSectionsLeft == 0)
return;
}
}
}
}
public static void SectionTileFrame(int startX, int startY, int endX, int endY)
{
Main.mapTime = Main.mapTimeMax + 10;
WorldGen.noMapUpdate = true;
int num1 = startX * 200;
int num2 = (endX + 1) * 200;
int num3 = startY * 150;
int num4 = (endY + 1) * 150;
if (num1 < 1)
num1 = 1;
if (num3 < 1)
num3 = 1;
if (num1 > Main.maxTilesX - 2)
num1 = Main.maxTilesX - 2;
if (num3 > Main.maxTilesY - 2)
num3 = Main.maxTilesY - 2;
if (num2 > Main.maxTilesX - 2)
num2 = Main.maxTilesX - 2;
if (num4 > Main.maxTilesY - 2)
num4 = Main.maxTilesY - 2;
for (int i = num1 - 1; i < num2 + 1; ++i)
{
for (int j = num3 - 1; j < num4 + 1; ++j)
{
if (Main.tile[i, j] == null)
Main.tile[i, j] = new Tile();
WorldGen.TileFrame(i, j, true, true);
Framing.WallFrame(i, j, true);
}
}
for (int x = startX; x <= endX; ++x)
{
for (int y = startY; y <= endY; ++y)
Main.sectionManager.SetSectionFramed(x, y);
}
WorldGen.noMapUpdate = false;
}
public static void RangeFrame(int startX, int startY, int endX, int endY)
{
int num1 = startX;
int num2 = endX + 1;
int num3 = startY;
int num4 = endY + 1;
for (int i = num1 - 1; i < num2 + 1; ++i)
{
for (int j = num3 - 1; j < num4 + 1; ++j)
{
WorldGen.TileFrame(i, j);
Framing.WallFrame(i, j);
}
}
}
public static void WaterCheck()
{
Liquid.numLiquid = 0;
LiquidBuffer.numLiquidBuffer = 0;
for (int index1 = 1; index1 < Main.maxTilesX - 1; ++index1)
{
for (int index2 = Main.maxTilesY - 2; index2 > 0; --index2)
{
Tile checkTile = Main.tile[index1, index2];
checkTile.checkingLiquid(false);
if (checkTile.liquid > (byte) 0 && checkTile.nactive() && Main.tileSolid[(int) checkTile.type] && !Main.tileSolidTop[(int) checkTile.type])
checkTile.liquid = (byte) 0;
else if (checkTile.liquid > (byte) 0)
{
if (checkTile.active())
{
if (checkTile.lava())
{
if (TileObjectData.CheckLavaDeath(checkTile))
WorldGen.KillTile(index1, index2);
}
else if (TileObjectData.CheckWaterDeath(checkTile))
WorldGen.KillTile(index1, index2);
}
Tile tile1 = Main.tile[index1, index2 + 1];
if ((!tile1.nactive() || !Main.tileSolid[(int) tile1.type] || Main.tileSolidTop[(int) tile1.type]) && tile1.liquid < byte.MaxValue)
{
if (tile1.liquid > (byte) 250)
tile1.liquid = byte.MaxValue;
else
Liquid.AddWater(index1, index2);
}
Tile tile2 = Main.tile[index1 - 1, index2];
Tile tile3 = Main.tile[index1 + 1, index2];
if ((!tile2.nactive() || !Main.tileSolid[(int) tile2.type] || Main.tileSolidTop[(int) tile2.type]) && (int) tile2.liquid != (int) checkTile.liquid)
Liquid.AddWater(index1, index2);
else if ((!tile3.nactive() || !Main.tileSolid[(int) tile3.type] || Main.tileSolidTop[(int) tile3.type]) && (int) tile3.liquid != (int) checkTile.liquid)
Liquid.AddWater(index1, index2);
if (checkTile.lava())
{
if (tile2.liquid > (byte) 0 && !tile2.lava())
Liquid.AddWater(index1, index2);
else if (tile3.liquid > (byte) 0 && !tile3.lava())
Liquid.AddWater(index1, index2);
else if (Main.tile[index1, index2 - 1].liquid > (byte) 0 && !Main.tile[index1, index2 - 1].lava())
Liquid.AddWater(index1, index2);
else if (tile1.liquid > (byte) 0 && !tile1.lava())
Liquid.AddWater(index1, index2);
}
}
}
}
}
public static void EveryTileFrame()
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
WorldGen.noLiquidCheck = true;
WorldGen.noTileActions = true;
for (int i = 0; i < Main.maxTilesX; ++i)
{
float num = (float) i / (float) Main.maxTilesX;
Main.statusText = Lang.gen[55].Value + " " + (object) (int) ((double) num * 100.0 + 1.0) + "%";
for (int j = 0; j < Main.maxTilesY; ++j)
{
if (Main.tile[i, j].active())
WorldGen.TileFrame(i, j, true);
if (Main.tile[i, j].wall > (byte) 0)
Framing.WallFrame(i, j, true);
}
}
WorldGen.noLiquidCheck = false;
WorldGen.noTileActions = false;
long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
}
public static void PlantCheck(int i, int j)
{
int num1 = -1;
int num2 = (int) Main.tile[i, j].type;
int num3 = i - 1;
int num4 = i + 1;
int maxTilesX = Main.maxTilesX;
int num5 = j - 1;
if (j + 1 >= Main.maxTilesY)
num1 = num2;
if (i - 1 >= 0 && Main.tile[i - 1, j] != null && Main.tile[i - 1, j].nactive())
{
int type1 = (int) Main.tile[i - 1, j].type;
}
if (i + 1 < Main.maxTilesX && Main.tile[i + 1, j] != null && Main.tile[i + 1, j].nactive())
{
int type2 = (int) Main.tile[i + 1, j].type;
}
if (j - 1 >= 0 && Main.tile[i, j - 1] != null && Main.tile[i, j - 1].nactive())
{
int type3 = (int) Main.tile[i, j - 1].type;
}
if (j + 1 < Main.maxTilesY && Main.tile[i, j + 1] != null && Main.tile[i, j + 1].nactive() && !Main.tile[i, j + 1].halfBrick() && Main.tile[i, j + 1].slope() == (byte) 0)
num1 = (int) Main.tile[i, j + 1].type;
if (i - 1 >= 0 && j - 1 >= 0 && Main.tile[i - 1, j - 1] != null && Main.tile[i - 1, j - 1].nactive())
{
int type4 = (int) Main.tile[i - 1, j - 1].type;
}
if (i + 1 < Main.maxTilesX && j - 1 >= 0 && Main.tile[i + 1, j - 1] != null && Main.tile[i + 1, j - 1].nactive())
{
int type5 = (int) Main.tile[i + 1, j - 1].type;
}
if (i - 1 >= 0 && j + 1 < Main.maxTilesY && Main.tile[i - 1, j + 1] != null && Main.tile[i - 1, j + 1].nactive())
{
int type6 = (int) Main.tile[i - 1, j + 1].type;
}
if (i + 1 < Main.maxTilesX && j + 1 < Main.maxTilesY && Main.tile[i + 1, j + 1] != null && Main.tile[i + 1, j + 1].nactive())
{
int type7 = (int) Main.tile[i + 1, j + 1].type;
}
if ((num2 != 3 || num1 == 2 || num1 == 78 || num1 == 380) && (num2 != 24 || num1 == 23) && (num2 != 61 || num1 == 60) && (num2 != 71 || num1 == 70) && (num2 != 73 || num1 == 2 || num1 == 78 || num1 == 380) && (num2 != 74 || num1 == 60) && (num2 != 110 || num1 == 109) && (num2 != 113 || num1 == 109) && (num2 != 201 || num1 == 199))
return;
if ((num2 == 3 || num2 == 73) && num1 != 2 && Main.tile[i, j].frameX >= (short) 162)
Main.tile[i, j].frameX = (short) 126;
if (num2 == 74 && num1 != 60 && Main.tile[i, j].frameX >= (short) 162)
Main.tile[i, j].frameX = (short) 126;
switch (num1)
{
case 2:
num2 = num2 != 113 ? 3 : 73;
break;
case 23:
num2 = 24;
if (Main.tile[i, j].frameX >= (short) 162)
{
Main.tile[i, j].frameX = (short) 126;
break;
}
break;
case 70:
num2 = 71;
while (Main.tile[i, j].frameX > (short) 72)
Main.tile[i, j].frameX -= (short) 72;
break;
case 109:
num2 = num2 != 73 ? 110 : 113;
break;
case 199:
num2 = 201;
break;
}
if (num2 != (int) Main.tile[i, j].type)
Main.tile[i, j].type = (ushort) num2;
else
WorldGen.KillTile(i, j);
}
public static bool CheckPound(int i, int j)
{
if (Main.tile[i, j] == null)
Main.tile[i, j] = new Tile();
if (Main.tile[i, j - 1] == null)
Main.tile[i, j - 1] = new Tile();
if (Main.tile[i, j + 1] == null)
Main.tile[i, j + 1] = new Tile();
switch (Main.tile[i, j].type)
{
case 10:
case 48:
case 137:
case 138:
case 232:
case 380:
case 387:
case 388:
return false;
default:
if (WorldGen.gen && (Main.tile[i, j].type == (ushort) 190 || Main.tile[i, j].type == (ushort) 30))
return false;
if (Main.tile[i, j - 1].active())
{
switch (Main.tile[i, j - 1].type)
{
case 5:
case 21:
case 26:
case 72:
case 77:
case 88:
case 235:
case 237:
case 323:
case 441:
case 467:
case 468:
return false;
}
}
return true;
}
}
public static bool SlopeTile(int i, int j, int slope = 0)
{
if (!WorldGen.CheckPound(i, j))
return false;
Main.tile[i, j].halfBrick(false);
Main.tile[i, j].slope((byte) slope);
if (!WorldGen.gen)
{
WorldGen.KillTile(i, j, true, true);
Main.PlaySound(0, i * 16, j * 16);
WorldGen.SquareTileFrame(i, j);
if (Main.tile[i, j].slope() == (byte) 0)
{
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(i * 16, j * 16, 16, 16);
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active && !Main.player[index].dead && rectangle.Intersects(new Microsoft.Xna.Framework.Rectangle((int) Main.player[index].position.X, (int) Main.player[index].position.Y, Main.player[index].width, Main.player[index].height)))
{
Main.player[index].gfxOffY += Main.player[index].position.Y + (float) Main.player[index].height - (float) rectangle.Y;
Main.player[index].position.Y = (float) (rectangle.Y - Main.player[index].height);
}
}
}
}
return true;
}
public static bool PoundTile(int i, int j)
{
if (!WorldGen.CheckPound(i, j))
return false;
if (!Main.tile[i, j].halfBrick())
Main.tile[i, j].halfBrick(true);
else
Main.tile[i, j].halfBrick(false);
if (!WorldGen.gen)
{
WorldGen.KillTile(i, j, true, true);
Main.PlaySound(0, i * 16, j * 16);
WorldGen.SquareTileFrame(i, j);
if (!Main.tile[i, j].halfBrick())
{
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(i * 16, j * 16, 16, 16);
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active && !Main.player[index].dead && rectangle.Intersects(new Microsoft.Xna.Framework.Rectangle((int) Main.player[index].position.X, (int) Main.player[index].position.Y, Main.player[index].width, Main.player[index].height)))
{
Main.player[index].gfxOffY += Main.player[index].position.Y + (float) Main.player[index].height - (float) rectangle.Y;
Main.player[index].position.Y = (float) (rectangle.Y - Main.player[index].height);
}
}
}
}
return true;
}
public static void PoundPlatform(int x, int y)
{
if (Main.tile[x, y].halfBrick())
{
WorldGen.PoundTile(x, y);
if (Main.netMode != 1)
return;
NetMessage.SendData(17, number: 7, number2: ((float) x), number3: ((float) y), number4: 1f);
}
else
{
int slope1 = 1;
int slope2 = 2;
if (TileID.Sets.Platforms[(int) Main.tile[x + 1, y - 1].type] || TileID.Sets.Platforms[(int) Main.tile[x - 1, y + 1].type] || WorldGen.SolidTile(x + 1, y) && !WorldGen.SolidTile(x - 1, y))
{
slope1 = 2;
slope2 = 1;
}
if (Main.tile[x, y].slope() == (byte) 0)
{
WorldGen.SlopeTile(x, y, slope1);
int num = (int) Main.tile[x, y].slope();
if (Main.netMode != 1)
return;
NetMessage.SendData(17, number: 14, number2: ((float) x), number3: ((float) y), number4: ((float) num));
}
else if ((int) Main.tile[x, y].slope() == slope1)
{
WorldGen.SlopeTile(x, y, slope2);
int num = (int) Main.tile[x, y].slope();
if (Main.netMode != 1)
return;
NetMessage.SendData(17, number: 14, number2: ((float) x), number3: ((float) y), number4: ((float) num));
}
else
{
WorldGen.SlopeTile(x, y);
int num = (int) Main.tile[x, y].slope();
if (Main.netMode == 1)
NetMessage.SendData(17, number: 14, number2: ((float) x), number3: ((float) y), number4: ((float) num));
WorldGen.PoundTile(x, y);
if (Main.netMode != 1)
return;
NetMessage.SendData(17, number: 7, number2: ((float) x), number3: ((float) y), number4: 1f);
}
}
}
public static int PlatformProperSides(int x, int y, bool acceptNonOpposing = false)
{
Tile tile = Main.tile[x, y];
if (!tile.active() || !TileID.Sets.Platforms[(int) tile.type])
return 0;
int num1 = (int) tile.slope();
int num2 = -1;
if (num1 == 1)
num2 = 2;
if (num1 == 2)
num2 = 1;
int num3 = 0;
int num4 = 1;
int num5 = 0;
if (num1 == 1)
num5 = 1;
if (num1 == 2)
num5 = -1;
if (acceptNonOpposing)
{
if (Main.tile[x + num4, y + num5].active() && TileID.Sets.Platforms[(int) Main.tile[x + num4, y + num5].type] && (int) Main.tile[x + num4, y + num5].slope() != num2)
++num3;
}
else if (Main.tile[x + num4, y + num5].active() && TileID.Sets.Platforms[(int) Main.tile[x + num4, y + num5].type] && (int) Main.tile[x + num4, y + num5].slope() == num1)
++num3;
int num6 = num4 * -1;
int num7 = num5 * -1;
if (acceptNonOpposing)
{
if (Main.tile[x + num6, y + num7].active() && TileID.Sets.Platforms[(int) Main.tile[x + num6, y + num7].type] && (int) Main.tile[x + num6, y + num7].slope() != num2)
++num3;
}
else if (Main.tile[x + num6, y + num7].active() && TileID.Sets.Platforms[(int) Main.tile[x + num6, y + num7].type] && (int) Main.tile[x + num6, y + num7].slope() == num1)
++num3;
return num3;
}
public static bool UpdateMapTile(int i, int j, bool addToList = true)
{
bool flag = false;
if (Main.mapEnabled && !WorldGen.noMapUpdate && !WorldGen.gen && ((Main.Map[i, j].Light <= (byte) 0 ? 0 : (Main.Map.UpdateType(i, j) ? 1 : 0)) & (addToList ? 1 : 0)) != 0)
{
flag = true;
if (MapHelper.numUpdateTile < MapHelper.maxUpdateTile - 1)
{
MapHelper.updateTileX[MapHelper.numUpdateTile] = (short) i;
MapHelper.updateTileY[MapHelper.numUpdateTile] = (short) j;
++MapHelper.numUpdateTile;
}
else
Main.refreshMap = true;
}
return flag;
}
public static void TileMergeAttemptFrametest(
int i,
int j,
int myType,
int lookfor,
ref int up,
ref int down,
ref int left,
ref int right,
ref int upLeft,
ref int upRight,
ref int downLeft,
ref int downRight)
{
if (up == lookfor)
{
WorldGen.TileFrame(i, j - 1);
if (WorldGen.mergeDown)
up = myType;
}
if (down == lookfor)
{
WorldGen.TileFrame(i, j + 1);
if (WorldGen.mergeUp)
down = myType;
}
if (left == lookfor)
{
WorldGen.TileFrame(i - 1, j);
if (WorldGen.mergeRight)
left = myType;
}
if (right == lookfor)
{
WorldGen.TileFrame(i + 1, j);
if (WorldGen.mergeLeft)
right = myType;
}
if (upLeft == lookfor)
upLeft = myType;
if (upRight == lookfor)
upRight = myType;
if (downLeft == lookfor)
downLeft = myType;
if (downRight != lookfor)
return;
downRight = myType;
}
public static void TileMergeAttemptFrametest(
int i,
int j,
int myType,
bool[] lookfor,
ref int up,
ref int down,
ref int left,
ref int right,
ref int upLeft,
ref int upRight,
ref int downLeft,
ref int downRight)
{
if (up > -1 && lookfor[up])
{
WorldGen.TileFrame(i, j - 1);
if (WorldGen.mergeDown)
up = myType;
}
if (down > -1 && lookfor[down])
{
WorldGen.TileFrame(i, j + 1);
if (WorldGen.mergeUp)
down = myType;
}
if (left > -1 && lookfor[left])
{
WorldGen.TileFrame(i - 1, j);
if (WorldGen.mergeRight)
left = myType;
}
if (right > -1 && lookfor[right])
{
WorldGen.TileFrame(i + 1, j);
if (WorldGen.mergeLeft)
right = myType;
}
if (upLeft > -1 && lookfor[upLeft])
upLeft = myType;
if (upRight > -1 && lookfor[upRight])
upRight = myType;
if (downLeft > -1 && lookfor[downLeft])
downLeft = myType;
if (downRight <= -1 || !lookfor[downRight])
return;
downRight = myType;
}
public static void TileMergeAttempt(
int myType,
int lookfor,
ref int up,
ref int down,
ref int left,
ref int right)
{
if (lookfor == up)
up = myType;
if (lookfor == down)
down = myType;
if (lookfor == left)
left = myType;
if (lookfor != right)
return;
right = myType;
}
public static void TileMergeAttempt(
int myType,
int lookfor,
ref int up,
ref int down,
ref int left,
ref int right,
ref int upLeft,
ref int upRight,
ref int downLeft,
ref int downRight)
{
if (lookfor == up)
up = myType;
if (lookfor == down)
down = myType;
if (lookfor == left)
left = myType;
if (lookfor == right)
right = myType;
if (lookfor == upLeft)
upLeft = myType;
if (lookfor == upRight)
upRight = myType;
if (lookfor == downLeft)
downLeft = myType;
if (lookfor != downRight)
return;
downRight = myType;
}
public static void TileMergeAttempt(
int myType,
bool[] lookfor,
ref int up,
ref int down,
ref int left,
ref int right,
ref int upLeft,
ref int upRight,
ref int downLeft,
ref int downRight)
{
if (up > -1 && lookfor[up])
up = myType;
if (down > -1 && lookfor[down])
down = myType;
if (left > -1 && lookfor[left])
left = myType;
if (right > -1 && lookfor[right])
right = myType;
if (upLeft > -1 && lookfor[upLeft])
upLeft = myType;
if (upRight > -1 && lookfor[upRight])
upRight = myType;
if (downLeft > -1 && lookfor[downLeft])
downLeft = myType;
if (downRight <= -1 || !lookfor[downRight])
return;
downRight = myType;
}
public static void TileMergeAttempt(
int myType,
bool[] lookfor,
bool[] exclude,
ref int up,
ref int down,
ref int left,
ref int right,
ref int upLeft,
ref int upRight,
ref int downLeft,
ref int downRight)
{
if (up > -1 && !exclude[up] && lookfor[up])
up = myType;
if (down > -1 && !exclude[down] && lookfor[down])
down = myType;
if (left > -1 && !exclude[left] && lookfor[left])
left = myType;
if (right > -1 && !exclude[right] && lookfor[right])
right = myType;
if (upLeft > -1 && !exclude[upLeft] && lookfor[upLeft])
upLeft = myType;
if (upRight > -1 && !exclude[upRight] && lookfor[upRight])
upRight = myType;
if (downLeft > -1 && !exclude[downLeft] && lookfor[downLeft])
downLeft = myType;
if (downRight <= -1 || exclude[downRight] || !lookfor[downRight])
return;
downRight = myType;
}
public static void TileMergeAttemptWeird(
int myType,
int changeTo,
bool[] exclude,
ref int up,
ref int down,
ref int left,
ref int right,
ref int upLeft,
ref int upRight,
ref int downLeft,
ref int downRight)
{
if (up > -1 && !exclude[up] && up != myType)
up = changeTo;
if (down > -1 && !exclude[down] && down != myType)
down = changeTo;
if (left > -1 && !exclude[left] && left != myType)
left = changeTo;
if (right > -1 && !exclude[right] && right != myType)
right = changeTo;
if (upLeft > -1 && !exclude[upLeft] && upLeft != myType)
upLeft = changeTo;
if (upRight > -1 && !exclude[upRight] && upRight != myType)
upRight = changeTo;
if (downLeft > -1 && !exclude[downLeft] && downLeft != myType)
downLeft = changeTo;
if (downRight <= -1 || exclude[downRight] || downRight == myType)
return;
downRight = changeTo;
}
public static void TileFrame(int i, int j, bool resetFrame = false, bool noBreak = false)
{
bool addToList = false;
try
{
if (i > 5)
{
if (j > 5)
{
if (i < Main.maxTilesX - 5)
{
if (j < Main.maxTilesY - 5)
{
if (Main.tile[i, j] != null)
{
addToList = WorldGen.UpdateMapTile(i, j);
Tile centerTile = Main.tile[i, j];
if (!centerTile.active())
{
centerTile.halfBrick(false);
centerTile.color((byte) 0);
centerTile.slope((byte) 0);
}
if (centerTile.liquid > (byte) 0 && Main.netMode != 1 && !WorldGen.noLiquidCheck)
Liquid.AddWater(i, j);
if (centerTile.active())
{
if (noBreak && Main.tileFrameImportant[(int) centerTile.type] && centerTile.type != (ushort) 4)
return;
int index1 = (int) centerTile.type;
if (Main.tileStone[index1])
index1 = 1;
int frameX1 = (int) centerTile.frameX;
int frameY1 = (int) centerTile.frameY;
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(-1, -1, 0, 0);
if (Main.tileFrameImportant[(int) centerTile.type])
{
switch (index1)
{
case 4:
Tile tile1 = Main.tile[i, j - 1];
Tile tile2 = Main.tile[i, j + 1];
Tile tile3 = Main.tile[i - 1, j];
Tile tile4 = Main.tile[i + 1, j];
Tile tile5 = Main.tile[i - 1, j + 1];
Tile tile6 = Main.tile[i + 1, j + 1];
Tile tile7 = Main.tile[i - 1, j - 1];
Tile tile8 = Main.tile[i + 1, j - 1];
short num1 = 0;
if (centerTile.frameX >= (short) 66)
num1 = (short) 66;
int index2 = -1;
int index3 = -1;
int index4 = -1;
int num2 = -1;
int num3 = -1;
int num4 = -1;
int num5 = -1;
if (tile1 != null && tile1.active() && !tile1.bottomSlope())
{
int type1 = (int) tile1.type;
}
if (tile2 != null && tile2.active() && !tile2.halfBrick() && !tile2.topSlope())
index2 = (int) tile2.type;
if (tile3 != null && tile3.active() && (tile3.slope() == (byte) 0 || (int) tile3.slope() % 2 != 1))
index3 = (int) tile3.type;
if (tile4 != null && tile4.active() && (tile4.slope() == (byte) 0 || (int) tile4.slope() % 2 != 0))
index4 = (int) tile4.type;
if (tile5 != null && tile5.active())
num2 = (int) tile5.type;
if (tile6 != null && tile6.active())
num3 = (int) tile6.type;
if (tile7 != null && tile7.active())
num4 = (int) tile7.type;
if (tile8 != null && tile8.active())
num5 = (int) tile8.type;
if (index2 >= 0 && Main.tileSolid[index2] && (!Main.tileNoAttach[index2] || TileID.Sets.Platforms[index2]))
{
centerTile.frameX = num1;
return;
}
if (index3 >= 0 && Main.tileSolid[index3] && !Main.tileNoAttach[index3] || index3 == 124 || index3 == 5 && num4 == 5 && num2 == 5)
{
centerTile.frameX = (short) (22 + (int) num1);
return;
}
if (index4 >= 0 && Main.tileSolid[index4] && !Main.tileNoAttach[index4] || index4 == 124 || index4 == 5 && num5 == 5 && num3 == 5)
{
centerTile.frameX = (short) (44 + (int) num1);
return;
}
if (centerTile.wall > (byte) 0)
{
centerTile.frameX = num1;
return;
}
WorldGen.KillTile(i, j);
return;
case 136:
Tile tile9 = Main.tile[i, j - 1];
Tile tile10 = Main.tile[i, j + 1];
Tile tile11 = Main.tile[i - 1, j];
Tile tile12 = Main.tile[i + 1, j];
Tile tile13 = Main.tile[i - 1, j + 1];
Tile tile14 = Main.tile[i + 1, j + 1];
Tile tile15 = Main.tile[i - 1, j - 1];
Tile tile16 = Main.tile[i + 1, j - 1];
int index5 = -1;
int index6 = -1;
int index7 = -1;
int num6 = -1;
int num7 = -1;
int num8 = -1;
int num9 = -1;
if (tile9 != null && tile9.nactive())
{
int type2 = (int) tile9.type;
}
if (tile10 != null && tile10.nactive() && !tile10.halfBrick() && !tile10.topSlope())
index5 = (int) tile10.type;
if (tile11 != null && tile11.nactive())
index6 = (int) tile11.type;
if (tile12 != null && tile12.nactive())
index7 = (int) tile12.type;
if (tile13 != null && tile13.nactive())
num6 = (int) tile13.type;
if (tile14 != null && tile14.nactive())
num7 = (int) tile14.type;
if (tile15 != null && tile15.nactive())
num8 = (int) tile15.type;
if (tile16 != null && tile16.nactive())
num9 = (int) tile16.type;
if (index5 >= 0 && Main.tileSolid[index5] && !Main.tileNoAttach[index5] && !tile10.halfBrick() && (tile10.slope() == (byte) 0 || tile10.bottomSlope()))
{
centerTile.frameX = (short) 0;
return;
}
if (index6 >= 0 && Main.tileSolid[index6] && !Main.tileNoAttach[index6] && (tile11.leftSlope() || tile11.slope() == (byte) 0) && !tile11.halfBrick() || index6 == 124 || index6 == 5 && num8 == 5 && num6 == 5)
{
centerTile.frameX = (short) 18;
return;
}
if (index7 >= 0 && Main.tileSolid[index7] && !Main.tileNoAttach[index7] && (tile12.rightSlope() || tile12.slope() == (byte) 0) && !tile12.halfBrick() || index7 == 124 || index7 == 5 && num9 == 5 && num7 == 5)
{
centerTile.frameX = (short) 36;
return;
}
if (centerTile.wall > (byte) 0)
{
centerTile.frameX = (short) 54;
return;
}
WorldGen.KillTile(i, j);
return;
case 442:
Tile tile17 = Main.tile[i, j - 1];
Tile tile18 = Main.tile[i, j + 1];
Tile tile19 = Main.tile[i - 1, j];
Tile tile20 = Main.tile[i + 1, j];
Tile tile21 = Main.tile[i - 1, j + 1];
Tile tile22 = Main.tile[i + 1, j + 1];
Tile tile23 = Main.tile[i - 1, j - 1];
Tile tile24 = Main.tile[i + 1, j - 1];
int index8 = -1;
int index9 = -1;
int index10 = -1;
int index11 = -1;
int num10 = -1;
int num11 = -1;
int num12 = -1;
int num13 = -1;
if (tile17 != null && tile17.nactive() && !tile17.bottomSlope())
index9 = (int) tile17.type;
if (tile18 != null && tile18.nactive() && !tile18.halfBrick() && !tile18.topSlope())
index8 = (int) tile18.type;
if (tile19 != null && tile19.nactive() && (tile19.slope() == (byte) 0 || (int) tile19.slope() % 2 != 1))
index10 = (int) tile19.type;
if (tile20 != null && tile20.nactive() && (tile20.slope() == (byte) 0 || (int) tile20.slope() % 2 != 0))
index11 = (int) tile20.type;
if (tile21 != null && tile21.nactive())
num10 = (int) tile21.type;
if (tile22 != null && tile22.nactive())
num11 = (int) tile22.type;
if (tile23 != null && tile23.nactive())
num12 = (int) tile23.type;
if (tile24 != null && tile24.nactive())
num13 = (int) tile24.type;
bool flag1 = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
if (index8 >= 0 && Main.tileSolid[index8] && (!Main.tileNoAttach[index8] || TileID.Sets.Platforms[index8]) && (tile18.bottomSlope() || tile18.slope() == (byte) 0) && !tile18.halfBrick())
flag4 = true;
if (index9 >= 0 && Main.tileSolid[index9] && (!Main.tileNoAttach[index9] || TileID.Sets.Platforms[index9] && tile17.halfBrick()) && (tile17.topSlope() || tile17.slope() == (byte) 0 || tile17.halfBrick()))
flag1 = true;
if (index10 >= 0 && Main.tileSolid[index10] && !Main.tileNoAttach[index10] && (tile19.leftSlope() || tile19.slope() == (byte) 0) && !tile19.halfBrick() || index10 == 124 || index10 == 5 && num12 == 5 && num10 == 5)
flag2 = true;
if (index11 >= 0 && Main.tileSolid[index11] && !Main.tileNoAttach[index11] && (tile20.rightSlope() || tile20.slope() == (byte) 0) && !tile20.halfBrick() || index11 == 124 || index11 == 5 && num13 == 5 && num11 == 5)
flag3 = true;
bool flag5;
switch ((int) centerTile.frameX / 22)
{
case 0:
flag5 = !flag4;
break;
case 1:
flag5 = !flag1;
break;
case 2:
flag5 = !flag2;
break;
case 3:
flag5 = !flag3;
break;
default:
flag5 = true;
break;
}
if (!flag5)
return;
if (flag4)
{
centerTile.frameX = (short) 0;
return;
}
if (flag1)
{
centerTile.frameX = (short) 22;
return;
}
if (flag2)
{
centerTile.frameX = (short) 44;
return;
}
if (flag3)
{
centerTile.frameX = (short) 66;
return;
}
WorldGen.KillTile(i, j);
return;
default:
if (index1 == 129 || index1 == 149)
{
Tile tile25 = Main.tile[i, j - 1];
Tile tile26 = Main.tile[i, j + 1];
Tile tile27 = Main.tile[i - 1, j];
Tile tile28 = Main.tile[i + 1, j];
int index12 = -1;
int index13 = -1;
int index14 = -1;
int index15 = -1;
if (tile25 != null && tile25.nactive() && !tile25.bottomSlope())
index13 = (int) tile25.type;
if (tile26 != null && tile26.nactive() && !tile26.halfBrick() && !tile26.topSlope())
index12 = (int) tile26.type;
if (tile27 != null && tile27.nactive())
index14 = (int) tile27.type;
if (tile28 != null && tile28.nactive())
index15 = (int) tile28.type;
if (index12 >= 0 && Main.tileSolid[index12] && !Main.tileSolidTop[index12])
{
centerTile.frameY = (short) 0;
return;
}
if (index14 >= 0 && Main.tileSolid[index14] && !Main.tileSolidTop[index14])
{
centerTile.frameY = (short) 54;
return;
}
if (index15 >= 0 && Main.tileSolid[index15] && !Main.tileSolidTop[index15])
{
centerTile.frameY = (short) 36;
return;
}
if (index13 >= 0 && Main.tileSolid[index13] && !Main.tileSolidTop[index13])
{
centerTile.frameY = (short) 18;
return;
}
WorldGen.KillTile(i, j);
return;
}
if (index1 >= 373 && index1 <= 375 || index1 == 461)
{
Tile tile29 = Main.tile[i, j - 1];
if (tile29 != null && tile29.active() && !tile29.bottomSlope() && Main.tileSolid[(int) tile29.type] && !Main.tileSolidTop[(int) tile29.type])
return;
WorldGen.KillTile(i, j);
return;
}
switch (index1)
{
case 178:
Tile tile30 = Main.tile[i, j - 1];
Tile tile31 = Main.tile[i, j + 1];
Tile tile32 = Main.tile[i - 1, j];
Tile tile33 = Main.tile[i + 1, j];
int index16 = -1;
int index17 = -1;
int index18 = -1;
int index19 = -1;
if (tile30 != null && tile30.active() && !tile30.bottomSlope())
index17 = (int) tile30.type;
if (tile31 != null && tile31.active() && !tile31.halfBrick() && !tile31.topSlope())
index16 = (int) tile31.type;
if (tile32 != null && tile32.active())
index18 = (int) tile32.type;
if (tile33 != null && tile33.active())
index19 = (int) tile33.type;
short num14 = (short) (WorldGen.genRand.Next(3) * 18);
if (index16 >= 0 && Main.tileSolid[index16] && !Main.tileSolidTop[index16])
{
if (centerTile.frameY >= (short) 0 && centerTile.frameY <= (short) 36)
return;
centerTile.frameY = num14;
return;
}
if (index18 >= 0 && Main.tileSolid[index18] && !Main.tileSolidTop[index18])
{
if (centerTile.frameY >= (short) 108 && centerTile.frameY <= (short) 54)
return;
centerTile.frameY = (short) (108 + (int) num14);
return;
}
if (index19 >= 0 && Main.tileSolid[index19] && !Main.tileSolidTop[index19])
{
if (centerTile.frameY >= (short) 162 && centerTile.frameY <= (short) 198)
return;
centerTile.frameY = (short) (162 + (int) num14);
return;
}
if (index17 >= 0 && Main.tileSolid[index17] && !Main.tileSolidTop[index17])
{
if (centerTile.frameY >= (short) 54 && centerTile.frameY <= (short) 90)
return;
centerTile.frameY = (short) (54 + (int) num14);
return;
}
WorldGen.KillTile(i, j);
return;
case 184:
Tile tile34 = Main.tile[i, j - 1];
Tile tile35 = Main.tile[i, j + 1];
Tile tile36 = Main.tile[i - 1, j];
Tile tile37 = Main.tile[i + 1, j];
int index20 = -1;
int index21 = -1;
int index22 = -1;
int index23 = -1;
if (tile34 != null && tile34.active() && !tile34.bottomSlope())
index21 = (int) tile34.type;
if (tile35 != null && tile35.active() && !tile35.halfBrick() && !tile35.topSlope())
index20 = (int) tile35.type;
if (tile36 != null && tile36.active())
index22 = (int) tile36.type;
if (tile37 != null && tile37.active())
index23 = (int) tile37.type;
short num15 = (short) (WorldGen.genRand.Next(3) * 18);
if (index20 >= 0 && Main.tileMoss[index20])
{
centerTile.frameX = index20 != 381 ? (short) (22 * (index20 - 179)) : (short) 110;
if (centerTile.frameY >= (short) 0 && centerTile.frameY <= (short) 36)
return;
centerTile.frameY = num15;
return;
}
if (index21 >= 0 && Main.tileMoss[index21])
{
centerTile.frameX = index21 != 381 ? (short) (22 * (index21 - 179)) : (short) 110;
if (centerTile.frameY >= (short) 54 && centerTile.frameY <= (short) 90)
return;
centerTile.frameY = (short) (54 + (int) num15);
return;
}
if (index22 >= 0 && Main.tileMoss[index22])
{
centerTile.frameX = index22 != 381 ? (short) (22 * (index22 - 179)) : (short) 110;
if (centerTile.frameY >= (short) 108 && centerTile.frameY <= (short) 54)
return;
centerTile.frameY = (short) (108 + (int) num15);
return;
}
if (index23 >= 0 && Main.tileMoss[index23])
{
centerTile.frameX = index23 != 381 ? (short) (22 * (index23 - 179)) : (short) 110;
if (centerTile.frameY >= (short) 162 && centerTile.frameY <= (short) 198)
return;
centerTile.frameY = (short) (162 + (int) num15);
return;
}
WorldGen.KillTile(i, j);
return;
default:
if (index1 == 3 || index1 == 24 || index1 == 61 || index1 == 71 || index1 == 73 || index1 == 74 || index1 == 110 || index1 == 113 || index1 == 201)
{
WorldGen.PlantCheck(i, j);
return;
}
if (index1 == 227)
{
WorldGen.CheckDye(i, j);
return;
}
if (index1 == 12 || index1 == 31)
{
WorldGen.CheckOrb(i, j, index1);
return;
}
switch (index1)
{
case 165:
WorldGen.CheckTight(i, j);
return;
case 185:
WorldGen.CheckPile(i, j);
return;
case 235:
WorldGen.Check3x1(i, j, index1);
return;
case 324:
Tile tile38 = Main.tile[i, j + 1];
if (tile38 == null)
{
tile38 = new Tile();
Main.tile[i, j + 1] = tile38;
}
if (tile38.nactive() && (Main.tileSolid[(int) tile38.type] || Main.tileSolidTop[(int) tile38.type]))
return;
WorldGen.KillTile(i, j);
return;
default:
if (index1 >= 275 && index1 <= 281 || index1 == 296 || index1 == 297 || index1 == 309 || index1 == 358 || index1 == 359 || index1 == 413 || index1 == 414)
{
WorldGen.Check6x3(i, j, index1);
return;
}
switch (index1)
{
case 10:
if (WorldGen.destroyObject)
return;
bool flag6 = false;
int frameY2 = (int) centerTile.frameY;
int doorStyle1 = frameY2 / 54 + (int) centerTile.frameX / 54 * 36;
int j1 = j - frameY2 % 54 / 18;
Tile tile39 = Main.tile[i, j1 - 1];
Tile tile40 = Main.tile[i, j1];
Tile tile41 = Main.tile[i, j1 + 1];
Tile tile42 = Main.tile[i, j1 + 2];
Tile testTile1 = Main.tile[i, j1 + 3];
if (tile39 == null)
{
tile39 = new Tile();
Main.tile[i, j1 - 1] = tile39;
}
if (tile40 == null)
{
tile40 = new Tile();
Main.tile[i, j1] = tile40;
}
if (tile41 == null)
{
tile41 = new Tile();
Main.tile[i, j1 + 1] = tile41;
}
if (tile42 == null)
{
tile42 = new Tile();
Main.tile[i, j1 + 2] = tile42;
}
if (testTile1 == null)
{
testTile1 = new Tile();
Main.tile[i, j1 + 3] = testTile1;
}
if (!tile39.active() || !Main.tileSolid[(int) tile39.type])
flag6 = true;
if (!WorldGen.SolidTile(testTile1))
flag6 = true;
if (!tile40.active() || (int) tile40.type != index1)
flag6 = true;
if (!tile41.active() || (int) tile41.type != index1)
flag6 = true;
if (!tile42.active() || (int) tile42.type != index1)
flag6 = true;
if (flag6)
{
WorldGen.destroyObject = true;
WorldGen.KillTile(i, j1);
WorldGen.KillTile(i, j1 + 1);
WorldGen.KillTile(i, j1 + 2);
WorldGen.DropDoorItem(i, j, doorStyle1);
}
WorldGen.destroyObject = false;
return;
case 11:
if (WorldGen.destroyObject)
return;
int num16 = 0;
int index24 = i;
int frameX2 = (int) centerTile.frameX;
int frameY3 = (int) centerTile.frameY;
int doorStyle2 = frameY3 / 54 + (int) centerTile.frameX / 72 * 36;
int num17 = j - frameY3 % 54 / 18;
bool flag7 = false;
switch (frameX2 % 72)
{
case 0:
index24 = i;
num16 = 1;
break;
case 18:
index24 = i - 1;
num16 = 1;
break;
case 36:
index24 = i + 1;
num16 = -1;
break;
case 54:
index24 = i;
num16 = -1;
break;
}
Tile tile43 = Main.tile[index24, num17 - 1];
Tile testTile2 = Main.tile[index24, num17 + 3];
if (tile43 == null)
{
tile43 = new Tile();
Main.tile[index24, num17 - 1] = tile43;
}
if (testTile2 == null)
{
testTile2 = new Tile();
Main.tile[index24, num17 + 3] = testTile2;
}
if (!tile43.active() || !Main.tileSolid[(int) tile43.type] || !WorldGen.SolidTile(testTile2))
{
flag7 = true;
WorldGen.destroyObject = true;
WorldGen.DropDoorItem(i, j, doorStyle2);
}
int num18 = index24;
if (num16 == -1)
num18 = index24 - 1;
for (int i1 = num18; i1 < num18 + 2; ++i1)
{
for (int j2 = num17; j2 < num17 + 3; ++j2)
{
if (!flag7)
{
Tile tile44 = Main.tile[i1, j2];
if (!tile44.active() || tile44.type != (ushort) 11)
{
WorldGen.destroyObject = true;
WorldGen.DropDoorItem(i, j, doorStyle2);
flag7 = true;
i1 = num18;
j2 = num17;
}
}
if (flag7)
WorldGen.KillTile(i1, j2);
}
}
WorldGen.destroyObject = false;
return;
case 314:
Minecart.FrameTrack(i, j, false);
return;
case 380:
Tile tile45 = Main.tile[i - 1, j];
if (tile45 == null)
return;
Tile tile46 = Main.tile[i + 1, j];
if (tile46 == null || Main.tile[i - 1, j + 1] == null || Main.tile[i + 1, j + 1] == null || Main.tile[i - 1, j - 1] == null || Main.tile[i + 1, j - 1] == null)
return;
int index25 = -1;
int index26 = -1;
if (tile45 != null && tile45.active())
index26 = !Main.tileStone[(int) tile45.type] ? (int) tile45.type : 1;
if (tile46 != null && tile46.active())
index25 = !Main.tileStone[(int) tile46.type] ? (int) tile46.type : 1;
if (index25 >= 0 && !Main.tileSolid[index25])
index25 = -1;
if (index26 >= 0 && !Main.tileSolid[index26])
index26 = -1;
rectangle.X = index26 != index1 || index25 != index1 ? (index26 != index1 || index25 == index1 ? (index26 == index1 || index25 != index1 ? 54 : 0) : 36) : 18;
centerTile.frameX = (short) rectangle.X;
return;
default:
if (index1 >= 0 && TileID.Sets.Platforms[index1])
{
Tile tile47 = Main.tile[i - 1, j];
if (tile47 == null)
return;
Tile tile48 = Main.tile[i + 1, j];
if (tile48 == null)
return;
Tile tile49 = Main.tile[i - 1, j + 1];
if (tile49 == null)
return;
Tile tile50 = Main.tile[i + 1, j + 1];
if (tile50 == null)
return;
Tile tile51 = Main.tile[i - 1, j - 1];
if (tile51 == null)
return;
Tile tile52 = Main.tile[i + 1, j - 1];
if (tile52 == null)
return;
int index27 = -1;
int index28 = -1;
if (tile47 != null && tile47.active())
index28 = !Main.tileStone[(int) tile47.type] ? (!TileID.Sets.Platforms[(int) tile47.type] ? (int) tile47.type : index1) : 1;
if (tile48 != null && tile48.active())
index27 = !Main.tileStone[(int) tile48.type] ? (!TileID.Sets.Platforms[(int) tile48.type] ? (int) tile48.type : index1) : 1;
if (index27 >= 0 && !Main.tileSolid[index27])
index27 = -1;
if (index28 >= 0 && !Main.tileSolid[index28])
index28 = -1;
if (index28 == index1 && tile47.halfBrick() != centerTile.halfBrick())
index28 = -1;
if (index27 == index1 && tile48.halfBrick() != centerTile.halfBrick())
index27 = -1;
if (index28 != -1 && index28 != index1 && centerTile.halfBrick())
index28 = -1;
if (index27 != -1 && index27 != index1 && centerTile.halfBrick())
index27 = -1;
if (index28 == -1 && tile51.active() && (int) tile51.type == index1 && tile51.slope() == (byte) 1)
index28 = index1;
if (index27 == -1 && tile52.active() && (int) tile52.type == index1 && tile52.slope() == (byte) 2)
index27 = index1;
if (index28 == index1 && tile47.slope() == (byte) 2 && index27 != index1)
index27 = -1;
if (index27 == index1 && tile48.slope() == (byte) 1 && index28 != index1)
index28 = -1;
rectangle.X = centerTile.slope() != (byte) 1 ? (centerTile.slope() != (byte) 2 ? (index28 != index1 || index27 != index1 ? (index28 != index1 || index27 != -1 ? (index28 != -1 || index27 != index1 ? (index28 == index1 || index27 != index1 ? (index28 != index1 || index27 == index1 ? (index28 == index1 || index28 == -1 || index27 != -1 ? (index28 != -1 || index27 == index1 || index27 == -1 ? 90 : 126) : 108) : 72) : 54) : (tile48.slope() != (byte) 1 ? 36 : 288)) : (tile47.slope() != (byte) 2 ? 18 : 270)) : (tile47.slope() != (byte) 2 || tile48.slope() != (byte) 1 ? (tile47.slope() != (byte) 2 ? (tile48.slope() != (byte) 1 ? 0 : 234) : 216) : 252)) : (!TileID.Sets.Platforms[(int) tile47.type] || tile47.slope() != (byte) 0 ? (tile49.active() || TileID.Sets.Platforms[(int) tile49.type] && tile49.slope() != (byte) 1 ? (tile48.active() || TileID.Sets.Platforms[(int) tile52.type] && tile52.slope() == (byte) 2 ? 144 : 378) : (tile48.active() || TileID.Sets.Platforms[(int) tile52.type] && tile52.slope() == (byte) 2 ? 342 : 414)) : 450)) : (!TileID.Sets.Platforms[(int) tile48.type] || tile48.slope() != (byte) 0 ? (tile50.active() || TileID.Sets.Platforms[(int) tile50.type] && tile50.slope() != (byte) 2 ? (tile47.active() || TileID.Sets.Platforms[(int) tile51.type] && tile51.slope() == (byte) 1 ? 180 : 396) : (tile47.active() || TileID.Sets.Platforms[(int) tile51.type] && tile51.slope() == (byte) 1 ? 360 : 432)) : 468);
centerTile.frameX = (short) rectangle.X;
return;
}
if (index1 == 233 || index1 == 236 || index1 == 238)
{
WorldGen.CheckJunglePlant(i, j, index1);
return;
}
if (index1 == 240 || index1 == 440)
{
WorldGen.Check3x3Wall(i, j);
return;
}
switch (index1)
{
case 241:
WorldGen.Check4x3Wall(i, j);
return;
case 242:
WorldGen.Check6x4Wall(i, j);
return;
case 245:
WorldGen.Check2x3Wall(i, j);
return;
case 246:
WorldGen.Check3x2Wall(i, j);
return;
default:
if (index1 == 464 || index1 == 466)
{
WorldGen.Check5x4(i, j, index1);
return;
}
if (index1 == 334)
{
WorldGen.CheckWeaponsRack(i, j);
return;
}
if (index1 == 34 || index1 == 454)
{
WorldGen.CheckChand(i, j, index1);
return;
}
if (index1 == 106 || index1 == 212 || index1 == 219 || index1 == 220 || index1 == 228 || index1 == 231 || index1 == 243 || index1 == 247 || index1 == 283 || index1 >= 300 && index1 <= 308 || index1 == 354 || index1 == 406 || index1 == 412 || index1 == 355 || index1 == 452 || index1 == 455)
{
WorldGen.Check3x3(i, j, (int) (ushort) index1);
return;
}
if (index1 == 15 || index1 == 20 || index1 == 216 || index1 == 338 || index1 == 390)
{
WorldGen.Check1x2(i, j, (ushort) index1);
return;
}
if (index1 == 14 || index1 == 469 || index1 == 17 || index1 == 26 || index1 == 77 || index1 == 86 || index1 == 87 || index1 == 377 || index1 == 88 || index1 == 89 || index1 == 114 || index1 == 133 || index1 == 186 || index1 == 187 || index1 == 215 || index1 == 217 || index1 == 218 || index1 == 237 || index1 == 244 || index1 == 285 || index1 == 286 || index1 == 298 || index1 == 299 || index1 == 310 || index1 == 339 || index1 >= 361 && index1 <= 364 || index1 >= 391 && index1 <= 394 || index1 == 405)
{
WorldGen.Check3x2(i, j, (int) (ushort) index1);
return;
}
if (index1 == 135 || index1 == 144 || index1 == 141 || index1 == 210 || index1 == 239 || index1 == 36 || index1 == 428)
{
WorldGen.Check1x1(i, j, index1);
return;
}
if (index1 == 419 || index1 == 420 || index1 == 423 || index1 == 424 || index1 == 429 || index1 == 445)
{
WorldGen.CheckLogicTiles(i, j, index1);
return;
}
if (index1 == 16 || index1 == 18 || index1 == 29 || index1 == 103 || index1 == 134 || index1 == 462)
{
WorldGen.Check2x1(i, j, (ushort) index1);
return;
}
if (index1 == 13 || index1 == 33 || index1 == 50 || index1 == 78 || index1 == 174 || index1 == 372)
{
WorldGen.CheckOnTable1x1(i, j, (int) (byte) index1);
return;
}
if (TileID.Sets.BasicChest[index1])
{
WorldGen.CheckChest(i, j, index1);
return;
}
switch (index1)
{
case 27:
WorldGen.CheckSunflower(i, j);
return;
case 28:
WorldGen.CheckPot(i, j);
return;
case 128:
WorldGen.CheckMan(i, j);
return;
case 171:
WorldGen.CheckXmasTree(i, j);
return;
case 254:
WorldGen.Check2x2Style(i, j, index1);
return;
case 269:
WorldGen.CheckWoman(i, j);
return;
default:
if (!TileID.Sets.BasicChestFake[index1] && index1 != 457)
{
if (index1 == 335 || index1 == 411)
{
WorldGen.Check2x2(i, j, index1);
return;
}
if (index1 == 132 || index1 == 138 || index1 == 142 || index1 == 143 || index1 >= 288 && index1 <= 295 || index1 >= 316 && index1 <= 318 || index1 == 172 || index1 == 360)
{
WorldGen.Check2x2(i, j, index1);
return;
}
if (index1 == 376 || index1 == 443 || index1 == 444)
{
WorldGen.CheckSuper(i, j, index1);
return;
}
if (index1 == 91)
{
WorldGen.CheckBanner(i, j, (byte) index1);
return;
}
if (index1 == 139 || index1 == 35)
{
WorldGen.CheckMB(i, j, (int) (byte) index1);
return;
}
if (index1 == 386 || index1 == 387)
{
WorldGen.CheckTrapDoor(i, j, index1);
return;
}
if (index1 == 389 || index1 == 388)
{
WorldGen.CheckTallGate(i, j, index1);
return;
}
if (index1 == 92 || index1 == 93 || index1 == 453)
{
WorldGen.Check1xX(i, j, (short) index1);
return;
}
if (index1 == 104 || index1 == 105 || index1 == 207 || index1 == 320 || index1 == 337 || index1 == 349 || index1 == 356 || index1 == 378 || index1 == 410 || index1 == 456 || index1 == 465)
{
WorldGen.Check2xX(i, j, (ushort) index1);
return;
}
if (index1 == 101 || index1 == 102 || index1 == 463)
{
WorldGen.Check3x4(i, j, index1);
return;
}
if (index1 == 42 || index1 == 270 || index1 == 271)
{
WorldGen.Check1x2Top(i, j, (ushort) index1);
return;
}
if (index1 == 55 || index1 == 85 || index1 == 395 || index1 == 425)
{
WorldGen.CheckSign(i, j, (ushort) index1);
return;
}
if (index1 == 209)
{
WorldGen.CheckCannon(i, j, index1);
return;
}
if (index1 == 79 || index1 == 90)
{
WorldGen.Check4x2(i, j, index1);
return;
}
if (index1 == 94 || index1 == 95 || index1 == 97 || index1 == 319 || index1 == 98 || index1 == 99 || index1 == 100 || index1 == 125 || index1 == 126 || index1 == 173 || index1 == 282 || index1 == 287)
{
WorldGen.Check2x2(i, j, index1);
return;
}
switch (index1)
{
case 81:
Tile tile53 = Main.tile[i, j - 1];
Tile tile54 = Main.tile[i, j + 1];
Tile tile55 = Main.tile[i - 1, j];
Tile tile56 = Main.tile[i + 1, j];
int index29 = -1;
int num19 = -1;
if (tile53 != null && tile53.active())
num19 = (int) tile53.type;
if (tile54 != null && tile54.active())
index29 = (int) tile54.type;
if (num19 != -1)
{
WorldGen.KillTile(i, j);
return;
}
if (index29 >= 0 && Main.tileSolid[index29] && !tile54.halfBrick() && !tile54.topSlope())
return;
WorldGen.KillTile(i, j);
return;
case 96:
WorldGen.Check2x2Style(i, j, index1);
return;
default:
if (Main.tileAlch[index1])
{
WorldGen.CheckAlch(i, j);
return;
}
switch (index1)
{
case 5:
WorldGen.CheckTree(i, j);
return;
case 72:
Tile tile57 = Main.tile[i, j - 1];
Tile tile58 = Main.tile[i, j + 1];
int num20 = -1;
int num21 = -1;
if (tile57 != null && tile57.active())
num21 = (int) tile57.type;
if (tile58 != null && tile58.active())
num20 = (int) tile58.type;
if (num20 != index1 && num20 != 70)
{
WorldGen.KillTile(i, j);
return;
}
if (num21 == index1 || centerTile.frameX != (short) 0)
return;
centerTile.frameNumber((byte) WorldGen.genRand.Next(3));
if (centerTile.frameNumber() == (byte) 0)
{
centerTile.frameX = (short) 18;
centerTile.frameY = (short) 0;
}
if (centerTile.frameNumber() == (byte) 1)
{
centerTile.frameX = (short) 18;
centerTile.frameY = (short) 18;
}
if (centerTile.frameNumber() != (byte) 2)
return;
centerTile.frameX = (short) 18;
centerTile.frameY = (short) 36;
return;
case 323:
WorldGen.CheckPalmTree(i, j);
return;
default:
return;
}
}
}
else
goto case 254;
}
}
}
}
}
}
}
else
{
if (index1 >= (int) byte.MaxValue && index1 <= 268 || index1 == 385 || index1 >= 446 && index1 <= 448)
{
Framing.SelfFrame8Way(i, j, centerTile, resetFrame);
return;
}
Tile tile59 = Main.tile[i, j - 1];
Tile tile60 = Main.tile[i, j + 1];
Tile tile61 = Main.tile[i - 1, j];
Tile tile62 = Main.tile[i + 1, j];
Tile tile63 = Main.tile[i - 1, j + 1];
Tile tile64 = Main.tile[i + 1, j + 1];
Tile tile65 = Main.tile[i - 1, j - 1];
Tile tile66 = Main.tile[i + 1, j - 1];
int upLeft = -1;
int up = -1;
int upRight = -1;
int left = -1;
int right = -1;
int downLeft = -1;
int down = -1;
int downRight = -1;
if (tile61 != null && tile61.active())
{
left = !Main.tileStone[(int) tile61.type] ? (int) tile61.type : 1;
if (tile61.slope() == (byte) 1 || tile61.slope() == (byte) 3)
left = -1;
}
if (tile62 != null && tile62.active())
{
right = !Main.tileStone[(int) tile62.type] ? (int) tile62.type : 1;
if (tile62.slope() == (byte) 2 || tile62.slope() == (byte) 4)
right = -1;
}
if (tile59 != null && tile59.active())
{
up = !Main.tileStone[(int) tile59.type] ? (int) tile59.type : 1;
if (tile59.slope() == (byte) 3 || tile59.slope() == (byte) 4)
up = -1;
}
if (tile60 != null && tile60.active())
{
down = !Main.tileStone[(int) tile60.type] ? (int) tile60.type : 1;
if (tile60.slope() == (byte) 1 || tile60.slope() == (byte) 2)
down = -1;
}
if (tile65 != null && tile65.active())
upLeft = !Main.tileStone[(int) tile65.type] ? (int) tile65.type : 1;
if (tile66 != null && tile66.active())
upRight = !Main.tileStone[(int) tile66.type] ? (int) tile66.type : 1;
if (tile63 != null && tile63.active())
downLeft = !Main.tileStone[(int) tile63.type] ? (int) tile63.type : 1;
if (tile64 != null && tile64.active())
downRight = !Main.tileStone[(int) tile64.type] ? (int) tile64.type : 1;
if (centerTile.slope() == (byte) 2)
{
up = -1;
left = -1;
}
if (centerTile.slope() == (byte) 1)
{
up = -1;
right = -1;
}
if (centerTile.slope() == (byte) 4)
{
down = -1;
left = -1;
}
if (centerTile.slope() == (byte) 3)
{
down = -1;
right = -1;
}
switch (index1)
{
case 147:
WorldGen.TileMergeAttempt(index1, Main.tileBrick, TileID.Sets.Ices, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 161:
case 163:
case 164:
case 200:
WorldGen.TileMergeAttempt(index1, Main.tileBrick, TileID.Sets.Snow, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 162:
WorldGen.TileMergeAttempt(index1, Main.tileBrick, TileID.Sets.IcesSnow, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
default:
if (Main.tileBrick[index1])
{
if (index1 == 60 || index1 == 70)
{
WorldGen.TileMergeAttempt(index1, Main.tileBrick, TileID.Sets.Mud, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
}
WorldGen.TileMergeAttempt(index1, Main.tileBrick, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
}
if (Main.tilePile[index1])
{
WorldGen.TileMergeAttempt(index1, Main.tilePile, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
}
break;
}
if ((index1 == 1 || Main.tileMoss[index1] || index1 == 117 || index1 == 25 || index1 == 203) && down == 165)
{
if (tile60.frameY == (short) 72)
down = index1;
else if (tile60.frameY == (short) 0)
down = index1;
}
if ((index1 == 1 || Main.tileMoss[index1] || index1 == 117 || index1 == 25 || index1 == 203) && up == 165)
{
if (tile59.frameY == (short) 90)
up = index1;
else if (tile59.frameY == (short) 54)
up = index1;
}
if (index1 == 225)
{
if (down == 165)
down = index1;
if (up == 165)
up = index1;
}
if ((index1 == 200 || index1 == 161 || index1 == 163 || index1 == 164) && down == 165)
down = index1;
if ((centerTile.slope() == (byte) 1 || centerTile.slope() == (byte) 2) && down > -1 && !TileID.Sets.Platforms[down])
down = index1;
if (up > -1 && (tile59.slope() == (byte) 1 || tile59.slope() == (byte) 2) && !TileID.Sets.Platforms[up])
up = index1;
if ((centerTile.slope() == (byte) 3 || centerTile.slope() == (byte) 4) && up > -1 && !TileID.Sets.Platforms[up])
up = index1;
if (down > -1 && (tile60.slope() == (byte) 3 || tile60.slope() == (byte) 4) && !TileID.Sets.Platforms[down])
down = index1;
if (index1 == 124)
{
if (up > -1 && Main.tileSolid[up])
up = index1;
if (down > -1 && Main.tileSolid[down])
down = index1;
}
if (up > -1 && tile59.halfBrick() && !TileID.Sets.Platforms[up])
up = index1;
if (left > -1 && tile61.halfBrick())
{
if (centerTile.halfBrick())
left = index1;
else if ((int) tile61.type != index1)
left = -1;
}
if (right > -1 && tile62.halfBrick())
{
if (centerTile.halfBrick())
right = index1;
else if ((int) tile62.type != index1)
right = -1;
}
if (centerTile.halfBrick())
{
if (left != index1)
left = -1;
if (right != index1)
right = -1;
up = -1;
}
if (tile60 != null && tile60.halfBrick())
down = -1;
if (!Main.tileSolid[index1])
{
if (index1 == 49)
{
WorldGen.CheckOnTable1x1(i, j, (int) (byte) index1);
return;
}
if (index1 == 80)
{
WorldGen.CactusFrame(i, j);
return;
}
}
WorldGen.mergeUp = false;
WorldGen.mergeDown = false;
WorldGen.mergeLeft = false;
WorldGen.mergeRight = false;
int num22;
if (resetFrame)
{
num22 = WorldGen.genRand.Next(0, 3);
centerTile.frameNumber((byte) num22);
}
else
num22 = (int) centerTile.frameNumber();
if (Main.tileLargeFrames[index1] == (byte) 1)
num22 = new int[4, 3]
{
{
2,
4,
2
},
{
1,
3,
1
},
{
2,
2,
4
},
{
1,
1,
3
}
}[j % 4, i % 3] - 1;
WorldGen.TileMergeAttempt(index1, Main.tileBlendAll, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
if (Main.tileBlendAll[index1])
WorldGen.TileMergeAttempt(index1, Main.tileSolid, Main.tileSolidTop, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
switch (index1)
{
case 0:
if (up > -1 && Main.tileMergeDirt[up])
{
WorldGen.TileFrame(i, j - 1);
if (WorldGen.mergeDown)
up = index1;
}
else if (up == 147)
{
WorldGen.TileFrame(i, j - 1);
if (WorldGen.mergeDown)
up = index1;
}
if (down > -1 && Main.tileMergeDirt[down])
{
WorldGen.TileFrame(i, j + 1);
if (WorldGen.mergeUp)
down = index1;
}
else if (down == 147)
{
WorldGen.TileFrame(i, j + 1);
if (WorldGen.mergeUp)
down = index1;
}
if (left > -1 && Main.tileMergeDirt[left])
{
WorldGen.TileFrame(i - 1, j);
if (WorldGen.mergeRight)
left = index1;
}
else if (left == 147)
{
WorldGen.TileFrame(i - 1, j);
if (WorldGen.mergeRight)
left = index1;
}
if (right > -1 && Main.tileMergeDirt[right])
{
WorldGen.TileFrame(i + 1, j);
if (WorldGen.mergeLeft)
right = index1;
}
else if (right == 147)
{
WorldGen.TileFrame(i + 1, j);
if (WorldGen.mergeLeft)
right = index1;
}
if (up == 2 || up == 23 || up == 109 || up == 199)
up = index1;
if (down == 2 || down == 23 || down == 109 || down == 199)
down = index1;
if (left == 2 || left == 23 || left == 109 || left == 199)
left = index1;
if (right == 2 || right == 23 || right == 109 || right == 199)
right = index1;
if (upLeft > -1 && Main.tileMergeDirt[upLeft])
upLeft = index1;
else if (upLeft == 2 || upLeft == 23 || upLeft == 109 || upLeft == 199)
upLeft = index1;
if (upRight > -1 && Main.tileMergeDirt[upRight])
upRight = index1;
else if (upRight == 2 || upRight == 23 || upRight == 109 || upRight == 199)
upRight = index1;
if (downLeft > -1 && Main.tileMergeDirt[downLeft])
downLeft = index1;
else if (downLeft == 2 || downLeft == 23 || downLeft == 109 || downLeft == 199)
downLeft = index1;
if (downRight > -1 && Main.tileMergeDirt[downRight])
downRight = index1;
else if (downRight == 2 || downRight == 23 || downRight == 109 || downRight == 199)
downRight = index1;
WorldGen.TileMergeAttempt(-2, 59, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttempt(index1, 191, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 53:
WorldGen.TileMergeAttemptFrametest(i, j, index1, 397, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 396, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 112:
WorldGen.TileMergeAttemptFrametest(i, j, index1, 398, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 400, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 116:
WorldGen.TileMergeAttemptFrametest(i, j, index1, 402, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 403, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 213:
if (up > -1 && Main.tileSolid[up] && !Main.tileSolidTop[up])
up = index1;
if (down > -1 && Main.tileSolid[down])
down = index1;
if (up != index1)
{
if (left > -1 && Main.tileSolid[left])
left = index1;
if (right > -1 && Main.tileSolid[right])
{
right = index1;
break;
}
break;
}
break;
case 234:
WorldGen.TileMergeAttemptFrametest(i, j, index1, 399, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 401, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
}
if (Main.tileMergeDirt[index1])
{
WorldGen.TileMergeAttempt(-2, 0, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
if (index1 == 1)
{
if ((double) j > Main.rockLayer)
WorldGen.TileMergeAttemptFrametest(i, j, index1, 59, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 57, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
}
}
else
{
switch (index1)
{
case 32:
if (down == 23)
{
down = index1;
break;
}
break;
case 51:
WorldGen.TileMergeAttempt(index1, TileID.Sets.AllTiles, Main.tileNoAttach, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 57:
WorldGen.TileMergeAttempt(-2, 1, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, TileID.Sets.HellSpecial, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 58:
case 75:
case 76:
WorldGen.TileMergeAttempt(-2, 57, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 59:
if ((double) j > Main.rockLayer)
WorldGen.TileMergeAttempt(-2, 1, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttempt(index1, TileID.Sets.GrassSpecial, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, TileID.Sets.JungleSpecial, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
if ((double) j < Main.rockLayer)
{
WorldGen.TileMergeAttemptFrametest(i, j, index1, 0, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
}
WorldGen.TileMergeAttempt(index1, 0, ref up, ref down, ref left, ref right);
break;
case 60:
WorldGen.TileMergeAttempt(59, 211, ref up, ref down, ref left, ref right);
break;
case 69:
if (down == 60)
{
down = index1;
break;
}
break;
case 147:
WorldGen.TileMergeAttemptFrametest(i, j, index1, TileID.Sets.IcesSlush, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 161:
case 163:
case 164:
case 200:
case 224:
WorldGen.TileMergeAttempt(-2, 147, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 162:
WorldGen.TileMergeAttempt(-2, TileID.Sets.IcesSnow, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 189:
WorldGen.TileMergeAttemptFrametest(i, j, index1, 196, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 191:
WorldGen.TileMergeAttempt(-2, 192, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttempt(index1, 0, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 192:
WorldGen.TileMergeAttemptFrametest(i, j, index1, 191, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 196:
WorldGen.TileMergeAttempt(-2, 189, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 211:
WorldGen.TileMergeAttempt(59, 60, ref up, ref down, ref left, ref right);
WorldGen.TileMergeAttempt(-2, 59, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 225:
case 226:
WorldGen.TileMergeAttempt(-2, 59, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 352:
if (down == 199)
{
down = index1;
break;
}
break;
case 383:
WorldGen.TileMergeAttempt(-2, 384, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttempt(index1, 59, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 384:
WorldGen.TileMergeAttemptFrametest(i, j, index1, 383, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 396:
WorldGen.TileMergeAttempt(-2, 397, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttempt(-2, 53, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 404, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 397:
WorldGen.TileMergeAttempt(-2, 53, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 396, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 398:
WorldGen.TileMergeAttempt(-2, 112, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 400, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 399:
WorldGen.TileMergeAttempt(-2, 234, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 401, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 400:
WorldGen.TileMergeAttempt(-2, 398, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttempt(-2, 112, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 401:
WorldGen.TileMergeAttempt(-2, 399, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttempt(-2, 234, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 402:
WorldGen.TileMergeAttempt(-2, 116, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 403, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 403:
WorldGen.TileMergeAttempt(-2, 402, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttempt(-2, 116, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 404:
WorldGen.TileMergeAttempt(-2, 396, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
WorldGen.TileMergeAttemptFrametest(i, j, index1, 407, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 407:
WorldGen.TileMergeAttempt(-2, 404, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
}
}
if (Main.tileStone[index1] || index1 == 1)
WorldGen.TileMergeAttempt(index1, Main.tileMoss, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
bool flag8 = false;
if (up == -2 && (int) centerTile.color() != (int) tile59.color())
{
up = index1;
WorldGen.mergeUp = true;
}
if (down == -2 && (int) centerTile.color() != (int) tile60.color())
{
down = index1;
WorldGen.mergeDown = true;
}
if (left == -2 && (int) centerTile.color() != (int) tile61.color())
{
left = index1;
WorldGen.mergeLeft = true;
}
if (right == -2 && (int) centerTile.color() != (int) tile62.color())
{
right = index1;
WorldGen.mergeRight = true;
}
if (index1 == 2 || index1 == 23 || index1 == 60 || index1 == 70 || index1 == 109 || index1 == 199 || Main.tileMoss[index1] || TileID.Sets.NeedsGrassFraming[index1])
{
flag8 = true;
WorldGen.TileMergeAttemptWeird(index1, -1, Main.tileSolid, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
int num23 = TileID.Sets.NeedsGrassFramingDirt[index1];
if (index1 == 60 || index1 == 70)
num23 = 59;
else if (Main.tileMoss[index1])
{
num23 = 1;
}
else
{
switch (index1)
{
case 2:
WorldGen.TileMergeAttempt(num23, 23, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
case 23:
WorldGen.TileMergeAttempt(num23, 2, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
break;
}
}
if (up != index1 && up != num23 && (down == index1 || down == num23))
{
if (left == num23 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 198;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 198;
break;
default:
rectangle.X = 36;
rectangle.Y = 198;
break;
}
}
else if (left == index1 && right == num23)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 198;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 198;
break;
default:
rectangle.X = 90;
rectangle.Y = 198;
break;
}
}
}
else if (down != index1 && down != num23 && (up == index1 || up == num23))
{
if (left == num23 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 216;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 216;
break;
default:
rectangle.X = 36;
rectangle.Y = 216;
break;
}
}
else if (left == index1 && right == num23)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 216;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 216;
break;
default:
rectangle.X = 90;
rectangle.Y = 216;
break;
}
}
}
else if (left != index1 && left != num23 && (right == index1 || right == num23))
{
if (up == num23 && down == index1)
{
switch (num22)
{
case 0:
rectangle.X = 72;
rectangle.Y = 144;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 162;
break;
default:
rectangle.X = 72;
rectangle.Y = 180;
break;
}
}
else if (down == index1 && up == num23)
{
switch (num22)
{
case 0:
rectangle.X = 72;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 108;
break;
default:
rectangle.X = 72;
rectangle.Y = 126;
break;
}
}
}
else if (right != index1 && right != num23 && (left == index1 || left == num23))
{
if (up == num23 && down == index1)
{
switch (num22)
{
case 0:
rectangle.X = 90;
rectangle.Y = 144;
break;
case 1:
rectangle.X = 90;
rectangle.Y = 162;
break;
default:
rectangle.X = 90;
rectangle.Y = 180;
break;
}
}
else if (down == index1 && right == up)
{
switch (num22)
{
case 0:
rectangle.X = 90;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 90;
rectangle.Y = 108;
break;
default:
rectangle.X = 90;
rectangle.Y = 126;
break;
}
}
}
else if (up == index1 && down == index1 && left == index1 && right == index1)
{
if (upLeft != index1 && upRight != index1 && downLeft != index1 && downRight != index1)
{
if (downRight == num23)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 324;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 324;
break;
default:
rectangle.X = 144;
rectangle.Y = 324;
break;
}
}
else if (upRight == num23)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 342;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 342;
break;
default:
rectangle.X = 144;
rectangle.Y = 342;
break;
}
}
else if (downLeft == num23)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 360;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 360;
break;
default:
rectangle.X = 144;
rectangle.Y = 360;
break;
}
}
else if (upLeft == num23)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 378;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 378;
break;
default:
rectangle.X = 144;
rectangle.Y = 378;
break;
}
}
else
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 234;
break;
case 1:
rectangle.X = 198;
rectangle.Y = 234;
break;
default:
rectangle.X = 252;
rectangle.Y = 234;
break;
}
}
}
else if (upLeft != index1 && downRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 306;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 306;
break;
default:
rectangle.X = 72;
rectangle.Y = 306;
break;
}
}
else if (upRight != index1 && downLeft != index1)
{
switch (num22)
{
case 0:
rectangle.X = 90;
rectangle.Y = 306;
break;
case 1:
rectangle.X = 108;
rectangle.Y = 306;
break;
default:
rectangle.X = 126;
rectangle.Y = 306;
break;
}
}
else if (upLeft != index1 && upRight == index1 && downLeft == index1 && downRight == index1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 144;
break;
default:
rectangle.X = 54;
rectangle.Y = 180;
break;
}
}
else if (upLeft == index1 && upRight != index1 && downLeft == index1 && downRight == index1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 144;
break;
default:
rectangle.X = 36;
rectangle.Y = 180;
break;
}
}
else if (upLeft == index1 && upRight == index1 && downLeft != index1 && downRight == index1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 126;
break;
default:
rectangle.X = 54;
rectangle.Y = 162;
break;
}
}
else if (upLeft == index1 && upRight == index1 && downLeft == index1 && downRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 126;
break;
default:
rectangle.X = 36;
rectangle.Y = 162;
break;
}
}
}
else if (up == index1 && down == num23 && left == index1 && right == index1 && upLeft == -1 && upRight == -1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 18;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 18;
break;
default:
rectangle.X = 144;
rectangle.Y = 18;
break;
}
}
else if (up == num23 && down == index1 && left == index1 && right == index1 && downLeft == -1 && downRight == -1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 36;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 36;
break;
default:
rectangle.X = 144;
rectangle.Y = 36;
break;
}
}
else if (up == index1 && down == index1 && left == num23 && right == index1 && upRight == -1 && downRight == -1)
{
switch (num22)
{
case 0:
rectangle.X = 198;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 198;
rectangle.Y = 18;
break;
default:
rectangle.X = 198;
rectangle.Y = 36;
break;
}
}
else if (up == index1 && down == index1 && left == index1 && right == num23 && upLeft == -1 && downLeft == -1)
{
switch (num22)
{
case 0:
rectangle.X = 180;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 180;
rectangle.Y = 18;
break;
default:
rectangle.X = 180;
rectangle.Y = 36;
break;
}
}
else if (up == index1 && down == num23 && left == index1 && right == index1)
{
if (upRight != -1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 144;
break;
default:
rectangle.X = 54;
rectangle.Y = 180;
break;
}
}
else if (upLeft != -1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 144;
break;
default:
rectangle.X = 36;
rectangle.Y = 180;
break;
}
}
}
else if (up == num23 && down == index1 && left == index1 && right == index1)
{
if (downRight != -1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 126;
break;
default:
rectangle.X = 54;
rectangle.Y = 162;
break;
}
}
else if (downLeft != -1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 126;
break;
default:
rectangle.X = 36;
rectangle.Y = 162;
break;
}
}
}
else if (up == index1 && down == index1 && left == index1 && right == num23)
{
if (upLeft != -1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 126;
break;
default:
rectangle.X = 54;
rectangle.Y = 162;
break;
}
}
else if (downLeft != -1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 144;
break;
default:
rectangle.X = 54;
rectangle.Y = 180;
break;
}
}
}
else if (up == index1 && down == index1 && left == num23 && right == index1)
{
if (upRight != -1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 126;
break;
default:
rectangle.X = 36;
rectangle.Y = 162;
break;
}
}
else if (downRight != -1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 144;
break;
default:
rectangle.X = 36;
rectangle.Y = 180;
break;
}
}
}
else if (up == num23 && down == index1 && left == index1 && right == index1 || up == index1 && down == num23 && left == index1 && right == index1 || up == index1 && down == index1 && left == num23 && right == index1 || up == index1 && down == index1 && left == index1 && right == num23)
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 18;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 18;
break;
default:
rectangle.X = 54;
rectangle.Y = 18;
break;
}
}
if ((up == index1 || up == num23) && (down == index1 || down == num23) && (left == index1 || left == num23) && (right == index1 || right == num23))
{
if (upLeft != index1 && upLeft != num23 && (upRight == index1 || upRight == num23) && (downLeft == index1 || downLeft == num23) && (downRight == index1 || downRight == num23))
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 144;
break;
default:
rectangle.X = 54;
rectangle.Y = 180;
break;
}
}
else if (upRight != index1 && upRight != num23 && (upLeft == index1 || upLeft == num23) && (downLeft == index1 || downLeft == num23) && (downRight == index1 || downRight == num23))
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 144;
break;
default:
rectangle.X = 36;
rectangle.Y = 180;
break;
}
}
else if (downLeft != index1 && downLeft != num23 && (upLeft == index1 || upLeft == num23) && (upRight == index1 || upRight == num23) && (downRight == index1 || downRight == num23))
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 126;
break;
default:
rectangle.X = 54;
rectangle.Y = 162;
break;
}
}
else if (downRight != index1 && downRight != num23 && (upLeft == index1 || upLeft == num23) && (downLeft == index1 || downLeft == num23) && (upRight == index1 || upRight == num23))
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 126;
break;
default:
rectangle.X = 36;
rectangle.Y = 162;
break;
}
}
}
if (up != num23 && up != index1 && down == index1 && left != num23 && left != index1 && right == index1 && downRight != num23 && downRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 90;
rectangle.Y = 270;
break;
case 1:
rectangle.X = 108;
rectangle.Y = 270;
break;
default:
rectangle.X = 126;
rectangle.Y = 270;
break;
}
}
else if (up != num23 && up != index1 && down == index1 && left == index1 && right != num23 && right != index1 && downLeft != num23 && downLeft != index1)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 270;
break;
case 1:
rectangle.X = 162;
rectangle.Y = 270;
break;
default:
rectangle.X = 180;
rectangle.Y = 270;
break;
}
}
else if (down != num23 && down != index1 && up == index1 && left != num23 && left != index1 && right == index1 && upRight != num23 && upRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 90;
rectangle.Y = 288;
break;
case 1:
rectangle.X = 108;
rectangle.Y = 288;
break;
default:
rectangle.X = 126;
rectangle.Y = 288;
break;
}
}
else if (down != num23 && down != index1 && up == index1 && left == index1 && right != num23 && right != index1 && upLeft != num23 && upLeft != index1)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 288;
break;
case 1:
rectangle.X = 162;
rectangle.Y = 288;
break;
default:
rectangle.X = 180;
rectangle.Y = 288;
break;
}
}
else if (up != index1 && up != num23 && down == index1 && left == index1 && right == index1 && downLeft != index1 && downLeft != num23 && downRight != index1 && downRight != num23)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 216;
break;
case 1:
rectangle.X = 198;
rectangle.Y = 216;
break;
default:
rectangle.X = 252;
rectangle.Y = 216;
break;
}
}
else if (down != index1 && down != num23 && up == index1 && left == index1 && right == index1 && upLeft != index1 && upLeft != num23 && upRight != index1 && upRight != num23)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 252;
break;
case 1:
rectangle.X = 198;
rectangle.Y = 252;
break;
default:
rectangle.X = 252;
rectangle.Y = 252;
break;
}
}
else if (left != index1 && left != num23 && down == index1 && up == index1 && right == index1 && upRight != index1 && upRight != num23 && downRight != index1 && downRight != num23)
{
switch (num22)
{
case 0:
rectangle.X = 126;
rectangle.Y = 234;
break;
case 1:
rectangle.X = 180;
rectangle.Y = 234;
break;
default:
rectangle.X = 234;
rectangle.Y = 234;
break;
}
}
else if (right != index1 && right != num23 && down == index1 && up == index1 && left == index1 && upLeft != index1 && upLeft != num23 && downLeft != index1 && downLeft != num23)
{
switch (num22)
{
case 0:
rectangle.X = 162;
rectangle.Y = 234;
break;
case 1:
rectangle.X = 216;
rectangle.Y = 234;
break;
default:
rectangle.X = 270;
rectangle.Y = 234;
break;
}
}
else if (up != num23 && up != index1 && (down == num23 || down == index1) && left == num23 && right == num23)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 270;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 270;
break;
default:
rectangle.X = 72;
rectangle.Y = 270;
break;
}
}
else if (down != num23 && down != index1 && (up == num23 || up == index1) && left == num23 && right == num23)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 288;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 288;
break;
default:
rectangle.X = 72;
rectangle.Y = 288;
break;
}
}
else if (left != num23 && left != index1 && (right == num23 || right == index1) && up == num23 && down == num23)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 270;
break;
case 1:
rectangle.X = 0;
rectangle.Y = 288;
break;
default:
rectangle.X = 0;
rectangle.Y = 306;
break;
}
}
else if (right != num23 && right != index1 && (left == num23 || left == index1) && up == num23 && down == num23)
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 270;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 288;
break;
default:
rectangle.X = 18;
rectangle.Y = 306;
break;
}
}
else if (up == index1 && down == num23 && left == num23 && right == num23)
{
switch (num22)
{
case 0:
rectangle.X = 198;
rectangle.Y = 288;
break;
case 1:
rectangle.X = 216;
rectangle.Y = 288;
break;
default:
rectangle.X = 234;
rectangle.Y = 288;
break;
}
}
else if (up == num23 && down == index1 && left == num23 && right == num23)
{
switch (num22)
{
case 0:
rectangle.X = 198;
rectangle.Y = 270;
break;
case 1:
rectangle.X = 216;
rectangle.Y = 270;
break;
default:
rectangle.X = 234;
rectangle.Y = 270;
break;
}
}
else if (up == num23 && down == num23 && left == index1 && right == num23)
{
switch (num22)
{
case 0:
rectangle.X = 198;
rectangle.Y = 306;
break;
case 1:
rectangle.X = 216;
rectangle.Y = 306;
break;
default:
rectangle.X = 234;
rectangle.Y = 306;
break;
}
}
else if (up == num23 && down == num23 && left == num23 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 306;
break;
case 1:
rectangle.X = 162;
rectangle.Y = 306;
break;
default:
rectangle.X = 180;
rectangle.Y = 306;
break;
}
}
if (up != index1 && up != num23 && down == index1 && left == index1 && right == index1)
{
if ((downLeft == num23 || downLeft == index1) && downRight != num23 && downRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 324;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 324;
break;
default:
rectangle.X = 36;
rectangle.Y = 324;
break;
}
}
else if ((downRight == num23 || downRight == index1) && downLeft != num23 && downLeft != index1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 324;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 324;
break;
default:
rectangle.X = 90;
rectangle.Y = 324;
break;
}
}
}
else if (down != index1 && down != num23 && up == index1 && left == index1 && right == index1)
{
if ((upLeft == num23 || upLeft == index1) && upRight != num23 && upRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 342;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 342;
break;
default:
rectangle.X = 36;
rectangle.Y = 342;
break;
}
}
else if ((upRight == num23 || upRight == index1) && upLeft != num23 && upLeft != index1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 342;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 342;
break;
default:
rectangle.X = 90;
rectangle.Y = 342;
break;
}
}
}
else if (left != index1 && left != num23 && up == index1 && down == index1 && right == index1)
{
if ((upRight == num23 || upRight == index1) && downRight != num23 && downRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 360;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 360;
break;
default:
rectangle.X = 90;
rectangle.Y = 360;
break;
}
}
else if ((downRight == num23 || downRight == index1) && upRight != num23 && upRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 360;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 360;
break;
default:
rectangle.X = 36;
rectangle.Y = 360;
break;
}
}
}
else if (right != index1 && right != num23 && up == index1 && down == index1 && left == index1)
{
if ((upLeft == num23 || upLeft == index1) && downLeft != num23 && downLeft != index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 378;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 378;
break;
default:
rectangle.X = 36;
rectangle.Y = 378;
break;
}
}
else if ((downLeft == num23 || downLeft == index1) && upLeft != num23 && upLeft != index1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 378;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 378;
break;
default:
rectangle.X = 90;
rectangle.Y = 378;
break;
}
}
}
if ((up == index1 || up == num23) && (down == index1 || down == num23) && (left == index1 || left == num23) && (right == index1 || right == num23) && upLeft != -1 && upRight != -1 && downLeft != -1 && downRight != -1)
{
if ((i + j) % 2 == 1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 198;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 198;
break;
default:
rectangle.X = 144;
rectangle.Y = 198;
break;
}
}
else
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 18;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 18;
break;
default:
rectangle.X = 54;
rectangle.Y = 18;
break;
}
}
}
WorldGen.TileMergeAttempt(-2, num23, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
}
WorldGen.TileMergeAttempt(index1, Main.tileMerge[index1], ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
if (rectangle.X == -1 && rectangle.Y == -1 && (Main.tileMergeDirt[index1] || index1 > -1 && TileID.Sets.ChecksForMerge[index1]))
{
if (!flag8)
{
flag8 = true;
WorldGen.TileMergeAttemptWeird(index1, -1, Main.tileSolid, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
}
if (up > -1 && up != index1)
up = -1;
if (down > -1 && down != index1)
down = -1;
if (left > -1 && left != index1)
left = -1;
if (right > -1 && right != index1)
right = -1;
if (up != -1 && down != -1 && left != -1 && right != -1)
{
if (up == -2 && down == index1 && left == index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 162;
rectangle.Y = 108;
break;
default:
rectangle.X = 180;
rectangle.Y = 108;
break;
}
WorldGen.mergeUp = true;
}
else if (up == index1 && down == -2 && left == index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 162;
rectangle.Y = 90;
break;
default:
rectangle.X = 180;
rectangle.Y = 90;
break;
}
WorldGen.mergeDown = true;
}
else if (up == index1 && down == index1 && left == -2 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 162;
rectangle.Y = 126;
break;
case 1:
rectangle.X = 162;
rectangle.Y = 144;
break;
default:
rectangle.X = 162;
rectangle.Y = 162;
break;
}
WorldGen.mergeLeft = true;
}
else if (up == index1 && down == index1 && left == index1 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 126;
break;
case 1:
rectangle.X = 144;
rectangle.Y = 144;
break;
default:
rectangle.X = 144;
rectangle.Y = 162;
break;
}
WorldGen.mergeRight = true;
}
else if (up == -2 && down == index1 && left == -2 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 126;
break;
default:
rectangle.X = 36;
rectangle.Y = 162;
break;
}
WorldGen.mergeUp = true;
WorldGen.mergeLeft = true;
}
else if (up == -2 && down == index1 && left == index1 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 126;
break;
default:
rectangle.X = 54;
rectangle.Y = 162;
break;
}
WorldGen.mergeUp = true;
WorldGen.mergeRight = true;
}
else if (up == index1 && down == -2 && left == -2 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 36;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 144;
break;
default:
rectangle.X = 36;
rectangle.Y = 180;
break;
}
WorldGen.mergeDown = true;
WorldGen.mergeLeft = true;
}
else if (up == index1 && down == -2 && left == index1 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 144;
break;
default:
rectangle.X = 54;
rectangle.Y = 180;
break;
}
WorldGen.mergeDown = true;
WorldGen.mergeRight = true;
}
else if (up == index1 && down == index1 && left == -2 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 180;
rectangle.Y = 126;
break;
case 1:
rectangle.X = 180;
rectangle.Y = 144;
break;
default:
rectangle.X = 180;
rectangle.Y = 162;
break;
}
WorldGen.mergeLeft = true;
WorldGen.mergeRight = true;
}
else if (up == -2 && down == -2 && left == index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 144;
rectangle.Y = 180;
break;
case 1:
rectangle.X = 162;
rectangle.Y = 180;
break;
default:
rectangle.X = 180;
rectangle.Y = 180;
break;
}
WorldGen.mergeUp = true;
WorldGen.mergeDown = true;
}
else if (up == -2 && down == index1 && left == -2 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 198;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 198;
rectangle.Y = 108;
break;
default:
rectangle.X = 198;
rectangle.Y = 126;
break;
}
WorldGen.mergeUp = true;
WorldGen.mergeLeft = true;
WorldGen.mergeRight = true;
}
else if (up == index1 && down == -2 && left == -2 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 198;
rectangle.Y = 144;
break;
case 1:
rectangle.X = 198;
rectangle.Y = 162;
break;
default:
rectangle.X = 198;
rectangle.Y = 180;
break;
}
WorldGen.mergeDown = true;
WorldGen.mergeLeft = true;
WorldGen.mergeRight = true;
}
else if (up == -2 && down == -2 && left == index1 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 216;
rectangle.Y = 144;
break;
case 1:
rectangle.X = 216;
rectangle.Y = 162;
break;
default:
rectangle.X = 216;
rectangle.Y = 180;
break;
}
WorldGen.mergeUp = true;
WorldGen.mergeDown = true;
WorldGen.mergeRight = true;
}
else if (up == -2 && down == -2 && left == -2 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 216;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 216;
rectangle.Y = 108;
break;
default:
rectangle.X = 216;
rectangle.Y = 126;
break;
}
WorldGen.mergeUp = true;
WorldGen.mergeDown = true;
WorldGen.mergeLeft = true;
}
else if (up == -2 && down == -2 && left == -2 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 198;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 198;
break;
default:
rectangle.X = 144;
rectangle.Y = 198;
break;
}
WorldGen.mergeUp = true;
WorldGen.mergeDown = true;
WorldGen.mergeLeft = true;
WorldGen.mergeRight = true;
}
else if (up == index1 && down == index1 && left == index1 && right == index1)
{
if (upLeft == -2)
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 144;
break;
default:
rectangle.X = 18;
rectangle.Y = 180;
break;
}
}
if (upRight == -2)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 108;
break;
case 1:
rectangle.X = 0;
rectangle.Y = 144;
break;
default:
rectangle.X = 0;
rectangle.Y = 180;
break;
}
}
if (downLeft == -2)
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 126;
break;
default:
rectangle.X = 18;
rectangle.Y = 162;
break;
}
}
if (downRight == -2)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 0;
rectangle.Y = 126;
break;
default:
rectangle.X = 0;
rectangle.Y = 162;
break;
}
}
}
}
else
{
if (index1 != 2 && index1 != 23 && index1 != 60 && index1 != 70 && index1 != 109 && index1 != 199)
{
if (up == -1 && down == -2 && left == index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 234;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 252;
rectangle.Y = 0;
break;
default:
rectangle.X = 270;
rectangle.Y = 0;
break;
}
WorldGen.mergeDown = true;
}
else if (up == -2 && down == -1 && left == index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 234;
rectangle.Y = 18;
break;
case 1:
rectangle.X = 252;
rectangle.Y = 18;
break;
default:
rectangle.X = 270;
rectangle.Y = 18;
break;
}
WorldGen.mergeUp = true;
}
else if (up == index1 && down == index1 && left == -1 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 234;
rectangle.Y = 36;
break;
case 1:
rectangle.X = 252;
rectangle.Y = 36;
break;
default:
rectangle.X = 270;
rectangle.Y = 36;
break;
}
WorldGen.mergeRight = true;
}
else if (up == index1 && down == index1 && left == -2 && right == -1)
{
switch (num22)
{
case 0:
rectangle.X = 234;
rectangle.Y = 54;
break;
case 1:
rectangle.X = 252;
rectangle.Y = 54;
break;
default:
rectangle.X = 270;
rectangle.Y = 54;
break;
}
WorldGen.mergeLeft = true;
}
}
if (up != -1 && down != -1 && left == -1 && right == index1)
{
if (up == -2 && down == index1)
{
switch (num22)
{
case 0:
rectangle.X = 72;
rectangle.Y = 144;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 162;
break;
default:
rectangle.X = 72;
rectangle.Y = 180;
break;
}
WorldGen.mergeUp = true;
}
else if (down == -2 && up == index1)
{
switch (num22)
{
case 0:
rectangle.X = 72;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 108;
break;
default:
rectangle.X = 72;
rectangle.Y = 126;
break;
}
WorldGen.mergeDown = true;
}
}
else if (up != -1 && down != -1 && left == index1 && right == -1)
{
if (up == -2 && down == index1)
{
switch (num22)
{
case 0:
rectangle.X = 90;
rectangle.Y = 144;
break;
case 1:
rectangle.X = 90;
rectangle.Y = 162;
break;
default:
rectangle.X = 90;
rectangle.Y = 180;
break;
}
WorldGen.mergeUp = true;
}
else if (down == -2 && up == index1)
{
switch (num22)
{
case 0:
rectangle.X = 90;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 90;
rectangle.Y = 108;
break;
default:
rectangle.X = 90;
rectangle.Y = 126;
break;
}
WorldGen.mergeDown = true;
}
}
else if (up == -1 && down == index1 && left != -1 && right != -1)
{
if (left == -2 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 198;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 198;
break;
default:
rectangle.X = 36;
rectangle.Y = 198;
break;
}
WorldGen.mergeLeft = true;
}
else if (right == -2 && left == index1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 198;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 198;
break;
default:
rectangle.X = 90;
rectangle.Y = 198;
break;
}
WorldGen.mergeRight = true;
}
}
else if (up == index1 && down == -1 && left != -1 && right != -1)
{
if (left == -2 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 216;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 216;
break;
default:
rectangle.X = 36;
rectangle.Y = 216;
break;
}
WorldGen.mergeLeft = true;
}
else if (right == -2 && left == index1)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 216;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 216;
break;
default:
rectangle.X = 90;
rectangle.Y = 216;
break;
}
WorldGen.mergeRight = true;
}
}
else if (up != -1 && down != -1 && left == -1 && right == -1)
{
if (up == -2 && down == -2)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 216;
break;
case 1:
rectangle.X = 108;
rectangle.Y = 234;
break;
default:
rectangle.X = 108;
rectangle.Y = 252;
break;
}
WorldGen.mergeUp = true;
WorldGen.mergeDown = true;
}
else if (up == -2)
{
switch (num22)
{
case 0:
rectangle.X = 126;
rectangle.Y = 144;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 162;
break;
default:
rectangle.X = 126;
rectangle.Y = 180;
break;
}
WorldGen.mergeUp = true;
}
else if (down == -2)
{
switch (num22)
{
case 0:
rectangle.X = 126;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 108;
break;
default:
rectangle.X = 126;
rectangle.Y = 126;
break;
}
WorldGen.mergeDown = true;
}
}
else if (up == -1 && down == -1 && left != -1 && right != -1)
{
if (left == -2 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 162;
rectangle.Y = 198;
break;
case 1:
rectangle.X = 180;
rectangle.Y = 198;
break;
default:
rectangle.X = 198;
rectangle.Y = 198;
break;
}
WorldGen.mergeLeft = true;
WorldGen.mergeRight = true;
}
else if (left == -2)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 252;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 252;
break;
default:
rectangle.X = 36;
rectangle.Y = 252;
break;
}
WorldGen.mergeLeft = true;
}
else if (right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 252;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 252;
break;
default:
rectangle.X = 90;
rectangle.Y = 252;
break;
}
WorldGen.mergeRight = true;
}
}
else if (up == -2 && down == -1 && left == -1 && right == -1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 144;
break;
case 1:
rectangle.X = 108;
rectangle.Y = 162;
break;
default:
rectangle.X = 108;
rectangle.Y = 180;
break;
}
WorldGen.mergeUp = true;
}
else if (up == -1 && down == -2 && left == -1 && right == -1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 90;
break;
case 1:
rectangle.X = 108;
rectangle.Y = 108;
break;
default:
rectangle.X = 108;
rectangle.Y = 126;
break;
}
WorldGen.mergeDown = true;
}
else if (up == -1 && down == -1 && left == -2 && right == -1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 234;
break;
case 1:
rectangle.X = 18;
rectangle.Y = 234;
break;
default:
rectangle.X = 36;
rectangle.Y = 234;
break;
}
WorldGen.mergeLeft = true;
}
else if (up == -1 && down == -1 && left == -1 && right == -2)
{
switch (num22)
{
case 0:
rectangle.X = 54;
rectangle.Y = 234;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 234;
break;
default:
rectangle.X = 90;
rectangle.Y = 234;
break;
}
WorldGen.mergeRight = true;
}
}
}
int num24 = centerTile.blockType();
if (TileID.Sets.HasSlopeFrames[index1])
{
if (num24 == 0)
{
bool flag9 = index1 == up && tile59.topSlope();
bool flag10 = index1 == left && tile61.leftSlope();
bool flag11 = index1 == right && tile62.rightSlope();
bool flag12 = index1 == down && tile60.bottomSlope();
int num25 = 0;
int num26 = 0;
if (flag9.ToInt() + flag10.ToInt() + flag11.ToInt() + flag12.ToInt() > 2)
{
int num27 = (tile59.slope() == (byte) 1).ToInt() + (tile62.slope() == (byte) 1).ToInt() + (tile60.slope() == (byte) 4).ToInt() + (tile61.slope() == (byte) 4).ToInt();
int num28 = (tile59.slope() == (byte) 2).ToInt() + (tile62.slope() == (byte) 3).ToInt() + (tile60.slope() == (byte) 3).ToInt() + (tile61.slope() == (byte) 2).ToInt();
if (num27 == num28)
{
num25 = 2;
num26 = 4;
}
else if (num27 > num28)
{
int num29 = index1 != upLeft ? 0 : (tile65.slope() == (byte) 0 ? 1 : 0);
bool flag13 = index1 == downRight && tile64.slope() == (byte) 0;
int num30 = flag13 ? 1 : 0;
if ((num29 & num30) != 0)
num26 = 4;
else if (flag13)
{
num25 = 6;
}
else
{
num25 = 7;
num26 = 1;
}
}
else
{
int num31 = index1 != upRight ? 0 : (tile66.slope() == (byte) 0 ? 1 : 0);
bool flag14 = index1 == downLeft && tile63.slope() == (byte) 0;
int num32 = flag14 ? 1 : 0;
if ((num31 & num32) != 0)
{
num26 = 4;
num25 = 1;
}
else if (flag14)
{
num25 = 7;
}
else
{
num25 = 6;
num26 = 1;
}
}
rectangle.X = (18 + num25) * 18;
rectangle.Y = num26 * 18;
}
else
{
if (flag9 & flag10 && index1 == down && index1 == right)
num26 = 2;
else if (flag9 & flag11 && index1 == down && index1 == left)
{
num25 = 1;
num26 = 2;
}
else if (flag11 & flag12 && index1 == up && index1 == left)
{
num25 = 1;
num26 = 3;
}
else if (flag12 & flag10 && index1 == up && index1 == right)
num26 = 3;
if (num25 != 0 || num26 != 0)
{
rectangle.X = (18 + num25) * 18;
rectangle.Y = num26 * 18;
}
}
}
if (num24 >= 2 && (rectangle.X < 0 || rectangle.Y < 0))
{
int num33 = -1;
int num34 = -1;
int num35 = -1;
int num36 = 0;
int num37 = 0;
switch (num24)
{
case 2:
num33 = left;
num34 = down;
num35 = downLeft;
++num36;
break;
case 3:
num33 = right;
num34 = down;
num35 = downRight;
break;
case 4:
num33 = left;
num34 = up;
num35 = upLeft;
++num36;
++num37;
break;
case 5:
num33 = right;
num34 = up;
num35 = upRight;
++num37;
break;
}
if (index1 != num33 || index1 != num34 || index1 != num35)
{
if (index1 == num33 && index1 == num34)
num36 += 2;
else if (index1 == num33)
num36 += 4;
else if (index1 == num34)
{
num36 += 4;
num37 += 2;
}
else
{
num36 += 2;
num37 += 2;
}
}
rectangle.X = (18 + num36) * 18;
rectangle.Y = num37 * 18;
}
}
if (rectangle.X < 0 || rectangle.Y < 0)
{
if (!flag8)
WorldGen.TileMergeAttemptWeird(index1, -1, Main.tileSolid, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
if (index1 == 2 || index1 == 23 || index1 == 60 || index1 == 70 || index1 == 109 || index1 == 199 || Main.tileMoss[index1])
WorldGen.TileMergeAttempt(index1, -2, ref up, ref down, ref left, ref right, ref upLeft, ref upRight, ref downLeft, ref downRight);
if (up == index1 && down == index1 && left == index1 && right == index1)
{
if (upLeft != index1 && upRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 18;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 18;
break;
default:
rectangle.X = 144;
rectangle.Y = 18;
break;
}
}
else if (downLeft != index1 && downRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 36;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 36;
break;
default:
rectangle.X = 144;
rectangle.Y = 36;
break;
}
}
else if (upLeft != index1 && downLeft != index1)
{
switch (num22)
{
case 0:
rectangle.X = 180;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 180;
rectangle.Y = 18;
break;
default:
rectangle.X = 180;
rectangle.Y = 36;
break;
}
}
else if (upRight != index1 && downRight != index1)
{
switch (num22)
{
case 0:
rectangle.X = 198;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 198;
rectangle.Y = 18;
break;
default:
rectangle.X = 198;
rectangle.Y = 36;
break;
}
}
else
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 18;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 18;
break;
default:
rectangle.X = 54;
rectangle.Y = 18;
break;
}
}
}
else if (up != index1 && down == index1 && left == index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 0;
break;
default:
rectangle.X = 54;
rectangle.Y = 0;
break;
}
}
else if (up == index1 && down != index1 && left == index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 36;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 36;
break;
default:
rectangle.X = 54;
rectangle.Y = 36;
break;
}
}
else if (up == index1 && down == index1 && left != index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 0;
rectangle.Y = 18;
break;
default:
rectangle.X = 0;
rectangle.Y = 36;
break;
}
}
else if (up == index1 && down == index1 && left == index1 && right != index1)
{
switch (num22)
{
case 0:
rectangle.X = 72;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 72;
rectangle.Y = 18;
break;
default:
rectangle.X = 72;
rectangle.Y = 36;
break;
}
}
else if (up != index1 && down == index1 && left != index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 54;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 54;
break;
default:
rectangle.X = 72;
rectangle.Y = 54;
break;
}
}
else if (up != index1 && down == index1 && left == index1 && right != index1)
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 54;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 54;
break;
default:
rectangle.X = 90;
rectangle.Y = 54;
break;
}
}
else if (up == index1 && down != index1 && left != index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 0;
rectangle.Y = 72;
break;
case 1:
rectangle.X = 36;
rectangle.Y = 72;
break;
default:
rectangle.X = 72;
rectangle.Y = 72;
break;
}
}
else if (up == index1 && down != index1 && left == index1 && right != index1)
{
switch (num22)
{
case 0:
rectangle.X = 18;
rectangle.Y = 72;
break;
case 1:
rectangle.X = 54;
rectangle.Y = 72;
break;
default:
rectangle.X = 90;
rectangle.Y = 72;
break;
}
}
else if (up == index1 && down == index1 && left != index1 && right != index1)
{
switch (num22)
{
case 0:
rectangle.X = 90;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 90;
rectangle.Y = 18;
break;
default:
rectangle.X = 90;
rectangle.Y = 36;
break;
}
}
else if (up != index1 && down != index1 && left == index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 72;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 72;
break;
default:
rectangle.X = 144;
rectangle.Y = 72;
break;
}
}
else if (up != index1 && down == index1 && left != index1 && right != index1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 0;
break;
default:
rectangle.X = 144;
rectangle.Y = 0;
break;
}
}
else if (up == index1 && down != index1 && left != index1 && right != index1)
{
switch (num22)
{
case 0:
rectangle.X = 108;
rectangle.Y = 54;
break;
case 1:
rectangle.X = 126;
rectangle.Y = 54;
break;
default:
rectangle.X = 144;
rectangle.Y = 54;
break;
}
}
else if (up != index1 && down != index1 && left != index1 && right == index1)
{
switch (num22)
{
case 0:
rectangle.X = 162;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 162;
rectangle.Y = 18;
break;
default:
rectangle.X = 162;
rectangle.Y = 36;
break;
}
}
else if (up != index1 && down != index1 && left == index1 && right != index1)
{
switch (num22)
{
case 0:
rectangle.X = 216;
rectangle.Y = 0;
break;
case 1:
rectangle.X = 216;
rectangle.Y = 18;
break;
default:
rectangle.X = 216;
rectangle.Y = 36;
break;
}
}
else if (up != index1 && down != index1 && left != index1 && right != index1)
{
switch (num22)
{
case 0:
rectangle.X = 162;
rectangle.Y = 54;
break;
case 1:
rectangle.X = 180;
rectangle.Y = 54;
break;
default:
rectangle.X = 198;
rectangle.Y = 54;
break;
}
}
}
if (rectangle.X <= -1 || rectangle.Y <= -1)
{
if (num22 <= 0)
{
rectangle.X = 18;
rectangle.Y = 18;
}
else if (num22 == 1)
{
rectangle.X = 36;
rectangle.Y = 18;
}
if (num22 >= 2)
{
rectangle.X = 54;
rectangle.Y = 18;
}
}
if (Main.tileLargeFrames[index1] == (byte) 1 && num22 == 3)
rectangle.Y += 90;
centerTile.frameX = (short) rectangle.X;
centerTile.frameY = (short) rectangle.Y;
if (index1 == 52 || index1 == 62 || index1 == 115 || index1 == 205)
{
up = tile59 == null ? index1 : (tile59.active() ? (!tile59.bottomSlope() ? (int) tile59.type : -1) : -1);
if ((index1 == 52 || index1 == 205) && (up == 109 || up == 115))
{
centerTile.type = (ushort) 115;
WorldGen.SquareTileFrame(i, j);
return;
}
if ((index1 == 115 || index1 == 205) && (up == 2 || up == 52))
{
centerTile.type = (ushort) 52;
WorldGen.SquareTileFrame(i, j);
return;
}
if ((index1 == 52 || index1 == 115) && (up == 199 || up == 205))
{
centerTile.type = (ushort) 205;
WorldGen.SquareTileFrame(i, j);
return;
}
if (up != index1)
{
bool flag15 = false;
if (up == -1)
flag15 = true;
if (index1 == 52 && up != 2 && up != 192)
flag15 = true;
if (index1 == 62 && up != 60)
flag15 = true;
if (index1 == 115 && up != 109)
flag15 = true;
if (index1 == 205 && up != 199)
flag15 = true;
if (flag15)
WorldGen.KillTile(i, j);
}
}
if (!WorldGen.noTileActions && centerTile.active() && (index1 == 53 || index1 == 112 || index1 == 116 || index1 == 123 || index1 == 234 || index1 == 224 || index1 == 330 || index1 == 331 || index1 == 332 || index1 == 333))
{
switch (Main.netMode)
{
case 0:
if (tile60 != null && !tile60.active())
{
bool flag16 = true;
if (tile59.active() && (TileID.Sets.BasicChest[(int) tile59.type] || TileID.Sets.BasicChestFake[(int) tile59.type] || tile59.type == (ushort) 323 || tile59.type == (ushort) 88))
flag16 = false;
if (flag16)
{
int Damage = 10;
int Type;
switch (index1)
{
case 59:
Type = 39;
break;
case 112:
Type = 56;
break;
case 116:
Type = 67;
break;
case 123:
Type = 71;
break;
case 224:
Type = 179;
break;
case 234:
Type = 241;
break;
case 330:
Type = 411;
Damage = 0;
break;
case 331:
Type = 412;
Damage = 0;
break;
case 332:
Type = 413;
Damage = 0;
break;
case 333:
Type = 414;
Damage = 0;
break;
default:
Type = 31;
break;
}
centerTile.ClearTile();
int index30 = Projectile.NewProjectile((float) (i * 16 + 8), (float) (j * 16 + 8), 0.0f, 0.41f, Type, Damage, 0.0f, Main.myPlayer);
Main.projectile[index30].ai[0] = 1f;
WorldGen.SquareTileFrame(i, j);
break;
}
break;
}
break;
case 2:
if (tile60 != null && !tile60.active())
{
bool flag17 = true;
if (tile59.active() && (TileID.Sets.BasicChest[(int) tile59.type] || TileID.Sets.BasicChestFake[(int) tile59.type] || tile59.type == (ushort) 323 || tile59.type == (ushort) 88))
flag17 = false;
if (flag17)
{
int Damage = 10;
int Type;
switch (index1)
{
case 59:
Type = 39;
break;
case 112:
Type = 56;
break;
case 116:
Type = 67;
break;
case 123:
Type = 71;
break;
case 224:
Type = 179;
break;
case 234:
Type = 241;
break;
case 330:
Type = 411;
Damage = 0;
break;
case 331:
Type = 412;
Damage = 0;
break;
case 332:
Type = 413;
Damage = 0;
break;
case 333:
Type = 414;
Damage = 0;
break;
default:
Type = 31;
break;
}
centerTile.active(false);
bool flag18 = false;
for (int index31 = 0; index31 < 1000; ++index31)
{
if (Main.projectile[index31].active && Main.projectile[index31].owner == Main.myPlayer && Main.projectile[index31].type == Type && Math.Abs(Main.projectile[index31].timeLeft - 3600) < 60 && (double) Main.projectile[index31].Distance(new Vector2((float) (i * 16 + 8), (float) (j * 16 + 10))) < 4.0)
{
flag18 = true;
break;
}
}
if (!flag18)
{
int index32 = Projectile.NewProjectile((float) (i * 16 + 8), (float) (j * 16 + 8), 0.0f, 2.5f, Type, Damage, 0.0f, Main.myPlayer);
Main.projectile[index32].velocity.Y = 0.5f;
Main.projectile[index32].position.Y += 2f;
Main.projectile[index32].netUpdate = true;
}
NetMessage.SendTileSquare(-1, i, j, 1);
WorldGen.SquareTileFrame(i, j);
break;
}
break;
}
break;
}
}
if (rectangle.X != frameX1)
{
if (rectangle.Y != frameY1)
{
if (frameX1 >= 0)
{
if (frameY1 >= 0)
{
++WorldGen.tileReframeCount;
if (WorldGen.tileReframeCount < 55)
{
int num38 = WorldGen.mergeUp ? 1 : 0;
bool mergeDown = WorldGen.mergeDown;
bool mergeLeft = WorldGen.mergeLeft;
bool mergeRight = WorldGen.mergeRight;
WorldGen.TileFrame(i - 1, j);
WorldGen.TileFrame(i + 1, j);
WorldGen.TileFrame(i, j - 1);
WorldGen.TileFrame(i, j + 1);
WorldGen.mergeUp = num38 != 0;
WorldGen.mergeDown = mergeDown;
WorldGen.mergeLeft = mergeLeft;
WorldGen.mergeRight = mergeRight;
}
--WorldGen.tileReframeCount;
}
}
}
}
}
}
}
}
}
}
}
}
catch
{
}
if (i <= 0 || j <= 0)
return;
WorldGen.UpdateMapTile(i, j, addToList);
}
public static void TriggerLunarApocalypse()
{
List<int> intList = new List<int>()
{
517,
422,
507,
493
};
int[] numArray = new int[4];
for (int index = 0; index < 4; ++index)
{
numArray[index] = intList[Main.rand.Next(intList.Count)];
intList.Remove(numArray[index]);
}
int num1 = Main.maxTilesX / 5;
int worldSurface = (int) Main.worldSurface;
for (int index1 = 0; index1 < 4; ++index1)
{
int num2 = num1 * (1 + index1);
bool flag = false;
for (int index2 = 0; index2 < 30; ++index2)
{
int num3 = Main.rand.Next(-100, 101);
for (int y = worldSurface; y > 100; --y)
{
if (!Collision.SolidTiles(num2 + num3 - 10, num2 + num3 + 10, y - 20, y + 15) && !WorldGen.PlayerLOS(num2 + num3 - 10, y) && !WorldGen.PlayerLOS(num2 + num3 + 10, y) && !WorldGen.PlayerLOS(num2 + num3 - 10, y - 20) && !WorldGen.PlayerLOS(num2 + num3 + 10, y - 20))
{
int number = NPC.NewNPC((num2 + num3) * 16, y * 16, numArray[index1]);
if (Main.netMode == 2 && number < 200)
NetMessage.SendData(23, number: number);
flag = true;
break;
}
}
if (flag)
break;
}
if (!flag)
NPC.NewNPC(num2 * 16, (worldSurface - 40) * 16, numArray[index1]);
}
int num4;
NPC.TowerActiveStardust = (num4 = 1) != 0;
NPC.TowerActiveSolar = num4 != 0;
NPC.TowerActiveNebula = num4 != 0;
NPC.TowerActiveVortex = num4 != 0;
NPC.LunarApocalypseIsUp = true;
int strengthTowerMax;
NPC.ShieldStrengthTowerStardust = strengthTowerMax = NPC.ShieldStrengthTowerMax;
NPC.ShieldStrengthTowerNebula = strengthTowerMax;
NPC.ShieldStrengthTowerVortex = strengthTowerMax;
NPC.ShieldStrengthTowerSolar = strengthTowerMax;
NetMessage.SendData(101);
WorldGen.MessageLunarApocalypse();
}
public static void UpdateLunarApocalypse()
{
if (!NPC.LunarApocalypseIsUp)
return;
bool flag1 = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
bool flag5 = false;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active)
{
switch (Main.npc[index].type)
{
case 398:
flag1 = true;
continue;
case 422:
flag3 = true;
continue;
case 493:
flag5 = true;
continue;
case 507:
flag4 = true;
continue;
case 517:
flag2 = true;
continue;
default:
continue;
}
}
}
if (!flag2)
NPC.TowerActiveSolar = false;
if (!flag3)
NPC.TowerActiveVortex = false;
if (!flag4)
NPC.TowerActiveNebula = false;
if (!flag5)
NPC.TowerActiveStardust = false;
if (NPC.TowerActiveSolar || NPC.TowerActiveVortex || NPC.TowerActiveNebula || NPC.TowerActiveStardust || flag1)
return;
WorldGen.StartImpendingDoom();
}
public static void StartImpendingDoom()
{
NPC.LunarApocalypseIsUp = false;
NPC.MoonLordCountdown = 3600;
NetMessage.SendData(103, number: NPC.MoonLordCountdown);
WorldGen.BroadcastText(NetworkText.FromKey(Lang.misc[52].Key), 50, (int) byte.MaxValue, 130);
if (Main.netMode == 1)
return;
WorldGen.GetRidOfCultists();
}
public static void GetRidOfCultists()
{
for (int number = 0; number < 200; ++number)
{
if (Main.npc[number].active && (Main.npc[number].type == 437 || Main.npc[number].type == 438 || Main.npc[number].type == 379))
{
Main.npc[number].active = false;
if (Main.netMode != 1)
NetMessage.SendData(23, number: number);
}
}
}
public static void MessageLunarApocalypse()
{
if (!NPC.LunarApocalypseIsUp)
return;
int num = 0;
if (!NPC.TowerActiveSolar)
++num;
if (!NPC.TowerActiveVortex)
++num;
if (!NPC.TowerActiveNebula)
++num;
if (!NPC.TowerActiveStardust)
++num;
WorldGen.BroadcastText(NetworkText.FromKey(Lang.misc[43 + num].Key), 175, 75, (int) byte.MaxValue);
}
public static void BroadcastText(NetworkText text, Vector4 color) => WorldGen.BroadcastText(text, new Color(color));
public static void BroadcastText(NetworkText text, Vector3 color) => WorldGen.BroadcastText(text, new Color(color));
public static void BroadcastText(NetworkText text, int r, int g, int b) => WorldGen.BroadcastText(text, new Color(r, g, b));
public static void BroadcastText(NetworkText text, byte r, byte g, byte b) => WorldGen.BroadcastText(text, new Color((int) r, (int) g, (int) b));
public static void BroadcastText(NetworkText text, Color color)
{
if (Main.netMode == 0)
{
Main.NewText(text.ToString(), color.R, color.G, color.B);
}
else
{
if (Main.netMode != 2)
return;
NetMessage.BroadcastChatMessage(text, color);
}
}
public static bool CanCutTile(int x, int y, TileCuttingContext context)
{
if (Main.tile[x, y + 1] == null || Main.tile[x, y + 1].type == (ushort) 78 || Main.tile[x, y + 1].type == (ushort) 380)
return false;
return Main.tile[x, y].type != (ushort) 254 || context == TileCuttingContext.TilePlacement;
}
public class Hooks
{
public static event Action OnWorldLoad;
public static void Initialize() => Player.Hooks.OnEnterWorld += (Action<Player>) (player =>
{
if (player.whoAmI != Main.myPlayer)
return;
WorldGen.Hooks.WorldLoaded();
Main.FixUIScale();
});
public static void WorldLoaded()
{
if (WorldGen.Hooks.OnWorldLoad == null)
return;
WorldGen.Hooks.OnWorldLoad();
}
public static void ClearWorld()
{
PressurePlateHelper.Reset();
WorldGen.TownManager.Clear();
NPC.ResetKillCount();
}
}
public class Spread
{
public static void Wall(int x, int y, int wallType)
{
if (!WorldGen.InWorld(x, y))
return;
byte num = (byte) wallType;
List<Point> pointList1 = new List<Point>();
List<Point> pointList2 = new List<Point>();
HashSet<Point> pointSet = new HashSet<Point>();
pointList2.Add(new Point(x, y));
while (pointList2.Count > 0)
{
pointList1.Clear();
pointList1.AddRange((IEnumerable<Point>) pointList2);
pointList2.Clear();
while (pointList1.Count > 0)
{
Point point1 = pointList1[0];
if (!WorldGen.InWorld(point1.X, point1.Y, 1))
{
pointList1.Remove(point1);
}
else
{
pointSet.Add(point1);
pointList1.Remove(point1);
Tile tile = Main.tile[point1.X, point1.Y];
if (WorldGen.SolidTile(point1.X, point1.Y) || tile.wall != (byte) 0)
{
if (tile.active() && tile.wall == (byte) 0)
tile.wall = num;
}
else
{
tile.wall = num;
Point point2 = new Point(point1.X - 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y - 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y + 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
}
}
}
}
}
public static void Wall2(int x, int y, int wallType)
{
if (!WorldGen.InWorld(x, y))
return;
byte num1 = (byte) wallType;
int num2 = 0;
int maxWallOut2 = WorldGen.maxWallOut2;
List<Point> pointList1 = new List<Point>();
List<Point> pointList2 = new List<Point>();
HashSet<Point> pointSet = new HashSet<Point>();
pointList2.Add(new Point(x, y));
while (pointList2.Count > 0)
{
pointList1.Clear();
pointList1.AddRange((IEnumerable<Point>) pointList2);
pointList2.Clear();
while (pointList1.Count > 0)
{
Point point1 = pointList1[0];
if (!WorldGen.InWorld(point1.X, point1.Y, 1))
{
pointList1.Remove(point1);
}
else
{
pointSet.Add(point1);
pointList1.Remove(point1);
Tile tile = Main.tile[point1.X, point1.Y];
if (!WorldGen.SolidTile(point1.X, point1.Y) && (int) tile.wall != (int) num1 && tile.wall != (byte) 4 && tile.wall != (byte) 40 && tile.wall != (byte) 3)
{
if (num1 == (byte) 63 && tile.wall == (byte) 0)
{
pointList1.Remove(point1);
}
else
{
++num2;
if (num2 >= maxWallOut2)
{
pointList1.Remove(point1);
}
else
{
tile.wall = num1;
Point point2 = new Point(point1.X - 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y - 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y + 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
if (num1 == (byte) 63)
{
point2 = new Point(point1.X - 1, point1.Y - 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 1, point1.Y - 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X - 1, point1.Y + 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 1, point1.Y + 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X - 2, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 2, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
}
}
}
}
else if (tile.active() && (int) tile.wall != (int) num1 && tile.wall != (byte) 4 && tile.wall != (byte) 40 && tile.wall != (byte) 3)
tile.wall = num1;
}
}
}
}
public static void Moss(int x, int y)
{
if (!WorldGen.InWorld(x, y))
return;
byte mossWall = WorldGen.mossWall;
ushort mossTile = (ushort) WorldGen.mossTile;
List<Point> pointList1 = new List<Point>();
List<Point> pointList2 = new List<Point>();
HashSet<Point> pointSet = new HashSet<Point>();
pointList2.Add(new Point(x, y));
while (pointList2.Count > 0)
{
pointList1.Clear();
pointList1.AddRange((IEnumerable<Point>) pointList2);
pointList2.Clear();
while (pointList1.Count > 0)
{
Point point1 = pointList1[0];
if (!WorldGen.InWorld(point1.X, point1.Y, 1))
{
pointList1.Remove(point1);
}
else
{
pointSet.Add(point1);
pointList1.Remove(point1);
Tile tile = Main.tile[point1.X, point1.Y];
if (WorldGen.SolidTile(point1.X, point1.Y) || tile.wall != (byte) 0)
{
if (tile.active())
{
if (tile.wall == (byte) 0)
tile.wall = mossWall;
if (tile.type == (ushort) 1)
tile.type = mossTile;
}
}
else
{
tile.wall = mossWall;
Point point2 = new Point(point1.X - 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y - 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y + 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
}
}
}
}
}
public static void Gem(int x, int y)
{
if (!WorldGen.InWorld(x, y))
return;
List<Point> pointList1 = new List<Point>();
List<Point> pointList2 = new List<Point>();
HashSet<Point> pointSet = new HashSet<Point>();
pointList2.Add(new Point(x, y));
while (pointList2.Count > 0)
{
pointList1.Clear();
pointList1.AddRange((IEnumerable<Point>) pointList2);
pointList2.Clear();
while (pointList1.Count > 0)
{
Point point1 = pointList1[0];
if (!WorldGen.InWorld(point1.X, point1.Y, 1))
{
pointList1.Remove(point1);
}
else
{
pointSet.Add(point1);
pointList1.Remove(point1);
Tile tile1 = Main.tile[point1.X, point1.Y];
if (WorldGen.SolidTile(point1.X, point1.Y) || tile1.wall != (byte) 0)
{
if (tile1.active())
{
if (WorldGen.Spread.Gemmable((int) tile1.type))
tile1.type = WorldGen.randGemTile();
Tile tile2 = Main.tile[point1.X - 1, point1.Y];
if (WorldGen.Spread.Gemmable((int) tile2.type))
tile2.type = WorldGen.randGemTile();
Tile tile3 = Main.tile[point1.X + 1, point1.Y];
if (WorldGen.Spread.Gemmable((int) tile3.type))
tile3.type = WorldGen.randGemTile();
Tile tile4 = Main.tile[point1.X, point1.Y - 1];
if (WorldGen.Spread.Gemmable((int) tile4.type))
tile4.type = WorldGen.randGemTile();
Tile tile5 = Main.tile[point1.X, point1.Y + 1];
if (WorldGen.Spread.Gemmable((int) tile5.type))
tile5.type = WorldGen.randGemTile();
}
}
else
{
tile1.wall = (byte) (48 + WorldGen.randGem());
if (!tile1.active() && WorldGen.genRand.Next(2) == 0)
WorldGen.PlaceTile(point1.X, point1.Y, 178, true, style: WorldGen.randGem());
Point point2 = new Point(point1.X - 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y - 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y + 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
}
}
}
}
}
public static void Spider(int x, int y)
{
if (!WorldGen.InWorld(x, y))
return;
byte num = 62;
List<Point> pointList1 = new List<Point>();
List<Point> pointList2 = new List<Point>();
HashSet<Point> pointSet = new HashSet<Point>();
pointList2.Add(new Point(x, y));
while (pointList2.Count > 0)
{
pointList1.Clear();
pointList1.AddRange((IEnumerable<Point>) pointList2);
pointList2.Clear();
while (pointList1.Count > 0)
{
Point point1 = pointList1[0];
if (!WorldGen.InWorld(point1.X, point1.Y, 1))
{
pointList1.Remove(point1);
}
else
{
pointSet.Add(point1);
pointList1.Remove(point1);
Tile tile = Main.tile[point1.X, point1.Y];
if (WorldGen.SolidTile(point1.X, point1.Y) || tile.wall != (byte) 0)
{
if (tile.active() && tile.wall == (byte) 0)
tile.wall = num;
}
else
{
tile.wall = num;
WorldGen.SquareWallFrame(point1.X, point1.Y);
if (!tile.active())
{
tile.liquid = (byte) 0;
tile.lava(false);
if (WorldGen.SolidTile(point1.X, point1.Y + 1) && WorldGen.genRand.Next(3) == 0)
{
if (WorldGen.genRand.Next(15) == 0)
WorldGen.AddBuriedChest(point1.X, point1.Y, 939, true, 15);
else
WorldGen.PlacePot(point1.X, point1.Y, style: WorldGen.genRand.Next(19, 21));
}
if (!tile.active())
{
if (WorldGen.SolidTile(point1.X, point1.Y - 1) && WorldGen.genRand.Next(3) == 0)
WorldGen.PlaceTight(point1.X, point1.Y, spiders: true);
else if (WorldGen.SolidTile(point1.X, point1.Y + 1))
{
WorldGen.PlaceTile(point1.X, point1.Y, 187, true, style: (9 + WorldGen.genRand.Next(5)));
if (WorldGen.genRand.Next(3) == 0)
{
if (!tile.active())
WorldGen.PlaceSmallPile(point1.X, point1.Y, 34 + WorldGen.genRand.Next(4), 1);
if (!tile.active())
WorldGen.PlaceSmallPile(point1.X, point1.Y, 48 + WorldGen.genRand.Next(6), 0);
}
}
}
}
Point point2 = new Point(point1.X - 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y - 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y + 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
}
}
}
}
}
public static void WallDungeon(int x, int y, int wallType)
{
if (!WorldGen.InWorld(x, y))
return;
byte num = (byte) wallType;
List<Point> pointList1 = new List<Point>();
List<Point> pointList2 = new List<Point>();
HashSet<Point> pointSet = new HashSet<Point>();
pointList2.Add(new Point(x, y));
while (pointList2.Count > 0)
{
pointList1.Clear();
pointList1.AddRange((IEnumerable<Point>) pointList2);
pointList2.Clear();
while (pointList1.Count > 0)
{
Point point1 = pointList1[0];
if (!WorldGen.InWorld(point1.X, point1.Y, 1))
{
pointList1.Remove(point1);
}
else
{
pointSet.Add(point1);
pointList1.Remove(point1);
Tile tile = Main.tile[point1.X, point1.Y];
if (!WorldGen.SolidTile(point1.X, point1.Y) && (int) tile.wall != (int) num && tile.wall > (byte) 0)
{
tile.wall = num;
Point point2 = new Point(point1.X - 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X + 1, point1.Y);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y - 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
point2 = new Point(point1.X, point1.Y + 1);
if (!pointSet.Contains(point2))
pointList2.Add(point2);
}
else if (tile.active())
tile.wall = num;
}
}
}
}
private static bool Gemmable(int type) => type == 0 || type == 1 || type == 40 || type == 59 || type == 60 || type == 70 || type == 147 || type == 161;
}
}
}