
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_ConnectionState_BeginGameInitialisation.h
// Author : Andy Tate
// Date   : 25-Feb-2009
//
// Copyright (C) 2009 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __AVP_CONNECTIONSTATE_BEGINGAMEINITIALISATION_H__
#define __AVP_CONNECTIONSTATE_BEGINGAMEINITIALISATION_H__

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

#include "Core/States/Connection/AVP_State_Connection.h"


////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////

class AVP_Connection;


////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_ConnectionState_BeginGameInitialisation
// Author       : Andy Tate
// Date         : 25-Feb-2009
//
// Description  : Class used to handle the beginning part of game initialisation.
////////////////////////////////////////////////////////////////////////////////

class AVP_ConnectionState_BeginGameInitialisation : public AVP_State_Connection
{
public:
	// Public functions...
	AVP_ConnectionState_BeginGameInitialisation(AVP_Connection& xParentMachine) : PARENT(xParentMachine)	{}
	//virtual ~AVP_ConnectionState_BeginGameInitialisation();

	// Overridden functions...
	virtual	void 		Enter(const u_int uPreviousState);
	virtual	void 		Update(void);
	virtual	void 		Render(void) const;
	virtual	void 		Exit(const u_int uNextState);

	virtual	const char*	GetName(void) const	{ return("Begin game initialisation"); }


protected:
	// Protected variables...

	// Protected functions...


private:
	// Private typedefs...
	typedef AVP_State_Connection PARENT;

	// Private variables...
	float 					m_fRequestActorCreateDelay;
	float 					m_fEnterGameDelay;
	float 					m_fEnterGameTimeOut;

	static const char*		s_szInitialisationName;

	static volatile bool	s_bInitialisationComplete;

	// Private functions...
	AVP_ConnectionState_BeginGameInitialisation(void);
	AVP_ConnectionState_BeginGameInitialisation(const AVP_ConnectionState_BeginGameInitialisation& xOther);

	AVP_ConnectionState_BeginGameInitialisation&	operator=(const AVP_ConnectionState_BeginGameInitialisation& xOther);

	void	CompleteInitialisation(void);

	void	PerformSinglePlayerInitialisation(void);
	void	PerformSinglePlayerCheckpointLoad(void);
	void	PerformSinglePlayerCheckpointRestart(void);
	void	PerformSinglePlayerLevelRestart(void);

	void	PerformMultiplayerInitialisation(void);
	void	PerformMultiplayerClientRestart(void);
	void	PerformMultiplayerServerRestart(void);

	static void PerformSinglePlayerInitialisation(const void* pUserData)
	{
		const AVP_ConnectionState_BeginGameInitialisation*	pxConstThis	= static_cast<const AVP_ConnectionState_BeginGameInitialisation*>(pUserData);
		AVP_ConnectionState_BeginGameInitialisation*		pxThis		= const_cast<AVP_ConnectionState_BeginGameInitialisation*>(pxConstThis);

		pxThis->PerformSinglePlayerInitialisation();
	}

	static void PerformSinglePlayerCheckpointLoad(const void* pUserData)
	{
		const AVP_ConnectionState_BeginGameInitialisation*	pxConstThis	= static_cast<const AVP_ConnectionState_BeginGameInitialisation*>(pUserData);
		AVP_ConnectionState_BeginGameInitialisation*		pxThis		= const_cast<AVP_ConnectionState_BeginGameInitialisation*>(pxConstThis);

		pxThis->PerformSinglePlayerCheckpointLoad();
	}

	static void PerformSinglePlayerCheckpointRestart(const void* pUserData)
	{
		const AVP_ConnectionState_BeginGameInitialisation*	pxConstThis	= static_cast<const AVP_ConnectionState_BeginGameInitialisation*>(pUserData);
		AVP_ConnectionState_BeginGameInitialisation*		pxThis		= const_cast<AVP_ConnectionState_BeginGameInitialisation*>(pxConstThis);

		pxThis->PerformSinglePlayerCheckpointRestart();
	}

	static void PerformSinglePlayerLevelRestart(const void* pUserData)
	{
		const AVP_ConnectionState_BeginGameInitialisation*	pxConstThis	= static_cast<const AVP_ConnectionState_BeginGameInitialisation*>(pUserData);
		AVP_ConnectionState_BeginGameInitialisation*		pxThis		= const_cast<AVP_ConnectionState_BeginGameInitialisation*>(pxConstThis);

		pxThis->PerformSinglePlayerLevelRestart();
	}

	static void PerformMultiplayerInitialisation(const void* pUserData)
	{
		const AVP_ConnectionState_BeginGameInitialisation*	pxConstThis	= static_cast<const AVP_ConnectionState_BeginGameInitialisation*>(pUserData);
		AVP_ConnectionState_BeginGameInitialisation*		pxThis		= const_cast<AVP_ConnectionState_BeginGameInitialisation*>(pxConstThis);

		pxThis->PerformMultiplayerInitialisation();
	}

	static void PerformMultiplayerClientRestart(const void* pUserData)
	{
		const AVP_ConnectionState_BeginGameInitialisation*	pxConstThis	= static_cast<const AVP_ConnectionState_BeginGameInitialisation*>(pUserData);
		AVP_ConnectionState_BeginGameInitialisation*		pxThis		= const_cast<AVP_ConnectionState_BeginGameInitialisation*>(pxConstThis);

		pxThis->PerformMultiplayerClientRestart();
	}

	static void PerformMultiplayerServerRestart(const void* pUserData)
	{
		const AVP_ConnectionState_BeginGameInitialisation*	pxConstThis	= static_cast<const AVP_ConnectionState_BeginGameInitialisation*>(pUserData);
		AVP_ConnectionState_BeginGameInitialisation*		pxThis		= const_cast<AVP_ConnectionState_BeginGameInitialisation*>(pxConstThis);

		pxThis->PerformMultiplayerServerRestart();
	}

};   // End of class 'AVP_ConnectionState_BeginGameInitialisation'.


#endif   // ifndef __AVP_CONNECTIONSTATE_BEGINGAMEINITIALISATION_H__


/// End of file. ///
