1 #ifndef BLANK_CLIENT_CLIENTSTATE_HPP_
2 #define BLANK_CLIENT_CLIENTSTATE_HPP_
5 #include "InitialState.hpp"
6 #include "InteractiveState.hpp"
7 #include "../app/State.hpp"
8 #include "../net/ConnectionHandler.hpp"
20 class InteractiveState;
24 , public ConnectionHandler {
29 const World::Config &,
30 const Interface::Config &,
31 const Client::Config &
34 Client &GetClient() noexcept { return client; }
35 Environment &GetEnv() noexcept { return env; }
37 World::Config &GetWorldConf() noexcept { return world_conf; }
38 const World::Config &GetWorldConf() const noexcept { return world_conf; }
39 const Interface::Config &GetInterfaceConf() const noexcept { return intf_conf; }
40 const Client::Config &GetClientConf() const noexcept { return client_conf; }
44 void OnEnter() override;
46 void Handle(const SDL_Event &) override;
47 void Update(int dt) override;
48 void Render(Viewport &) override;
50 void OnPacketLost(std::uint16_t) override;
51 void OnTimeout() override;
53 void On(const Packet::Join &) override;
54 void On(const Packet::Part &) override;
55 void On(const Packet::SpawnEntity &) override;
56 void On(const Packet::DespawnEntity &) override;
57 void On(const Packet::EntityUpdate &) override;
58 void On(const Packet::PlayerCorrection &) override;
59 void On(const Packet::ChunkBegin &) override;
60 void On(const Packet::ChunkData &) override;
63 /// flag entity as updated by given packet
64 /// returns false if the update should be ignored
65 bool UpdateEntity(std::uint32_t id, std::uint16_t seq);
66 /// drop update information or given entity
67 void ClearEntity(std::uint32_t id);
71 World::Config world_conf;
72 const Interface::Config &intf_conf;
73 const Client::Config &client_conf;
74 std::unique_ptr<InteractiveState> state;
77 InitialState init_state;
82 std::uint16_t last_packet;
85 std::map<std::uint32_t, UpdateStatus> update_status;
86 IntervalTimer update_timer;