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/ChatState.hpp"
10 #include "../app/IntervalTimer.hpp"
11 #include "../audio/SoundBank.hpp"
12 #include "../graphics/SkyBox.hpp"
13 #include "../io/WorldSave.hpp"
14 #include "../net/Packet.hpp"
15 #include "../shared/WorldResources.hpp"
16 #include "../ui/HUD.hpp"
17 #include "../ui/InteractiveManipulator.hpp"
18 #include "../ui/Interface.hpp"
19 #include "../world/ChunkRenderer.hpp"
20 #include "../world/EntityState.hpp"
21 #include "../world/Player.hpp"
22 #include "../world/World.hpp"
33 class InteractiveState
35 , public ClientController
36 , public ChatState::Responder {
39 explicit InteractiveState(MasterState &, std::uint32_t player_id);
41 World &GetWorld() noexcept { return world; }
42 Player &GetPlayer() noexcept { return player; }
43 PlayerController &GetPlayerController() noexcept { return input; }
44 ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
46 void OnResume() override;
47 void OnPause() override;
49 void OnFocus() override;
50 void OnBlur() override;
52 void Handle(const SDL_Event &) override;
53 void Update(int dt) override;
54 void Render(Viewport &) override;
56 void Handle(const Packet::SpawnEntity &);
57 void Handle(const Packet::DespawnEntity &);
58 void Handle(const Packet::EntityUpdate &);
59 void Handle(const Packet::PlayerCorrection &);
60 void Handle(const Packet::BlockUpdate &);
61 void Handle(const Packet::Message &);
63 void SetAudio(bool) override;
64 void SetVideo(bool) override;
65 void SetHUD(bool) override;
66 void SetDebug(bool) override;
69 void OnLineSubmit(const std::string &) override;
72 /// flag entity as updated by given packet
73 /// returns false if the update should be ignored
74 bool UpdateEntity(std::uint32_t id, std::uint16_t seq);
75 /// drop update information or given entity
76 void ClearEntity(std::uint32_t id);
86 InteractiveManipulator manip;
89 ChunkReceiver chunk_receiver;
90 ChunkRenderer chunk_renderer;
91 CoarseTimer loop_timer;
96 std::uint16_t last_packet;
99 std::map<std::uint32_t, UpdateStatus> update_status;