This repository has been archived on 2024-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
MainTree/core/exports/maintree/maintree.h

75 lines
3.1 KiB
C
Raw Normal View History

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;
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;
MtTaskMainFn continuous_threads[4];
2024-01-26 19:30:06 +00:00
void *userdata;
} MtTaskCreationInfo;
MtState mt_initialize(char *app_name);
2024-01-26 19:30:06 +00:00
void mt_cleanup(MtState state);
void mt_start(MtState state);
MtEntity mt_summon(MtState state);
void mt_drop(MtEntity entity);
2024-01-26 19:30:06 +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);
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 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.
/// @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.
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);
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);
void mt_untag(MtEntity entity, char *name);
2024-01-26 19:30:06 +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