#include "component_animation_stretch.h"

/* DEPENDENCIES: Sprite, Text */

/* Sets animation_stretch component info. */
void
component_animation_stretch_init(ComponentAnimationStretch* self, f32 base, f32 multiplier, f32 speed)
{
	self->base = base;
	self->multiplier = multiplier;
	self->speed = speed;
}

/* Ticks animation_stretch component. */
void
component_animation_stretch_tick(ComponentAnimationStretch* 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[0] = self->base + (cos(self->timer * self->speed) * self->multiplier);

	self->timer++;
}
