#include "entity_cursor.h"

/* Initializes a cursor entity. */
void
entity_cursor_init(ECS* ecs, u32 id)
{
	ComponentSprite* sprite;
	vec2 mousePosition;
	vec3 position;

	sprite = ecs_component_add(ecs, ECS_COMPONENT_SPRITE, id);

	ecs_component_add(ecs, ECS_COMPONENT_ANIMATION_CURSOR, id);
	
	mouse_world_position_get(&ecs->game->input.mouse, &ecs->game->renderer, mousePosition);

	position[0] = mousePosition[0];
	position[1] = mousePosition[1];
	position[2] = 0.0f;

	component_sprite_atlas_init
	(
		sprite,
		ecs->game->resources.textures[TEXTURE_CURSOR],
		(s32*)CURSOR_FRAME_SIZE,
		(s32*)CURSOR_ATLAS_SIZE,
		(f32*)CURSOR_SIZE,
		position
	);
}
