//==========================================================================//
// File:	 gosFX_EffectCloud.hpp											//
// Project:  gosFX					                                        //
// Contents: EffectCloud Component											//
//--------------------------------------------------------------------------//
// Date      Who    Modification                                            //
// 09/28/98  JTR    Created													//
//																			//
//--------------------------------------------------------------------------//
// Copyright (C) 1997-1998, Virtual World Entertainment, Inc.               //
// All Rights reserved worldwide                                            //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL              //
//==========================================================================//
//
#pragma once

#include "gosFX.hpp"
#include "SpinningCloud.hpp"

namespace gosFX
{
	//############################################################################
	//########################  EffectCloud__Specification  #############################
	//############################################################################

	class EffectCloud__Specification:
		public SpinningCloud__Specification
	{
	//----------------------------------------------------------------------
	// Constructors/Destructors
	//
	protected:
		EffectCloud__Specification(
			Stuff::MemoryStream *stream,
			int gfx_version
		);

	public:
		typedef SpinningCloud__Specification BaseClass;

		EffectCloud__Specification();
		~EffectCloud__Specification();

		static EffectCloud__Specification*
			Make(
				Stuff::MemoryStream *stream,
				int gfx_version
			);

		void
			Copy(EffectCloud__Specification *spec);

		void
			Save(Stuff::MemoryStream *stream);

		unsigned
			m_particleEffectID;
	};

	//############################################################################
	//########################  SpinningCloud__Particle  #############################
	//############################################################################

	class EffectCloud__Particle:
		public SpinningCloud__Particle
	{
	public:
		typedef SpinningCloud__Particle BaseClass;

		Effect
			*m_effect;
	};

	//############################################################################
	//#############################  EffectCloud  #################################
	//############################################################################

	class EffectCloud:
		public SpinningCloud
	{
	//----------------------------------------------------------------------------
	// Class Registration Support
	//
	public:
		typedef SpinningCloud BaseClass;

		static void InitializeClass();
		static void	TerminateClass();

		typedef EffectCloud__Specification Specification;
		typedef EffectCloud__Particle Particle;

		enum {
			ParticleSize = sizeof(Particle)
		};

	//----------------------------------------------------------------------------
	// Class Data Support
	//
	protected:
		EffectCloud(
			Specification *spec,
			unsigned flags
		);

	public:
		~EffectCloud();

		static EffectCloud*
			Make(
				Specification *spec,
				unsigned flags
			);

		Specification*
			GetSpecification()
				{
					Check_Object(this);
					return
						Cast_Object(Specification*, m_specification);
				}
		Particle*
			GetParticle(unsigned index)
				{
					Check_Object(this); Check_Object(GetSpecification());
					return
						Cast_Pointer(
							Particle*,
							&m_data[index*GetSpecification()->m_particleClassSize]
						);
				}

		static ClassData
			*DefaultData;

	//----------------------------------------------------------------------------
	// Testing
	//
	public:
		void
			TestInstance() const;

	//----------------------------------------------------------------------------
	// API
	//
	protected:
		bool
			AnimateParticle(
				unsigned index,
				const Stuff::LinearMatrix4D *world_to_new_local,
				Stuff::Time till
			);
		void
			CreateNewParticle(
				unsigned index,
				Stuff::Point3D *translation
			);
		void
			DestroyParticle(unsigned index);

	public:
		void
			Stop();
		void
			Draw(DrawInfo *info);
	};
}
