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.0 KiB

  1. //========= Copyright 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. void Spawn( void );
  16. virtual void Precache( void );
  17. bool CreateVPhysics();
  18. void RotSpawn( void );
  19. bool KeyValue( const char *szKeyName, const char *szValue );
  20. int DrawDebugTextOverlays();
  21. protected:
  22. void ButtonActivate( );
  23. void SparkSoundCache( void );
  24. void ButtonTouch( ::CBaseEntity *pOther );
  25. void ButtonSpark ( void );
  26. void TriggerAndWait( void );
  27. void ButtonReturn( void );
  28. void ButtonBackHome( void );
  29. void ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  30. bool OnUseLocked( CBaseEntity *pActivator );
  31. virtual void Lock();
  32. virtual void Unlock();
  33. // Input handlers
  34. void InputLock( inputdata_t &inputdata );
  35. void InputUnlock( inputdata_t &inputdata );
  36. void InputPress( inputdata_t &inputdata );
  37. void InputPressIn( inputdata_t &inputdata );
  38. void InputPressOut( inputdata_t &inputdata );
  39. virtual int OnTakeDamage( const CTakeDamageInfo &info );
  40. enum BUTTON_CODE { BUTTON_NOTHING, BUTTON_ACTIVATE, BUTTON_RETURN, BUTTON_PRESS };
  41. BUTTON_CODE ButtonResponseToTouch( void );
  42. void Press( CBaseEntity *pActivator, BUTTON_CODE eCode );
  43. DECLARE_DATADESC();
  44. virtual int ObjectCaps(void);
  45. Vector m_vecMoveDir;
  46. bool m_fStayPushed; // button stays pushed in until touched again?
  47. bool m_fRotating; // a rotating button? default is a sliding button.
  48. locksound_t m_ls; // door lock sounds
  49. byte m_bLockedSound; // ordinals from entity selection
  50. byte m_bLockedSentence;
  51. byte m_bUnlockedSound;
  52. byte m_bUnlockedSentence;
  53. bool m_bLocked;
  54. int m_sounds;
  55. float m_flUseLockedTime; // Controls how often we fire the OnUseLocked output.
  56. bool m_bSolidBsp;
  57. string_t m_sNoise; // The actual WAV file name of the sound.
  58. COutputEvent m_OnDamaged;
  59. COutputEvent m_OnPressed;
  60. COutputEvent m_OnUseLocked;
  61. COutputEvent m_OnIn;
  62. COutputEvent m_OnOut;
  63. int m_nState;
  64. };
  65. //
  66. // Rotating button (aka "lever")
  67. //
  68. class CRotButton : public CBaseButton
  69. {
  70. public:
  71. DECLARE_CLASS( CRotButton, CBaseButton );
  72. void Spawn( void );
  73. bool CreateVPhysics( void );
  74. };
  75. class CMomentaryRotButton : public CRotButton
  76. {
  77. DECLARE_CLASS( CMomentaryRotButton, CRotButton );
  78. public:
  79. void Spawn ( void );
  80. bool CreateVPhysics( void );
  81. virtual int ObjectCaps( void );
  82. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  83. void UseMoveDone( void );
  84. void ReturnMoveDone( void );
  85. void OutputMovementComplete(void);
  86. void SetPositionMoveDone(void);
  87. void UpdateSelf( float value, bool bPlaySound );
  88. void PlaySound( void );
  89. void UpdateTarget( float value, CBaseEntity *pActivator );
  90. int DrawDebugTextOverlays(void);
  91. static CMomentaryRotButton *Instance( edict_t *pent ) { return (CMomentaryRotButton *)GetContainingEntity(pent); }
  92. float GetPos(const QAngle &vecAngles);
  93. DECLARE_DATADESC();
  94. virtual void Lock();
  95. virtual void Unlock();
  96. // Input handlers
  97. void InputSetPosition( inputdata_t &inputdata );
  98. void InputSetPositionImmediately( inputdata_t &inputdata );
  99. void InputDisableUpdateTarget( inputdata_t &inputdata );
  100. void InputEnableUpdateTarget( inputdata_t &inputdata );
  101. void InputEnable( inputdata_t &inputdata );
  102. void InputDisable( inputdata_t &inputdata );
  103. virtual void Enable( void );
  104. virtual void Disable( void );
  105. bool m_bDisabled;
  106. COutputFloat m_Position;
  107. COutputEvent m_OnUnpressed;
  108. COutputEvent m_OnFullyOpen;
  109. COutputEvent m_OnFullyClosed;
  110. COutputEvent m_OnReachedPosition;
  111. int m_lastUsed;
  112. QAngle m_start;
  113. QAngle m_end;
  114. float m_IdealYaw;
  115. string_t m_sNoise;
  116. bool m_bUpdateTarget; // Used when jiggling so that we don't jiggle the target (door, etc)
  117. int m_direction;
  118. float m_returnSpeed;
  119. float m_flStartPosition;
  120. protected:
  121. void UpdateThink( void );
  122. };
  123. #endif // BUTTONS_H