#ifndef RTS_BASEBUILDING_H
#define RTS_BASEBUILDING_H

// ##################################################################################
//	>>
//
// ##################################################################################

#include "hl2wars/c_rts_mouse_model.h"
#include "hl2wars/rts_shareddefs.h"

enum Building_states_t
{
	BS_PRECONSTRUCTION = 0,
	BS_UNDERCONSTRUCTION,
	BS_CONSTRUCTED,
};

// ##################################################################################
//	>> Building model implementation
//
// ##################################################################################
class C_BaseBuildingModel : public C_MouseRTSModel
{
public:
	DECLARE_CLASS( C_BaseBuildingModel , C_MouseRTSModel );
	DECLARE_CLIENTCLASS();

	// Constructor
	C_BaseBuildingModel ( void );
	~C_BaseBuildingModel ( void );

	void			Spawn( void );
	void			UpdateOnRemove( void );

	virtual void	OnCursorEntered();
	virtual void	OnCursorHover();

	int				GetHealth() const { return m_iHealth; };
	int				GetMaxHealth() const { return m_iMaxHealth; };

	int				GetOwnerShip() { return m_iOwnerShip; }
	Vector			GetOwnerShipTarget() { return m_vOwnerShipIconTarget; }

	virtual void	SetSelected( bool selected );
	virtual bool	IsSelected() { return m_bSelected; }

	// construction info
	int				GetConstructionProgress() { return m_iConstructProgress; }
	bool			IsUnderConstruction() { return m_iConstructionState != BS_CONSTRUCTED; }

	void					ClientThink( void );
	void					OnDataChanged( DataUpdateType_t type );

	// virtual functions that can be implemented in a higher level
	virtual int GetQueueCount( int i ) { return 0; }
	virtual int GetTypeAbility( int i ) { return 0; }
	virtual int GetTypeQueueAbility( int i ) { return 0; }
	virtual float GetBuildTime() { return 0.0f; }
	virtual float GetBuildTimeMax() { return 0.0f; }
	
	virtual float GetViewDistance() { return m_fViewDistance; }

	//void Spawn();

	virtual color32 GetColor();

	virtual int GetBrushType( void ) { return MOUSEBRUSH_BUILDING; };

protected:
	// default info
	bool			m_bSelected;
	int				m_iOwnerShip;
	Vector			m_vOwnerShipIconTarget;

	char	m_iszNetIcon[MAX_PATH];
	CHudTexture		*m_pMiniMapIcon;

private:
	// construction info
	int				m_iHealth;	// health of the npc
	int				m_iMaxHealth;
	int				m_iConstructionState;
	int				m_iConstructProgress;

	float			m_fViewDistance;

public:
	C_BaseBuildingModel		*m_pNext;
};

extern C_BaseBuildingModel *GetBuildingModelList();

// ##################################################################################
//	>> Building model component implementation
//
// ##################################################################################
class C_BuildingComponent : public C_MouseRTSModel
{
public:
	DECLARE_CLASS( C_BuildingComponent , C_MouseRTSModel );
	DECLARE_CLIENTCLASS();

	// Constructor
	C_BuildingComponent ( void );
	
	virtual void			Spawn( void );
	void					ClientThink( void );

	C_BaseBuildingModel *		GetOuter() 			{ return m_hOuter; }
	const C_BaseBuildingModel *	GetOuter() const 	{ return m_hOuter; }

private:
	CHandle<C_BaseBuildingModel>	m_hOuter;
};

#endif  // RTS_BASEBUILDING_H