#include "entity_chip.h"

/* Initializes a chip entity. */
void
entity_chip_init(ECS* ecs, u32 id, vec3 position, u32 sender)
{
	ComponentEnemy* enemy;
	ComponentActionDeleteOnTouchGameEntityType* actionDeleteOnTouchGameEntityType;

	enemy = ecs_component_add(ecs, ECS_COMPONENT_ENEMY, id);
	actionDeleteOnTouchGameEntityType = ecs_component_add(ecs, ECS_COMPONENT_ACTION_DELETE_ON_TOUCH_GAME_ENTITY_TYPE, id);

	component_enemy_init
	(
		enemy,
		ecs,
		ecs->game->resources.textures[TEXTURE_CHIP],
		(s32*)CHIP_FRAME_SIZE,
		(s32*)CHIP_ATLAS_SIZE,
		(f32*)CHIP_SIZE,
		(f32*)CHIP_PHYSICS_SIZE,
		position,
		CHIP_FRICTION,
		CHIP_VELOCITY_MAX,
		CHIP_HEALTH,
		CHIP_IS_BOUNCE,
		CHIP_IS_AFFECTED_BY_GRAVITY,
		CHIP_IS_SOLID,
		CHIP_GOODIE_COUNT,
		1,
		NULL
	);

	component_action_delete_on_touch_game_entity_type_init
	(
		actionDeleteOnTouchGameEntityType, 
		CHIP_ACTION_DELETE_ON_TOUCH_GAME_ENTITY_TYPE
	);

	ComponentGameEntityType* gameEntityType;

	gameEntityType = ecs_component_add(ecs, ECS_COMPONENT_GAME_ENTITY_TYPE, id);

	component_game_entity_type_init
	(
		gameEntityType, 
		GAME_ENTITY_CHIP
	);
}
