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 * 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-29 18:48:56 +00:00
|
|
|
typedef void (*MtEffectorFn) (MtEntity entity, void *userdata, usz_t invocation_id);
|
|
|
|
typedef void (*MtTaskMainFn) (MtTask task, void *userdata);
|
2024-01-26 19:30:06 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *task_name;
|
|
|
|
usz_t min_num_threads;
|
|
|
|
usz_t max_num_threads;
|
2024-01-29 18:48:56 +00:00
|
|
|
MtTaskMainFn continuous_threads[4];
|
2024-01-26 19:30:06 +00:00
|
|
|
void *userdata;
|
|
|
|
|
|
|
|
} MtTaskCreationInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-29 18:48:56 +00:00
|
|
|
MtState mt_initialize(char *app_name);
|
2024-01-26 19:30:06 +00:00
|
|
|
void mt_cleanup(MtState state);
|
|
|
|
void mt_start(MtState state);
|
|
|
|
|
2024-01-29 18:48:56 +00:00
|
|
|
MtEntity mt_summon(MtState state);
|
2024-01-30 21:31:31 +00:00
|
|
|
void mt_drop(MtEntity entity);
|
2024-01-26 19:30:06 +00:00
|
|
|
|
2024-01-29 18:48:56 +00:00
|
|
|
void mt_add_create_effector(MtState state, char *effector_name, MtEffectorFn function, void *userdata);
|
|
|
|
void mt_add_delete_effector(MtState state, char *effector_name, MtEffectorFn function, void *userdata);
|
|
|
|
void mt_add_entity_effector(MtState state, char *effector_name, usz_t ticks_delta, MtEffectorFn function, void *userdata);
|
|
|
|
void mt_add_tick_effector(MtState state, char *effector_name, usz_t ticks_delta, MtEffectorFn 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.
|
2024-01-29 18:48:56 +00:00
|
|
|
/// @param state The state in which the tick effector should reside.
|
2024-01-26 19:30:06 +00:00
|
|
|
/// @param effector_name The name of the effector. This will be copied into the effector's structure.
|
2024-01-29 18:48:56 +00:00
|
|
|
/// @param ticks_delta The wanted number of ticks between two invocations of the effector.
|
2024-01-26 19:30:06 +00:00
|
|
|
/// @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.
|
2024-01-29 18:48:56 +00:00
|
|
|
void mt_add_tagged_tick_effector(MtState state, char *effector_name, usz_t ticks_delta, MtEffectorFn function, char **tag_names);
|
2024-01-26 19:30:06 +00:00
|
|
|
|
|
|
|
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);
|
2024-01-29 18:48:56 +00:00
|
|
|
void mt_tag_vec3(MtEntity entity, char *name, rr_vec3f_s vector);
|
2024-01-26 19:30:06 +00:00
|
|
|
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
|