]> git.localhorst.tv Git - blank.git/blob - src/client/ChunkReceiver.hpp
centralize entity controllers
[blank.git] / src / client / ChunkReceiver.hpp
1 #ifndef BLANK_CLIENT_CHUNKRECEIVER_HPP_
2 #define BLANK_CLIENT_CHUNKRECEIVER_HPP_
3
4 #include "../app/IntervalTimer.hpp"
5 #include "../net/Packet.hpp"
6
7 #include <cstdint>
8 #include <list>
9
10
11 namespace blank {
12
13 class ChunkStore;
14 class WorldSave;
15
16 namespace client {
17
18 class ChunkTransmission;
19
20 class ChunkReceiver {
21
22 public:
23         ChunkReceiver(ChunkStore &, const WorldSave &);
24         ~ChunkReceiver();
25
26         void Update(int dt);
27
28         int ToLoad() const noexcept;
29
30         void LoadOne();
31         void LoadN(std::size_t n);
32
33         void StoreN(std::size_t n);
34
35         void Handle(const Packet::ChunkBegin &);
36         void Handle(const Packet::ChunkData &);
37
38 private:
39         ChunkTransmission &GetTransmission(std::uint32_t id);
40         void Commit(ChunkTransmission &);
41
42 private:
43         ChunkStore &store;
44         const WorldSave &save;
45         std::list<ChunkTransmission> transmissions;
46         CoarseTimer timer;
47
48 };
49
50 }
51 }
52
53 #endif