
#pragma once
#ifndef AI_WEAPONS_HPP
#define AI_WEAPONS_HPP

#include <Stuff\Scalar.hpp>
#pragma warning (push)
#include <stlport\vector>
#pragma warning (pop)
#include "AI_HitTesting.hpp"



namespace Adept
{
	class Entity__CollisionQuery;
};

namespace MechWarrior4
{
	class MWObject;
	class Weapon;
};

namespace Adept
{
	class DamageObject;
};


namespace MW4AI
{
	Stuff::Scalar GetMaxWeaponDistance(MechWarrior4::Weapon& weapon);
//	Stuff::Scalar GetMinWeaponDistance(MechWarrior4::Weapon& weapon);

	Stuff::Scalar GetMaxWeaponDistance(MechWarrior4::MWObject& vehicle);
	Stuff::Scalar GetMinWeaponDistance(MechWarrior4::MWObject& vehicle);

	void SetWeaponsToMaxWaitValue(MechWarrior4::MWObject& object);

	bool HasAnyUnlimitedAmmoWeapons(MechWarrior4::MWObject& object);
	bool HasAnyProjectileWeapons(MechWarrior4::MWObject& object);

	bool WeaponCanFire(MechWarrior4::Weapon& weapon,
					   Stuff::Scalar line_length = 0,
					   Stuff::Time min_delay = 0,
					   Stuff::Time max_delay = 0);

	bool GetWeaponsThatCanFire(std::vector<Weapon *>& weapons,
							   bool can_spend_ammo,
							   Stuff::Time min_delay,
							   Stuff::Time max_delay);

	bool GetWeaponsThatCanFireAt(std::vector<Weapon *>& weapons,
								 const Stuff::Point3D& aim);

	bool GetWeaponsThatCanFireFrom(std::vector<Weapon *>& weapons,
								   FireSource fire_source);

	bool MightHitFriendlies(const Stuff::Line3D& line,
							Stuff::Scalar line_length,
							MechWarrior4::MWObject& shooter,
							MechWarrior4::MWObject* ignore = 0);

	bool AnyWeaponReady(MechWarrior4::MWObject& vehicle,
						Stuff::Time min_delay = 0,
						Stuff::Time max_delay = 0);

	bool AnyWeaponNotReady(MechWarrior4::MWObject& vehicle,
						   Stuff::Time min_delay = 0,
						   Stuff::Time max_delay = 0);

	unsigned int NumWeapons(MechWarrior4::MWObject& vehicle);
	unsigned int NumWeaponsReady(MechWarrior4::MWObject& vehicle,
								 Stuff::Time min_delay = 0,
								 Stuff::Time max_delay = 0);

	bool WeaponIsArmWeapon(const MechWarrior4::Weapon& weapon, bool left);
	Stuff::LinearMatrix4D WeaponSiteLocalToWorld(const MechWarrior4::Weapon& weapon);

	typedef std::vector<Adept::DamageObject*> component_vector;

	void DamageObjectChainToVector(Stuff::SortedChainOf<Adept::DamageObject*,int>& chain, component_vector& v);

	Adept::DamageObject* GetComponent_MostDamaged(MechWarrior4::MWObject& who, const component_vector& v);
	Adept::DamageObject* GetComponent_LeastDamaged(const component_vector& v);
	Adept::DamageObject* GetComponent_Random(const component_vector& v);
	Adept::DamageObject* GetComponent_TorsoThenTopDown(const component_vector& v);

	void GetLeftmostAndRightmostWeapons(MechWarrior4::MWObject& object,
										std::vector<MechWarrior4::Weapon*>& weapons);

	Stuff::Point3D GetWeaponCenter(MechWarrior4::MWObject& object);

	void SetRaySourceToBestComponent(Adept::Entity__CollisionQuery& query);
};


#endif AI_WEAPONS_HPP
