
#pragma once
#ifndef AI_FIREDATA_HPP
#define AI_FIREDATA_HPP

#include <Adept\Entity.hpp>
#include <Stuff\Line.hpp>
#include <Stuff\Normal.hpp>
#include <Stuff\Point3D.hpp>



namespace MechWarrior4
{
	class Weapon;
};

namespace MW4AI
{
	class FireData
	{
	  public:
		FireData(Adept::Entity& source,
				 const Stuff::Point3D& src,
				 const Stuff::Point3D& dest);

		FireData(Adept::Entity& source,
				 MechWarrior4::Weapon& weapon,
				 const Stuff::Point3D& dest);

		FireData(const FireData& copy_from);

		Adept::Entity* Project();

		inline Adept::Entity& GetSource() const;
		inline const Stuff::Point3D& GetOrigin() const;
		inline Stuff::Point3D GetDest();
		inline const Stuff::Line3D& GetLine() const;
		inline Stuff::Line3D& GetLine();
		inline Adept::Entity__CollisionQuery& GetQuery();
		inline Adept::Entity* GetRaySource() const;
		inline void SetLineLength(Stuff::Scalar length);

		enum HIT_RESULT
		{
			HIT_TARGET,
			HIT_SOMETHING_ELSE,
			HIT_NOTHING
		};

		HIT_RESULT GetHitResult(Adept::Entity* desired_target = 0, bool ignore_dead_components = false) const;
		bool HitsGround() const;

	  private:
		void CreateLine(const Stuff::Point3D& src,
						const Stuff::Point3D& dest);

	  private:
		Adept::Entity__CollisionQuery m_Query;
		Stuff::Line3D m_Line;
		Stuff::Normal3D m_Normal;
		Adept::Entity& m_Source;
	};

	inline const Stuff::Line3D& FireData::GetLine() const
	{
		return (m_Line);
	}

	inline Stuff::Line3D& FireData::GetLine()
	{
		return (m_Line);
	}

	inline Adept::Entity__CollisionQuery& FireData::GetQuery()
	{
		return (m_Query);
	}

	inline Adept::Entity* FireData::GetRaySource() const
	{
		return (m_Query.m_raySource);
	}

	inline Adept::Entity& FireData::GetSource() const
	{
		return (m_Source);
	}

	inline const Stuff::Point3D& FireData::GetOrigin() const
	{
		return (m_Line.m_origin);
	}

	inline Stuff::Point3D FireData::GetDest()
	{
		Stuff::Point3D rv;
		m_Line.FindEnd(&rv);
		return (rv);
	}

	inline void FireData::SetLineLength(Stuff::Scalar length)
	{
		Verify(length > 0);
		m_Line.m_length = length;
	}
};



#endif // AI_FIREDATA_HPP