2021-11-30 21:29:18 -06:00
|
|
|
#ifndef REGISTRY_H
|
|
|
|
#define REGISTRY_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2022-08-28 22:34:33 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
struct mGameObject;
|
|
|
|
|
|
|
|
struct component {
|
|
|
|
const char *name;
|
|
|
|
void *(*make)(struct mGameObject * go);
|
2022-08-28 22:34:33 -05:00
|
|
|
void (*io)(void *data, FILE *f, int read);
|
2021-11-30 21:29:18 -06:00
|
|
|
void *data;
|
|
|
|
struct mGameObject *go;
|
|
|
|
void (*draw_debug)(void *data);
|
|
|
|
void (*draw_gui)(void *data);
|
2022-08-26 11:38:35 -05:00
|
|
|
void (*delete)(void *data);
|
2021-11-30 21:29:18 -06:00
|
|
|
int id;
|
|
|
|
int datasize;
|
|
|
|
void (*init)(void *data, struct mGameObject * go);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct component components[MAXNAME];
|
|
|
|
extern int ncomponent;
|
|
|
|
|
2022-06-21 15:21:00 -05:00
|
|
|
void comp_draw_debug(struct component *c);
|
|
|
|
void comp_draw_gui(struct component *c);
|
|
|
|
void comp_update(struct component *c, struct mGameObject *go);
|
|
|
|
|
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
void registry_init();
|
|
|
|
void register_component(const char *name, size_t size,
|
2022-08-12 14:03:56 -05:00
|
|
|
void (*make)(struct mGameObject * go, struct component * c),
|
2022-08-26 11:38:35 -05:00
|
|
|
void (*delete)(void *data),
|
2022-08-28 22:34:33 -05:00
|
|
|
void (*io)(void *data, FILE *f, int read),
|
2021-11-30 21:29:18 -06:00
|
|
|
void(*draw_debug)(void *data),
|
|
|
|
void(*draw_gui)(void *data),
|
2022-08-12 14:03:56 -05:00
|
|
|
void(*init)(void *data, struct mGameObject * go));
|
2021-11-30 21:29:18 -06:00
|
|
|
|
|
|
|
#endif
|