
/**
*
* \file Asura_Botanicals_TemplateManager.h
*
* Created by Dave Reed - 08/11/2005
*
* Copyright (C) 2005 Rebellion (Derby), All Rights Reserved.
*
**/

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifdef ASURA_USE_BOTANICALS

#ifndef __Asura_Botanicals_TemplateManager_H__
#define __Asura_Botanicals_TemplateManager_H__

#ifdef ASURA_TOOLS

#include "Core/Asura_String.h"
#include "Core/Asura_Hash.h"

#include "Botanicals/Asura_Botanicals_ShapeManager.h"


typedef enum ASURA_BOTANICALS_TEMPLATE_TYPE
{
	ASURA_BOTANICALS_TEMPLATE_BOTANICALSHAPE=0,	// BotanicalShape - with LOD
	ASURA_BOTANICALS_TEMPLATE_SHAPE=1,			// Standard shape *Tools/testing only*
	NUM_ASURA_BOTANICALS_TEMPLATE_TYPES
};


struct Asura_Botanicals_ModelTemplateData
{		
	Asura_Hash_ID uShapeID;
};


struct Asura_Botanicals_Template
{
	// Data shared between all template types
	ASURA_BOTANICALS_TEMPLATE_TYPE  eType;

	// These should all be made #ifdef ASURA_TOOLS?
	Asura_String				  xTemplateName;	
	Asura_String				  xShapeName;
	Asura_String				  xSelectionShapeName;	
    
	// Template IDs are used for remapping instances when the template list
	// has been changed, invalidating the template indices stored in the 
	// instance.
	int							  iUID;
		
	// If it's a standard shape we have one of these
	Asura_Hash_ID				  uShapeID;
	// Else we have one of these
	Asura_BotanicalShape		 *pxBotanicalShape;

	// This is the shape used for selection in placement mode
	Asura_Hash_ID				  uSelectionShapeID;

	// Beyond this point are parameters used by the tool (for all instance types)
	bool                          bVisible;
	bool                          bLocked;
	bool                          bMergeRenderMeshWithEnv;
	bool                          bMergeCollisionMeshWithEnv;
	bool                          bPermanentlyMergeMesh;

	// Collision radius used by the placement tool only
	float                         fCollisionHeight;			
	float						  fCollisionRadius;

	// Placement parameters - Control the scale/rotation randomization
	float						  fMinYRotation;
	float                         fMaxYRotation;
	float						  fMinScale;
	float						  fMaxScale;

};



class Asura_Botanicals_TemplateManager
{	
	friend class Asura_Chunk_Botanicals_Templates;

public:
	static void						 Initialise();			// Load templates from botatmps.asr
	static void						 Shutdown();
    static void						 Reset(); 		
	static bool						 Save(char* szTemplatesFileName, char* szStylesFileName);												
    static void						 LoadResources();		// Load the shapes referenced by the templates

	static void						 AllocateTemplates(int iNumTemplates); 

	static int						 GetNumTemplates(void);
	static Asura_Botanicals_Template*GetTemplate(int iIdx);	
	static char						*GetTemplateName(int iIdx);
	static void						 SetTemplateName(Asura_Botanicals_Template* pTemplate,char* szName);	
	static int						 GetTemplateIndexFromUID(int iUID);

	// Tools-only functions to manipulate the template list. In game builds, 
	// this should be loaded as one block of data and not modified
	static int						 CreateTemplate(ASURA_BOTANICALS_TEMPLATE_TYPE eType);
	static void						 RemoveTemplate(int iIdx);		
	static void						 ToggleTemplateVisible(int iIdx);
	static bool						 GetTemplateVisible(int iIdx);

private:
	static int						 s_iNextUID;
	static int						 s_iNumTemplates;
	static Asura_Botanicals_Template*s_pxTemplates;
};


#endif // #ifdef ASURA_TOOLS

#endif // __Asura_Botanicals_TemplateManager_H__

#endif //ASURA_USE_BOTANICALS
