-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerStatePacket.hpp
More file actions
92 lines (87 loc) · 2.25 KB
/
Copy pathPlayerStatePacket.hpp
File metadata and controls
92 lines (87 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include "../Export.h"
#include "Network/Packet.h"
#include "Core/Reflection/TypeTraits.hpp"
#include <array>
namespace sh::game
{
class PlayerStatePacket : public network::Packet
{
SPACKET(PlayerStatePacket, ID)
public:
constexpr static uint32_t ID = (core::reflection::TypeTraits::GetTypeHash<PlayerStatePacket>() >> 32);
public:
auto GetId() const -> uint32_t override
{
return ID;
}
auto Serialize() const -> core::Json override
{
auto json = network::Packet::Serialize();
json["px"] = px;
json["py"] = py;
json["vx"] = vx;
json["vy"] = vy;
json["lastSeq"] = lastProcessedInputSeq;
json["player"] = playerUUID;
json["st"] = serverTick;
json["ct"] = clientTickAtState;
json["ground"] = bGround;
json["prone"] = bProne;
json["lock"] = bLock;
json["right"] = bRight;
json["bUp"] = bUp;
json["skid"] = skillId;
json["skusing"] = bSkillUsing;
return json;
}
void Deserialize(const core::Json& json) override
{
network::Packet::Deserialize(json);
if (json.contains("px"))
px = json["px"];
if (json.contains("py"))
py = json["py"];
if (json.contains("vx"))
vx = json["vx"];
if (json.contains("vy"))
vy = json["vy"];
if (json.contains("lastSeq"))
lastProcessedInputSeq = json["lastSeq"];
if (json.contains("player"))
playerUUID = json["player"];
if (json.contains("st"))
serverTick = json["st"];
if (json.contains("ct"))
clientTickAtState = json["ct"];
if (json.contains("ground"))
bGround = json["ground"];
if (json.contains("prone"))
bProne = json["prone"];
if (json.contains("lock"))
bLock = json["lock"];
if (json.contains("right"))
bRight = json["right"];
if (json.contains("bUp"))
bUp = json["bUp"];
if (json.contains("skid"))
skillId = json["skid"];
if (json.contains("skusing"))
bSkillUsing = json["skusing"];
}
public:
float px = 0.f, py = 0.f;
float vx = 0.f, vy = 0.f;
uint64_t lastProcessedInputSeq = 0;
uint64_t serverTick = 0;
uint64_t clientTickAtState = 0;
std::array<uint32_t, 4> playerUUID;
bool bGround = false;
bool bProne = false;
bool bLock = false;
bool bRight = false;
bool bUp = false;
uint32_t skillId = 0;
bool bSkillUsing = false;
};
}//namespace