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