]> git.localhorst.tv Git - blank.git/blobdiff - src/client/NetworkedInput.hpp
transmit player input from client to server
[blank.git] / src / client / NetworkedInput.hpp
diff --git a/src/client/NetworkedInput.hpp b/src/client/NetworkedInput.hpp
new file mode 100644 (file)
index 0000000..462b6a7
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef BLANK_CLIENT_NETWORKEDINPUT_HPP_
+#define BLANK_CLIENT_NETWORKEDINPUT_HPP_
+
+#include "../ui/PlayerController.hpp"
+
+#include "../world/EntityState.hpp"
+
+#include <cstdint>
+#include <list>
+
+
+namespace blank {
+namespace client {
+
+class Client;
+
+class NetworkedInput
+: public PlayerController {
+
+public:
+       explicit NetworkedInput(World &, Player &, Client &);
+
+       void Update(int dt);
+       void PushPlayerUpdate(int dt);
+       void MergePlayerCorrection(std::uint16_t, const EntityState &);
+
+       void StartPrimaryAction() override;
+       void StopPrimaryAction() override;
+       void StartSecondaryAction() override;
+       void StopSecondaryAction() override;
+       void StartTertiaryAction() override;
+       void StopTertiaryAction() override;
+
+private:
+       Client &client;
+
+       struct PlayerHistory {
+               EntityState state;
+               int delta_t;
+               std::uint16_t packet;
+               PlayerHistory(EntityState s, int dt, std::uint16_t p)
+               : state(s), delta_t(dt), packet(p) { }
+       };
+       std::list<PlayerHistory> player_hist;
+
+       std::uint8_t actions;
+
+};
+
+}
+}
+
+#endif