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 "../audio/SoundBank.hpp"
11 #include "../graphics/SkyBox.hpp"
12 #include "../io/WorldSave.hpp"
13 #include "../net/Packet.hpp"
14 #include "../shared/WorldResources.hpp"
15 #include "../ui/HUD.hpp"
16 #include "../ui/InteractiveManipulator.hpp"
17 #include "../ui/Interface.hpp"
18 #include "../world/ChunkRenderer.hpp"
19 #include "../world/EntityState.hpp"
20 #include "../world/Player.hpp"
21 #include "../world/World.hpp"
32 class InteractiveState
34 , public ClientController {
37 explicit InteractiveState(MasterState &, std::uint32_t player_id);
39 World &GetWorld() noexcept { return world; }
40 Player &GetPlayer() noexcept { return player; }
41 ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
43 void OnEnter() override;
45 void Handle(const SDL_Event &) override;
46 void Update(int dt) override;
47 void Render(Viewport &) override;
49 void Handle(const Packet::SpawnEntity &);
50 void Handle(const Packet::DespawnEntity &);
51 void Handle(const Packet::EntityUpdate &);
52 void Handle(const Packet::PlayerCorrection &);
53 void Handle(const Packet::BlockUpdate &);
55 void SetAudio(bool) override;
56 void SetVideo(bool) override;
57 void SetHUD(bool) override;
58 void SetDebug(bool) override;
62 /// flag entity as updated by given packet
63 /// returns false if the update should be ignored
64 bool UpdateEntity(std::uint32_t id, std::uint16_t seq);
65 /// drop update information or given entity
66 void ClearEntity(std::uint32_t id);
76 InteractiveManipulator manip;
79 ChunkReceiver chunk_receiver;
80 ChunkRenderer chunk_renderer;
81 IntervalTimer loop_timer;
86 std::uint16_t last_packet;
89 std::map<std::uint32_t, UpdateStatus> update_status;