summaryrefslogtreecommitdiffstats
path: root/src/GameState.hpp
blob: e96af29ce4b8f9b5ff3697bbdd8dc3fb3073c04a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once

#include <mutex>
#include <queue>
#include <memory>

#include <glm/mat4x4.hpp>

#include "World.hpp"
#include "Window.hpp"

class Packet;
class NetworkClient;
class Entity;

class GameState {
public:

    GameState() = default;

    ~GameState() = default;

    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);
    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;
};