CEngineSharp_Server.World.Entities.Player.MoveTo C# (CSharp) Method

MoveTo() public method

public MoveTo ( Vector vector, byte direction ) : void
vector CEngineSharp_Utilities.Vector
direction byte
return void
        public void MoveTo(Vector vector, byte direction)
        {
            this.Direction = direction;

            //// If the tile is blocked, we obviously can't move to it.
            if (vector.X >= 0 && vector.Y >= 0 && vector.X < this.Map.MapWidth && vector.Y < this.Map.MapHeight && !this.Map.GetTile(vector).Blocked && !this.Map.GetTile(vector).IsOccupied)
            {
                // Unblock the previous tile so that another entity may occupy it.
                this.Map.GetTile(this.Position).IsOccupied = false;

                // Change our character's position to the new position.
                this.Position = vector;

                // Block the tile that we're moving to.
                this.Map.GetTile(vector).IsOccupied = true;
            }

            Packet packet = new Packet(PacketType.PlayerMovementPacket);
            packet.Message.Write(this.PlayerIndex);
            packet.Message.Write(this.Position);
            packet.Message.Write(direction);
            //this.Connection.SendMessage(packet, NetDeliveryMethod.ReliableOrdered, (int)ChannelTypes.WORLD);
            // SENDTOMAP
        }