#include "component_action_damage.h"

/* DEPENDENCIES: Physics, Health */

/* Sets action_damage component info. */
void
component_action_damage_init(ComponentActionDamage* self, u32 value)
{
	self->value = value;
}

/* Ticks action_damage component. */
void
component_action_damage_tick(ComponentActionDamage* self, ECS* ecs)
{	
	ComponentPhysics* physics;
	ComponentHealth* health;

	physics = ecs_component_get(ecs, ECS_COMPONENT_PHYSICS, self->component.id);

	for (s32 i = 0; i < (s32)physics->collisions.count; i++)
	{
		health = ecs_component_from_index_get(ecs, ECS_COMPONENT_HEALTH, i);

		if (health)
		{
			health->value -= self->value;
			printf("HEALTH: %i\n", health->value);
		}
	}
}
