X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fclient%2FInteractiveState.hpp;h=b86258e9f2bb892bb06309f3e29a9c39ff717dc2;hb=07b8335e7bfd631e0878e183c87238812d632c56;hp=efaeae425c03d869ef8df008ebad386793138b72;hpb=13e676a6e49128ebc6c63b8dd08bef51d360e8e9;p=blank.git diff --git a/src/client/InteractiveState.hpp b/src/client/InteractiveState.hpp index efaeae4..b86258e 100644 --- a/src/client/InteractiveState.hpp +++ b/src/client/InteractiveState.hpp @@ -2,10 +2,22 @@ #define BLANK_CLIENT_INTERACTIVESTATE_HPP_ #include "../app/State.hpp" +#include "../ui/ClientController.hpp" + +#include "ChunkReceiver.hpp" +#include "NetworkedInput.hpp" +#include "../app/IntervalTimer.hpp" +#include "../audio/SoundBank.hpp" +#include "../graphics/SkyBox.hpp" #include "../io/WorldSave.hpp" +#include "../net/Packet.hpp" +#include "../shared/WorldResources.hpp" +#include "../ui/HUD.hpp" +#include "../ui/InteractiveManipulator.hpp" #include "../ui/Interface.hpp" -#include "../world/BlockTypeRegistry.hpp" #include "../world/ChunkRenderer.hpp" +#include "../world/EntityState.hpp" +#include "../world/Player.hpp" #include "../world/World.hpp" @@ -18,13 +30,15 @@ namespace client { class MasterState; class InteractiveState -: public State { +: public State +, public ClientController { public: explicit InteractiveState(MasterState &, std::uint32_t player_id); World &GetWorld() noexcept { return world; } - Interface &GetInterface() noexcept { return interface; } + Player &GetPlayer() noexcept { return player; } + ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; } void OnEnter() override; @@ -32,13 +46,47 @@ public: void Update(int dt) override; void Render(Viewport &) override; + void Handle(const Packet::SpawnEntity &); + void Handle(const Packet::DespawnEntity &); + void Handle(const Packet::EntityUpdate &); + void Handle(const Packet::PlayerCorrection &); + void Handle(const Packet::BlockUpdate &); + + void SetAudio(bool) override; + void SetVideo(bool) override; + void SetHUD(bool) override; + void SetDebug(bool) override; + void Exit() override; + +private: + /// flag entity as updated by given packet + /// returns false if the update should be ignored + bool UpdateEntity(std::uint32_t id, std::uint16_t seq); + /// drop update information or given entity + void ClearEntity(std::uint32_t id); + private: MasterState &master; - BlockTypeRegistry block_types; + WorldResources res; + SoundBank sounds; WorldSave save; World world; + Player &player; + HUD hud; + InteractiveManipulator manip; + NetworkedInput input; Interface interface; + ChunkReceiver chunk_receiver; ChunkRenderer chunk_renderer; + IntervalTimer loop_timer; + + SkyBox sky; + + struct UpdateStatus { + std::uint16_t last_packet; + int last_update; + }; + std::map update_status; };