X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fclient%2FInteractiveState.hpp;h=2bc459a330a875e9fb748a9e0a10fda43f61c020;hb=7e782291e0ce39eb2d4e8c1df28f682c313e6f8d;hp=09a9919a2e7b15c8c563a480bdae426420480c02;hpb=ac41db13c9d64f5ef12b26c335d57504d02fd2fd;p=blank.git diff --git a/src/client/InteractiveState.hpp b/src/client/InteractiveState.hpp index 09a9919..2bc459a 100644 --- a/src/client/InteractiveState.hpp +++ b/src/client/InteractiveState.hpp @@ -1,18 +1,26 @@ #ifndef BLANK_CLIENT_INTERACTIVESTATE_HPP_ #define BLANK_CLIENT_INTERACTIVESTATE_HPP_ -#include "../app/IntervalTimer.hpp" #include "../app/State.hpp" +#include "../ui/ClientController.hpp" + +#include "ChunkReceiver.hpp" +#include "NetworkedInput.hpp" +#include "../app/IntervalTimer.hpp" +#include "../graphics/SkyBox.hpp" #include "../io/WorldSave.hpp" -#include "../model/Skeletons.hpp" +#include "../model/ModelRegistry.hpp" +#include "../model/ShapeRegistry.hpp" +#include "../net/Packet.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" -#include - namespace blank { @@ -23,14 +31,16 @@ 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; } - Skeletons &GetSkeletons() noexcept { return skeletons; } + Player &GetPlayer() noexcept { return player; } + ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; } + ModelRegistry &GetModels() noexcept { return models; } void OnEnter() override; @@ -38,27 +48,48 @@ public: void Update(int dt) override; void Render(Viewport &) override; - void PushPlayerUpdate(const Entity &, int dt); - void MergePlayerCorrection(std::uint16_t, const EntityState &); + 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; + ShapeRegistry shapes; BlockTypeRegistry block_types; + ModelRegistry models; WorldSave save; World world; + Player &player; + HUD hud; + InteractiveManipulator manip; + NetworkedInput input; Interface interface; + ChunkReceiver chunk_receiver; ChunkRenderer chunk_renderer; - Skeletons skeletons; IntervalTimer loop_timer; - struct PlayerHistory { - EntityState state; - int delta_t; - std::uint16_t packet; - PlayerHistory(EntityState s, int dt, std::uint16_t p) - : state(s), delta_t(dt), packet(p) { } + SkyBox sky; + + struct UpdateStatus { + std::uint16_t last_packet; + int last_update; }; - std::list player_hist; + std::map update_status; };