#include "component_action_delete_on_timer.h"

/* DEPENDENCIES: Timer */
/* This entity associated with this component will be deleted if its timer component runs out. */

/* Initializes action delete on timer component. */
void
component_action_delete_on_timer_init(ComponentActionDeleteOnTimer* self, u32 value)
{
	self->max = value;
	self->value = self->max;
}

/* Ticks action delete on timer component. */
void
component_action_delete_on_timer_tick(ComponentActionDeleteOnTimer* self, ECS* ecs)
{
	self->value--;

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