prosperon/source/engine/registry.h

47 lines
1.3 KiB
C
Raw Normal View History

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"
2022-11-19 17:13:57 -06:00
struct gameobject;
2021-11-30 21:29:18 -06:00
2023-01-03 09:06:36 -06:00
struct component_interface {
const char *name;
void *(*make)(struct gameobject * go); /* Called to create the component */
void (*io)(void *data, FILE *f, int read);
void (*draw_debug)(void *data); /* Draw debugging info in editor */
void (*draw_gui)(void *data);
void (*init)(void *data, struct gameobject * go);
void (*delete)(void *data);
2023-01-02 17:43:07 -06:00
};
2021-11-30 21:29:18 -06:00
struct component {
void *data;
2022-11-19 17:13:57 -06:00
struct gameobject *go;
2023-01-03 09:06:36 -06:00
struct component_interface *ref;
2021-11-30 21:29:18 -06:00
};
2023-01-03 09:06:36 -06:00
struct component comp_make(struct component_interface *interface);
2022-06-21 15:21:00 -05:00
void comp_draw_debug(struct component *c);
void comp_draw_gui(struct component *c);
2023-01-03 09:06:36 -06:00
void comp_delete(struct component *c);
void comp_init(struct component *c);
void comp_io(struct component *c, int read);
2022-11-19 17:13:57 -06:00
void comp_update(struct component *c, struct gameobject *go);
2022-06-21 15:21:00 -05:00
2021-11-30 21:29:18 -06:00
void registry_init();
void register_component(const char *name, size_t size,
2022-11-19 17:13:57 -06:00
void (*make)(struct gameobject * 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-11-19 17:13:57 -06:00
void(*init)(void *data, struct gameobject * go));
2021-11-30 21:29:18 -06:00
#endif