Counter Strike : Global Offensive Source Code
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.

150 lines
4.6 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Controls the pose parameters of a model
  4. //
  5. //===========================================================================//
  6. #define MAX_POSE_CONTROLLED_PROPS 4 // Number of entities by the same name that can be controlled
  7. // Type of frequency modulations
  8. enum PoseController_FModType_t
  9. {
  10. POSECONTROLLER_FMODTYPE_NONE = 0,
  11. POSECONTROLLER_FMODTYPE_SINE,
  12. POSECONTROLLER_FMODTYPE_SQUARE,
  13. POSECONTROLLER_FMODTYPE_TRIANGLE,
  14. POSECONTROLLER_FMODTYPE_SAWTOOTH,
  15. POSECONTROLLER_FMODTYPE_NOISE,
  16. POSECONTROLLER_FMODTYPE_TOTAL,
  17. };
  18. #ifndef CLIENT_DLL
  19. //-----------------------------------------------------------------------------
  20. // SERVER CLASS
  21. //-----------------------------------------------------------------------------
  22. #include "baseentity.h"
  23. class CPoseController : public CBaseEntity
  24. {
  25. public:
  26. DECLARE_CLASS( CPoseController, CBaseEntity );
  27. DECLARE_SERVERCLASS();
  28. DECLARE_DATADESC();
  29. virtual void Spawn( void );
  30. void Think( void );
  31. void BuildPropList( void );
  32. void BuildPoseIndexList( void );
  33. void SetPoseIndex( int i, int iValue );
  34. void SetCurrentPose( float fCurrentPoseValue );
  35. float GetPoseValue( void );
  36. void SetProp( CBaseAnimating *pProp );
  37. void SetPropName( const char *pName );
  38. void SetPoseParameterName( const char *pName );
  39. void SetPoseValue( float fValue );
  40. void SetInterpolationTime( float fValue );
  41. void SetInterpolationWrap( bool bWrap );
  42. void SetCycleFrequency( float fValue );
  43. void SetFModType( int nType );
  44. void SetFModTimeOffset( float fValue );
  45. void SetFModRate( float fValue );
  46. void SetFModAmplitude( float fValue );
  47. void RandomizeFMod( float fExtremeness );
  48. // Input handlers
  49. void InputSetPoseParameterName( inputdata_t &inputdata );
  50. void InputSetPoseValue( inputdata_t &inputdata );
  51. void InputSetInterpolationTime( inputdata_t &inputdata );
  52. void InputSetCycleFrequency( inputdata_t &inputdata );
  53. void InputSetFModType( inputdata_t &inputdata );
  54. void InputSetFModTimeOffset( inputdata_t &inputdata );
  55. void InputSetFModRate( inputdata_t &inputdata );
  56. void InputSetFModAmplitude( inputdata_t &inputdata );
  57. void InputRandomizeFMod( inputdata_t &inputdata );
  58. void InputGetFMod( inputdata_t &inputdata );
  59. private:
  60. CNetworkArray( EHANDLE, m_hProps, MAX_POSE_CONTROLLED_PROPS ); // Handles to controlled models
  61. CNetworkArray( unsigned char, m_chPoseIndex, MAX_POSE_CONTROLLED_PROPS ); // Pose parameter indices for each model
  62. bool m_bDisablePropLookup;
  63. CNetworkVar( bool, m_bPoseValueParity );
  64. string_t m_iszPropName; // Targetname of the models to control
  65. string_t m_iszPoseParameterName; // Pose parameter name to control
  66. CNetworkVar( float, m_fPoseValue ); // Normalized pose parameter value (maps to each pose parameter's min and max range)
  67. CNetworkVar( float, m_fInterpolationTime ); // Interpolation speed for client matching absolute pose values
  68. CNetworkVar( bool, m_bInterpolationWrap ); // Interpolation for the client wraps 0 to 1.
  69. CNetworkVar( float, m_fCycleFrequency ); // Cycles per second
  70. // Frequency modulation variables
  71. CNetworkVar( PoseController_FModType_t, m_nFModType );
  72. CNetworkVar( float, m_fFModTimeOffset );
  73. CNetworkVar( float, m_fFModRate );
  74. CNetworkVar( float, m_fFModAmplitude );
  75. };
  76. #else //#ifndef CLIENT_DLL
  77. //-----------------------------------------------------------------------------
  78. // CLIENT CLASS
  79. //-----------------------------------------------------------------------------
  80. #include "c_baseentity.h"
  81. #include "fx_interpvalue.h"
  82. class C_PoseController : public C_BaseEntity
  83. {
  84. public:
  85. DECLARE_CLASS( C_PoseController, C_BaseEntity );
  86. DECLARE_CLIENTCLASS();
  87. virtual void Spawn( void );
  88. virtual void OnDataChanged( DataUpdateType_t updateType );
  89. virtual void ClientThink( void );
  90. private:
  91. void UpdateModulation( void );
  92. void UpdatePoseCycle( float fCycleAmount );
  93. void SetCurrentPose( float fCurrentPoseValue );
  94. // Networked variables
  95. EHANDLE m_hProps[MAX_POSE_CONTROLLED_PROPS];
  96. unsigned char m_chPoseIndex[MAX_POSE_CONTROLLED_PROPS];
  97. bool m_bPoseValueParity;
  98. float m_fPoseValue;
  99. float m_fInterpolationTime;
  100. bool m_bInterpolationWrap;
  101. float m_fCycleFrequency;
  102. PoseController_FModType_t m_nFModType;
  103. float m_fFModTimeOffset;
  104. float m_fFModRate;
  105. float m_fFModAmplitude;
  106. bool m_bOldPoseValueParity;
  107. float m_fCurrentPoseValue; // Actual pose value cycled by the frequency and modulation
  108. float m_fCurrentFMod; // The current fequency modulation amount (stored for noise walk)
  109. CInterpolatedValue m_PoseTransitionValue;
  110. };
  111. #endif //#ifndef CLIENT_DLL