
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_PlayingState_GameOver.cpp
// Author : Anthony Gregson
// Date   : 03/12/07
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#include "Core/Asura.h"

// This file's header...
#include "Core/States/Playing/AVP_PlayingState_GameOver.h"

// Asura independent header-files...
#include "GUIMenu/Asura_GUIMenu_System.h"
#include "Rewards/Asura_Rewards_System.h"


// Game independent header-files...
#include "Core/AVP_Game_Core.h"
#include "Core/AVP_GameStatus.h"
#include "Core/AVP_Settings.h"
#include "GUIMenu/AVP_GUIMenu_System.h"
#include "Multiplayer/AVP_Multiplayer_GameRules.h"
#include "Multiplayer/AVP_Multiplayer_ScoreBoard.h"
#include "Rewards/AVP_Rewards_System.h"


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


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


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


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


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

////////////////////////////////////////////////////////////////////////////////
// Function	: AVP_PlayingState_GameOver::Enter
// Author	: Anthony Gregson
// Date		: 03/12/07
////////////////////////////////////////////////////////////////////////////////

void AVP_PlayingState_GameOver::Enter(const u_int uPreviousState)
{
#ifdef ASURA_USE_GUI_MENU_SYSTEM
	// These menu screens are just what we originally had, I'm sure this will change substantially once we have a full set of post-game menus (and, of course, a proper set of game ending reasons)

	if (Asura_GUIMenu_System::IsMenuPageHashActive(AVP_GUIMenu_System::GetMenuHash(AVP_GUIMenu_System::GUIMENU_ID_HUD)))
	{
		AVP_GUIMenu_System::Deactivate( AVP_GUIMenu_System::GUIMENU_ID_HUD );
	}

	if (Asura_GUIMenu_System::IsMenuPageHashActive(AVP_GUIMenu_System::GetMenuHash(AVP_GUIMenu_System::GUIMENU_ID_WEAPONSELECTOR)))
	{
		AVP_GUIMenu_System::Deactivate( AVP_GUIMenu_System::GUIMENU_ID_WEAPONSELECTOR );
	}

	if (AVP_GameStatus::GetGameOver())
	{
		if ( AVP_Settings::IsSinglePlayer() )
		{
			// Only machine
			AVP_GUIMenu_System::Activate(AVP_GUIMenu_System::GUIMENU_ID_GAMEOVER);
		}
		else
		{
			// Server OR Client in multiplayer
			AVP_Multiplayer_ScoreBoard::ActivateResultsTables();
		}
	}
	else if (AVP_GameStatus::GetLevelComplete())
	{
		AVP_GUIMenu_System::Activate(AVP_GUIMenu_System::GUIMENU_ID_MISSIONCOMPLETE);
#ifdef ASURA_USE_REWARDS
		Asura_Rewards_System::HandleEvent(uAVP_EVENT_LEVEL_COMPLETE, 0);// NY - 02 April 2009 - level number to go here
#endif // #ifdef ASURA_USE_REWARDS
	}
	else
	{
		Asura_Assert(false, "Unexpected game over reason");
		AVP_GUIMenu_System::Activate(AVP_GUIMenu_System::GUIMENU_ID_GAMEOVER);
	}
#endif //#ifdef ASURA_USE_GUI_MENU_SYSTEM

	AVP_Game_Core::SetPausedFSFX(true);

	AVP_Game_Core::SetupPausedDSP( true );
}

/// End of function 'AVP_PlayingState_GameOver::Enter'. ///



////////////////////////////////////////////////////////////////////////////////
// Function	: AVP_PlayingState_GameOver::Update
// Author	: Anthony Gregson
// Date		: 03/12/07
////////////////////////////////////////////////////////////////////////////////

void AVP_PlayingState_GameOver::Update()
{
	// TODO - Effectively we're just waiting for menus to finish or for word from the server to carry on, but there may still be some things that need updating here (timeouts for the server to continue automatically, for instance).
}

/// End of function 'AVP_PlayingState_GameOver::Update'. ///


////////////////////////////////////////////////////////////////////////////////
// Function	: AVP_PlayingState_GameOver::Render
// Author	: Anthony Gregson
// Date		: 03/12/07
////////////////////////////////////////////////////////////////////////////////

void AVP_PlayingState_GameOver::Render() const
{
	// TODO - If the game over needs to render anything that isn't in the HUD or menu code already, it'll go here. Not sure if that'll ever be the case though.
}

/// End of function 'AVP_PlayingState_GameOver::Update'. ///


/// End of file. ///
