Skip to content

Commit 3d0eea3

Browse files
Kelwanzaucy
authored andcommitted
feat: API for streaming components
1 parent e811be1 commit 3d0eea3

File tree

5 files changed

+86
-3
lines changed

5 files changed

+86
-3
lines changed

ecsact/runtime/async.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,25 @@ ECSACT_ASYNC_API_FN(void, ecsact_async_disconnect)(void);
205205
*/
206206
ECSACT_ASYNC_API_FN(int32_t, ecsact_async_get_current_tick)(void);
207207

208+
/**
209+
* Sends Ecsact stream data to the specified registry. Stream data will be
210+
* applied on the next ecsact_execute_systems call.
211+
*/
212+
ECSACT_CORE_API_FN(ecsact_async_request_id, ecsact_async_stream)
213+
( //
214+
int32_t count,
215+
const ecsact_entity_id* entities,
216+
const ecsact_component_id* component_ids,
217+
const void* components_data
218+
);
219+
208220
#define FOR_EACH_ECSACT_ASYNC_API_FN(fn, ...) \
209221
fn(ecsact_async_enqueue_execution_options, __VA_ARGS__); \
210222
fn(ecsact_async_flush_events, __VA_ARGS__); \
211223
fn(ecsact_async_connect, __VA_ARGS__); \
212224
fn(ecsact_async_disconnect, __VA_ARGS__); \
213-
fn(ecsact_async_get_current_tick, __VA_ARGS__);
225+
fn(ecsact_async_get_current_tick, __VA_ARGS__); \
226+
fn(ecsact_async_stream, __VA_ARGS__)
214227

215228
#undef ECSACT_ASYNC_API
216229
#undef ECSACT_ASYNC_API_FN

ecsact/runtime/common.h

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@ typedef enum {
274274
ECSACT_EXEC_SYS_ERR_ACTION_ENTITY_CONSTRAINT_BROKEN = 2,
275275
} ecsact_execute_systems_error;
276276

277+
typedef enum {
278+
ECSACT_STREAM_OK = 0,
279+
280+
/**
281+
* An invalid or non-stream component ID was passed into the stream.
282+
*/
283+
ECSACT_STREAM_INVALID_COMPONENT_ID = 1,
284+
} ecsact_stream_error;
285+
277286
typedef enum {
278287
/**
279288
* System has no capabilities for this component.
@@ -287,7 +296,8 @@ typedef enum {
287296

288297
/**
289298
* System may only write to component.
290-
* NOTE: This flag is only valid if accompanied by `ECSACT_SYS_CAP_READONLY`.
299+
* NOTE: This flag is only valid if accompanied by
300+
* `ECSACT_SYS_CAP_READONLY`.
291301
*/
292302
ECSACT_SYS_CAP_WRITEONLY = 2,
293303

@@ -342,6 +352,11 @@ typedef enum {
342352
* `ECSACT_SYS_CAP_INCLUDE`
343353
*/
344354
ECSACT_SYS_CAP_REMOVES = 64 | ECSACT_SYS_CAP_INCLUDE,
355+
356+
/**
357+
* System may enable or disable streaming data for this component.
358+
*/
359+
ECSACT_SYS_CAP_STREAM_TOGGLE = 128,
345360
} ecsact_system_capability;
346361

347362
/**
@@ -661,6 +676,32 @@ typedef enum {
661676
ECSACT_EVENT_DESTROY_ENTITY = 4,
662677
} ecsact_event;
663678

679+
typedef enum ecsact_component_type {
680+
/**
681+
* The component has no unique type
682+
*/
683+
ECSACT_COMPONENT_TYPE_NONE = 0,
684+
685+
/*
686+
* The component takes in a continuous feed of data. Look at stream toggle to
687+
* see how you can set the component to receive updates from either
688+
* ecsact_stream or systems.
689+
*/
690+
ECSACT_COMPONENT_TYPE_STREAM = 1,
691+
692+
/*
693+
* The component is a stream component (@see ECSACT_COMPONENT_TYPE_STREAM) but
694+
* may be updated overtime instead of all at once.
695+
*/
696+
ECSACT_COMPONENT_TYPE_LAZY_STREAM = 2,
697+
698+
/**
699+
* The component only lives during system execution and is automatically
700+
* removed.
701+
*/
702+
ECSACT_COMPONENT_TYPE_TRANSIENT = 3
703+
} ecsact_component_stream;
704+
664705
/**
665706
* Component event callback
666707
*/

