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.

102 lines
3.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_PLAYERCLASS_SHARED_H
  7. #define TF_PLAYERCLASS_SHARED_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_shareddefs.h"
  12. #include "tf_classdata.h"
  13. // Client specific.
  14. #ifdef CLIENT_DLL
  15. EXTERN_RECV_TABLE( DT_TFPlayerClassShared );
  16. // Server specific.
  17. #else
  18. EXTERN_SEND_TABLE( DT_TFPlayerClassShared );
  19. #endif
  20. //-----------------------------------------------------------------------------
  21. // TF Player Class Shared
  22. //-----------------------------------------------------------------------------
  23. class CTFPlayerClassShared
  24. {
  25. public:
  26. CTFPlayerClassShared();
  27. DECLARE_EMBEDDED_NETWORKVAR()
  28. DECLARE_CLASS_NOBASE( CTFPlayerClassShared );
  29. bool Init( int iClass );
  30. bool IsClass( int iClass ) const { return ( m_iClass == iClass ); }
  31. int GetClassIndex( void ) const { return m_iClass; }
  32. void Reset( void );
  33. #ifdef CLIENT_DLL
  34. string_t GetClassIconName( void ) const { return MAKE_STRING( m_iszClassIcon ); }
  35. bool HasCustomModel( void ) const { return m_iszCustomModel[0] != '\0'; }
  36. #else
  37. string_t GetClassIconName( void ) const { return m_iszClassIcon.Get(); }
  38. void SetClassIconName( string_t iszClassIcon ) { m_iszClassIcon = iszClassIcon; }
  39. bool HasCustomModel( void ) const { return (m_iszCustomModel.Get() != NULL_STRING); }
  40. #endif
  41. #ifndef CLIENT_DLL
  42. #define USE_CLASS_ANIMATIONS true
  43. void SetCustomModel( const char *pszModelName, bool isUsingClassAnimations = false );
  44. void SetCustomModelOffset( Vector &vecOffset ) { m_vecCustomModelOffset = vecOffset; }
  45. void SetCustomModelRotates( bool bRotates ) { m_bCustomModelRotates = bRotates; }
  46. void SetCustomModelRotation( QAngle &vecOffset ) { m_angCustomModelRotation = vecOffset; m_bCustomModelRotationSet = true; }
  47. void ClearCustomModelRotation( void ) { m_bCustomModelRotationSet = false; }
  48. void SetCustomModelVisibleToSelf( bool bVisible ) { m_bCustomModelVisibleToSelf = bVisible; }
  49. #endif
  50. const char *GetName( void ) const { return GetPlayerClassData( m_iClass )->m_szClassName; }
  51. const char *GetModelName( void ) const;
  52. const char *GetHandModelName( int iHandIndex ) const;
  53. float GetMaxSpeed( void ) { return GetPlayerClassData( m_iClass )->m_flMaxSpeed; }
  54. int GetMaxHealth( void ) const { return GetPlayerClassData( m_iClass )->m_nMaxHealth; }
  55. int GetMaxArmor( void ) const { return GetPlayerClassData( m_iClass )->m_nMaxArmor; }
  56. Vector GetCustomModelOffset( void ) const { return m_vecCustomModelOffset.Get(); }
  57. QAngle GetCustomModelRotation( void ) const { return m_angCustomModelRotation.Get(); }
  58. bool CustomModelRotationSet( void ) { return m_bCustomModelRotationSet.Get(); }
  59. bool CustomModelRotates( void ) const { return m_bCustomModelRotates.Get(); }
  60. bool CustomModelIsVisibleToSelf( void ) const { return m_bCustomModelVisibleToSelf.Get(); }
  61. bool CustomModelUsesClassAnimations( void ) const { return m_bUseClassAnimations.Get(); }
  62. bool CustomModelHasChanged( void );
  63. TFPlayerClassData_t *GetData( void ) const { return GetPlayerClassData( m_iClass ); }
  64. // If needed, put this into playerclass scripts
  65. bool CanBuildObject( int iObjectType );
  66. protected:
  67. CNetworkVar( int, m_iClass );
  68. #ifdef CLIENT_DLL
  69. char m_iszClassIcon[MAX_PATH];
  70. char m_iszCustomModel[MAX_PATH];
  71. #else
  72. CNetworkVar( string_t, m_iszClassIcon );
  73. CNetworkVar( string_t, m_iszCustomModel );
  74. #endif
  75. CNetworkVar( Vector, m_vecCustomModelOffset );
  76. CNetworkVar( QAngle, m_angCustomModelRotation );
  77. CNetworkVar( bool, m_bCustomModelRotates );
  78. CNetworkVar( bool, m_bCustomModelRotationSet );
  79. CNetworkVar( bool, m_bCustomModelVisibleToSelf );
  80. CNetworkVar( bool, m_bUseClassAnimations );
  81. CNetworkVar( int, m_iClassModelParity );
  82. int m_iOldClassModelParity;
  83. };
  84. #endif // TF_PLAYERCLASS_SHARED_H