]> git.localhorst.tv Git - blank.git/blob - src/client/Client.hpp
transmit player input from client to server
[blank.git] / src / client / Client.hpp
1 #ifndef BLANK_CLIENT_CLIENT_HPP_
2 #define BLANK_CLIENT_CLIENT_HPP_
3
4 #include "../app/Config.hpp"
5 #include "../net/Connection.hpp"
6
7 #include <string>
8 #include <SDL_net.h>
9
10
11 namespace blank {
12
13 class World;
14
15 namespace client {
16
17 class Client {
18
19 public:
20         explicit Client(const Config::Network &);
21         ~Client();
22
23         void Handle();
24
25         void Update(int dt);
26
27         Connection &GetConnection() noexcept { return conn; }
28         const Connection &GetConnection() const noexcept { return conn; }
29
30         std::uint16_t SendPing();
31         std::uint16_t SendLogin(const std::string &);
32         std::uint16_t SendPart();
33         std::uint16_t SendPlayerUpdate(
34                 const EntityState &prediction,
35                 const glm::vec3 &movement,
36                 float pitch,
37                 float yaw,
38                 std::uint8_t actions,
39                 std::uint8_t slot);
40
41 private:
42         void HandlePacket(const UDPpacket &);
43
44 private:
45         Connection conn;
46         UDPsocket client_sock;
47         UDPpacket client_pack;
48
49 };
50
51 }
52 }
53
54 #endif