#include "MW4Headers.hpp"

// Created 3/15/2002 by ASH&ACS - IFF Jammer

#include "IFF_Jammer.hpp"
#include "Mech.hpp"
#include "SubsystemClassData.hpp"



//#############################################################################
//############################    JIFFY    ###########################
//#############################################################################

IFF_Jammer::ClassData*
	IFF_Jammer::DefaultData = NULL;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	IFF_Jammer::InitializeClass()
{
	Verify(!DefaultData);
	DefaultData =
		new ClassData(
			IFF_JammerClassID,
			"MechWarrior4::IFF_Jammer",
			Subsystem::DefaultData,
			0, NULL,
			(Entity::Factory)Make,
			(Entity::CreateMessage::Factory)CreateMessage::ConstructCreateMessage,
			ExecutionStateEngine::DefaultData,
			(Entity::GameModel::Factory)GameModel::ConstructGameModel,
			NULL,
			(Entity::GameModel::ReadAndVerifier)GameModel::ReadAndVerify,
			(Entity::GameModel::ModelWrite)GameModel::WriteToText,
			(Entity::GameModel::ModelSave)GameModel::SaveGameModel,
			(Subsystem::StreamCreate)CreateStream
		);
	Register_Object(DefaultData);

	DIRECT_GAME_MODEL_ATTRIBUTE(
		IFF_Jammer__GameModel,
		TargeterMissileLockPercent,
		m_targeterMissileLockPercent,
		Scalar
	);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	IFF_Jammer::TerminateClass()
{
	Unregister_Object(DefaultData);
	delete DefaultData;
	DefaultData = NULL;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
IFF_Jammer*
	IFF_Jammer::Make(
		CreateMessage *message,
		ReplicatorID *base_id
	)
{
	Check_Object(message);
	gos_PushCurrentHeap(Heap);
	IFF_Jammer *new_entity = 
		new IFF_Jammer(DefaultData, message, base_id, NULL);
	gos_PopCurrentHeap();
	Check_Object(new_entity);
	return new_entity;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
IFF_Jammer::IFF_Jammer(
	ClassData *class_data,
	CreateMessage *message,
	ReplicatorID *base_id,
	ElementRenderer::Element *element
):
	Subsystem(class_data, message, base_id, element)
{
	Check_Object(message);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
IFF_Jammer::~IFF_Jammer()
{
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	IFF_Jammer::DestroySubsystem()
{
	Check_Object(this);
	
	MWObject *mw_object = GetParentVehicle();
	Check_Object(mw_object);
	Verify(mw_object->IsDerivedFrom(Mech::DefaultData));
	Mech *mech = Cast_Object(Mech *, mw_object);
	mech->DestroyIFF_Jammer();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	IFF_Jammer::TestInstance() const
{
	Verify(IsDerivedFrom(DefaultData));
}
