//==========================================================================//
// File:	 EffectLibrary.hpp												//
// Project:  gosFX					                                        //
// Contents: Base Effect Component											//
//--------------------------------------------------------------------------//
// Date      Who    Modification                                            //
// 10/07/98  JMA    Created													//
//																			//
//--------------------------------------------------------------------------//
// Copyright (C) 1997-1998, Virtual World Entertainment, Inc.               //
// All Rights reserved worldwide                                            //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL              //
//==========================================================================//

#pragma once

#pragma warning(push)
#include <stlport\map>
#pragma warning(pop)

#include "gosFX.hpp"
#include "Effect.hpp"

namespace MidLevelRenderer
{
	class MLRShape;
}

namespace gosFX
{
	class DebrisCloud__Specification;

	class EffectLibrary
		#if defined(_ARMOR)
			: public Stuff::Signature
		#endif
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Initialization
	//
	public:
		static void InitializeClass();
		static void TerminateClass();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructors/Destructors
	//
	public:
		EffectLibrary(bool preload=true);
		virtual ~EffectLibrary();

		static EffectLibrary* Instance;

	protected:
		EffectLibrary(EffectLibrary &source)
			{STOP(("Shouldn't be called"));}

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// File goodies
	//
	public:
		void Load(Stuff::MemoryStream* stream);
		void Save(Stuff::MemoryStream* stream);
		void SetLength(unsigned index);
		unsigned GetLength()
			{Check_Object(this); return m_effects.GetLength();}

		Stuff::FileDependencies m_fileDependencies;
		bool m_preloadEffects;

	//----------------------------------------------------------------------------
	// Shape table
	//
	public:
		virtual MidLevelRenderer::MLRShape* UseShape(Stuff::MString& shape_file)=0;
		virtual void LoadDebrisArray(
			gosFX::DebrisCloud__Specification *spec,
			Stuff::MString& debris_file
		)=0;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Effect management
	//
	public:
		int Find(const char* name);
		Effect::Specification* Find(int id)
			{Check_Object(this); return m_effects[id];}
		Effect* MakeEffect(unsigned index, unsigned flags);

		Stuff::DynamicArrayOf<Effect::Specification*> m_effects;
		Stuff::DynamicArrayOf<Stuff::MString> m_effectNames;
		stlport::map<Stuff::MString, int> m_effectMap;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Testing
	//
	public:
		void
			TestInstance() const
				{}
	};
}
