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 PlayerController &GetPlayerController() noexcept { return input; }
42 ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
44 void OnEnter() override;
46 void Handle(const SDL_Event &) override;
47 void Update(int dt) override;
48 void Render(Viewport &) override;
50 void Handle(const Packet::SpawnEntity &);
51 void Handle(const Packet::DespawnEntity &);
52 void Handle(const Packet::EntityUpdate &);
53 void Handle(const Packet::PlayerCorrection &);
54 void Handle(const Packet::BlockUpdate &);
56 void SetAudio(bool) override;
57 void SetVideo(bool) override;
58 void SetHUD(bool) override;
59 void SetDebug(bool) 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);
77 InteractiveManipulator manip;
80 ChunkReceiver chunk_receiver;
81 ChunkRenderer chunk_renderer;
82 IntervalTimer loop_timer;
87 std::uint16_t last_packet;
90 std::map<std::uint32_t, UpdateStatus> update_status;