#include "component_lifetime.h"

/* Sets lifetime component info. */
void
component_lifetime_init(ComponentLifetime* self, u32 lifetime)
{
	self->lifetimeMax = lifetime;
	self->lifetime = self->lifetimeMax;
}

/* Ticks lifetime component; when it hits 0, poof. */
void
component_lifetime_tick(ComponentLifetime* self, ECS* ecs)
{
	self->lifetime--;

	if (self->lifetime <= 0)
		ecs_entity_delete(ecs, self->component.id);
}
