summaryrefslogtreecommitdiff
path: root/src/ecs.hpp
blob: 60fce3f51aa5743008201d0d8f7e487352af47b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef PKE_ECS_HPP
#define PKE_ECS_HPP

#include "pk.h"
#include "components.hpp"

extern pk_arr_t<Entity_Base *> EntitiesWithExcessInstances;

void ECS_Init();
void ECS_Teardown();
void ECS_Tick_Early(double delta);
void ECS_Tick(double delta);
void ECS_Tick_Late(double delta);

bool ecs_pk_arr_find_first_matching_pointer(void *search_ptr, void *list_ptr);

Entity_Base *ECS_CreateGenericEntity();
EntityHandle ECS_CreateEntity(Entity_Base *entity, Entity_Base *parentEnt = nullptr);
Entity_Base *ECS_GetEntity(EntityHandle handle);
Entity_Base *ECS_GetEntityByUUID(pk_uuid uuid);
void ECS_MarkForRemoval(Entity_Base *entity);
pk_bkt_arr *ECS_GetEntities();

void ECS_HandleCollision(CompInstance *lhs, CompInstance *rhs);

CompGrBinds *ECS_CreateGrBinds(Entity_Base *);
CompGrBinds *ECS_GetGrBinds(GrBindsHandle grBindsHandle);
void ECS_GetGrBinds(Entity_Base *entity, pk_arr_t<CompGrBinds *> &arr);
pk_bkt_arr *ECS_GetGrBinds();

CompInstance *ECS_CreateInstance(Entity_Base *entity, pk_uuid uuid, CompGrBinds *entityTypeGrBinds, InstPos *instance_pos);
CompInstance *ECS_GetInstance(InstanceHandle instanceHandle);
void ECS_GetInstances(Entity_Base *entity, pk_arr_t<CompInstance *> &arr);
void ECS_UpdateInstance(CompInstance *instance, const InstPos &instPos, bool overridePhysics = false);
pk_bkt_arr *ECS_GetInstances();

/* Callbacks
 * user_event_data: entity
 * user_cb_data: user-defined when cb is registered
 * user_ev_data: user-defined when ev is emitted
 *
 * note: user_ev_data is null for static_ui buttons.
 */
pke_component_event *ECS_CreateEv(Entity_Base *entity, pk_uuid uuid);
pke_component_event *ECS_GetEv(PkeEventHandle handle);
void ECS_GetEvs(Entity_Base *entity, pk_arr_t<pke_component_event *> &arr);
pk_bkt_arr *ECS_GetEvs();

#endif /* PKE_ECS_HPP */