VOX
A little voxel engine
Loading...
Searching...
No Matches
PlayerMovePacket.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IPacket.hpp"
4#include "glm/vec3.hpp"
5
7{
8public:
10 PlayerMovePacket(uint64_t id, glm::dvec3 position, glm::dvec3 displacement);
12
15
18
19 void Serialize(uint8_t * buffer) const override;
20 void Deserialize(const uint8_t * buffer) override;
21 uint32_t Size() const override;
22 bool HasDynamicSize() const override;
23 IPacket::Type GetType() const override;
24
25 std::shared_ptr<IPacket> Clone() const override;
26
27 /*******************************
28 **ATTRIBUTES
29 *******************************/
30
31 uint64_t GetPlayerId() const;
32 glm::dvec3 GetPosition() const;
33 glm::dvec3 GetDisplacement() const;
34
35 void SetPlayerId(uint64_t id);
36 void SetPosition(glm::dvec3 position);
37 void SetDisplacement(glm::dvec3 displacement);
38private:
39 uint64_t m_player_id;
40 glm::dvec3 m_position;
41 glm::dvec3 m_displacement;
42};
an abstract class that servers as a base for all network packets
Definition: IPacket.hpp:40
Type
Definition: IPacket.hpp:48
Definition: PlayerMovePacket.hpp:7
void SetDisplacement(glm::dvec3 displacement)
Definition: PlayerMovePacket.cpp:126
IPacket::Type GetType() const override
Get the Type of the packet.
Definition: PlayerMovePacket.cpp:91
PlayerMovePacket & operator=(const PlayerMovePacket &other)
Definition: PlayerMovePacket.cpp:23
void Deserialize(const uint8_t *buffer) override
read the packet from the buffer, the buffer must at least be of size Size()
Definition: PlayerMovePacket.cpp:66
uint64_t GetPlayerId() const
Definition: PlayerMovePacket.cpp:101
PlayerMovePacket()
Definition: PlayerMovePacket.cpp:3
void SetPlayerId(uint64_t id)
Definition: PlayerMovePacket.cpp:116
glm::dvec3 GetPosition() const
Definition: PlayerMovePacket.cpp:106
void SetPosition(glm::dvec3 position)
Definition: PlayerMovePacket.cpp:121
glm::dvec3 GetDisplacement() const
Definition: PlayerMovePacket.cpp:111
uint32_t Size() const override
return the size of the packet in bytes, usually used to reserve the right amount of memory in the sen...
Definition: PlayerMovePacket.cpp:81
~PlayerMovePacket()
Definition: PlayerMovePacket.cpp:47
bool HasDynamicSize() const override
Tell if the packet has a dynamic size.
Definition: PlayerMovePacket.cpp:86
std::shared_ptr< IPacket > Clone() const override
Create a new instance of the packet.
Definition: PlayerMovePacket.cpp:96
void Serialize(uint8_t *buffer) const override
will write the packet in the buffer, the buffer must at least be of size Size()
Definition: PlayerMovePacket.cpp:51