#include "entity_excorsant.h"

/* Initializes an Excorsant entity. */
void
entity_excorsant_init(ECS* ecs, u32 id, vec3 position, u32 targetID, u32 level, Vector* entityList)
{
	ComponentEnemy* enemy;
	ComponentBehaviorBoomerang* behaviorBoomerang;
	ComponentBehaviorActInRectangle* behaviorActInRectangle;
	ComponentAnimationLevitate* animationLevitate;

	behaviorBoomerang = ecs_component_add(ecs, ECS_COMPONENT_BEHAVIOR_BOOMERANG, id);
	behaviorActInRectangle = ecs_component_add(ecs, ECS_COMPONENT_BEHAVIOR_ACT_IN_RECTANGLE, id);

	enemy = ecs_component_add(ecs, ECS_COMPONENT_ENEMY, id);
	animationLevitate = ecs_component_add(ecs, ECS_COMPONENT_ANIMATION_LEVITATE, id);

	component_enemy_init
	(
		enemy,
		ecs,
		ecs->game->resources.textures[TEXTURE_EXCORSANT],
		(s32*)EXCORSANT_FRAME_SIZE,
		(s32*)EXCORSANT_ATLAS_SIZE,
		(f32*)EXCORSANT_SIZE,
		(f32*)EXCORSANT_PHYSICS_SIZE,
		position,
		EXCORSANT_FRICTION,
		EXCORSANT_VELOCITY_MAX,
		EXCORSANT_HEALTH_MAX,
		EXCORSANT_IS_BOUNCE,
		EXCORSANT_IS_AFFECTED_BY_GRAVITY,
		EXCORSANT_IS_SOLID,
		EXCORSANT_GOODIE_COUNT,
		level,
		entityList
	);

	component_behavior_boomerang_init
	(
		behaviorBoomerang,
		ecs,
		EXCORSANT_CHASE_SPEED,
		EXCORSANT_BEHAVIOR_BOOMERANG_INITIAL_SPEED,
		EXCORSANT_BEHAVIOR_BOOMERANG_SPEED,
		EXCORSANT_BEHAVIOR_BOOMERANG_TIMER,
		targetID
	);

	component_animation_levitate_init
	(
		animationLevitate,
		EXCORSANT_ANIMATION_LEVITATE_HEIGHT,
		EXCORSANT_ANIMATION_LEVITATE_RANGE,
		EXCORSANT_ANIMATION_LEVITATE_SPEED
	);

	component_behavior_act_in_rectangle_init(behaviorActInRectangle, EXCORSANT_ACT_RECTANGLE);

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

	component_game_entity_type_init 
	( 
		gameEntityType, 
		GAME_ENTITY_EXCORSANT
	);	
}
