Add fireball particles, add max lifespan to fireball

This commit is contained in:
2024-02-10 11:39:01 +01:00
parent 1c6fab51c6
commit 1487d67a3b
5 changed files with 57 additions and 38 deletions

View File

@@ -58,11 +58,13 @@ void updateParticleEmitter(ecs_iter_t *it) {
ecs_entity_t entity = it->entities[i];
if (ecs_has(ECS, entity, EmitterAttachment)) {
EmitterAttachment attachment = *ecs_get(ECS, entity, EmitterAttachment);
if (ecs_is_alive(ECS, attachment.baseEntity)) {
Vector2 pos = *ecs_get(ECS, entity, Position);
pos = Vector2Add(pos, attachment.offset);
emitter[i].pos = pos;
if (!ecs_is_alive(ECS, attachment.baseEntity)) {
ecs_delete(ECS, attachment.baseEntity);
continue;
}
Vector2 pos = *ecs_get(ECS, attachment.baseEntity, Position);
pos = Vector2Add(pos, attachment.offset);
emitter[i].pos = pos;
}
const struct ParticleEmitterData data = emitter[i].data;