Add emitter component
Also, add funciton to check if emitter handle is still alivescene_man
parent
841603a432
commit
ad789329d1
|
@ -26,6 +26,7 @@ typedef enum ComponentEnum {
|
|||
CLIFETIMER_T,
|
||||
CWATERRUNNER_T,
|
||||
CAIRTIMER_T,
|
||||
CEMITTER_T,
|
||||
} ComponentEnum_t;
|
||||
|
||||
typedef enum MovementMode {
|
||||
|
@ -215,6 +216,13 @@ typedef struct _CMoveable_t {
|
|||
bool gridmove;
|
||||
} CMoveable_t;
|
||||
|
||||
typedef uint16_t EmitterHandle;
|
||||
typedef struct _CEmitter_t
|
||||
{
|
||||
EmitterHandle handle;
|
||||
Vector2 offset;
|
||||
} CEmitter_t;
|
||||
|
||||
static inline void set_bbox(CBBox_t* p_bbox, unsigned int x, unsigned int y)
|
||||
{
|
||||
p_bbox->size.x = x;
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
#define MAX_TILE_TYPES 16
|
||||
|
||||
#define N_TAGS 10
|
||||
#define N_COMPONENTS 14
|
||||
#define N_COMPONENTS 15
|
||||
#define MAX_COMP_POOL_SIZE 1024
|
||||
#endif // _ENGINE_CONF_H
|
||||
|
|
|
@ -77,6 +77,7 @@ static CMoveable_t cmoveable_buffer[MAX_COMP_POOL_SIZE];
|
|||
static CLifeTimer_t clifetimer_buffer[MAX_COMP_POOL_SIZE];
|
||||
static CWaterRunner_t cwaterrunner_buffer[32];
|
||||
static CAirTimer_t cairtimer_buffer[8]; // Only player is expected to have this
|
||||
static CEmitter_t cemitter_buffer[MAX_COMP_POOL_SIZE]; // Only player is expected to have this
|
||||
|
||||
// Static allocate mempools
|
||||
static MemPool_t comp_mempools[N_COMPONENTS] = {
|
||||
|
@ -94,6 +95,7 @@ static MemPool_t comp_mempools[N_COMPONENTS] = {
|
|||
{clifetimer_buffer, MAX_COMP_POOL_SIZE, sizeof(CLifeTimer_t), NULL, {0}},
|
||||
{cwaterrunner_buffer, 32, sizeof(CWaterRunner_t), NULL, {0}},
|
||||
{cairtimer_buffer, 8, sizeof(CAirTimer_t), NULL, {0}},
|
||||
{cemitter_buffer, MAX_COMP_POOL_SIZE, sizeof(CEmitter_t), NULL, {0}},
|
||||
};
|
||||
static MemPool_t ent_mempool = {
|
||||
.buffer = entity_buffer,
|
||||
|
|
|
@ -126,6 +126,13 @@ void unload_emitter_handle(ParticleSystem_t* system, EmitterHandle handle)
|
|||
system->emitters[handle].finished = true;
|
||||
}
|
||||
|
||||
bool is_emitter_handle_alive(ParticleSystem_t* system, EmitterHandle handle)
|
||||
{
|
||||
if (handle == 0) return false;
|
||||
|
||||
return system->emitters[handle].active;
|
||||
}
|
||||
|
||||
EmitterHandle play_particle_emitter(ParticleSystem_t* system, const ParticleEmitter_t* in_emitter)
|
||||
{
|
||||
EmitterHandle idx = load_in_particle_emitter(system, in_emitter);
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef uint16_t EmitterHandle;
|
||||
|
||||
typedef enum PartEmitterType
|
||||
{
|
||||
EMITTER_UNKNOWN = 0,
|
||||
|
@ -86,6 +84,7 @@ void play_emitter_handle(ParticleSystem_t* system, EmitterHandle handle);
|
|||
void stop_emitter_handle(ParticleSystem_t* system, EmitterHandle handle);
|
||||
void update_emitter_handle_position(ParticleSystem_t* system, EmitterHandle handle, Vector2 pos);
|
||||
void unload_emitter_handle(ParticleSystem_t* system, EmitterHandle handle);
|
||||
bool is_emitter_handle_alive(ParticleSystem_t* system, EmitterHandle handle);
|
||||
|
||||
void update_particle_system(ParticleSystem_t* system);
|
||||
void draw_particle_system(ParticleSystem_t* system);
|
||||
|
|
Loading…
Reference in New Issue