//////////////////////////////////////////////////////////////////////////////
//
// AVP_Game_Core.h
//
// Copyright (c) 2005 Rebellion. All rights reserved.
//
// Description:
//
//     basic game loop.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef ___AVP_GAME_CORE_H___
#define ___AVP_GAME_CORE_H___ 1

#include "ChunkSystem/Asura_SaveBlock.h"
#if defined(AVP_ALLOW_GAME_TIME_SCALE_CHANGE)
#include "Input/Asura_ControlMap.h"
#endif	// defined(AVP_ALLOW_GAME_TIME_SCALE_CHANGE)

#include "Camera/Asura_Camera.h"
#include "Core/AVP_Settings.h"

class Asura_FSFX_Handler;
class AVP_Player;
class Asura_Vector_3;
class Asura_Quat;
class Asura_Blueprint;

class AVP_Game_Core
{
public:
	enum CharacterType
	{
		CHARACTERTYPE_UNKNOWN			= -1,

		FIRST_SINGLE_PLAYER_CHARACTER	= 0,
		SINGLE_PLAYER_ALIEN			= FIRST_SINGLE_PLAYER_CHARACTER,
		SINGLE_PLAYER_MARINE,
		SINGLE_PLAYER_PREDATOR,
		LAST_SINGLE_PLAYER_CHARACTER	= SINGLE_PLAYER_PREDATOR,

		FIRST_MULTIPLAYER_CHARACTER,
		MULTIPLAYER_ALIEN			= FIRST_MULTIPLAYER_CHARACTER,
		MULTIPLAYER_MARINE,
		MULTIPLAYER_PREDATOR,
		LAST_MULTIPLAYER_CHARACTER		= MULTIPLAYER_PREDATOR,

		NUM_CHARACTERTYPES
	};

	// Public functions...
	static void Initialise();
	static void Update();
	static void Render();
	static void Shutdown();

	// Pause check...
	static bool	IsPaused(void);

	// Start of level loading/saving functions...
	static bool LoadBlock(Asura_StaticSaveBlock &xBlock);
	static bool	LoadLevelStartBlock(void);
	static bool	SaveLevelStartBlock(void);
	static bool	LoadCheckPointBlock(void);
	static bool	SaveCheckPointBlock(void);

	// Player functions...
	static AVP_Player*	GetPlayer(void)	{ return(s_pxPlayer); }
	static Asura_Guid	GetPlayerGuid(void);
	static bool			IsLocalPlayer(const u_int uGuid);

	static bool GetCanMakePlayerActors();
	static bool ShouldCompressPlayerCommandsMessages(); 

	static void RequestPause();
	static void RequestObjectives();

	static void SetRespawnSpecies(const AVP_Settings::Species uSpecies);
	static AVP_Settings::Species GetRespawnSpecies() { return(static_cast<AVP_Settings::Species>(s_uRespawnSpecies)); }
	static Asura_Hash_ID GetPlayerBlueprintHashForSpecies( const AVP_Settings::Species eSpecies );
	
	static Asura_Hash_ID GetStartPointBlueprintHashForSpecies( const AVP_Settings::Species eSpecies ); 
	static Asura_Hash_ID GetStartPointBlueprintHashForTeam( const AVP_Settings::Team eTeam ); 

	static void SetReceivedInitialiseCompleteMessage(bool bReceived) { s_bReceivedInitialiseCompleteMessage = bReceived; }
	static bool GetReceivedInitialiseCompleteMessage() { return s_bReceivedInitialiseCompleteMessage; }
    
	static void	SetVisionMode(const Asura_Hash_ID uNewBlueprintHash, const Asura_Hash_ID uOldBlueprintHash, const bool bInstant);
	static Asura_CameraData::HDRSettings& GetVisionModeHDRSettings(){ return s_xVisionModeHDRSettings;}

	static void GetHDRSettingsFromBlueprint( const Asura_Blueprint& xBlueprint, Asura_CameraData::HDRSettings& xSettings );
	
	static Asura_FSFX_Handler* GetFSFXHandler(){ return s_pxFSFXHandler; }
	static bool	SetFSFXValue(const Asura_Blueprint& xBlueprint, const Asura_Hash_ID uParameterHash, const float fValue, const float fTime);
	static bool	SetFSFXValue(const Asura_Hash_ID uFSFXHash, const float fValue, const float fTime);
	static bool	ResetFSFXValue(const Asura_Blueprint& xBlueprint, const Asura_Hash_ID uParameterHash);

	static void SetPausedFSFX(bool bIsOn);
	static void SetupPausedDSP(bool bOn);

	static const Asura_Blueprint* GetLevelBlueprint( const char* szLevelFile, CharacterType eCharType );

	static Asura_StaticSaveBlock* GetCheckpointBlock(){ return &s_xCheckpointBlock; };

private:

	// Private variables...
	static Asura_StaticSaveBlock	s_xLevelStartBlock;
	static Asura_StaticSaveBlock	s_xCheckpointBlock;
	static AVP_Player*				s_pxPlayer;

#if defined(AVP_ALLOW_GAME_TIME_SCALE_CHANGE)
	enum GameTimeScaleMapping
	{
		GTS_CHANGE_SPEED,
		GTS_PAUSE,
		GTS_RESET,
		GTS_ADVANCE_ONE_FRAME,

		MAX_GAME_TIME_SCALE_MAPPINGS
	};

	static Asura_ControlMap	s_xGameTimeScaleControlMap;
	static float			s_fGameTimeScaleDisplay;
	static float			s_fCurrentGameTimeScale;
	static bool				s_bAdvanceOneFrame;

#endif	// defined(AVP_ALLOW_GAME_TIME_SCALE_CHANGE)

	static u_int			s_uRespawnSpecies;
	static bool				s_bReceivedInitialiseCompleteMessage;


	//Vision modes
	static Asura_FSFX_Handler* s_pxFSFXHandler;
	static Asura_CameraData::HDRSettings s_xVisionModeHDRSettings;

	// Private functions...
#if defined(AVP_ALLOW_GAME_TIME_SCALE_CHANGE)
	static void UpdateGameTimeScale(void);
	static void RenderGameTimeScale(void);
#endif	// defined(AVP_ALLOW_GAME_TIME_SCALE_CHANGE)

	static void	Platform_Initialise(void);
	static void	Platform_Shutdown(void);

	static bool Project_TeleportServerEntity(const Asura_Guid uGuidToTeleport, const Asura_Vector_3& xPosition, const Asura_Quat& xOrientation);

	static bool Respawn(bool bHelp); 
};


// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

#endif // #ifndef ___AVP_GAME_CORE_H___
