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.

116 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Game rules for Portal.
  4. //
  5. //=============================================================================//
  6. #ifdef PORTAL_MP
  7. #include "portal_mp_gamerules.h" //redirect to multiplayer gamerules in multiplayer builds
  8. #else
  9. #ifndef PORTAL_GAMERULES_H
  10. #define PORTAL_GAMERULES_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. #include "gamerules.h"
  15. #include "hl2_gamerules.h"
  16. #ifdef CLIENT_DLL
  17. #define CPortalGameRules C_PortalGameRules
  18. #define CPortalGameRulesProxy C_PortalGameRulesProxy
  19. #endif
  20. #if defined ( CLIENT_DLL )
  21. #include "steam/steam_api.h"
  22. #endif
  23. class CPortalGameRulesProxy : public CGameRulesProxy
  24. {
  25. public:
  26. DECLARE_CLASS( CPortalGameRulesProxy, CGameRulesProxy );
  27. DECLARE_NETWORKCLASS();
  28. };
  29. class CPortalGameRules : public CHalfLife2
  30. {
  31. public:
  32. DECLARE_CLASS( CPortalGameRules, CSingleplayRules );
  33. virtual bool Init();
  34. virtual bool ShouldCollide( int collisionGroup0, int collisionGroup1 );
  35. virtual bool ShouldUseRobustRadiusDamage(CBaseEntity *pEntity);
  36. #ifndef CLIENT_DLL
  37. virtual bool ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target );
  38. virtual float GetAutoAimScale( CBasePlayer *pPlayer );
  39. #endif
  40. #ifdef CLIENT_DLL
  41. virtual bool IsBonusChallengeTimeBased( void );
  42. #endif
  43. private:
  44. // Rules change for the mega physgun
  45. CNetworkVar( bool, m_bMegaPhysgun );
  46. #ifdef CLIENT_DLL
  47. DECLARE_CLIENTCLASS_NOBASE(); // This makes datatables able to access our private vars.
  48. #else
  49. DECLARE_SERVERCLASS_NOBASE(); // This makes datatables able to access our private vars.
  50. CPortalGameRules();
  51. virtual ~CPortalGameRules() {}
  52. virtual void Think( void );
  53. virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args );
  54. virtual void PlayerSpawn( CBasePlayer *pPlayer );
  55. virtual void InitDefaultAIRelationships( void );
  56. virtual const char* AIClassText(int classType);
  57. virtual const char *GetGameDescription( void ) { return "Portal"; }
  58. // Ammo
  59. virtual void PlayerThink( CBasePlayer *pPlayer );
  60. virtual float GetAmmoDamage( CBaseEntity *pAttacker, CBaseEntity *pVictim, int nAmmoType );
  61. virtual bool ShouldBurningPropsEmitLight();
  62. bool ShouldRemoveRadio( void );
  63. public:
  64. virtual float FlPlayerFallDamage( CBasePlayer *pPlayer );
  65. bool MegaPhyscannonActive( void ) { return m_bMegaPhysgun; }
  66. private:
  67. int DefaultFOV( void ) { return 75; }
  68. #endif
  69. };
  70. //-----------------------------------------------------------------------------
  71. // Gets us at the Half-Life 2 game rules
  72. //-----------------------------------------------------------------------------
  73. inline CPortalGameRules* PortalGameRules()
  74. {
  75. return static_cast<CPortalGameRules*>(g_pGameRules);
  76. }
  77. #endif // PORTAL_GAMERULES_H
  78. #endif