public void FindPulley()
{
if (!this.controlUp && !this.controlDown)
return;
int index1 = (int)((double)this.position.X + (double)(this.width / 2)) / 16;
int index2 = (int)((double)this.position.Y - 8.0) / 16;
if (Main.tile[index1, index2] == null || !Main.tile[index1, index2].active() || !Main.tileRope[(int)Main.tile[index1, index2].type])
return;
float num1 = this.position.Y;
if (Main.tile[index1, index2 - 1] == null)
Main.tile[index1, index2 - 1] = new Tile();
if (Main.tile[index1, index2 + 1] == null)
Main.tile[index1, index2 + 1] = new Tile();
if ((!Main.tile[index1, index2 - 1].active() || !Main.tileRope[(int)Main.tile[index1, index2 - 1].type]) && (!Main.tile[index1, index2 + 1].active() || !Main.tileRope[(int)Main.tile[index1, index2 + 1].type]))
num1 = (float)(index2 * 16 + 22);
float x1 = (float)(index1 * 16 + 8 - this.width / 2 + 6 * this.direction);
int num2 = index1 * 16 + 8 - this.width / 2 + 6;
int num3 = index1 * 16 + 8 - this.width / 2;
int num4 = index1 * 16 + 8 - this.width / 2 - 6;
int num5 = 1;
float num6 = Math.Abs(this.position.X - (float)num2);
if ((double)Math.Abs(this.position.X - (float)num3) < (double)num6)
{
num5 = 2;
num6 = Math.Abs(this.position.X - (float)num3);
}
if ((double)Math.Abs(this.position.X - (float)num4) < (double)num6)
{
num5 = 3;
Math.Abs(this.position.X - (float)num4);
}
if (num5 == 1)
{
x1 = (float)num2;
this.pulleyDir = (byte)2;
this.direction = 1;
}
if (num5 == 2)
{
x1 = (float)num3;
this.pulleyDir = (byte)1;
}
if (num5 == 3)
{
x1 = (float)num4;
this.pulleyDir = (byte)2;
this.direction = -1;
}
if (!Collision.SolidCollision(new Vector2(x1, this.position.Y), this.width, this.height))
{
if (this.whoAmI == Main.myPlayer)
Main.cameraX = Main.cameraX + this.position.X - x1;
this.pulley = true;
this.position.X = x1;
this.gfxOffY = this.position.Y - num1;
this.stepSpeed = 2.5f;
this.position.Y = num1;
this.velocity.X = 0.0f;
}
else
{
float x2 = (float)num2;
this.pulleyDir = (byte)2;
this.direction = 1;
if (!Collision.SolidCollision(new Vector2(x2, this.position.Y), this.width, this.height))
{
if (this.whoAmI == Main.myPlayer)
Main.cameraX = Main.cameraX + this.position.X - x2;
this.pulley = true;
this.position.X = x2;
this.gfxOffY = this.position.Y - num1;
this.stepSpeed = 2.5f;
this.position.Y = num1;
this.velocity.X = 0.0f;
}
else
{
float x3 = (float)num4;
this.pulleyDir = (byte)2;
this.direction = -1;
if (Collision.SolidCollision(new Vector2(x3, this.position.Y), this.width, this.height))
return;
if (this.whoAmI == Main.myPlayer)
Main.cameraX = Main.cameraX + this.position.X - x3;
this.pulley = true;
this.position.X = x3;
this.gfxOffY = this.position.Y - num1;
this.stepSpeed = 2.5f;
this.position.Y = num1;
this.velocity.X = 0.0f;
}
}
}