Brunot
Loading...
Searching...
No Matches
Engine.h
Go to the documentation of this file.
1
11// ____ __ __ __
12// /\__ _\/\ \ /\ \/\ \
13// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
14// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
15// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
16// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
17// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
18
19
20#pragma once
21#include "Framework/Node.h"
22#include "Framework/Root.h"
23
24class Engine
25{
26public:
27 Engine();
28 Engine(Engine& other) = delete;
29 ~Engine();
30
31 auto run() -> int;
32 static auto shutdown(int code) -> void;
33
34
42 template <std::derived_from<System> system>
43 static auto getSystem() -> system*
44 {
45 auto typeId = system::getEnum();
46 auto isSystemType = [typeId](const GameObject& object) -> bool
47 {
48 return object.getKey().getSubtype()
49 == static_cast<unsigned short>(typeId);
50 };
51
52 if (auto singleton = getSingleton())
53 {
54 return static_cast<system*>(singleton->rootNode.findDirect(isSystemType));
55 }
56 return nullptr;
57 }
58
63 static auto getRoot() -> Root*
64 {
65 return getSingleton()->root;
66 }
67
68private:
70 Root* root; // a pointer to the Root object that rootNode holds. see Root.h for purpose.
71 bool shouldShutdown{false}; // true if Engine should shutdown
72 int shutdownCode{0}; // The number to return when shutting down
73 double lastFrameTime{0};
74
75 static auto getSingleton() -> Engine*;
76};
Manages the heirarchical structure between Systems and Entities.
Definition Engine.h:25
Root * root
Definition Engine.h:70
static auto getRoot() -> Root *
Definition Engine.h:63
static auto getSingleton() -> Engine *
Definition Engine.cpp:112
static auto shutdown(int code) -> void
Definition Engine.cpp:105
bool shouldShutdown
Definition Engine.h:71
Engine(Engine &other)=delete
int shutdownCode
Definition Engine.h:72
Engine()
Definition Engine.cpp:29
~Engine()
Definition Engine.cpp:40
double lastFrameTime
Definition Engine.h:73
auto run() -> int
Definition Engine.cpp:45
static auto getSystem() -> system *
A function to get a system.
Definition Engine.h:43
Node rootNode
Definition Engine.h:69
the base class for the engine, most things inherit from this.
Definition GameObject.h:77
Manages the heirarchical structure between Systems and Entities.
Definition Node.h:41
Definition Root.h:22