ecsact/runtime/core.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,19 @@ ECSACT_CORE_API_FN(ecsact_ees, ecsact_get_entity_execution_status)
264264
ecsact_system_like_id system_like_id
265265
);
266266

267+
/**
268+
* Sends Ecsact stream data to the specified registry. Stream data will be
269+
* applied on the next ecsact_execute_systems call.
270+
*/
271+
ECSACT_CORE_API_FN(ecsact_stream_error, ecsact_stream)
272+
( //
273+
ecsact_registry_id registry_id,
274+
int32_t count,
275+
const ecsact_entity_id* entities,
276+
const ecsact_component_id* component_ids,
277+
const void* components_data
278+
);
279+
267280
// # BEGIN FOR_EACH_ECSACT_CORE_API_FN
268281
#ifdef ECSACT_MSVC_TRADITIONAL
269282
# define FOR_EACH_ECSACT_CORE_API_FN(fn, ...) ECSACT_MSVC_TRADITIONAL_ERROR()
@@ -287,6 +300,7 @@ ECSACT_CORE_API_FN(ecsact_ees, ecsact_get_entity_execution_status)
287300
fn(ecsact_update_component, __VA_ARGS__); \
288301
fn(ecsact_remove_component, __VA_ARGS__); \
289302
fn(ecsact_execute_systems, __VA_ARGS__); \
303+
fn(ecsact_stream, __VA_ARGS__); \
290304
fn(ecsact_get_entity_execution_status, __VA_ARGS__)
291305
#endif
292306

ecsact/runtime/dynamic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,12 @@ ECSACT_DYNAMIC_API_FN(void, ecsact_set_system_notify_component_setting)
515515
ecsact_system_notify_setting setting
516516
);
517517

518+
ECSACT_DYNAMIC_API_FN(void, ecsact_set_component_type)
519+
( //
520+
ecsact_component_id comopnent_id,
521+
ecsact_component_type component_type
522+
);
523+
518524
// # BEGIN FOR_EACH_ECSACT_DYNAMIC_API_FN
519525
#ifdef ECSACT_MSVC_TRADITIONAL
520526
# define FOR_EACH_ECSACT_DYNAMIC_API_FN(fn, ...) \

ecsact/runtime/meta.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,14 @@ ECSACT_META_API_FN(void, ecsact_meta_system_notify_settings)
511511
int32_t* out_notifies_count
512512
);
513513

514+
/**
515+
* Check the type of a component.
516+
*/
517+
ECSACT_META_API_FN(ecsact_component_type, ecsact_meta_component_type)
518+
( //
519+
ecsact_component_id component_id
520+
);
521+
514522
// # BEGIN FOR_EACH_ECSACT_META_API_FN
515523
#ifdef ECSACT_MSVC_TRADITIONAL
516524
# define FOR_EACH_ECSACT_META_API_FN(fn, ...) ECSACT_MSVC_TRADITIONAL_ERROR()
@@ -575,7 +583,8 @@ ECSACT_META_API_FN(void, ecsact_meta_system_notify_settings)
575583
fn(ecsact_meta_get_lazy_iteration_rate, __VA_ARGS__); \
576584
fn(ecsact_meta_get_system_parallel_execution, __VA_ARGS__); \
577585
fn(ecsact_meta_system_notify_settings_count, __VA_ARGS__); \
578-
fn(ecsact_meta_system_notify_settings, __VA_ARGS__)
586+
fn(ecsact_meta_system_notify_settings, __VA_ARGS__); \
587+
fn(ecsact_meta_component_stream, __VA_ARGS__)
579588
#endif
580589

581590
#endif // ECSACT_RUNTIME_META_H

0 commit comments

Comments
 (0)