11#include "game/GameInstance.h"
12#include "input/InputManager.h"
13#include "input/KeyboardKey.hpp"
14#include "input/MouseButton.hpp"
15#include "misc/ThreadPool.h"
16#include "game/World.h"
17#include "render/RenderSettings.h"
180 const std::function<
void(
const std::optional<Error>&)>& onCreated,
213 const std::function<
void(
const std::optional<Error>&)>& onLoaded,
214 const std::filesystem::path& pathToNodeTree,
321 [[nodiscard]] std::optional<Error>
initialize(std::optional<RendererType> preferredRenderer);
338 template <
typename MyGameInstance>
339 requires std::derived_from<MyGameInstance, GameInstance>
447 std::variant<KeyboardKey, MouseButton> key,
KeyboardModifiers modifiers,
bool bIsPressedDown);
473 std::pair<std::recursive_mutex, std::unique_ptr<World>>
mtxWorld;
516 "- you are switching a world but your game instance holds some non-nullptr gc pointers,\n"
517 "- you are not using STL container wrappers for gc "
518 "pointers (for example, you need to use `sgc::GcVector<sgc::GcPtr<T>>` instead of "
519 "`std::vector<sgc::GcPtr<T>>`, and other `gc_*` containers when storing gc pointers),\n"
520 "- you are capturing `sgc::GcPtr` pointer(s) in `std::function` (this might leak in some "
522 "- for a more detailed list of possible issues see the \"README\" file at "
523 "https://github.com/Flone-dnb/sgc";
Definition: CameraManager.h:16
Definition: GameInstance.h:32
Definition: GameManager.h:34
void runGarbageCollection(bool bForce=false)
Definition: GameManager.cpp:238
static const char * sGcLeakReasons
Definition: GameManager.h:515
float getWorldTimeInSeconds()
Definition: GameManager.cpp:458
std::unique_ptr< GameInstance > pGameInstance
Definition: GameManager.h:470
void addTaskToThreadPool(const std::function< void()> &task)
Definition: GameManager.cpp:387
void triggerActionEvents(std::variant< KeyboardKey, MouseButton > key, KeyboardModifiers modifiers, bool bIsPressedDown)
Definition: GameManager.cpp:609
bool bIsBeingDestroyed
Definition: GameManager.h:512
std::unique_ptr< CameraManager > pCameraManager
Definition: GameManager.h:479
ThreadPool threadPool
Definition: GameManager.h:482
std::pair< std::recursive_mutex, std::unique_ptr< World > > mtxWorld
Definition: GameManager.h:473
Window * getWindow() const
Definition: GameManager.cpp:588
std::optional< Error > initialize(std::optional< RendererType > preferredRenderer)
Definition: GameManager.cpp:60
size_t getCalledEveryFrameNodeCount()
Definition: GameManager.cpp:488
InputManager inputManager
Definition: GameManager.h:491
void setGarbageCollectorRunInterval(long long iGcRunIntervalInSec)
Definition: GameManager.cpp:301
void executeDeferredTasks()
Definition: GameManager.cpp:349
static GameManager * get()
Definition: GameManager.cpp:299
void onMouseInput(MouseButton button, KeyboardModifiers modifiers, bool bIsPressedDown)
Definition: GameManager.cpp:509
void onMouseScrollMove(int iOffset)
Definition: GameManager.cpp:538
std::chrono::steady_clock::time_point lastGcRunTime
Definition: GameManager.h:494
Window * pWindow
Definition: GameManager.h:467
std::pair< std::recursive_mutex, std::queue< std::function< void()> > > mtxDeferredTasks
Definition: GameManager.h:488
void createWorld(const std::function< void(const std::optional< Error > &)> &onCreated, size_t iWorldSize=Globals::getDefaultWorldSize())
Definition: GameManager.cpp:396
CameraManager * getCameraManager() const
Definition: GameManager.cpp:592
bool bShouldAcceptNewDeferredTasks
Definition: GameManager.h:506
void onMouseMove(double xOffset, double yOffset)
Definition: GameManager.cpp:519
std::unique_ptr< Renderer > pRenderer
Definition: GameManager.h:476
void onGameStarted()
Definition: GameManager.cpp:216
void destroyAndCleanExistingWorld()
Definition: GameManager.cpp:813
size_t getTotalSpawnedNodeCount()
Definition: GameManager.cpp:478
void triggerAxisEvents(KeyboardKey key, KeyboardModifiers modifiers, bool bIsPressedDown)
Definition: GameManager.cpp:707
void queueGarbageCollection(bool bForce, const std::optional< std::function< void()> > &onFinished={})
Definition: GameManager.cpp:306
void onWindowFocusChanged(bool bIsFocused) const
Definition: GameManager.cpp:557
size_t getWorldSize()
Definition: GameManager.cpp:468
float timeSincePrevFrameInSec
Definition: GameManager.h:497
void onWindowClose() const
Definition: GameManager.cpp:565
std::thread::id mainThreadId
Definition: GameManager.h:503
long long getGarbageCollectorRunIntervalInSec() const
Definition: GameManager.cpp:596
GameInstance * getGameInstance() const
Definition: GameManager.cpp:590
void destroy()
Definition: GameManager.cpp:103
sgc::GcPtr< Node > getWorldRootNode()
Definition: GameManager.cpp:448
long long iGcRunIntervalInSec
Definition: GameManager.h:500
bool bIsInitialized
Definition: GameManager.h:509
void onBeforeNewFrame(float timeSincePrevCallInSec)
Definition: GameManager.cpp:315
void addDeferredTask(const std::function< void()> &task)
Definition: GameManager.cpp:570
float getTimeSincePrevFrameInSec() const
Definition: GameManager.cpp:594
void onTickFinished()
Definition: GameManager.cpp:232
void setGameInstance()
Definition: GameManager.h:340
void onKeyboardInput(KeyboardKey key, KeyboardModifiers modifiers, bool bIsPressedDown)
Definition: GameManager.cpp:498
bool isNodeSpawned(size_t iNodeId)
Definition: GameManager.cpp:598
void onFramebufferSizeChanged(int iWidth, int iHeight) const
Definition: GameManager.cpp:561
void loadNodeTreeAsWorld(const std::function< void(const std::optional< Error > &)> &onLoaded, const std::filesystem::path &pathToNodeTree, size_t iWorldSize=Globals::getDefaultWorldSize())
Definition: GameManager.cpp:414
bool isBeingDestroyed() const
Definition: GameManager.cpp:607
static constexpr size_t getDefaultWorldSize()
Definition: Globals.h:33
Definition: KeyboardKey.hpp:10
Definition: ThreadPool.h:14