public void QuickGrapple()
{
if (this.frozen || this.tongued || (this.webbed || this.stoned))
return;
if (this.mount.Active)
this.mount.Dismount(this);
if (this.noItems)
return;
Item obj = (Item)null;
if (obj == null && Main.projHook[this.miscEquips[4].shoot])
obj = this.miscEquips[4];
if (obj == null)
{
for (int index = 0; index < 58; ++index)
{
if (Main.projHook[this.inventory[index].shoot])
{
obj = this.inventory[index];
break;
}
}
}
if (obj == null)
return;
if (obj.shoot == 73)
{
int num = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && (Main.projectile[index].type == 73 || Main.projectile[index].type == 74))
++num;
}
if (num > 1)
obj = (Item)null;
}
else if (obj.shoot == 165)
{
int num = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == 165)
++num;
}
if (num > 8)
obj = (Item)null;
}
else if (obj.shoot == 372)
{
int num = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && Main.projectile[index].type == 372)
++num;
}
if (num > 2)
obj = (Item)null;
}
else if (obj.shoot == 165)
{
int num = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && (Main.projectile[index].type >= 646 && Main.projectile[index].type <= 649))
++num;
}
if (num > 4)
obj = (Item)null;
}
else
{
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].owner == Main.myPlayer && (Main.projectile[index].type == obj.shoot && (double)Main.projectile[index].ai[0] != 2.0))
{
obj = (Item)null;
break;
}
}
}
if (obj == null)
return;
Main.PlaySound(2, (int)this.position.X, (int)this.position.Y, obj.useSound);
if (Main.netMode == 1 && this.whoAmI == Main.myPlayer)
NetMessage.SendData(51, -1, -1, "", this.whoAmI, 2f, 0.0f, 0.0f, 0, 0, 0);
int Type = obj.shoot;
float num1 = obj.shootSpeed;
int Damage = obj.damage;
float KnockBack = obj.knockBack;
if (Type == 13 || Type == 32 || Type == 315 || (Type >= 230 && Type <= 235 || Type == 331))
{
this.grappling[0] = -1;
this.grapCount = 0;
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI)
{
if (Main.projectile[index].type == 13)
Main.projectile[index].Kill();
if (Main.projectile[index].type == 331)
Main.projectile[index].Kill();
if (Main.projectile[index].type == 315)
Main.projectile[index].Kill();
if (Main.projectile[index].type >= 230 && Main.projectile[index].type <= 235)
Main.projectile[index].Kill();
}
}
}
if (Type == 256)
{
int num2 = 0;
int index1 = -1;
int num3 = 100000;
for (int index2 = 0; index2 < 1000; ++index2)
{
if (Main.projectile[index2].active && Main.projectile[index2].owner == this.whoAmI && Main.projectile[index2].type == 256)
{
++num2;
if (Main.projectile[index2].timeLeft < num3)
{
index1 = index2;
num3 = Main.projectile[index2].timeLeft;
}
}
}
if (num2 > 1)
Main.projectile[index1].Kill();
}
if (Type == 73)
{
for (int index = 0; index < 1000; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].owner == this.whoAmI && Main.projectile[index].type == 73)
Type = 74;
}
}
if (obj.itemId == 3572)
{
int num2 = -1;
int num3 = -1;
for (int index = 0; index < 1000; ++index)
{
Projectile projectile = Main.projectile[index];
if (projectile.active && projectile.owner == this.whoAmI && (projectile.type >= 646 && projectile.type <= 649) && (num3 == -1 || num3 < projectile.timeLeft))
{
num2 = projectile.type;
num3 = projectile.timeLeft;
}
}
switch (num2)
{
case -1:
case 649:
Type = 646;
break;
case 646:
Type = 647;
break;
case 647:
Type = 648;
break;
case 648:
Type = 649;
break;
}
}
Vector2 vector2 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
float f1 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
float f2 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
if ((double)this.gravDir == -1.0)
f2 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y;
float num4 = (float)Math.Sqrt((double)f1 * (double)f1 + (double)f2 * (double)f2);
float num5;
if (float.IsNaN(f1) && float.IsNaN(f2) || (double)f1 == 0.0 && (double)f2 == 0.0)
{
f1 = (float)this.direction;
f2 = 0.0f;
num5 = num1;
}
else
num5 = num1 / num4;
float SpeedX = f1 * num5;
float SpeedY = f2 * num5;
Projectile.NewProjectile(vector2.X, vector2.Y, SpeedX, SpeedY, Type, Damage, KnockBack, this.whoAmI, 0.0f, 0.0f);
}