#ifndef _ALIAS_ECS_H_
#define _ALIAS_ECS_H_
#include <alias/memory.h>
typedef enum alias_ecs_Result {
ALIAS_ECS_SUCCESS = 0, ALIAS_ECS_ERROR_INVALID_ARGUMENT = -1, ALIAS_ECS_ERROR_OUT_OF_MEMORY = -2, ALIAS_ECS_ERROR_DOES_NOT_EXIST = -3, ALIAS_ECS_ERROR_INVALID_ENTITY = -4, ALIAS_ECS_ERROR_INVALID_LAYER = -5, ALIAS_ECS_ERROR_COMPONENT_EXISTS = -6,
ALIAS_ECS_ERROR_COMPONENT_DOES_NOT_EXIST = -7,
} alias_ecs_Result;
typedef struct alias_ecs_Instance alias_ecs_Instance;
alias_ecs_Result alias_ecs_create_instance(
const alias_MemoryCB * memory_callback
, alias_ecs_Instance * * instance_ptr
);
void alias_ecs_destroy_instance(alias_ecs_Instance * instance);
typedef uint64_t alias_ecs_LayerHandle;
#define ALIAS_ECS_INVALID_LAYER 0xFFFFFFFF
typedef struct alias_ecs_LayerCreateInfo {
uint32_t max_entities;
} alias_ecs_LayerCreateInfo;
alias_ecs_Result alias_ecs_create_layer(
alias_ecs_Instance * instance
, const alias_ecs_LayerCreateInfo * create_info
, alias_ecs_LayerHandle * layer_handle_ptr
);
typedef enum alias_ecs_LayerDestroyFlags {
ALIAS_ECS_LAYER_DESTROY_REMOVE_ENTITIES = 0x1,
} alias_ecs_LayerDestroyFlags;
alias_ecs_Result alias_ecs_destroy_layer(
alias_ecs_Instance * instance
, const alias_ecs_LayerHandle layer_handle
, alias_ecs_LayerDestroyFlags flags
);
typedef uint32_t alias_ecs_ComponentHandle;
typedef uint64_t alias_ecs_EntityHandle;
typedef void (* alias_ecs_ComponentInitFN)(void * ud, alias_ecs_Instance * instance, alias_ecs_EntityHandle entity, void ** data);
typedef alias_Closure(alias_ecs_ComponentInitFN) alias_ecs_ComponentInitCB;
typedef void (* alias_ecs_ComponentCleanupFN)(void * ud, alias_ecs_Instance * instance, alias_ecs_EntityHandle entity, void ** data);
typedef alias_Closure(alias_ecs_ComponentCleanupFN) alias_ecs_ComponentCleanupCB;
typedef enum alias_ecs_ComponentCreateFlags {
ALIAS_ECS_COMPONENT_CREATE_NOT_NULL = 0x1,
} alias_ecs_ComponentCreateFlags;
typedef struct alias_ecs_ComponentCreateInfo {
alias_ecs_ComponentCreateFlags flags;
size_t size;
uint32_t num_required_components;
const alias_ecs_ComponentHandle * required_components;
alias_ecs_ComponentInitCB init;
alias_ecs_ComponentCleanupCB cleanup;
} alias_ecs_ComponentCreateInfo;
alias_ecs_Result alias_ecs_register_component(
alias_ecs_Instance * instance
, const alias_ecs_ComponentCreateInfo * create_info
, alias_ecs_ComponentHandle * component_ptr
);
typedef struct alias_ecs_EntitySpawnComponent {
alias_ecs_ComponentHandle component;
uint32_t stride;
const void * data;
} alias_ecs_EntitySpawnComponent;
typedef struct alias_ecs_EntitySpawnInfo {
alias_ecs_LayerHandle layer;
uint32_t count;
uint32_t num_components;
const alias_ecs_EntitySpawnComponent * components;
} alias_ecs_EntitySpawnInfo;
alias_ecs_Result alias_ecs_spawn(
alias_ecs_Instance * instance
, const alias_ecs_EntitySpawnInfo * spawn_info
, alias_ecs_EntityHandle * entities_ptr
);
alias_ecs_Result alias_ecs_add_component_to_entity(
alias_ecs_Instance * instance
, alias_ecs_EntityHandle entity
, alias_ecs_ComponentHandle component
, const void * data
);
alias_ecs_Result alias_ecs_remove_component_from_entity(
alias_ecs_Instance * instance
, alias_ecs_EntityHandle entity
, alias_ecs_ComponentHandle component
);
alias_ecs_Result alias_ecs_write_entity_component(
alias_ecs_Instance * instance
, alias_ecs_EntityHandle entity
, alias_ecs_ComponentHandle component
, void * * out_ptr
);
alias_ecs_Result alias_ecs_read_entity_component(
alias_ecs_Instance * instance
, alias_ecs_EntityHandle entity
, alias_ecs_ComponentHandle component
, const void * * out_ptr
);
alias_ecs_Result alias_ecs_despawn(
alias_ecs_Instance * instance
, uint32_t num_entities
, const alias_ecs_EntityHandle * entities
);
typedef struct alias_ecs_Query alias_ecs_Query;
typedef void (* alias_ecs_QueryFN)(void * ud, alias_ecs_Instance * instance, alias_ecs_EntityHandle entity, void ** data);
typedef alias_Closure(alias_ecs_QueryFN) alias_ecs_QueryCB;
typedef enum alias_ecs_Filter {
ALIAS_ECS_FILTER_EXCLUDE,
ALIAS_ECS_FILTER_OPTIONAL,
ALIAS_ECS_FILTER_MODIFIED
} alias_ecs_Filter;
typedef struct alias_ecs_QueryFilterCreateInfo {
alias_ecs_Filter filter;
alias_ecs_ComponentHandle component;
} alias_ecs_QueryFilterCreateInfo;
typedef struct alias_ecs_QueryCreateInfo {
uint32_t num_write_components;
const alias_ecs_ComponentHandle * write_components;
uint32_t num_read_components;
const alias_ecs_ComponentHandle * read_components;
uint32_t num_filters;
alias_ecs_QueryFilterCreateInfo * filters;
} alias_ecs_QueryCreateInfo;
alias_ecs_Result alias_ecs_create_query(
alias_ecs_Instance * instance
, const alias_ecs_QueryCreateInfo * create_info
, alias_ecs_Query * * query_ptr
);
alias_ecs_Result alias_ecs_execute_query(
alias_ecs_Instance * instance
, alias_ecs_Query * query
, alias_ecs_QueryCB cb
);
void alias_ecs_destroy_query(
alias_ecs_Instance * instance
, alias_ecs_Query * query
);
#endif