#include "../Gaia/RuGaia_Base.h"

#pragma unmanaged

// ************************************************************************************************************************************************************

ruRTTI_DEFINE_SUBCLASS(CRuGaia_Base, IRuCollisionHierarchy)
ruHEAP_DEFINE_SUBCLASS(CRuGaia_Base, "CRuGaia_Base", "IRuCollisionHierarchy")
ruCLASSGUID_DEFINE(CRuGaia_Base, 0xA0B62428, 0x87C1448f, 0x9EEE166F, 0x12313C68)

// ************************************************************************************************************************************************************

void CRuGaia_ZoneDescriptor::CopySettings(const CRuGaia_ZoneDescriptor &zoneDesc)
{
	delete[] m_skyGradientTextureName;
	m_skyGradientTextureName = NULL;

	delete[] m_horizonCloudTextureName;
	m_horizonCloudTextureName = NULL;

	delete[] m_overheadCloudTextureName;
	m_overheadCloudTextureName = NULL;

	m_color_Primary = zoneDesc.m_color_Primary;
	m_color_Secondary = zoneDesc.m_color_Secondary;
	m_color_Ambient = zoneDesc.m_color_Ambient;
	m_color_Specular = zoneDesc.m_color_Specular;
	m_color_Fog = zoneDesc.m_color_Fog;

	m_fog_Start = zoneDesc.m_fog_Start;
	m_fog_End = zoneDesc.m_fog_End;

	m_theta_Standard = zoneDesc.m_theta_Standard;
	m_phi_Standard = zoneDesc.m_phi_Standard;

	m_theta_Specular = zoneDesc.m_theta_Specular;
	m_phi_Specular = zoneDesc.m_phi_Specular;

	m_cloud_HorizonColor = zoneDesc.m_cloud_HorizonColor;
	m_cloud_OverheadColor = zoneDesc.m_cloud_OverheadColor;
	m_cloud_HorizonCount = zoneDesc.m_cloud_HorizonCount;
	m_cloud_OverheadCount = zoneDesc.m_cloud_OverheadCount;

	if(zoneDesc.m_skyGradientTextureName)
	{
		INT32 len = strlen(zoneDesc.m_skyGradientTextureName);
		m_skyGradientTextureName = ruNEW char [len + 1];
		memcpy(m_skyGradientTextureName, zoneDesc.m_skyGradientTextureName, sizeof(char) * (len + 1));
	}

	if(zoneDesc.m_horizonCloudTextureName)
	{
		INT32 len = strlen(zoneDesc.m_horizonCloudTextureName);
		m_horizonCloudTextureName = ruNEW char [len + 1];
		memcpy(m_horizonCloudTextureName, zoneDesc.m_horizonCloudTextureName, sizeof(char) * (len + 1));
	}

	if(zoneDesc.m_overheadCloudTextureName)
	{
		INT32 len = strlen(zoneDesc.m_overheadCloudTextureName);
		m_overheadCloudTextureName = ruNEW char [len + 1];
		memcpy(m_overheadCloudTextureName, zoneDesc.m_overheadCloudTextureName, sizeof(char) * (len + 1));
	}

	if(zoneDesc.m_customSkyBoxName)
	{
		INT32 len = strlen(zoneDesc.m_customSkyBoxName);
		m_customSkyBoxName = ruNEW char [len + 1];
		memcpy(m_customSkyBoxName, zoneDesc.m_customSkyBoxName, sizeof(char) * (len + 1));
	}

	m_frameRateMultiplier = zoneDesc.m_frameRateMultiplier;

	m_cloudMode = zoneDesc.m_cloudMode;
}

CRuGaia_ZoneDescriptor &CRuGaia_ZoneDescriptor::operator=(const CRuGaia_ZoneDescriptor &zoneDesc)
{
	delete[] m_name;
	m_name = NULL;

	m_id = zoneDesc.m_id;
	m_timeGroup = zoneDesc.m_timeGroup;
	m_weatherGroup = zoneDesc.m_weatherGroup;
	
	if(zoneDesc.m_name)
	{
		INT32 len = strlen(zoneDesc.m_name);
		m_name = ruNEW char [len + 1];
		memcpy(m_name, zoneDesc.m_name, sizeof(char) * (len + 1));
	}

	CopySettings(zoneDesc);

	return *this;
}

// ************************************************************************************************************************************************************

CRuGaia_Base::~CRuGaia_Base()
{
}

// ************************************************************************************************************************************************************

#pragma managed
