4#include <entt/entt.hpp>
8#include <unordered_map>
21template <
typename TScheduler>
22concept CScheduler = std::derived_from<TScheduler, Scheduler::AScheduler>;
24template <
typename TPlugin>
25concept CPlugin = std::derived_from<TPlugin, IPlugin>;
70 template <
typename TResource> TResource &
RegisterResource(TResource &&resource);
75 template <
typename TResource> TResource &
GetResource();
80 template <
typename TResource>
const TResource &
GetResource()
const;
85 template <
typename TResource>
bool HasResource()
const;
99 template <CScheduler TScheduler> TScheduler &
GetScheduler();
112 this->
_schedulers.Before<TSchedulerA, TSchedulerB>();
121 this->
_schedulers.After<TSchedulerA, TSchedulerB>();
131 this->
_schedulers.RemoveDependencyAfter<TSchedulerA, TSchedulerB>();
141 this->
_schedulers.RemoveDependencyBefore<TSchedulerA, TSchedulerB>();
172 template <
typename... Systems>
decltype(
auto)
RegisterSystem(Systems... systems);
180 template <CScheduler TScheduler,
typename System,
typename ErrorCallback>
190 template <
typename System,
typename ErrorCallback>
215 template <CPlugin TPlugin>
bool HasPlugin()
const;
220 bool HasPlugin(std::type_index type)
const;
245 template <CPlugin TPlugin>
void AddPlugin();
257 std::unordered_map<std::type_index, std::unique_ptr<IPlugin>>
_plugins;
void AddPlugin()
Adds a plugin.
Definition Core.inl:90
bool IsRunning()
Get the running state of the core.
Definition Core.cpp:62
void SetErrorPolicyForAllSchedulers(Scheduler::SchedulerErrorPolicy policy)
Sets the error policy for all schedulers.
Definition Core.cpp:101
std::unique_ptr< Registry > _registry
The registry that contains all components (and by definition, the entities).
Definition Core.hpp:249
void Stop()
Stop the core execution. It will finish the current loop, call shutdown systems if any and stop.
Definition Core.cpp:64
const Registry & GetRegistry() const
Get the entt::registry that contains all components. It should be used to update component through sy...
Definition Core.hpp:56
TResource & GetResource()
Get a reference of a resource.
Definition Core.inl:14
~Core()
Destructor of the core. It will clear the registry and the scheduler container.
Definition Core.cpp:42
void RunSystems()
Run all the systems once by calling each scheduler.
Definition Core.cpp:83
TScheduler & RegisterScheduler(Args &&...args)
Add a new scheduler to the registry.
Definition Core.inl:36
void SetSchedulerBefore()
Sets the execution order of two schedulers, ensuring that TSchedulerA is executed before TSchedulerB.
Definition Core.hpp:110
bool HasResource() const
Check if a resource is registered in the core.
Definition Core.inl:24
bool IsEntityValid(Id entity) const
Check if entity is valid in the context of the registry. It check if the id of the entity exist.
Definition Core.cpp:95
TScheduler & GetScheduler()
Get a scheduler from the registry by its type.
Definition Core.inl:47
Engine::SchedulerContainer _schedulers
The container that contains all the schedulers.
Definition Core.hpp:251
void RemoveDependencyAfter()
Removes a dependency between two schedulers, ensuring that TSchedulerB is no longer dependent on TSch...
Definition Core.hpp:129
void ClearEntities()
Clear all entities and components from the registry.
Definition Core.cpp:97
decltype(auto) RegisterSystemWithErrorHandler(System system, ErrorCallback callback)
Add a system to a specific scheduler, associated with a callback that should run if the system fails ...
Definition Core.inl:77
void SetDefaultScheduler()
Sets the default scheduler.
Definition Core.hpp:228
decltype(auto) RegisterSystem(Systems... systems)
Add one or multiple systems associated with a specific scheduler.
Definition Core.inl:61
Core()
Default constructor of the core. It will initialize the registry and the scheduler container....
Definition Core.cpp:11
std::type_index _defaultScheduler
The default scheduler type index. It is used when adding systems without specifying a scheduler.
Definition Core.hpp:253
bool HasPlugin() const
Checks if a plugin is present.
Definition Core.inl:100
void AddPlugins()
Adds multiple plugins that will be call instantly through the Bind method to agregate their systems a...
Definition Core.inl:88
void RemoveDependencyBefore()
Removes a dependency between two schedulers, ensuring that TSchedulerA is no longer dependent on TSch...
Definition Core.hpp:139
void KillEntity(Id entity)
Kill an entity. It will remove all components from the entity.
Definition Core.cpp:51
entt::basic_registry< Id > Registry
The type of the registry used by the core. It is an alias for entt::basic_registry with Id as entity ...
Definition Core.hpp:37
bool _running
The running state of the core. It is true if the core is running, false otherwise....
Definition Core.hpp:260
std::vector< std::type_index > _schedulersToDelete
The list of schedulers to delete at the end of the current loop.
Definition Core.hpp:255
void SetSchedulerAfter()
Sets the execution order of two schedulers by specifying that one scheduler should execute after anot...
Definition Core.hpp:119
std::unordered_map< std::type_index, std::unique_ptr< IPlugin > > _plugins
The plugins added to the core.
Definition Core.hpp:257
void DeleteScheduler()
Deletes a scheduler.
Definition Core.inl:42
void DeleteResource()
Delete a resource from the core.
Definition Core.inl:29
Entity CreateEntity()
Create an entity in the context of the registry.
Definition Core.cpp:44
TResource & RegisterResource(TResource &&resource)
Store a resource instance.
Definition Core.inl:9
Registry & GetRegistry()
Get the entt::registry that contains all components. It should be used to update component through sy...
Definition Core.hpp:50
void RunCore()
Execute the core loop, which will run all the schedulers.
Definition Core.cpp:74
Wrapper class providing a convenient interface for entity manipulation with the Core....
Definition Entity.hpp:20
Manages a collection of schedulers, allowing addition, retrieval, and deletion of schedulers.
Definition SchedulerContainer.hpp:39
AScheduler is an abstract class that implements the IScheduler interface. It provides common function...
Definition AScheduler.hpp:15
Update scheduler that runs systems every time it is called.
Definition Update.hpp:8
SchedulerErrorPolicy
Enum that defines how the scheduler will handle errors.
Definition IScheduler.hpp:11
FunctionUtils::CallableFunction< TCallable, void, Core & > System
Definition System.hpp:19
A strongly-typed identifier wrapper based on entt::id_type. This structure provides a type-safe wrapp...
Definition Id.hpp:49