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

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef FUNC_LADDER_H
  7. #define FUNC_LADDER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #if defined( CLIENT_DLL )
  12. #define CFuncLadder C_FuncLadder
  13. #define CInfoLadderDismount C_InfoLadderDismount
  14. #endif
  15. class CInfoLadderDismount : public CBaseEntity
  16. {
  17. public:
  18. DECLARE_CLASS( CInfoLadderDismount, CBaseEntity );
  19. DECLARE_NETWORKCLASS();
  20. virtual void DrawDebugGeometryOverlays();
  21. };
  22. typedef CHandle< CInfoLadderDismount > CInfoLadderDismountHandle;
  23. // Spawnflags
  24. #define SF_LADDER_DONTGETON 1 // Set for ladders that are acting as automount points, but not really ladders
  25. //-----------------------------------------------------------------------------
  26. // Purpose: A player-climbable ladder
  27. //-----------------------------------------------------------------------------
  28. class CFuncLadder : public CBaseEntity
  29. {
  30. public:
  31. DECLARE_CLASS( CFuncLadder, CBaseEntity );
  32. DECLARE_NETWORKCLASS();
  33. DECLARE_DATADESC();
  34. CFuncLadder();
  35. ~CFuncLadder();
  36. virtual void Spawn();
  37. virtual void DrawDebugGeometryOverlays(void);
  38. int GetDismountCount() const;
  39. CInfoLadderDismount *GetDismount( int index );
  40. void GetTopPosition( Vector& org );
  41. void GetBottomPosition( Vector& org );
  42. void ComputeLadderDir( Vector& bottomToTopVec );
  43. void SetEndPoints( const Vector& p1, const Vector& p2 );
  44. void InputEnable( inputdata_t &inputdata );
  45. void InputDisable( inputdata_t &inputdata );
  46. bool IsEnabled() const;
  47. void PlayerGotOn( CBasePlayer *pPlayer );
  48. void PlayerGotOff( CBasePlayer *pPlayer );
  49. virtual void Activate();
  50. bool DontGetOnLadder( void ) const;
  51. static int GetLadderCount();
  52. static CFuncLadder *GetLadder( int index );
  53. static CUtlVector< CFuncLadder * > s_Ladders;
  54. public:
  55. void FindNearbyDismountPoints( const Vector& origin, float radius, CUtlVector< CInfoLadderDismountHandle >& list );
  56. const char *GetSurfacePropName();
  57. private:
  58. void SearchForDismountPoints();
  59. // Movement vector from "bottom" to "top" of ladder
  60. CNetworkVector( m_vecLadderDir );
  61. // Dismount points near top/bottom of ladder, precomputed
  62. CUtlVector< CInfoLadderDismountHandle > m_Dismounts;
  63. // Endpoints for checking for mount/dismount
  64. CNetworkVector( m_vecPlayerMountPositionTop );
  65. CNetworkVector( m_vecPlayerMountPositionBottom );
  66. bool m_bDisabled;
  67. CNetworkVar( bool, m_bFakeLadder );
  68. #if defined( GAME_DLL )
  69. string_t m_surfacePropName;
  70. //-----------------------------------------------------
  71. // Outputs
  72. //-----------------------------------------------------
  73. COutputEvent m_OnPlayerGotOnLadder;
  74. COutputEvent m_OnPlayerGotOffLadder;
  75. virtual int UpdateTransmitState();
  76. #endif
  77. };
  78. inline bool CFuncLadder::IsEnabled() const
  79. {
  80. return !m_bDisabled;
  81. }
  82. const char *FuncLadder_GetSurfaceprops(CBaseEntity *pLadderEntity);
  83. #endif // FUNC_LADDER_H