Potato Engine
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
9
10class Player;
11class World;
12
24#define SET_DEFAULT_SUBCLASS(def, set) \
25static 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
36class GameInstance : public IEngineSubsystem
37{
38public:
43 static GameInstance* get();
44 virtual void Resolve() noexcept override;
45
46 void LoadSubobjects();
47
49 World* GetWorld() const;
52
57 void RequestShutdown();
58
80
81private:
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
89private:
90
91 PlayerController* ActivePlayerController;
92 World* world;
93
94};
95
96namespace __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}
int MS_REPEAT_THRESHOLD
Threshold to wait for input completion in milliseconds.
bool _isMainTickRunning
static GameInstance * get()
Gets singleton instance.
PlayerController * GetPlayerController() const
Gets player controller object.
float FRAMES_PER_SECOND
Global FPS constant for screen refresh.
void RequestShutdown()
Requests to queue engine shutdown.
World * GetWorld() const
Gets world object.
Interface for internal engine classes.
Main managing class for the player, controlling interactions and non-local behavior.
User controllable character.
Definition Player.hpp:12
Local level managing gameplay interactions.
Definition World.hpp:19