X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fclient%2FInteractiveState.hpp;h=d5fd4a1859fb3c8b188e7f03bed58023ceff0c49;hb=69e4d6c0a86a27f9b3f1297e46c55b36059a24b9;hp=86757a294c10501dd28c074a28ba59410220bb59;hpb=3a487f44c26f9bb9d1a1c831406b6497b2b3b425;p=blank.git diff --git a/src/client/InteractiveState.hpp b/src/client/InteractiveState.hpp index 86757a2..d5fd4a1 100644 --- a/src/client/InteractiveState.hpp +++ b/src/client/InteractiveState.hpp @@ -7,15 +7,15 @@ #include "ChunkReceiver.hpp" #include "NetworkedInput.hpp" #include "../app/IntervalTimer.hpp" +#include "../audio/SoundBank.hpp" #include "../graphics/SkyBox.hpp" #include "../io/WorldSave.hpp" -#include "../model/ShapeRegistry.hpp" -#include "../model/Skeletons.hpp" #include "../net/Packet.hpp" +#include "../shared/ChatState.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" @@ -32,24 +32,33 @@ class MasterState; class InteractiveState : public State -, public ClientController { +, public ClientController +, public ChatState::Responder { public: explicit InteractiveState(MasterState &, std::uint32_t player_id); World &GetWorld() noexcept { return world; } Player &GetPlayer() noexcept { return player; } + PlayerController &GetPlayerController() noexcept { return input; } ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; } - Skeletons &GetSkeletons() noexcept { return skeletons; } - void OnEnter() override; + void OnResume() override; + void OnPause() override; + + void OnFocus() override; + void OnBlur() override; void Handle(const SDL_Event &) override; 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 Handle(const Packet::Message &); void SetAudio(bool) override; void SetVideo(bool) override; @@ -57,10 +66,19 @@ public: void SetDebug(bool) override; void Exit() override; + void OnLineSubmit(const std::string &) 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; + WorldResources res; + SoundBank sounds; WorldSave save; World world; Player &player; @@ -70,11 +88,18 @@ private: Interface interface; ChunkReceiver chunk_receiver; ChunkRenderer chunk_renderer; - Skeletons skeletons; - IntervalTimer loop_timer; + CoarseTimer loop_timer; SkyBox sky; + struct UpdateStatus { + std::uint16_t last_packet; + int last_update; + }; + std::map update_status; + + ChatState chat; + }; }