2024-03-30 21:25:39 +08:00
|
|
|
#pragma once
|
|
|
|
|
2024-04-22 04:50:06 +08:00
|
|
|
#include "util/vector.h"
|
2024-03-30 21:25:39 +08:00
|
|
|
#include "render_bundle.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct _App App;
|
|
|
|
typedef struct _Entity Entity;
|
|
|
|
|
|
|
|
typedef void (*render_CustomFunc)(App *app, Entity *e, Vec2 entity_screen_pos, void *user);
|
|
|
|
|
|
|
|
// Rendering component.
|
|
|
|
// This is mostly for components requiring static renders.
|
|
|
|
typedef struct {
|
2024-04-15 16:21:24 +08:00
|
|
|
Entity *super;
|
2024-03-30 21:25:39 +08:00
|
|
|
|
|
|
|
render_Bundle *bundle; // A render bundle, usually found by render_FindBundle()
|
|
|
|
render_CustomFunc custom; // Custom rendering function
|
|
|
|
void *custom_data; // User data for the callback
|
2024-04-15 16:21:24 +08:00
|
|
|
|
2024-04-22 04:50:06 +08:00
|
|
|
Box2 fillbox; // Fill box
|
|
|
|
vector_Vector *fillpoly; // Fill polygon, vector of Vec2
|
|
|
|
uint32_t fillcolor; // Fill color
|
2024-03-30 21:25:39 +08:00
|
|
|
} Component_Render;
|
|
|
|
|
|
|
|
|
|
|
|
// Creates a new component with a static render bundle
|
2024-04-16 10:30:37 +08:00
|
|
|
Component_Render *render_NewComponent(Entity *super, const char *bundle_name);
|
2024-03-30 21:25:39 +08:00
|
|
|
// Creates a new component with a callback for rendering
|
2024-04-16 10:30:37 +08:00
|
|
|
Component_Render *render_NewComponentFunc(Entity *super, render_CustomFunc func, void *data);
|
2024-03-30 21:25:39 +08:00
|
|
|
void render_DeleteComponent(Component_Render *r);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|