Beispiel #1
0
        public static void SmoothSlope(int x, int y, bool applyToNeighbors = true)
        {
            if (applyToNeighbors)
            {
                Tile.SmoothSlope(x + 1, y, false);
                Tile.SmoothSlope(x - 1, y, false);
                Tile.SmoothSlope(x, y + 1, false);
                Tile.SmoothSlope(x, y - 1, false);
            }
            Tile tile = Main.tile[x, y];

            if (!WorldGen.SolidOrSlopedTile(x, y))
            {
                return;
            }
            bool flag1 = !WorldGen.TileEmpty(x, y - 1);
            bool flag2 = !WorldGen.SolidOrSlopedTile(x, y - 1) && flag1;
            bool flag3 = WorldGen.SolidOrSlopedTile(x, y + 1);
            bool flag4 = WorldGen.SolidOrSlopedTile(x - 1, y);
            bool flag5 = WorldGen.SolidOrSlopedTile(x + 1, y);

            switch ((flag1 ? 1 : 0) << 3 | (flag3 ? 1 : 0) << 2 | (flag4 ? 1 : 0) << 1 | (flag5 ? 1 : 0))
            {
            case 4:
                tile.slope((byte)0);
                tile.halfBrick(true);
                break;

            case 5:
                tile.halfBrick(false);
                tile.slope((byte)2);
                break;

            case 6:
                tile.halfBrick(false);
                tile.slope((byte)1);
                break;

            case 9:
                if (flag2)
                {
                    break;
                }
                tile.halfBrick(false);
                tile.slope((byte)4);
                break;

            case 10:
                if (flag2)
                {
                    break;
                }
                tile.halfBrick(false);
                tile.slope((byte)3);
                break;

            default:
                tile.halfBrick(false);
                tile.slope((byte)0);
                break;
            }
        }
Beispiel #2
0
 public static void SendWalker(Point startFloorPosition, int height, int direction, out int distanceCoveredInTiles, out Point lastIteratedFloorSpot, int maxDistance = 100, bool showDebug = false)
 {
   distanceCoveredInTiles = 0;
   // ISSUE: explicit reference operation
   // ISSUE: variable of a reference type
   Point& local1 = @startFloorPosition;
   // ISSUE: explicit reference operation
   int num1 = (^local1).Y - 1;
   // ISSUE: explicit reference operation
   (^local1).Y = (__Null) num1;
   lastIteratedFloorSpot = startFloorPosition;
   for (int index1 = 0; index1 < maxDistance; ++index1)
   {
     for (int index2 = 0; index2 < 3 && WorldGen.SolidTile3((int) startFloorPosition.X, (int) startFloorPosition.Y); ++index2)
     {
       // ISSUE: explicit reference operation
       // ISSUE: variable of a reference type
       Point& local2 = @startFloorPosition;
       // ISSUE: explicit reference operation
       int num2 = (^local2).Y - 1;
       // ISSUE: explicit reference operation
       (^local2).Y = (__Null) num2;
     }
     int topY1;
     int bottomY1;
     Collision.ExpandVertically((int) startFloorPosition.X, (int) startFloorPosition.Y, out topY1, out bottomY1, height, 2);
     ++topY1;
     --bottomY1;
     if (!WorldGen.SolidTile3((int) startFloorPosition.X, bottomY1 + 1))
     {
       int topY2;
       int bottomY2;
       Collision.ExpandVertically((int) startFloorPosition.X, bottomY1, out topY2, out bottomY2, 0, 6);
       if (showDebug)
         Dust.QuickBox(new Vector2((float) (startFloorPosition.X * 16 + 8), (float) (topY2 * 16)), new Vector2((float) (startFloorPosition.X * 16 + 8), (float) (bottomY2 * 16)), 1, Color.get_Blue(), (Action<Dust>) null);
       if (!WorldGen.SolidTile3((int) startFloorPosition.X, bottomY2))
         break;
     }
     if (bottomY1 - topY1 >= height - 1)
     {
       if (showDebug)
       {
         Dust.QuickDust(startFloorPosition, Color.get_Green()).scale = 1f;
         Dust.QuickBox(new Vector2((float) (startFloorPosition.X * 16 + 8), (float) (topY1 * 16)), new Vector2((float) (startFloorPosition.X * 16 + 8), (float) (bottomY1 * 16 + 16)), 1, Color.get_Red(), (Action<Dust>) null);
       }
       distanceCoveredInTiles += direction;
       // ISSUE: explicit reference operation
       // ISSUE: variable of a reference type
       Point& local2 = @startFloorPosition;
       // ISSUE: explicit reference operation
       int num2 = (^local2).X + direction;
       // ISSUE: explicit reference operation
       (^local2).X = (__Null) num2;
       startFloorPosition.Y = (__Null) bottomY1;
       lastIteratedFloorSpot = startFloorPosition;
       if (Math.Abs(distanceCoveredInTiles) >= maxDistance)
         break;
     }
     else
       break;
   }
   distanceCoveredInTiles = Math.Abs(distanceCoveredInTiles);
 }
 private static void InnerClientLoop()
 {
     try
     {
         NetMessage.buffer[256].Reset();
         int num = -1;
         while (!Disconnect)
         {
             if (Connection.Socket.IsConnected())
             {
                 Connection.IsActive = true;
                 if (Connection.State == 0)
                 {
                     Main.statusText  = Language.GetTextValue("Net.FoundServer");
                     Connection.State = 1;
                     NetMessage.SendData(1);
                 }
                 if (Connection.State == 2 && num != Connection.State)
                 {
                     Main.statusText = Language.GetTextValue("Net.SendingPlayerData");
                 }
                 if (Connection.State == 3 && num != Connection.State)
                 {
                     Main.statusText = Language.GetTextValue("Net.RequestingWorldInformation");
                 }
                 if (Connection.State == 4)
                 {
                     WorldGen.worldCleared = false;
                     Connection.State      = 5;
                     if (Main.cloudBGActive >= 1f)
                     {
                         Main.cloudBGAlpha = 1f;
                     }
                     else
                     {
                         Main.cloudBGAlpha = 0f;
                     }
                     Main.windSpeedCurrent = Main.windSpeedTarget;
                     Cloud.resetClouds();
                     Main.cloudAlpha = Main.maxRaining;
                     WorldGen.clearWorld();
                     if (Main.mapEnabled)
                     {
                         Main.Map.Load();
                     }
                 }
                 if (Connection.State == 5 && Main.loadMapLock)
                 {
                     float num2 = (float)Main.loadMapLastX / (float)Main.maxTilesX;
                     Main.statusText = Lang.gen[68].Value + " " + (int)(num2 * 100f + 1f) + "%";
                 }
                 else if (Connection.State == 5 && WorldGen.worldCleared)
                 {
                     Connection.State = 6;
                     Main.player[Main.myPlayer].FindSpawn();
                     NetMessage.SendData(8, -1, -1, null, Main.player[Main.myPlayer].SpawnX, Main.player[Main.myPlayer].SpawnY);
                 }
                 if (Connection.State == 6 && num != Connection.State)
                 {
                     Main.statusText = Language.GetTextValue("Net.RequestingTileData");
                 }
                 if (!Connection.IsReading && !Disconnect && Connection.Socket.IsDataAvailable())
                 {
                     Connection.IsReading = true;
                     Connection.Socket.AsyncReceive(Connection.ReadBuffer, 0, Connection.ReadBuffer.Length, Connection.ClientReadCallBack);
                 }
                 if (Connection.StatusMax > 0 && Connection.StatusText != "")
                 {
                     if (Connection.StatusCount >= Connection.StatusMax)
                     {
                         Main.statusText        = Language.GetTextValue("Net.StatusComplete", Connection.StatusText);
                         Connection.StatusText  = "";
                         Connection.StatusMax   = 0;
                         Connection.StatusCount = 0;
                     }
                     else
                     {
                         Main.statusText = Connection.StatusText + ": " + (int)((float)Connection.StatusCount / (float)Connection.StatusMax * 100f) + "%";
                     }
                 }
                 Thread.Sleep(1);
             }
             else if (Connection.IsActive)
             {
                 Main.statusText = Language.GetTextValue("Net.LostConnection");
                 Disconnect      = true;
             }
             num = Connection.State;
         }
         try
         {
             Connection.Socket.Close();
         }
         catch
         {
         }
         if (!Main.gameMenu)
         {
             Main.gameMenu = true;
             Main.SwitchNetMode(0);
             MapHelper.noStatusText = true;
             Player.SavePlayer(Main.ActivePlayerFileData);
             Player.ClearPlayerTempInfo();
             Main.ActivePlayerFileData.StopPlayTimer();
             SoundEngine.StopTrackedSounds();
             MapHelper.noStatusText = false;
             Main.menuMode          = 14;
         }
         NetMessage.buffer[256].Reset();
         if (Main.menuMode == 15 && Main.statusText == Language.GetTextValue("Net.LostConnection"))
         {
             Main.menuMode = 14;
         }
         if (Connection.StatusText != "" && Connection.StatusText != null)
         {
             Main.statusText = Language.GetTextValue("Net.LostConnection");
         }
         Connection.StatusCount = 0;
         Connection.StatusMax   = 0;
         Connection.StatusText  = "";
         Main.SwitchNetMode(0);
     }
     catch (Exception value)
     {
         try
         {
             using StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", append: true);
             streamWriter.WriteLine(DateTime.Now);
             streamWriter.WriteLine(value);
             streamWriter.WriteLine("");
         }
         catch
         {
         }
         Disconnect = true;
     }
     if (Netplay.OnDisconnect != null)
     {
         Netplay.OnDisconnect();
     }
 }
Beispiel #4
0
        public static void ClientLoop(object threadContext)
        {
            Netplay.ResetNetDiag();
            if (Main.rand == null)
            {
                Main.rand = new Random((int)DateTime.Now.Ticks);
            }
            if (WorldGen.genRand == null)
            {
                WorldGen.genRand = new Random((int)DateTime.Now.Ticks);
            }
            Main.player[Main.myPlayer].hostile = false;
            Main.clientPlayer = (Player)Main.player[Main.myPlayer].clientClone();
            for (int i = 0; i < 255; i++)
            {
                if (i != Main.myPlayer)
                {
                    Main.player[i] = new Player();
                }
            }
            Main.menuMode = 10;
            Main.menuMode = 14;
            if (!Main.autoPass)
            {
                Main.statusText = "Connecting to " + Netplay.serverIP;
            }
            Main.netMode       = 1;
            Netplay.disconnect = false;
            Netplay.clientSock = new ClientSock();
            Netplay.clientSock.tcpClient.NoDelay = true;
            Netplay.clientSock.readBuffer        = new byte[1024];
            Netplay.clientSock.writeBuffer       = new byte[1024];
            bool flag = true;

            while (flag)
            {
                flag = false;
                try
                {
                    Netplay.clientSock.tcpClient.Connect(Netplay.serverIP, Netplay.serverPort);
                    Netplay.clientSock.networkStream = Netplay.clientSock.tcpClient.GetStream();
                    flag = false;
                }
                catch
                {
                    if (!Netplay.disconnect && Main.gameMenu)
                    {
                        flag = true;
                    }
                }
            }
            NetMessage.buffer[256].Reset();
            int num = -1;

            while (!Netplay.disconnect)
            {
                if (Netplay.clientSock.tcpClient.Connected)
                {
                    if (NetMessage.buffer[256].checkBytes)
                    {
                        NetMessage.CheckBytes(256);
                    }
                    Netplay.clientSock.active = true;
                    if (Netplay.clientSock.state == 0)
                    {
                        Main.statusText          = "Found server";
                        Netplay.clientSock.state = 1;
                        NetMessage.SendData(1, -1, -1, "", 0, 0f, 0f, 0f, 0);
                    }
                    if (Netplay.clientSock.state == 2 && num != Netplay.clientSock.state)
                    {
                        Main.statusText = "Sending player data...";
                    }
                    if (Netplay.clientSock.state == 3 && num != Netplay.clientSock.state)
                    {
                        Main.statusText = "Requesting world information";
                    }
                    if (Netplay.clientSock.state == 4)
                    {
                        WorldGen.worldCleared    = false;
                        Netplay.clientSock.state = 5;
                        WorldGen.clearWorld();
                    }
                    if (Netplay.clientSock.state == 5 && WorldGen.worldCleared)
                    {
                        Netplay.clientSock.state = 6;
                        Main.player[Main.myPlayer].FindSpawn();
                        NetMessage.SendData(8, -1, -1, "", Main.player[Main.myPlayer].SpawnX, (float)Main.player[Main.myPlayer].SpawnY, 0f, 0f, 0);
                    }
                    if (Netplay.clientSock.state == 6 && num != Netplay.clientSock.state)
                    {
                        Main.statusText = "Requesting tile data";
                    }
                    if (!Netplay.clientSock.locked && !Netplay.disconnect && Netplay.clientSock.networkStream.DataAvailable)
                    {
                        Netplay.clientSock.locked = true;
                        Netplay.clientSock.networkStream.BeginRead(Netplay.clientSock.readBuffer, 0, Netplay.clientSock.readBuffer.Length, new AsyncCallback(Netplay.clientSock.ClientReadCallBack), Netplay.clientSock.networkStream);
                    }
                    if (Netplay.clientSock.statusMax > 0 && Netplay.clientSock.statusText != "")
                    {
                        if (Netplay.clientSock.statusCount >= Netplay.clientSock.statusMax)
                        {
                            Main.statusText = Netplay.clientSock.statusText + ": Complete!";
                            Netplay.clientSock.statusText  = "";
                            Netplay.clientSock.statusMax   = 0;
                            Netplay.clientSock.statusCount = 0;
                        }
                        else
                        {
                            Main.statusText = string.Concat(new object[]
                            {
                                Netplay.clientSock.statusText,
                                ": ",
                                (int)((float)Netplay.clientSock.statusCount / (float)Netplay.clientSock.statusMax * 100f),
                                "%"
                            });
                        }
                    }
                    Thread.Sleep(1);
                }
                else
                {
                    if (Netplay.clientSock.active)
                    {
                        Main.statusText    = "Lost connection";
                        Netplay.disconnect = true;
                    }
                }
                num = Netplay.clientSock.state;
            }
            try
            {
                Netplay.clientSock.networkStream.Close();
                Netplay.clientSock.networkStream = Netplay.clientSock.tcpClient.GetStream();
            }
            catch
            {
            }
            if (!Main.gameMenu)
            {
                Main.netMode = 0;
                Player.SavePlayer(Main.player[Main.myPlayer], Main.playerPathName);
                Main.gameMenu = true;
                Main.menuMode = 14;
            }
            NetMessage.buffer[256].Reset();
            if (Main.menuMode == 15 && Main.statusText == "Lost connection")
            {
                Main.menuMode = 14;
            }
            if (Netplay.clientSock.statusText != "" && Netplay.clientSock.statusText != null)
            {
                Main.statusText = "Lost connection";
            }
            Netplay.clientSock.statusCount = 0;
            Netplay.clientSock.statusMax   = 0;
            Netplay.clientSock.statusText  = "";
            Main.netMode = 0;
        }
Beispiel #5
0
        public static void SmoothSlope(int x, int y, bool applyToNeighbors = true, bool sync = false)
        {
            if (applyToNeighbors)
            {
                Tile.SmoothSlope(x + 1, y, false, sync);
                Tile.SmoothSlope(x - 1, y, false, sync);
                Tile.SmoothSlope(x, y + 1, false, sync);
                Tile.SmoothSlope(x, y - 1, false, sync);
            }
            Tile tile = Main.tile[x, y];

            if (!WorldGen.CanPoundTile(x, y) || !WorldGen.SolidOrSlopedTile(x, y))
            {
                return;
            }
            bool flag1 = !WorldGen.TileEmpty(x, y - 1);
            bool flag2 = !WorldGen.SolidOrSlopedTile(x, y - 1) & flag1;
            bool flag3 = WorldGen.SolidOrSlopedTile(x, y + 1);
            bool flag4 = WorldGen.SolidOrSlopedTile(x - 1, y);
            bool flag5 = WorldGen.SolidOrSlopedTile(x + 1, y);
            int  num1  = (flag1 ? 1 : 0) << 3 | (flag3 ? 1 : 0) << 2 | (flag4 ? 1 : 0) << 1 | (flag5 ? 1 : 0);
            bool flag6 = tile.halfBrick();
            int  num2  = (int)tile.slope();

            switch (num1)
            {
            case 4:
                tile.slope((byte)0);
                tile.halfBrick(true);
                break;

            case 5:
                tile.halfBrick(false);
                tile.slope((byte)2);
                break;

            case 6:
                tile.halfBrick(false);
                tile.slope((byte)1);
                break;

            case 9:
                if (!flag2)
                {
                    tile.halfBrick(false);
                    tile.slope((byte)4);
                    break;
                }
                break;

            case 10:
                if (!flag2)
                {
                    tile.halfBrick(false);
                    tile.slope((byte)3);
                    break;
                }
                break;

            default:
                tile.halfBrick(false);
                tile.slope((byte)0);
                break;
            }
            if (!sync)
            {
                return;
            }
            int  num3  = (int)tile.slope();
            bool flag7 = flag6 != tile.halfBrick();
            bool flag8 = num2 != num3;

            if (flag7 & flag8)
            {
                NetMessage.SendData(17, -1, -1, (NetworkText)null, 23, (float)x, (float)y, (float)num3, 0, 0, 0);
            }
            else if (flag7)
            {
                NetMessage.SendData(17, -1, -1, (NetworkText)null, 7, (float)x, (float)y, 1f, 0, 0, 0);
            }
            else
            {
                if (!flag8)
                {
                    return;
                }
                NetMessage.SendData(17, -1, -1, (NetworkText)null, 14, (float)x, (float)y, (float)num3, 0, 0, 0);
            }
        }
 public static bool SearchAvoidedByNPCs(int x, int y)
 {
     return(WorldGen.InWorld(x, y, 1) && Main.tile[x, y] != null && (!Main.tile[x, y].active() || !TileID.Sets.AvoidedByNPCs[(int)Main.tile[x, y].type]));
 }
