X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fclient%2FInteractiveState.hpp;h=2bc459a330a875e9fb748a9e0a10fda43f61c020;hb=4e3afb4c7631591b80cb7740a9b6f46da69b7ae4;hp=8e7064eacf0a1e2be1f98bf309abe463f26d7043;hpb=d5ef462f3bd70a9717c1309466ce8d90b038c5cd;p=blank.git diff --git a/src/client/InteractiveState.hpp b/src/client/InteractiveState.hpp index 8e7064e..2bc459a 100644 --- a/src/client/InteractiveState.hpp +++ b/src/client/InteractiveState.hpp @@ -9,7 +9,8 @@ #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" @@ -39,7 +40,7 @@ public: World &GetWorld() noexcept { return world; } Player &GetPlayer() noexcept { return player; } ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; } - Skeletons &GetSkeletons() noexcept { return skeletons; } + ModelRegistry &GetModels() noexcept { return models; } void OnEnter() override; @@ -47,7 +48,10 @@ public: void Update(int dt) override; void Render(Viewport &) override; - 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; @@ -56,9 +60,18 @@ public: 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; @@ -68,11 +81,16 @@ private: Interface interface; ChunkReceiver chunk_receiver; ChunkRenderer chunk_renderer; - Skeletons skeletons; IntervalTimer loop_timer; SkyBox sky; + struct UpdateStatus { + std::uint16_t last_packet; + int last_update; + }; + std::map update_status; + }; }