diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2019-01-27 03:23:40 +0100 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2019-01-27 03:23:40 +0100 |
commit | 3043fe13bbca4fc10cae7d74beabc696aa2d6451 (patch) | |
tree | 92bd173ffb66a1fc55abd11e155b0f5860b26521 /src/GameState.hpp | |
parent | Updated .gitignore (diff) | |
download | AltCraft-3043fe13bbca4fc10cae7d74beabc696aa2d6451.tar AltCraft-3043fe13bbca4fc10cae7d74beabc696aa2d6451.tar.gz AltCraft-3043fe13bbca4fc10cae7d74beabc696aa2d6451.tar.bz2 AltCraft-3043fe13bbca4fc10cae7d74beabc696aa2d6451.tar.lz AltCraft-3043fe13bbca4fc10cae7d74beabc696aa2d6451.tar.xz AltCraft-3043fe13bbca4fc10cae7d74beabc696aa2d6451.tar.zst AltCraft-3043fe13bbca4fc10cae7d74beabc696aa2d6451.zip |
Diffstat (limited to '')
-rw-r--r-- | src/GameState.hpp | 140 |
1 files changed, 94 insertions, 46 deletions
diff --git a/src/GameState.hpp b/src/GameState.hpp index e96af29..cd39a48 100644 --- a/src/GameState.hpp +++ b/src/GameState.hpp @@ -1,73 +1,121 @@ #pragma once -#include <mutex> -#include <queue> #include <memory> +#include <string> +#include <vector> #include <glm/mat4x4.hpp> +#include "Vector.hpp" #include "World.hpp" #include "Window.hpp" class Packet; -class NetworkClient; class Entity; +struct TimeStatus { + double interpolatedTimeOfDay = 0; + long long worldAge = 0; + long long timeOfDay = 0; + bool doDaylightCycle = true; +}; + +struct GameStatus { + std::string levelType; + Vector spawnPosition; + int gamemode = 0; + int dimension = 0; + unsigned char difficulty = 0; + unsigned char maxPlayers = 0; + bool isGameStarted = false; + bool reducedDebugInfo = false; +}; + +struct PlayerStatus { + std::string uid; + std::string name; + float flyingSpeed = 0; + float fovModifier = 0; + float health = 0; + int eid = 0; + bool invulnerable = false; + bool flying = false; + bool allowFlying = false; + bool creativeMode = false; +}; + +struct SelectionStatus { + VectorF raycastHit; + Vector selectedBlock; + float distanceToSelectedBlock; + bool isBlockSelected; +}; + class GameState { -public: + Entity* player = nullptr; + + World world; + + TimeStatus timeStatus; - GameState() = default; + GameStatus gameStatus; - ~GameState() = default; + PlayerStatus playerStatus; + + SelectionStatus selectionStatus; + + Window playerInventory; + + std::vector<Window> openedWindows; +public: void Update(float deltaTime); void UpdatePacket(std::shared_ptr<Packet> ptr); - enum Direction { - FORWARD, BACKWARD, LEFT, RIGHT, JUMP - }; void StartDigging(); + void FinishDigging(); + void CancelDigging(); + void PlaceBlock(); - void HandleMovement(GameState::Direction direction, float deltaTime); + + enum MoveType { + FORWARD, BACKWARD, LEFT, RIGHT, JUMP + }; + + void HandleMovement(GameState::MoveType direction, float deltaTime); + void HandleRotation(double yaw, double pitch); + glm::mat4 GetViewMatrix(); - Entity* player; - - World world; - - std::string g_PlayerUuid = ""; - std::string g_PlayerName = ""; - bool g_IsGameStarted = false; - int g_PlayerEid = 0; - int g_Gamemode = 0; - int g_Dimension = 0; - unsigned char g_Difficulty = 0; - unsigned char g_MaxPlayers = 0; - std::string g_LevelType = ""; - bool g_ReducedDebugInfo = false; - Vector g_SpawnPosition; - bool g_PlayerInvulnerable = false; - bool g_PlayerFlying = false; - bool g_PlayerAllowFlying = false; - bool g_PlayerCreativeMode = false; - float g_PlayerFlyingSpeed = 0; - float g_PlayerFovModifier = 0; - float g_PlayerHealth = 0; - - long long WorldAge = 0; - long long TimeOfDay = 0; - - Window playerInventory; - std::vector<Window> openedWindows; - - bool isBlockSelected; - Vector selectedBlock; - float distanceToSelectedBlock; - VectorF raycastHit; - - double interpolatedTimeOfDay; - bool doDaylightCycle = true; + + inline Entity *GetPlayer() { + return player; + } + + inline World &GetWorld() { + return world; + } + + inline TimeStatus GetTimeStatus() { + return timeStatus; + } + + inline GameStatus GetGameStatus() { + return gameStatus; + } + + inline PlayerStatus GetPlayerStatus() { + return playerStatus; + } + + inline SelectionStatus GetSelectionStatus() { + return selectionStatus; + } + + inline Window &GetInventory() { + return playerInventory; + } }; |