Beispiel #7
0
        public static void SmoothSlope(int x, int y, bool applyToNeighbors = true)
        {
            if (applyToNeighbors)
            {
                Tile.SmoothSlope(x + 1, y, false);
                Tile.SmoothSlope(x - 1, y, false);
                Tile.SmoothSlope(x, y + 1, false);
                Tile.SmoothSlope(x, y - 1, false);
            }
            Tile tile = Main.tile[x, y];

            if (!WorldGen.SolidOrSlopedTile(x, y))
            {
                return;
            }
            bool flag  = !WorldGen.TileEmpty(x, y - 1);
            bool flag1 = (WorldGen.SolidOrSlopedTile(x, y - 1) ? false : flag);
            bool flag2 = WorldGen.SolidOrSlopedTile(x, y + 1);
            bool flag3 = WorldGen.SolidOrSlopedTile(x - 1, y);
            bool flag4 = WorldGen.SolidOrSlopedTile(x + 1, y);

            switch ((flag ? 1 : 0) << 3 | (flag2 ? 1 : 0) << 2 | (flag3 ? 1 : 0) << 1 | (flag4 ? 1 : 0))
            {
            case 4:
            {
                tile.slope(0);
                tile.halfBrick(true);
                return;
            }

            case 5:
            {
                tile.halfBrick(false);
                tile.slope(2);
                return;
            }

            case 6:
            {
                tile.halfBrick(false);
                tile.slope(1);
                return;
            }

            case 7:
            case 8:
            {
                tile.halfBrick(false);
                tile.slope(0);
                break;
            }

            case 9:
            {
                if (flag1)
                {
                    break;
                }
                tile.halfBrick(false);
                tile.slope(4);
                return;
            }

            case 10:
            {
                if (flag1)
                {
                    break;
                }
                tile.halfBrick(false);
                tile.slope(3);
                return;
            }

            default:
            {
                goto case 8;
            }
            }
        }
		public static void Draw(Main mainInstance, SpriteBatch sb)
		{
			if (Main.player[Main.myPlayer].dead && !Main.player[Main.myPlayer].ghost)
			{
				Main.setKey = -1;
				IngameOptions.Close();
				Main.playerInventory = false;
				return;
			}
			new Vector2((float)Main.mouseX, (float)Main.mouseY);
			bool flag = Main.mouseLeft && Main.mouseLeftRelease;
			Vector2 value = new Vector2((float)Main.screenWidth, (float)Main.screenHeight);
			Vector2 value2 = new Vector2(670f, 480f);
			Vector2 value3 = value / 2f - value2 / 2f;
			int num = 20;
			Utils.DrawInvBG(sb, value3.X - (float)num, value3.Y - (float)num, value2.X + (float)(num * 2), value2.Y + (float)(num * 2), new Color(33, 15, 91, 255) * 0.685f);
			if (new Rectangle((int)value3.X - num, (int)value3.Y - num, (int)value2.X + num * 2, (int)value2.Y + num * 2).Contains(new Point(Main.mouseX, Main.mouseY)))
			{
				Main.player[Main.myPlayer].mouseInterface = true;
			}
			Utils.DrawInvBG(sb, value3.X + (float)(num / 2), value3.Y + (float)(num * 5 / 2), value2.X / 2f - (float)num, value2.Y - (float)(num * 3), default(Color));
			Utils.DrawInvBG(sb, value3.X + value2.X / 2f + (float)num, value3.Y + (float)(num * 5 / 2), value2.X / 2f - (float)(num * 3 / 2), value2.Y - (float)(num * 3), default(Color));
			Utils.DrawBorderString(sb, "Settings Menu", value3 + value2 * new Vector2(0.5f, 0f), Color.White, 1f, 0.5f, 0f, -1);
			float num2 = 0.7f;
			float num3 = 0.8f;
			float num4 = 0.01f;
			if (IngameOptions.oldLeftHover != IngameOptions.leftHover && IngameOptions.leftHover != -1)
			{
				Main.PlaySound(SoundTypeID.MENU_TICK, -1, -1, 1);
			}
			if (IngameOptions.oldRightHover != IngameOptions.rightHover && IngameOptions.rightHover != -1)
			{
				Main.PlaySound(SoundTypeID.MENU_TICK, -1, -1, 1);
			}
			if (flag && IngameOptions.rightHover != -1 && !IngameOptions.noSound)
			{
				Main.PlaySound(SoundTypeID.MENU_TICK, -1, -1, 1);
			}
			IngameOptions.oldLeftHover = IngameOptions.leftHover;
			IngameOptions.oldRightHover = IngameOptions.rightHover;
			IngameOptions.noSound = false;
			int num5 = 5;
			Vector2 anchor = new Vector2(value3.X + value2.X / 4f, value3.Y + (float)(num * 5 / 2));
			Vector2 offset = new Vector2(0f, value2.Y - (float)(num * 3)) / (float)(num5 + 1);
			for (int i = 0; i < 6; i++)
			{
				if (IngameOptions.leftHover == i || i == IngameOptions.category)
				{
					IngameOptions.leftScale[i] += num4;
				}
				else
				{
					IngameOptions.leftScale[i] -= num4;
				}
				if (IngameOptions.leftScale[i] < num2)
				{
					IngameOptions.leftScale[i] = num2;
				}
				if (IngameOptions.leftScale[i] > num3)
				{
					IngameOptions.leftScale[i] = num3;
				}
			}
			IngameOptions.leftHover = -1;
			int num6 = IngameOptions.category;
			if (IngameOptions.DrawLeftSide(sb, Lang.menu[114], 0, anchor, offset, IngameOptions.leftScale, 0.7f, 0.8f, 0.01f))
			{
				IngameOptions.leftHover = 0;
				if (flag)
				{
					IngameOptions.category = 0;
					Main.PlaySound(SoundTypeID.MENU_OPEN, -1, -1, 1);
				}
			}
			if (IngameOptions.DrawLeftSide(sb, Lang.menu[63], 1, anchor, offset, IngameOptions.leftScale, 0.7f, 0.8f, 0.01f))
			{
				IngameOptions.leftHover = 1;
				if (flag)
				{
					IngameOptions.category = 1;
					Main.PlaySound(SoundTypeID.MENU_OPEN, -1, -1, 1);
				}
			}
			if (IngameOptions.DrawLeftSide(sb, Lang.menu[66], 2, anchor, offset, IngameOptions.leftScale, 0.7f, 0.8f, 0.01f))
			{
				IngameOptions.leftHover = 2;
				if (flag)
				{
					IngameOptions.category = 2;
					Main.PlaySound(SoundTypeID.MENU_OPEN, -1, -1, 1);
				}
			}
			if (IngameOptions.DrawLeftSide(sb, Lang.menu[115], 3, anchor, offset, IngameOptions.leftScale, 0.7f, 0.8f, 0.01f))
			{
				IngameOptions.leftHover = 3;
				if (flag)
				{
					IngameOptions.category = 3;
					Main.PlaySound(SoundTypeID.MENU_OPEN, -1, -1, 1);
				}
			}
			if (IngameOptions.DrawLeftSide(sb, Lang.menu[118], 4, anchor, offset, IngameOptions.leftScale, 0.7f, 0.8f, 0.01f))
			{
				IngameOptions.leftHover = 4;
				if (flag)
				{
					IngameOptions.Close();
				}
			}
			if (IngameOptions.DrawLeftSide(sb, Lang.inter[35], 5, anchor, offset, IngameOptions.leftScale, 0.7f, 0.8f, 0.01f))
			{
				IngameOptions.leftHover = 5;
				if (flag)
				{
					IngameOptions.Close();
					Main.menuMode = 10;
					WorldGen.SaveAndQuit();
				}
			}
			if (num6 != IngameOptions.category)
			{
				for (int j = 0; j < IngameOptions.rightScale.Length; j++)
				{
					IngameOptions.rightScale[j] = 0f;
				}
			}
			int num7 = 0;
			switch (IngameOptions.category)
			{
			case 0:
				num7 = 6;
				num2 = 1f;
				num3 = 1.001f;
				num4 = 0.001f;
				break;
			case 1:
				num7 = 8;
				num2 = 1f;
				num3 = 1.001f;
				num4 = 0.001f;
				break;
			case 2:
				num7 = 13;
				num2 = 0.8f;
				num3 = 0.801f;
				num4 = 0.001f;
				break;
			case 3:
				num7 = 7;
				num2 = 0.8f;
				num3 = 0.801f;
				num4 = 0.001f;
				break;
			}
			Vector2 anchor2 = new Vector2(value3.X + value2.X * 3f / 4f, value3.Y + (float)(num * 5 / 2));
			Vector2 offset2 = new Vector2(0f, value2.Y - (float)(num * 3)) / (float)(num7 + 1);
			for (int k = 0; k < 13; k++)
			{
				if (IngameOptions.rightLock == k || (IngameOptions.rightHover == k && IngameOptions.rightLock == -1))
				{
					IngameOptions.rightScale[k] += num4;
				}
				else
				{
					IngameOptions.rightScale[k] -= num4;
				}
				if (IngameOptions.rightScale[k] < num2)
				{
					IngameOptions.rightScale[k] = num2;
				}
				if (IngameOptions.rightScale[k] > num3)
				{
					IngameOptions.rightScale[k] = num3;
				}
			}
			IngameOptions.inBar = false;
			IngameOptions.rightHover = -1;
			if (!Main.mouseLeft)
			{
				IngameOptions.rightLock = -1;
			}
			if (IngameOptions.rightLock == -1)
			{
				IngameOptions.notBar = false;
			}
			if (IngameOptions.category == 0)
			{
				int num8 = 0;
				anchor2.X -= 70f;
				if (IngameOptions.DrawRightSide(sb, string.Concat(new object[]
				{
					Lang.menu[99],
					" ",
					Math.Round((double)(Main.musicVolume * 100f)),
					"%"
				}), num8, anchor2, offset2, IngameOptions.rightScale[num8], (IngameOptions.rightScale[num8] - num2) / (num3 - num2), default(Color)))
				{
					if (IngameOptions.rightLock == -1)
					{
						IngameOptions.notBar = true;
					}
					IngameOptions.noSound = true;
					IngameOptions.rightHover = num8;
				}
				IngameOptions.valuePosition.X = value3.X + value2.X - (float)(num / 2) - 20f;
				IngameOptions.valuePosition.Y = IngameOptions.valuePosition.Y - 3f;
				float musicVolume = IngameOptions.DrawValueBar(sb, 0.75f, Main.musicVolume);
				if ((IngameOptions.inBar || IngameOptions.rightLock == num8) && !IngameOptions.notBar)
				{
					IngameOptions.rightHover = num8;
					if (Main.mouseLeft && IngameOptions.rightLock == num8)
					{
						Main.musicVolume = musicVolume;
					}
				}
				if ((float)Main.mouseX > value3.X + value2.X * 2f / 3f + (float)num && (float)Main.mouseX < IngameOptions.valuePosition.X + 3.75f && (float)Main.mouseY > IngameOptions.valuePosition.Y - 10f && (float)Main.mouseY <= IngameOptions.valuePosition.Y + 10f)
				{
					if (IngameOptions.rightLock == -1)
					{
						IngameOptions.notBar = true;
					}
					IngameOptions.rightHover = num8;
				}
				num8++;
				if (IngameOptions.DrawRightSide(sb, string.Concat(new object[]
				{
					Lang.menu[98],
					" ",
					Math.Round((double)(Main.soundVolume * 100f)),
					"%"
				}), num8, anchor2, offset2, IngameOptions.rightScale[num8], (IngameOptions.rightScale[num8] - num2) / (num3 - num2), default(Color)))
				{
					if (IngameOptions.rightLock == -1)
					{
						IngameOptions.notBar = true;
					}
					IngameOptions.rightHover = num8;
				}
				IngameOptions.valuePosition.X = value3.X + value2.X - (float)(num / 2) - 20f;
				IngameOptions.valuePosition.Y = IngameOptions.valuePosition.Y - 3f;
				float soundVolume = IngameOptions.DrawValueBar(sb, 0.75f, Main.soundVolume);
				if ((IngameOptions.inBar || IngameOptions.rightLock == num8) && !IngameOptions.notBar)
				{
					IngameOptions.rightHover = num8;
					if (Main.mouseLeft && IngameOptions.rightLock == num8)
					{
						Main.soundVolume = soundVolume;
						IngameOptions.noSound = true;
					}
				}
				if ((float)Main.mouseX > value3.X + value2.X * 2f / 3f + (float)num && (float)Main.mouseX < IngameOptions.valuePosition.X + 3.75f && (float)Main.mouseY > IngameOptions.valuePosition.Y - 10f && (float)Main.mouseY <= IngameOptions.valuePosition.Y + 10f)
				{
					if (IngameOptions.rightLock == -1)
					{
						IngameOptions.notBar = true;
					}
					IngameOptions.rightHover = num8;
				}
				num8++;
				if (IngameOptions.DrawRightSide(sb, string.Concat(new object[]
				{
					Lang.menu[119],
					" ",
					Math.Round((double)(Main.ambientVolume * 100f)),
					"%"
				}), num8, anchor2, offset2, IngameOptions.rightScale[num8], (IngameOptions.rightScale[num8] - num2) / (num3 - num2), default(Color)))
				{
					if (IngameOptions.rightLock == -1)
					{
						IngameOptions.notBar = true;
					}
					IngameOptions.rightHover = num8;
				}
				IngameOptions.valuePosition.X = value3.X + value2.X - (float)(num / 2) - 20f;
				IngameOptions.valuePosition.Y = IngameOptions.valuePosition.Y - 3f;
				float ambientVolume = IngameOptions.DrawValueBar(sb, 0.75f, Main.ambientVolume);
				if ((IngameOptions.inBar || IngameOptions.rightLock == num8) && !IngameOptions.notBar)
				{
					IngameOptions.rightHover = num8;
					if (Main.mouseLeft && IngameOptions.rightLock == num8)
					{
						Main.ambientVolume = ambientVolume;
						IngameOptions.noSound = true;
					}
				}
				if ((float)Main.mouseX > value3.X + value2.X * 2f / 3f + (float)num && (float)Main.mouseX < IngameOptions.valuePosition.X + 3.75f && (float)Main.mouseY > IngameOptions.valuePosition.Y - 10f && (float)Main.mouseY <= IngameOptions.valuePosition.Y + 10f)
				{
					if (IngameOptions.rightLock == -1)
					{
						IngameOptions.notBar = true;
					}
					IngameOptions.rightHover = num8;
				}
				num8++;
				anchor2.X += 70f;
				if (IngameOptions.DrawRightSide(sb, Main.autoSave ? Lang.menu[67] : Lang.menu[68], num8, anchor2, offset2, IngameOptions.rightScale[num8], (IngameOptions.rightScale[num8] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num8;
					if (flag)
					{
						Main.autoSave = !Main.autoSave;
					}
				}
				num8++;
				if (IngameOptions.DrawRightSide(sb, Main.autoPause ? Lang.menu[69] : Lang.menu[70], num8, anchor2, offset2, IngameOptions.rightScale[num8], (IngameOptions.rightScale[num8] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num8;
					if (flag)
					{
						Main.autoPause = !Main.autoPause;
					}
				}
				num8++;
				if (IngameOptions.DrawRightSide(sb, Main.showItemText ? Lang.menu[71] : Lang.menu[72], num8, anchor2, offset2, IngameOptions.rightScale[num8], (IngameOptions.rightScale[num8] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num8;
					if (flag)
					{
						Main.showItemText = !Main.showItemText;
					}
				}
				num8++;
			}
			if (IngameOptions.category == 1)
			{
				int num9 = 0;
				if (IngameOptions.DrawRightSide(sb, Main.graphics.IsFullScreen ? Lang.menu[49] : Lang.menu[50], num9, anchor2, offset2, IngameOptions.rightScale[num9], (IngameOptions.rightScale[num9] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num9;
					if (flag)
					{
						Main.graphics.ToggleFullScreen();
					}
				}
				num9++;
				if (IngameOptions.DrawRightSide(sb, string.Concat(new object[]
				{
					Lang.menu[51],
					": ",
					Main.graphics.PreferredBackBufferWidth,
					"x",
					Main.graphics.PreferredBackBufferHeight
				}), num9, anchor2, offset2, IngameOptions.rightScale[num9], (IngameOptions.rightScale[num9] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num9;
					if (flag)
					{
						int num10 = 0;
						for (int l = 0; l < Main.numDisplayModes; l++)
						{
							if (Main.displayWidth[l] == Main.graphics.PreferredBackBufferWidth && Main.displayHeight[l] == Main.graphics.PreferredBackBufferHeight)
							{
								num10 = l;
								break;
							}
						}
						num10++;
						if (num10 >= Main.numDisplayModes)
						{
							num10 = 0;
						}
						Main.graphics.PreferredBackBufferWidth = Main.displayWidth[num10];
						Main.graphics.PreferredBackBufferHeight = Main.displayHeight[num10];
					}
				}
				num9++;
				anchor2.X -= 70f;
				if (IngameOptions.DrawRightSide(sb, string.Concat(new object[]
				{
					Lang.menu[52],
					": ",
					Main.bgScroll,
					"%"
				}), num9, anchor2, offset2, IngameOptions.rightScale[num9], (IngameOptions.rightScale[num9] - num2) / (num3 - num2), default(Color)))
				{
					if (IngameOptions.rightLock == -1)
					{
						IngameOptions.notBar = true;
					}
					IngameOptions.noSound = true;
					IngameOptions.rightHover = num9;
				}
				IngameOptions.valuePosition.X = value3.X + value2.X - (float)(num / 2) - 20f;
				IngameOptions.valuePosition.Y = IngameOptions.valuePosition.Y - 3f;
				float num11 = IngameOptions.DrawValueBar(sb, 0.75f, (float)Main.bgScroll / 100f);
				if ((IngameOptions.inBar || IngameOptions.rightLock == num9) && !IngameOptions.notBar)
				{
					IngameOptions.rightHover = num9;
					if (Main.mouseLeft && IngameOptions.rightLock == num9)
					{
						Main.bgScroll = (int)(num11 * 100f);
						Main.caveParrallax = 1f - (float)Main.bgScroll / 500f;
					}
				}
				if ((float)Main.mouseX > value3.X + value2.X * 2f / 3f + (float)num && (float)Main.mouseX < IngameOptions.valuePosition.X + 3.75f && (float)Main.mouseY > IngameOptions.valuePosition.Y - 10f && (float)Main.mouseY <= IngameOptions.valuePosition.Y + 10f)
				{
					if (IngameOptions.rightLock == -1)
					{
						IngameOptions.notBar = true;
					}
					IngameOptions.rightHover = num9;
				}
				num9++;
				anchor2.X += 70f;
				if (IngameOptions.DrawRightSide(sb, Main.fixedTiming ? Lang.menu[53] : Lang.menu[54], num9, anchor2, offset2, IngameOptions.rightScale[num9], (IngameOptions.rightScale[num9] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num9;
					if (flag)
					{
						Main.fixedTiming = !Main.fixedTiming;
					}
				}
				num9++;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[55 + Lighting.lightMode], num9, anchor2, offset2, IngameOptions.rightScale[num9], (IngameOptions.rightScale[num9] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num9;
					if (flag)
					{
						Lighting.lightCounter += 100;
						Lighting.lightMode++;
						if (Lighting.lightMode >= 4)
						{
							Lighting.lightMode = 0;
						}
						if (Lighting.lightMode == 2 || Lighting.lightMode == 0)
						{
							Main.renderCount = 0;
							Main.renderNow = true;
							Lighting.BlackOut();
						}
					}
				}
				num9++;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[116] + " " + ((Lighting.LightingThreads > 0) ? string.Concat(Lighting.LightingThreads + 1) : Lang.menu[117]), num9, anchor2, offset2, IngameOptions.rightScale[num9], (IngameOptions.rightScale[num9] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num9;
					if (flag)
					{
						Lighting.LightingThreads++;
						if (Lighting.LightingThreads > Environment.ProcessorCount - 1)
						{
							Lighting.LightingThreads = 0;
						}
					}
				}
				num9++;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[59 + Main.qaStyle], num9, anchor2, offset2, IngameOptions.rightScale[num9], (IngameOptions.rightScale[num9] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num9;
					if (flag)
					{
						Main.qaStyle++;
						if (Main.qaStyle > 3)
						{
							Main.qaStyle = 0;
						}
					}
				}
				num9++;
				if (IngameOptions.DrawRightSide(sb, Main.owBack ? Lang.menu[100] : Lang.menu[101], num9, anchor2, offset2, IngameOptions.rightScale[num9], (IngameOptions.rightScale[num9] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num9;
					if (flag)
					{
						Main.owBack = !Main.owBack;
					}
				}
				num9++;
			}
			if (IngameOptions.category == 2)
			{
				int num12 = 0;
				anchor2.X -= 30f;
				int num13 = 0;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cUp, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 1;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cDown, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 2;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cLeft, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 3;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cRight, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 4;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cJump, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 5;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cThrowItem, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 6;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
				if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cInv, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 7;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cHeal, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 8;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cMana, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 9;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cBuff, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 10;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cHook, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				num13 = 11;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[74 + num13], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), (Main.setKey == num13) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num13) ? "_" : KeyBoardDefinitions.cTorch, num12, num3, (Main.setKey == num13) ? Color.Gold : ((IngameOptions.rightHover == num12) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
						Main.setKey = num13;
					}
				}
				num12++;
				anchor2.X += 30f;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[86], num12, anchor2, offset2, IngameOptions.rightScale[num12], (IngameOptions.rightScale[num12] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num12;
					if (flag)
					{
                        KeyBoardDefinitions.resetBindingValues();
						Main.setKey = -1;
					}
				}
				num12++;
				if (Main.setKey >= 0)
				{
					Main.blockInput = true;
					Keys[] pressedKeys = Main.keyState.GetPressedKeys();
					if (pressedKeys.Length > 0)
					{
						string text = string.Concat(pressedKeys[0]);
						if (text != "None")
						{
                            KeyBoardDefinitions.setBindingValue(Main.setKey, text);
							Main.blockKey = pressedKeys[0];
							Main.blockInput = false;
							Main.setKey = -1;
						}
					}
				}
			}
			if (IngameOptions.category == 3)
			{
				int num14 = 0;
				anchor2.X -= 30f;
				int num15 = 0;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[106 + num15], num14, anchor2, offset2, IngameOptions.rightScale[num14], (IngameOptions.rightScale[num14] - num2) / (num3 - num2), (Main.setKey == num15) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
				if (IngameOptions.DrawValue(sb, (Main.setKey == num15) ? "_" : KeyBoardDefinitions.cMapStyle, num14, num3, (Main.setKey == num15) ? Color.Gold : ((IngameOptions.rightHover == num14) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				num14++;
				num15 = 1;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[106 + num15], num14, anchor2, offset2, IngameOptions.rightScale[num14], (IngameOptions.rightScale[num14] - num2) / (num3 - num2), (Main.setKey == num15) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num15) ? "_" : KeyBoardDefinitions.cMapFull, num14, num3, (Main.setKey == num15) ? Color.Gold : ((IngameOptions.rightHover == num14) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				num14++;
				num15 = 2;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[106 + num15], num14, anchor2, offset2, IngameOptions.rightScale[num14], (IngameOptions.rightScale[num14] - num2) / (num3 - num2), (Main.setKey == num15) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num15) ? "_" : KeyBoardDefinitions.cMapZoomIn, num14, num3, (Main.setKey == num15) ? Color.Gold : ((IngameOptions.rightHover == num14) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				num14++;
				num15 = 3;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[106 + num15], num14, anchor2, offset2, IngameOptions.rightScale[num14], (IngameOptions.rightScale[num14] - num2) / (num3 - num2), (Main.setKey == num15) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num15) ? "_" : KeyBoardDefinitions.cMapZoomOut, num14, num3, (Main.setKey == num15) ? Color.Gold : ((IngameOptions.rightHover == num14) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				num14++;
				num15 = 4;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[106 + num15], num14, anchor2, offset2, IngameOptions.rightScale[num14], (IngameOptions.rightScale[num14] - num2) / (num3 - num2), (Main.setKey == num15) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num15) ? "_" : KeyBoardDefinitions.cMapAlphaUp, num14, num3, (Main.setKey == num15) ? Color.Gold : ((IngameOptions.rightHover == num14) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				num14++;
				num15 = 5;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[106 + num15], num14, anchor2, offset2, IngameOptions.rightScale[num14], (IngameOptions.rightScale[num14] - num2) / (num3 - num2), (Main.setKey == num15) ? Color.Gold : default(Color)))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				IngameOptions.valuePosition.X = IngameOptions.valuePosition.X + 10f;
                if (IngameOptions.DrawValue(sb, (Main.setKey == num15) ? "_" : KeyBoardDefinitions.cMapAlphaDown, num14, num3, (Main.setKey == num15) ? Color.Gold : ((IngameOptions.rightHover == num14) ? Color.White : default(Color))))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
						Main.setKey = num15;
					}
				}
				num14++;
				anchor2.X += 30f;
				if (IngameOptions.DrawRightSide(sb, Lang.menu[86], num14, anchor2, offset2, IngameOptions.rightScale[num14], (IngameOptions.rightScale[num14] - num2) / (num3 - num2), default(Color)))
				{
					IngameOptions.rightHover = num14;
					if (flag)
					{
                        KeyBoardDefinitions.resetMapBindingValues();
						Main.setKey = -1;
					}
				}
				num14++;
				if (Main.setKey >= 0)
				{
					Main.blockInput = true;
					Keys[] pressedKeys2 = Main.keyState.GetPressedKeys();
					if (pressedKeys2.Length > 0)
					{
						string text2 = string.Concat(pressedKeys2[0]);
						if (text2 != "None")
						{
							KeyBoardDefinitions.setBindingMapValue(Main.setKey, text2);
							Main.setKey = -1;
							Main.blockKey = pressedKeys2[0];
							Main.blockInput = false;
						}
					}
				}
			}
			if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
			{
				IngameOptions.rightLock = IngameOptions.rightHover;
			}
			sb.Draw(Main.cursorTexture, new Vector2((float)(Main.mouseX + 1), (float)(Main.mouseY + 1)), null, new Color((int)((float)Main.cursorColor.R * 0.2f), (int)((float)Main.cursorColor.G * 0.2f), (int)((float)Main.cursorColor.B * 0.2f), (int)((float)Main.cursorColor.A * 0.5f)), 0f, default(Vector2), Main.cursorScale * 1.1f, SpriteEffects.None, 0f);
			sb.Draw(Main.cursorTexture, new Vector2((float)Main.mouseX, (float)Main.mouseY), null, Main.cursorColor, 0f, default(Vector2), Main.cursorScale, SpriteEffects.None, 0f);
		}
Beispiel #9
0
        public void DrawFreshAnimations(SpriteBatch spriteBatch)
        {
            for (int index = 0; index < this.data.Length; ++index)
            {
                ++this.data[index].animationTimeElapsed;
            }
            if (!Main.SettingsEnabled_MinersWobble)
            {
                return;
            }
            int     num1      = 1;
            Vector2 vector2_1 = new Vector2((float)Main.offScreenRange);

            if (Main.drawToScreen)
            {
                vector2_1 = Vector2.Zero;
            }
            vector2_1 = Vector2.Zero;
            for (int index = 0; index < this.data.Length; ++index)
            {
                if (this.data[index].type == num1)
                {
                    int damage = this.data[index].damage;
                    if (damage >= 20)
                    {
                        int x = this.data[index].X;
                        int y = this.data[index].Y;
                        if (WorldGen.InWorld(x, y, 0))
                        {
                            bool flag1;
                            if ((flag1 = Main.tile[x, y] != null) && num1 == 1)
                            {
                                flag1 = flag1 && Main.tile[x, y].active() && Main.tileSolid[(int)Main.tile[x, y].type];
                            }
                            if (flag1 && num1 == 2)
                            {
                                flag1 = flag1 && (int)Main.tile[x, y].wall != 0;
                            }
                            if (flag1)
                            {
                                bool flag2 = false;
                                bool flag3 = false;
                                if ((int)Main.tile[x, y].type == 10)
                                {
                                    flag2 = false;
                                }
                                else if (Main.tileSolid[(int)Main.tile[x, y].type] && !Main.tileSolidTop[(int)Main.tile[x, y].type])
                                {
                                    flag2 = true;
                                }
                                else if ((int)Main.tile[x, y].type == 5)
                                {
                                    flag3 = true;
                                    int num2 = (int)Main.tile[x, y].frameX / 22;
                                    int num3 = (int)Main.tile[x, y].frameY / 22;
                                    if (num3 < 9)
                                    {
                                        flag2 = (num2 != 1 && num2 != 2 || (num3 < 6 || num3 > 8)) && ((num2 != 3 || num3 > 2) && ((num2 != 4 || num3 < 3 || num3 > 5) && (num2 != 5 || num3 < 6 || num3 > 8)));
                                    }
                                }
                                else if ((int)Main.tile[x, y].type == 72)
                                {
                                    flag3 = true;
                                    if ((int)Main.tile[x, y].frameX <= 34)
                                    {
                                        flag2 = true;
                                    }
                                }
                                if (flag2 && (int)Main.tile[x, y].slope() == 0 && !Main.tile[x, y].halfBrick())
                                {
                                    int num2 = 0;
                                    if (damage >= 80)
                                    {
                                        num2 = 3;
                                    }
                                    else if (damage >= 60)
                                    {
                                        num2 = 2;
                                    }
                                    else if (damage >= 40)
                                    {
                                        num2 = 1;
                                    }
                                    else if (damage >= 20)
                                    {
                                        num2 = 0;
                                    }
                                    Rectangle rectangle = new Rectangle(this.data[index].crackStyle * 18, num2 * 18, 16, 16);
                                    rectangle.Inflate(-2, -2);
                                    if (flag3)
                                    {
                                        rectangle.X = (4 + this.data[index].crackStyle / 2) * 18;
                                    }
                                    int animationTimeElapsed = this.data[index].animationTimeElapsed;
                                    if ((double)animationTimeElapsed < 10.0)
                                    {
                                        float   num3     = (float)animationTimeElapsed / 10f;
                                        float   num4     = 1f;
                                        Color   color1   = Lighting.GetColor(x, y);
                                        float   rotation = 0.0f;
                                        Vector2 zero     = Vector2.Zero;
                                        float   num5     = num3;
                                        float   num6     = 0.5f;
                                        float   num7     = num5 % num6 * 2f;
                                        if ((int)((double)num5 / (double)num6) % 2 == 1)
                                        {
                                            num7 = 1f - num7;
                                        }
                                        num4 = (float)((double)num7 * 0.449999988079071 + 1.0);
                                        Tile      tileSafely = Framing.GetTileSafely(x, y);
                                        Tile      tile       = tileSafely;
                                        Texture2D texture    = !Main.canDrawColorTile(tileSafely.type, (int)tileSafely.color()) ? Main.tileTexture[(int)tileSafely.type] : (Texture2D)Main.tileAltTexture[(int)tileSafely.type, (int)tileSafely.color()];
                                        Vector2   origin     = new Vector2(8f);
                                        Vector2   vector2_2  = new Vector2(1f);
                                        float     num8       = (float)((double)num7 * 0.200000002980232 + 1.0);
                                        Color     color2     = color1 * 0.8f;
                                        Vector2   scale      = num8 * vector2_2;
                                        Vector2   position   = (new Vector2((float)(x * 16 - (int)Main.screenPosition.X), (float)(y * 16 - (int)Main.screenPosition.Y)) + vector2_1 + origin + zero).Floor();
                                        spriteBatch.Draw(texture, position, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, 16, 16)), color2, rotation, origin, scale, SpriteEffects.None, 0.0f);
                                        color2.A = (byte)180;
                                        spriteBatch.Draw(Main.tileCrackTexture, position, new Rectangle?(rectangle), color2, rotation, origin, scale, SpriteEffects.None, 0.0f);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #10
0
        public static void WallFrame(int i, int j, bool resetFrame = false)
        {
            if (WorldGen.SkipFramingBecauseOfGen || i <= 0 || (j <= 0 || i >= Main.maxTilesX - 1) || (j >= Main.maxTilesY - 1 || Main.tile[i, j] == null))
            {
                return;
            }
            WorldGen.UpdateMapTile(i, j, true);
            Tile tile1 = Main.tile[i, j];

            if (tile1.wall == (ushort)0)
            {
                tile1.wallColor((byte)0);
            }
            else
            {
                int  index1 = 0;
                Tile tile2  = Main.tile[i, j - 1];
                if (tile2 != null && (tile2.wall > (ushort)0 || tile2.active() && tile2.type == (ushort)54))
                {
                    index1 = 1;
                }
                Tile tile3 = Main.tile[i - 1, j];
                if (tile3 != null && (tile3.wall > (ushort)0 || tile3.active() && tile3.type == (ushort)54))
                {
                    index1 |= 2;
                }
                Tile tile4 = Main.tile[i + 1, j];
                if (tile4 != null && (tile4.wall > (ushort)0 || tile4.active() && tile4.type == (ushort)54))
                {
                    index1 |= 4;
                }
                Tile tile5 = Main.tile[i, j + 1];
                if (tile5 != null && (tile5.wall > (ushort)0 || tile5.active() && tile5.type == (ushort)54))
                {
                    index1 |= 8;
                }
                int index2;
                if (Main.wallLargeFrames[(int)tile1.wall] == (byte)1)
                {
                    index2 = Framing.phlebasTileFrameNumberLookup[j % 4][i % 3] - 1;
                    tile1.wallFrameNumber((byte)index2);
                }
                else if (Main.wallLargeFrames[(int)tile1.wall] == (byte)2)
                {
                    index2 = Framing.lazureTileFrameNumberLookup[i % 2][j % 2] - 1;
                    tile1.wallFrameNumber((byte)index2);
                }
                else if (resetFrame)
                {
                    index2 = WorldGen.genRand.Next(0, 3);
                    if (tile1.wall == (ushort)21 && WorldGen.genRand.Next(2) == 0)
                    {
                        index2 = 2;
                    }
                    tile1.wallFrameNumber((byte)index2);
                }
                else
                {
                    index2 = (int)tile1.wallFrameNumber();
                }
                if (index1 == 15)
                {
                    index1 += Framing.centerWallFrameLookup[i % 3][j % 3];
                }
                Point16 point16 = Framing.wallFrameLookup[index1][index2];
                tile1.wallFrameX((int)point16.X);
                tile1.wallFrameY((int)point16.Y);
            }
        }
Beispiel #11
0
        public static void WallFrame(int i, int j, bool resetFrame = false)
        {
            if (WorldGen.SkipFramingBecauseOfGen || i <= 0 || j <= 0 || i >= Main.maxTilesX - 1 || j >= Main.maxTilesY - 1 || Main.tile[i, j] == null)
            {
                return;
            }
            WorldGen.UpdateMapTile(i, j);
            Tile tile = Main.tile[i, j];

            if (tile.wall == 0)
            {
                tile.wallColor(0);
                return;
            }
            int num = 0;

            if (j - 1 >= 0)
            {
                Tile tile2 = Main.tile[i, j - 1];
                if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54)))
                {
                    num = 1;
                }
            }
            if (i - 1 >= 0)
            {
                Tile tile2 = Main.tile[i - 1, j];
                if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54)))
                {
                    num |= 2;
                }
            }
            if (i + 1 <= Main.maxTilesX - 1)
            {
                Tile tile2 = Main.tile[i + 1, j];
                if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54)))
                {
                    num |= 4;
                }
            }
            if (j + 1 <= Main.maxTilesY - 1)
            {
                Tile tile2 = Main.tile[i, j + 1];
                if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54)))
                {
                    num |= 8;
                }
            }
            int num2 = 0;

            if (Main.wallLargeFrames[tile.wall] == 1)
            {
                num2 = phlebasTileFrameNumberLookup[j % 4][i % 3] - 1;
                tile.wallFrameNumber((byte)num2);
            }
            else if (Main.wallLargeFrames[tile.wall] == 2)
            {
                num2 = lazureTileFrameNumberLookup[i % 2][j % 2] - 1;
                tile.wallFrameNumber((byte)num2);
            }
            else if (resetFrame)
            {
                num2 = WorldGen.genRand.Next(0, 3);
                if (tile.wall == 21 && WorldGen.genRand.Next(2) == 0)
                {
                    num2 = 2;
                }
                tile.wallFrameNumber((byte)num2);
            }
            else
            {
                num2 = tile.wallFrameNumber();
            }
            if (num == 15)
            {
                num += centerWallFrameLookup[i % 3][j % 3];
            }
            Point16 point = wallFrameLookup[num][num2];

            tile.wallFrameX(point.X);
            tile.wallFrameY(point.Y);
        }
        public void DrawFreshAnimations(SpriteBatch spriteBatch)
        {
            for (int i = 0; i < data.Length; i++)
            {
                data[i].animationTimeElapsed++;
            }
            if (!Main.SettingsEnabled_MinersWobble)
            {
                return;
            }
            int     num    = 1;
            Vector2 vector = new Vector2(Main.offScreenRange);

            if (Main.drawToScreen)
            {
                vector = Vector2.Zero;
            }
            vector = Vector2.Zero;
            for (int j = 0; j < data.Length; j++)
            {
                if (data[j].type != num)
                {
                    continue;
                }
                int damage = data[j].damage;
                if (damage < 20)
                {
                    continue;
                }
                int x = data[j].X;
                int y = data[j].Y;
                if (!WorldGen.InWorld(x, y))
                {
                    continue;
                }
                bool flag = Main.tile[x, y] != null;
                if (flag && num == 1)
                {
                    flag = flag && Main.tile[x, y].active() && Main.tileSolid[Main.tile[x, y].type];
                }
                if (flag && num == 2)
                {
                    flag = flag && Main.tile[x, y].wall != 0;
                }
                if (!flag)
                {
                    continue;
                }
                bool flag2 = false;
                bool flag3 = false;
                if (Main.tile[x, y].type == 10)
                {
                    flag2 = false;
                }
                else if (Main.tileSolid[Main.tile[x, y].type] && !Main.tileSolidTop[Main.tile[x, y].type])
                {
                    flag2 = true;
                }
                else if (WorldGen.IsTreeType(Main.tile[x, y].type))
                {
                    flag3 = true;
                    int num2 = Main.tile[x, y].frameX / 22;
                    int num3 = Main.tile[x, y].frameY / 22;
                    if (num3 < 9)
                    {
                        flag2 = ((num2 != 1 && num2 != 2) || num3 < 6 || num3 > 8) && (num2 != 3 || num3 > 2) && (num2 != 4 || num3 < 3 || num3 > 5) && ((num2 != 5 || num3 < 6 || num3 > 8) ? true : false);
                    }
                }
                else if (Main.tile[x, y].type == 72)
                {
                    flag3 = true;
                    if (Main.tile[x, y].frameX <= 34)
                    {
                        flag2 = true;
                    }
                }
                if (!flag2 || Main.tile[x, y].slope() != 0 || Main.tile[x, y].halfBrick())
                {
                    continue;
                }
                int num4 = 0;
                if (damage >= 80)
                {
                    num4 = 3;
                }
                else if (damage >= 60)
                {
                    num4 = 2;
                }
                else if (damage >= 40)
                {
                    num4 = 1;
                }
                else if (damage >= 20)
                {
                    num4 = 0;
                }
                Rectangle value = new Rectangle(data[j].crackStyle * 18, num4 * 18, 16, 16);
                value.Inflate(-2, -2);
                if (flag3)
                {
                    value.X = (4 + data[j].crackStyle / 2) * 18;
                }
                int animationTimeElapsed = data[j].animationTimeElapsed;
                if (!((float)animationTimeElapsed >= 10f))
                {
                    float   num5     = (float)animationTimeElapsed / 10f;
                    Color   color    = Lighting.GetColor(x, y);
                    float   rotation = 0f;
                    Vector2 zero     = Vector2.Zero;
                    float   num6     = 0.5f;
                    float   num7     = num5 % num6;
                    num7 *= 1f / num6;
                    if ((int)(num5 / num6) % 2 == 1)
                    {
                        num7 = 1f - num7;
                    }
                    Tile      tileSafely = Framing.GetTileSafely(x, y);
                    Tile      tile       = tileSafely;
                    Texture2D texture2D  = Main.instance.TilePaintSystem.TryGetTileAndRequestIfNotReady(tileSafely.type, 0, tileSafely.color());
                    if (texture2D != null)
                    {
                        Vector2 vector2     = new Vector2(8f);
                        Vector2 value2      = new Vector2(1f);
                        float   scaleFactor = num7 * 0.2f + 1f;
                        float   num8        = 1f - num7;
                        num8   = 1f;
                        color *= num8 * num8 * 0.8f;
                        Vector2 scale    = scaleFactor * value2;
                        Vector2 position = (new Vector2(x * 16 - (int)Main.screenPosition.X, y * 16 - (int)Main.screenPosition.Y) + vector + vector2 + zero);
                        spriteBatch.Draw(texture2D, position, new Rectangle(tile.frameX, tile.frameY, 16, 16), color, rotation, vector2, scale, SpriteEffects.None, 0f);
                        color.A = 180;
                        spriteBatch.Draw(TextureAssets.TileCrack.Value, position, value, color, rotation, vector2, scale, SpriteEffects.None, 0f);
                    }
                }
            }
        }
Beispiel #13
0
 private static void InnerClientLoop()
 {
     try
     {
         NetMessage.buffer[256].Reset();
         int num1 = -1;
         while (!Netplay.disconnect)
         {
             if (Netplay.Connection.Socket.IsConnected())
             {
                 if (NetMessage.buffer[256].checkBytes)
                 {
                     NetMessage.CheckBytes(256);
                 }
                 Netplay.Connection.IsActive = true;
                 if (Netplay.Connection.State == 0)
                 {
                     Main.statusText          = Language.GetTextValue("Net.FoundServer");
                     Netplay.Connection.State = 1;
                     NetMessage.SendData(1, -1, -1, (NetworkText)null, 0, 0.0f, 0.0f, 0.0f, 0, 0, 0);
                 }
                 if (Netplay.Connection.State == 2 && num1 != Netplay.Connection.State)
                 {
                     Main.statusText = Language.GetTextValue("Net.SendingPlayerData");
                 }
                 if (Netplay.Connection.State == 3 && num1 != Netplay.Connection.State)
                 {
                     Main.statusText = Language.GetTextValue("Net.RequestingWorldInformation");
                 }
                 if (Netplay.Connection.State == 4)
                 {
                     WorldGen.worldCleared    = false;
                     Netplay.Connection.State = 5;
                     Main.cloudBGAlpha        = (double)Main.cloudBGActive < 1.0 ? 0.0f : 1f;
                     Main.windSpeed           = Main.windSpeedSet;
                     Cloud.resetClouds();
                     Main.cloudAlpha = Main.maxRaining;
                     WorldGen.clearWorld();
                     if (Main.mapEnabled)
                     {
                         Main.Map.Load();
                     }
                 }
                 if (Netplay.Connection.State == 5 && Main.loadMapLock)
                 {
                     float num2 = (float)Main.loadMapLastX / (float)Main.maxTilesX;
                     Main.statusText = Lang.gen[68].Value + " " + (object)(int)((double)num2 * 100.0 + 1.0) + "%";
                 }
                 else if (Netplay.Connection.State == 5 && WorldGen.worldCleared)
                 {
                     Netplay.Connection.State = 6;
                     Main.player[Main.myPlayer].FindSpawn();
                     NetMessage.SendData(8, -1, -1, (NetworkText)null, Main.player[Main.myPlayer].SpawnX, (float)Main.player[Main.myPlayer].SpawnY, 0.0f, 0.0f, 0, 0, 0);
                 }
                 if (Netplay.Connection.State == 6 && num1 != Netplay.Connection.State)
                 {
                     Main.statusText = Language.GetTextValue("Net.RequestingTileData");
                 }
                 if (!Netplay.Connection.IsReading && !Netplay.disconnect && Netplay.Connection.Socket.IsDataAvailable())
                 {
                     Netplay.Connection.IsReading = true;
                     Netplay.Connection.Socket.AsyncReceive(Netplay.Connection.ReadBuffer, 0, Netplay.Connection.ReadBuffer.Length, new SocketReceiveCallback(Netplay.Connection.ClientReadCallBack), (object)null);
                 }
                 if (Netplay.Connection.StatusMax > 0 && Netplay.Connection.StatusText != "")
                 {
                     if (Netplay.Connection.StatusCount >= Netplay.Connection.StatusMax)
                     {
                         Main.statusText = Language.GetTextValue("Net.StatusComplete", (object)Netplay.Connection.StatusText);
                         Netplay.Connection.StatusText  = "";
                         Netplay.Connection.StatusMax   = 0;
                         Netplay.Connection.StatusCount = 0;
                     }
                     else
                     {
                         Main.statusText = Netplay.Connection.StatusText + ": " + (object)(int)((double)Netplay.Connection.StatusCount / (double)Netplay.Connection.StatusMax * 100.0) + "%";
                     }
                 }
                 Thread.Sleep(1);
             }
             else if (Netplay.Connection.IsActive)
             {
                 Main.statusText    = Language.GetTextValue("Net.LostConnection");
                 Netplay.disconnect = true;
             }
             num1 = Netplay.Connection.State;
         }
         try
         {
             Netplay.Connection.Socket.Close();
         }
         catch
         {
         }
         if (!Main.gameMenu)
         {
             Main.SwitchNetMode(0);
             Player.SavePlayer(Main.ActivePlayerFileData, false);
             Main.ActivePlayerFileData.StopPlayTimer();
             Main.gameMenu = true;
             Main.StopTrackedSounds();
             Main.menuMode = 14;
         }
         NetMessage.buffer[256].Reset();
         if (Main.menuMode == 15 && Main.statusText == Language.GetTextValue("Net.LostConnection"))
         {
             Main.menuMode = 14;
         }
         if (Netplay.Connection.StatusText != "" && Netplay.Connection.StatusText != null)
         {
             Main.statusText = Language.GetTextValue("Net.LostConnection");
         }
         Netplay.Connection.StatusCount = 0;
         Netplay.Connection.StatusMax   = 0;
         Netplay.Connection.StatusText  = "";
         Main.SwitchNetMode(0);
     }
     catch (Exception ex)
     {
         try
         {
             using (StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", true))
             {
                 streamWriter.WriteLine((object)DateTime.Now);
                 streamWriter.WriteLine((object)ex);
                 streamWriter.WriteLine("");
             }
         }
         catch
         {
         }
         Netplay.disconnect = true;
     }
     if (Netplay.OnDisconnect == null)
     {
         return;
     }
     Netplay.OnDisconnect.Invoke();
 }
Beispiel #14
0
        public static void ClientLoop()
        {
            Thread.CurrentThread.SetProcessorAffinity(5);
            Init();
            UI.main.player.hostile = false;
            UI.main.player.NetClone(UI.main.netPlayer);
            for (int i = 0; i < 8; i++)
            {
                if (i != UI.main.myPlayer)
                {
                    Main.player[i].active = 0;
                }
            }
            WorldGen.clearWorld();
            if (UI.main.menuMode == MenuMode.NETPLAY)
            {
                Main.netMode = 1;
                try
                {
                    if (isJoiningRemoteInvite)
                    {
                        isJoiningRemoteInvite = false;
                        session = NetworkSession.JoinInvited(gamersWaitingToJoinInvite);
                        gamersWaitingToJoinInvite.Clear();
                        gamersWhoReceivedInvite.Clear();
                    }
                    else
                    {
                        session = NetworkSession.Join(WorldSelect.Session());
                    }
                }
                catch (Exception)
                {
                    UI.Error(Lang.menu[5], Lang.inter[21], rememberPreviousMenu: true);
                    UI.main.menuType = MenuType.MAIN;
                    Main.netMode     = 0;
                    disconnect       = true;
                    stopSession      = true;
                    goto IL_028d;
                }
                hookEvents = true;
                while (!disconnect && session != null)
                {
                    switch (clientState)
                    {
                    case ClientState.JOINING:
                        UI.main.FirstProgressStep(3, Lang.menu[8]);
                        clientState = ClientState.WAITING_FOR_PLAYER_ID;
                        break;

                    case ClientState.WAITING_FOR_PLAYER_ID:
                        if (UI.main.progress <= 0.999f)
                        {
                            UI.main.progress = UI.main.progress + 0.001f;
                        }
                        break;

                    case ClientState.WAITING_FOR_PLAYER_DATA_REQ:
                        if (UI.main.progress <= 0.999f)
                        {
                            UI.main.progress = UI.main.progress + 0.001f;
                        }
                        break;

                    case ClientState.RECEIVED_PLAYER_DATA_REQ:
                        UI.main.NextProgressStep(Lang.menu[73]);
                        clientState = ClientState.WAITING_FOR_WORLD_INFO;
                        break;

                    case ClientState.WAITING_FOR_WORLD_INFO:
                        if (UI.main.progress <= 0.999f)
                        {
                            UI.main.progress = UI.main.progress + 0.001f;
                        }
                        break;

                    case ClientState.WAITING_FOR_TILE_DATA:
                        if (clientStatusMax > 0)
                        {
                            if (clientStatusCount >= clientStatusMax)
                            {
                                clientStatusMax   = 0;
                                clientStatusCount = 0;
                                UI.main.progress  = 1f;
                            }
                            else
                            {
                                UI.main.statusText = Lang.inter[44];
                                UI.main.progress   = (float)clientStatusCount / (float)clientStatusMax;
                            }
                        }
                        break;
                    }
                    Thread.Sleep(0);
                }
                clientStatusCount = 0;
                clientStatusMax   = 0;
                stopSession       = true;
            }
            goto IL_028d;
IL_028d:
            sessionThread = null;
        }
        public static bool Place(TileObject toBePlaced)
        {
            var tileData =
                TileObjectData.GetTileData(toBePlaced.type, toBePlaced.style, toBePlaced.alternate);

            if (tileData == null)
            {
                return(false);
            }
            if (tileData.HookPlaceOverride.hook != null)
            {
                int num1;
                int num2;
                if (tileData.HookPlaceOverride.processedCoordinates)
                {
                    num1 = toBePlaced.xCoord;
                    num2 = toBePlaced.yCoord;
                }
                else
                {
                    num1 = toBePlaced.xCoord + (int)tileData.Origin.X;
                    num2 = toBePlaced.yCoord + (int)tileData.Origin.Y;
                }

                if (tileData.HookPlaceOverride.hook(num1, num2, toBePlaced.type, toBePlaced.style, 1) ==
                    tileData.HookPlaceOverride.badReturn)
                {
                    return(false);
                }
            }
            else
            {
                var type           = (ushort)toBePlaced.type;
                var placementStyle =
                    tileData.CalculatePlacementStyle(toBePlaced.style, toBePlaced.alternate, toBePlaced.random);
                var num1 = 0;
                if (tileData.StyleWrapLimit > 0)
                {
                    num1            = placementStyle / tileData.StyleWrapLimit * tileData.StyleLineSkip;
                    placementStyle %= tileData.StyleWrapLimit;
                }

                int num2;
                int num3;
                if (tileData.StyleHorizontal)
                {
                    num2 = tileData.CoordinateFullWidth * placementStyle;
                    num3 = tileData.CoordinateFullHeight * num1;
                }
                else
                {
                    num2 = tileData.CoordinateFullWidth * num1;
                    num3 = tileData.CoordinateFullHeight * placementStyle;
                }

                var xCoord = toBePlaced.xCoord;
                var yCoord = toBePlaced.yCoord;
                for (var index1 = 0; index1 < tileData.Width; ++index1)
                {
                    for (var index2 = 0; index2 < tileData.Height; ++index2)
                    {
                        var tileSafely = Framing.GetTileSafely(xCoord + index1, yCoord + index2);
                        if (tileSafely.active() && Main.tileCut[(int)tileSafely.type])
                        {
                            WorldGen.KillTile(xCoord + index1, yCoord + index2, false, false, false);
                        }
                    }
                }

                for (var index1 = 0; index1 < tileData.Width; ++index1)
                {
                    var num4 = num2 + index1 * (tileData.CoordinateWidth + tileData.CoordinatePadding);
                    var num5 = num3;
                    for (var index2 = 0; index2 < tileData.Height; ++index2)
                    {
                        var tileSafely = Framing.GetTileSafely(xCoord + index1, yCoord + index2);
                        if (!tileSafely.active())
                        {
                            tileSafely.active(true);
                            tileSafely.frameX = (short)num4;
                            tileSafely.frameY = (short)num5;
                            tileSafely.type   = type;
                        }

                        num5 += tileData.CoordinateHeights[index2] + tileData.CoordinatePadding;
                    }
                }
            }

            if (tileData.FlattenAnchors)
            {
                var anchorData = tileData.AnchorBottom;
                if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    var num = toBePlaced.xCoord + anchorData.checkStart;
                    var j   = toBePlaced.yCoord + tileData.Height;
                    for (var index = 0; index < anchorData.tileCount; ++index)
                    {
                        var tileSafely = Framing.GetTileSafely(num + index, j);
                        if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] &&
                            tileSafely.blockType() != 0)
                        {
                            WorldGen.SlopeTile(num + index, j, 0);
                        }
                    }
                }

                anchorData = tileData.AnchorTop;
                if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    var num = toBePlaced.xCoord + anchorData.checkStart;
                    var j   = toBePlaced.yCoord - 1;
                    for (var index = 0; index < anchorData.tileCount; ++index)
                    {
                        var tileSafely = Framing.GetTileSafely(num + index, j);
                        if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] &&
                            tileSafely.blockType() != 0)
                        {
                            WorldGen.SlopeTile(num + index, j, 0);
                        }
                    }
                }

                anchorData = tileData.AnchorRight;
                if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    var i   = toBePlaced.xCoord + tileData.Width;
                    var num = toBePlaced.yCoord + anchorData.checkStart;
                    for (var index = 0; index < anchorData.tileCount; ++index)
                    {
                        var tileSafely = Framing.GetTileSafely(i, num + index);
                        if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] &&
                            tileSafely.blockType() != 0)
                        {
                            WorldGen.SlopeTile(i, num + index, 0);
                        }
                    }
                }

                anchorData = tileData.AnchorLeft;
                if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile)
                {
                    var i   = toBePlaced.xCoord - 1;
                    var num = toBePlaced.yCoord + anchorData.checkStart;
                    for (var index = 0; index < anchorData.tileCount; ++index)
                    {
                        var tileSafely = Framing.GetTileSafely(i, num + index);
                        if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] &&
                            tileSafely.blockType() != 0)
                        {
                            WorldGen.SlopeTile(i, num + index, 0);
                        }
                    }
                }
            }

            return(true);
        }
        /*public static void newRecent()
         * {
         *      for (int i = 0; i < Main.maxMP; i++)
         *      {
         *              if (Main.recentIP[i] == Netplay.serverIP.ToString() && Main.recentPort[i] == Netplay.serverPort)
         *              {
         *                      for (int j = i; j < Main.maxMP - 1; j++)
         *                      {
         *                              Main.recentIP[j] = Main.recentIP[j + 1];
         *                              Main.recentPort[j] = Main.recentPort[j + 1];
         *                              Main.recentWorld[j] = Main.recentWorld[j + 1];
         *                      }
         *              }
         *      }
         *      for (int k = Main.maxMP - 1; k > 0; k--)
         *      {
         *              Main.recentIP[k] = Main.recentIP[k - 1];
         *              Main.recentPort[k] = Main.recentPort[k - 1];
         *              Main.recentWorld[k] = Main.recentWorld[k - 1];
         *      }
         *      Main.recentIP[0] = Netplay.serverIP.ToString();
         *      Main.recentPort[0] = Netplay.serverPort;
         *      Main.recentWorld[0] = Main.worldName;
         *      Main.SaveRecent();
         * }
         * public static void ClientLoop(object threadContext)
         * {
         *      Netplay.ResetNetDiag();
         *  Main.ServerSideCharacter = false;
         *      if (Main.rand == null)
         *      {
         *              Main.rand = new Random((int)DateTime.Now.Ticks);
         *      }
         *      if (WorldGen.genRand == null)
         *      {
         *              WorldGen.genRand = new Random((int)DateTime.Now.Ticks);
         *      }
         *      Main.player[Main.myPlayer].hostile = false;
         *      Main.clientPlayer = (Player)Main.player[Main.myPlayer].clientClone();
         *      for (int i = 0; i < 255; i++)
         *      {
         *              if (i != Main.myPlayer)
         *              {
         *                      Main.player[i] = new Player();
         *              }
         *      }
         *      Main.menuMode = 10;
         *      Main.menuMode = 14;
         *      if (!Main.autoPass)
         *      {
         *              Main.statusText = "Connecting to " + Netplay.serverIP;
         *      }
         *      Main.netMode = 1;
         *      Netplay.disconnect = false;
         *      Netplay.clientSock = new ClientSock();
         *      Netplay.clientSock.tcpClient.NoDelay = true;
         *      Netplay.clientSock.readBuffer = new byte[1024];
         *      Netplay.clientSock.writeBuffer = new byte[1024];
         *      bool flag = true;
         *      while (flag)
         *      {
         *              flag = false;
         *              try
         *              {
         *                      Netplay.clientSock.tcpClient.Connect(Netplay.serverIP, Netplay.serverPort);
         *                      Netplay.clientSock.networkStream = Netplay.clientSock.tcpClient.GetStream();
         *                      flag = false;
         *              }
         *              catch
         *              {
         *                      if (!Netplay.disconnect && Main.gameMenu)
         *                      {
         *                              flag = true;
         *                      }
         *              }
         *      }
         *      NetMessage.buffer[256].Reset();
         *      int num = -1;
         *      while (!Netplay.disconnect)
         *      {
         *              if (Netplay.clientSock.tcpClient.Connected)
         *              {
         *                      if (NetMessage.buffer[256].checkBytes)
         *                      {
         *                              NetMessage.CheckBytes(256);
         *                      }
         *                      Netplay.clientSock.active = true;
         *                      if (Netplay.clientSock.state == 0)
         *                      {
         *                              Main.statusText = "Found server";
         *                              Netplay.clientSock.state = 1;
         *                              NetMessage.SendData(1, -1, -1, "", 0, 0f, 0f, 0f, 0);
         *                      }
         *                      if (Netplay.clientSock.state == 2 && num != Netplay.clientSock.state)
         *                      {
         *                              Main.statusText = "Sending player data...";
         *                      }
         *                      if (Netplay.clientSock.state == 3 && num != Netplay.clientSock.state)
         *                      {
         *                              Main.statusText = "Requesting world information";
         *                      }
         *                      if (Netplay.clientSock.state == 4)
         *                      {
         *                              WorldGen.worldCleared = false;
         *                              Netplay.clientSock.state = 5;
         *                              if (Main.cloudBGActive >= 1f)
         *                              {
         *                                      Main.cloudBGAlpha = 1f;
         *                              }
         *                              else
         *                              {
         *                                      Main.cloudBGAlpha = 0f;
         *                              }
         *                              Main.windSpeed = Main.windSpeedSet;
         *                              Cloud.resetClouds();
         *                              Main.cloudAlpha = Main.maxRaining;
         *                              WorldGen.clearWorld();
         *                              if (Main.mapEnabled)
         *                              {
         *                                      Map.loadMap();
         *                              }
         *                      }
         *                      if (Netplay.clientSock.state == 5 && Main.loadMapLock)
         *                      {
         *                              float num2 = (float)Main.loadMapLastX / (float)Main.maxTilesX;
         *                              Main.statusText = string.Concat(new object[]
         *                              {
         *                                      Lang.gen[68],
         *                                      " ",
         *                                      (int)(num2 * 100f + 1f),
         *                                      "%"
         *                              });
         *                      }
         *                      else
         *                      {
         *                              if (Netplay.clientSock.state == 5 && WorldGen.worldCleared)
         *                              {
         *                                      Netplay.clientSock.state = 6;
         *                                      Main.player[Main.myPlayer].FindSpawn();
         *                                      NetMessage.SendData(8, -1, -1, "", Main.player[Main.myPlayer].SpawnX, (float)Main.player[Main.myPlayer].SpawnY, 0f, 0f, 0);
         *                              }
         *                      }
         *                      if (Netplay.clientSock.state == 6 && num != Netplay.clientSock.state)
         *                      {
         *                              Main.statusText = "Requesting tile data";
         *                      }
         *                      if (!Netplay.clientSock.locked && !Netplay.disconnect && Netplay.clientSock.networkStream.DataAvailable)
         *                      {
         *                              Netplay.clientSock.locked = true;
         *                              Netplay.clientSock.networkStream.BeginRead(Netplay.clientSock.readBuffer, 0, Netplay.clientSock.readBuffer.Length, new AsyncCallback(Netplay.clientSock.ClientReadCallBack), Netplay.clientSock.networkStream);
         *                      }
         *                      if (Netplay.clientSock.statusMax > 0 && Netplay.clientSock.statusText != "")
         *                      {
         *                              if (Netplay.clientSock.statusCount >= Netplay.clientSock.statusMax)
         *                              {
         *                                      Main.statusText = Netplay.clientSock.statusText + ": Complete!";
         *                                      Netplay.clientSock.statusText = "";
         *                                      Netplay.clientSock.statusMax = 0;
         *                                      Netplay.clientSock.statusCount = 0;
         *                              }
         *                              else
         *                              {
         *                                      Main.statusText = string.Concat(new object[]
         *                                      {
         *                                              Netplay.clientSock.statusText,
         *                                              ": ",
         *                                              (int)((float)Netplay.clientSock.statusCount / (float)Netplay.clientSock.statusMax * 100f),
         *                                              "%"
         *                                      });
         *                              }
         *                      }
         *                      Thread.Sleep(1);
         *              }
         *              else
         *              {
         *                      if (Netplay.clientSock.active)
         *                      {
         *                              Main.statusText = "Lost connection";
         *                              Netplay.disconnect = true;
         *                      }
         *              }
         *              num = Netplay.clientSock.state;
         *      }
         *      try
         *      {
         *              Netplay.clientSock.networkStream.Close();
         *              Netplay.clientSock.networkStream = Netplay.clientSock.tcpClient.GetStream();
         *      }
         *      catch
         *      {
         *      }
         *      if (!Main.gameMenu)
         *      {
         *              Main.netMode = 0;
         *              Player.SavePlayer(Main.player[Main.myPlayer], Main.playerPathName);
         *              Main.gameMenu = true;
         *              Main.menuMode = 14;
         *      }
         *      NetMessage.buffer[256].Reset();
         *      if (Main.menuMode == 15 && Main.statusText == "Lost connection")
         *      {
         *              Main.menuMode = 14;
         *      }
         *      if (Netplay.clientSock.statusText != "" && Netplay.clientSock.statusText != null)
         *      {
         *              Main.statusText = "Lost connection";
         *      }
         *      Netplay.clientSock.statusCount = 0;
         *      Netplay.clientSock.statusMax = 0;
         *      Netplay.clientSock.statusText = "";
         *      Main.netMode = 0;
         * }*/
        public static void ServerLoop(object threadContext)
        {
            Netplay.ResetNetDiag();
            if (Main.rand == null)
            {
                Main.rand = new Random((int)DateTime.Now.Ticks);
            }
            if (WorldGen.genRand == null)
            {
                WorldGen.genRand = new Random((int)DateTime.Now.Ticks);
            }
            Main.myPlayer      = 255;
            Netplay.serverIP   = IPAddress.Any;
            Main.menuMode      = 14;
            Main.statusText    = "Starting server...";
            Main.netMode       = 2;
            Netplay.disconnect = false;
            for (int i = 0; i < 256; i++)
            {
                Netplay.serverSock[i] = new ServerSock();
                Netplay.serverSock[i].Reset();
                Netplay.serverSock[i].whoAmI            = i;
                Netplay.serverSock[i].tcpClient         = new TcpClient();
                Netplay.serverSock[i].tcpClient.NoDelay = true;
                Netplay.serverSock[i].readBuffer        = new byte[1024];
                Netplay.serverSock[i].writeBuffer       = new byte[1024];
            }
            Netplay.tcpListener = new TcpListener(Netplay.serverListenIP, Netplay.serverPort);
            try
            {
                Netplay.tcpListener.Start();
            }
            catch (Exception ex)
            {
                Main.menuMode      = 15;
                Main.statusText    = ex.ToString();
                Netplay.disconnect = true;
            }
            if (!Netplay.disconnect)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ListenForClients), 1);
                Main.statusText = "Server started";
            }
            int num = 0;

            while (!Netplay.disconnect)
            {
                if (Netplay.stopListen)
                {
                    int num2 = -1;
                    for (int j = 0; j < Main.maxNetPlayers; j++)
                    {
                        if (serverSock[j].tcpClient == null || serverSock[j].tcpClient.Client == null || !Netplay.serverSock[j].tcpClient.Connected)
                        {
                            num2 = j;
                            break;
                        }
                    }
                    if (num2 >= 0)
                    {
                        if (Main.ignoreErrors)
                        {
                            try
                            {
                                Netplay.tcpListener.Start();
                                Netplay.stopListen = false;
                                ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ListenForClients), 1);
                                goto IL_219;
                            }
                            catch
                            {
                                goto IL_219;
                            }
                        }
                        Netplay.tcpListener.Start();
                        Netplay.stopListen = false;
                        ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ListenForClients), 1);
                    }
                }
