This is an attempt to make writing simulators and games as simple as possible using the Entity-Component-System architecture.
The main focuses of this project are as follows:
- Performance
- API simplicity
- Development simplicity
TODO: Write details here
TODO: Write details here
This function adds a system to the engine to be managed.
Allows components to be added to systems before the engine is started
Starts the engine running. Calls the callback after tick_duration milliseconds.
Creates a new unique entity that can be used in the engine.
Returns the passed in entity if it doesn't exist in the engine yet. If it already exists it returns a new entity.
Removes an entity from the engine, marking the associated components as deleteable
Creating a new system is rather easy as ese generates the necessary functions for the system (add, delete, etc.) so you don't have to write them yourself. However, hooks are provided to allow the programmer to add additional functionality into those generated functions as needed. How to use the hooks can be seen in the example at the bottom.
Hooks into the system's add function. Gets passed the entity id and the pointer to the component being added prior to addition. Returns void.
Hooks into the system's delete function. Gets passed the entity id and the pointer to the component being removed prior to removal. Returns void.
Hooks into the system's resolution function. No arguments. Called before the adding and removal of components. Returns void.
The function that is called during the tick phase of the engine. Gets passed the entity id and a pointer to the associated component. Returns void.
#include "system.h"
#define ESE_SYSTEM_TYPE example
typedef struct
{
int value;
} example;
#define ESE_ADD_HOOK add_hook // Doesn't need to be defined unless you want to hook into the add functionality
void add_hook(entity e, example * component)
{
// Do stuff here
}
#define ESE_DELETE_HOOK delete_hook // Doesn't need to be defined unless you want to hook into the delete functionality
void delete_hook(entity e, example * component)
{
// Do stuff here
}
#define ESE_RESOLVE_HOOK resolve_hook
void resolve_hook()
{
// Do stuff here
}
#define ESE_TICK_HOOK example_tick // Doesn't need to be defined unless you want to do something to the component each tick
void example_tick(uint64_t tick, entity e, example * component)
{
// Do stuff here
}
#include "system_generator.h"