// GUIFXGenerator.cpp: implementation of the GUIFXGenerator class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "mw4gameed2.h"
#include "GUIFXGenerator.h"
#include "ObjPanelDlg.h"
#include "FXPanel.h"
#include <MW4\EffectGenerator.hpp>

using namespace MechWarrior4;


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

GUIFXGenerator::GUIFXGenerator():EdGameObject()
{
Changeable=false;

}

bool GUIFXGenerator::IsNightOnly()
{
EffectGenerator* myfx=Cast_Object(EffectGenerator*,MyEntity);
return myfx->m_nightOnly;
}

void GUIFXGenerator::SetNightOnly(bool flag)
{
EffectGenerator* myfx=Cast_Object(EffectGenerator*,MyEntity);
myfx->m_nightOnly=flag;
}

	
bool GUIFXGenerator::IsRandom()
{
EffectGenerator* myfx=Cast_Object(EffectGenerator*,MyEntity);
return myfx->m_randomizeTime;
}

	
void GUIFXGenerator::SetRandom(bool flag)
{
EffectGenerator* myfx=Cast_Object(EffectGenerator*,MyEntity);
myfx->m_randomizeTime=flag;
}

	
Scalar GUIFXGenerator::GetDelay()
{
EffectGenerator* myfx=Cast_Object(EffectGenerator*,MyEntity);
return myfx->timeDelay;
}


void GUIFXGenerator::SetDelay(Scalar delay)
{
EffectGenerator* myfx=Cast_Object(EffectGenerator*,MyEntity);
myfx->timeDelay=delay;
}


ResourceID GUIFXGenerator::GetEffect()
{
EffectGenerator* myfx=Cast_Object(EffectGenerator*,MyEntity);
return myfx->effectResourceID;
}	

void GUIFXGenerator::SetEffect(ResourceID &rid)
{
	if(rid==ResourceID::Null) return;
EffectGenerator* myfx=Cast_Object(EffectGenerator*,MyEntity);
myfx->effectResourceID=rid;
}


void GUIFXGenerator::Copy(GUIFXGenerator &obj)
{
	EdGameObject::Copy(obj);
	SetEffect(obj.GetEffect());
 	SetDelay(obj.GetDelay());
	SetRandom(obj.IsRandom());
	SetNightOnly(obj.IsNightOnly());	
}

EdGUIObject *GUIFXGenerator::Clone()
{
	GUIFXGenerator *obj=new GUIFXGenerator;
	obj->Copy(*this);
	return obj;
}



void GUIFXGenerator::AddPanel(CObjPanelDlg *pnl,UndoCommand **cmd)
{
	EdGUIObject::AddPanel(pnl,cmd);
	pnl->AddPanel(new CFXPanel(this,cmd));
}

GUIFXGenerator::GUIFXGenerator(CString name,Point3D &pnt)
{
	BuildFrom(CString("Misc\\FXGenerator\\FXGenerator.instance"),name);
	SetPos(pnt);
}


void GUIFXGenerator::BuildDisplayInfoFromData()
{
		if(LineList) delete LineList;
		Scalar rad=5;
		LineCount=9;
		
		LineList=new GUILine[LineCount];


		LineList[0].SetLine(Point3D(-rad,-rad,-rad),
							Point3D(rad,rad,rad));
		LineList[1].SetLine(Point3D(rad,-rad,-rad),
							Point3D(-rad,rad,rad));
		LineList[2].SetLine(Point3D(-rad,rad,-rad),
							Point3D(rad,-rad,rad));
		LineList[3].SetLine(Point3D(-rad,-rad,rad),
							Point3D(rad,rad,-rad));

	
	
		LineList[4].SetLine(Point3D(rad*0.05f,rad*0.05f,rad),
							Point3D(rad*0.05f,rad*0.05f,rad*3));
		LineList[5].SetLine(Point3D(rad*0.05f,rad*0.05f,rad*3),
							Point3D(rad,rad*0.05f,rad*2));
		LineList[6].SetLine(Point3D(rad*0.05f,rad*0.05f,rad*3),
							Point3D(-rad,rad*0.05f,rad*2));
		LineList[7].SetLine(Point3D(rad*0.05f,rad*0.05f,rad*3),
							Point3D(rad*0.05f,rad,rad*2));
		LineList[8].SetLine(Point3D(rad*0.05f,rad*0.05f,rad*3),
							Point3D(rad*0.05f,-rad,rad*2));

		BuildRadius();

}

GUIFXGenerator::~GUIFXGenerator()
{
}

