public override void onPlayerMove(PlayerMoveEvent Event) { Player p = Event.Sender as Player; //p.sendMessage("You are on tile: x=" + p.TileLocation.X + " y=" + p.TileLocation.Y); foreach ( RegisteredPattern rp in registeredPatterns) { //p.sendMessage("Player is in x=" + (int)(Event.Location.X / 16) + " y=" + (int)(Event.Location.Y / 16)); //p.sendMessage("Rune location is y=" + rp.y + " ( " + (rp.y - 1) + " ) and x between " + rp.x + " and " + rp.x + rp.patt.sizeX); if ((int)(Event.Location.Y/16) == (rp.y - rp.patt.sizeY - 1) && ((int)(Event.Location.X/16) >= rp.x && (int)(Event.Location.X/16) <= rp.x+rp.patt.sizeX)) { p.sendMessage("Activating rune: " + rp.patt.name); p.teleportTo( Main.spawnTileX*16 , Main.spawnTileY*16); } } base.onPlayerMove(Event); }
public override void onPlayerMove(PlayerMoveEvent Event) { //base.onPlayerMove(Event); //Player player = Event.Player; //player.sendMessage("You have moved."); }
/// <summary> /// Hook method for player movement /// </summary> /// <param name="Event">PlayerMoveEvent info</param> public virtual void onPlayerMove(PlayerMoveEvent Event) { }
public void Process(int start, int length, int num, int whoAmI, byte[] readBuffer, byte bufferData) { int playerIndex = (int)readBuffer[num++]; if (playerIndex == Main.myPlayer) { return; } Player player = (Player)Main.players[playerIndex].Clone(); playerIndex = whoAmI; player.oldVelocity = player.Velocity; int controlMap = (int)readBuffer[num++]; player.selectedItemIndex = (int)readBuffer[num++]; player.Position.X = BitConverter.ToSingle(readBuffer, num); num += 4; player.Position.Y = BitConverter.ToSingle(readBuffer, num); num += 4; player.Velocity.X = BitConverter.ToSingle(readBuffer, num); num += 4; player.Velocity.Y = BitConverter.ToSingle(readBuffer, num); num += 4; player.fallStart = (int)(player.Position.Y / 16f); player.controlUp = (controlMap & 1) == 1; player.controlDown = (controlMap & 2) == 2; player.controlLeft = (controlMap & 4) == 4; player.controlRight = (controlMap & 8) == 8; player.controlJump = (controlMap & 16) == 16; player.controlUseItem = (controlMap & 32) == 32; player.direction = (controlMap & 64) == 64 ? 1 : -1; PlayerMoveEvent playerEvent = new PlayerMoveEvent(); playerEvent.Sender = Main.players[playerIndex]; //We want to use the old player. (Possibly, to keep old Data?) playerEvent.Location = player.Position; playerEvent.Velocity = player.Velocity; playerEvent.FallStart = player.fallStart; Program.server.PluginManager.processHook(Hooks.PLAYER_MOVE, playerEvent); if (playerEvent.Cancelled) { return; } PlayerKeyPressEvent playerInteractEvent = new PlayerKeyPressEvent(); playerInteractEvent.Sender = Main.players[playerIndex]; Key playerKeysPressed = new Key(); playerKeysPressed.Up = player.controlUp; playerKeysPressed.Down = player.controlDown; playerKeysPressed.Left = player.controlLeft; playerKeysPressed.Right = player.controlRight; playerKeysPressed.Jump = player.controlJump; playerInteractEvent.KeysPressed = playerKeysPressed; playerInteractEvent.MouseClicked = player.controlUseItem; playerInteractEvent.FacingDirection = player.direction; Program.server.PluginManager.processHook(Hooks.PLAYER_KEYPRESS, playerInteractEvent); if (playerEvent.Cancelled) { return; } Main.players[playerIndex] = player; if (Netplay.slots[whoAmI].state == SlotState.PLAYING) { NetMessage.SendData(13, -1, whoAmI, "", playerIndex); } }