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