-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_state.fbs
127 lines (110 loc) · 2.46 KB
/
game_state.fbs
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// defined to mirror RayLib's Vector3 def
struct OD_Vector3 {
x: float;
y: float;
z: float;
}
struct OD_Vector2 {
x: float;
y: float;
}
// defined to mirror RayLib's BoundingBox def
struct OD_BoundingBox {
min: OD_Vector3;
max: OD_Vector3;
}
//TODO: define a Raylib Model in the future (many dependencies need to be defined)
// Define the enums. ALL RELIABLE except for Input & DifferentialState, ad GlobalState
enum PacketType : byte {
// Client --> Server
CreateLobby,
Join,
Start,
Input,
Leave,
CreateLobbyResult,
//Server --> Client
StartResult,
JoinResult,
LeaveResult,
GlobalState, //TODO: send global snapshot every so often
DifferentialState, // TODO: portions of this will be null (so not sent/encoded)
Timeout,
Revert, //TODO: If there is packet loss, send this packet with the last ack'ed (full state) so client can revert back to this state
}
table SourcePoint {
address: string;
port: uint;
}
table DestPoint {
address: string;
port: uint;
}
// for both the client and server
struct Tick{
tick_number: uint;
dt: float;
}
table OD_Camera3D {
position: OD_Vector3;
target: OD_Vector3;
up: OD_Vector3;
fovy: float;
projection: int;
}
// Define the contents of an Entity
table Entity {
entity_id: uint;
entity_label: string;
position: OD_Vector3;
facing: OD_Vector3;
velocity: OD_Vector3;
alive: bool;
}
// Define the state of a Client
table Client {
source_point: SourcePoint;
tick: Tick;
client_uid: uint;
alive: bool;
sprint: bool;
// crouch: bool;
camera: OD_Camera3D;
grounded: bool;
cooldown: float;
position: OD_Vector3;
facing: OD_Vector3;
velocity: OD_Vector3;
entities:[Entity];
}
table Input {
w: bool;
a: bool;
s: bool;
d: bool;
mouse_delta: OD_Vector2;
shoot: bool;
space: bool;
dt: float;
previous_position: OD_Vector3;
sprint: bool;
crouch: bool;
//implement future support for sliding
}
table GlobalState {
client_state:[Client];
}
union PacketPayload {
Input,
GlobalState,
}
table OD_Packet {
packet_type: PacketType;
dest_point: DestPoint;
source_point: SourcePoint;
lobby_number :uint;
reliable: bool; //TODO: find a way to keep this out of the buffer (but have a way for the transmitter to check if it is reliable)
tick: Tick;
payload: PacketPayload;
}
root_type OD_Packet;