VOX
A little voxel engine
Loading...
Searching...
No Matches
BlockActionPacket.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IPacket.hpp"
4#include "Block.hpp"
5
7{
8public:
9 enum class Action : uint8_t
10 {
11 PLACE
12 };
13
15 BlockActionPacket(BlockInfo::Type block_id, glm::vec3 position, Action action);
17
20
23
24
25 void Serialize(uint8_t * buffer) const override;
26 void Deserialize(const uint8_t * buffer) override;
27 uint32_t Size() const override;
28 bool HasDynamicSize() const override;
29 IPacket::Type GetType() const override;
30
31 std::shared_ptr<IPacket> Clone() const override;
32
33 /*******************************
34 * ATTRIBUTES
35 * *****************************/
36
38 glm::vec3 GetPosition() const;
39 Action GetAction() const;
40
41 void SetBlockID(BlockInfo::Type block_id);
42 void SetPosition(glm::vec3 position);
43 void SetAction(Action action);
44private:
45 BlockInfo::Type m_block_id;
46 glm::vec3 m_position;
47 Action m_action;
48};
Definition: BlockActionPacket.hpp:7
void SetBlockID(BlockInfo::Type block_id)
Definition: BlockActionPacket.cpp:116
void Serialize(uint8_t *buffer) const override
will write the packet in the buffer, the buffer must at least be of size Size()
Definition: BlockActionPacket.cpp:50
bool HasDynamicSize() const override
Tell if the packet has a dynamic size.
Definition: BlockActionPacket.cpp:86
Action GetAction() const
Definition: BlockActionPacket.cpp:111
glm::vec3 GetPosition() const
Definition: BlockActionPacket.cpp:106
BlockInfo::Type GetBlockID() const
Definition: BlockActionPacket.cpp:101
void Deserialize(const uint8_t *buffer) override
read the packet from the buffer, the buffer must at least be of size Size()
Definition: BlockActionPacket.cpp:66
~BlockActionPacket()
Definition: BlockActionPacket.cpp:46
BlockActionPacket()
Definition: BlockActionPacket.cpp:3
IPacket::Type GetType() const override
Get the Type of the packet.
Definition: BlockActionPacket.cpp:91
Action
Definition: BlockActionPacket.hpp:10
BlockActionPacket & operator=(const BlockActionPacket &other)
Definition: BlockActionPacket.cpp:17
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: BlockActionPacket.cpp:81
void SetAction(Action action)
Definition: BlockActionPacket.cpp:126
void SetPosition(glm::vec3 position)
Definition: BlockActionPacket.cpp:121
std::shared_ptr< IPacket > Clone() const override
Create a new instance of the packet.
Definition: BlockActionPacket.cpp:96
Type
Definition: Block.hpp:33
an abstract class that servers as a base for all network packets
Definition: IPacket.hpp:40
Type
Definition: IPacket.hpp:48