/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


		#include "scene3d/mtrigger.h"
		#include "log/log.h"

		using namespace GS::S3D;
		using namespace GS::NML;


//------------------------------------------------------------------------------
bool				MTrigger::FromMetaTag(Tag &tag)
{
	if	((tag.name != "Trigger") && (tag.name != "MTrigger"))
		__ERR__(__LOG_E__ << "Could not parse trigger, incorrect root tag (" << tag.name << ").\n", false)

	// Parse root tags.
	NMLTagForeach(pt, tag)
	{
				if	(pt->name == "MItem")
				MItem::FromMetaTag(*pt);
		else	if	(pt->name == "Item")
				((Item *)this)->FromMetaTag(*pt);

		else	__LOG_W__ << "Unknown tag '" << pt->name << "' in <Trigger>.\n";
	}
	return true;
}
Tag					*MTrigger::AsMetaTag()
{
	Tag *root = new Tag("MTrigger");
	if	(!root)
		__ERR__(__LOG_E__ << "Could not create root tag to serialize.\n", NULL)

	root->AddChild(MItem::AsMetaTag());
	root->AddChild(((Item *)this)->AsMetaTag());
	return root;
}
//------------------------------------------------------------------------------
