2024-01-26 19:30:06 +00:00
|
|
|
// Exported functions of MainTree
|
|
|
|
|
|
|
|
#ifndef MAINTREE_H
|
|
|
|
#define MAINTREE_H
|
|
|
|
|
|
|
|
#include <librr/types.h>
|
|
|
|
#include <librr/linear_algebra.h>
|
|
|
|
|
|
|
|
typedef void * MtType;
|
|
|
|
typedef void * MtEntity;
|
|
|
|
|
|
|
|
/// @brief: An MtTask is a piece of functionality with an own state/context which will be executed on the same thread or set of threads.
|
|
|
|
typedef void * MtTask;
|
|
|
|
typedef void * MtState;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-27 22:21:19 +00:00
|
|
|
typedef void (*mt_type_effector_fn) (MtType type, void *userdata, usz_t invocation);
|
|
|
|
typedef void (*mt_entity_effector_fn) (MtEntity entity, void *userdata, usz_t invocation);
|
2024-01-26 19:30:06 +00:00
|
|
|
typedef void (*mt_task_main_fn) (MtTask task, void *userdata);
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *task_name;
|
|
|
|
usz_t min_num_threads;
|
|
|
|
usz_t max_num_threads;
|
|
|
|
void *userdata;
|
|
|
|
|
|
|
|
} MtTaskCreationInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MtState mt_create_state(char *app_name);
|
|
|
|
void mt_cleanup(MtState state);
|
|
|
|
void mt_start(MtState state);
|
|
|
|
|
|
|
|
MtType mt_register_type(char *identifier);
|
|
|
|
void mt_forget_type(MtType type);
|
|
|
|
|
|
|
|
MtEntity mt_make(MtType type);
|
2024-01-27 22:21:19 +00:00
|
|
|
void mt_add_registration_effector(MtState state, char *effector_name, mt_type_effector_fn function, void *userdata);
|
|
|
|
void mt_add_create_effector(MtType type, char *effector_name, mt_entity_effector_fn function, void *userdata);
|
|
|
|
void mt_add_delete_effector(MtType type, char *effector_name, mt_entity_effector_fn function, void *userdata);
|
|
|
|
void mt_add_entity_tick_effector(MtType type, char *effector_name, usz_t ticks_delta, mt_entity_effector_fn function, void *userdata);
|
|
|
|
void mt_add_tick_effector(MtState state, char *effector_name, usz_t ticks_delta, mt_entity_effector_fn function, void *userdata);
|
2024-01-28 00:00:41 +00:00
|
|
|
void mt_remove_effector(MtState state, const char *effector_name);
|
2024-01-26 19:30:06 +00:00
|
|
|
|
|
|
|
/// @brief Adds a tick effector which only acts upon entitys with certain tags.
|
|
|
|
/// @param type The type for which to add the tick effector.
|
|
|
|
/// @param effector_name The name of the effector. This will be copied into the effector's structure.
|
|
|
|
/// @param ticks_delta The wanted number of ticks between two invocations of the effector
|
|
|
|
/// @param function The function to call for an entity if it contains all necessary tags.
|
|
|
|
/// @param tag_names A nullpointer-terminated list of tag-ids that must be present in an entity for that entity to be effected.
|
|
|
|
void mt_add_tagged_tick_effector(MtType type, char *effector_name, usz_t ticks_delta, mt_entity_effector_fn function, char **tag_names);
|
|
|
|
|
|
|
|
void mt_tag_i64(MtEntity entity, char *name, i64_t integer);
|
|
|
|
void mt_tag_f64(MtEntity entity, char *name, f64_t real);
|
|
|
|
void mt_tag_str(MtEntity entity, char *name, char *string);
|
|
|
|
void mt_tag_ptr(MtEntity entity, char *name, void *pointer);
|
|
|
|
void mt_tag_vec2(MtEntity entity, char *name, rr_vec2f_s vector);
|
|
|
|
void mt_tag_vec3(MtEntity entity, char *name, rr_vec2f_s vector);
|
|
|
|
void mt_tag_vec4(MtEntity entity, char *name, rr_vec4f_s vector);
|
|
|
|
|
2024-01-28 00:00:41 +00:00
|
|
|
void mt_untag(MtEntity entity, char *name);
|
2024-01-26 19:30:06 +00:00
|
|
|
|
2024-01-28 00:00:41 +00:00
|
|
|
i64_t mt_get_i64_tag(MtEntity entity, char *name);
|
|
|
|
f64_t mt_get_f64_tag(MtEntity entity, char *name);
|
|
|
|
char * mt_get_str_tag(MtEntity entity, char *name);
|
|
|
|
void * mt_get_ptr_tag(MtEntity entity, char *name);
|
|
|
|
rr_vec2f_s mt_get_vec2_tag(MtEntity entity, char *name);
|
|
|
|
rr_vec3f_s mt_get_vec3_tag(MtEntity entity, char *name);
|
|
|
|
rr_vec4f_s mt_get_vec4_tag(MtEntity entity, char *name);
|
2024-01-26 19:30:06 +00:00
|
|
|
|
|
|
|
MtTask mt_create_task(MtState state, MtTaskCreationInfo creation_info);
|
|
|
|
void mt_delete_task(MtTask task);
|
|
|
|
|
|
|
|
void mt_task_remove_effector(MtTask task, const char *effector_name);
|
|
|
|
|
|
|
|
#endif // MAINTREE_H
|