#include "entity_chipper.h"

/* Initializes a Chipper entity. */
void
entity_chipper_init(ECS* ecs, u32 id, vec3 position, u32 targetID, u32 level, Vector* entityList)
{
	ComponentEnemy* enemy;
	ComponentBehaviorApproachAndShoot* behaviorApproachAndShoot;
	ComponentBehaviorActInRectangle* behaviorActInRectangle;

	enemy = ecs_component_add(ecs, ECS_COMPONENT_ENEMY, id);
	behaviorApproachAndShoot = ecs_component_add(ecs, ECS_COMPONENT_BEHAVIOR_APPROACH_AND_SHOOT, id);
	behaviorActInRectangle = ecs_component_add(ecs, ECS_COMPONENT_BEHAVIOR_ACT_IN_RECTANGLE, id);

	component_enemy_init
	(
		enemy,
		ecs,
		ecs->game->resources.textures[TEXTURE_CHIPPER],
		(s32*)CHIPPER_FRAME_SIZE,
		(s32*)CHIPPER_ATLAS_SIZE,
		(f32*)CHIPPER_SIZE,
		(f32*)CHIPPER_PHYSICS_SIZE,
		position,
		CHIPPER_FRICTION,
		CHIPPER_VELOCITY_MAX,
		CHIPPER_HEALTH_MAX,
		CHIPPER_GAME_OBJECT_IS_BOUNCE,
		CHIPPER_GAME_OBJECT_IS_AFFECTED_BY_GRAVITY,
		CHIPPER_GAME_OBJECT_IS_SOLID,
		CHIPPER_GOODIE_COUNT,
		level,
		entityList
	);

	component_behavior_approach_and_shoot_init
	(
		behaviorApproachAndShoot,
		ecs,
		entity_chip_init,
		CHIPPER_BEHAVIOR_APPROACH_AND_SHOOT_SPEED,
		CHIPPER_BEHAVIOR_APPROACH_AND_SHOOT_PROJECTILE_SPEED,
		CHIPPER_BEHAVIOR_APPROACH_AND_SHOOT_OFFSET,
		CHIPPER_BEHAVIOR_APPROACH_AND_SHOOT_HEIGHT,
		CHIPPER_BEHAVIOR_APPROACH_AND_SHOOT_DISTANCE,
		CHIPPER_BEHAVIOR_APPROACH_AND_SHOOT_TIMER,
		targetID
	);

	component_behavior_act_in_rectangle_init(behaviorActInRectangle, CHIPPER_ACT_RECTANGLE);

	ComponentGameEntityType* gameEntityType;

	gameEntityType = ecs_component_add(ecs, ECS_COMPONENT_GAME_ENTITY_TYPE, id);

	component_game_entity_type_init
	(
		gameEntityType, 
		GAME_ENTITY_CHIPPER
	);
}