IL_219:
                int num3 = 0;
                for (int k = 0; k < 256; k++)
                {
                    if (NetMessage.buffer[k].checkBytes)
                    {
                        NetMessage.CheckBytes(k);
                    }
                    if (killInactive && serverSock[k].active && serverSock[k].state == 0 && (DateTime.UtcNow - serverSock[k].connectTime).TotalSeconds > 5)
                    {
                        Netplay.serverSock[k].kill = true;
                    }
                    if (Netplay.serverSock[k].kill)
                    {
                        ServerApi.Hooks.InvokeServerLeave(Netplay.serverSock[k].whoAmI);
                        Netplay.serverSock[k].Reset();
                        NetMessage.syncPlayers();
                    }
                    else
                    {
                        if (serverSock[k].tcpClient != null && serverSock[k].tcpClient.Client != null && serverSock[k].tcpClient.Connected)
                        {
                            if (!Netplay.serverSock[k].active)
                            {
                                Netplay.serverSock[k].state = 0;
                            }
                            Netplay.serverSock[k].active = true;
                            num3++;
                            if (!Netplay.serverSock[k].locked)
                            {
                                try
                                {
                                    Netplay.serverSock[k].networkStream = Netplay.serverSock[k].tcpClient.GetStream();
                                    if (Netplay.serverSock[k].networkStream.DataAvailable)
                                    {
                                        Netplay.serverSock[k].locked = true;
                                        Netplay.serverSock[k].networkStream.BeginRead(Netplay.serverSock[k].readBuffer, 0, Netplay.serverSock[k].readBuffer.Length, new AsyncCallback(Netplay.serverSock[k].ServerReadCallBack), Netplay.serverSock[k].networkStream);
                                    }
                                }
                                catch
                                {
                                    Netplay.serverSock[k].kill = true;
                                }
                            }
                            if (Netplay.serverSock[k].statusMax > 0 && Netplay.serverSock[k].statusText2 != "")
                            {
                                if (Netplay.serverSock[k].statusCount >= Netplay.serverSock[k].statusMax)
                                {
                                    try{
                                        Netplay.serverSock[k].statusText = string.Concat(new object[]
                                        {
                                            "(",
                                            Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
                                            ") ",
                                            Netplay.serverSock[k].name,
                                            " ",
                                            Netplay.serverSock[k].statusText2,
                                            ": Complete!"
                                        });
                                    } catch (Exception ex)
                                    {}
                                    Netplay.serverSock[k].statusText2 = "";
                                    Netplay.serverSock[k].statusMax   = 0;
                                    Netplay.serverSock[k].statusCount = 0;
                                }
                                else
                                {
                                    try{
                                        Netplay.serverSock[k].statusText = string.Concat(new object[]
                                        {
                                            "(",
                                            Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
                                            ") ",
                                            Netplay.serverSock[k].name,
                                            " ",
                                            Netplay.serverSock[k].statusText2,
                                            ": ",
                                            (int)((float)Netplay.serverSock[k].statusCount / (float)Netplay.serverSock[k].statusMax * 100f),
                                            "%"
                                        });
                                    }catch (Exception ex)
                                    {}
                                }
                            }
                            else
                            {
                                if (Netplay.serverSock[k].state == 0)
                                {
                                    try {
                                        Netplay.serverSock[k].statusText = string.Concat(new object[]
                                        {
                                            "(",
                                            Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
                                            ") ",
                                            Netplay.serverSock[k].name,
                                            " is connecting..."
                                        });
                                    } catch (Exception ex)
                                    {}
                                }

                                else
                                {
                                    if (Netplay.serverSock[k].state == 1)
                                    {
                                        try {
                                            Netplay.serverSock[k].statusText = string.Concat(new object[]
                                            {
                                                "(",
                                                Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
                                                ") ",
                                                Netplay.serverSock[k].name,
                                                " is sending player data..."
                                            });
                                        } catch (Exception ex)
                                        {}
                                    }
                                    else
                                    {
                                        try {
                                            if (Netplay.serverSock[k].state == 2)
                                            {
                                                Netplay.serverSock[k].statusText = string.Concat(new object[]
                                                {
                                                    "(",
                                                    Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
                                                    ") ",
                                                    Netplay.serverSock[k].name,
                                                    " requested world information"
                                                });
                                            }
                                            else
                                            {
                                                if (Netplay.serverSock[k].state != 3 && Netplay.serverSock[k].state == 10)
                                                {
                                                    Netplay.serverSock[k].statusText = string.Concat(new object[]
                                                    {
                                                        "(",
                                                        Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
                                                        ") ",
                                                        Netplay.serverSock[k].name,
                                                        " is playing"
                                                    });
                                                }
                                            }
                                        } catch (Exception ex)
                                        {}
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (Netplay.serverSock[k].active)
                            {
                                Netplay.serverSock[k].kill = true;
                            }
                            else
                            {
                                Netplay.serverSock[k].statusText2 = "";
                                if (k < 255)
                                {
                                    Main.player[k].active = false;
                                }
                            }
                        }
                    }
                }
                num++;
                if (num > 10)
                {
                    Thread.Sleep(1);
                    num = 0;
                }
                else
                {
                    Thread.Sleep(0);
                }
                if (!WorldGen.saveLock && !Main.dedServ)
                {
                    if (num3 == 0)
                    {
                        Main.statusText = "Waiting for clients...";
                    }
                    else
                    {
                        Main.statusText = num3 + " clients connected";
                    }
                }
                if (num3 == 0)
                {
                    Netplay.anyClients = false;
                }
                else
                {
                    Netplay.anyClients = true;
                }
                Netplay.ServerUp = true;
            }
            Netplay.tcpListener.Stop();
            for (int l = 0; l < 256; l++)
            {
                Netplay.serverSock[l].Reset();
            }
            if (Main.menuMode != 15)
            {
                Main.netMode  = 0;
                Main.menuMode = 10;
                WorldGen.saveWorld(false);
                while (WorldGen.saveLock)
                {
                }
                Main.menuMode = 0;
            }
            else
            {
                Main.netMode = 0;
            }
            Main.myPlayer = 0;
        }
        public static void DrawPreview(SpriteBatch sb, TileObjectPreviewData op, Vector2 position)
        {
            var coordinates    = op.Coordinates;
            var texture        = Main.tileTexture[(int)op.Type];
            var tileData       = TileObjectData.GetTileData((int)op.Type, (int)op.Style, op.Alternate);
            var placementStyle = tileData.CalculatePlacementStyle((int)op.Style, op.Alternate, op.Random);
            var num1           = 0;
            var drawYoffset    = tileData.DrawYOffset;

            if (tileData.StyleWrapLimit > 0)
            {
                num1            = placementStyle / tileData.StyleWrapLimit * tileData.StyleLineSkip;
                placementStyle %= tileData.StyleWrapLimit;
            }

            int num2;
            int num3;

            if (tileData.StyleHorizontal)
            {
                num2 = tileData.CoordinateFullWidth * placementStyle;
                num3 = tileData.CoordinateFullHeight * num1;
            }
            else
            {
                num2 = tileData.CoordinateFullWidth * num1;
                num3 = tileData.CoordinateFullHeight * placementStyle;
            }

            for (var index1 = 0; index1 < (int)op.Size.X; ++index1)
            {
                var x = num2 + (index1 - (int)op.ObjectStart.X) *
                        (tileData.CoordinateWidth + tileData.CoordinatePadding);
                var y = num3;
                for (var index2 = 0; index2 < (int)op.Size.Y; ++index2)
                {
                    var i    = (int)coordinates.X + index1;
                    var num4 = (int)coordinates.Y + index2;
                    if (index2 == 0 && tileData.DrawStepDown != 0 &&
                        WorldGen.SolidTile(Framing.GetTileSafely(i, num4 - 1)))
                    {
                        drawYoffset += tileData.DrawStepDown;
                    }
                    Color color1;
                    switch (op[index1, index2])
                    {
                    case 1:
                        color1 = Color.White;
                        break;

                    case 2:
                        color1 = Color.Red * 0.7f;
                        break;

                    default:
                        continue;
                    }

                    var color2 = color1 * 0.5f;
                    if (index1 >= (int)op.ObjectStart.X && index1 < (int)op.ObjectStart.X + tileData.Width &&
                        (index2 >= (int)op.ObjectStart.Y && index2 < (int)op.ObjectStart.Y + tileData.Height))
                    {
                        var effects = SpriteEffects.None;
                        if (tileData.DrawFlipHorizontal && index1 % 2 == 1)
                        {
                            effects |= SpriteEffects.FlipHorizontally;
                        }
                        if (tileData.DrawFlipVertical && index2 % 2 == 1)
                        {
                            effects |= SpriteEffects.FlipVertically;
                        }
                        var rectangle = new Rectangle(x, y, tileData.CoordinateWidth,
                                                      tileData.CoordinateHeights[index2 - (int)op.ObjectStart.Y]);
                        sb.Draw(texture,
                                new Vector2(
                                    (float)(i * 16 - (int)((double)position.X +
                                                           (double)(tileData.CoordinateWidth - 16) / 2.0)),
                                    (float)(num4 * 16 - (int)position.Y + drawYoffset)), new Rectangle?(rectangle),
                                color2, 0.0f, Vector2.Zero, 1f, effects, 0.0f);
                        y += tileData.CoordinateHeights[index2 - (int)op.ObjectStart.Y] + tileData.CoordinatePadding;
                    }
                }
            }
        }
Beispiel #18
0
        public void Update()
        {
            if (Main.netMode == 2 || !this.active)
            {
                return;
            }
            bool flag = this.type >= 1024 && this.type <= 1026;

            if (this.type >= 276 && this.type <= 282)
            {
                this.velocity.X *= 0.98f;
                this.velocity.Y *= 0.98f;
                if ((double)this.velocity.Y < (double)this.scale)
                {
                    this.velocity.Y += 0.05f;
                }
                if ((double)this.velocity.Y > 0.1)
                {
                    this.rotation = (double)this.velocity.X <= 0.0 ? this.rotation - 0.01f : this.rotation + 0.01f;
                }
            }
            if (this.type >= 570 && this.type <= 572)
            {
                this.scale = this.scale - 1f / 1000f;
                if ((double)this.scale <= 0.01)
                {
                    this.scale    = 0.01f;
                    Gore.goreTime = 0;
                }
                this.sticky   = false;
                this.rotation = this.velocity.X * 0.1f;
            }
            else if (this.type >= 706 && this.type <= 717 || this.type == 943)
            {
                this.alpha = (double)this.position.Y >= Main.worldSurface * 16.0 + 8.0 ? 100 : 0;
                int num1 = 4;
                this.frameCounter = (byte)((uint)this.frameCounter + 1U);
                if ((int)this.frame <= 4)
                {
                    int x = (int)((double)this.position.X / 16.0);
                    int y = (int)((double)this.position.Y / 16.0) - 1;
                    if (WorldGen.InWorld(x, y, 0) && !Main.tile[x, y].active())
                    {
                        this.active = false;
                    }
                    if ((int)this.frame == 0)
                    {
                        num1 = 24 + Main.rand.Next(256);
                    }
                    if ((int)this.frame == 1)
                    {
                        num1 = 24 + Main.rand.Next(256);
                    }
                    if ((int)this.frame == 2)
                    {
                        num1 = 24 + Main.rand.Next(256);
                    }
                    if ((int)this.frame == 3)
                    {
                        num1 = 24 + Main.rand.Next(96);
                    }
                    if ((int)this.frame == 5)
                    {
                        num1 = 16 + Main.rand.Next(64);
                    }
                    if (this.type == 716)
                    {
                        num1 *= 2;
                    }
                    if (this.type == 717)
                    {
                        num1 *= 4;
                    }
                    if (this.type == 943 && (int)this.frame < 6)
                    {
                        num1 = 4;
                    }
                    if ((int)this.frameCounter >= num1)
                    {
                        this.frameCounter = (byte)0;
                        this.frame        = (byte)((uint)this.frame + 1U);
                        if ((int)this.frame == 5)
                        {
                            int index = Gore.NewGore(this.position, this.velocity, this.type, 1f);
                            Main.gore[index].frame     = (byte)9;
                            Main.gore[index].velocity *= 0.0f;
                        }
                        if (this.type == 943 && (int)this.frame > 4)
                        {
                            if (Main.rand.Next(2) == 0)
                            {
                                Gore gore = Main.gore[Gore.NewGore(this.position, this.velocity, this.type, this.scale)];
                                int  num2 = 0;
                                gore.frameCounter = (byte)num2;
                                int num3 = 7;
                                gore.frame = (byte)num3;
                                Vector2 vector2 = Vector2.UnitY * 1f;
                                gore.velocity = vector2;
                            }
                            if (Main.rand.Next(2) == 0)
                            {
                                Gore gore = Main.gore[Gore.NewGore(this.position, this.velocity, this.type, this.scale)];
                                int  num2 = 0;
                                gore.frameCounter = (byte)num2;
                                int num3 = 7;
                                gore.frame = (byte)num3;
                                Vector2 vector2 = Vector2.UnitY * 2f;
                                gore.velocity = vector2;
                            }
                        }
                    }
                }
                else if ((int)this.frame <= 6)
                {
                    int num2 = 8;
                    if (this.type == 716)
                    {
                        num2 *= 2;
                    }
                    if (this.type == 717)
                    {
                        num2 *= 3;
                    }
                    if ((int)this.frameCounter >= num2)
                    {
                        this.frameCounter = (byte)0;
                        this.frame        = (byte)((uint)this.frame + 1U);
                        if ((int)this.frame == 7)
                        {
                            this.active = false;
                        }
                    }
                }
                else if ((int)this.frame <= 9)
                {
                    int num2 = 6;
                    if (this.type == 716)
                    {
                        num2             = (int)((double)num2 * 1.5);
                        this.velocity.Y += 0.175f;
                    }
                    else if (this.type == 717)
                    {
                        num2            *= 2;
                        this.velocity.Y += 0.15f;
                    }
                    else if (this.type == 943)
                    {
                        num2             = (int)((double)num2 * 1.5);
                        this.velocity.Y += 0.2f;
                    }
                    else
                    {
                        this.velocity.Y += 0.2f;
                    }
                    if ((double)this.velocity.Y < 0.5)
                    {
                        this.velocity.Y = 0.5f;
                    }
                    if ((double)this.velocity.Y > 12.0)
                    {
                        this.velocity.Y = 12f;
                    }
                    if ((int)this.frameCounter >= num2)
                    {
                        this.frameCounter = (byte)0;
                        this.frame        = (byte)((uint)this.frame + 1U);
                    }
                    if ((int)this.frame > 9)
                    {
                        this.frame = (byte)7;
                    }
                }
                else
                {
                    if (this.type == 716)
                    {
                        num1 *= 2;
                    }
                    else if (this.type == 717)
                    {
                        num1 *= 6;
                    }
                    this.velocity.Y += 0.1f;
                    if ((int)this.frameCounter >= num1)
                    {
                        this.frameCounter = (byte)0;
                        this.frame        = (byte)((uint)this.frame + 1U);
                    }
                    this.velocity = this.velocity * 0.0f;
                    if ((int)this.frame > 14)
                    {
                        this.active = false;
                    }
                }
            }
            else if (this.type == 11 || this.type == 12 || (this.type == 13 || this.type == 61) || (this.type == 62 || this.type == 63 || (this.type == 99 || this.type == 220)) || (this.type == 221 || this.type == 222 || this.type >= 375 && this.type <= 377 || (this.type >= 435 && this.type <= 437 || this.type >= 861 && this.type <= 862)))
            {
                this.velocity.Y *= 0.98f;
                this.velocity.X *= 0.98f;
                this.scale       = this.scale - 0.007f;
                if ((double)this.scale < 0.1)
                {
                    this.scale = 0.1f;
                    this.alpha = (int)byte.MaxValue;
                }
            }
            else if (this.type == 16 || this.type == 17)
            {
                this.velocity.Y *= 0.98f;
                this.velocity.X *= 0.98f;
                this.scale       = this.scale - 0.01f;
                if ((double)this.scale < 0.1)
                {
                    this.scale = 0.1f;
                    this.alpha = (int)byte.MaxValue;
                }
            }
            else if (this.type == 331)
            {
                this.alpha       = this.alpha + 5;
                this.velocity.Y *= 0.95f;
                this.velocity.X *= 0.95f;
                this.rotation    = this.velocity.X * 0.1f;
            }
            else if (GoreID.Sets.SpecialAI[this.type] == 3)
            {
                byte num1 = (byte)((uint)this.frameCounter + 1U);
                this.frameCounter = num1;
                if ((int)num1 >= 8 && (double)this.velocity.Y > 0.200000002980232)
                {
                    this.frameCounter = (byte)0;
                    int  num2 = (int)this.frame / 4;
                    byte num3 = (byte)((uint)this.frame + 1U);
                    this.frame = num3;
                    if ((int)num3 >= 4 + num2 * 4)
                    {
                        this.frame = (byte)(num2 * 4);
                    }
                }
            }
            else if (GoreID.Sets.SpecialAI[this.type] != 1 && GoreID.Sets.SpecialAI[this.type] != 2)
            {
                if (this.type >= 907 && this.type <= 909)
                {
                    this.rotation    = 0.0f;
                    this.velocity.X *= 0.98f;
                    if ((double)this.velocity.Y > 0.0 && (double)this.velocity.Y < 1.0 / 1000.0)
                    {
                        this.velocity.Y = (float)((double)Main.rand.NextFloat() * -3.0 - 0.5);
                    }
                    if ((double)this.velocity.Y > -1.0)
                    {
                        this.velocity.Y -= 0.1f;
                    }
                    if ((double)this.scale < 1.0)
                    {
                        this.scale = this.scale + 0.1f;
                    }
                    byte num1 = (byte)((uint)this.frameCounter + 1U);
                    this.frameCounter = num1;
                    if ((int)num1 >= 8)
                    {
                        this.frameCounter = (byte)0;
                        byte num2 = (byte)((uint)this.frame + 1U);
                        this.frame = num2;
                        if ((int)num2 >= 3)
                        {
                            this.frame = (byte)0;
                        }
                    }
                }
                else if (this.type < 411 || this.type > 430)
                {
                    this.velocity.Y += 0.2f;
                }
            }
            this.rotation = this.rotation + this.velocity.X * 0.1f;
            if (this.type >= 580 && this.type <= 582)
            {
                this.rotation    = 0.0f;
                this.velocity.X *= 0.95f;
            }
            if (GoreID.Sets.SpecialAI[this.type] == 2)
            {
                if (this.timeLeft < 60)
                {
                    this.alpha = this.alpha + Main.rand.Next(1, 7);
                }
                else if (this.alpha > 100)
                {
                    this.alpha = this.alpha - Main.rand.Next(1, 4);
                }
                if (this.alpha < 0)
                {
                    this.alpha = 0;
                }
                if (this.alpha > (int)byte.MaxValue)
                {
                    this.timeLeft = 0;
                }
                this.velocity.X = (float)(((double)this.velocity.X * 50.0 + (double)Main.windSpeed * 2.0 + (double)Main.rand.Next(-10, 11) * 0.100000001490116) / 51.0);
                float num1 = 0.0f;
                if ((double)this.velocity.X < 0.0)
                {
                    num1 = this.velocity.X * 0.2f;
                }
                this.velocity.Y = (float)(((double)this.velocity.Y * 50.0 - 0.349999994039536 + (double)num1 + (double)Main.rand.Next(-10, 11) * 0.200000002980232) / 51.0);
                this.rotation   = this.velocity.X * 0.6f;
                float num2 = -1f;
                if (Main.goreLoaded[this.type])
                {
                    Rectangle rectangle1 = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale));
                    for (int index = 0; index < (int)byte.MaxValue; ++index)
                    {
                        if (Main.player[index].active && !Main.player[index].dead)
                        {
                            Rectangle rectangle2 = new Rectangle((int)Main.player[index].position.X, (int)Main.player[index].position.Y, Main.player[index].width, Main.player[index].height);
                            if (rectangle1.Intersects(rectangle2))
                            {
                                this.timeLeft = 0;
                                num2          = Main.player[index].velocity.Length();
                                break;
                            }
                        }
                    }
                }
                if (this.timeLeft > 0)
                {
                    if (Main.rand.Next(2) == 0)
                    {
                        this.timeLeft = this.timeLeft - 1;
                    }
                    if (Main.rand.Next(50) == 0)
                    {
                        this.timeLeft = this.timeLeft - 5;
                    }
                    if (Main.rand.Next(100) == 0)
                    {
                        this.timeLeft = this.timeLeft - 10;
                    }
                }
                else
                {
                    this.alpha = (int)byte.MaxValue;
                    if (Main.goreLoaded[this.type] && (double)num2 != -1.0)
                    {
                        float num3 = (float)((double)Main.goreTexture[this.type].Width * (double)this.scale * 0.800000011920929);
                        float x    = this.position.X;
                        float y    = this.position.Y;
                        float num4 = (float)Main.goreTexture[this.type].Width * this.scale;
                        float num5 = (float)Main.goreTexture[this.type].Height * this.scale;
                        int   Type = 31;
                        for (int index1 = 0; (double)index1 < (double)num3; ++index1)
                        {
                            int index2 = Dust.NewDust(new Vector2(x, y), (int)num4, (int)num5, Type, 0.0f, 0.0f, 0, new Color(), 1f);
                            Main.dust[index2].velocity *= (float)((1.0 + (double)num2) / 3.0);
                            Main.dust[index2].noGravity = true;
                            Main.dust[index2].alpha     = 100;
                            Main.dust[index2].scale     = this.scale;
                        }
                    }
                }
            }
            if (this.type >= 411 && this.type <= 430)
            {
                this.alpha      = 50;
                this.velocity.X = (float)(((double)this.velocity.X * 50.0 + (double)Main.windSpeed * 2.0 + (double)Main.rand.Next(-10, 11) * 0.100000001490116) / 51.0);
                this.velocity.Y = (float)(((double)this.velocity.Y * 50.0 - 0.25 + (double)Main.rand.Next(-10, 11) * 0.200000002980232) / 51.0);
                this.rotation   = this.velocity.X * 0.3f;
                if (Main.goreLoaded[this.type])
                {
                    Rectangle rectangle1 = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale));
                    for (int index = 0; index < (int)byte.MaxValue; ++index)
                    {
                        if (Main.player[index].active && !Main.player[index].dead)
                        {
                            Rectangle rectangle2 = new Rectangle((int)Main.player[index].position.X, (int)Main.player[index].position.Y, Main.player[index].width, Main.player[index].height);
                            if (rectangle1.Intersects(rectangle2))
                            {
                                this.timeLeft = 0;
                            }
                        }
                    }
                    if (Collision.SolidCollision(this.position, (int)((double)Main.goreTexture[this.type].Width * (double)this.scale), (int)((double)Main.goreTexture[this.type].Height * (double)this.scale)))
                    {
                        this.timeLeft = 0;
                    }
                }
                if (this.timeLeft > 0)
                {
                    if (Main.rand.Next(2) == 0)
                    {
                        this.timeLeft = this.timeLeft - 1;
                    }
                    if (Main.rand.Next(50) == 0)
                    {
                        this.timeLeft = this.timeLeft - 5;
                    }
                    if (Main.rand.Next(100) == 0)
                    {
                        this.timeLeft = this.timeLeft - 10;
                    }
                }
                else
                {
                    this.alpha = (int)byte.MaxValue;
                    if (Main.goreLoaded[this.type])
                    {
                        float num1 = (float)((double)Main.goreTexture[this.type].Width * (double)this.scale * 0.800000011920929);
                        float x    = this.position.X;
                        float y    = this.position.Y;
                        float num2 = (float)Main.goreTexture[this.type].Width * this.scale;
                        float num3 = (float)Main.goreTexture[this.type].Height * this.scale;
                        int   Type = 176;
                        if (this.type >= 416 && this.type <= 420)
                        {
                            Type = 177;
                        }
                        if (this.type >= 421 && this.type <= 425)
                        {
                            Type = 178;
                        }
                        if (this.type >= 426 && this.type <= 430)
                        {
                            Type = 179;
                        }
                        for (int index1 = 0; (double)index1 < (double)num1; ++index1)
                        {
                            int index2 = Dust.NewDust(new Vector2(x, y), (int)num2, (int)num3, Type, 0.0f, 0.0f, 0, new Color(), 1f);
                            Main.dust[index2].noGravity = true;
                            Main.dust[index2].alpha     = 100;
                            Main.dust[index2].scale     = this.scale;
                        }
                    }
                }
            }
            else if (GoreID.Sets.SpecialAI[this.type] != 3 && GoreID.Sets.SpecialAI[this.type] != 1)
            {
                if (this.type >= 706 && this.type <= 717 || this.type == 943)
                {
                    if (this.type == 716)
                    {
                        float num1 = 0.6f;
                        float num2 = (int)this.frame != 0 ? ((int)this.frame != 1 ? ((int)this.frame != 2 ? ((int)this.frame != 3 ? ((int)this.frame != 4 ? ((int)this.frame != 5 ? ((int)this.frame != 6 ? ((int)this.frame > 9 ? ((int)this.frame != 10 ? ((int)this.frame != 11 ? ((int)this.frame != 12 ? ((int)this.frame != 13 ? ((int)this.frame != 14 ? 0.0f : num1 * 0.1f) : num1 * 0.2f) : num1 * 0.3f) : num1 * 0.4f) : num1 * 0.5f) : num1 * 0.5f) : num1 * 0.2f) : num1 * 0.4f) : num1 * 0.5f) : num1 * 0.4f) : num1 * 0.3f) : num1 * 0.2f) : num1 * 0.1f;
                        Lighting.AddLight(this.position + new Vector2(8f, 8f), 1f * num2, 0.5f * num2, 0.1f * num2);
                    }
                    Vector2 velocity = this.velocity;
                    this.velocity = Collision.TileCollision(this.position, this.velocity, 16, 14, false, false, 1);
                    if (this.velocity != velocity)
                    {
                        if ((int)this.frame < 10)
                        {
                            this.frame        = (byte)10;
                            this.frameCounter = (byte)0;
                            if (this.type != 716 && this.type != 717 && this.type != 943)
                            {
                                Main.PlaySound(39, (int)this.position.X + 8, (int)this.position.Y + 8, Main.rand.Next(2), 1f, 0.0f);
                            }
                        }
                    }
                    else if (Collision.WetCollision(this.position + this.velocity, 16, 14))
                    {
                        if ((int)this.frame < 10)
                        {
                            this.frame        = (byte)10;
                            this.frameCounter = (byte)0;
                            if (this.type != 716 && this.type != 717 && this.type != 943)
                            {
                                Main.PlaySound(39, (int)this.position.X + 8, (int)this.position.Y + 8, 2, 1f, 0.0f);
                            }
                            ((WaterShaderData)Filters.Scene["WaterDistortion"].GetShader()).QueueRipple(this.position + new Vector2(8f, 8f), 1f, RippleShape.Square, 0.0f);
                        }
                        int index1 = (int)((double)this.position.X + 8.0) / 16;
                        int index2 = (int)((double)this.position.Y + 14.0) / 16;
                        if (Main.tile[index1, index2] != null && (int)Main.tile[index1, index2].liquid > 0)
                        {
                            this.velocity   = this.velocity * 0.0f;
                            this.position.Y = (float)(index2 * 16 - (int)Main.tile[index1, index2].liquid / 16);
                        }
                    }
                }
                else if (this.sticky)
                {
                    int num1 = 32;
                    if (Main.goreLoaded[this.type])
                    {
                        num1 = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num1)
                        {
                            num1 = Main.goreTexture[this.type].Height;
                        }
                    }
                    if (flag)
                    {
                        num1 = 4;
                    }
                    int     num2     = (int)((double)num1 * 0.899999976158142);
                    Vector2 velocity = this.velocity;
                    this.velocity = Collision.TileCollision(this.position, this.velocity, (int)((double)num2 * (double)this.scale), (int)((double)num2 * (double)this.scale), false, false, 1);
                    if ((double)this.velocity.Y == 0.0)
                    {
                        if (flag)
                        {
                            this.velocity.X *= 0.94f;
                        }
                        else
                        {
                            this.velocity.X *= 0.97f;
                        }
                        if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                        {
                            this.velocity.X = 0.0f;
                        }
                    }
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - GoreID.Sets.DisappearSpeed[this.type];
                    }
                    else
                    {
                        this.alpha = this.alpha + GoreID.Sets.DisappearSpeedAlpha[this.type];
                    }
                }
                else
                {
                    this.alpha = this.alpha + 2 * GoreID.Sets.DisappearSpeedAlpha[this.type];
                }
            }
            if (this.type >= 907 && this.type <= 909)
            {
                int num1 = 32;
                if (Main.goreLoaded[this.type])
                {
                    num1 = Main.goreTexture[this.type].Width;
                    if (Main.goreTexture[this.type].Height < num1)
                    {
                        num1 = Main.goreTexture[this.type].Height;
                    }
                }
                int     num2    = (int)((double)num1 * 0.899999976158142);
                Vector4 vector4 = Collision.SlopeCollision(this.position, this.velocity, num2, num2, 0.0f, true);
                this.position.X = vector4.X;
                this.position.Y = vector4.Y;
                this.velocity.X = vector4.Z;
                this.velocity.Y = vector4.W;
            }
            if (GoreID.Sets.SpecialAI[this.type] == 1)
            {
                if ((double)this.velocity.Y < 0.0)
                {
                    Vector2 Velocity = new Vector2(this.velocity.X, 0.6f);
                    int     num1     = 32;
                    if (Main.goreLoaded[this.type])
                    {
                        num1 = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num1)
                        {
                            num1 = Main.goreTexture[this.type].Height;
                        }
                    }
                    int     num2    = (int)((double)num1 * 0.899999976158142);
                    Vector2 vector2 = Collision.TileCollision(this.position, Velocity, (int)((double)num2 * (double)this.scale), (int)((double)num2 * (double)this.scale), false, false, 1);
                    vector2.X *= 0.97f;
                    if ((double)vector2.X > -0.01 && (double)vector2.X < 0.01)
                    {
                        vector2.X = 0.0f;
                    }
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - 1;
                    }
                    else
                    {
                        this.alpha = this.alpha + 1;
                    }
                    this.velocity.X = vector2.X;
                }
                else
                {
                    this.velocity.Y += (float)Math.PI / 60f;
                    Vector2 Velocity = new Vector2(Vector2.UnitY.RotatedBy((double)this.velocity.Y, new Vector2()).X * 2f, Math.Abs(Vector2.UnitY.RotatedBy((double)this.velocity.Y, new Vector2()).Y) * 3f) * 2f;
                    int     num      = 32;
                    if (Main.goreLoaded[this.type])
                    {
                        num = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num)
                        {
                            num = Main.goreTexture[this.type].Height;
                        }
                    }
                    Vector2 vector2 = Velocity;
                    Vector2 v       = Collision.TileCollision(this.position, Velocity, (int)((double)num * (double)this.scale), (int)((double)num * (double)this.scale), false, false, 1);
                    if (v != vector2)
                    {
                        this.velocity.Y = -1f;
                    }
                    this.position = this.position + v;
                    this.rotation = v.ToRotation() + 3.141593f;
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - 1;
                    }
                    else
                    {
                        this.alpha = this.alpha + 1;
                    }
                }
            }
            else if (GoreID.Sets.SpecialAI[this.type] == 3)
            {
                if ((double)this.velocity.Y < 0.0)
                {
                    Vector2 Velocity = new Vector2(this.velocity.X, -0.2f);
                    int     num1     = 8;
                    if (Main.goreLoaded[this.type])
                    {
                        num1 = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num1)
                        {
                            num1 = Main.goreTexture[this.type].Height;
                        }
                    }
                    int     num2    = (int)((double)num1 * 0.899999976158142);
                    Vector2 vector2 = Collision.TileCollision(this.position, Velocity, (int)((double)num2 * (double)this.scale), (int)((double)num2 * (double)this.scale), false, false, 1);
                    vector2.X *= 0.94f;
                    if ((double)vector2.X > -0.01 && (double)vector2.X < 0.01)
                    {
                        vector2.X = 0.0f;
                    }
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - GoreID.Sets.DisappearSpeed[this.type];
                    }
                    else
                    {
                        this.alpha = this.alpha + GoreID.Sets.DisappearSpeedAlpha[this.type];
                    }
                    this.velocity.X = vector2.X;
                }
                else
                {
                    this.velocity.Y += (float)Math.PI / 180f;
                    Vector2 Velocity = new Vector2(Vector2.UnitY.RotatedBy((double)this.velocity.Y, new Vector2()).X * 1f, Math.Abs(Vector2.UnitY.RotatedBy((double)this.velocity.Y, new Vector2()).Y) * 1f);
                    int     num      = 8;
                    if (Main.goreLoaded[this.type])
                    {
                        num = Main.goreTexture[this.type].Width;
                        if (Main.goreTexture[this.type].Height < num)
                        {
                            num = Main.goreTexture[this.type].Height;
                        }
                    }
                    Vector2 vector2 = Velocity;
                    Vector2 v       = Collision.TileCollision(this.position, Velocity, (int)((double)num * (double)this.scale), (int)((double)num * (double)this.scale), false, false, 1);
                    if (v != vector2)
                    {
                        this.velocity.Y = -1f;
                    }
                    this.position = this.position + v;
                    this.rotation = v.ToRotation() + 1.570796f;
                    if (this.timeLeft > 0)
                    {
                        this.timeLeft = this.timeLeft - GoreID.Sets.DisappearSpeed[this.type];
                    }
                    else
                    {
                        this.alpha = this.alpha + GoreID.Sets.DisappearSpeedAlpha[this.type];
                    }
                }
            }
            else
            {
                this.position = this.position + this.velocity;
            }
            if (this.alpha >= (int)byte.MaxValue)
            {
                this.active = false;
            }
            if ((double)this.light <= 0.0)
            {
                return;
            }
            float R = this.light * this.scale;
            float G = this.light * this.scale;
            float B = this.light * this.scale;

            if (this.type == 16)
            {
                B *= 0.3f;
                G *= 0.8f;
            }
            else if (this.type == 17)
            {
                G *= 0.6f;
                R *= 0.3f;
            }
            if (Main.goreLoaded[this.type])
            {
                Lighting.AddLight((int)(((double)this.position.X + (double)Main.goreTexture[this.type].Width * (double)this.scale / 2.0) / 16.0), (int)(((double)this.position.Y + (double)Main.goreTexture[this.type].Height * (double)this.scale / 2.0) / 16.0), R, G, B);
            }
            else
            {
                Lighting.AddLight((int)(((double)this.position.X + 32.0 * (double)this.scale / 2.0) / 16.0), (int)(((double)this.position.Y + 32.0 * (double)this.scale / 2.0) / 16.0), R, G, B);
            }
        }
