]> git.localhorst.tv Git - blank.git/blobdiff - src/client/InteractiveState.hpp
block sounds depending on block type
[blank.git] / src / client / InteractiveState.hpp
index 1b9c9a5ba06fc4b42a6a92399daee24ab6ce144a..b86258e9f2bb892bb06309f3e29a9c39ff717dc2 100644 (file)
@@ -5,23 +5,21 @@
 #include "../ui/ClientController.hpp"
 
 #include "ChunkReceiver.hpp"
-#include "ChunkRequester.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 "../ui/DirectInput.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"
 
-#include <list>
-
 
 namespace blank {
 
@@ -41,7 +39,6 @@ public:
        World &GetWorld() noexcept { return world; }
        Player &GetPlayer() noexcept { return player; }
        ChunkReceiver &GetChunkReceiver() noexcept { return chunk_receiver; }
-       Skeletons &GetSkeletons() noexcept { return skeletons; }
 
        void OnEnter() override;
 
@@ -49,8 +46,11 @@ 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;
@@ -58,32 +58,35 @@ 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;
-       BlockTypeRegistry block_types;
+       WorldResources res;
+       SoundBank sounds;
        WorldSave save;
        World world;
        Player &player;
        HUD hud;
        InteractiveManipulator manip;
-       DirectInput input;
+       NetworkedInput input;
        Interface interface;
-       ChunkRequester chunk_requester;
        ChunkReceiver chunk_receiver;
        ChunkRenderer chunk_renderer;
-       Skeletons skeletons;
        IntervalTimer loop_timer;
 
        SkyBox sky;
 
-       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) { }
+       struct UpdateStatus {
+               std::uint16_t last_packet;
+               int last_update;
        };
-       std::list<PlayerHistory> player_hist;
+       std::map<std::uint32_t, UpdateStatus> update_status;
 
 };