Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef HL2MP_GAMERULES_H
  14. #define HL2MP_GAMERULES_H
  15. #pragma once
  16. #include "gamerules.h"
  17. #include "teamplay_gamerules.h"
  18. #include "gamevars_shared.h"
  19. #ifndef CLIENT_DLL
  20. #include "hl2mp_player.h"
  21. #endif
  22. #define VEC_CROUCH_TRACE_MIN HL2MPRules()->GetHL2MPViewVectors()->m_vCrouchTraceMin
  23. #define VEC_CROUCH_TRACE_MAX HL2MPRules()->GetHL2MPViewVectors()->m_vCrouchTraceMax
  24. enum
  25. {
  26. TEAM_COMBINE = 2,
  27. TEAM_REBELS,
  28. };
  29. #ifdef CLIENT_DLL
  30. #define CHL2MPRules C_HL2MPRules
  31. #define CHL2MPGameRulesProxy C_HL2MPGameRulesProxy
  32. #endif
  33. class CHL2MPGameRulesProxy : public CGameRulesProxy
  34. {
  35. public:
  36. DECLARE_CLASS( CHL2MPGameRulesProxy, CGameRulesProxy );
  37. DECLARE_NETWORKCLASS();
  38. };
  39. class HL2MPViewVectors : public CViewVectors
  40. {
  41. public:
  42. HL2MPViewVectors(
  43. Vector vView,
  44. Vector vHullMin,
  45. Vector vHullMax,
  46. Vector vDuckHullMin,
  47. Vector vDuckHullMax,
  48. Vector vDuckView,
  49. Vector vObsHullMin,
  50. Vector vObsHullMax,
  51. Vector vDeadViewHeight,
  52. Vector vCrouchTraceMin,
  53. Vector vCrouchTraceMax ) :
  54. CViewVectors(
  55. vView,
  56. vHullMin,
  57. vHullMax,
  58. vDuckHullMin,
  59. vDuckHullMax,
  60. vDuckView,
  61. vObsHullMin,
  62. vObsHullMax,
  63. vDeadViewHeight )
  64. {
  65. m_vCrouchTraceMin = vCrouchTraceMin;
  66. m_vCrouchTraceMax = vCrouchTraceMax;
  67. }
  68. Vector m_vCrouchTraceMin;
  69. Vector m_vCrouchTraceMax;
  70. };
  71. class CHL2MPRules : public CTeamplayRules
  72. {
  73. public:
  74. DECLARE_CLASS( CHL2MPRules, CTeamplayRules );
  75. #ifdef CLIENT_DLL
  76. DECLARE_CLIENTCLASS_NOBASE(); // This makes datatables able to access our private vars.
  77. #else
  78. DECLARE_SERVERCLASS_NOBASE(); // This makes datatables able to access our private vars.
  79. #endif
  80. CHL2MPRules();
  81. virtual ~CHL2MPRules();
  82. virtual void Precache( void );
  83. virtual bool ShouldCollide( int collisionGroup0, int collisionGroup1 );
  84. virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args );
  85. virtual float FlWeaponRespawnTime( CBaseCombatWeapon *pWeapon );
  86. virtual float FlWeaponTryRespawn( CBaseCombatWeapon *pWeapon );
  87. virtual Vector VecWeaponRespawnSpot( CBaseCombatWeapon *pWeapon );
  88. virtual int WeaponShouldRespawn( CBaseCombatWeapon *pWeapon );
  89. virtual void Think( void );
  90. virtual void CreateStandardEntities( void );
  91. virtual void ClientSettingsChanged( CBasePlayer *pPlayer );
  92. virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget );
  93. virtual void GoToIntermission( void );
  94. virtual void DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info );
  95. virtual const char *GetGameDescription( void );
  96. // derive this function if you mod uses encrypted weapon info files
  97. virtual const unsigned char *GetEncryptionKey( void ) { return (unsigned char *)"x9Ke0BY7"; }
  98. virtual const CViewVectors* GetViewVectors() const;
  99. const HL2MPViewVectors* GetHL2MPViewVectors() const;
  100. float GetMapRemainingTime();
  101. void CleanUpMap();
  102. void CheckRestartGame();
  103. void RestartGame();
  104. #ifndef CLIENT_DLL
  105. virtual Vector VecItemRespawnSpot( CItem *pItem );
  106. virtual QAngle VecItemRespawnAngles( CItem *pItem );
  107. virtual float FlItemRespawnTime( CItem *pItem );
  108. virtual bool CanHavePlayerItem( CBasePlayer *pPlayer, CBaseCombatWeapon *pItem );
  109. virtual bool FShouldSwitchWeapon( CBasePlayer *pPlayer, CBaseCombatWeapon *pWeapon );
  110. void AddLevelDesignerPlacedObject( CBaseEntity *pEntity );
  111. void RemoveLevelDesignerPlacedObject( CBaseEntity *pEntity );
  112. void ManageObjectRelocation( void );
  113. void CheckChatForReadySignal( CHL2MP_Player *pPlayer, const char *chatmsg );
  114. const char *GetChatFormat( bool bTeamOnly, CBasePlayer *pPlayer );
  115. #endif
  116. virtual void ClientDisconnected( edict_t *pClient );
  117. bool CheckGameOver( void );
  118. bool IsIntermission( void );
  119. void PlayerKilled( CBasePlayer *pVictim, const CTakeDamageInfo &info );
  120. bool IsTeamplay( void ) { return m_bTeamPlayEnabled; }
  121. void CheckAllPlayersReady( void );
  122. virtual bool IsConnectedUserInfoChangeAllowed( CBasePlayer *pPlayer );
  123. private:
  124. CNetworkVar( bool, m_bTeamPlayEnabled );
  125. CNetworkVar( float, m_flGameStartTime );
  126. CUtlVector<EHANDLE> m_hRespawnableItemsAndWeapons;
  127. float m_tmNextPeriodicThink;
  128. float m_flRestartGameTime;
  129. bool m_bCompleteReset;
  130. bool m_bAwaitingReadyRestart;
  131. bool m_bHeardAllPlayersReady;
  132. #ifndef CLIENT_DLL
  133. bool m_bChangelevelDone;
  134. #endif
  135. };
  136. inline CHL2MPRules* HL2MPRules()
  137. {
  138. return static_cast<CHL2MPRules*>(g_pGameRules);
  139. }
  140. #endif //HL2MP_GAMERULES_H