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>;
68 template <
typename TResource> TResource &
RegisterResource(TResource &&resource);
73 template <
typename TResource> TResource &
GetResource();
78 template <
typename TResource>
const TResource &
GetResource()
const;
83 template <
typename TResource>
bool HasResource()
const;
97 template <CScheduler TScheduler> TScheduler &
GetScheduler();
154 template <
typename... Systems>
decltype(
auto)
RegisterSystem(Systems... systems);
162 template <CScheduler TScheduler,
typename System,
typename ErrorCallback>
172 template <
typename System,
typename ErrorCallback>
197 template <CPlugin TPlugin>
bool HasPlugin()
const;
202 bool HasPlugin(std::type_index type)
const;
223 template <CPlugin TPlugin>
void AddPlugin();
235 std::unordered_map<std::type_index, std::unique_ptr<IPlugin>>
_plugins;
void AddPlugin()
Adds a plugin.
Definition Core.ipp:110
bool IsRunning()
Get the running state of the core.
Definition Core.cpp:66
void SetErrorPolicyForAllSchedulers(Scheduler::SchedulerErrorPolicy policy)
Sets the error policy for all schedulers.
Definition Core.cpp:105
std::unique_ptr< Registry > _registry
The registry that contains all components (and by definition, the entities).
Definition Core.hpp:227
void Stop()
Stop the core execution. It will finish the current loop, call shutdown systems if any and stop.
Definition Core.cpp:68
TResource & GetResource()
Get a reference of a resource.
Definition Core.ipp: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:87
TScheduler & RegisterScheduler(Args &&...args)
Add a new scheduler to the registry.
Definition Core.ipp:36
void SetSchedulerBefore()
Sets the execution order of two schedulers, ensuring that TSchedulerA is executed before TSchedulerB.
Definition Core.ipp:66
bool HasResource() const
Check if a resource is registered in the core.
Definition Core.ipp: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:99
TScheduler & GetScheduler()
Get a scheduler from the registry by its type.
Definition Core.ipp:47
Engine::SchedulerContainer _schedulers
The container that contains all the schedulers.
Definition Core.hpp:229
void RemoveDependencyAfter()
Removes a dependency between two schedulers, ensuring that TSchedulerB is no longer dependent on TSch...
Definition Core.ipp:76
void ClearEntities()
Clear all entities and components from the registry.
Definition Core.cpp:101
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.ipp:97
void SetDefaultScheduler()
Sets the default scheduler.
Definition Core.ipp:125
decltype(auto) RegisterSystem(Systems... systems)
Add one or multiple systems associated with a specific scheduler.
Definition Core.ipp: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:231
Registry & GetRegistry()
Get the entt::registry that contains all components. It should be used to update component through sy...
Definition Core.cpp:44
bool HasPlugin() const
Checks if a plugin is present.
Definition Core.ipp:120
void AddPlugins()
Adds multiple plugins that will be call instantly through the Bind method to agregate their systems a...
Definition Core.ipp:108
void RemoveDependencyBefore()
Removes a dependency between two schedulers, ensuring that TSchedulerA is no longer dependent on TSch...
Definition Core.ipp:81
void KillEntity(Id entity)
Kill an entity. It will remove all components from the entity.
Definition Core.cpp:55
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
void Run(void)
Run a loop of schedulers until _running is false.
Definition Core.cpp:78
bool _running
The running state of the core. It is true if the core is running, false otherwise....
Definition Core.hpp:238
std::vector< std::type_index > _schedulersToDelete
The list of schedulers to delete at the end of the current loop.
Definition Core.hpp:233
void SetSchedulerAfter()
Sets the execution order of two schedulers by specifying that one scheduler should execute after anot...
Definition Core.ipp:71
std::unordered_map< std::type_index, std::unique_ptr< IPlugin > > _plugins
The plugins added to the core.
Definition Core.hpp:235
void DeleteScheduler()
Deletes a scheduler.
Definition Core.ipp:42
void DeleteResource()
Delete a resource from the core.
Definition Core.ipp:29
Entity CreateEntity()
Create an entity in the context of the registry.
Definition Core.cpp:48
TResource & RegisterResource(TResource &&resource)
Store a resource instance.
Definition Core.ipp:9
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:16
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:20
A strongly-typed identifier wrapper based on entt::id_type. This structure provides a type-safe wrapp...
Definition Id.hpp:47