Skip to content

Commit 94b3c74

Browse files
Kelwanzaucy
andauthored
Change core API for design refactor (#130)
Co-authored-by: Ezekiel Warren <[email protected]>
1 parent 3d3171d commit 94b3c74

File tree

1 file changed

+81
-4
lines changed

1 file changed

+81
-4
lines changed

ecsact/runtime/core.h

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,37 @@ typedef struct ecsact_execution_options {
333333
* Sequential list of actions to be executed.
334334
*/
335335
ecsact_action* actions;
336+
337+
/**
338+
* Length of entities to be created.
339+
*/
340+
int create_entities_length;
341+
342+
/**
343+
* Sequential list of component lengths for each entity in
344+
* `create_entities_components`.
345+
*/
346+
int* create_entities_components_length;
347+
348+
/**
349+
* A sequential 2D list that represents a set of entities with a list of
350+
* components. Entity length is determined by `create_entities_length`. The
351+
* length of components for each entity is determined by
352+
* `create_entities_components_length`.
353+
*/
354+
ecsact_component** create_entities_components;
355+
356+
/**
357+
* Length of `destroy_entities` sequential list.
358+
*/
359+
int destroy_entities_length;
360+
361+
/**
362+
* A sequentual list of entity IDs that will be destroyed along with its
363+
* components. Length is determined by `destroy_entities_length`.
364+
*/
365+
ecsact_entity_id* destroy_entities;
366+
336367
} ecsact_execution_options;
337368

338369
typedef enum {
@@ -363,6 +394,24 @@ typedef enum {
363394
* when at the end of the execution call the component is removed.
364395
*/
365396
ECSACT_EVENT_REMOVE_COMPONENT = 2,
397+
398+
/**
399+
* Create entity - Entity has been created during execution.
400+
*
401+
* Happens on entity creation and before any `INIT_COMPONENT`
402+
* events. It will also be triggered by any generated entities. Returns the
403+
* entity ID associated with the created entity
404+
*/
405+
ECSACT_EVENT_CREATE_ENTITY = 3,
406+
407+
/**
408+
* Destroy entity - Entity has been destroyed during execution.
409+
*
410+
* Invoked when an entity is destroyed. Any components associated with the
411+
* entity will also be destroyed. Returns the entity ID associated with the
412+
* destroyed entity
413+
*/
414+
ECSACT_EVENT_DESTROY_ENTITY = 4,
366415
} ecsact_event;
367416

368417
/**
@@ -376,12 +425,15 @@ typedef void (*ecsact_component_event_callback)( //
376425
void* callback_user_data
377426
);
378427

428+
typedef void (*ecsact_entity_event_callback
429+
)(ecsact_event event, ecsact_entity_id entity_id, void* callback_user_data);
430+
379431
/**
380432
* Holds event handler callbacks and their user data
381433
*/
382434
typedef struct ecsact_execution_events_collector {
383435
/**
384-
* invoked after system executions are finished for every component that is
436+
* Invoked after system executions are finished for every component that is
385437
* new. The component_data is the last value given for the component, not the
386438
* first. Invocation happens in the calling thread. `event` will always be
387439
* `ECSACT_EVENT_INIT_COMPONENT`
@@ -394,7 +446,7 @@ typedef struct ecsact_execution_events_collector {
394446
void* init_callback_user_data;
395447

396448
/**
397-
* invoked after system executions are finished for every changed component.
449+
* Invoked after system executions are finished for every changed component.
398450
* Invocation happens in the calling thread. `event` will always be
399451
* `ECSACT_EVENT_UPDATE_COMPONENT`
400452
*/
@@ -406,8 +458,8 @@ typedef struct ecsact_execution_events_collector {
406458
void* update_callback_user_data;
407459

408460
/**
409-
* invoked after system executions are finished for every removed component.
410-
* Invocation happens in the calling thread. `event` will will always be
461+
* Invoked after system executions are finished for every removed component.
462+
* Invocation happens in the calling thread. `event` will always be
411463
* `ECSACT_EVENT_REMOVE_COMPONENT`.
412464
*/
413465
ecsact_component_event_callback remove_callback;
@@ -416,6 +468,31 @@ typedef struct ecsact_execution_events_collector {
416468
* `callback_user_data` passed to `remove_callback`
417469
*/
418470
void* remove_callback_user_data;
471+
472+
/**
473+
* Invoked after system executions are finished for every created entity.
474+
* Invocation happens in the calling thread. `event` will will always be
475+
* `ECSACT_EVENT_CREATE_ENTITY`.
476+
*/
477+
ecsact_entity_event_callback entity_created_callback;
478+
479+
/**
480+
* `callback_user_data` passed to `entity_created_callback`
481+
*/
482+
void* entity_created_callback_user_data;
483+
484+
/**
485+
* Invoked after system executions are finished for every removed component.
486+
* Invocation happens in the calling thread. `event` will will always be
487+
* `ECSACT_EVENT_DESTROY_COMPONENT`.
488+
*/
489+
ecsact_entity_event_callback entity_destroyed_callback;
490+
491+
/**
492+
* `callback_user_data` passed to `entity_destroyed_callback`
493+
*/
494+
void* entity_destroyed_callback_user_data;
495+
419496
} ecsact_execution_events_collector;
420497

421498
/**

0 commit comments

Comments
 (0)