Beispiel #19
0
 public void Update()
 {
     if (Main.netMode == 2 || !active)
     {
         return;
     }
     if (type >= 276 && type <= 282)
     {
         velocity.X *= 0.98f;
         velocity.Y *= 0.98f;
         if (velocity.Y < scale)
         {
             velocity.Y += 0.05f;
         }
         if ((double)velocity.Y > 0.1)
         {
             if (velocity.X > 0f)
             {
                 rotation += 0.01f;
             }
             else
             {
                 rotation -= 0.01f;
             }
         }
     }
     if (type >= 570 && type <= 572)
     {
         scale -= 0.001f;
         if ((double)scale <= 0.01)
         {
             scale    = 0.01f;
             goreTime = 0;
         }
         sticky   = false;
         rotation = velocity.X * 0.1f;
     }
     else if (type >= 706 && type <= 717)
     {
         if ((double)position.Y < Main.worldSurface * 16.0 + 8.0)
         {
             alpha = 0;
         }
         else
         {
             alpha = 100;
         }
         int num = 4;
         frameCounter++;
         if (frame <= 4)
         {
             int num2 = (int)(position.X / 16f);
             int num3 = (int)(position.Y / 16f) - 1;
             if (WorldGen.InWorld(num2, num3) && !Main.tile[num2, num3].active())
             {
                 active = false;
             }
             if (frame == 0)
             {
                 num = 24 + Main.rand.Next(256);
             }
             if (frame == 1)
             {
                 num = 24 + Main.rand.Next(256);
             }
             if (frame == 2)
             {
                 num = 24 + Main.rand.Next(256);
             }
             if (frame == 3)
             {
                 num = 24 + Main.rand.Next(96);
             }
             if (frame == 5)
             {
                 num = 16 + Main.rand.Next(64);
             }
             if (type == 716)
             {
                 num *= 2;
             }
             if (type == 717)
             {
                 num *= 4;
             }
             if (frameCounter >= num)
             {
                 frameCounter = 0;
                 frame++;
                 if (frame == 5)
                 {
                     int num4 = NewGore(position, velocity, type);
                     Main.gore[num4].frame     = 9;
                     Main.gore[num4].velocity *= 0f;
                 }
             }
         }
         else if (frame <= 6)
         {
             num = 8;
             if (type == 716)
             {
                 num *= 2;
             }
             if (type == 717)
             {
                 num *= 3;
             }
             if (frameCounter >= num)
             {
                 frameCounter = 0;
                 frame++;
                 if (frame == 7)
                 {
                     active = false;
                 }
             }
         }
         else if (frame <= 9)
         {
             num = 6;
             if (type == 716)
             {
                 num         = (int)((double)num * 1.5);
                 velocity.Y += 0.175f;
             }
             else if (type == 717)
             {
                 num        *= 2;
                 velocity.Y += 0.15f;
             }
             else
             {
                 velocity.Y += 0.2f;
             }
             if ((double)velocity.Y < 0.5)
             {
                 velocity.Y = 0.5f;
             }
             if (velocity.Y > 12f)
             {
                 velocity.Y = 12f;
             }
             if (frameCounter >= num)
             {
                 frameCounter = 0;
                 frame++;
             }
             if (frame > 9)
             {
                 frame = 7;
             }
         }
         else
         {
             if (type == 716)
             {
                 num *= 2;
             }
             else if (type == 717)
             {
                 num *= 6;
             }
             velocity.Y += 0.1f;
             if (frameCounter >= num)
             {
                 frameCounter = 0;
                 frame++;
             }
             velocity *= 0f;
             if (frame > 14)
             {
                 active = false;
             }
         }
     }
     else if (type == 11 || type == 12 || type == 13 || type == 61 || type == 62 || type == 63 || type == 99 || type == 220 || type == 221 || type == 222 || (type >= 375 && type <= 377) || (type >= 435 && type <= 437) || (type >= 861 && type <= 862))
     {
         velocity.Y *= 0.98f;
         velocity.X *= 0.98f;
         scale      -= 0.007f;
         if ((double)scale < 0.1)
         {
             scale = 0.1f;
             alpha = 255;
         }
     }
     else if (type == 16 || type == 17)
     {
         velocity.Y *= 0.98f;
         velocity.X *= 0.98f;
         scale      -= 0.01f;
         if ((double)scale < 0.1)
         {
             scale = 0.1f;
             alpha = 255;
         }
     }
     else if (type == 331)
     {
         alpha      += 5;
         velocity.Y *= 0.95f;
         velocity.X *= 0.95f;
         rotation    = velocity.X * 0.1f;
     }
     else if (type != 860 && type != 892 && type != 893 && (type < 825 || type > 827) && (type < 411 || type > 430))
     {
         velocity.Y += 0.2f;
     }
     rotation += velocity.X * 0.1f;
     if (type >= 580 && type <= 582)
     {
         rotation    = 0f;
         velocity.X *= 0.95f;
     }
     if (type >= 825 && type <= 827)
     {
         if (timeLeft < 60)
         {
             alpha += Main.rand.Next(1, 7);
         }
         else if (alpha > 100)
         {
             alpha -= Main.rand.Next(1, 4);
         }
         if (alpha < 0)
         {
             alpha = 0;
         }
         if (alpha > 255)
         {
             timeLeft = 0;
         }
         velocity.X = (velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f;
         float num5 = 0f;
         if (velocity.X < 0f)
         {
             num5 = velocity.X * 0.2f;
         }
         velocity.Y = (velocity.Y * 50f + -0.35f + num5 + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f;
         rotation   = velocity.X * 0.6f;
         float num6 = -1f;
         if (Main.goreLoaded[type])
         {
             Rectangle rectangle = new Rectangle((int)position.X, (int)position.Y, (int)((float)Main.goreTexture[type].Width * scale), (int)((float)Main.goreTexture[type].Height * scale));
             for (int i = 0; i < 16; i++)
             {
                 if (Main.player[i].active && !Main.player[i].dead)
                 {
                     Rectangle value = new Rectangle((int)Main.player[i].position.X, (int)Main.player[i].position.Y, Main.player[i].width, Main.player[i].height);
                     if (rectangle.Intersects(value))
                     {
                         timeLeft = 0;
                         num6     = Main.player[i].velocity.Length();
                         break;
                     }
                 }
             }
         }
         if (timeLeft > 0)
         {
             if (Main.rand.Next(2) == 0)
             {
                 timeLeft--;
             }
             if (Main.rand.Next(50) == 0)
             {
                 timeLeft -= 5;
             }
             if (Main.rand.Next(100) == 0)
             {
                 timeLeft -= 10;
             }
         }
         else
         {
             alpha = 255;
             if (Main.goreLoaded[type] && num6 != -1f)
             {
                 float num7  = (float)Main.goreTexture[type].Width * scale * 0.8f;
                 float x     = position.X;
                 float y     = position.Y;
                 float num8  = (float)Main.goreTexture[type].Width * scale;
                 float num9  = (float)Main.goreTexture[type].Height * scale;
                 int   num10 = 31;
                 for (int j = 0; (float)j < num7; j++)
                 {
                     int num11 = Dust.NewDust(new Vector2(x, y), (int)num8, (int)num9, num10);
                     Main.dust[num11].velocity *= (1f + num6) / 3f;
                     Main.dust[num11].noGravity = true;
                     Main.dust[num11].alpha     = 100;
                     Main.dust[num11].scale     = scale;
                 }
             }
         }
     }
     if (type >= 411 && type <= 430)
     {
         alpha      = 50;
         velocity.X = (velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f;
         velocity.Y = (velocity.Y * 50f + -0.25f + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f;
         rotation   = velocity.X * 0.3f;
         if (Main.goreLoaded[type])
         {
             Rectangle rectangle2 = new Rectangle((int)position.X, (int)position.Y, (int)((float)Main.goreTexture[type].Width * scale), (int)((float)Main.goreTexture[type].Height * scale));
             for (int k = 0; k < 16; k++)
             {
                 if (Main.player[k].active && !Main.player[k].dead)
                 {
                     Rectangle value2 = new Rectangle((int)Main.player[k].position.X, (int)Main.player[k].position.Y, Main.player[k].width, Main.player[k].height);
                     if (rectangle2.Intersects(value2))
                     {
                         timeLeft = 0;
                     }
                 }
             }
             if (Collision.SolidCollision(position, (int)((float)Main.goreTexture[type].Width * scale), (int)((float)Main.goreTexture[type].Height * scale)))
             {
                 timeLeft = 0;
             }
         }
         if (timeLeft > 0)
         {
             if (Main.rand.Next(2) == 0)
             {
                 timeLeft--;
             }
             if (Main.rand.Next(50) == 0)
             {
                 timeLeft -= 5;
             }
             if (Main.rand.Next(100) == 0)
             {
                 timeLeft -= 10;
             }
         }
         else
         {
             alpha = 255;
             if (Main.goreLoaded[type])
             {
                 float num12 = (float)Main.goreTexture[type].Width * scale * 0.8f;
                 float x2    = position.X;
                 float y2    = position.Y;
                 float num13 = (float)Main.goreTexture[type].Width * scale;
                 float num14 = (float)Main.goreTexture[type].Height * scale;
                 int   num15 = 176;
                 if (type >= 416 && type <= 420)
                 {
                     num15 = 177;
                 }
                 if (type >= 421 && type <= 425)
                 {
                     num15 = 178;
                 }
                 if (type >= 426 && type <= 430)
                 {
                     num15 = 179;
                 }
                 for (int l = 0; (float)l < num12; l++)
                 {
                     int num16 = Dust.NewDust(new Vector2(x2, y2), (int)num13, (int)num14, num15);
                     Main.dust[num16].noGravity = true;
                     Main.dust[num16].alpha     = 100;
                     Main.dust[num16].scale     = scale;
                 }
             }
         }
     }
     else if (type != 860 && type != 892 && type != 893)
     {
         if (type >= 706 && type <= 717)
         {
             if (type == 716)
             {
                 float num17 = 1f;
                 float num18 = 1f;
                 float num19 = 1f;
                 float num20 = 0.6f;
                 num20 = ((frame == 0) ? (num20 * 0.1f) : ((frame == 1) ? (num20 * 0.2f) : ((frame == 2) ? (num20 * 0.3f) : ((frame == 3) ? (num20 * 0.4f) : ((frame == 4) ? (num20 * 0.5f) : ((frame == 5) ? (num20 * 0.4f) : ((frame == 6) ? (num20 * 0.2f) : ((frame <= 9) ? (num20 * 0.5f) : ((frame == 10) ? (num20 * 0.5f) : ((frame == 11) ? (num20 * 0.4f) : ((frame == 12) ? (num20 * 0.3f) : ((frame == 13) ? (num20 * 0.2f) : ((frame != 14) ? 0f : (num20 * 0.1f))))))))))))));
                 num17 = 1f * num20;
                 num18 = 0.5f * num20;
                 num19 = 0.1f * num20;
                 Lighting.AddLight(position + new Vector2(8f, 8f), num17, num18, num19);
             }
             Vector2 value3 = velocity;
             velocity = Collision.TileCollision(position, velocity, 16, 14);
             if (velocity != value3)
             {
                 if (frame < 10)
                 {
                     frame        = 10;
                     frameCounter = 0;
                     if (type != 716 && type != 717)
                     {
                         Main.PlaySound(39, (int)position.X + 8, (int)position.Y + 8, Main.rand.Next(2));
                     }
                 }
             }
             else if (Collision.WetCollision(position + velocity, 16, 14))
             {
                 if (frame < 10)
                 {
                     frame        = 10;
                     frameCounter = 0;
                     if (type != 716 && type != 717)
                     {
                         Main.PlaySound(39, (int)position.X + 8, (int)position.Y + 8, 2);
                     }
                 }
                 int num21 = (int)(position.X + 8f) / 16;
                 int num22 = (int)(position.Y + 14f) / 16;
                 if (Main.tile[num21, num22] != null && Main.tile[num21, num22].liquid > 0)
                 {
                     velocity  *= 0f;
                     position.Y = num22 * 16 - (int)Main.tile[num21, num22].liquid / 16;
                 }
             }
         }
         else if (sticky)
         {
             int num23 = 32;
             if (Main.goreLoaded[type])
             {
                 num23 = Main.goreTexture[type].Width;
                 if (Main.goreTexture[type].Height < num23)
                 {
                     num23 = Main.goreTexture[type].Height;
                 }
             }
             num23    = (int)((float)num23 * 0.9f);
             velocity = Collision.TileCollision(position, velocity, (int)((float)num23 * scale), (int)((float)num23 * scale));
             if (velocity.Y == 0f)
             {
                 velocity.X *= 0.97f;
                 if ((double)velocity.X > -0.01 && (double)velocity.X < 0.01)
                 {
                     velocity.X = 0f;
                 }
             }
             if (timeLeft > 0)
             {
                 timeLeft--;
             }
             else
             {
                 alpha++;
             }
         }
         else
         {
             alpha += 2;
         }
     }
     if (type == 860 || type == 892 || type == 893)
     {
         if (velocity.Y < 0f)
         {
             Vector2 vector = new Vector2(velocity.X, 0.6f);
             int     num24  = 32;
             if (Main.goreLoaded[type])
             {
                 num24 = Main.goreTexture[type].Width;
                 if (Main.goreTexture[type].Height < num24)
                 {
                     num24 = Main.goreTexture[type].Height;
                 }
             }
             num24     = (int)((float)num24 * 0.9f);
             vector    = Collision.TileCollision(position, vector, (int)((float)num24 * scale), (int)((float)num24 * scale));
             vector.X *= 0.97f;
             if ((double)vector.X > -0.01 && (double)vector.X < 0.01)
             {
                 vector.X = 0f;
             }
             if (timeLeft > 0)
             {
                 timeLeft--;
             }
             else
             {
                 alpha++;
             }
             velocity.X = vector.X;
         }
         else
         {
             velocity.Y += (float)Math.PI / 60f;
             Vector2 vector2 = new Vector2(Vector2.UnitY.RotatedBy(velocity.Y).X * 2f, Math.Abs(Vector2.UnitY.RotatedBy(velocity.Y).Y) * 3f);
             vector2 *= 2f;
             int num25 = 32;
             if (Main.goreLoaded[type])
             {
                 num25 = Main.goreTexture[type].Width;
                 if (Main.goreTexture[type].Height < num25)
                 {
                     num25 = Main.goreTexture[type].Height;
                 }
             }
             Vector2 value4 = vector2;
             vector2 = Collision.TileCollision(position, vector2, (int)((float)num25 * scale), (int)((float)num25 * scale));
             if (vector2 != value4)
             {
                 velocity.Y = -1f;
             }
             position += vector2;
             rotation  = vector2.ToRotation() + (float)Math.PI;
             if (timeLeft > 0)
             {
                 timeLeft--;
             }
             else
             {
                 alpha++;
             }
         }
     }
     else
     {
         position += velocity;
     }
     if (alpha >= 255)
     {
         active = false;
     }
     if (light > 0f)
     {
         float num26 = light * scale;
         float num27 = light * scale;
         float num28 = light * scale;
         if (type == 16)
         {
             num28 *= 0.3f;
             num27 *= 0.8f;
         }
         else if (type == 17)
         {
             num27 *= 0.6f;
             num26 *= 0.3f;
         }
         if (Main.goreLoaded[type])
         {
             Lighting.AddLight((int)((position.X + (float)Main.goreTexture[type].Width * scale / 2f) / 16f), (int)((position.Y + (float)Main.goreTexture[type].Height * scale / 2f) / 16f), num26, num27, num28);
         }
         else
         {
             Lighting.AddLight((int)((position.X + 32f * scale / 2f) / 16f), (int)((position.Y + 32f * scale / 2f) / 16f), num26, num27, num28);
         }
     }
 }