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.

222 lines
5.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ====
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef BUTTONS_H
  7. #define BUTTONS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class CBaseButton : public CBaseToggle
  12. {
  13. public:
  14. DECLARE_CLASS( CBaseButton, CBaseToggle );
  15. DECLARE_SERVERCLASS();
  16. void Spawn( void );
  17. virtual void Precache( void );
  18. bool CreateVPhysics();
  19. void RotSpawn( void );
  20. bool KeyValue( const char *szKeyName, const char *szValue );
  21. int DrawDebugTextOverlays();
  22. protected:
  23. void ButtonActivate( );
  24. void SparkSoundCache( void );
  25. void ButtonTouch( ::CBaseEntity *pOther );
  26. void ButtonSpark ( void );
  27. void TriggerAndWait( void );
  28. void ButtonReturn( void );
  29. void ButtonBackHome( void );
  30. void ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  31. bool OnUseLocked( CBaseEntity *pActivator );
  32. virtual void Lock();
  33. virtual void Unlock();
  34. // Input handlers
  35. void InputLock( inputdata_t &inputdata );
  36. void InputUnlock( inputdata_t &inputdata );
  37. void InputPress( inputdata_t &inputdata );
  38. void InputPressIn( inputdata_t &inputdata );
  39. void InputPressOut( inputdata_t &inputdata );
  40. virtual int OnTakeDamage( const CTakeDamageInfo &info );
  41. enum BUTTON_CODE { BUTTON_NOTHING, BUTTON_ACTIVATE, BUTTON_RETURN, BUTTON_PRESS };
  42. BUTTON_CODE ButtonResponseToTouch( void );
  43. void Press( CBaseEntity *pActivator, BUTTON_CODE eCode );
  44. DECLARE_DATADESC();
  45. virtual int ObjectCaps(void);
  46. Vector m_vecMoveDir;
  47. bool m_fStayPushed; // button stays pushed in until touched again?
  48. bool m_fRotating; // a rotating button? default is a sliding button.
  49. locksound_t m_ls; // door lock sounds
  50. byte m_bLockedSound; // ordinals from entity selection
  51. byte m_bLockedSentence;
  52. byte m_bUnlockedSound;
  53. byte m_bUnlockedSentence;
  54. bool m_bLocked;
  55. int m_sounds;
  56. float m_flUseLockedTime; // Controls how often we fire the OnUseLocked output.
  57. bool m_bSolidBsp;
  58. string_t m_sNoise; // The actual WAV file name of the sound.
  59. COutputEvent m_OnDamaged;
  60. COutputEvent m_OnPressed;
  61. COutputEvent m_OnUseLocked;
  62. COutputEvent m_OnIn;
  63. COutputEvent m_OnOut;
  64. int m_nState;
  65. };
  66. //
  67. // Rotating button (aka "lever")
  68. //
  69. class CRotButton : public CBaseButton
  70. {
  71. public:
  72. DECLARE_CLASS( CRotButton, CBaseButton );
  73. void Spawn( void );
  74. bool CreateVPhysics( void );
  75. };
  76. class CMomentaryRotButton : public CRotButton
  77. {
  78. DECLARE_CLASS( CMomentaryRotButton, CRotButton );
  79. public:
  80. void Spawn ( void );
  81. bool CreateVPhysics( void );
  82. virtual int ObjectCaps( void );
  83. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  84. void UseMoveDone( void );
  85. void ReturnMoveDone( void );
  86. void OutputMovementComplete(void);
  87. void SetPositionMoveDone(void);
  88. void UpdateSelf( float value, bool bPlaySound );
  89. void PlaySound( void );
  90. void UpdateTarget( float value, CBaseEntity *pActivator );
  91. int DrawDebugTextOverlays(void);
  92. static CMomentaryRotButton *Instance( edict_t *pent ) { return (CMomentaryRotButton *)GetContainingEntity(pent); }
  93. float GetPos(const QAngle &vecAngles);
  94. DECLARE_DATADESC();
  95. virtual void Lock();
  96. virtual void Unlock();
  97. // Input handlers
  98. void InputSetPosition( inputdata_t &inputdata );
  99. void InputSetPositionImmediately( inputdata_t &inputdata );
  100. void InputDisableUpdateTarget( inputdata_t &inputdata );
  101. void InputEnableUpdateTarget( inputdata_t &inputdata );
  102. void InputEnable( inputdata_t &inputdata );
  103. void InputDisable( inputdata_t &inputdata );
  104. virtual void Enable( void );
  105. virtual void Disable( void );
  106. bool m_bDisabled;
  107. COutputFloat m_Position;
  108. COutputEvent m_OnUnpressed;
  109. COutputEvent m_OnFullyOpen;
  110. COutputEvent m_OnFullyClosed;
  111. COutputEvent m_OnReachedPosition;
  112. int m_lastUsed;
  113. QAngle m_start;
  114. QAngle m_end;
  115. float m_IdealYaw;
  116. string_t m_sNoise;
  117. bool m_bUpdateTarget; // Used when jiggling so that we don't jiggle the target (door, etc)
  118. int m_direction;
  119. float m_returnSpeed;
  120. float m_flStartPosition;
  121. protected:
  122. void UpdateThink( void );
  123. };
  124. //--------------------------------------------------------------------------------------------------------
  125. //
  126. // CButtonTimed - func_button_timed
  127. //
  128. //--------------------------------------------------------------------------------------------------------
  129. class CButtonTimed : public CBaseButton
  130. {
  131. public:
  132. DECLARE_CLASS( CButtonTimed, CBaseButton );
  133. DECLARE_DATADESC();
  134. DECLARE_SERVERCLASS();
  135. CButtonTimed();
  136. void UseTimed( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  137. void UseThink( void );
  138. virtual void Spawn( void );
  139. virtual int ObjectCaps( void )
  140. {
  141. const int base_flags = BaseClass::ObjectCaps();
  142. return (base_flags | FCAP_CONTINUOUS_USE | FCAP_USE_IN_RADIUS);
  143. }
  144. void StopUse( void );
  145. void InputEnable( inputdata_t &inputdata );
  146. void InputDisable( inputdata_t &inputdata );
  147. void Enable( void );
  148. void Disable( void );
  149. private:
  150. CNetworkVar( string_t, m_sUseString);
  151. CNetworkVar( string_t, m_sUseSubString);
  152. int m_nUseTime;
  153. bool m_bAutoDisable;
  154. bool m_bInUse;
  155. float m_flUseStartTime;
  156. float m_flLastUseTime;
  157. COutputEvent m_OnUnpressed;
  158. COutputEvent m_OnTimeUp;
  159. };
  160. #endif // BUTTONS_H