
///////////////////////////////////////////////////////////////////////////////
//
// File   : Asura_FacialAnimation_System.h
// Author : Andy Tate
// Date   : 8-May-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __ASURA_FACIALANIMATION_SYSTEM_H__
#define __ASURA_FACIALANIMATION_SYSTEM_H__

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Core/Asura_HashTree.h"
#include "FacialAnimation/Asura_FacialAnimation_AnimationHandler.h"
#include "FacialAnimation/Asura_FacialAnimation_Face.h"
#include "FacialAnimation/Asura_FacialAnimation_FaceAnimation.h"


////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Class        : Asura_FacialAnimation_System
// Author       : Andy Tate
// Date         : 8-May-2008
//
// Description  : Class used to control both storage and updating of facial
//				  animation data.
////////////////////////////////////////////////////////////////////////////////

class Asura_FacialAnimation_System
{
public:
	// Public functions...
	static void	Initialise(void);
	static void Reset(void);
	static void	Shutdown(void);

	static void	Update(void);

	// Face functions...
	static Asura_FacialAnimation_Face*	CreateFace(const Asura_Hash_ID uHash)								{ return(s_xFaceContainer.AddNode(uHash)); }
	static Asura_FacialAnimation_Face*	CreateFace(const Asura_Hash_ID uHash, Asura_Chunk_Stream& xStream)	{ return(s_xFaceContainer.AddNode(uHash, xStream)); }
	static bool							DestroyFace(const Asura_Hash_ID uHash)								{ return(s_xFaceContainer.DeleteNodeByHash(uHash)); }
	static Asura_FacialAnimation_Face*	FindFace(const Asura_Hash_ID uHash)									{ return(s_xFaceContainer.GetDataByHash(uHash)); }

	// Face-animation functions...
	static Asura_FacialAnimation_FaceAnimation*	CreateFaceAnimation(const Asura_Hash_ID uHash)								{ return(s_xFaceAnimationContainer.AddNode(uHash)); }
	static Asura_FacialAnimation_FaceAnimation*	CreateFaceAnimation(const Asura_Hash_ID uHash, Asura_Chunk_Stream& xStream)	{ return(s_xFaceAnimationContainer.AddNode(uHash, xStream)); }
	static bool									DestroyFaceAnimation(const Asura_Hash_ID uHash)								{ return(s_xFaceAnimationContainer.DeleteNodeByHash(uHash)); }
	static Asura_FacialAnimation_FaceAnimation*	FindFaceAnimation(const Asura_Hash_ID uHash)								{ return(s_xFaceAnimationContainer.GetDataByHash(uHash)); }

	// Animation-handler functions...
	static bool	AddAnimationHandler(const Asura_Guid uGuid, Asura_FacialAnimation_AnimationHandler* pxHandler);
	static bool	RemoveAnimationHandler(const Asura_Guid uGuid);

	static Asura_FacialAnimation_AnimationHandler*	FindAnimationHandler(const Asura_Guid uGuid)	{ Asura_FacialAnimation_AnimationHandler** ppxAnimationHandler = s_xAnimationHandlerContainer.GetDataByHash(uGuid); return((ppxAnimationHandler == NULL) ? NULL : *ppxAnimationHandler); }


protected:
	// Protected variables...

	// Protected functions...


private:
	// Private typedefs...
	typedef Asura_TemplateHashTree<Asura_FacialAnimation_Face> FaceContainer;
	typedef Asura_TemplateHashTree<Asura_FacialAnimation_FaceAnimation> FaceAnimationContainer;

	typedef Asura_TemplateHashTree<Asura_FacialAnimation_AnimationHandler*> AnimationHandlerContainer;
	typedef Asura_TemplateHashTree_Iterator<Asura_FacialAnimation_AnimationHandler*> AnimationHandlerIterator;
	typedef Asura_TemplateHashTree_ConstIterator<Asura_FacialAnimation_AnimationHandler*> AnimationHandlerConstIterator;

	// Private variables...
	static FaceContainer				s_xFaceContainer;				// Storage for all of the faces we have.
	static FaceAnimationContainer		s_xFaceAnimationContainer;		// Storage for all of the animations to use for faces.
	static AnimationHandlerContainer	s_xAnimationHandlerContainer;	// Storage for all of the animation-handlers for entities current;y using facial-animation data.

	// Private functions...
	Asura_FacialAnimation_System(void);
	Asura_FacialAnimation_System(const Asura_FacialAnimation_System& xOther);
	~Asura_FacialAnimation_System();

	Asura_FacialAnimation_System&	operator=(const Asura_FacialAnimation_System& xOther);

};   // End of class 'Asura_FacialAnimation_System'.

#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

#endif   // ifndef __ASURA_FACIALANIMATION_SYSTEM_H__


/// End of file. ///
