]> git.localhorst.tv Git - blank.git/blob - src/client/InteractiveState.hpp
more packet introspection from payload
[blank.git] / src / client / InteractiveState.hpp
1 #ifndef BLANK_CLIENT_INTERACTIVESTATE_HPP_
2 #define BLANK_CLIENT_INTERACTIVESTATE_HPP_
3
4 #include "../app/IntervalTimer.hpp"
5 #include "../app/State.hpp"
6 #include "../io/WorldSave.hpp"
7 #include "../model/Skeletons.hpp"
8 #include "../net/ChunkReceiver.hpp"
9 #include "../ui/Interface.hpp"
10 #include "../world/BlockTypeRegistry.hpp"
11 #include "../world/ChunkRenderer.hpp"
12 #include "../world/EntityState.hpp"
13 #include "../world/World.hpp"
14
15 #include <list>
16
17
18 namespace blank {
19
20 class Environment;
21
22 namespace client {
23
24 class MasterState;
25
26 class InteractiveState
27 : public State {
28
29 public:
30         explicit InteractiveState(MasterState &, std::uint32_t player_id);
31
32         World &GetWorld() noexcept { return world; }
33         Interface &GetInterface() noexcept { return interface; }
34         ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
35         Skeletons &GetSkeletons() noexcept { return skeletons; }
36
37         void OnEnter() override;
38
39         void Handle(const SDL_Event &) override;
40         void Update(int dt) override;
41         void Render(Viewport &) override;
42
43         void PushPlayerUpdate(const Entity &, int dt);
44         void MergePlayerCorrection(std::uint16_t, const EntityState &);
45
46 private:
47         MasterState &master;
48         BlockTypeRegistry block_types;
49         WorldSave save;
50         World world;
51         Interface interface;
52         ChunkReceiver chunk_receiver;
53         ChunkRenderer chunk_renderer;
54         Skeletons skeletons;
55         IntervalTimer loop_timer;
56
57         struct PlayerHistory {
58                 EntityState state;
59                 int delta_t;
60                 std::uint16_t packet;
61                 PlayerHistory(EntityState s, int dt, std::uint16_t p)
62                 : state(s), delta_t(dt), packet(p) { }
63         };
64         std::list<PlayerHistory> player_hist;
65
66 };
67
68 }
69 }
70
71 #endif