
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_StateMachine_Core.cpp
// Author : Anthony Gregson
// Date   : 21/11/07
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h"

// This file's header...
#include "Core/AVP_StateMachine_Core.h"

// Asura independent header-files...

// Game independent header-files...
#include "Core/States/AVP_State_FMV.h"
#include "Core/States/Core/AVP_CoreState_Game.h"
#include "Core/States/Core/AVP_CoreState_ShuttingDown.h"
#include "Core/States/Core/AVP_CoreState_Void.h"

#if defined(ASURA_TOOLS)
#include "Core/States/Core/AVP_CoreState_LoadingTools.h"
#include "Core/States/Core/AVP_CoreState_Tools.h"
#endif	// defined(ASURA_TOOLS)

#if defined(AVP_USE_DEVELOPMENT_FRONT_END)
#include "Core/States/Core/AVP_CoreState_DevelopmentFrontend.h"
#endif	// defined(AVP_USE_DEVELOPMENT_FRONT_END)

#if defined(AVP_USE_GAME_FRONTEND)
#include "Core/States/Core/AVP_CoreState_GameFrontend.h"
#endif	//defined(AVP_USE_GAME_FRONTEND)

#include "Debugging/Asura_Assert.h"


////////////////////////////////////////////////////////////////////////////////
// Constant declarations...
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Static variable declarations...
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Private functions...
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Protected functions...
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Public functions...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Function	: AVP_StateMachine_Core::AVP_StateMachine_Core
// Author	: Anthony Gregson
// Date		: 21/11/07
////////////////////////////////////////////////////////////////////////////////

AVP_StateMachine_Core::AVP_StateMachine_Core(void)
: AVP_StateMachine(AVP_StateMachine_Core::MAX_STATES)
{
	RegisterState(STATE_VOID, new AVP_CoreState_Void(*this));
#if defined(ASURA_TOOLS)
	RegisterState(STATE_LOADINGTOOLS, new AVP_CoreState_LoadingTools(*this));
	RegisterState(STATE_TOOLS, new AVP_CoreState_Tools(*this));
#endif	// defined(ASURA_TOOLS)
#if defined(AVP_USE_DEVELOPMENT_FRONT_END)
	RegisterState(STATE_DEVELOPMENTFRONTEND, new AVP_CoreState_DevelopmentFrontend(*this));
#endif	// defined(AVP_USE_DEVELOPMENT_FRONT_END)

#if defined(AVP_USE_GAME_FRONTEND)
	//	Register single Frontend State
	RegisterState(STATE_FOX_FMV, new AVP_State_FMV("Fox FMV", "Fox", STATE_SEGA_FMV, *this));
	RegisterState(STATE_SEGA_FMV, new AVP_State_FMV("Sega FMV", "Sega", STATE_REBELLION_FMV, *this));
	RegisterState(STATE_REBELLION_FMV, new AVP_State_FMV("Rebellion FMV", "Rebellion", STATE_GAMEFRONTEND, *this));
	RegisterState(STATE_GAMEFRONTEND, new AVP_CoreState_GameFrontend(*this));
#endif	//defined(AVP_USE_GAME_FRONTEND)

	RegisterState(STATE_GAME, new AVP_CoreState_Game(*this));
	RegisterState(STATE_SHUTTINGDOWN, new AVP_CoreState_ShuttingDown(*this));
}

/// End of function 'AVP_StateMachine_Core::AVP_StateMachine_Core'. ///


void AVP_StateMachine_Core::Initialise()
{
	Asura_Assert(m_uCurrentState == STATE_VOID, "Re-initialising core state machine. Was this expected?");
}

void AVP_StateMachine_Core::Shutdown()
{
	Asura_Assert(m_uCurrentState == STATE_SHUTTINGDOWN, "Should only shutdown the core state machine once the application is quit.");
	// Intentionally not resetting the current state, as we expect this state machine to run as long as the game is running.
}

void AVP_StateMachine_Core::RequestQuitApplication()
{
	AVP_State_Core* pxCurrentState = static_cast<AVP_State_Core*>(GetCurrentStateObject());
	if (pxCurrentState)
	{
		pxCurrentState->RequestQuitApplication();
	}
}

/// End of file. ///
