]> git.localhorst.tv Git - blank.git/blob - src/client/NetworkedInput.hpp
use "forces" for entity control and RK4 integrator
[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                 glm::vec3 tgt_vel;
40                 int delta_t;
41                 std::uint16_t packet;
42                 PlayerHistory(EntityState s, const glm::vec3 &tv, int dt, std::uint16_t p)
43                 : state(s), tgt_vel(tv), delta_t(dt), packet(p) { }
44         };
45         std::list<PlayerHistory> player_hist;
46
47         std::uint8_t actions;
48
49 };
50
51 }
52 }
53
54 #endif