#pragma once

/**
 * \file PlayerShootPacket.h
 * \brief File containing the blitz::protocol::PlayerShootPacket class
 */

#include "blitz/game/Player.h"
#include "blitz/protocol/Protocol.h"

namespace blitz {
namespace protocol {

/**
 * \class PlayerShootPacket
 * \brief Packet for when a player shoots.
 * %Packet structure :
 * |      PacketType 		|
 * |------------------------|
 * | PacketType::PlayerShoot|
 *
 * |	 Field Name 	|  	 Field Type		|  			  Notes 			   |
 * |--------------------|-------------------|----------------------------------|
 * |	Player ID		|     PlayerID	    |  The ID of the player that shot  |
 * |	Position		|   Vec3f 			|     Position of the player	   |
 * |	Yaw				|    float			|       Yaw of the player		   |
 * |	Pitch			|    float			|      Pitch of the player		   |
 */
class PlayerShootPacket : public Packet {
  private:
	game::PlayerID m_Player;  // only used when sent to client
	Vec3f m_Position;
	float m_Yaw, m_Pitch;

  public:
	/**
	 * \brief Default constructor.
	 */
	PlayerShootPacket() {}
	/**
	 * \brief Constructor.
	 * \param position The position of the player.
	 * \param yaw The yaw of the player.
	 * \param pitch The pitch of the player.
	 * \param player The ID of the player.
	 */
	PlayerShootPacket(Vec3f position, float yaw, float pitch, game::PlayerID player = 0) :
		m_Player(player), m_Position(position), m_Yaw(yaw), m_Pitch(pitch) {}
	virtual ~PlayerShootPacket() {}

	virtual DataBuffer Serialize(bool packetID = true) const;
	virtual void Deserialize(DataBuffer& data);
	virtual void Dispatch(PacketHandler* handler) const;

	/**
	 * \brief Get the position of the player.
	 * \return The position of the player.
	 */
	const Vec3f& GetPosition() const {
		return m_Position;
	}

	/**
	 * \brief Get the yaw of the player.
	 * \return The yaw of the player.
	 */
	float GetYaw() const {
		return m_Yaw;
	}

	/**
	 * \brief Get the pitch of the player.
	 * \return The pitch of the player.
	 */
	float GetPitch() const {
		return m_Pitch;
	}

	/**
	 * \brief Get the ID of the player.
	 * \return The ID of the player.
	 */
	game::PlayerID GetPlayer() const {
		return m_Player;
	}

	virtual PacketType GetType() const {
		return PacketType::PlayerShoot;
	}
};

}  // namespace protocol
}  // namespace blitz