//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $Workfile:     $
// $Date:         $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//

#ifndef HL2WARS_GAMERULES_H
#define HL2WARS_GAMERULES_H
#pragma once

#include "gamerules.h"
#include "hl2_gamerules.h"

#ifndef CLIENT_DLL
#include "hl2wars/hl2wars_player.h"
#endif


#ifdef CLIENT_DLL
	#define CHL2WarsRules C_HL2WarsRules
	#define CHL2WarsGameRulesProxy C_HL2WarsGameRulesProxy
#endif

enum gamemodes
{
	GAMEMODE_SANDBOX = 0,	// just start a random map
	GAMEMODE_CLASSIC,		// create a game in the gamelobby, then start it.
	GAMEMODE_SINGLEPLAYER,  // Basicly the half-life 2 rules, missions/campaign
};

class CHL2WarsGameRulesProxy : public CGameRulesProxy
{
public:
	DECLARE_CLASS( CHL2WarsGameRulesProxy, CGameRulesProxy );
	DECLARE_NETWORKCLASS();
};

class CHL2WarsRules : public CHalfLife2
{
public:
	DECLARE_CLASS( CHL2WarsRules, CHalfLife2 );

#ifdef CLIENT_DLL

	DECLARE_CLIENTCLASS_NOBASE(); // This makes datatables able to access our private vars.

#else

	DECLARE_SERVERCLASS_NOBASE(); // This makes datatables able to access our private vars.
#endif
	
	CHL2WarsRules();
	virtual ~CHL2WarsRules();

	// Functions to verify the single/multiplayer status of a game
	virtual bool IsMultiplayer( void );

#ifdef CLIENT_DLL
#else
	virtual void			Think( void );
	virtual void			ChangeLevel( void );
	virtual void			GetNextLevelName( char *szNextMap, int bufsize );
#endif 
	virtual const char *GetGameDescription( void );
	// hl2wars game related rules
	//int		GetGameMode() { return m_iGameMode; }
	//void	SetGameMode( int gamemode ) { m_iGameMode = gamemode; }
	int		GetGameMode();
	void	SetGameMode( int gamemode );

	bool	IsGameRoom( void ) { return m_bGameRoom; }
	void	SetGameRoom( bool state ) { m_bGameRoom = state; }

	float GetMapRemainingTime();

	bool CheckGameOver( void );
	bool IsIntermission( void );
	virtual void GoToIntermission( void );

	bool	CheckAllPlayersPresent();
	
private:
	CNetworkVar( float, m_flGameStartTime );
	CNetworkVar( bool, m_bGameRoom );

	//float m_tmNextPeriodicThink;
	//float m_flRestartGameTime;
	//bool m_bCompleteReset;
	//bool m_bAwaitingReadyRestart;
	//bool m_bHeardAllPlayersReady;
#ifndef CLIENT_DLL
	// map change stuff
	static int m_nMapCycleTimeStamp;
	static int m_nMapCycleindex;
	static CUtlVector<char*> m_MapList;

	float m_flIntermissionEndTime;
	bool m_bAllPlayersPresent;
#endif // CLIENT_DLL
};

inline CHL2WarsRules* HL2WarsRules()
{
	return static_cast<CHL2WarsRules*>(g_pGameRules);
}

#endif //HL2WARS_GAMERULES_H
