/*****************************************************************************
 * $Id: game_base_craft.hh,v 1.41 2006/08/10 03:18:58 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_GAME
#ifndef GAME_BASE_CRAFT_HH
#define GAME_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( QuadrantPtrc 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 );
	void				SetAnimation( eAnimate animate );
	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 )
};
#if DEBUG
typedef       Ptr<Craft> CraftPtr;
typedef const Ptr<Craft> CraftPtrc;
#else
typedef Craft* CraftPtr;
typedef Craft* CraftPtrc;
#endif

void
Listener_Craft_DrawObjects( void );

void
Listener_Craft_ResetScene( void );

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

#endif // GAME_BASE_CRAFT_HH
#endif // COMPILING_GAME
