zel_level.h

Typedefs

typedef struct zel_level_t _zel_level_t
typedef void (*zel_system_t)(_zel_level_t *level, float delta_time)

Functions

zel_level_t *zel_level_create(const char *level_name)
void zel_level_destroy(zel_level_t *level)
zel_entity_id zel_level_create_entity(zel_level_t *level)
void zel_level_destroy_entity(zel_level_t *level, zel_entity_id entity)
void zel_level_register_system(zel_level_t *level, zel_system_t system_update, const char *system_name)
void zel_level_unregister_system(zel_level_t *level, const char *system_name)
template<typename T>
void zel_level_register_component(zel_level_t *level)

Call this function before using a component type in your program to register it. Only call this function once for every level.

template<typename T>
void zel_level_register_component_with_destroy(zel_level_t *level, void (*destroy_function)(T*))

Call this function before using a component type in your program to register it. Only call this function once for every level. (Same as zel_level_register_component, but with the option to supply a destroy function)

template<typename T>
void zel_level_add_component(zel_level_t *level, zel_entity_id entity, T component)

Copies and adds a component to the specified entity in the specified level

template<typename T>
T *zel_level_get_component(zel_level_t *level, zel_entity_id entity)

Returns a pointer to the requested component for the specified entity in the specified level. If the component does not exist, it returns a null pointer. The pointer must not be freed, that’s done when the component is destroyed.

template<typename A, typename ...T>
bool zel_level_has_components(zel_level_t *level, zel_entity_id entity)
template<class _Container>
class QueueContainerWrapper : public _Container
#include <zel_level.h>

Public Types

typedef _Container::container_type container_type

Public Functions

inline container_type &get_container()
struct zel_level_t
#include <zel_level.h>

The struct which holds all the entities, components and systems data.

Public Members

const char *level_name
std::unordered_map<std::type_index, ZelComponentBase*> components
std::unordered_map<std::string, zel_system_t> systems
std::vector<uint8_t> entities = {0}
QueueContainerWrapper<std::queue<uint32_t>> empty_entities_spots