#include "entity_goodie.h"

/* Initializes a goodie entity. */
void
entity_goodie_init(ECS* ecs, u32 id, vec3 position, vec3 velocity, f32 height)
{
	ComponentPickup* pickup;
	ComponentActionOnTouchGiveGoodies* actionOnTouchGiveGoodies;

	pickup = ecs_component_add(ecs, ECS_COMPONENT_PICKUP, id);
	actionOnTouchGiveGoodies = ecs_component_add(ecs, ECS_COMPONENT_ACTION_ON_TOUCH_GIVE_GOODIES, id);
	
	component_pickup_init
	(
	
		pickup,
		ecs,
		ecs->game->resources.textures[TEXTURE_GOODIES],
		(s32*)GOODIE_FRAME_SIZE,
		(s32*)GOODIE_ATLAS_SIZE,
		(f32*)GOODIE_SIZE,
		(f32*)GOODIE_PHYSICS_SIZE,
		position,
		GOODIE_FRICTION,
		GOODIE_VELOCITY_MAX,
		(f32*)velocity,
		height,
		GOODIE_PICKUP_TIME,
		GOODIE_PICKUP_FADE_THRESHOLD,
		GOODIE_PICKUP_GAME_ENTITY_TYPE
	);

	component_action_on_touch_give_goodies_init(actionOnTouchGiveGoodies, GOODIE_PICKUP_VALUE);

	ComponentGameEntityType* gameEntityType; 
	gameEntityType = ecs_component_add(ecs, ECS_COMPONENT_GAME_ENTITY_TYPE, id); 

	component_game_entity_type_init 
	( 
		gameEntityType, 
		GAME_ENTITY_GOODIE
	);
}
