
#pragma once
#ifndef AI_SQUAD_HPP
#define AI_SQUAD_HPP

#include <Stuff\Auto_Ptr.hpp>
#include <Adept\Entity.hpp>
#include <Adept\NameTable.hpp>



namespace MechWarrior4
{
	class CombatAI;
	class MWObject;
	class Group;
};

#define INTERFACE_SquadAI(post)														\
  public:																			\
	virtual void Update(MechWarrior4::Group& group,									\
						MechWarrior4::CombatAI& combat_ai) ##post					\
	virtual void NotifyShot(MechWarrior4::Group& group,								\
							Adept::ObjectID id) ##post								\
	virtual void NotifyShotFired(MechWarrior4::Group& group,						\
								 const Stuff::Line3D& line,							\
								 MechWarrior4::MWObject& at_who,					\
								 MechWarrior4::MWObject& shooter) ##post			\
	virtual void NotifyMemberAdded(MechWarrior4::Group& group,						\
								   MechWarrior4::MWObject& who) ##post				\
	virtual void SetEntityToIgnore(Adept::ObjectID objectid) ##post					\
	virtual void NotifyMemberRemoved(MechWarrior4::Group& group,					\
									 MechWarrior4::MWObject& who) ##post

#define PURE_SquadAI	INTERFACE_SquadAI(=0;)
#define DERIVED_SquadAI INTERFACE_SquadAI(;)

namespace MW4AI
{
	namespace Squad
	{
		enum ID									// NOTE: these constants must exactly match those in MWCONST.ABI
		{
			GROUPAI_FIRST		= 3999,

			GROUPAI_NONE		= 4000,
			GROUPAI_LANCEMATE	= 4001,
			GROUPAI_RADIOSQUAD	= 4002,
			GROUPAI_MOODSQUAD	= 4003,
			GROUPAI_FOCUSFIRESQUAD = 4004,

			GROUPAI_LAST		= 4005
		};

		class AI
		{
			PURE_SquadAI;

		  public:
			virtual ~AI() {};

			virtual bool IgnoresFriendlyFire() const { return (false); }

			virtual ID GetID() const = 0;

			virtual void NotifyMechDestroyed(MechWarrior4::Group& group,
											 const Adept::ReplicatorID& inflicting_id,
											 const Adept::ReplicatorID& victim_id)
			{ };

		  protected:
			Adept::Entity* GetLeader(const MechWarrior4::Group& group) const;
			int GetIndex(const MechWarrior4::CombatAI& combat_ai, const MechWarrior4::Group& group) const;
		};

		Stuff::Auto_Ptr<AI> CreateAI(ID id);
	};
};



#endif // AI_SQUAD_HPP
