]> git.localhorst.tv Git - blank.git/blobdiff - src/client/InteractiveState.hpp
cleanup of sdl event to string functions
[blank.git] / src / client / InteractiveState.hpp
index eaca4c9c78880d8679755c24d71f2558f7ea1977..f371c8ca837aeb094c7ef5dc719b3f1b84c494f7 100644 (file)
@@ -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 "../audio/SoundBank.hpp"
+#include "../graphics/SkyBox.hpp"
 #include "../io/WorldSave.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"
 #include "../world/World.hpp"
 
-#include <list>
-
 
 namespace blank {
 
@@ -23,42 +31,79 @@ namespace client {
 class MasterState;
 
 class InteractiveState
-: public State {
+: public State
+, public ClientController
+, public ChatState::Responder {
 
 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; }
+       PlayerController &GetPlayerController() noexcept { return input; }
+       ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
 
-       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 PushPlayerUpdate(const Entity &);
-       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;
+       void SetHUD(bool) override;
+       void SetDebug(bool) override;
+       void NextCamera() 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;
-       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;
-       Skeletons skeletons;
-       IntervalTimer loop_timer;
-       IntervalTimer update_timer;
-
-       struct PlayerHistory {
-               EntityState state;
-               std::uint16_t packet;
-               PlayerHistory(EntityState s, std::uint16_t p)
-               : state(s), packet(p) { }
+       CoarseTimer loop_timer;
+       CoarseTimer stat_timer;
+
+       SkyBox sky;
+
+       struct UpdateStatus {
+               std::uint16_t last_packet;
+               int last_update;
        };
-       std::list<PlayerHistory> player_hist;
+       std::map<std::uint32_t, UpdateStatus> update_status;
+
+       ChatState chat;
+
+       int time_skipped;
+       unsigned int packets_skipped;
 
 };