]> git.localhorst.tv Git - blank.git/blob - src/client/NetworkedInput.hpp
file and directory removal functions
[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         bool UpdateImportant() const noexcept;
24         void Update(Entity &, float dt) override;
25         void PushPlayerUpdate(int dt);
26         void MergePlayerCorrection(std::uint16_t, const EntityState &);
27
28         void StartPrimaryAction() override;
29         void StopPrimaryAction() override;
30         void StartSecondaryAction() override;
31         void StopSecondaryAction() override;
32         void StartTertiaryAction() override;
33         void StopTertiaryAction() override;
34
35 private:
36         Client &client;
37
38         struct PlayerHistory {
39                 EntityState state;
40                 glm::vec3 movement;
41                 float delta_t;
42                 std::uint16_t packet;
43                 PlayerHistory(EntityState s, const glm::vec3 &mv, float dt, std::uint16_t p)
44                 : state(s), movement(mv), delta_t(dt), packet(p) { }
45         };
46         std::list<PlayerHistory> player_hist;
47
48         glm::vec3 old_movement;
49
50         std::uint8_t old_actions;
51         std::uint8_t actions;
52
53 };
54
55 }
56 }
57
58 #endif