summaryrefslogtreecommitdiff
path: root/game/shared/dod/dod_round_timer.h
blob: 8d65b41f14d2867265ff32c683232c0e1da0a665 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Round timer for dod gamerules
//
//=============================================================================//

#ifndef DOD_ROUND_TIMER_H
#define DOD_ROUND_TIMER_H

#ifdef _WIN32
#pragma once
#endif

#ifdef CLIENT_DLL
	#define CDODRoundTimer C_DODRoundTimer
#endif

class CDODRoundTimer : public CBaseEntity
{
public:
	DECLARE_CLASS( CDODRoundTimer, CBaseEntity );
	DECLARE_NETWORKCLASS();

	// Constructor
	CDODRoundTimer();

	// Destructor
	virtual ~CDODRoundTimer();

	// Set the initial length of the timer
	void SetTimeRemaining( int iTimerSeconds );

	// Add time to an already running ( or paused ) timer
	void AddTimerSeconds( int iSecondsToAdd );

	void PauseTimer( void );
	void ResumeTimer( void );

	// Returns seconds to display.
	// When paused shows amount of time left once the timer is resumed
	float GetTimeRemaining( void );

	int GetTimerMaxLength( void );

#ifndef CLIENT_DLL

	int UpdateTransmitState();

#else

	void InternalSetPaused( bool bPaused ) { m_bTimerPaused = bPaused; }

#endif	

private:
	CNetworkVar( bool, m_bTimerPaused );
	CNetworkVar( float, m_flTimeRemaining );
	CNetworkVar( float, m_flTimerEndTime );

	int m_iTimerMaxLength;	// Sum of starting duration plus any time we added
};

#ifdef CLIENT_DLL
	extern CDODRoundTimer *g_DODRoundTimer;
#endif

#endif	//DOD_ROUND_TIMER_H