#pragma once
#define MLR_MLRSHADOWLIGHT_HPP

#include "MLR.hpp"
#include "MLRInfiniteLightWithFalloff.hpp"

namespace MidLevelRenderer {

	//##########################################################################
	//######################    MLRShadowLight    #############################
	//##########################################################################

	class MLRShadowLight:
		public MLRInfiniteLightWithFalloff
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		MLRShadowLight();
		MLRShadowLight(
			Stuff::MemoryStream *stream,
			int version
		);
		MLRShadowLight(Stuff::Page *page);
		~MLRShadowLight();

		void
			Save(Stuff::MemoryStream *stream);
		void
			Write(Stuff::Page *page);

		virtual LightType
			GetLightType() 
				{ Check_Object(this); return ShadowLight; }

		virtual void
			LightVertex(const MLRVertexData&)
				{ Check_Object(this); }
		virtual void
			LightCenter(RGBAColor&)
				{ Check_Object(this); }

		void
			SetLightMap(MLRLightMap *light_map);

// MSL 5.02 Shadow
		MLRLightMap *
			GetLightMap()
		{ Check_Object(this); return showShadow ? lightMap : NULL; }

		const MLRTexture*
			GetShadowTexture()
				{ Check_Object(this); return shadowTexture; }

		void
			SeeDetailShadow(bool b=true);

		void
			SetBlobDistance(Stuff::Scalar d)
				{ Check_Object(this); blobDistance = d; }

		Stuff::Scalar
			GetBlobDistance()
				{ Check_Object(this); return blobDistance; }

// MSL 5.02 Shadow
//		
// 	Needed a way to clip out a shadow when it is out of range.
//  Out of range is when it is past the fogend setting of the current mission.
//
		void 
			ShowShadow(bool fShow)
				{ Check_Object(this); showShadow = fShow;}

		bool 
			GetShowShadow()
				{ Check_Object(this); return showShadow;}
		

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Class Data Support
	//
	public:
		static ClassData
			*DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Testing
	//
	public:
		void
			TestInstance();

	protected:
		MLRLightMap
			*lightMap;

		MLRTexture
			*shadowTexture;
		
		unsigned
			blobTextureHandle;

		bool
			detailShadow;

		Stuff::Scalar
			blobDistance;
// MSL 5.02 Shadow
		bool
			showShadow;
	};

}
