]> git.localhorst.tv Git - blank.git/blob - src/client/NetworkedInput.hpp
basic message state
[blank.git] / src / client / NetworkedInput.hpp
1 #ifndef BLANK_CLIENT_NETWORKEDINPUT_HPP_
2 #define BLANK_CLIENT_NETWORKEDINPUT_HPP_
3
4 #include "../ui/PlayerController.hpp"
5
6 #include "../world/EntityState.hpp"
7
8 #include <cstdint>
9 #include <list>
10
11
12 namespace blank {
13 namespace client {
14
15 class Client;
16
17 class NetworkedInput
18 : public PlayerController {
19
20 public:
21         explicit NetworkedInput(World &, Player &, Client &);
22
23         void Update(int dt);
24         void PushPlayerUpdate(int dt);
25         void MergePlayerCorrection(std::uint16_t, const EntityState &);
26
27         void StartPrimaryAction() override;
28         void StopPrimaryAction() override;
29         void StartSecondaryAction() override;
30         void StopSecondaryAction() override;
31         void StartTertiaryAction() override;
32         void StopTertiaryAction() override;
33
34 private:
35         Client &client;
36
37         struct PlayerHistory {
38                 EntityState state;
39                 int delta_t;
40                 std::uint16_t packet;
41                 PlayerHistory(EntityState s, int dt, std::uint16_t p)
42                 : state(s), delta_t(dt), packet(p) { }
43         };
44         std::list<PlayerHistory> player_hist;
45
46         std::uint8_t actions;
47
48 };
49
50 }
51 }
52
53 #endif