#include "entity_icon_notice.h"

/* Initializes an icon notice entity. */
void
entity_icon_notice_init(ECS* ecs, u32 id, vec3 position, IconType type)
{
	ComponentActionDeleteOnTimer* actionDeleteOnTimer;
	ComponentAnimationColorChange* animationColorChange;
	ComponentAnimationMove* animationMove;
	ComponentSprite* sprite;

	sprite = ecs_component_add(ecs, ECS_COMPONENT_SPRITE, id);
	actionDeleteOnTimer = ecs_component_add(ecs, ECS_COMPONENT_ACTION_DELETE_ON_TIMER, id);
	animationColorChange = ecs_component_add(ecs, ECS_COMPONENT_ANIMATION_COLOR_CHANGE, id);
	animationMove = ecs_component_add(ecs, ECS_COMPONENT_ANIMATION_MOVE, id);

	component_sprite_atlas_init
	(
		sprite,
		ecs->game->resources.textures[TEXTURE_ICONS],
		(s32*)ICON_FRAME_SIZE,
		(s32*)ICON_ATLAS_SIZE,
		(f32*)ENTITY_ICON_NOTICE_SIZE,
		position
	);

	sprite->atlas.index = type;

	component_action_delete_on_timer_init
	(
		actionDeleteOnTimer,
		ENTITY_ICON_NOTICE_TIMER
	);

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

	component_animation_move_init
	(
		animationMove,
		(f32*)ENTITY_ICON_NOTICE_MOVE_VELOCITY
	);
}
