public void Update(int i)
{
if (this.launcherWait > 0)
{
this.launcherWait--;
}
this.maxFallSpeed = 10f;
this.gravity = Player.defaultGravity;
Player.jumpHeight = 15;
Player.jumpSpeed = 5.01f;
this.maxRunSpeed = 3f;
this.runAcceleration = 0.08f;
this.runSlowdown = 0.2f;
this.accRunSpeed = this.maxRunSpeed;
if (!this.mount.Active || !this.mount.Cart)
{
this.onWrongGround = false;
}
this.heldProj = -1;
if (this.PortalPhysicsEnabled)
{
this.maxFallSpeed = 30f;
}
if (this.wet)
{
if (this.honeyWet)
{
this.gravity = 0.1f;
this.maxFallSpeed = 3f;
}
else if (this.merman)
{
this.gravity = 0.3f;
this.maxFallSpeed = 7f;
}
else
{
this.gravity = 0.2f;
this.maxFallSpeed = 5f;
Player.jumpHeight = 30;
Player.jumpSpeed = 6.01f;
}
}
if (this.vortexDebuff)
{
this.gravity = 0f;
}
this.maxFallSpeed += 0.01f;
bool flag = false;
if (Main.myPlayer == i)
{
TileObject.objectPreview.Reset();
}
if (this.active)
{
if (this.ghostDmg > 0f)
{
this.ghostDmg -= 2.5f;
}
if (this.ghostDmg < 0f)
{
this.ghostDmg = 0f;
}
if (Main.expertMode)
{
if (this.lifeSteal < 70f)
{
this.lifeSteal += 0.5f;
}
if (this.lifeSteal > 70f)
{
this.lifeSteal = 70f;
}
}
else
{
if (this.lifeSteal < 80f)
{
this.lifeSteal += 0.6f;
}
if (this.lifeSteal > 80f)
{
this.lifeSteal = 80f;
}
}
if (this.mount.Active)
{
this.position.Y = this.position.Y + (float)this.height;
this.height = 42 + this.mount.HeightBoost;
this.position.Y = this.position.Y - (float)this.height;
if (this.mount.Type == 0)
{
int num = (int)(this.position.X + (float)(this.width / 2)) / 16;
int j = (int)(this.position.Y + (float)(this.height / 2) - 14f) / 16;
Lighting.AddLight(num, j, 0.5f, 0.2f, 0.05f);
Lighting.AddLight(num + this.direction, j, 0.5f, 0.2f, 0.05f);
Lighting.AddLight(num + this.direction * 2, j, 0.5f, 0.2f, 0.05f);
}
}
else
{
this.position.Y = this.position.Y + (float)this.height;
this.height = 42;
this.position.Y = this.position.Y - (float)this.height;
}
Main.numPlayers++;
this.outOfRange = false;
if (this.whoAmI != Main.myPlayer)
{
int num2 = (int)(this.position.X + (float)(this.width / 2)) / 16;
int num3 = (int)(this.position.Y + (float)(this.height / 2)) / 16;
if (!WorldGen.InWorld(num2, num3, 4))
{
flag = true;
}
else if (Main.tile[num2, num3] == null)
{
flag = true;
}
else if (Main.tile[num2 - 3, num3] == null)
{
flag = true;
}
else if (Main.tile[num2 + 3, num3] == null)
{
flag = true;
}
else if (Main.tile[num2, num3 - 3] == null)
{
flag = true;
}
else if (Main.tile[num2, num3 + 3] == null)
{
flag = true;
}
if (flag)
{
this.outOfRange = true;
this.numMinions = 0;
this.slotsMinions = 0f;
this.itemAnimation = 0;
this.PlayerFrame();
}
}
if (this.tankPet >= 0)
{
if (!this.tankPetReset)
{
this.tankPetReset = true;
}
else
{
this.tankPet = -1;
}
}
}
if (this.chatOverhead.timeLeft > 0)
{
this.chatOverhead.timeLeft = this.chatOverhead.timeLeft - 1;
}
if (!this.active || flag)
{
return;
}
this.miscCounter++;
if (this.miscCounter >= 300)
{
this.miscCounter = 0;
}
this.infernoCounter++;
if (this.infernoCounter >= 180)
{
this.infernoCounter = 0;
}
float num4 = (float)(Main.maxTilesX / 4200);
num4 *= num4;
float num5 = (float)((double)(this.position.Y / 16f - (60f + 10f * num4)) / (Main.worldSurface / 6.0));
if ((double)num5 < 0.25)
{
num5 = 0.25f;
}
if (num5 > 1f)
{
num5 = 1f;
}
this.gravity *= num5;
this.maxRegenDelay = (1f - (float)this.statMana / (float)this.statManaMax2) * 60f * 4f + 45f;
this.maxRegenDelay *= 0.7f;
this.UpdateSocialShadow();
this.UpdateTeleportVisuals();
this.whoAmI = i;
if (this.whoAmI == Main.myPlayer)
{
this.TryPortalJumping();
}
if (this.runSoundDelay > 0)
{
this.runSoundDelay--;
}
if (this.attackCD > 0)
{
this.attackCD--;
}
if (this.itemAnimation == 0)
{
this.attackCD = 0;
}
if (this.potionDelay > 0)
{
this.potionDelay--;
}
if (i == Main.myPlayer)
{
if (this.trashItem.itemId >= 1522 && this.trashItem.itemId <= 1527)
{
this.trashItem.SetDefaults(0, false);
}
this.UpdateBiomes();
this.UpdateMinionTarget();
}
if (this.ghost)
{
this.Ghost();
return;
}
if (this.dead)
{
this.UpdateDead();
return;
}
if (i == Main.myPlayer)
{
this.controlUp = false;
this.controlLeft = false;
this.controlDown = false;
this.controlRight = false;
this.controlJump = false;
this.controlUseItem = false;
this.controlUseTile = false;
this.controlThrow = false;
this.controlInv = false;
this.controlHook = false;
this.controlTorch = false;
this.controlSmart = false;
this.controlMount = false;
this.mapStyle = false;
this.mapAlphaDown = false;
this.mapAlphaUp = false;
this.mapFullScreen = false;
this.mapZoomIn = false;
this.mapZoomOut = false;
bool flag2 = false;
bool flag3 = false;
Keys[] pressedKeys = Main.keyState.GetPressedKeys();
for (int k = 0; k < pressedKeys.Length; k++)
{
if (pressedKeys[k] == Keys.LeftShift || pressedKeys[k] == Keys.RightShift)
{
flag2 = true;
}
else if (pressedKeys[k] == Keys.LeftAlt || pressedKeys[k] == Keys.RightAlt)
{
flag3 = true;
}
}
if (Main.hasFocus)
{
if (!Main.chatMode && !Main.editSign && !Main.editChest && !Main.blockInput)
{
if (Main.blockKey != Keys.None)
{
bool flag4 = false;
for (int l = 0; l < pressedKeys.Length; l++)
{
if (pressedKeys[l] == Main.blockKey)
{
pressedKeys[l] = Keys.None;
flag4 = true;
}
}
if (!flag4)
{
Main.blockKey = Keys.None;
}
}
bool flag5 = false;
bool flag6 = false;
for (int m = 0; m < pressedKeys.Length; m++)
{
string a = string.Concat(pressedKeys[m]);
if (pressedKeys[m] != Keys.Tab || ((!flag2) && !flag3))
{
if (a == Main.cUp)
{
this.controlUp = true;
}
if (a == Main.cLeft)
{
this.controlLeft = true;
}
if (a == Main.cDown)
{
this.controlDown = true;
}
if (a == Main.cRight)
{
this.controlRight = true;
}
if (a == Main.cJump)
{
this.controlJump = true;
}
if (a == Main.cThrowItem)
{
this.controlThrow = true;
}
if (a == Main.cInv)
{
this.controlInv = true;
}
if (a == Main.cBuff)
{
this.QuickBuff();
}
if (a == Main.cHeal)
{
flag6 = true;
}
if (a == Main.cMana)
{
flag5 = true;
}
if (a == Main.cHook)
{
this.controlHook = true;
}
if (a == Main.cTorch)
{
this.controlTorch = true;
}
if (a == Main.cSmart)
{
this.controlSmart = true;
}
if (a == Main.cMount)
{
this.controlMount = true;
}
if (Main.mapEnabled)
{
if (a == Main.cMapZoomIn)
{
this.mapZoomIn = true;
}
if (a == Main.cMapZoomOut)
{
this.mapZoomOut = true;
}
if (a == Main.cMapAlphaUp)
{
this.mapAlphaUp = true;
}
if (a == Main.cMapAlphaDown)
{
this.mapAlphaDown = true;
}
if (a == Main.cMapFull)
{
this.mapFullScreen = true;
}
if (a == Main.cMapStyle)
{
this.mapStyle = true;
}
}
}
}
if (Main.gamePad)
{
GamePadState state = GamePad.GetState(PlayerIndex.One);
if (state.DPad.Up == ButtonState.Pressed)
{
this.controlUp = true;
}
if (state.DPad.Down == ButtonState.Pressed)
{
this.controlDown = true;
}
if (state.DPad.Left == ButtonState.Pressed)
{
this.controlLeft = true;
}
if (state.DPad.Right == ButtonState.Pressed)
{
this.controlRight = true;
}
if (state.Triggers.Left > 0f)
{
this.controlJump = true;
}
if (state.Triggers.Right > 0f)
{
this.controlUseItem = true;
}
Main.mouseX = (int)((float)(Main.screenWidth / 2) + state.ThumbSticks.Right.X * (float)Player.tileRangeX * 16f);
Main.mouseY = (int)((float)(Main.screenHeight / 2) - state.ThumbSticks.Right.Y * (float)Player.tileRangeX * 16f);
if (state.ThumbSticks.Right.X == 0f)
{
Main.mouseX = Main.screenWidth / 2 + this.direction * 2;
}
}
if (Main.mapFullscreen)
{
if (this.controlUp)
{
Main.mapFullscreenPos.Y = Main.mapFullscreenPos.Y - 1f * (16f / Main.mapFullscreenScale);
}
if (this.controlDown)
{
Main.mapFullscreenPos.Y = Main.mapFullscreenPos.Y + 1f * (16f / Main.mapFullscreenScale);
}
if (this.controlLeft)
{
Main.mapFullscreenPos.X = Main.mapFullscreenPos.X - 1f * (16f / Main.mapFullscreenScale);
}
if (this.controlRight)
{
Main.mapFullscreenPos.X = Main.mapFullscreenPos.X + 1f * (16f / Main.mapFullscreenScale);
}
this.controlUp = false;
this.controlLeft = false;
this.controlDown = false;
this.controlRight = false;
this.controlJump = false;
this.controlUseItem = false;
this.controlUseTile = false;
this.controlThrow = false;
this.controlHook = false;
this.controlTorch = false;
this.controlSmart = false;
this.controlMount = false;
}
if (flag6)
{
if (this.releaseQuickHeal)
{
this.QuickHeal();
}
this.releaseQuickHeal = false;
}
else
{
this.releaseQuickHeal = true;
}
if (flag5)
{
if (this.releaseQuickMana)
{
this.QuickMana();
}
this.releaseQuickMana = false;
}
else
{
this.releaseQuickMana = true;
}
if (this.controlLeft && this.controlRight)
{
this.controlLeft = false;
this.controlRight = false;
}
if (Main.cSmartToggle)
{
if (this.controlSmart && this.releaseSmart)
{
Main.PlaySound(12, -1, -1, 1);
Main.smartDigEnabled = !Main.smartDigEnabled;
}
}
else
{
if (Main.smartDigEnabled != this.controlSmart)
{
Main.PlaySound(12, -1, -1, 1);
}
Main.smartDigEnabled = this.controlSmart;
}
if (this.controlSmart)
{
this.releaseSmart = false;
}
else
{
this.releaseSmart = true;
}
if (this.controlMount)
{
if (this.releaseMount)
{
this.QuickMount();
}
this.releaseMount = false;
}
else
{
this.releaseMount = true;
}
if (Main.mapFullscreen)
{
if (this.mapZoomIn)
{
Main.mapFullscreenScale *= 1.05f;
}
if (this.mapZoomOut)
{
Main.mapFullscreenScale *= 0.95f;
}
}
else
{
if (Main.mapStyle == 1)
{
if (this.mapZoomIn)
{
Main.mapMinimapScale *= 1.025f;
}
if (this.mapZoomOut)
{
Main.mapMinimapScale *= 0.975f;
}
if (this.mapAlphaUp)
{
Main.mapMinimapAlpha += 0.015f;
}
if (this.mapAlphaDown)
{
Main.mapMinimapAlpha -= 0.015f;
}
}
else if (Main.mapStyle == 2)
{
if (this.mapZoomIn)
{
Main.mapOverlayScale *= 1.05f;
}
if (this.mapZoomOut)
{
Main.mapOverlayScale *= 0.95f;
}
if (this.mapAlphaUp)
{
Main.mapOverlayAlpha += 0.015f;
}
if (this.mapAlphaDown)
{
Main.mapOverlayAlpha -= 0.015f;
}
}
if (this.mapStyle)
{
if (this.releaseMapStyle)
{
Main.PlaySound(12, -1, -1, 1);
Main.mapStyle++;
if (Main.mapStyle > 2)
{
Main.mapStyle = 0;
}
}
this.releaseMapStyle = false;
}
else
{
this.releaseMapStyle = true;
}
}
if (this.mapFullScreen)
{
if (this.releaseMapFullscreen)
{
if (Main.mapFullscreen)
{
Main.PlaySound(11, -1, -1, 1);
Main.mapFullscreen = false;
}
else
{
Main.playerInventory = false;
this.talkNPC = -1;
Main.npcChatCornerItem = 0;
Main.PlaySound(10, -1, -1, 1);
float mapFullscreenScale = 2.5f;
Main.mapFullscreenScale = mapFullscreenScale;
Main.mapFullscreen = true;
Main.resetMapFull = true;
Main.buffString = string.Empty;
}
}
this.releaseMapFullscreen = false;
}
else
{
this.releaseMapFullscreen = true;
}
}
if (this.confused)
{
bool flag7 = this.controlLeft;
bool flag8 = this.controlUp;
this.controlLeft = this.controlRight;
this.controlRight = flag7;
this.controlUp = this.controlRight;
this.controlDown = flag8;
}
else if (this.cartFlip)
{
if (this.controlRight || this.controlLeft)
{
bool flag9 = this.controlLeft;
this.controlLeft = this.controlRight;
this.controlRight = flag9;
}
else
{
this.cartFlip = false;
}
}
for (int n = 0; n < this.doubleTapCardinalTimer.Length; n++)
{
this.doubleTapCardinalTimer[n]--;
if (this.doubleTapCardinalTimer[n] < 0)
{
this.doubleTapCardinalTimer[n] = 0;
}
}
for (int num6 = 0; num6 < 4; num6++)
{
bool flag10 = false;
bool flag11 = false;
switch (num6)
{
case 0:
flag10 = (this.controlDown && this.releaseDown);
flag11 = this.controlDown;
break;
case 1:
flag10 = (this.controlUp && this.releaseUp);
flag11 = this.controlUp;
break;
case 2:
flag10 = (this.controlRight && this.releaseRight);
flag11 = this.controlRight;
break;
case 3:
flag10 = (this.controlLeft && this.releaseLeft);
flag11 = this.controlLeft;
break;
}
if (flag10)
{
if (this.doubleTapCardinalTimer[num6] > 0)
{
this.KeyDoubleTap(num6);
}
else
{
this.doubleTapCardinalTimer[num6] = 15;
}
}
if (flag11)
{
this.holdDownCardinalTimer[num6]++;
this.KeyHoldDown(num6, this.holdDownCardinalTimer[num6]);
}
else
{
this.holdDownCardinalTimer[num6] = 0;
}
}
if (Main.mouseLeft)
{
if (!Main.blockMouse && !this.mouseInterface)
{
this.controlUseItem = true;
}
}
else
{
Main.blockMouse = false;
}
if (Main.mouseRight && !this.mouseInterface && !Main.blockMouse)
{
this.controlUseTile = true;
}
if (this.controlInv)
{
if (this.releaseInventory)
{
if (Main.mapFullscreen)
{
Main.mapFullscreen = false;
this.releaseInventory = false;
Main.PlaySound(11, -1, -1, 1);
}
else
{
this.ToggleInv();
}
}
this.releaseInventory = false;
}
else
{
this.releaseInventory = true;
}
if (this.delayUseItem)
{
if (!this.controlUseItem)
{
this.delayUseItem = false;
}
this.controlUseItem = false;
}
if (this.itemAnimation == 0 && this.itemTime == 0)
{
this.dropItemCheck();
int num7 = this.selectedItem;
bool flag12 = false;
if (!Main.chatMode && this.selectedItem != 58 && !Main.editSign && !Main.editChest)
{
if (Main.keyState.IsKeyDown(Keys.D1))
{
this.selectedItem = 0;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D2))
{
this.selectedItem = 1;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D3))
{
this.selectedItem = 2;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D4))
{
this.selectedItem = 3;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D5))
{
this.selectedItem = 4;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D6))
{
this.selectedItem = 5;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D7))
{
this.selectedItem = 6;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D8))
{
this.selectedItem = 7;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D9))
{
this.selectedItem = 8;
flag12 = true;
}
if (Main.keyState.IsKeyDown(Keys.D0))
{
this.selectedItem = 9;
flag12 = true;
}
if (this.controlTorch && flag12)
{
if (this.selectedItem != this.nonTorch)
{
Main.PlaySound(12, -1, -1, 1);
}
this.nonTorch = this.selectedItem;
this.selectedItem = num7;
flag12 = false;
}
}
bool flag13 = Main.hairWindow;
if (flag13)
{
int y = Main.screenHeight / 2 + 60;
int x = Main.screenWidth / 2 - Main.hairStyleBackTexture.Width / 2;
flag13 = new Rectangle(x, y, Main.hairStyleBackTexture.Width, Main.hairStyleBackTexture.Height).Contains(Main.MouseScreen.ToPoint());
}
if (flag12 && CaptureManager.Instance.Active)
{
CaptureManager.Instance.Active = false;
}
if (num7 != this.selectedItem)
{
Main.PlaySound(12, -1, -1, 1);
}
if (Main.mapFullscreen)
{
int num8 = (Main.mouseState.ScrollWheelValue - Main.oldMouseWheel) / 120;
Main.mapFullscreenScale *= 1f + (float)num8 * 0.3f;
}
else if (CaptureManager.Instance.Active)
{
CaptureManager.Instance.Scrolling();
}
else if (!flag13)
{
if (!Main.playerInventory)
{
int num9;
for (num9 = (Main.mouseState.ScrollWheelValue - Main.oldMouseWheel) / 120; num9 > 9; num9 -= 10)
{
}
while (num9 < 0)
{
num9 += 10;
}
this.selectedItem -= num9;
if (num9 != 0)
{
Main.PlaySound(12, -1, -1, 1);
}
if (this.changeItem >= 0)
{
if (this.selectedItem != this.changeItem)
{
Main.PlaySound(12, -1, -1, 1);
}
this.selectedItem = this.changeItem;
this.changeItem = -1;
}
if (this.itemAnimation == 0)
{
while (this.selectedItem > 9)
{
this.selectedItem -= 10;
}
while (this.selectedItem < 0)
{
this.selectedItem += 10;
}
}
}
else
{
int num10 = (Main.mouseState.ScrollWheelValue - Main.oldMouseWheel) / 120;
bool flag14 = true;
if (Main.recBigList)
{
int num11 = 42;
int num12 = 340;
int num13 = 310;
int num14 = (Main.screenWidth - num13 - 280) / num11;
int num15 = (Main.screenHeight - num12 - 20) / num11;
if (new Rectangle(num13, num12, num14 * num11, num15 * num11).Contains(Main.MouseScreen.ToPoint()))
{
num10 *= -1;
int num16 = Math.Sign(num10);
while (num10 != 0)
{
if (num10 < 0)
{
Main.recStart -= num14;
if (Main.recStart < 0)
{
Main.recStart = 0;
}
}
else
{
Main.recStart += num14;
if (Main.recStart > Main.numAvailableRecipes - num14)
{
Main.recStart = Main.numAvailableRecipes - num14;
}
}
num10 -= num16;
}
}
}
if (flag14)
{
Main.focusRecipe += num10;
if (Main.focusRecipe > Main.numAvailableRecipes - 1)
{
Main.focusRecipe = Main.numAvailableRecipes - 1;
}
if (Main.focusRecipe < 0)
{
Main.focusRecipe = 0;
}
}
}
}
}
}
if (this.selectedItem == 58)
{
this.nonTorch = -1;
}
else
{
this.SmartitemLookup();
}
if (this.stoned != this.lastStoned)
{
if (this.whoAmI == Main.myPlayer && this.stoned)
{
int damage = (int)(20.0 * (double)Main.damageMultiplier);
this.Hurt(damage, 0, false, false, Lang.deathMsg(-1, -1, -1, 4), false);
}
Main.PlaySound(0, (int)this.position.X, (int)this.position.Y, 1);
for (int num17 = 0; num17 < 20; num17++)
{
int num18 = Dust.NewDust(this.position, this.width, this.height, 1, 0f, 0f, 0, default(Color), 1f);
if (Main.rand.Next(2) == 0)
{
Main.dust[num18].noGravity = true;
}
}
}
this.lastStoned = this.stoned;
if (this.frozen || this.webbed || this.stoned)
{
this.controlJump = false;
this.controlDown = false;
this.controlLeft = false;
this.controlRight = false;
this.controlUp = false;
this.controlUseItem = false;
this.controlUseTile = false;
this.controlThrow = false;
this.gravDir = 1f;
}
if (!this.controlThrow)
{
this.releaseThrow = true;
}
else
{
this.releaseThrow = false;
}
if (Main.netMode == 1)
{
bool flag15 = false;
if (this.controlUp != Main.clientPlayer.controlUp)
{
flag15 = true;
}
if (this.controlDown != Main.clientPlayer.controlDown)
{
flag15 = true;
}
if (this.controlLeft != Main.clientPlayer.controlLeft)
{
flag15 = true;
}
if (this.controlRight != Main.clientPlayer.controlRight)
{
flag15 = true;
}
if (this.controlJump != Main.clientPlayer.controlJump)
{
flag15 = true;
}
if (this.controlUseItem != Main.clientPlayer.controlUseItem)
{
flag15 = true;
}
if (this.selectedItem != Main.clientPlayer.selectedItem)
{
flag15 = true;
}
if (flag15)
{
NetMessage.SendData(13, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0, 0, 0);
}
}
if (Main.playerInventory)
{
this.AdjTiles();
}
if (this.chest != -1)
{
if (this.chest != -2)
{
this.flyingPigChest = -1;
}
if (this.flyingPigChest >= 0)
{
if (!Main.projectile[this.flyingPigChest].active || Main.projectile[this.flyingPigChest].type != 525)
{
Main.PlaySound(2, -1, -1, 59);
this.chest = -1;
Recipe.FindRecipes();
}
else
{
int num19 = (int)(((double)this.position.X + (double)this.width * 0.5) / 16.0);
int num20 = (int)(((double)this.position.Y + (double)this.height * 0.5) / 16.0);
this.chestX = (int)Main.projectile[this.flyingPigChest].Center.X / 16;
this.chestY = (int)Main.projectile[this.flyingPigChest].Center.Y / 16;
if (num19 < this.chestX - Player.tileRangeX || num19 > this.chestX + Player.tileRangeX + 1 || num20 < this.chestY - Player.tileRangeY || num20 > this.chestY + Player.tileRangeY + 1)
{
if (this.chest != -1)
{
Main.PlaySound(2, -1, -1, 59);
}
this.chest = -1;
Recipe.FindRecipes();
}
}
}
else
{
int num21 = (int)(((double)this.position.X + (double)this.width * 0.5) / 16.0);
int num22 = (int)(((double)this.position.Y + (double)this.height * 0.5) / 16.0);
if (num21 < this.chestX - Player.tileRangeX || num21 > this.chestX + Player.tileRangeX + 1 || num22 < this.chestY - Player.tileRangeY || num22 > this.chestY + Player.tileRangeY + 1)
{
if (this.chest != -1)
{
Main.PlaySound(11, -1, -1, 1);
}
this.chest = -1;
Recipe.FindRecipes();
}
else if (!Main.tile[this.chestX, this.chestY].active())
{
Main.PlaySound(11, -1, -1, 1);
this.chest = -1;
Recipe.FindRecipes();
}
}
}
else
{
this.flyingPigChest = -1;
}
if (this.velocity.Y <= 0f)
{
this.fallStart2 = (int)(this.position.Y / 16f);
}
if (this.velocity.Y == 0f)
{
int num23 = 25;
num23 += this.extraFall;
int num24 = (int)(this.position.Y / 16f) - this.fallStart;
if (this.mount.CanFly)
{
num24 = 0;
}
if (this.mount.Cart && Minecart.OnTrack(this.position, this.width, this.height))
{
num24 = 0;
}
if (this.mount.Type == 1)
{
num24 = 0;
}
this.mount.FatigueRecovery();
bool flag16 = false;
for (int num25 = 3; num25 < 10; num25++)
{
if (this.armor[num25].stack > 0 && this.armor[num25].wingSlot > -1)
{
flag16 = true;
}
}
if (this.stoned)
{
int num26 = (int)(((float)num24 * this.gravDir - 2f) * 20f);
if (num26 > 0)
{
this.Hurt(num26, 0, false, false, Lang.deathMsg(-1, -1, -1, 4), false);
this.immune = false;
}
}
else if (((this.gravDir == 1f && num24 > num23) || (this.gravDir == -1f && num24 < -num23)) && !this.noFallDmg && !flag16)
{
this.immune = false;
int num27 = (int)((float)num24 * this.gravDir - (float)num23) * 10;
if (this.mount.Active)
{
num27 = (int)((float)num27 * this.mount.FallDamage);
}
this.Hurt(num27, 0, false, false, Lang.deathMsg(-1, -1, -1, 0), false);
if (!this.dead && this.statLife <= this.statLifeMax2 / 10)
{
AchievementsHelper.HandleSpecialEvent(this, 8);
}
}
this.fallStart = (int)(this.position.Y / 16f);
}
if (this.jump > 0 || this.rocketDelay > 0 || this.wet || this.slowFall || (double)num5 < 0.8 || this.tongued)
{
this.fallStart = (int)(this.position.Y / 16f);
}
}
if (Main.netMode != 1)
{
if (this.chest == -1 && this.lastChest >= 0 && Main.chest[this.lastChest] != null && Main.chest[this.lastChest] != null)
{
int x2 = Main.chest[this.lastChest].x;
int y2 = Main.chest[this.lastChest].y;
NPC.BigMimicSummonCheck(x2, y2);
Chest.MagicChest(Chest.FindChest(x2, y2));
}
this.lastChest = this.chest;
}
if (this.mouseInterface)
{
this.delayUseItem = true;
}
Player.tileTargetX = (int)(((float)Main.mouseX + Main.screenPosition.X) / 16f);
Player.tileTargetY = (int)(((float)Main.mouseY + Main.screenPosition.Y) / 16f);
if (this.gravDir == -1f)
{
Player.tileTargetY = (int)((Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY) / 16f);
}
if (Player.tileTargetX >= Main.maxTilesX - 5)
{
Player.tileTargetX = Main.maxTilesX - 5;
}
if (Player.tileTargetY >= Main.maxTilesY - 5)
{
Player.tileTargetY = Main.maxTilesY - 5;
}
if (Player.tileTargetX < 5)
{
Player.tileTargetX = 5;
}
if (Player.tileTargetY < 5)
{
Player.tileTargetY = 5;
}
if (Main.tile[Player.tileTargetX - 1, Player.tileTargetY] == null)
{
Main.tile[Player.tileTargetX - 1, Player.tileTargetY] = new Tile();
}
if (Main.tile[Player.tileTargetX + 1, Player.tileTargetY] == null)
{
Main.tile[Player.tileTargetX + 1, Player.tileTargetY] = new Tile();
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY] == null)
{
Main.tile[Player.tileTargetX, Player.tileTargetY] = new Tile();
}
if (!Main.tile[Player.tileTargetX, Player.tileTargetY].active())
{
if (Main.tile[Player.tileTargetX - 1, Player.tileTargetY].active() && Main.tile[Player.tileTargetX - 1, Player.tileTargetY].type == 323)
{
int frameY = (int)Main.tile[Player.tileTargetX - 1, Player.tileTargetY].frameY;
if (frameY < -4)
{
Player.tileTargetX++;
}
if (frameY > 4)
{
Player.tileTargetX--;
}
}
else if (Main.tile[Player.tileTargetX + 1, Player.tileTargetY].active() && Main.tile[Player.tileTargetX + 1, Player.tileTargetY].type == 323)
{
int frameY2 = (int)Main.tile[Player.tileTargetX + 1, Player.tileTargetY].frameY;
if (frameY2 < -4)
{
Player.tileTargetX++;
}
if (frameY2 > 4)
{
Player.tileTargetX--;
}
}
}
this.SmartCursorLookup();
this.UpdateImmunity();
if (this.petalTimer > 0)
{
this.petalTimer--;
}
if (this.shadowDodgeTimer > 0)
{
this.shadowDodgeTimer--;
}
if (this.jump > 0 || this.velocity.Y != 0f)
{
this.slippy = false;
this.slippy2 = false;
this.powerrun = false;
this.sticky = false;
}
this.potionDelayTime = Item.potionDelay;
this.restorationDelayTime = Item.restorationDelay;
if (this.pStone)
{
this.potionDelayTime = (int)((double)this.potionDelayTime * 0.75);
this.restorationDelayTime = (int)((double)this.restorationDelayTime * 0.75);
}
if (this.yoraiz0rEye > 0)
{
this.Yoraiz0rEye();
}
this.ResetEffects();
this.UpdateDyes(i);
this.meleeCrit += this.inventory[this.selectedItem].crit;
this.magicCrit += this.inventory[this.selectedItem].crit;
this.rangedCrit += this.inventory[this.selectedItem].crit;
this.thrownCrit += this.inventory[this.selectedItem].crit;
if (this.whoAmI == Main.myPlayer)
{
Main.musicBox2 = -1;
if (Main.waterCandles > 0)
{
this.AddBuff(86, 2, false);
}
if (Main.peaceCandles > 0)
{
this.AddBuff(157, 2, false);
}
if (Main.campfire)
{
this.AddBuff(87, 2, false);
}
if (Main.starInBottle)
{
this.AddBuff(158, 2, false);
}
if (Main.heartLantern)
{
this.AddBuff(89, 2, false);
}
if (Main.sunflower)
{
this.AddBuff(146, 2, false);
}
if (this.hasBanner)
{
this.AddBuff(147, 2, false);
}
}
for (int num28 = 0; num28 < 191; num28++)
{
this.buffImmune[num28] = false;
}
this.UpdateBuffs(i);
if (this.whoAmI == Main.myPlayer)
{
if (!this.onFire && !this.poisoned)
{
this.trapDebuffSource = false;
}
this.UpdatePet(i);
this.UpdatePetLight(i);
}
if (this.accMerman && this.wet && !this.lavaWet && (!this.mount.Active || this.mount.Type != 3))
{
this.releaseJump = true;
this.wings = 0;
this.merman = true;
this.accFlipper = true;
this.AddBuff(34, 2, true);
}
else
{
this.merman = false;
}
this.accMerman = false;
if (this.wolfAcc && !this.merman && !Main.dayTime && !this.wereWolf)
{
this.AddBuff(28, 60, true);
}
this.wolfAcc = false;
if (this.whoAmI == Main.myPlayer)
{
for (int num29 = 0; num29 < 22; num29++)
{
if (this.buffType[num29] > 0 && this.buffTime[num29] <= 0)
{
this.DelBuff(num29);
}
}
}
this.beetleDefense = false;
this.beetleOffense = false;
this.doubleJumpCloud = false;
this.setSolar = false;
this.head = this.armor[0].headSlot;
this.body = this.armor[1].bodySlot;
this.legs = this.armor[2].legSlot;
this.handon = -1;
this.handoff = -1;
this.back = -1;
this.front = -1;
this.shoe = -1;
this.waist = -1;
this.shield = -1;
this.neck = -1;
this.face = -1;
this.balloon = -1;
if (this.MountFishronSpecialCounter > 0f)
{
this.MountFishronSpecialCounter -= 1f;
}
if (this._portalPhysicsTime > 0)
{
this._portalPhysicsTime--;
}
this.UpdateEquips(i);
if (this.inventory[this.selectedItem].itemId == 3384)
{
this._portalPhysicsTime = 30;
}
if (this.mount.Active)
{
this.mount.UpdateEffects(this);
}
this.gemCount++;
if (this.gemCount >= 10)
{
this.gem = -1;
this.gemCount = 0;
for (int num30 = 0; num30 <= 58; num30++)
{
if (this.inventory[num30].itemId == 0 || this.inventory[num30].stack == 0)
{
this.inventory[num30].itemId = 0;
this.inventory[num30].stack = 0;
this.inventory[num30].name = "";
this.inventory[num30].netID = 0;
}
if (this.inventory[num30].itemId >= 1522 && this.inventory[num30].itemId <= 1527)
{
this.gem = this.inventory[num30].itemId - 1522;
}
}
}
if (!this.vortexStealthActive)
{
float num31 = 0f;
float num32 = 0f;
float num33 = 0f;
int num34 = this.head;
if (num34 <= 171)
{
if (num34 != 11)
{
switch (num34)
{
case 169:
num31 = 0f;
num32 = 0.36f;
num33 = 0.4f;
break;
case 170:
num31 = 0.4f;
num32 = 0.16f;
num33 = 0.36f;
break;
case 171:
num31 = 0.5f;
num32 = 0.25f;
num33 = 0.05f;
break;
}
}
else
{
num31 = 0.92f;
num32 = 0.8f;
num33 = 0.65f;
}
}
else if (num34 != 178)
{
if (num34 == 189)
{
num31 = 0.9f;
num32 = 0.9f;
num33 = 0.7f;
}
}
else
{
num31 = 0.1f;
num32 = 0.2f;
num33 = 0.3f;
}
float num35 = 0f;
float num36 = 0f;
float num37 = 0f;
num34 = this.body;
switch (num34)
{
case 175:
num35 = 0f;
num36 = 0.36f;
num37 = 0.4f;
break;
case 176:
num35 = 0.4f;
num36 = 0.16f;
num37 = 0.36f;
break;
case 177:
num35 = 0.5f;
num36 = 0.25f;
num37 = 0.05f;
break;
default:
if (num34 == 190)
{
num31 = 0.9f;
num32 = 0.9f;
num33 = 0.7f;
}
break;
}
float num38 = 0f;
float num39 = 0f;
float num40 = 0f;
num34 = this.legs;
switch (num34)
{
case 110:
num38 = 0f;
num39 = 0.36f;
num40 = 0.4f;
break;
case 111:
num38 = 0.4f;
num39 = 0.16f;
num40 = 0.36f;
break;
case 112:
num38 = 0.5f;
num39 = 0.25f;
num40 = 0.05f;
break;
default:
if (num34 == 130)
{
num31 = 0.9f;
num32 = 0.9f;
num33 = 0.7f;
}
break;
}
if (num31 != 0f || num32 != 0f || num33 != 0f)
{
float num41 = 1f;
if (num31 == num35 && num32 == num36 && num33 == num37)
{
num41 += 0.5f;
}
if (num31 == num38 && num32 == num39 && num33 == num40)
{
num41 += 0.5f;
}
Vector2 spinningpoint = new Vector2((float)(this.width / 2 + 8 * this.direction), 2f);
if (this.fullRotation != 0f)
{
spinningpoint = spinningpoint.RotatedBy((double)this.fullRotation, this.fullRotationOrigin);
}
int i2 = (int)(this.position.X + spinningpoint.X) / 16;
int j2 = (int)(this.position.Y + spinningpoint.Y) / 16;
Lighting.AddLight(i2, j2, num31 * num41, num32 * num41, num33 * num41);
}
if (num35 != 0f || num36 != 0f || num37 != 0f)
{
float num42 = 1f;
if (num35 == num31 && num36 == num32 && num37 == num33)
{
num42 += 0.5f;
}
if (num35 == num38 && num36 == num39 && num37 == num40)
{
num42 += 0.5f;
}
Vector2 spinningpoint2 = new Vector2((float)(this.width / 2 + 8), (float)(this.height / 2));
if (this.fullRotation != 0f)
{
spinningpoint2 = spinningpoint2.RotatedBy((double)this.fullRotation, this.fullRotationOrigin);
}
int i3 = (int)(this.position.X + spinningpoint2.X) / 16;
int j3 = (int)(this.position.Y + spinningpoint2.Y) / 16;
Lighting.AddLight(i3, j3, num35 * num42, num36 * num42, num37 * num42);
}
if (num38 != 0f || num39 != 0f || num40 != 0f)
{
float num43 = 1f;
if (num38 == num35 && num39 == num36 && num40 == num37)
{
num43 += 0.5f;
}
if (num38 == num31 && num39 == num32 && num40 == num33)
{
num43 += 0.5f;
}
Vector2 spinningpoint3 = new Vector2((float)(this.width / 2 + 8 * this.direction), (float)this.height * 0.75f);
if (this.fullRotation != 0f)
{
spinningpoint3 = spinningpoint3.RotatedBy((double)this.fullRotation, this.fullRotationOrigin);
}
int i4 = (int)(this.position.X + spinningpoint3.X) / 16;
int j4 = (int)(this.position.Y + spinningpoint3.Y) / 16;
Lighting.AddLight(i4, j4, num38 * num43, num39 * num43, num40 * num43);
}
}
this.UpdateArmorSets(i);
if (this.merman)
{
this.wings = 0;
}
if (this.invis)
{
if (this.itemAnimation == 0 && this.aggro > -750)
{
this.aggro = -750;
}
else if (this.aggro > -250)
{
this.aggro = -250;
}
}
if (this.inventory[this.selectedItem].itemId == 3106)
{
if (this.itemAnimation > 0)
{
this.stealthTimer = 15;
if (this.stealth > 0f)
{
this.stealth += 0.1f;
}
}
else if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1 && (double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
{
if (this.stealthTimer == 0 && this.stealth > 0f)
{
this.stealth -= 0.02f;
if ((double)this.stealth <= 0.0)
{
this.stealth = 0f;
if (Main.netMode == 1)
{
NetMessage.SendData(84, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
}
}
}
}
else if (this.stealth > 0f)
{
this.stealth += 0.1f;
}
if (this.stealth > 1f)
{
this.stealth = 1f;
}
this.meleeDamage += (1f - this.stealth) * 3f;
this.meleeCrit += (int)((1f - this.stealth) * 30f);
if (this.meleeCrit > 100)
{
this.meleeCrit = 100;
}
this.aggro -= (int)((1f - this.stealth) * 750f);
if (this.stealthTimer > 0)
{
this.stealthTimer--;
}
}
else if (this.shroomiteStealth)
{
if (this.itemAnimation > 0)
{
this.stealthTimer = 5;
}
if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1 && (double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
{
if (this.stealthTimer == 0 && this.stealth > 0f)
{
this.stealth -= 0.015f;
if ((double)this.stealth <= 0.0)
{
this.stealth = 0f;
if (Main.netMode == 1)
{
NetMessage.SendData(84, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
}
}
}
}
else
{
float num44 = Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y);
this.stealth += num44 * 0.0075f;
if (this.stealth > 1f)
{
this.stealth = 1f;
}
}
this.rangedDamage += (1f - this.stealth) * 0.6f;
this.rangedCrit += (int)((1f - this.stealth) * 10f);
this.aggro -= (int)((1f - this.stealth) * 750f);
if (this.stealthTimer > 0)
{
this.stealthTimer--;
}
}
else if (this.setVortex)
{
bool flag17 = false;
if (this.vortexStealthActive)
{
float num45 = this.stealth;
this.stealth -= 0.04f;
if (this.stealth < 0f)
{
this.stealth = 0f;
}
else
{
flag17 = true;
}
if (this.stealth == 0f && num45 != this.stealth && Main.netMode == 1)
{
NetMessage.SendData(84, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
}
this.rangedDamage += (1f - this.stealth) * 0.8f;
this.rangedCrit += (int)((1f - this.stealth) * 20f);
this.aggro -= (int)((1f - this.stealth) * 1200f);
this.moveSpeed *= 0.3f;
if (this.mount.Active)
{
this.vortexStealthActive = false;
}
}
else
{
float num46 = this.stealth;
this.stealth += 0.04f;
if (this.stealth > 1f)
{
this.stealth = 1f;
}
else
{
flag17 = true;
}
if (this.stealth == 1f && num46 != this.stealth && Main.netMode == 1)
{
NetMessage.SendData(84, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
}
}
if (flag17)
{
if (Main.rand.Next(2) == 0)
{
Vector2 vector = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
Dust dust = Main.dust[Dust.NewDust(base.Center - vector * 30f, 0, 0, 229, 0f, 0f, 0, default(Color), 1f)];
dust.noGravity = true;
dust.position = base.Center - vector * (float)Main.rand.Next(5, 11);
dust.velocity = vector.RotatedBy(1.5707963705062866, default(Vector2)) * 4f;
dust.scale = 0.5f + Main.rand.NextFloat();
dust.fadeIn = 0.5f;
}
if (Main.rand.Next(2) == 0)
{
Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
Dust dust2 = Main.dust[Dust.NewDust(base.Center - vector2 * 30f, 0, 0, 240, 0f, 0f, 0, default(Color), 1f)];
dust2.noGravity = true;
dust2.position = base.Center - vector2 * 12f;
dust2.velocity = vector2.RotatedBy(-1.5707963705062866, default(Vector2)) * 2f;
dust2.scale = 0.5f + Main.rand.NextFloat();
dust2.fadeIn = 0.5f;
}
}
}
else
{
this.stealth = 1f;
}
if (this.manaSick)
{
this.magicDamage *= 1f - this.manaSickReduction;
}
if (this.inventory[this.selectedItem].itemId == 1947)
{
this.meleeSpeed = (1f + this.meleeSpeed) / 2f;
}
if ((double)this.pickSpeed < 0.3)
{
this.pickSpeed = 0.3f;
}
if (this.meleeSpeed > 3f)
{
this.meleeSpeed = 3f;
}
if ((double)this.moveSpeed > 1.6)
{
this.moveSpeed = 1.6f;
}
if (this.tileSpeed > 3f)
{
this.tileSpeed = 3f;
}
this.tileSpeed = 1f / this.tileSpeed;
if (this.wallSpeed > 3f)
{
this.wallSpeed = 3f;
}
this.wallSpeed = 1f / this.wallSpeed;
if (this.statManaMax2 > 400)
{
this.statManaMax2 = 400;
}
if (this.statDefense < 0)
{
this.statDefense = 0;
}
if (this.dazed)
{
this.moveSpeed /= 3f;
}
else if (this.slow)
{
this.moveSpeed /= 2f;
}
else if (this.chilled)
{
this.moveSpeed *= 0.75f;
}
this.meleeSpeed = 1f / this.meleeSpeed;
this.UpdateLifeRegen();
this.soulDrain = 0;
this.UpdateManaRegen();
if (this.manaRegenCount < 0)
{
this.manaRegenCount = 0;
}
if (this.statMana > this.statManaMax2)
{
this.statMana = this.statManaMax2;
}
this.runAcceleration *= this.moveSpeed;
this.maxRunSpeed *= this.moveSpeed;
this.UpdateJumpHeight();
for (int num47 = 0; num47 < 22; num47++)
{
if (this.buffType[num47] > 0 && this.buffTime[num47] > 0 && this.buffImmune[this.buffType[num47]])
{
this.DelBuff(num47);
}
}
if (this.brokenArmor)
{
this.statDefense /= 2;
}
this.lastTileRangeX = Player.tileRangeX;
this.lastTileRangeY = Player.tileRangeY;
if (this.mount.Active && this.mount.BlockExtraJumps)
{
this.jumpAgainCloud = false;
this.jumpAgainSandstorm = false;
this.jumpAgainBlizzard = false;
this.jumpAgainFart = false;
this.jumpAgainSail = false;
this.jumpAgainUnicorn = false;
}
else
{
if (!this.doubleJumpCloud)
{
this.jumpAgainCloud = false;
}
else if (this.velocity.Y == 0f || this.sliding)
{
this.jumpAgainCloud = true;
}
if (!this.doubleJumpSandstorm)
{
this.jumpAgainSandstorm = false;
}
else if (this.velocity.Y == 0f || this.sliding)
{
this.jumpAgainSandstorm = true;
}
if (!this.doubleJumpBlizzard)
{
this.jumpAgainBlizzard = false;
}
else if (this.velocity.Y == 0f || this.sliding)
{
this.jumpAgainBlizzard = true;
}
if (!this.doubleJumpFart)
{
this.jumpAgainFart = false;
}
else if (this.velocity.Y == 0f || this.sliding)
{
this.jumpAgainFart = true;
}
if (!this.doubleJumpSail)
{
this.jumpAgainSail = false;
}
else if (this.velocity.Y == 0f || this.sliding)
{
this.jumpAgainSail = true;
}
if (!this.doubleJumpUnicorn)
{
this.jumpAgainUnicorn = false;
}
else if (this.velocity.Y == 0f || this.sliding)
{
this.jumpAgainUnicorn = true;
}
}
if (!this.carpet)
{
this.canCarpet = false;
this.carpetFrame = -1;
}
else if (this.velocity.Y == 0f || this.sliding)
{
this.canCarpet = true;
this.carpetTime = 0;
this.carpetFrame = -1;
this.carpetFrameCounter = 0f;
}
if (this.gravDir == -1f)
{
this.canCarpet = false;
}
if (this.ropeCount > 0)
{
this.ropeCount--;
}
if (!this.pulley && !this.frozen && !this.webbed && !this.stoned && !this.controlJump && this.gravDir == 1f && this.ropeCount == 0 && this.grappling[0] == -1 && !this.tongued && !this.mount.Active)
{
this.FindPulley();
}
if (this.pulley)
{
if (this.mount.Active)
{
this.pulley = false;
}
this.sandStorm = false;
this.dJumpEffectCloud = false;
this.dJumpEffectSandstorm = false;
this.dJumpEffectBlizzard = false;
this.dJumpEffectFart = false;
this.dJumpEffectSail = false;
this.dJumpEffectUnicorn = false;
int num48 = (int)(this.position.X + (float)(this.width / 2)) / 16;
int num49 = (int)(this.position.Y - 8f) / 16;
bool flag18 = false;
if (this.pulleyDir == 0)
{
this.pulleyDir = 1;
}
if (this.pulleyDir == 1)
{
if (this.direction == -1 && this.controlLeft && (this.releaseLeft || this.leftTimer == 0))
{
this.pulleyDir = 2;
flag18 = true;
}
else if ((this.direction == 1 && this.controlRight && this.releaseRight) || this.rightTimer == 0)
{
this.pulleyDir = 2;
flag18 = true;
}
else
{
if (this.direction == 1 && this.controlLeft)
{
this.direction = -1;
flag18 = true;
}
if (this.direction == -1 && this.controlRight)
{
this.direction = 1;
flag18 = true;
}
}
}
else if (this.pulleyDir == 2)
{
if (this.direction == 1 && this.controlLeft)
{
flag18 = true;
int num50 = num48 * 16 + 8 - this.width / 2;
if (!Collision.SolidCollision(new Vector2((float)num50, this.position.Y), this.width, this.height))
{
this.pulleyDir = 1;
this.direction = -1;
flag18 = true;
}
}
if (this.direction == -1 && this.controlRight)
{
flag18 = true;
int num51 = num48 * 16 + 8 - this.width / 2;
if (!Collision.SolidCollision(new Vector2((float)num51, this.position.Y), this.width, this.height))
{
this.pulleyDir = 1;
this.direction = 1;
flag18 = true;
}
}
}
bool flag19 = false;
if (!flag18 && ((this.controlLeft && (this.releaseLeft || this.leftTimer == 0)) || (this.controlRight && (this.releaseRight || this.rightTimer == 0))))
{
int num52 = 1;
if (this.controlLeft)
{
num52 = -1;
}
int num53 = num48 + num52;
if (Main.tile[num53, num49].active() && Main.tileRope[(int)Main.tile[num53, num49].type])
{
this.pulleyDir = 1;
this.direction = num52;
int num54 = num53 * 16 + 8 - this.width / 2;
float num55 = this.position.Y;
num55 = (float)(num49 * 16 + 22);
if ((!Main.tile[num53, num49 - 1].active() || !Main.tileRope[(int)Main.tile[num53, num49 - 1].type]) && (!Main.tile[num53, num49 + 1].active() || !Main.tileRope[(int)Main.tile[num53, num49 + 1].type]))
{
num55 = (float)(num49 * 16 + 22);
}
if (Collision.SolidCollision(new Vector2((float)num54, num55), this.width, this.height))
{
this.pulleyDir = 2;
this.direction = -num52;
if (this.direction == 1)
{
num54 = num53 * 16 + 8 - this.width / 2 + 6;
}
else
{
num54 = num53 * 16 + 8 - this.width / 2 + -6;
}
}
if (i == Main.myPlayer)
{
Main.cameraX = Main.cameraX + this.position.X - (float)num54;
}
this.position.X = (float)num54;
this.gfxOffY = this.position.Y - num55;
this.position.Y = num55;
flag19 = true;
}
}
if (!flag19 && !flag18 && !this.controlUp && ((this.controlLeft && this.releaseLeft) || (this.controlRight && this.releaseRight)))
{
this.pulley = false;
if (this.controlLeft && this.velocity.X == 0f)
{
this.velocity.X = -1f;
}
if (this.controlRight && this.velocity.X == 0f)
{
this.velocity.X = 1f;
}
}
if (this.velocity.X != 0f)
{
this.pulley = false;
}
if (Main.tile[num48, num49] == null)
{
Main.tile[num48, num49] = new Tile();
}
if (!Main.tile[num48, num49].active() || !Main.tileRope[(int)Main.tile[num48, num49].type])
{
this.pulley = false;
}
if (this.gravDir != 1f)
{
this.pulley = false;
}
if (this.frozen || this.webbed || this.stoned)
{
this.pulley = false;
}
if (!this.pulley)
{
this.velocity.Y = this.velocity.Y - this.gravity;
}
if (this.controlJump)
{
this.pulley = false;
this.jump = Player.jumpHeight;
this.velocity.Y = -Player.jumpSpeed;
}
}
if (this.pulley)
{
this.fallStart = (int)this.position.Y / 16;
this.wingFrame = 0;
if (this.wings == 4)
{
this.wingFrame = 3;
}
int num56 = (int)(this.position.X + (float)(this.width / 2)) / 16;
int num57 = (int)(this.position.Y - 16f) / 16;
int num58 = (int)(this.position.Y - 8f) / 16;
bool flag20 = true;
bool flag21 = false;
if ((Main.tile[num56, num58 - 1].active() && Main.tileRope[(int)Main.tile[num56, num58 - 1].type]) || (Main.tile[num56, num58 + 1].active() && Main.tileRope[(int)Main.tile[num56, num58 + 1].type]))
{
flag21 = true;
}
if (Main.tile[num56, num57] == null)
{
Main.tile[num56, num57] = new Tile();
}
if (!Main.tile[num56, num57].active() || !Main.tileRope[(int)Main.tile[num56, num57].type])
{
flag20 = false;
if (this.velocity.Y < 0f)
{
this.velocity.Y = 0f;
}
}
if (flag21)
{
if (this.controlUp && flag20)
{
float num59 = this.position.X;
float y3 = this.position.Y - Math.Abs(this.velocity.Y) - 2f;
if (Collision.SolidCollision(new Vector2(num59, y3), this.width, this.height))
{
num59 = (float)(num56 * 16 + 8 - this.width / 2 + 6);
if (!Collision.SolidCollision(new Vector2(num59, y3), this.width, (int)((float)this.height + Math.Abs(this.velocity.Y) + 2f)))
{
if (i == Main.myPlayer)
{
Main.cameraX = Main.cameraX + this.position.X - num59;
}
this.pulleyDir = 2;
this.direction = 1;
this.position.X = num59;
this.velocity.X = 0f;
}
else
{
num59 = (float)(num56 * 16 + 8 - this.width / 2 + -6);
if (!Collision.SolidCollision(new Vector2(num59, y3), this.width, (int)((float)this.height + Math.Abs(this.velocity.Y) + 2f)))
{
if (i == Main.myPlayer)
{
Main.cameraX = Main.cameraX + this.position.X - num59;
}
this.pulleyDir = 2;
this.direction = -1;
this.position.X = num59;
this.velocity.X = 0f;
}
}
}
if (this.velocity.Y > 0f)
{
this.velocity.Y = this.velocity.Y * 0.7f;
}
if (this.velocity.Y > -3f)
{
this.velocity.Y = this.velocity.Y - 0.2f;
}
else
{
this.velocity.Y = this.velocity.Y - 0.02f;
}
if (this.velocity.Y < -8f)
{
this.velocity.Y = -8f;
}
}
else if (this.controlDown)
{
float num60 = this.position.X;
float y4 = this.position.Y;
if (Collision.SolidCollision(new Vector2(num60, y4), this.width, (int)((float)this.height + Math.Abs(this.velocity.Y) + 2f)))
{
num60 = (float)(num56 * 16 + 8 - this.width / 2 + 6);
if (!Collision.SolidCollision(new Vector2(num60, y4), this.width, (int)((float)this.height + Math.Abs(this.velocity.Y) + 2f)))
{
if (i == Main.myPlayer)
{
Main.cameraX = Main.cameraX + this.position.X - num60;
}
this.pulleyDir = 2;
this.direction = 1;
this.position.X = num60;
this.velocity.X = 0f;
}
else
{
num60 = (float)(num56 * 16 + 8 - this.width / 2 + -6);
if (!Collision.SolidCollision(new Vector2(num60, y4), this.width, (int)((float)this.height + Math.Abs(this.velocity.Y) + 2f)))
{
if (i == Main.myPlayer)
{
Main.cameraX = Main.cameraX + this.position.X - num60;
}
this.pulleyDir = 2;
this.direction = -1;
this.position.X = num60;
this.velocity.X = 0f;
}
}
}
if (this.velocity.Y < 0f)
{
this.velocity.Y = this.velocity.Y * 0.7f;
}
if (this.velocity.Y < 3f)
{
this.velocity.Y = this.velocity.Y + 0.2f;
}
else
{
this.velocity.Y = this.velocity.Y + 0.1f;
}
if (this.velocity.Y > this.maxFallSpeed)
{
this.velocity.Y = this.maxFallSpeed;
}
}
else
{
this.velocity.Y = this.velocity.Y * 0.7f;
if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
{
this.velocity.Y = 0f;
}
}
}
else if (this.controlDown)
{
this.ropeCount = 10;
this.pulley = false;
this.velocity.Y = 1f;
}
else
{
this.velocity.Y = 0f;
this.position.Y = (float)(num57 * 16 + 22);
}
float num61 = (float)(num56 * 16 + 8 - this.width / 2);
if (this.pulleyDir == 1)
{
num61 = (float)(num56 * 16 + 8 - this.width / 2);
}
if (this.pulleyDir == 2)
{
num61 = (float)(num56 * 16 + 8 - this.width / 2 + 6 * this.direction);
}
if (i == Main.myPlayer)
{
Main.cameraX = Main.cameraX + this.position.X - num61;
}
this.position.X = num61;
this.pulleyFrameCounter += Math.Abs(this.velocity.Y * 0.75f);
if (this.velocity.Y != 0f)
{
this.pulleyFrameCounter += 0.75f;
}
if (this.pulleyFrameCounter > 10f)
{
this.pulleyFrame++;
this.pulleyFrameCounter = 0f;
}
if (this.pulleyFrame > 1)
{
this.pulleyFrame = 0;
}
this.canCarpet = true;
this.carpetFrame = -1;
this.wingTime = (float)this.wingTimeMax;
this.rocketTime = this.rocketTimeMax;
this.rocketDelay = 0;
this.rocketFrame = false;
this.canRocket = false;
this.rocketRelease = false;
}
else if (this.grappling[0] == -1 && !this.tongued)
{
if (this.wingsLogic > 0 && this.velocity.Y != 0f && !this.merman)
{
if (this.wingsLogic == 1 || this.wingsLogic == 2)
{
this.accRunSpeed = 6.25f;
}
if (this.wingsLogic == 4)
{
this.accRunSpeed = 6.5f;
}
if (this.wingsLogic == 5 || this.wingsLogic == 6 || this.wingsLogic == 13 || this.wingsLogic == 15)
{
this.accRunSpeed = 6.75f;
}
if (this.wingsLogic == 7 || this.wingsLogic == 8)
{
this.accRunSpeed = 7f;
}
if (this.wingsLogic == 9 || this.wingsLogic == 10 || this.wingsLogic == 11 || this.wingsLogic == 20 || this.wingsLogic == 21 || this.wingsLogic == 23 || this.wingsLogic == 24)
{
this.accRunSpeed = 7.5f;
}
if (this.wingsLogic == 22)
{
if (this.controlDown && this.controlJump && this.wingTime > 0f)
{
this.accRunSpeed = 10f;
this.runAcceleration *= 10f;
}
else
{
this.accRunSpeed = 6.25f;
}
}
if (this.wingsLogic == 30)
{
if (this.controlDown && this.controlJump && this.wingTime > 0f)
{
this.accRunSpeed = 12f;
this.runAcceleration *= 12f;
}
else
{
this.accRunSpeed = 6.5f;
this.runAcceleration *= 1.5f;
}
}
if (this.wingsLogic == 32)
{
if (this.controlDown && this.controlJump && this.wingTime > 0f)
{
this.accRunSpeed = 7.5f;
this.runAcceleration *= 5f;
}
else
{
this.accRunSpeed = 5.5f;
this.runAcceleration *= 1.1f;
}
}
if (this.wingsLogic == 26)
{
this.accRunSpeed = 8f;
this.runAcceleration *= 2f;
}
if (this.wingsLogic == 29)
{
this.accRunSpeed = 9f;
this.runAcceleration *= 2.5f;
}
if (this.wingsLogic == 12)
{
this.accRunSpeed = 7.75f;
}
if (this.wingsLogic == 16 || this.wingsLogic == 17 || this.wingsLogic == 18 || this.wingsLogic == 19 || this.wingsLogic == 34 || this.wingsLogic == 3 || this.wingsLogic == 28 || this.wingsLogic == 33 || this.wingsLogic == 34 || this.wingsLogic == 35 || this.wingsLogic == 36)
{
this.accRunSpeed = 7f;
}
}
if (this.sticky)
{
this.maxRunSpeed *= 0.25f;
this.runAcceleration *= 0.25f;
this.runSlowdown *= 2f;
if (this.velocity.X > this.maxRunSpeed)
{
this.velocity.X = this.maxRunSpeed;
}
if (this.velocity.X < -this.maxRunSpeed)
{
this.velocity.X = -this.maxRunSpeed;
}
}
else if (this.powerrun)
{
this.maxRunSpeed *= 3.5f;
this.runAcceleration *= 1f;
this.runSlowdown *= 2f;
}
else if (this.slippy2)
{
this.runAcceleration *= 0.6f;
this.runSlowdown = 0f;
if (this.iceSkate)
{
this.runAcceleration *= 3.5f;
this.maxRunSpeed *= 1.25f;
}
}
else if (this.slippy)
{
this.runAcceleration *= 0.7f;
if (this.iceSkate)
{
this.runAcceleration *= 3.5f;
this.maxRunSpeed *= 1.25f;
}
else
{
this.runSlowdown *= 0.1f;
}
}
if (this.sandStorm)
{
this.runAcceleration *= 1.5f;
this.maxRunSpeed *= 2f;
}
if (this.dJumpEffectBlizzard && this.doubleJumpBlizzard)
{
this.runAcceleration *= 3f;
this.maxRunSpeed *= 1.5f;
}
if (this.dJumpEffectFart && this.doubleJumpFart)
{
this.runAcceleration *= 3f;
this.maxRunSpeed *= 1.75f;
}
if (this.dJumpEffectUnicorn && this.doubleJumpUnicorn)
{
this.runAcceleration *= 3f;
this.maxRunSpeed *= 1.5f;
}
if (this.dJumpEffectSail && this.doubleJumpSail)
{
this.runAcceleration *= 1.5f;
this.maxRunSpeed *= 1.25f;
}
if (this.carpetFrame != -1)
{
this.runAcceleration *= 1.25f;
this.maxRunSpeed *= 1.5f;
}
if (this.inventory[this.selectedItem].itemId == 3106 && this.stealth < 1f)
{
float num62 = this.maxRunSpeed / 2f * (1f - this.stealth);
this.maxRunSpeed -= num62;
this.accRunSpeed = this.maxRunSpeed;
}
if (this.mount.Active)
{
this.rocketBoots = 0;
this.wings = 0;
this.wingsLogic = 0;
this.maxRunSpeed = this.mount.RunSpeed;
this.accRunSpeed = this.mount.DashSpeed;
this.runAcceleration = this.mount.Acceleration;
if (this.mount.Type == 12 && !this.MountFishronSpecial)
{
this.runAcceleration /= 2f;
this.maxRunSpeed /= 2f;
}
this.mount.AbilityRecovery();
if (this.mount.Cart && this.velocity.Y == 0f)
{
if (!Minecart.OnTrack(this.position, this.width, this.height))
{
this.fullRotation = 0f;
this.onWrongGround = true;
this.runSlowdown = 0.2f;
if ((this.controlLeft && this.releaseLeft) || (this.controlRight && this.releaseRight))
{
this.mount.Dismount(this);
}
}
else
{
this.runSlowdown = this.runAcceleration;
this.onWrongGround = false;
}
}
if (this.mount.Type == 8)
{
this.mount.UpdateDrill(this, this.controlUp, this.controlDown);
}
}
this.HorizontalMovement();
if (this.gravControl)
{
if (this.controlUp && this.releaseUp)
{
if (this.gravDir == 1f)
{
this.gravDir = -1f;
this.fallStart = (int)(this.position.Y / 16f);
this.jump = 0;
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 8);
}
else
{
this.gravDir = 1f;
this.fallStart = (int)(this.position.Y / 16f);
this.jump = 0;
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 8);
}
}
}
else if (this.gravControl2)
{
if (this.controlUp && this.releaseUp && this.velocity.Y == 0f)
{
if (this.gravDir == 1f)
{
this.gravDir = -1f;
this.fallStart = (int)(this.position.Y / 16f);
this.jump = 0;
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 8);
}
else
{
this.gravDir = 1f;
this.fallStart = (int)(this.position.Y / 16f);
this.jump = 0;
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 8);
}
}
}
else
{
this.gravDir = 1f;
}
if (this.velocity.Y == 0f && this.mount.Active && this.mount.CanHover && this.controlUp && this.releaseUp)
{
this.velocity.Y = -(this.mount.Acceleration + this.gravity + 0.001f);
}
if (this.controlUp)
{
this.releaseUp = false;
}
else
{
this.releaseUp = true;
}
this.sandStorm = false;
this.JumpMovement();
if (this.wingsLogic == 0)
{
this.wingTime = 0f;
}
if (this.rocketBoots == 0)
{
this.rocketTime = 0;
}
if (this.jump == 0)
{
this.dJumpEffectCloud = false;
this.dJumpEffectSandstorm = false;
this.dJumpEffectBlizzard = false;
this.dJumpEffectFart = false;
this.dJumpEffectSail = false;
this.dJumpEffectUnicorn = false;
}
this.DashMovement();
this.WallslideMovement();
this.CarpetMovement();
this.DoubleJumpVisuals();
if (this.wings > 0 || this.mount.Active)
{
this.sandStorm = false;
}
if (((this.gravDir == 1f && this.velocity.Y > -Player.jumpSpeed) || (this.gravDir == -1f && this.velocity.Y < Player.jumpSpeed)) && this.velocity.Y != 0f)
{
this.canRocket = true;
}
bool flag22 = false;
if (((this.velocity.Y == 0f || this.sliding) && this.releaseJump) || (this.autoJump && this.justJumped))
{
this.mount.ResetFlightTime(this.velocity.X);
this.wingTime = (float)this.wingTimeMax;
}
if (this.wingsLogic > 0 && this.controlJump && this.wingTime > 0f && !this.jumpAgainCloud && this.jump == 0 && this.velocity.Y != 0f)
{
flag22 = true;
}
if ((this.wingsLogic == 22 || this.wingsLogic == 28 || this.wingsLogic == 30 || this.wingsLogic == 32 || this.wingsLogic == 33 || this.wingsLogic == 35) && this.controlJump && this.controlDown && this.wingTime > 0f)
{
flag22 = true;
}
if (this.frozen || this.webbed || this.stoned)
{
if (this.mount.Active)
{
this.mount.Dismount(this);
}
this.velocity.Y = this.velocity.Y + this.gravity;
if (this.velocity.Y > this.maxFallSpeed)
{
this.velocity.Y = this.maxFallSpeed;
}
this.sandStorm = false;
this.dJumpEffectCloud = false;
this.dJumpEffectSandstorm = false;
this.dJumpEffectBlizzard = false;
this.dJumpEffectFart = false;
this.dJumpEffectSail = false;
this.dJumpEffectUnicorn = false;
}
else
{
if (flag22)
{
if (this.wings == 10 && Main.rand.Next(2) == 0)
{
int num63 = 4;
if (this.direction == 1)
{
num63 = -40;
}
int num64 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num63, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 76, 0f, 0f, 50, default(Color), 0.6f);
Main.dust[num64].fadeIn = 1.1f;
Main.dust[num64].noGravity = true;
Main.dust[num64].noLight = true;
Main.dust[num64].velocity *= 0.3f;
Main.dust[num64].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 34 && Main.rand.Next(2) == 0)
{
int num65 = 4;
if (this.direction == 1)
{
num65 = -40;
}
int num66 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num65, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 261, 0f, 0f, 50, default(Color), 0.6f);
Main.dust[num66].fadeIn = 1.1f;
Main.dust[num66].noGravity = true;
Main.dust[num66].noLight = true;
Main.dust[num66].velocity *= 0.3f;
Main.dust[num66].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 9 && Main.rand.Next(2) == 0)
{
int num67 = 4;
if (this.direction == 1)
{
num67 = -40;
}
int num68 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num67, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 6, 0f, 0f, 200, default(Color), 2f);
Main.dust[num68].noGravity = true;
Main.dust[num68].velocity *= 0.3f;
Main.dust[num68].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 6 && Main.rand.Next(4) == 0)
{
int num69 = 4;
if (this.direction == 1)
{
num69 = -40;
}
int num70 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num69, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 55, 0f, 0f, 200, default(Color), 1f);
Main.dust[num70].velocity *= 0.3f;
Main.dust[num70].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 5 && Main.rand.Next(3) == 0)
{
int num71 = 6;
if (this.direction == 1)
{
num71 = -30;
}
int num72 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num71, this.position.Y), 18, this.height, 58, 0f, 0f, 255, default(Color), 1.2f);
Main.dust[num72].velocity *= 0.3f;
Main.dust[num72].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 26)
{
int num73 = 6;
if (this.direction == 1)
{
num73 = -30;
}
int num74 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num73, this.position.Y), 18, this.height, 217, 0f, 0f, 100, default(Color), 1.4f);
Main.dust[num74].noGravity = true;
Main.dust[num74].noLight = true;
Main.dust[num74].velocity /= 4f;
Main.dust[num74].velocity -= this.velocity;
Main.dust[num74].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
if (Main.rand.Next(2) == 0)
{
num73 = -24;
if (this.direction == 1)
{
num73 = 12;
}
float num75 = this.position.Y;
if (this.gravDir == -1f)
{
num75 += (float)(this.height / 2);
}
num74 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num73, num75), 12, this.height / 2, 217, 0f, 0f, 100, default(Color), 1.4f);
Main.dust[num74].noGravity = true;
Main.dust[num74].noLight = true;
Main.dust[num74].velocity /= 4f;
Main.dust[num74].velocity -= this.velocity;
Main.dust[num74].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
}
if (this.wings == 29 && Main.rand.Next(3) == 0)
{
int num76 = 4;
if (this.direction == 1)
{
num76 = -40;
}
int num77 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num76, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 6, 0f, 0f, 100, default(Color), 2.4f);
Main.dust[num77].noGravity = true;
Main.dust[num77].velocity *= 0.3f;
if (Main.rand.Next(10) == 0)
{
Main.dust[num77].fadeIn = 2f;
}
Main.dust[num77].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 31)
{
if (Main.rand.Next(6) == 0)
{
int num78 = 4;
if (this.direction == 1)
{
num78 = -40;
}
Dust dust3 = Main.dust[Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num78, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 86, 0f, 0f, 0, default(Color), 1f)];
dust3.noGravity = true;
dust3.scale = 1f;
dust3.fadeIn = 1.2f;
dust3.velocity *= 0.2f;
dust3.noLight = true;
dust3.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (Main.rand.Next(3) == 0)
{
int num79 = 4;
if (this.direction == 1)
{
num79 = -40;
}
Dust dust4 = Main.dust[Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num79, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 240, 0f, 0f, 0, default(Color), 1f)];
dust4.noGravity = true;
dust4.scale = 1.2f;
dust4.velocity *= 0.2f;
dust4.alpha = 200;
dust4.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (Main.rand.Next(2) == 0)
{
if (Main.rand.Next(6) == 0)
{
int num80 = -24;
if (this.direction == 1)
{
num80 = 12;
}
float num81 = this.position.Y;
if (this.gravDir == -1f)
{
num81 += (float)(this.height / 2);
}
Dust dust5 = Main.dust[Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num80, num81), 12, this.height / 2, 86, 0f, 0f, 0, default(Color), 1f)];
dust5.noGravity = true;
dust5.scale = 1f;
dust5.fadeIn = 1.2f;
dust5.velocity *= 0.2f;
dust5.noLight = true;
dust5.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (Main.rand.Next(3) == 0)
{
int num80 = -24;
if (this.direction == 1)
{
num80 = 12;
}
float num82 = this.position.Y;
if (this.gravDir == -1f)
{
num82 += (float)(this.height / 2);
}
Dust dust6 = Main.dust[Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num80, num82), 12, this.height / 2, 240, 0f, 0f, 0, default(Color), 1f)];
dust6.noGravity = true;
dust6.scale = 1.2f;
dust6.velocity *= 0.2f;
dust6.alpha = 200;
dust6.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
}
}
this.WingMovement();
}
if (this.wings == 4)
{
if (flag22 || this.jump > 0)
{
this.rocketDelay2--;
if (this.rocketDelay2 <= 0)
{
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 13);
this.rocketDelay2 = 60;
}
int num83 = 2;
if (this.controlUp)
{
num83 = 4;
}
for (int num84 = 0; num84 < num83; num84++)
{
int type = 6;
if (this.head == 41)
{
int arg_5B01_0 = this.body;
}
float scale = 1.75f;
int alpha = 100;
float x3 = this.position.X + (float)(this.width / 2) + 16f;
if (this.direction > 0)
{
x3 = this.position.X + (float)(this.width / 2) - 26f;
}
float num85 = this.position.Y + (float)this.height - 18f;
if (num84 == 1 || num84 == 3)
{
x3 = this.position.X + (float)(this.width / 2) + 8f;
if (this.direction > 0)
{
x3 = this.position.X + (float)(this.width / 2) - 20f;
}
num85 += 6f;
}
if (num84 > 1)
{
num85 += this.velocity.Y;
}
int num86 = Dust.NewDust(new Vector2(x3, num85), 8, 8, type, 0f, 0f, alpha, default(Color), scale);
Dust expr_5C14_cp_0 = Main.dust[num86];
expr_5C14_cp_0.velocity.X = expr_5C14_cp_0.velocity.X * 0.1f;
Main.dust[num86].velocity.Y = Main.dust[num86].velocity.Y * 1f + 2f * this.gravDir - this.velocity.Y * 0.3f;
Main.dust[num86].noGravity = true;
Main.dust[num86].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
if (num83 == 4)
{
Dust expr_5CAC_cp_0 = Main.dust[num86];
expr_5CAC_cp_0.velocity.Y = expr_5CAC_cp_0.velocity.Y + 6f;
}
}
this.wingFrameCounter++;
if (this.wingFrameCounter > 4)
{
this.wingFrame++;
this.wingFrameCounter = 0;
if (this.wingFrame >= 3)
{
this.wingFrame = 0;
}
}
}
else if (!this.controlJump || this.velocity.Y == 0f)
{
this.wingFrame = 3;
}
}
else if (this.wings == 28)
{
if (this.velocity.Y != 0f)
{
Lighting.AddLight(base.Bottom, 0.3f, 0.1f, 0.4f);
}
}
else if (this.wings == 22)
{
if (!this.controlJump)
{
this.wingFrame = 0;
this.wingFrameCounter = 0;
}
else if (this.wingTime > 0f)
{
if (this.controlDown)
{
if (this.velocity.X != 0f)
{
this.wingFrameCounter++;
int num87 = 2;
if (this.wingFrameCounter < num87)
{
this.wingFrame = 1;
}
else if (this.wingFrameCounter < num87 * 2)
{
this.wingFrame = 2;
}
else if (this.wingFrameCounter < num87 * 3)
{
this.wingFrame = 3;
}
else if (this.wingFrameCounter < num87 * 4 - 1)
{
this.wingFrame = 2;
}
else
{
this.wingFrame = 2;
this.wingFrameCounter = 0;
}
}
else
{
this.wingFrameCounter++;
int num88 = 6;
if (this.wingFrameCounter < num88)
{
this.wingFrame = 4;
}
else if (this.wingFrameCounter < num88 * 2)
{
this.wingFrame = 5;
}
else if (this.wingFrameCounter < num88 * 3 - 1)
{
this.wingFrame = 4;
}
else
{
this.wingFrame = 4;
this.wingFrameCounter = 0;
}
}
}
else
{
this.wingFrameCounter++;
int num89 = 2;
if (this.wingFrameCounter < num89)
{
this.wingFrame = 4;
}
else if (this.wingFrameCounter < num89 * 2)
{
this.wingFrame = 5;
}
else if (this.wingFrameCounter < num89 * 3)
{
this.wingFrame = 6;
}
else if (this.wingFrameCounter < num89 * 4 - 1)
{
this.wingFrame = 5;
}
else
{
this.wingFrame = 5;
this.wingFrameCounter = 0;
}
}
}
else
{
this.wingFrameCounter++;
int num90 = 6;
if (this.wingFrameCounter < num90)
{
this.wingFrame = 4;
}
else if (this.wingFrameCounter < num90 * 2)
{
this.wingFrame = 5;
}
else if (this.wingFrameCounter < num90 * 3 - 1)
{
this.wingFrame = 4;
}
else
{
this.wingFrame = 4;
this.wingFrameCounter = 0;
}
}
}
else if (this.wings == 12)
{
if (flag22 || this.jump > 0)
{
this.wingFrameCounter++;
int num91 = 5;
if (this.wingFrameCounter < num91)
{
this.wingFrame = 1;
}
else if (this.wingFrameCounter < num91 * 2)
{
this.wingFrame = 2;
}
else if (this.wingFrameCounter < num91 * 3)
{
this.wingFrame = 3;
}
else if (this.wingFrameCounter < num91 * 4 - 1)
{
this.wingFrame = 2;
}
else
{
this.wingFrame = 2;
this.wingFrameCounter = 0;
}
}
else if (this.velocity.Y != 0f)
{
this.wingFrame = 2;
}
else
{
this.wingFrame = 0;
}
}
else if (this.wings == 24)
{
if (flag22 || this.jump > 0)
{
this.wingFrameCounter++;
int num92 = 1;
if (this.wingFrameCounter < num92)
{
this.wingFrame = 1;
}
else if (this.wingFrameCounter < num92 * 2)
{
this.wingFrame = 2;
}
else if (this.wingFrameCounter < num92 * 3)
{
this.wingFrame = 3;
}
else
{
this.wingFrame = 2;
if (this.wingFrameCounter >= num92 * 4 - 1)
{
this.wingFrameCounter = 0;
}
}
}
else if (this.velocity.Y != 0f)
{
if (this.controlJump)
{
this.wingFrameCounter++;
int num93 = 3;
if (this.wingFrameCounter < num93)
{
this.wingFrame = 1;
}
else if (this.wingFrameCounter < num93 * 2)
{
this.wingFrame = 2;
}
else if (this.wingFrameCounter < num93 * 3)
{
this.wingFrame = 3;
}
else
{
this.wingFrame = 2;
if (this.wingFrameCounter >= num93 * 4 - 1)
{
this.wingFrameCounter = 0;
}
}
}
else if (this.wingTime == 0f)
{
this.wingFrame = 0;
}
else
{
this.wingFrame = 1;
}
}
else
{
this.wingFrame = 0;
}
}
else if (this.wings == 30)
{
bool flag23 = false;
if (flag22 || this.jump > 0)
{
this.wingFrameCounter++;
int num94 = 2;
if (this.wingFrameCounter >= num94 * 3)
{
this.wingFrameCounter = 0;
}
this.wingFrame = 1 + this.wingFrameCounter / num94;
flag23 = true;
}
else if (this.velocity.Y != 0f)
{
if (this.controlJump)
{
this.wingFrameCounter++;
int num95 = 2;
if (this.wingFrameCounter >= num95 * 3)
{
this.wingFrameCounter = 0;
}
this.wingFrame = 1 + this.wingFrameCounter / num95;
flag23 = true;
}
else if (this.wingTime == 0f)
{
this.wingFrame = 0;
}
else
{
this.wingFrame = 0;
}
}
else
{
this.wingFrame = 0;
}
if (flag23)
{
for (int num96 = 0; num96 < 4; num96++)
{
if (Main.rand.Next(4) == 0)
{
Vector2 value = (-0.745398164f + 0.3926991f * (float)num96 + 0.03f * (float)num96).ToRotationVector2() * new Vector2((float)(-(float)this.direction * 20), 20f);
Dust dust7 = Main.dust[Dust.NewDust(base.Center, 0, 0, 229, 0f, 0f, 100, Color.White, 0.8f)];
dust7.noGravity = true;
dust7.position = base.Center + value;
dust7.velocity = base.DirectionTo(dust7.position) * 2f;
if (Main.rand.Next(10) != 0)
{
dust7.customData = this;
}
else
{
dust7.fadeIn = 0.5f;
}
dust7.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
}
for (int num97 = 0; num97 < 4; num97++)
{
if (Main.rand.Next(8) == 0)
{
Vector2 value2 = (-0.7053982f + 0.3926991f * (float)num97 + 0.03f * (float)num97).ToRotationVector2() * new Vector2((float)(this.direction * 20), 24f) + new Vector2((float)(-(float)this.direction) * 16f, 0f);
Dust dust8 = Main.dust[Dust.NewDust(base.Center, 0, 0, 229, 0f, 0f, 100, Color.White, 0.5f)];
dust8.noGravity = true;
dust8.position = base.Center + value2;
dust8.velocity = Vector2.Normalize(dust8.position - base.Center - new Vector2((float)(-(float)this.direction) * 16f, 0f)) * 2f;
dust8.position += dust8.velocity * 5f;
if (Main.rand.Next(10) != 0)
{
dust8.customData = this;
}
else
{
dust8.fadeIn = 0.5f;
}
dust8.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
}
}
}
else if (this.wings == 34)
{
if (flag22 || this.jump > 0)
{
this.wingFrameCounter++;
int num98 = 4;
if (this.wingFrameCounter >= num98 * 6)
{
this.wingFrameCounter = 0;
}
this.wingFrame = this.wingFrameCounter / num98;
}
else if (this.velocity.Y != 0f)
{
if (this.controlJump)
{
this.wingFrameCounter++;
int num99 = 9;
if (this.wingFrameCounter >= num99 * 6)
{
this.wingFrameCounter = 0;
}
this.wingFrame = this.wingFrameCounter / num99;
}
else
{
this.wingFrameCounter++;
int num100 = 6;
if (this.wingFrameCounter >= num100 * 6)
{
this.wingFrameCounter = 0;
}
this.wingFrame = this.wingFrameCounter / num100;
}
}
else
{
this.wingFrameCounter++;
int num101 = 4;
if (this.wingFrameCounter >= num101 * 6)
{
this.wingFrameCounter = 0;
}
this.wingFrame = this.wingFrameCounter / num101;
}
}
else if (this.wings == 33)
{
bool flag24 = false;
if (flag22 || this.jump > 0)
{
flag24 = true;
}
else if (this.velocity.Y != 0f && this.controlJump)
{
flag24 = true;
}
if (flag24)
{
Color newColor = Main.hslToRgb(Main.rgbToHsl(this.eyeColor).X, 1f, 0.5f);
int num102 = (this.direction == 1) ? 0 : -4;
for (int num103 = 0; num103 < 2; num103++)
{
Dust dust9 = Main.dust[Dust.NewDust(this.position, this.width, this.height, 182, this.velocity.X, this.velocity.Y, 127, newColor, 1f)];
dust9.noGravity = true;
dust9.fadeIn = 1f;
dust9.scale = 1f;
dust9.noLight = true;
if (num103 == 0)
{
dust9.position = new Vector2(this.position.X + (float)num102, this.position.Y + (float)this.height);
dust9.velocity.X = dust9.velocity.X * 1f - 2f - this.velocity.X * 0.3f;
dust9.velocity.Y = dust9.velocity.Y * 1f + 2f * this.gravDir - this.velocity.Y * 0.3f;
}
else if (num103 == 1)
{
dust9.position = new Vector2(this.position.X + (float)this.width + (float)num102, this.position.Y + (float)this.height);
dust9.velocity.X = dust9.velocity.X * 1f + 2f - this.velocity.X * 0.3f;
dust9.velocity.Y = dust9.velocity.Y * 1f + 2f * this.gravDir - this.velocity.Y * 0.3f;
}
Dust dust10 = Dust.CloneDust(dust9);
dust10.scale *= 0.65f;
dust10.fadeIn *= 0.65f;
dust10.color = new Color(255, 255, 255, 255);
dust9.noLight = true;
dust9.shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
}
}
else
{
int num104 = 4;
if (this.wings == 32)
{
num104 = 3;
}
if (flag22 || this.jump > 0)
{
this.wingFrameCounter++;
if (this.wingFrameCounter > num104)
{
this.wingFrame++;
this.wingFrameCounter = 0;
if (this.wingFrame >= 4)
{
this.wingFrame = 0;
}
}
}
else if (this.velocity.Y != 0f)
{
this.wingFrame = 1;
if (this.wings == 32)
{
this.wingFrame = 3;
}
if (this.wings == 29 && Main.rand.Next(5) == 0)
{
int num105 = 4;
if (this.direction == 1)
{
num105 = -40;
}
int num106 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num105, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 6, 0f, 0f, 100, default(Color), 2.4f);
Main.dust[num106].noGravity = true;
Main.dust[num106].velocity *= 0.3f;
if (Main.rand.Next(10) == 0)
{
Main.dust[num106].fadeIn = 2f;
}
Main.dust[num106].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
}
else
{
this.wingFrame = 0;
}
}
if (this.wingsLogic > 0 && this.rocketBoots > 0 && this.velocity.Y != 0f)
{
this.wingTime += (float)(this.rocketTime * 6);
this.rocketTime = 0;
}
if (flag22 && this.wings != 4 && this.wings != 22 && this.wings != 0 && this.wings != 24 && this.wings != 28 && this.wings != 30 && this.wings != 33)
{
if (this.wingFrame == 3)
{
if (!this.flapSound)
{
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 32);
}
this.flapSound = true;
}
else
{
this.flapSound = false;
}
}
if (this.velocity.Y == 0f || this.sliding || (this.autoJump && this.justJumped))
{
this.rocketTime = this.rocketTimeMax;
}
if ((this.wingTime == 0f || this.wingsLogic == 0) && this.rocketBoots > 0 && this.controlJump && this.rocketDelay == 0 && this.canRocket && this.rocketRelease && !this.jumpAgainCloud)
{
if (this.rocketTime > 0)
{
this.rocketTime--;
this.rocketDelay = 10;
if (this.rocketDelay2 <= 0)
{
if (this.rocketBoots == 1)
{
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 13);
this.rocketDelay2 = 30;
}
else if (this.rocketBoots == 2 || this.rocketBoots == 3)
{
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 24);
this.rocketDelay2 = 15;
}
}
}
else
{
this.canRocket = false;
}
}
if (this.rocketDelay2 > 0)
{
this.rocketDelay2--;
}
if (this.rocketDelay == 0)
{
this.rocketFrame = false;
}
if (this.rocketDelay > 0)
{
int num107 = this.height;
if (this.gravDir == -1f)
{
num107 = 4;
}
this.rocketFrame = true;
for (int num108 = 0; num108 < 2; num108++)
{
int type2 = 6;
float scale2 = 2.5f;
int alpha2 = 100;
if (this.rocketBoots == 2)
{
type2 = 16;
scale2 = 1.5f;
alpha2 = 20;
}
else if (this.rocketBoots == 3)
{
type2 = 76;
scale2 = 1f;
alpha2 = 20;
}
else if (this.socialShadow)
{
type2 = 27;
scale2 = 1.5f;
}
if (num108 == 0)
{
int num109 = Dust.NewDust(new Vector2(this.position.X - 4f, this.position.Y + (float)num107 - 10f), 8, 8, type2, 0f, 0f, alpha2, default(Color), scale2);
Main.dust[num109].shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this);
if (this.rocketBoots == 1)
{
Main.dust[num109].noGravity = true;
}
Main.dust[num109].velocity.X = Main.dust[num109].velocity.X * 1f - 2f - this.velocity.X * 0.3f;
Main.dust[num109].velocity.Y = Main.dust[num109].velocity.Y * 1f + 2f * this.gravDir - this.velocity.Y * 0.3f;
if (this.rocketBoots == 2)
{
Main.dust[num109].velocity *= 0.1f;
}
if (this.rocketBoots == 3)
{
Main.dust[num109].velocity *= 0.05f;
Dust expr_6EBF_cp_0 = Main.dust[num109];
expr_6EBF_cp_0.velocity.Y = expr_6EBF_cp_0.velocity.Y + 0.15f;
Main.dust[num109].noLight = true;
if (Main.rand.Next(2) == 0)
{
Main.dust[num109].noGravity = true;
Main.dust[num109].scale = 1.75f;
}
}
}
else
{
int num110 = Dust.NewDust(new Vector2(this.position.X + (float)this.width - 4f, this.position.Y + (float)num107 - 10f), 8, 8, type2, 0f, 0f, alpha2, default(Color), scale2);
Main.dust[num110].shader = GameShaders.Armor.GetSecondaryShader(this.cShoe, this);
if (this.rocketBoots == 1)
{
Main.dust[num110].noGravity = true;
}
Main.dust[num110].velocity.X = Main.dust[num110].velocity.X * 1f + 2f - this.velocity.X * 0.3f;
Main.dust[num110].velocity.Y = Main.dust[num110].velocity.Y * 1f + 2f * this.gravDir - this.velocity.Y * 0.3f;
if (this.rocketBoots == 2)
{
Main.dust[num110].velocity *= 0.1f;
}
if (this.rocketBoots == 3)
{
Main.dust[num110].velocity *= 0.05f;
Dust expr_7086_cp_0 = Main.dust[num110];
expr_7086_cp_0.velocity.Y = expr_7086_cp_0.velocity.Y + 0.15f;
Main.dust[num110].noLight = true;
if (Main.rand.Next(2) == 0)
{
Main.dust[num110].noGravity = true;
Main.dust[num110].scale = 1.75f;
}
}
}
}
if (this.rocketDelay == 0)
{
this.releaseJump = true;
}
this.rocketDelay--;
this.velocity.Y = this.velocity.Y - 0.1f * this.gravDir;
if (this.gravDir == 1f)
{
if (this.velocity.Y > 0f)
{
this.velocity.Y = this.velocity.Y - 0.5f;
}
else if ((double)this.velocity.Y > (double)(-(double)Player.jumpSpeed) * 0.5)
{
this.velocity.Y = this.velocity.Y - 0.1f;
}
if (this.velocity.Y < -Player.jumpSpeed * 1.5f)
{
this.velocity.Y = -Player.jumpSpeed * 1.5f;
}
}
else
{
if (this.velocity.Y < 0f)
{
this.velocity.Y = this.velocity.Y + 0.5f;
}
else if ((double)this.velocity.Y < (double)Player.jumpSpeed * 0.5)
{
this.velocity.Y = this.velocity.Y + 0.1f;
}
if (this.velocity.Y > Player.jumpSpeed * 1.5f)
{
this.velocity.Y = Player.jumpSpeed * 1.5f;
}
}
}
else if (!flag22)
{
if (this.mount.CanHover)
{
this.mount.Hover(this);
}
else if (this.mount.CanFly && this.controlJump && this.jump == 0)
{
if (this.mount.Flight())
{
if (this.controlDown)
{
this.velocity.Y = this.velocity.Y * 0.9f;
if (this.velocity.Y > -1f && (double)this.velocity.Y < 0.5)
{
this.velocity.Y = 1E-05f;
}
}
else
{
if (this.velocity.Y > 0f)
{
this.velocity.Y = this.velocity.Y - 0.5f;
}
else if ((double)this.velocity.Y > (double)(-(double)Player.jumpSpeed) * 1.5)
{
this.velocity.Y = this.velocity.Y - 0.1f;
}
if (this.velocity.Y < -Player.jumpSpeed * 1.5f)
{
this.velocity.Y = -Player.jumpSpeed * 1.5f;
}
}
}
else
{
this.velocity.Y = this.velocity.Y + this.gravity / 3f * this.gravDir;
if (this.gravDir == 1f)
{
if (this.velocity.Y > this.maxFallSpeed / 3f && !this.controlDown)
{
this.velocity.Y = this.maxFallSpeed / 3f;
}
}
else if (this.velocity.Y < -this.maxFallSpeed / 3f && !this.controlUp)
{
this.velocity.Y = -this.maxFallSpeed / 3f;
}
}
}
else if (this.slowFall && ((!this.controlDown && this.gravDir == 1f) || (!this.controlDown && this.gravDir == -1f)))
{
if ((this.controlUp && this.gravDir == 1f) || (this.controlUp && this.gravDir == -1f))
{
this.gravity = this.gravity / 10f * this.gravDir;
}
else
{
this.gravity = this.gravity / 3f * this.gravDir;
}
this.velocity.Y = this.velocity.Y + this.gravity;
}
else if (this.wingsLogic > 0 && this.controlJump && this.velocity.Y > 0f)
{
this.fallStart = (int)(this.position.Y / 16f);
if (this.velocity.Y > 0f)
{
if (this.wings == 10 && Main.rand.Next(3) == 0)
{
int num111 = 4;
if (this.direction == 1)
{
num111 = -40;
}
int num112 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num111, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 76, 0f, 0f, 50, default(Color), 0.6f);
Main.dust[num112].fadeIn = 1.1f;
Main.dust[num112].noGravity = true;
Main.dust[num112].noLight = true;
Main.dust[num112].velocity *= 0.3f;
Main.dust[num112].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 34 && Main.rand.Next(3) == 0)
{
int num113 = 4;
if (this.direction == 1)
{
num113 = -40;
}
int num114 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num113, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 261, 0f, 0f, 50, default(Color), 0.6f);
Main.dust[num114].fadeIn = 1.1f;
Main.dust[num114].noGravity = true;
Main.dust[num114].noLight = true;
Main.dust[num114].velocity *= 0.3f;
Main.dust[num114].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 9 && Main.rand.Next(3) == 0)
{
int num115 = 8;
if (this.direction == 1)
{
num115 = -40;
}
int num116 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num115, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 6, 0f, 0f, 200, default(Color), 2f);
Main.dust[num116].noGravity = true;
Main.dust[num116].velocity *= 0.3f;
Main.dust[num116].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 29 && Main.rand.Next(3) == 0)
{
int num117 = 8;
if (this.direction == 1)
{
num117 = -40;
}
int num118 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num117, this.position.Y + (float)(this.height / 2) - 15f), 30, 30, 6, 0f, 0f, 100, default(Color), 2.4f);
Main.dust[num118].noGravity = true;
Main.dust[num118].velocity *= 0.3f;
if (Main.rand.Next(10) == 0)
{
Main.dust[num118].fadeIn = 2f;
}
Main.dust[num118].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 6)
{
if (Main.rand.Next(10) == 0)
{
int num119 = 4;
if (this.direction == 1)
{
num119 = -40;
}
int num120 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num119, this.position.Y + (float)(this.height / 2) - 12f), 30, 20, 55, 0f, 0f, 200, default(Color), 1f);
Main.dust[num120].velocity *= 0.3f;
Main.dust[num120].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
}
else if (this.wings == 5 && Main.rand.Next(6) == 0)
{
int num121 = 6;
if (this.direction == 1)
{
num121 = -30;
}
int num122 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num121, this.position.Y), 18, this.height, 58, 0f, 0f, 255, default(Color), 1.2f);
Main.dust[num122].velocity *= 0.3f;
Main.dust[num122].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
if (this.wings == 4)
{
this.rocketDelay2--;
if (this.rocketDelay2 <= 0)
{
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 13);
this.rocketDelay2 = 60;
}
int type3 = 6;
float scale3 = 1.5f;
int alpha3 = 100;
float x4 = this.position.X + (float)(this.width / 2) + 16f;
if (this.direction > 0)
{
x4 = this.position.X + (float)(this.width / 2) - 26f;
}
float num123 = this.position.Y + (float)this.height - 18f;
if (Main.rand.Next(2) == 1)
{
x4 = this.position.X + (float)(this.width / 2) + 8f;
if (this.direction > 0)
{
x4 = this.position.X + (float)(this.width / 2) - 20f;
}
num123 += 6f;
}
int num124 = Dust.NewDust(new Vector2(x4, num123), 8, 8, type3, 0f, 0f, alpha3, default(Color), scale3);
Dust expr_7C2F_cp_0 = Main.dust[num124];
expr_7C2F_cp_0.velocity.X = expr_7C2F_cp_0.velocity.X * 0.3f;
Dust expr_7C4D_cp_0 = Main.dust[num124];
expr_7C4D_cp_0.velocity.Y = expr_7C4D_cp_0.velocity.Y + 10f;
Main.dust[num124].noGravity = true;
Main.dust[num124].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
this.wingFrameCounter++;
if (this.wingFrameCounter > 4)
{
this.wingFrame++;
this.wingFrameCounter = 0;
if (this.wingFrame >= 3)
{
this.wingFrame = 0;
}
}
}
else if (this.wings != 22 && this.wings != 28)
{
if (this.wings == 30)
{
this.wingFrameCounter++;
int num125 = 5;
if (this.wingFrameCounter >= num125 * 3)
{
this.wingFrameCounter = 0;
}
this.wingFrame = 1 + this.wingFrameCounter / num125;
}
else if (this.wings == 34)
{
this.wingFrameCounter++;
int num126 = 7;
if (this.wingFrameCounter >= num126 * 6)
{
this.wingFrameCounter = 0;
}
this.wingFrame = this.wingFrameCounter / num126;
}
else if (this.wings == 26)
{
int num127 = 6;
if (this.direction == 1)
{
num127 = -30;
}
int num128 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num127, this.position.Y), 18, this.height, 217, 0f, 0f, 100, default(Color), 1.4f);
Main.dust[num128].noGravity = true;
Main.dust[num128].noLight = true;
Main.dust[num128].velocity /= 4f;
Main.dust[num128].velocity -= this.velocity;
Main.dust[num128].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
if (Main.rand.Next(2) == 0)
{
num127 = -24;
if (this.direction == 1)
{
num127 = 12;
}
float num129 = this.position.Y;
if (this.gravDir == -1f)
{
num129 += (float)(this.height / 2);
}
num128 = Dust.NewDust(new Vector2(this.position.X + (float)(this.width / 2) + (float)num127, num129), 12, this.height / 2, 217, 0f, 0f, 100, default(Color), 1.4f);
Main.dust[num128].noGravity = true;
Main.dust[num128].noLight = true;
Main.dust[num128].velocity /= 4f;
Main.dust[num128].velocity -= this.velocity;
Main.dust[num128].shader = GameShaders.Armor.GetSecondaryShader(this.cWings, this);
}
this.wingFrame = 2;
}
else if (this.wings != 24)
{
if (this.wings == 12)
{
this.wingFrame = 3;
}
else
{
this.wingFrame = 2;
}
}
}
}
this.velocity.Y = this.velocity.Y + this.gravity / 3f * this.gravDir;
if (this.gravDir == 1f)
{
if (this.velocity.Y > this.maxFallSpeed / 3f && !this.controlDown)
{
this.velocity.Y = this.maxFallSpeed / 3f;
}
}
else if (this.velocity.Y < -this.maxFallSpeed / 3f && !this.controlUp)
{
this.velocity.Y = -this.maxFallSpeed / 3f;
}
}
else if (this.cartRampTime <= 0)
{
this.velocity.Y = this.velocity.Y + this.gravity * this.gravDir;
}
else
{
this.cartRampTime--;
}
}
if (!this.mount.Active || this.mount.Type != 5)
{
if (this.gravDir == 1f)
{
if (this.velocity.Y > this.maxFallSpeed)
{
this.velocity.Y = this.maxFallSpeed;
}
if (this.slowFall && this.velocity.Y > this.maxFallSpeed / 3f && !this.controlDown)
{
this.velocity.Y = this.maxFallSpeed / 3f;
}
if (this.slowFall && this.velocity.Y > this.maxFallSpeed / 5f && this.controlUp)
{
this.velocity.Y = this.maxFallSpeed / 10f;
}
}
else
{
if (this.velocity.Y < -this.maxFallSpeed)
{
this.velocity.Y = -this.maxFallSpeed;
}
if (this.slowFall && this.velocity.Y < -this.maxFallSpeed / 3f && !this.controlDown)
{
this.velocity.Y = -this.maxFallSpeed / 3f;
}
if (this.slowFall && this.velocity.Y < -this.maxFallSpeed / 5f && this.controlUp)
{
this.velocity.Y = -this.maxFallSpeed / 10f;
}
}
}
}
}
if (this.mount.Active)
{
this.wingFrame = 0;
}
if ((this.wingsLogic == 22 || this.wingsLogic == 28 || this.wingsLogic == 30 || this.wingsLogic == 32 || this.wingsLogic == 33 || this.wingsLogic == 35) && this.controlDown && this.controlJump && this.wingTime > 0f && !this.merman)
{
this.velocity.Y = this.velocity.Y * 0.9f;
if (this.velocity.Y > -2f && this.velocity.Y < 1f)
{
this.velocity.Y = 1E-05f;
}
}
this.GrabItems(i);
if (!Main.mapFullscreen)
{
if (this.position.X / 16f - (float)Player.tileRangeX <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY - 2f >= (float)Player.tileTargetY)
{
if (Main.tile[Player.tileTargetX, Player.tileTargetY] == null)
{
Main.tile[Player.tileTargetX, Player.tileTargetY] = new Tile();
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].active())
{
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 79)
{
this.noThrow = 2;
this.showItemIcon = true;
int num130 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 36);
if (num130 == 0)
{
this.showItemIcon2 = 224;
}
else if (num130 == 1)
{
this.showItemIcon2 = 644;
}
else if (num130 == 2)
{
this.showItemIcon2 = 645;
}
else if (num130 == 3)
{
this.showItemIcon2 = 646;
}
else if (num130 == 4)
{
this.showItemIcon2 = 920;
}
else if (num130 == 5)
{
this.showItemIcon2 = 1470;
}
else if (num130 == 6)
{
this.showItemIcon2 = 1471;
}
else if (num130 == 7)
{
this.showItemIcon2 = 1472;
}
else if (num130 == 8)
{
this.showItemIcon2 = 1473;
}
else if (num130 == 9)
{
this.showItemIcon2 = 1719;
}
else if (num130 == 10)
{
this.showItemIcon2 = 1720;
}
else if (num130 == 11)
{
this.showItemIcon2 = 1721;
}
else if (num130 == 12)
{
this.showItemIcon2 = 1722;
}
else if (num130 >= 13 && num130 <= 18)
{
this.showItemIcon2 = 2066 + num130 - 13;
}
else if (num130 >= 19 && num130 <= 20)
{
this.showItemIcon2 = 2139 + num130 - 19;
}
else if (num130 == 21)
{
this.showItemIcon2 = 2231;
}
else if (num130 == 22)
{
this.showItemIcon2 = 2520;
}
else if (num130 == 23)
{
this.showItemIcon2 = 2538;
}
else if (num130 == 24)
{
this.showItemIcon2 = 2553;
}
else if (num130 == 25)
{
this.showItemIcon2 = 2568;
}
else if (num130 == 26)
{
this.showItemIcon2 = 2669;
}
else if (num130 == 27)
{
this.showItemIcon2 = 2811;
}
else if (num130 == 28)
{
this.showItemIcon2 = 3162;
}
else if (num130 == 29)
{
this.showItemIcon2 = 3164;
}
else if (num130 == 30)
{
this.showItemIcon2 = 3163;
}
else
{
this.showItemIcon2 = 646;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 33)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 105;
int num131 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 22);
if (num131 == 1)
{
this.showItemIcon2 = 1405;
}
if (num131 == 2)
{
this.showItemIcon2 = 1406;
}
if (num131 == 3)
{
this.showItemIcon2 = 1407;
}
if (num131 >= 4 && num131 <= 13)
{
this.showItemIcon2 = 2045 + num131 - 4;
}
if (num131 >= 14 && num131 <= 16)
{
this.showItemIcon2 = 2153 + num131 - 14;
}
if (num131 == 17)
{
this.showItemIcon2 = 2236;
}
if (num131 == 18)
{
this.showItemIcon2 = 2523;
}
if (num131 == 19)
{
this.showItemIcon2 = 2542;
}
if (num131 == 20)
{
this.showItemIcon2 = 2556;
}
if (num131 == 21)
{
this.showItemIcon2 = 2571;
}
if (num131 == 22)
{
this.showItemIcon2 = 2648;
}
if (num131 == 23)
{
this.showItemIcon2 = 2649;
}
if (num131 == 24)
{
this.showItemIcon2 = 2650;
}
if (num131 == 25)
{
this.showItemIcon2 = 2651;
}
else if (num131 == 26)
{
this.showItemIcon2 = 2818;
}
else if (num131 == 27)
{
this.showItemIcon2 = 3171;
}
else if (num131 == 28)
{
this.showItemIcon2 = 3173;
}
else if (num131 == 29)
{
this.showItemIcon2 = 3172;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 21)
{
Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY];
int num132 = Player.tileTargetX;
int num133 = Player.tileTargetY;
if (tile.frameX % 36 != 0)
{
num132--;
}
if (tile.frameY % 36 != 0)
{
num133--;
}
int num134 = Chest.FindChest(num132, num133);
this.showItemIcon2 = -1;
if (num134 < 0)
{
this.showItemIconText = Lang.chestType[0];
}
else
{
if (Main.chest[num134].name != "")
{
this.showItemIconText = Main.chest[num134].name;
}
else
{
this.showItemIconText = Lang.chestType[(int)(tile.frameX / 36)];
}
if (this.showItemIconText == Lang.chestType[(int)(tile.frameX / 36)])
{
this.showItemIcon2 = Chest.chestTypeToIcon[(int)(tile.frameX / 36)];
this.showItemIconText = "";
}
}
this.noThrow = 2;
this.showItemIcon = true;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 88)
{
Tile tile2 = Main.tile[Player.tileTargetX, Player.tileTargetY];
int num135 = Player.tileTargetX;
int num136 = Player.tileTargetY;
num135 -= (int)(tile2.frameX % 54 / 18);
if (tile2.frameY % 36 != 0)
{
num136--;
}
int num137 = Chest.FindChest(num135, num136);
this.showItemIcon2 = -1;
if (num137 < 0)
{
this.showItemIconText = Lang.dresserType[0];
}
else
{
if (Main.chest[num137].name != "")
{
this.showItemIconText = Main.chest[num137].name;
}
else
{
this.showItemIconText = Lang.dresserType[(int)(tile2.frameX / 54)];
}
if (this.showItemIconText == Lang.dresserType[(int)(tile2.frameX / 54)])
{
this.showItemIcon2 = Chest.dresserTypeToIcon[(int)(tile2.frameX / 54)];
this.showItemIconText = "";
}
}
this.noThrow = 2;
this.showItemIcon = true;
if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY > 0)
{
this.showItemIcon2 = 269;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 10 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 11)
{
this.noThrow = 2;
this.showItemIcon = true;
int num138 = (int)Main.tile[Player.tileTargetX, Player.tileTargetY].frameY;
int num139 = 0;
while (num138 >= 54)
{
num138 -= 54;
num139++;
}
if (num139 == 0)
{
this.showItemIcon2 = 25;
}
else if (num139 == 9)
{
this.showItemIcon2 = 837;
}
else if (num139 == 10)
{
this.showItemIcon2 = 912;
}
else if (num139 == 11)
{
this.showItemIcon2 = 1141;
}
else if (num139 == 12)
{
this.showItemIcon2 = 1137;
}
else if (num139 == 13)
{
this.showItemIcon2 = 1138;
}
else if (num139 == 14)
{
this.showItemIcon2 = 1139;
}
else if (num139 == 15)
{
this.showItemIcon2 = 1140;
}
else if (num139 == 16)
{
this.showItemIcon2 = 1411;
}
else if (num139 == 17)
{
this.showItemIcon2 = 1412;
}
else if (num139 == 18)
{
this.showItemIcon2 = 1413;
}
else if (num139 == 19)
{
this.showItemIcon2 = 1458;
}
else if (num139 >= 20 && num139 <= 23)
{
this.showItemIcon2 = 1709 + num139 - 20;
}
else if (num139 == 24)
{
this.showItemIcon2 = 1793;
}
else if (num139 == 25)
{
this.showItemIcon2 = 1815;
}
else if (num139 == 26)
{
this.showItemIcon2 = 1924;
}
else if (num139 == 27)
{
this.showItemIcon2 = 2044;
}
else if (num139 == 28)
{
this.showItemIcon2 = 2265;
}
else if (num139 == 29)
{
this.showItemIcon2 = 2528;
}
else if (num139 == 30)
{
this.showItemIcon2 = 2561;
}
else if (num139 == 31)
{
this.showItemIcon2 = 2576;
}
else if (num139 == 32)
{
this.showItemIcon2 = 2815;
}
else if (num139 == 33)
{
this.showItemIcon2 = 3129;
}
else if (num139 == 34)
{
this.showItemIcon2 = 3131;
}
else if (num139 == 35)
{
this.showItemIcon2 = 3130;
}
else if (num139 >= 4 && num139 <= 8)
{
this.showItemIcon2 = 812 + num139;
}
else
{
this.showItemIcon2 = 649 + num139;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 104)
{
this.noThrow = 2;
this.showItemIcon = true;
switch (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 36)
{
case 0:
this.showItemIcon2 = 359;
break;
case 1:
this.showItemIcon2 = 2237;
break;
case 2:
this.showItemIcon2 = 2238;
break;
case 3:
this.showItemIcon2 = 2239;
break;
case 4:
this.showItemIcon2 = 2240;
break;
case 5:
this.showItemIcon2 = 2241;
break;
case 6:
this.showItemIcon2 = 2560;
break;
case 7:
this.showItemIcon2 = 2575;
break;
case 8:
this.showItemIcon2 = 2591;
break;
case 9:
this.showItemIcon2 = 2592;
break;
case 10:
this.showItemIcon2 = 2593;
break;
case 11:
this.showItemIcon2 = 2594;
break;
case 12:
this.showItemIcon2 = 2595;
break;
case 13:
this.showItemIcon2 = 2596;
break;
case 14:
this.showItemIcon2 = 2597;
break;
case 15:
this.showItemIcon2 = 2598;
break;
case 16:
this.showItemIcon2 = 2599;
break;
case 17:
this.showItemIcon2 = 2600;
break;
case 18:
this.showItemIcon2 = 2601;
break;
case 19:
this.showItemIcon2 = 2602;
break;
case 20:
this.showItemIcon2 = 2603;
break;
case 21:
this.showItemIcon2 = 2604;
break;
case 22:
this.showItemIcon2 = 2605;
break;
case 23:
this.showItemIcon2 = 2606;
break;
case 24:
this.showItemIcon2 = 2809;
break;
case 25:
this.showItemIcon2 = 3126;
break;
case 26:
this.showItemIcon2 = 3128;
break;
case 27:
this.showItemIcon2 = 3127;
break;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 356)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 3064;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 377)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 3198;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 209)
{
this.noThrow = 2;
this.showItemIcon = true;
if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < 72)
{
this.showItemIcon2 = 928;
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < 144)
{
this.showItemIcon2 = 1337;
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < 216)
{
this.showItemIcon2 = 3369;
}
int num140;
for (num140 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18); num140 >= 4; num140 -= 4)
{
}
if (num140 < 2)
{
this.showItemIconR = true;
}
else
{
this.showItemIconR = false;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 216)
{
this.noThrow = 2;
this.showItemIcon = true;
int num141 = (int)Main.tile[Player.tileTargetX, Player.tileTargetY].frameY;
int num142 = 0;
while (num141 >= 40)
{
num141 -= 40;
num142++;
}
this.showItemIcon2 = 970 + num142;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 387 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 386)
{
this.noThrow = 2;
this.showItemIcon = true;
int num143 = 0;
int num144 = 0;
WorldGen.GetTopLeftAndStyles(ref num143, ref num144, 2, 1 + (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 386).ToInt(), 18, 18);
this.showItemIcon2 = 3239;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 389 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 388)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 3240;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 335)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 2700;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 410)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 3536 + Math.Min((int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 36), 3);
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 411 && Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < 36)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 3545;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 338)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 2738;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 219 && (this.inventory[this.selectedItem].itemId == 424 || this.inventory[this.selectedItem].itemId == 1103))
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = this.inventory[this.selectedItem].itemId;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 212)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 949;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 314 && this.gravDir == 1f)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 2343;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 215)
{
this.noThrow = 2;
this.showItemIcon = true;
int num145 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 54);
if (num145 == 0)
{
this.showItemIcon2 = 966;
}
else if (num145 == 6)
{
this.showItemIcon2 = 3050;
}
else
{
this.showItemIcon2 = 3046 + num145 - 1;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 4)
{
this.noThrow = 2;
this.showItemIcon = true;
int num146 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 22);
if (num146 == 0)
{
this.showItemIcon2 = 8;
}
else if (num146 == 8)
{
this.showItemIcon2 = 523;
}
else if (num146 == 9)
{
this.showItemIcon2 = 974;
}
else if (num146 == 10)
{
this.showItemIcon2 = 1245;
}
else if (num146 == 11)
{
this.showItemIcon2 = 1333;
}
else if (num146 == 12)
{
this.showItemIcon2 = 2274;
}
else if (num146 == 13)
{
this.showItemIcon2 = 3004;
}
else if (num146 == 14)
{
this.showItemIcon2 = 3045;
}
else if (num146 == 15)
{
this.showItemIcon2 = 3114;
}
else
{
this.showItemIcon2 = 426 + num146;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 13)
{
this.noThrow = 2;
this.showItemIcon = true;
int num147 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
if (num147 == 1)
{
this.showItemIcon2 = 28;
}
else if (num147 == 2)
{
this.showItemIcon2 = 110;
}
else if (num147 == 3)
{
this.showItemIcon2 = 350;
}
else if (num147 == 4)
{
this.showItemIcon2 = 351;
}
else if (num147 == 5)
{
this.showItemIcon2 = 2234;
}
else if (num147 == 6)
{
this.showItemIcon2 = 2244;
}
else if (num147 == 7)
{
this.showItemIcon2 = 2257;
}
else if (num147 == 8)
{
this.showItemIcon2 = 2258;
}
else
{
this.showItemIcon2 = 31;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 29)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 87;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 97)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 346;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 49)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 148;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 174)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 713;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 50)
{
this.noThrow = 2;
if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX == 90)
{
this.showItemIcon = true;
this.showItemIcon2 = 165;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 139)
{
this.noThrow = 2;
int num148 = Player.tileTargetX;
int num149 = Player.tileTargetY;
int num150 = 0;
for (int num151 = (int)(Main.tile[num148, num149].frameY / 18); num151 >= 2; num151 -= 2)
{
num150++;
}
this.showItemIcon = true;
if (num150 == 28)
{
this.showItemIcon2 = 1963;
}
else if (num150 == 29)
{
this.showItemIcon2 = 1964;
}
else if (num150 == 30)
{
this.showItemIcon2 = 1965;
}
else if (num150 == 31)
{
this.showItemIcon2 = 2742;
}
else if (num150 == 32)
{
this.showItemIcon2 = 3044;
}
else if (num150 == 33)
{
this.showItemIcon2 = 3235;
}
else if (num150 == 34)
{
this.showItemIcon2 = 3236;
}
else if (num150 == 35)
{
this.showItemIcon2 = 3237;
}
else if (num150 == 36)
{
this.showItemIcon2 = 3370;
}
else if (num150 == 37)
{
this.showItemIcon2 = 3371;
}
else if (num150 >= 13)
{
this.showItemIcon2 = 1596 + num150 - 13;
}
else
{
this.showItemIcon2 = 562 + num150;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 207)
{
this.noThrow = 2;
int num152 = Player.tileTargetX;
int num153 = Player.tileTargetY;
int num154 = 0;
for (int num155 = (int)(Main.tile[num152, num153].frameX / 18); num155 >= 2; num155 -= 2)
{
num154++;
}
this.showItemIcon = true;
if (num154 == 0)
{
this.showItemIcon2 = 909;
}
else if (num154 == 1)
{
this.showItemIcon2 = 910;
}
else if (num154 == 2)
{
this.showItemIcon2 = 940;
}
else if (num154 == 3)
{
this.showItemIcon2 = 941;
}
else if (num154 == 4)
{
this.showItemIcon2 = 942;
}
else if (num154 == 5)
{
this.showItemIcon2 = 943;
}
else if (num154 == 6)
{
this.showItemIcon2 = 944;
}
else if (num154 == 7)
{
this.showItemIcon2 = 945;
}
}
if (Main.tileSign[(int)Main.tile[Player.tileTargetX, Player.tileTargetY].type])
{
this.noThrow = 2;
int num156 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
int num157 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
num156 %= 2;
int num158 = Player.tileTargetX - num156;
int num159 = Player.tileTargetY - num157;
Main.signBubble = true;
Main.signX = num158 * 16 + 16;
Main.signY = num159 * 16;
int num160 = Sign.ReadSign(num158, num159, false);
if (num160 != -1)
{
Main.signHover = num160;
}
if (num160 != -1)
{
Main.signHover = num160;
this.showItemIcon = false;
this.showItemIcon2 = -1;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 237)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 1293;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 125)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 487;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 354)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 2999;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 287)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 2177;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 132)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 513;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 136)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = 538;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 144)
{
this.noThrow = 2;
this.showItemIcon = true;
this.showItemIcon2 = (int)(583 + Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
}
if (this.controlUseTile)
{
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 212 && this.launcherWait <= 0)
{
int num161 = Player.tileTargetX;
int num162 = Player.tileTargetY;
bool flag25 = false;
for (int num163 = 0; num163 < 58; num163++)
{
if (this.inventory[num163].itemId == 949 && this.inventory[num163].stack > 0)
{
this.inventory[num163].stack--;
if (this.inventory[num163].stack <= 0)
{
this.inventory[num163].SetDefaults(0, false);
}
flag25 = true;
break;
}
}
if (flag25)
{
this.launcherWait = 10;
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 11);
int num164 = (int)(Main.tile[num161, num162].frameX / 18);
int num165 = 0;
while (num164 >= 3)
{
num165++;
num164 -= 3;
}
num164 = num161 - num164;
int num166;
for (num166 = (int)(Main.tile[num161, num162].frameY / 18); num166 >= 3; num166 -= 3)
{
}
num166 = num162 - num166;
float num167 = 12f + (float)Main.rand.Next(450) * 0.01f;
float num168 = (float)Main.rand.Next(85, 105);
float num169 = (float)Main.rand.Next(-35, 11);
int type4 = 166;
int damage2 = 35;
float knockBack = 3.5f;
Vector2 vector3 = new Vector2((float)((num164 + 2) * 16 - 8), (float)((num166 + 2) * 16 - 8));
if (num165 == 0)
{
num168 *= -1f;
vector3.X -= 12f;
}
else
{
vector3.X += 12f;
}
float num170 = num168;
float num171 = num169;
float num172 = (float)Math.Sqrt((double)(num170 * num170 + num171 * num171));
num172 = num167 / num172;
num170 *= num172;
num171 *= num172;
Projectile.NewProjectile(vector3.X, vector3.Y, num170, num171, type4, damage2, knockBack, Main.myPlayer, 0f, 0f);
}
}
if (this.releaseUseTile)
{
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 132 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 136 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 144)
{
Wiring.HitSwitch(Player.tileTargetX, Player.tileTargetY);
NetMessage.SendData(59, -1, -1, "", Player.tileTargetX, (float)Player.tileTargetY, 0f, 0f, 0, 0, 0);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 139)
{
Main.PlaySound(28, Player.tileTargetX * 16, Player.tileTargetY * 16, 0);
WorldGen.SwitchMB(Player.tileTargetX, Player.tileTargetY);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 215)
{
Main.PlaySound(28, Player.tileTargetX * 16, Player.tileTargetY * 16, 0);
int num173 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX % 54 / 18);
int num174 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY % 36 / 18);
int num175 = Player.tileTargetX - num173;
int num176 = Player.tileTargetY - num174;
int num177 = 36;
if (Main.tile[num175, num176].frameY >= 36)
{
num177 = -36;
}
for (int num178 = num175; num178 < num175 + 3; num178++)
{
for (int num179 = num176; num179 < num176 + 2; num179++)
{
Main.tile[num178, num179].frameY = (short)((int)Main.tile[num178, num179].frameY + num177);
}
}
NetMessage.SendTileSquare(-1, num175 + 1, num176 + 1, 3);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 207)
{
Main.PlaySound(28, Player.tileTargetX * 16, Player.tileTargetY * 16, 0);
WorldGen.SwitchFountain(Player.tileTargetX, Player.tileTargetY);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 410)
{
Main.PlaySound(28, Player.tileTargetX * 16, Player.tileTargetY * 16, 0);
WorldGen.SwitchMonolith(Player.tileTargetX, Player.tileTargetY);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 216)
{
WorldGen.LaunchRocket(Player.tileTargetX, Player.tileTargetY);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 386 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 387)
{
bool value3 = Main.tile[Player.tileTargetX, Player.tileTargetY].type == 387;
int num180 = WorldGen.ShiftTrapdoor(Player.tileTargetX, Player.tileTargetY, (float)(Player.tileTargetY * 16) > base.Center.Y, -1).ToInt();
if (num180 == 0)
{
num180 = -WorldGen.ShiftTrapdoor(Player.tileTargetX, Player.tileTargetY, (float)(Player.tileTargetY * 16) <= base.Center.Y, -1).ToInt();
}
if (num180 != 0)
{
NetMessage.SendData(19, -1, -1, "", 2 + value3.ToInt(), (float)Player.tileTargetX, (float)Player.tileTargetY, (float)(num180 * Math.Sign((float)(Player.tileTargetY * 16) - base.Center.Y)), 0, 0, 0);
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 388 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 389)
{
bool flag26 = Main.tile[Player.tileTargetX, Player.tileTargetY].type == 389;
WorldGen.ShiftTallGate(Player.tileTargetX, Player.tileTargetY, flag26);
NetMessage.SendData(19, -1, -1, "", 4 + flag26.ToInt(), (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 335)
{
WorldGen.LaunchRocketSmall(Player.tileTargetX, Player.tileTargetY);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 411 && Main.tile[Player.tileTargetX, Player.tileTargetY].frameX < 36)
{
Wiring.HitSwitch(Player.tileTargetX, Player.tileTargetY);
NetMessage.SendData(59, -1, -1, "", Player.tileTargetX, (float)Player.tileTargetY, 0f, 0f, 0, 0, 0);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 338)
{
int num181 = Player.tileTargetX;
int num182 = Player.tileTargetY;
if (Main.tile[num181, num182].frameY == 18)
{
num182--;
}
bool flag27 = false;
for (int num183 = 0; num183 < 1000; num183++)
{
if (Main.projectile[num183].active && Main.projectile[num183].aiStyle == 73 && Main.projectile[num183].ai[0] == (float)num181 && Main.projectile[num183].ai[1] == (float)num182)
{
flag27 = true;
break;
}
}
if (!flag27)
{
Projectile.NewProjectile((float)(num181 * 16 + 8), (float)(num182 * 16 + 2), 0f, 0f, 419 + Main.rand.Next(4), 0, 0f, this.whoAmI, (float)num181, (float)num182);
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 4 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 13 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 33 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 49 || (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 50 && Main.tile[Player.tileTargetX, Player.tileTargetY].frameX == 90) || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 174)
{
WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, false, false, false);
if (Main.netMode == 1)
{
NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 334)
{
if (this.ItemFitsWeaponRack(this.inventory[this.selectedItem]))
{
this.PlaceWeapon(Player.tileTargetX, Player.tileTargetY);
}
else
{
int num184 = Player.tileTargetX;
int num185 = Player.tileTargetY;
if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY == 0)
{
num185++;
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY == 36)
{
num185--;
}
int frameX = (int)Main.tile[Player.tileTargetX, num185].frameX;
int num186 = (int)Main.tile[Player.tileTargetX, num185].frameX;
int num187 = 0;
while (num186 >= 5000)
{
num186 -= 5000;
num187++;
}
if (num187 != 0)
{
num186 = (num187 - 1) * 18;
}
num186 %= 54;
if (num186 == 18)
{
frameX = (int)Main.tile[Player.tileTargetX - 1, num185].frameX;
num184--;
}
if (num186 == 36)
{
frameX = (int)Main.tile[Player.tileTargetX - 2, num185].frameX;
num184 -= 2;
}
if (frameX >= 5000)
{
WorldGen.KillTile(Player.tileTargetX, num185, true, false, false);
if (Main.netMode == 1)
{
NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)num185, 1f, 0, 0, 0);
}
}
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 395)
{
if (this.ItemFitsItemFrame(this.inventory[this.selectedItem]) && !this.inventory[this.selectedItem].favorited)
{
this.PlaceItemInFrame(Player.tileTargetX, Player.tileTargetY);
}
else
{
int num188 = Player.tileTargetX;
int num189 = Player.tileTargetY;
if (Main.tile[num188, num189].frameX % 36 != 0)
{
num188--;
}
if (Main.tile[num188, num189].frameY % 36 != 0)
{
num189--;
}
int num190 = TEItemFrame.Find(num188, num189);
if (num190 != -1 && ((TEItemFrame)TileEntity.ByID[num190]).item.stack > 0)
{
WorldGen.KillTile(Player.tileTargetX, num189, true, false, false);
if (Main.netMode == 1)
{
NetMessage.SendData(17, -1, -1, "", 0, (float)Player.tileTargetX, (float)num189, 1f, 0, 0, 0);
}
}
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 125)
{
this.AddBuff(29, 36000, true);
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 4);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 377)
{
this.AddBuff(159, 36000, true);
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 37);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 354)
{
this.AddBuff(150, 36000, true);
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 4);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 287)
{
this.AddBuff(93, 36000, true);
Main.PlaySound(7, (int)this.position.X, (int)this.position.Y, 1);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 356)
{
if (!Main.fastForwardTime && (Main.netMode == 1 || Main.sundialCooldown == 0))
{
Main.Sundialing();
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, 4);
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 79)
{
int num191 = Player.tileTargetX;
int num192 = Player.tileTargetY;
num191 += (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18 * -1);
if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameX >= 72)
{
num191 += 4;
num191++;
}
else
{
num191 += 2;
}
int num193 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
int num194 = 0;
while (num193 > 1)
{
num193 -= 2;
num194++;
}
num192 -= num193;
num192 += 2;
this.FindSpawn();
if (this.SpawnX == num191 && this.SpawnY == num192)
{
this.RemoveSpawn();
Main.NewText("Spawn point removed!", 255, 240, 20, false);
}
else if (Player.CheckSpawn(num191, num192))
{
this.ChangeSpawn(num191, num192);
Main.NewText("Spawn point set!", 255, 240, 20, false);
}
}
else if (Main.tileSign[(int)Main.tile[Player.tileTargetX, Player.tileTargetY].type])
{
bool flag28 = true;
if (this.sign >= 0)
{
int num195 = Sign.ReadSign(Player.tileTargetX, Player.tileTargetY, true);
if (num195 == this.sign)
{
this.sign = -1;
Main.npcChatText = "";
Main.editSign = false;
Main.PlaySound(11, -1, -1, 1);
flag28 = false;
}
}
if (flag28)
{
if (Main.netMode == 0)
{
this.talkNPC = -1;
Main.npcChatCornerItem = 0;
Main.playerInventory = false;
Main.editSign = false;
Main.PlaySound(10, -1, -1, 1);
int num196 = Sign.ReadSign(Player.tileTargetX, Player.tileTargetY, true);
this.sign = num196;
Main.npcChatText = Main.sign[num196].text;
}
else
{
int num197 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
int num198 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
while (num197 > 1)
{
num197 -= 2;
}
int num199 = Player.tileTargetX - num197;
int num200 = Player.tileTargetY - num198;
if (Main.tileSign[(int)Main.tile[num199, num200].type])
{
NetMessage.SendData(46, -1, -1, "", num199, (float)num200, 0f, 0f, 0, 0, 0);
}
}
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 104)
{
string text = "AM";
double num201 = Main.time;
if (!Main.dayTime)
{
num201 += 54000.0;
}
num201 = num201 / 86400.0 * 24.0;
double num202 = 7.5;
num201 = num201 - num202 - 12.0;
if (num201 < 0.0)
{
num201 += 24.0;
}
if (num201 >= 12.0)
{
text = "PM";
}
int num203 = (int)num201;
double num204 = num201 - (double)num203;
num204 = (double)((int)(num204 * 60.0));
string text2 = string.Concat(num204);
if (num204 < 10.0)
{
text2 = "0" + text2;
}
if (num203 > 12)
{
num203 -= 12;
}
if (num203 == 0)
{
num203 = 12;
}
string newText = string.Concat(new object[]
{
"Time: ",
num203,
":",
text2,
" ",
text
});
Main.NewText(newText, 255, 240, 20, false);
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 237)
{
bool flag29 = false;
if (!NPC.AnyNPCs(245) && Main.hardMode && NPC.downedPlantBoss)
{
for (int num205 = 0; num205 < 58; num205++)
{
if (this.inventory[num205].itemId == 1293)
{
this.inventory[num205].stack--;
if (this.inventory[num205].stack <= 0)
{
this.inventory[num205].SetDefaults(0, false);
}
flag29 = true;
break;
}
}
}
if (flag29)
{
Main.PlaySound(15, (int)this.position.X, (int)this.position.Y, 0);
if (Main.netMode != 1)
{
NPC.SpawnOnPlayer(i, 245);
}
else
{
NetMessage.SendData(61, -1, -1, "", this.whoAmI, 245f, 0f, 0f, 0, 0, 0);
}
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 10)
{
int num206 = Player.tileTargetX;
int num207 = Player.tileTargetY;
if (Main.tile[num206, num207].frameY >= 594 && Main.tile[num206, num207].frameY <= 646)
{
int num208 = 1141;
for (int num209 = 0; num209 < 58; num209++)
{
if (this.inventory[num209].itemId == num208 && this.inventory[num209].stack > 0)
{
this.inventory[num209].stack--;
if (this.inventory[num209].stack <= 0)
{
this.inventory[num209] = new Item();
}
WorldGen.UnlockDoor(num206, num207);
if (Main.netMode == 1)
{
NetMessage.SendData(52, -1, -1, "", this.whoAmI, 2f, (float)num206, (float)num207, 0, 0, 0);
}
}
}
}
else
{
WorldGen.OpenDoor(Player.tileTargetX, Player.tileTargetY, this.direction);
NetMessage.SendData(19, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)this.direction, 0, 0, 0);
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 11 && WorldGen.CloseDoor(Player.tileTargetX, Player.tileTargetY, false))
{
NetMessage.SendData(19, -1, -1, "", 1, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)this.direction, 0, 0, 0);
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 88)
{
if (Main.tile[Player.tileTargetX, Player.tileTargetY].frameY == 0)
{
Main.CancelClothesWindow(true);
Main.mouseRightRelease = false;
int num210 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
num210 %= 3;
num210 = Player.tileTargetX - num210;
int num211 = Player.tileTargetY - (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
if (this.sign > -1)
{
Main.PlaySound(11, -1, -1, 1);
this.sign = -1;
Main.editSign = false;
Main.npcChatText = string.Empty;
}
if (Main.editChest)
{
Main.PlaySound(12, -1, -1, 1);
Main.editChest = false;
Main.npcChatText = string.Empty;
}
if (this.editedChestName)
{
NetMessage.SendData(33, -1, -1, Main.chest[this.chest].name, this.chest, 1f, 0f, 0f, 0, 0, 0);
this.editedChestName = false;
}
if (Main.netMode == 1)
{
if (num210 == this.chestX && num211 == this.chestY && this.chest != -1)
{
this.chest = -1;
Main.PlaySound(11, -1, -1, 1);
}
else
{
NetMessage.SendData(31, -1, -1, "", num210, (float)num211, 0f, 0f, 0, 0, 0);
Main.stackSplit = 600;
}
}
else
{
this.flyingPigChest = -1;
int num212 = Chest.FindChest(num210, num211);
if (num212 != -1)
{
Main.stackSplit = 600;
if (num212 == this.chest)
{
this.chest = -1;
Main.PlaySound(11, -1, -1, 1);
}
else if (num212 != this.chest && this.chest == -1)
{
this.chest = num212;
Main.playerInventory = true;
Main.recBigList = false;
Main.PlaySound(10, -1, -1, 1);
this.chestX = num210;
this.chestY = num211;
}
else
{
this.chest = num212;
Main.playerInventory = true;
Main.recBigList = false;
Main.PlaySound(12, -1, -1, 1);
this.chestX = num210;
this.chestY = num211;
}
Recipe.FindRecipes();
}
}
}
else
{
Main.playerInventory = false;
this.chest = -1;
Main.dresserX = Player.tileTargetX;
Main.dresserY = Player.tileTargetY;
Main.OpenClothesWindow();
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 209)
{
WorldGen.SwitchCannon(Player.tileTargetX, Player.tileTargetY);
}
else if ((Main.tile[Player.tileTargetX, Player.tileTargetY].type == 21 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 29 || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 97) && this.talkNPC == -1)
{
Main.mouseRightRelease = false;
int num213 = 0;
int num214;
for (num214 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18); num214 > 1; num214 -= 2)
{
}
num214 = Player.tileTargetX - num214;
int num215 = Player.tileTargetY - (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 29)
{
num213 = 1;
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 97)
{
num213 = 2;
}
if (this.sign > -1)
{
Main.PlaySound(11, -1, -1, 1);
this.sign = -1;
Main.editSign = false;
Main.npcChatText = string.Empty;
}
if (Main.editChest)
{
Main.PlaySound(12, -1, -1, 1);
Main.editChest = false;
Main.npcChatText = string.Empty;
}
if (this.editedChestName)
{
NetMessage.SendData(33, -1, -1, Main.chest[this.chest].name, this.chest, 1f, 0f, 0f, 0, 0, 0);
this.editedChestName = false;
}
if (Main.netMode == 1 && num213 == 0 && (Main.tile[num214, num215].frameX < 72 || Main.tile[num214, num215].frameX > 106) && (Main.tile[num214, num215].frameX < 144 || Main.tile[num214, num215].frameX > 178) && (Main.tile[num214, num215].frameX < 828 || Main.tile[num214, num215].frameX > 1006) && (Main.tile[num214, num215].frameX < 1296 || Main.tile[num214, num215].frameX > 1330) && (Main.tile[num214, num215].frameX < 1368 || Main.tile[num214, num215].frameX > 1402) && (Main.tile[num214, num215].frameX < 1440 || Main.tile[num214, num215].frameX > 1474))
{
if (num214 == this.chestX && num215 == this.chestY && this.chest != -1)
{
this.chest = -1;
Main.PlaySound(11, -1, -1, 1);
}
else
{
NetMessage.SendData(31, -1, -1, "", num214, (float)num215, 0f, 0f, 0, 0, 0);
Main.stackSplit = 600;
}
}
else
{
int num216 = -1;
if (num213 == 1)
{
num216 = -2;
}
else if (num213 == 2)
{
num216 = -3;
}
else
{
bool flag30 = false;
if (Chest.isLocked(num214, num215))
{
int num217 = 327;
if (Main.tile[num214, num215].frameX >= 144 && Main.tile[num214, num215].frameX <= 178)
{
num217 = 329;
}
if (Main.tile[num214, num215].frameX >= 828 && Main.tile[num214, num215].frameX <= 1006)
{
int num218 = (int)(Main.tile[num214, num215].frameX / 18);
int num219 = 0;
while (num218 >= 2)
{
num218 -= 2;
num219++;
}
num219 -= 23;
num217 = 1533 + num219;
}
flag30 = true;
for (int num220 = 0; num220 < 58; num220++)
{
if (this.inventory[num220].itemId == num217 && this.inventory[num220].stack > 0 && Chest.Unlock(num214, num215))
{
if (num217 != 329)
{
this.inventory[num220].stack--;
if (this.inventory[num220].stack <= 0)
{
this.inventory[num220] = new Item();
}
}
if (Main.netMode == 1)
{
NetMessage.SendData(52, -1, -1, "", this.whoAmI, 1f, (float)num214, (float)num215, 0, 0, 0);
}
}
}
}
if (!flag30)
{
num216 = Chest.FindChest(num214, num215);
}
}
if (num216 != -1)
{
Main.stackSplit = 600;
if (num216 == this.chest)
{
this.chest = -1;
Main.PlaySound(11, -1, -1, 1);
}
else if (num216 != this.chest && this.chest == -1)
{
this.chest = num216;
Main.playerInventory = true;
Main.recBigList = false;
Main.PlaySound(10, -1, -1, 1);
this.chestX = num214;
this.chestY = num215;
if (Main.tile[num214, num215].frameX >= 36 && Main.tile[num214, num215].frameX < 72)
{
AchievementsHelper.HandleSpecialEvent(this, 16);
}
}
else
{
this.chest = num216;
Main.playerInventory = true;
Main.recBigList = false;
Main.PlaySound(12, -1, -1, 1);
this.chestX = num214;
this.chestY = num215;
}
Recipe.FindRecipes();
}
}
}
else if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 314 && this.gravDir == 1f)
{
bool flag31 = true;
if (this.mount.Active)
{
if (this.mount.Cart)
{
flag31 = false;
}
else
{
this.mount.Dismount(this);
}
}
if (flag31)
{
Vector2 vector4 = new Vector2((float)Main.mouseX + Main.screenPosition.X, (float)Main.mouseY + Main.screenPosition.Y);
if (this.direction > 0)
{
this.minecartLeft = false;
}
else
{
this.minecartLeft = true;
}
this.grappling[0] = -1;
this.grapCount = 0;
for (int num221 = 0; num221 < 1000; num221++)
{
if (Main.projectile[num221].active && Main.projectile[num221].owner == this.whoAmI && Main.projectile[num221].aiStyle == 7)
{
Main.projectile[num221].Kill();
}
}
Projectile.NewProjectile(vector4.X, vector4.Y, 0f, 0f, 403, 0, 0f, this.whoAmI, 0f, 0f);
}
}
}
this.releaseUseTile = false;
}
else
{
this.releaseUseTile = true;
}
}
}
else
{
if (Main.tile[Player.tileTargetX, Player.tileTargetY] == null)
{
Main.tile[Player.tileTargetX, Player.tileTargetY] = new Tile();
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 21)
{
Tile tile3 = Main.tile[Player.tileTargetX, Player.tileTargetY];
int num222 = Player.tileTargetX;
int num223 = Player.tileTargetY;
if (tile3.frameX % 36 != 0)
{
num222--;
}
if (tile3.frameY % 36 != 0)
{
num223--;
}
int num224 = Chest.FindChest(num222, num223);
this.showItemIcon2 = -1;
if (num224 < 0)
{
this.showItemIconText = Lang.chestType[0];
}
else
{
if (Main.chest[num224].name != "")
{
this.showItemIconText = Main.chest[num224].name;
}
else
{
this.showItemIconText = Lang.chestType[(int)(tile3.frameX / 36)];
}
if (this.showItemIconText == Lang.chestType[(int)(tile3.frameX / 36)])
{
this.showItemIcon2 = Chest.chestTypeToIcon[(int)(tile3.frameX / 36)];
this.showItemIconText = "";
}
}
this.noThrow = 2;
this.showItemIcon = true;
if (this.showItemIconText == "")
{
this.showItemIcon = false;
this.showItemIcon2 = 0;
}
}
if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 88)
{
Tile tile4 = Main.tile[Player.tileTargetX, Player.tileTargetY];
int num225 = Player.tileTargetX;
int num226 = Player.tileTargetY;
num225 -= (int)(tile4.frameX % 54 / 18);
if (tile4.frameY % 36 != 0)
{
num226--;
}
int num227 = Chest.FindChest(num225, num226);
this.showItemIcon2 = -1;
if (num227 < 0)
{
this.showItemIconText = Lang.dresserType[0];
}
else
{
if (Main.chest[num227].name != "")
{
this.showItemIconText = Main.chest[num227].name;
}
else
{
this.showItemIconText = Lang.dresserType[(int)(tile4.frameX / 54)];
}
if (this.showItemIconText == Lang.dresserType[(int)(tile4.frameX / 54)])
{
this.showItemIcon2 = Chest.dresserTypeToIcon[(int)(tile4.frameX / 54)];
this.showItemIconText = "";
}
}
this.noThrow = 2;
this.showItemIcon = true;
if (this.showItemIconText == "")
{
this.showItemIcon = false;
this.showItemIcon2 = 0;
}
}
if (Main.tileSign[(int)Main.tile[Player.tileTargetX, Player.tileTargetY].type])
{
this.noThrow = 2;
int num228 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameX / 18);
int num229 = (int)(Main.tile[Player.tileTargetX, Player.tileTargetY].frameY / 18);
num228 %= 2;
int num230 = Player.tileTargetX - num228;
int num231 = Player.tileTargetY - num229;
Main.signBubble = true;
Main.signX = num230 * 16 + 16;
Main.signY = num231 * 16;
int num232 = Sign.ReadSign(num230, num231, true);
if (num232 != -1)
{
Main.signHover = num232;
this.showItemIcon = false;
this.showItemIcon2 = -1;
}
}
}
}
if (this.tongued)
{
bool flag32 = false;
if (Main.wof >= 0)
{
float num233 = Main.npc[Main.wof].position.X + (float)(Main.npc[Main.wof].width / 2);
num233 += (float)(Main.npc[Main.wof].direction * 200);
float num234 = Main.npc[Main.wof].position.Y + (float)(Main.npc[Main.wof].height / 2);
Vector2 vector5 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
float num235 = num233 - vector5.X;
float num236 = num234 - vector5.Y;
float num237 = (float)Math.Sqrt((double)(num235 * num235 + num236 * num236));
float num238 = 11f;
float num239;
if (num237 > num238)
{
num239 = num238 / num237;
}
else
{
num239 = 1f;
flag32 = true;
}
num235 *= num239;
num236 *= num239;
this.velocity.X = num235;
this.velocity.Y = num236;
}
else
{
flag32 = true;
}
if (flag32 && Main.myPlayer == this.whoAmI)
{
for (int num240 = 0; num240 < 22; num240++)
{
if (this.buffType[num240] == 38)
{
this.DelBuff(num240);
}
}
}
}
if (Main.myPlayer == this.whoAmI)
{
this.WOFTongue();
if (this.controlHook)
{
if (this.releaseHook)
{
this.QuickGrapple();
}
this.releaseHook = false;
}
else
{
this.releaseHook = true;
}
if (this.talkNPC >= 0)
{
Rectangle rectangle = new Rectangle((int)(this.position.X + (float)(this.width / 2) - (float)(Player.tileRangeX * 16)), (int)(this.position.Y + (float)(this.height / 2) - (float)(Player.tileRangeY * 16)), Player.tileRangeX * 16 * 2, Player.tileRangeY * 16 * 2);
Rectangle value4 = new Rectangle((int)Main.npc[this.talkNPC].position.X, (int)Main.npc[this.talkNPC].position.Y, Main.npc[this.talkNPC].width, Main.npc[this.talkNPC].height);
if (!rectangle.Intersects(value4) || this.chest != -1 || !Main.npc[this.talkNPC].active)
{
if (this.chest == -1)
{
Main.PlaySound(11, -1, -1, 1);
}
this.talkNPC = -1;
Main.npcChatCornerItem = 0;
Main.npcChatText = "";
}
}
if (this.sign >= 0)
{
Rectangle value5 = new Rectangle((int)(this.position.X + (float)(this.width / 2) - (float)(Player.tileRangeX * 16)), (int)(this.position.Y + (float)(this.height / 2) - (float)(Player.tileRangeY * 16)), Player.tileRangeX * 16 * 2, Player.tileRangeY * 16 * 2);
try
{
bool flag33 = false;
if (Main.sign[this.sign] == null)
{
flag33 = true;
}
if (!flag33 && !new Rectangle(Main.sign[this.sign].x * 16, Main.sign[this.sign].y * 16, 32, 32).Intersects(value5))
{
flag33 = true;
}
if (flag33)
{
Main.PlaySound(11, -1, -1, 1);
this.sign = -1;
Main.editSign = false;
Main.npcChatText = "";
}
}
catch
{
Main.PlaySound(11, -1, -1, 1);
this.sign = -1;
Main.editSign = false;
Main.npcChatText = "";
}
}
if (Main.editSign)
{
if (this.sign == -1)
{
Main.editSign = false;
}
else
{
Main.npcChatText = Main.GetInputText(Main.npcChatText);
if (Main.inputTextEnter)
{
byte[] bytes = new byte[]
{
10
};
Main.npcChatText += Encoding.ASCII.GetString(bytes);
}
else if (Main.inputTextEscape)
{
Main.PlaySound(12, -1, -1, 1);
Main.editSign = false;
Main.blockKey = Keys.Escape;
Main.npcChatText = Main.sign[this.sign].text;
}
}
}
else if (Main.editChest)
{
string inputText = Main.GetInputText(Main.npcChatText);
if (Main.inputTextEnter)
{
Main.PlaySound(12, -1, -1, 1);
Main.editChest = false;
int num241 = Main.player[Main.myPlayer].chest;
if (Main.npcChatText == Main.defaultChestName)
{
Main.npcChatText = "";
}
if (Main.chest[num241].name != Main.npcChatText)
{
Main.chest[num241].name = Main.npcChatText;
if (Main.netMode == 1)
{
this.editedChestName = true;
}
}
}
else if (Main.inputTextEscape)
{
Main.PlaySound(12, -1, -1, 1);
Main.editChest = false;
Main.npcChatText = string.Empty;
Main.blockKey = Keys.Escape;
}
else if (inputText.Length <= 20)
{
Main.npcChatText = inputText;
}
}
if (this.mount.Active && this.mount.Cart && Math.Abs(this.velocity.X) > 4f)
{
Rectangle rectangle2 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
for (int num242 = 0; num242 < 200; num242++)
{
if (Main.npc[num242].active && !Main.npc[num242].friendly && Main.npc[num242].damage > 0 && Main.npc[num242].immune[i] == 0 && rectangle2.Intersects(new Rectangle((int)Main.npc[num242].position.X, (int)Main.npc[num242].position.Y, Main.npc[num242].width, Main.npc[num242].height)))
{
float num243 = (float)this.meleeCrit;
if (num243 < (float)this.rangedCrit)
{
num243 = (float)this.rangedCrit;
}
if (num243 < (float)this.magicCrit)
{
num243 = (float)this.magicCrit;
}
bool crit = false;
if ((float)Main.rand.Next(1, 101) <= num243)
{
crit = true;
}
float num244 = Math.Abs(this.velocity.X) / this.maxRunSpeed;
int num245 = Main.DamageVar(25f + 55f * num244);
if (this.mount.Type == 11)
{
num245 = Main.DamageVar(50f + 100f * num244);
}
if (this.mount.Type == 13)
{
num245 = Main.DamageVar(15f + 30f * num244);
}
float num246 = 5f + 25f * num244;
int num247 = 1;
if (this.velocity.X < 0f)
{
num247 = -1;
}
if (this.whoAmI == Main.myPlayer)
{
Main.npc[num242].StrikeNPC(num245, num246, num247, crit, false, false);
if (Main.netMode != 0)
{
NetMessage.SendData(28, -1, -1, "", num242, (float)num245, num246, (float)num247, 0, 0, 0);
}
}
Main.npc[num242].immune[i] = 30;
if (!Main.npc[num242].active)
{
AchievementsHelper.HandleSpecialEvent(this, 9);
}
}
}
}
if (!this.immune)
{
Rectangle rectangle3 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
for (int num248 = 0; num248 < 200; num248++)
{
if (Main.npc[num248].active && !Main.npc[num248].friendly && Main.npc[num248].damage > 0 && (this.dash != 2 || num248 != this.eocHit || this.eocDash <= 0) && !this.npcTypeNoAggro[Main.npc[num248].type])
{
float num249 = 1f;
Rectangle value6 = new Rectangle((int)Main.npc[num248].position.X, (int)Main.npc[num248].position.Y, Main.npc[num248].width, Main.npc[num248].height);
if (Main.npc[num248].type >= 430 && Main.npc[num248].type <= 436 && Main.npc[num248].ai[2] > 5f)
{
int num250 = 34;
if (Main.npc[num248].spriteDirection < 0)
{
value6.X -= num250;
value6.Width += num250;
}
else
{
value6.Width += num250;
}
num249 *= 1.25f;
}
else if (Main.npc[num248].type >= 494 && Main.npc[num248].type <= 495 && Main.npc[num248].ai[2] > 5f)
{
int num251 = 18;
if (Main.npc[num248].spriteDirection < 0)
{
value6.X -= num251;
value6.Width += num251;
}
else
{
value6.Width += num251;
}
num249 *= 1.25f;
}
else if (Main.npc[num248].type == 460)
{
Rectangle rectangle4 = new Rectangle(0, 0, 30, 14);
rectangle4.X = (int)Main.npc[num248].Center.X;
if (Main.npc[num248].direction < 0)
{
rectangle4.X -= rectangle4.Width;
}
rectangle4.Y = (int)Main.npc[num248].position.Y + Main.npc[num248].height - 20;
if (rectangle3.Intersects(rectangle4))
{
value6 = rectangle4;
num249 *= 1.35f;
}
}
else if (Main.npc[num248].type == 417 && Main.npc[num248].ai[0] == 6f && Main.npc[num248].ai[3] > 0f && Main.npc[num248].ai[3] < 4f)
{
Rectangle rectangle5 = Utils.CenteredRectangle(Main.npc[num248].Center, new Vector2(100f));
if (rectangle3.Intersects(rectangle5))
{
value6 = rectangle5;
num249 *= 1.35f;
}
}
else if (Main.npc[num248].type == 466)
{
Rectangle rectangle6 = new Rectangle(0, 0, 30, 8);
rectangle6.X = (int)Main.npc[num248].Center.X;
if (Main.npc[num248].direction < 0)
{
rectangle6.X -= rectangle6.Width;
}
rectangle6.Y = (int)Main.npc[num248].position.Y + Main.npc[num248].height - 32;
if (rectangle3.Intersects(rectangle6))
{
value6 = rectangle6;
num249 *= 1.75f;
}
}
if (rectangle3.Intersects(value6) && !this.npcTypeNoAggro[Main.npc[num248].type])
{
int num252 = -1;
if (Main.npc[num248].position.X + (float)(Main.npc[num248].width / 2) < this.position.X + (float)(this.width / 2))
{
num252 = 1;
}
int num253 = Main.DamageVar((float)Main.npc[num248].damage * num249);
int num254 = Item.NPCtoBanner(Main.npc[num248].BannerID());
if (num254 > 0 && this.NPCBannerBuff[num254])
{
if (Main.expertMode)
{
num253 = (int)((double)num253 * 0.5);
}
else
{
num253 = (int)((double)num253 * 0.75);
}
}
if (this.whoAmI == Main.myPlayer && this.thorns > 0f && !this.immune && !Main.npc[num248].dontTakeDamage)
{
int num255 = (int)((float)num253 * this.thorns);
int num256 = 10;
if (this.turtleThorns)
{
num255 = num253;
}
Main.npc[num248].StrikeNPC(num255, (float)num256, -num252, false, false, false);
if (Main.netMode != 0)
{
NetMessage.SendData(28, -1, -1, "", num248, (float)num255, (float)num256, (float)(-(float)num252), 0, 0, 0);
}
}
if (this.resistCold && Main.npc[num248].coldDamage)
{
num253 = (int)((float)num253 * 0.7f);
}
if (!this.immune)
{
this.StatusPlayer(Main.npc[num248]);
}
this.Hurt(num253, num252, false, false, Lang.deathMsg(-1, num248, -1, -1), false);
}
}
}
}
Vector2 vector6;
if (!this.mount.Active || !this.mount.Cart)
{
vector6 = Collision.HurtTiles(this.position, this.velocity, this.width, this.height, this.fireWalk);
}
else
{
vector6 = Collision.HurtTiles(this.position, this.velocity, this.width, this.height - 16, this.fireWalk);
}
if (vector6.Y == 0f && !this.fireWalk)
{
foreach (Point current in this.TouchedTiles)
{
Tile tile5 = Main.tile[current.X, current.Y];
if (tile5 != null && tile5.active() && tile5.nactive() && !this.fireWalk && TileID.Sets.TouchDamageHot[(int)tile5.type] != 0)
{
vector6.Y = (float)TileID.Sets.TouchDamageHot[(int)tile5.type];
vector6.X = (float)((base.Center.X / 16f < (float)current.X + 0.5f) ? -1 : 1);
break;
}
}
}
if (vector6.Y == 20f)
{
this.AddBuff(67, 20, true);
}
else if (vector6.Y == 15f)
{
if (this.suffocateDelay < 5)
{
this.suffocateDelay += 1;
}
else
{
this.AddBuff(68, 1, true);
}
}
else if (vector6.Y != 0f)
{
int damage3 = Main.DamageVar(vector6.Y);
this.Hurt(damage3, 0, false, false, Lang.deathMsg(-1, -1, -1, 3), false);
}
else
{
this.suffocateDelay = 0;
}
}
if (this.controlRight)
{
this.releaseRight = false;
}
else
{
this.releaseRight = true;
this.rightTimer = 7;
}
if (this.controlLeft)
{
this.releaseLeft = false;
}
else
{
this.releaseLeft = true;
this.leftTimer = 7;
}
this.releaseDown = !this.controlDown;
if (this.rightTimer > 0)
{
this.rightTimer--;
}
else if (this.controlRight)
{
this.rightTimer = 7;
}
if (this.leftTimer > 0)
{
this.leftTimer--;
}
else if (this.controlLeft)
{
this.leftTimer = 7;
}
this.GrappleMovement();
this.StickyMovement();
this.CheckDrowning();
if (this.gravDir == -1f)
{
this.waterWalk = false;
this.waterWalk2 = false;
}
int num257 = this.height;
if (this.waterWalk)
{
num257 -= 6;
}
bool flag34 = Collision.LavaCollision(this.position, this.width, num257);
if (flag34)
{
if (!this.lavaImmune && Main.myPlayer == i && !this.immune)
{
if (this.lavaTime > 0)
{
this.lavaTime--;
}
else if (this.lavaRose)
{
this.Hurt(50, 0, false, false, Lang.deathMsg(-1, -1, -1, 2), false);
this.AddBuff(24, 210, true);
}
else
{
this.Hurt(80, 0, false, false, Lang.deathMsg(-1, -1, -1, 2), false);
this.AddBuff(24, 420, true);
}
}
this.lavaWet = true;
}
else
{
this.lavaWet = false;
if (this.lavaTime < this.lavaMax)
{
this.lavaTime++;
}
}
if (this.lavaTime > this.lavaMax)
{
this.lavaTime = this.lavaMax;
}
if (this.waterWalk2 && !this.waterWalk)
{
num257 -= 6;
}
bool flag35 = Collision.WetCollision(this.position, this.width, this.height);
bool flag36 = Collision.honey;
if (flag36)
{
this.AddBuff(48, 1800, true);
this.honeyWet = true;
}
if (flag35)
{
if (this.onFire && !this.lavaWet)
{
for (int num258 = 0; num258 < 22; num258++)
{
if (this.buffType[num258] == 24)
{
this.DelBuff(num258);
}
}
}
if (!this.wet)
{
if (this.wetCount == 0)
{
this.wetCount = 10;
if (!flag34)
{
if (this.honeyWet)
{
for (int num259 = 0; num259 < 20; num259++)
{
int num260 = Dust.NewDust(new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2) - 8f), this.width + 12, 24, 152, 0f, 0f, 0, default(Color), 1f);
Dust expr_D6CD_cp_0 = Main.dust[num260];
expr_D6CD_cp_0.velocity.Y = expr_D6CD_cp_0.velocity.Y - 1f;
Dust expr_D6ED_cp_0 = Main.dust[num260];
expr_D6ED_cp_0.velocity.X = expr_D6ED_cp_0.velocity.X * 2.5f;
Main.dust[num260].scale = 1.3f;
Main.dust[num260].alpha = 100;
Main.dust[num260].noGravity = true;
}
Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
}
else
{
for (int num261 = 0; num261 < 50; num261++)
{
int num262 = Dust.NewDust(new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2) - 8f), this.width + 12, 24, Dust.dustWater(), 0f, 0f, 0, default(Color), 1f);
Dust expr_D7EE_cp_0 = Main.dust[num262];
expr_D7EE_cp_0.velocity.Y = expr_D7EE_cp_0.velocity.Y - 3f;
Dust expr_D80E_cp_0 = Main.dust[num262];
expr_D80E_cp_0.velocity.X = expr_D80E_cp_0.velocity.X * 2.5f;
Main.dust[num262].scale = 0.8f;
Main.dust[num262].alpha = 100;
Main.dust[num262].noGravity = true;
}
Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 0);
}
}
else
{
for (int num263 = 0; num263 < 20; num263++)
{
int num264 = Dust.NewDust(new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2) - 8f), this.width + 12, 24, 35, 0f, 0f, 0, default(Color), 1f);
Dust expr_D90C_cp_0 = Main.dust[num264];
expr_D90C_cp_0.velocity.Y = expr_D90C_cp_0.velocity.Y - 1.5f;
Dust expr_D92C_cp_0 = Main.dust[num264];
expr_D92C_cp_0.velocity.X = expr_D92C_cp_0.velocity.X * 2.5f;
Main.dust[num264].scale = 1.3f;
Main.dust[num264].alpha = 100;
Main.dust[num264].noGravity = true;
}
Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
}
}
this.wet = true;
}
}
else if (this.wet)
{
this.wet = false;
if (this.jump > Player.jumpHeight / 5 && this.wetSlime == 0)
{
this.jump = Player.jumpHeight / 5;
}
if (this.wetCount == 0)
{
this.wetCount = 10;
if (!this.lavaWet)
{
if (this.honeyWet)
{
for (int num265 = 0; num265 < 20; num265++)
{
int num266 = Dust.NewDust(new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2) - 8f), this.width + 12, 24, 152, 0f, 0f, 0, default(Color), 1f);
Dust expr_DA93_cp_0 = Main.dust[num266];
expr_DA93_cp_0.velocity.Y = expr_DA93_cp_0.velocity.Y - 1f;
Dust expr_DAB3_cp_0 = Main.dust[num266];
expr_DAB3_cp_0.velocity.X = expr_DAB3_cp_0.velocity.X * 2.5f;
Main.dust[num266].scale = 1.3f;
Main.dust[num266].alpha = 100;
Main.dust[num266].noGravity = true;
}
Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
}
else
{
for (int num267 = 0; num267 < 50; num267++)
{
int num268 = Dust.NewDust(new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2)), this.width + 12, 24, Dust.dustWater(), 0f, 0f, 0, default(Color), 1f);
Dust expr_DBAE_cp_0 = Main.dust[num268];
expr_DBAE_cp_0.velocity.Y = expr_DBAE_cp_0.velocity.Y - 4f;
Dust expr_DBCE_cp_0 = Main.dust[num268];
expr_DBCE_cp_0.velocity.X = expr_DBCE_cp_0.velocity.X * 2.5f;
Main.dust[num268].scale = 0.8f;
Main.dust[num268].alpha = 100;
Main.dust[num268].noGravity = true;
}
Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 0);
}
}
else
{
for (int num269 = 0; num269 < 20; num269++)
{
int num270 = Dust.NewDust(new Vector2(this.position.X - 6f, this.position.Y + (float)(this.height / 2) - 8f), this.width + 12, 24, 35, 0f, 0f, 0, default(Color), 1f);
Dust expr_DCCC_cp_0 = Main.dust[num270];
expr_DCCC_cp_0.velocity.Y = expr_DCCC_cp_0.velocity.Y - 1.5f;
Dust expr_DCEC_cp_0 = Main.dust[num270];
expr_DCEC_cp_0.velocity.X = expr_DCEC_cp_0.velocity.X * 2.5f;
Main.dust[num270].scale = 1.3f;
Main.dust[num270].alpha = 100;
Main.dust[num270].noGravity = true;
}
Main.PlaySound(19, (int)this.position.X, (int)this.position.Y, 1);
}
}
}
if (!flag36)
{
this.honeyWet = false;
}
if (!this.wet)
{
this.lavaWet = false;
this.honeyWet = false;
}
if (this.wetCount > 0)
{
this.wetCount -= 1;
}
if (this.wetSlime > 0)
{
this.wetSlime -= 1;
}
if (this.wet && this.mount.Active)
{
switch (this.mount.Type)
{
case 3:
this.wetSlime = 30;
if (this.velocity.Y > 2f)
{
this.velocity.Y = this.velocity.Y * 0.9f;
}
this.velocity.Y = this.velocity.Y - 0.5f;
if (this.velocity.Y < -4f)
{
this.velocity.Y = -4f;
}
break;
case 5:
case 7:
if (this.whoAmI == Main.myPlayer)
{
this.mount.Dismount(this);
}
break;
}
}
if (Main.expertMode && this.ZoneSnow && this.wet && !this.lavaWet && !this.honeyWet && !this.arcticDivingGear)
{
this.AddBuff(46, 150, true);
}
float num271 = 1f + Math.Abs(this.velocity.X) / 3f;
if (this.gfxOffY > 0f)
{
this.gfxOffY -= num271 * this.stepSpeed;
if (this.gfxOffY < 0f)
{
this.gfxOffY = 0f;
}
}
else if (this.gfxOffY < 0f)
{
this.gfxOffY += num271 * this.stepSpeed;
if (this.gfxOffY > 0f)
{
this.gfxOffY = 0f;
}
}
if (this.gfxOffY > 32f)
{
this.gfxOffY = 32f;
}
if (this.gfxOffY < -32f)
{
this.gfxOffY = -32f;
}
if (Main.myPlayer == i && !this.iceSkate)
{
this.CheckIceBreak();
}
this.SlopeDownMovement();
bool flag37 = this.mount.Type == 7 || this.mount.Type == 8 || this.mount.Type == 12;
if (this.velocity.Y == this.gravity && (!this.mount.Active || (!this.mount.Cart && !flag37)))
{
Collision.StepDown(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int)this.gravDir, this.waterWalk || this.waterWalk2);
}
if (this.gravDir == -1f)
{
if ((this.carpetFrame != -1 || this.velocity.Y <= this.gravity) && !this.controlUp)
{
Collision.StepUp(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int)this.gravDir, this.controlUp, 0);
}
}
else if (flag37 || ((this.carpetFrame != -1 || this.velocity.Y >= this.gravity) && !this.controlDown && !this.mount.Cart))
{
Collision.StepUp(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, (int)this.gravDir, this.controlUp, 0);
}
this.oldPosition = this.position;
this.oldDirection = this.direction;
bool falling = false;
if (this.velocity.Y > this.gravity)
{
falling = true;
}
if (this.velocity.Y < -this.gravity)
{
falling = true;
}
Vector2 velocity = this.velocity;
this.slideDir = 0;
bool ignorePlats = false;
bool fallThrough = this.controlDown;
if (this.gravDir == -1f || (this.mount.Active && this.mount.Cart) || this.GoingDownWithGrapple)
{
ignorePlats = true;
fallThrough = true;
}
this.onTrack = false;
bool flag38 = false;
if (this.mount.Active && this.mount.Cart)
{
float num272;
if (!this.ignoreWater && !this.merman)
{
if (this.honeyWet)
{
num272 = 0.25f;
}
else if (this.wet)
{
num272 = 0.5f;
}
else
{
num272 = 1f;
}
}
else
{
num272 = 1f;
}
this.velocity *= num272;
DelegateMethods.Minecart.rotation = this.fullRotation;
DelegateMethods.Minecart.rotationOrigin = this.fullRotationOrigin;
BitsByte bitsByte = Minecart.TrackCollision(ref this.position, ref this.velocity, ref this.lastBoost, this.width, this.height, this.controlDown, this.controlUp, this.fallStart2, false, this.mount.MinecartDust);
if (bitsByte[0])
{
this.onTrack = true;
this.gfxOffY = Minecart.TrackRotation(ref this.fullRotation, this.position + this.velocity, this.width, this.height, this.controlDown, this.controlUp, this.mount.MinecartDust);
this.fullRotationOrigin = new Vector2((float)(this.width / 2), (float)this.height);
}
if (bitsByte[1])
{
if (this.controlLeft || this.controlRight)
{
if (this.cartFlip)
{
this.cartFlip = false;
}
else
{
this.cartFlip = true;
}
}
if (this.velocity.X > 0f)
{
this.direction = 1;
}
else if (this.velocity.X < 0f)
{
this.direction = -1;
}
Main.PlaySound(2, (int)this.position.X + this.width / 2, (int)this.position.Y + this.height / 2, 56);
}
this.velocity /= num272;
if (bitsByte[3] && this.whoAmI == Main.myPlayer)
{
flag38 = true;
}
if (bitsByte[2])
{
this.cartRampTime = (int)(Math.Abs(this.velocity.X) / this.mount.RunSpeed * 20f);
}
if (bitsByte[4])
{
this.trackBoost -= 4f;
}
if (bitsByte[5])
{
this.trackBoost += 4f;
}
}
bool flag39 = this.whoAmI == Main.myPlayer && !this.mount.Active;
Vector2 position = this.position;
if (this.vortexDebuff)
{
this.velocity.Y = this.velocity.Y * 0.8f + (float)Math.Cos((double)(base.Center.X % 120f / 120f * 6.28318548f)) * 5f * 0.2f;
}
if (this.wingsLogic == 3 && this.controlUp && this.controlDown)
{
this.position += this.velocity;
}
else if (this.tongued)
{
this.position += this.velocity;
flag39 = false;
}
else if (this.honeyWet && !this.ignoreWater)
{
this.HoneyCollision(fallThrough, ignorePlats);
}
else if (this.wet && !this.merman && !this.ignoreWater)
{
this.WaterCollision(fallThrough, ignorePlats);
}
else
{
this.DryCollision(fallThrough, ignorePlats);
if (this.mount.Active && this.mount.Type == 3 && this.velocity.Y != 0f && !this.SlimeDontHyperJump)
{
Vector2 velocity2 = this.velocity;
this.velocity.X = 0f;
this.DryCollision(fallThrough, ignorePlats);
this.velocity.X = velocity2.X;
}
}
this.UpdateTouchingTiles();
this.TryBouncingBlocks(falling);
this.TryLandingOnDetonator();
if (this.wingsLogic != 3 || !this.controlUp || !this.controlDown)
{
this.SlopingCollision(fallThrough);
}
if (flag39 && this.velocity.Y == 0f)
{
AchievementsHelper.HandleRunning(Math.Abs(this.position.X - position.X));
}
if (flag38)
{
NetMessage.SendData(13, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
Minecart.HitTrackSwitch(new Vector2(this.position.X, this.position.Y), this.width, this.height);
}
if (velocity.X != this.velocity.X)
{
if (velocity.X < 0f)
{
this.slideDir = -1;
}
else if (velocity.X > 0f)
{
this.slideDir = 1;
}
}
if (this.gravDir == 1f && Collision.up)
{
this.velocity.Y = 0.01f;
if (!this.merman)
{
this.jump = 0;
}
}
else if (this.gravDir == -1f && Collision.down)
{
this.velocity.Y = -0.01f;
if (!this.merman)
{
this.jump = 0;
}
}
if (this.velocity.Y == 0f && this.grappling[0] == -1)
{
this.FloorVisuals(falling);
}
if (this.whoAmI == Main.myPlayer)
{
Collision.SwitchTiles(this.position, this.width, this.height, this.oldPosition, 1);
}
this.BordersMovement();
this.numMinions = 0;
this.slotsMinions = 0f;
if (this.altFunctionUse == 0 && this.selectedItem != 58 && this.controlUseTile && this.releaseUseItem && !this.controlUseItem && !this.mouseInterface && this.inventory[this.selectedItem].itemId == 3384)
{
this.altFunctionUse = 1;
this.controlUseItem = true;
}
if (!this.controlUseItem && this.altFunctionUse == 1)
{
this.altFunctionUse = 0;
}
if (Main.ignoreErrors)
{
try
{
this.ItemCheck(i);
goto IL_E88C;
}
catch
{
goto IL_E88C;
}
}
this.ItemCheck(i);
IL_E88C:
this.PlayerFrame();
if (this.mount.Type == 8)
{
this.mount.UseDrill(this);
}
if (this.statLife > this.statLifeMax2)
{
this.statLife = this.statLifeMax2;
}
if (this.statMana > this.statManaMax2)
{
this.statMana = this.statManaMax2;
}
this.grappling[0] = -1;
this.grapCount = 0;
}