/*****************************************************************************
 * $Id: mod_base_craft.hh,v 1.1 2006/11/24 21:56:57 devel Exp $
 * @file
 * @author	Jim E. Brooks  http://www.jimbrooks.org
 * @brief	Craft class.
 *//*
 * LEGAL:	COPYRIGHT (C) 2004 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE (GPL).
 *****************************************************************************/

#if COMPILING_MODULE
#ifndef MOD_BASE_CRAFT_HH
#define MOD_BASE_CRAFT_HH 1

#include "eng_dyna.hh"
#include "eng_dyna_model.hh"
#include "eng_poly16.hh"
#include "eng_polygon.hh"

////////////////////////////////////////////////////////////////////////////////
/// @brief Craft class.
class Craft : public DynaModel
{
private:
	PREVENT_COPYING(Craft)
	typedef DynaModel Parent;
public:
						Craft( QuadrantPtrConst q, const Position& pos, const vector<string>& fnameModelVec );
	virtual				~Craft();
	const string		GetName( void ) { return string("Craft"); }
	void				FinalConstruction( void );
	void				Save( void );
	void				Reset( void );
	void				Reload( const MatrixExt& xmReload );
	void				Translate( uint axis, fp inc );
	void				Draw( void );
	virtual int			Animate( void );
	void				SetThrottle( Percent percent );
	void				Revive( void );
	uint				GetGunCnt( void ) const  { return mGunCnt; }
	void				SetGunCnt( uint gunCnt ) { mGunCnt = gunCnt; }
private:
	virtual void		DrawShadow( void );
	void				DrawExplosion( void );
	bool				CollisionDetection( const fp inc );
protected:
						/// Call SetNeedRecalc() if object is transformed.
	void				SetNeedRecalc( void )
						{
							mNeedRecalcShadowWorldVertexs = true;
							Parent::SetNeedRecalc();
						}
private:
	MatrixExt			mXmOrig;
	EyeVertex*			mEyeVertexs;
	WorldVertex*		mShadowWorldVertexs;
	EyeVertex*			mShadowEyeVertexs;
	bool				mNeedRecalcShadowWorldVertexs;	///< for speed, avoid recalculation when
	int					mExplosion;						///< decremented every frame
	bool				mPostTakeoff;
	uint				mGunCnt;
public:
	DECL_TYPESIG( TYPESIG_CRAFT )
friend class PilotModule;
};

#if DEBUG
typedef       SafePtr<Craft> CraftPtr;
typedef const SafePtr<Craft> CraftPtrConst;
#else
typedef Craft*       CraftPtr;
typedef Craft* const CraftPtrConst;
#endif

void
Listener_Craft_DrawObjects( void );

void
Listener_Craft_ResetScene( void );

void
ForEachCraft( void(*func)(CraftPtrConst,long), long userdata );

#endif // MOD_BASE_CRAFT_HH
#endif // COMPILING_MODULE
