#include "component_animation_squash.h"

/* DEPENDENCIES: Sprite, Text */

/* Sets animation_squash component info. */
void
component_animation_squash_init(ComponentAnimationSquash* self, f32 base, f32 multiplier, f32 speed)
{
	self->base = base;
	self->multiplier = multiplier;
	self->speed = speed;
}

/* Ticks animation_squash component. */
void
component_animation_squash_tick(ComponentAnimationSquash* self, ECS* ecs)
{
	DrawObject* drawObject;

	drawObject = ecs_component_get(ecs, ECS_COMPONENT_SPRITE, self->component.id);

	if (!drawObject)
		drawObject = ecs_component_get(ecs, ECS_COMPONENT_TEXT, self->component.id);

	drawObject->scale[1] = self->base + (cos(self->timer * self->speed) * self->multiplier);

	self->timer++;
}
