1 #ifndef BLANK_CLIENT_INTERACTIVESTATE_HPP_
2 #define BLANK_CLIENT_INTERACTIVESTATE_HPP_
4 #include "../app/State.hpp"
5 #include "../ui/ClientController.hpp"
7 #include "ChunkReceiver.hpp"
8 #include "NetworkedInput.hpp"
9 #include "../app/IntervalTimer.hpp"
10 #include "../graphics/SkyBox.hpp"
11 #include "../io/WorldSave.hpp"
12 #include "../net/Packet.hpp"
13 #include "../shared/WorldResources.hpp"
14 #include "../ui/HUD.hpp"
15 #include "../ui/InteractiveManipulator.hpp"
16 #include "../ui/Interface.hpp"
17 #include "../world/ChunkRenderer.hpp"
18 #include "../world/EntityState.hpp"
19 #include "../world/Player.hpp"
20 #include "../world/World.hpp"
31 class InteractiveState
33 , public ClientController {
36 explicit InteractiveState(MasterState &, std::uint32_t player_id);
38 World &GetWorld() noexcept { return world; }
39 Player &GetPlayer() noexcept { return player; }
40 ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
42 void OnEnter() override;
44 void Handle(const SDL_Event &) override;
45 void Update(int dt) override;
46 void Render(Viewport &) override;
48 void Handle(const Packet::SpawnEntity &);
49 void Handle(const Packet::DespawnEntity &);
50 void Handle(const Packet::EntityUpdate &);
51 void Handle(const Packet::PlayerCorrection &);
52 void Handle(const Packet::BlockUpdate &);
54 void SetAudio(bool) override;
55 void SetVideo(bool) override;
56 void SetHUD(bool) override;
57 void SetDebug(bool) override;
61 /// flag entity as updated by given packet
62 /// returns false if the update should be ignored
63 bool UpdateEntity(std::uint32_t id, std::uint16_t seq);
64 /// drop update information or given entity
65 void ClearEntity(std::uint32_t id);
74 InteractiveManipulator manip;
77 ChunkReceiver chunk_receiver;
78 ChunkRenderer chunk_renderer;
79 IntervalTimer loop_timer;
84 std::uint16_t last_packet;
87 std::map<std::uint32_t, UpdateStatus> update_status;