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 "../model/ShapeRegistry.hpp"
13 #include "../model/Skeletons.hpp"
14 #include "../net/Packet.hpp"
15 #include "../ui/HUD.hpp"
16 #include "../ui/InteractiveManipulator.hpp"
17 #include "../ui/Interface.hpp"
18 #include "../world/BlockTypeRegistry.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 {
38 explicit InteractiveState(MasterState &, std::uint32_t player_id);
40 World &GetWorld() noexcept { return world; }
41 Player &GetPlayer() noexcept { return player; }
42 ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
43 Skeletons &GetSkeletons() noexcept { return skeletons; }
45 void OnEnter() override;
47 void Handle(const SDL_Event &) override;
48 void Update(int dt) override;
49 void Render(Viewport &) override;
51 void Handle(const Packet::SpawnEntity &);
52 void Handle(const Packet::DespawnEntity &);
53 void Handle(const Packet::EntityUpdate &);
54 void Handle(const Packet::PlayerCorrection &);
55 void Handle(const Packet::BlockUpdate &);
57 void SetAudio(bool) override;
58 void SetVideo(bool) override;
59 void SetHUD(bool) override;
60 void SetDebug(bool) override;
64 /// flag entity as updated by given packet
65 /// returns false if the update should be ignored
66 bool UpdateEntity(std::uint32_t id, std::uint16_t seq);
67 /// drop update information or given entity
68 void ClearEntity(std::uint32_t id);
73 BlockTypeRegistry block_types;
78 InteractiveManipulator manip;
81 ChunkReceiver chunk_receiver;
82 ChunkRenderer chunk_renderer;
84 IntervalTimer loop_timer;
88 std::vector<float> tex_map;
91 std::uint16_t last_packet;
94 std::map<std::uint32_t, UpdateStatus> update_status;