Potato Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
GameInstance.hpp
Go to the documentation of this file.
1
2
#pragma once
3
4
#include <functional>
5
#include <type_traits>
6
7
#include "
PlayerController.hpp
"
8
#include "
Core/EngineSubsystem.hpp
"
9
10
class
Player
;
11
class
World
;
12
24
#define SET_DEFAULT_SUBCLASS(def, set) \
25
static struct __##set##_DEFAULT_SUBCLASS_REGISTER { \
26
__##set##_DEFAULT_SUBCLASS_REGISTER() { \
27
__DEFAULT_INSTANTIATORS::get_##def() = []() -> def* { return new set(); }; \
28
} \
29
} __##set##_DEFAULT_SUBCLASS_REGISTER_i;
30
36
class
GameInstance :
public
IEngineSubsystem
37
{
38
public
:
43
static
GameInstance*
get
();
44
virtual
void
Resolve()
noexcept
override
;
45
46
void
LoadSubobjects();
47
49
World
*
GetWorld
()
const
;
51
PlayerController
*
GetPlayerController
()
const
;
52
57
void
RequestShutdown
();
58
63
bool
_isMainTickRunning
;
68
float
FRAMES_PER_SECOND
;
79
int
MS_REPEAT_THRESHOLD
;
80
81
private
:
82
GameInstance();
83
~GameInstance();
84
GameInstance(
const
GameInstance&) =
delete
;
85
GameInstance& operator = (
const
GameInstance&) =
delete
;
86
GameInstance(GameInstance&&) =
delete
;
87
GameInstance& operator = (GameInstance&&) =
delete
;
88
89
private
:
90
91
PlayerController
* ActivePlayerController;
92
World
* world;
93
94
};
95
96
namespace
__DEFAULT_INSTANTIATORS {
97
inline
std::function<
Player
*()>& get_Player() {
98
static
std::function<
Player
*()> f;
99
return
f;
100
}
101
inline
std::function<PlayerController*()>& get_PlayerController() {
102
static
std::function<PlayerController*()> f;
103
return
f;
104
}
105
}
EngineSubsystem.hpp
PlayerController.hpp
GameInstance::MS_REPEAT_THRESHOLD
int MS_REPEAT_THRESHOLD
Threshold to wait for input completion in milliseconds.
Definition
GameInstance.hpp:79
GameInstance::_isMainTickRunning
bool _isMainTickRunning
Definition
GameInstance.hpp:63
GameInstance::get
static GameInstance * get()
Gets singleton instance.
Definition
GameInstance.cpp:8
GameInstance::GetPlayerController
PlayerController * GetPlayerController() const
Gets player controller object.
Definition
GameInstance.cpp:49
GameInstance::FRAMES_PER_SECOND
float FRAMES_PER_SECOND
Global FPS constant for screen refresh.
Definition
GameInstance.hpp:68
GameInstance::RequestShutdown
void RequestShutdown()
Requests to queue engine shutdown.
Definition
GameInstance.cpp:39
GameInstance::GetWorld
World * GetWorld() const
Gets world object.
Definition
GameInstance.cpp:48
IEngineSubsystem
Interface for internal engine classes.
Definition
EngineSubsystem.hpp:9
PlayerController
Main managing class for the player, controlling interactions and non-local behavior.
Definition
PlayerController.hpp:13
Player
User controllable character.
Definition
Player.hpp:12
World
Local level managing gameplay interactions.
Definition
World.hpp:19
Game
Control
GameInstance.hpp
Generated by
1.17.0