1 #ifndef BLANK_CLIENT_CLIENTSTATE_HPP_
2 #define BLANK_CLIENT_CLIENTSTATE_HPP_
4 #include "../app/State.hpp"
5 #include "../net/ConnectionHandler.hpp"
8 #include "InitialState.hpp"
9 #include "InteractiveState.hpp"
10 #include "../app/Config.hpp"
22 class InteractiveState;
26 , public ConnectionHandler {
35 Client &GetClient() noexcept { return client; }
36 Environment &GetEnv() noexcept { return env; }
38 Config &GetConfig() noexcept { return config; }
39 const Config &GetConfig() const noexcept { return config; }
41 World::Config &GetWorldConf() noexcept { return world_conf; }
42 const World::Config &GetWorldConf() const noexcept { return world_conf; }
46 void OnEnter() override;
48 void Handle(const SDL_Event &) override;
49 void Update(int dt) override;
50 void Render(Viewport &) override;
52 void OnPacketLost(std::uint16_t) override;
53 void OnTimeout() override;
55 void On(const Packet::Join &) override;
56 void On(const Packet::Part &) override;
57 void On(const Packet::SpawnEntity &) override;
58 void On(const Packet::DespawnEntity &) override;
59 void On(const Packet::EntityUpdate &) override;
60 void On(const Packet::PlayerCorrection &) override;
61 void On(const Packet::ChunkBegin &) override;
62 void On(const Packet::ChunkData &) override;
63 void On(const Packet::BlockUpdate &) override;
66 /// flag entity as updated by given packet
67 /// returns false if the update should be ignored
68 bool UpdateEntity(std::uint32_t id, std::uint16_t seq);
69 /// drop update information or given entity
70 void ClearEntity(std::uint32_t id);
75 World::Config world_conf;
76 std::unique_ptr<InteractiveState> state;
79 InitialState init_state;
84 std::uint16_t last_packet;
87 std::map<std::uint32_t, UpdateStatus> update_status;
88 IntervalTimer update_timer;