#include "MW4Headers.hpp"

#include "AI_Squad.hpp"

#include "AI_Lancemate.hpp"
#include "AI_MoodSquad.hpp"
#include "AI_FocusFireSquad.hpp"
#include "Group.hpp"
#include "aiutils.hpp"
#include "CombatAI.hpp"



Stuff::Auto_Ptr<MW4AI::Squad::AI> MW4AI::Squad::CreateAI(MW4AI::Squad::ID id)
{
	Verify(id > GROUPAI_FIRST);
	Verify(id < GROUPAI_LAST);

	MW4AI::Squad::AI* ai = 0;

	switch (id)
	{
		case GROUPAI_NONE:
		{
			break;
		}

		case GROUPAI_LANCEMATE:
		{
			ai = new Lancemate;
			break;
		}

		case GROUPAI_RADIOSQUAD:
		{
			ai = new RadioSquad;
			break;
		}

		case GROUPAI_MOODSQUAD:
		{
			ai = new MoodSquad;
			break;
		}

		case GROUPAI_FOCUSFIRESQUAD:
		{
			ai = new FocusFireSquad;
			break;
		}

		default:
		{
			Verify(!"GroupAI ID not found.");
			break;
		}
	}

	Stuff::Auto_Ptr<MW4AI::Squad::AI> rv(ai);
	return (rv);
}

Adept::Entity* MW4AI::Squad::AI::GetLeader(const MechWarrior4::Group& group) const
{
	return (group.IDToEntity(*(group.GetElements().begin())));

}

int MW4AI::Squad::AI::GetIndex(const MechWarrior4::CombatAI& combat_ai, const MechWarrior4::Group& group) const
{
	Verify(group.GetElements().size() > 0);
	return (index_of(group.GetElements().begin(),group.GetElements().end(),combat_ai.GetSelf().objectID));
}
