#include "entity_redirect_arrow.h"

/* Initializes a redirect_arrow entity. */
void
entity_redirect_arrow_init(ECS* ecs, u32 id, vec3 position, u32 followID)
{
	ComponentSprite* sprite;
	ComponentActionFollow* actionFollow;
	ComponentAnimationColorChange* animationColorChange;

	sprite = ecs_component_add(ecs, ECS_COMPONENT_SPRITE, id);
	actionFollow = ecs_component_add(ecs, ECS_COMPONENT_ACTION_FOLLOW, id);
	animationColorChange = ecs_component_add(ecs, ECS_COMPONENT_ANIMATION_COLOR_CHANGE, id);

	ecs_component_add(ecs, ECS_COMPONENT_ACTION_POINT_TO_MOUSE, id);

	component_sprite_init
	(
		sprite,
		ecs->game->resources.textures[TEXTURE_REDIRECT_ARROW],
		(f32*)ENTITY_REDIRECT_ARROW_SIZE,
		position
	);

	component_action_follow_init
	(
		actionFollow,
		followID,
		ENTITY_REDIRECT_ARROW_OFFSET
	);

	component_animation_color_change_init
	(
		animationColorChange,
		(f32*)COLOR_OPAQUE,
		(f32*)COLOR_TRANSPARENT,
		ENTITY_REDIRECT_ARROW_ANIMATION_COLOR_CHANGE_TIMER,
		ANIMATION_COLOR_CHANGE_MODE_STICK
	);

	glm_vec4_copy((f32*)COLOR_TRANSPARENT, sprite->color);
}
