//===========================================================================//
// File:        ElevationMap.cpp                                        
// Project: MechWarrior4    					                             //
// Contents: Implementation details of static entity class                   //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 12/21/98  JSE  Initial coding.                                            //
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Fasa Interactive										 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#include "MW4Headers.hpp"

#if !defined(ADEPT_ENTITYMANAGER_HPP)
	#include "Adept\EntityManager.hpp"
#endif

#define ELEVATIONMAP_VERSION 0

//#############################################################################
//###############################    ElevationMap    ##########################
//#############################################################################

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
ElevationMap::ClassData*
	ElevationMap::DefaultData = NULL;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	ElevationMap::InitializeClass()
{
	Check_Object(PreCollisionStateEngine::DefaultData);
	Check_Object(PostCollisionStateEngine::DefaultData);
	Verify(!DefaultData);
	DefaultData =
		new ClassData(
			ElevationMapClassID,
			"MechWarrior4::ElevationMap",
			Entity::DefaultData,
			0, NULL,
			(Entity::Factory)Make,
			(Entity::ToolFactory)ToolMake,
			ELEVATIONMAP_VERSION,
			PreCollisionStateEngine::DefaultData,
			PostCollisionStateEngine::DefaultData,
			CreateGameModel
		);
	Register_Object(DefaultData);

}

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

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
ElevationMap*
	ElevationMap::Make(
		MemoryStream *stream,
		CreationParameters *creation_parameters
	)
{
	Check_Object(stream);
	ElevationMap *new_entity;
	Entity__Make(&new_entity, DefaultData, stream, creation_parameters);
	return new_entity;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	ElevationMap::Save(MemoryStream *stream)
{
	Check_Object(this);
	Check_Object(stream);

	Entity::Save(stream);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
ElevationMap::ElevationMap(
	ClassData *class_data,
	MemoryStream *stream,
	CreationParameters *creation_parameters
):
	Entity(class_data, stream, creation_parameters)
{
	Check_Pointer(this);
	Check_Object(stream);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	ElevationMap::Reuse(
		MemoryStream *stream,
		CreationParameters *creation_parameters
	)
{
	Entity::Reuse(stream, creation_parameters);
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	ElevationMap::PreCollisionExecute(const SimulationTime& till)
{

	STOP(("ElevationMap::PreCollisionExecute should never be called"));

#if 0

	Check_Object(this);
	Check_Object(&till);

	Entity::PreCollisionExecute(till);
	//
	//---------------------------------
	// If we aren't executing, stop now
	//---------------------------------
	//
	Check_Object(preCollisionState);
	int pre_state = preCollisionState->GetState();
	Verify(pre_state != PreCollisionStateEngine::NeverExecuteState);

	//
	//---------------------------------------------------
	// If the state is just AlwaysExecute, just sit there
	//---------------------------------------------------
	//
	if (pre_state == PreCollisionStateEngine::AlwaysExecuteState)
	{
		return;
	}
#endif

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	ElevationMap::PostCollisionExecute(const SimulationTime& till)
{
	

	STOP(("ElevationMap::PostCollisionExecute should never be called"));

#if 0
	Check_Object(this);
	Check_Object(&till);

	//
	//------------------------------
	// Handle the never execute case
	//------------------------------
	//
	Check_Object(postCollisionState);
	#ifdef _DEBUG
		int post_state = postCollisionState->GetState();
		Verify(post_state != PostCollisionStateEngine::NeverExecuteState);
	#endif
	Entity::PostCollisionExecute(till);
#endif

}

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