/**
*
* \file Tools_Entity_Glass_Object.h
*
* Created by Andrew Weinkove - 18/07/2002
*
* Copyright (C) 2002 Rebellion, All Rights Reserved.
*
* \brief
*
**/
#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef _TOOLS_ENTITY_GLASS_OBJECT_H_
#define _TOOLS_ENTITY_GLASS_OBJECT_H_

#include "Rendering/Asura_Colour.h"
#include "Entity/Tools_Entity_PhysicsObject.h"

//////////////////////////
// Forward declarations //
//////////////////////////
class Tools_WorldSpaceRectangle_Object;
class Asura_Overlay;
class Asura_Vector_2;
class Asura_ServerEntity_Glass;
class Asura_ClientEntity_Glass;

///////////////////////////////
// Tools_Entity_Glass_Object //
///////////////////////////////
class Tools_Entity_Glass_Object : public virtual Tools_Entity_PhysicsObject
{
protected:
	Tools_Entity_Glass_Object(Asura_ServerEntity_Glass* pxGlassServer, Asura_ClientEntity_Glass* pxGlassClient);
	virtual ~Tools_Entity_Glass_Object();

	virtual const char* GetTypeDescription() {return s_szLongName;}

	static const char* GetNamePrefix() { return "Glass_"; }
	virtual const char* GetMyNamePrefix() const { return Tools_Entity_Glass_Object::GetNamePrefix(); }

	virtual void AddOverlayControls(Asura_Overlay* pxNewOverlay, Asura_Vector_2& pxOffset);
	virtual void PrintInfo(float& x,float& y) {}
	virtual void Edit() { EditWorldSpaceRectangle(); }

	virtual void OnSelection();
    virtual void OnDeselection();
    virtual void UpdateWhileSelected();
	virtual void UpdatePositionInAsuraData(bool);
	bool HandlesThisMessage(int messageID);

	void RenderGlass();
	virtual void Render();
	virtual Asura_String GetTextureNameForExport();

	virtual void Copy(const Tools_Object* pxObject);
	virtual Tools_Object* CreateObjectOfThisType() const;


protected:
	Tools_WorldSpaceRectangle_Object* m_pxPaneObject;
	Asura_ServerEntity_Glass* m_pxGlassServer;
	Asura_ClientEntity_Glass* m_pxGlassClient;

	Asura_RGBA m_xToolsColour;
	bool m_bUseTextureAsEnvironmentMap;
	float m_fTopLeftU;
	float m_fTopLeftV;
	float m_fBottomRightU;
	float m_fBottomRightV;

	// Test breakage data and functions.
	float m_fTestSmashForce;
	float m_fTestSmashXCoord;
	float m_fTestSmashYCoord;
	float m_fTestBlastForce;
	bool  m_bBlastPaneDirection;
	
	bool m_bIsDestructible;
	float m_fHealth;


////////////////////
// Static members //
////////////////////
public:
	static void Project_Create(const Asura_Vector_3& xCornerPosition, const Asura_Matrix_3x3& xOrientation, const Asura_Vector_2& xEdgeLengths); // Create project specific tools glass object.

// Helper function to add a new glass object in tools.
	static void CreationHelper( Asura_ServerEntity_Glass* (*pfnCreateServer)(Asura_Guid),
								Asura_ClientEntity_Glass* (*pfnCreateClient)(void),
								Tools_Object* (*pfnCreateTools)(Asura_Entity* pxEntity),
								const Asura_Vector_3& xCornerPosition, 
								const Asura_Matrix_3x3& xOrientation, 
								const Asura_Vector_2& xEdgeLengths);


protected:
	static void EditWorldSpaceRectangle();
	static void ChooseTexture();
	static void RemoveTexture();
	static bool CanRemoveTexture();
	static void DoNothing() {};

	//static class Asura_ServerEntity_Glass *GetServerEntity(Tools_Entity_Glass_Object *pxObject);
	//static class Asura_ClientEntity_Glass *GetClientEntity(Tools_Entity_Glass_Object *pxObject);

	static void SmashPaneAtPosition();
	static void BlastPane();
	static bool CanTestCurrentGlass();
		
protected:
	static Tools_Entity_Glass_Object *s_pxThisObjectForTesting;

	static const char* const s_szLongName;
	static const char* const s_szShortName;

private :

    typedef Tools_Entity_PhysicsObject PARENT;

	static Asura_Hashed_List<Tools_Entity_Glass_Object> s_xList;


};

#endif //_TOOLS_ENTITY_GLASS_OBJECT_H_
