#include "component_action_on_delete_give_ammo.h"

/* DEPENDENCIES: Ammo, ActEntity */
/* On deletion, give ammo to the ID belonging to ActEntity. */

/* Initializes action on delete give ammo component. */
void
component_action_on_delete_give_ammo_init(ComponentActionOnDeleteGiveAmmo* self, u32 value)
{
	self->value = value;
}

/* Ticks aciton on delete give ammo component. */
void
component_action_on_delete_give_ammo_delete(ComponentActionOnDeleteGiveAmmo* self, ECS* ecs)
{
	ComponentActEntity* actEntity;
	ComponentAmmo* ammo;

	actEntity = ecs_component_get(ecs, ECS_COMPONENT_ACT_ENTITY, self->component.id);
	ammo = ecs_component_get(ecs, ECS_COMPONENT_AMMO, actEntity->id);

	ammo->value += self->value;
	ammo->value = MAX(ammo->value, ammo->max);
}
