public static bool SwitchTiles(Func <Int32, Int32, ITile> TileRefs, ISandbox sandbox, Vector2 Position, int Width, int Height, Vector2 oldPosition, ISender Sender) { if (TileRefs == null) { TileRefs = TileCollection.ITileAt; } int num = (int)(Position.X / 16f) - 1; int num2 = (int)((Position.X + (float)Width) / 16f) + 2; int num3 = (int)(Position.Y / 16f) - 1; int num4 = (int)((Position.Y + (float)Height) / 16f) + 2; if (num < 0) { num = 0; } if (num2 > Main.maxTilesX) { num2 = Main.maxTilesX; } if (num3 < 0) { num3 = 0; } if (num4 > Main.maxTilesY) { num4 = Main.maxTilesY; } for (int x = num; x < num2; x++) { for (int y = num3; y < num4; y++) { if (TileRefs(x, y).Active&& TileRefs(x, y).Type == 135) { Vector2 vector; vector.X = (float)(x * 16); vector.Y = (float)(y * 16 + 12); if (Position.X + (float)Width > vector.X && Position.X < vector.X + 16f && Position.Y + (float)Height > vector.Y && (double)Position.Y < (double)vector.Y + 4.01 && (oldPosition.X + (float)Width <= vector.X || oldPosition.X >= vector.X + 16f || oldPosition.Y + (float)Height <= vector.Y || (double)oldPosition.Y >= (double)vector.Y + 16.01)) { WorldModify.hitSwitch(TileRefs, sandbox, x, y, Sender); NetMessage.SendData(59, -1, -1, "", x, (float)y, 0f, 0f, 0); return(true); } } } } return(false); }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int X = BitConverter.ToInt32(readBuffer, num); num += 4; int Y = BitConverter.ToInt32(readBuffer, num); num += 4; WorldModify.hitSwitch(X, Y, Main.players[whoAmI]); NetMessage.SendData(59, -1, whoAmI, "", X, (float)Y, 0f, 0f, 0); }