Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
APlugin.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "core/Core.hpp"
4#include "plugin/IPlugin.hpp"
5
6namespace Engine {
9class APlugin : public IPlugin {
10 public:
15 explicit APlugin(Core &core) : _core(core) {};
16
18 virtual void Bind(void) = 0;
19
30 template <CScheduler TScheduler, typename... Systems> inline decltype(auto) RegisterSystems(Systems... systems)
31 {
32 return _core.RegisterSystem<TScheduler>(systems...);
33 }
34
41 template <typename TResource> TResource &RegisterResource(TResource &&resource)
42 {
43 return _core.RegisterResource(std::forward<TResource>(resource));
44 }
45
50 template <CPlugin... TPlugins> void RequirePlugins() { (RequirePlugin<TPlugins>(), ...); }
51
60 template <CScheduler TScheduler, typename... Args> inline TScheduler &RegisterScheduler(Args &&...args)
61 {
62 return _core.RegisterScheduler<TScheduler>(std::forward<Args>(args)...);
63 }
64
69 Core &GetCore() { return _core; }
70
71 private:
78 template <CPlugin TPlugin> void RequirePlugin()
79 {
80 if (!_core.HasPlugin<TPlugin>())
81 {
82 _core.AddPlugins<TPlugin>();
83 }
84 }
85
88};
89} // namespace Engine
Core & GetCore()
Get a reference to the core. This can be used to register systems and resources in the Bind method.
Definition APlugin.hpp:69
decltype(auto) RegisterSystems(Systems... systems)
Register systems to a scheduler.
Definition APlugin.hpp:30
APlugin(Core &core)
Constructor for APlugin. It takes a reference to the Core, which is used to register systems and reso...
Definition APlugin.hpp:15
void RequirePlugin()
Add a plugin to the core if it is not already added.
Definition APlugin.hpp:78
TScheduler & RegisterScheduler(Args &&...args)
Register a scheduler in the core.
Definition APlugin.hpp:60
Core & _core
Reference to the core, which is used to register systems and resources in the Bind method.
Definition APlugin.hpp:87
void RequirePlugins()
Add a plugin to the core.
Definition APlugin.hpp:50
virtual void Bind(void)=0
Pure virtual method that must be implemented by derived plugin classes. This method is called when th...
TResource & RegisterResource(TResource &&resource)
Register a resource in the core.
Definition APlugin.hpp:41
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
Interface for plugins that can be added to the engine.
Definition IPlugin.hpp:6
Definition Core.hpp:25
Definition Core.hpp:22
Definition Core.hpp:17