#include "AdeptHeaders.hpp"
#include "VideoHeaders.hpp"
#include "Tool.hpp"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
ConeComponent::ClassData*
	ConeComponent::CreateFactoryRequest(FactoryRequestParameters *parameters)
{
	Check_Object(parameters);

	//
	//-------------------------------------------------------------------------
	// Allocate enough room for what we need to write out, then call our parent
	//-------------------------------------------------------------------------
	//
	MemoryStream *component_stream = parameters->m_stream;
	Check_Object(component_stream);
	component_stream->AllocateBytes(sizeof(ConeComponent));
	Check_Object(Resource::ParentFileDependencies);

	//
	//----------------------------
	// Let our parent do its thing
	//----------------------------
	//
	bool result = BaseClass::CreateFactoryRequest(parameters) != NULL;

	Page *page = parameters->m_page;
	Check_Object(page);

	Scalar length;
	page->GetEntry("Length", &length, true);
	*component_stream << length;

	Scalar start_falloff;
	page->GetEntry("StartFalloff", &start_falloff, true);
	*component_stream << start_falloff;

	Scalar end_falloff;
	page->GetEntry("EndFalloff", &end_falloff, true);
	*component_stream << end_falloff;

	Scalar angle;
	page->GetEntry("Angle", &angle, true);
	*component_stream << angle;
	
	RGBAColor color;
	page->GetEntry("StartColor", &color, true);
	*component_stream << color;

	RGBAColor color2;
	page->GetEntry("EndColor", &color2, true);
	*component_stream << color2;

	Check_Object(DefaultData);
	return (result) ? DefaultData : NULL;
}

