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.

152 lines
5.0 KiB

  1. // func_elevator.h
  2. // Copyright 2007 Turtle Rock Studios, Inc.
  3. #ifndef FUNC_ELEVATOR_H
  4. #define FUNC_ELEVATOR_H
  5. #include "basetoggle.h"
  6. #include "utlmap.h"
  7. //--------------------------------------------------------------------------------------------------------
  8. class CInfoElevatorFloor : public CPointEntity
  9. {
  10. public:
  11. DECLARE_CLASS( CInfoElevatorFloor, CPointEntity );
  12. DECLARE_DATADESC();
  13. void OnReachedFloor( CBaseEntity *elevator );
  14. COutputEvent m_OnReachedFloor;
  15. };
  16. //--------------------------------------------------------------------------------------------------------
  17. struct FloorInfo
  18. {
  19. float height; // Height of this floor
  20. string_t name; // Name of this floor
  21. EHANDLE button; // Button that moves the elevator to this floor
  22. };
  23. //--------------------------------------------------------------------------------------------------------
  24. class CFuncElevator : public CBaseToggle
  25. {
  26. public:
  27. DECLARE_CLASS( CFuncElevator, CBaseToggle );
  28. DECLARE_SERVERCLASS();
  29. DECLARE_DATADESC();
  30. IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_vecVelocity );
  31. IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_fFlags );
  32. CFuncElevator();
  33. virtual void Spawn( void );
  34. virtual void Precache( void );
  35. virtual bool CreateVPhysics( void );
  36. virtual int DrawDebugTextOverlays( void );
  37. // FIXMEL4DTOMAINMERGE
  38. // virtual void PhysicsSimulate( void );
  39. virtual void MoveDone( void );
  40. virtual void Blocked( CBaseEntity *pOther );
  41. int GetNumFloors( void ) const; // Returns the number of floors at which this elevator can stop
  42. const FloorInfo *GetFloor( int floorNumber ) const; // Returns a FloorInfo * for the given floor
  43. int GetCurrentFloor( void ) const; // Returns the current floor, or -1 if the elevator is in-between floors
  44. int GetDestinationFloor( void ) const; // Returns the floor to which the elevator is moving, or the current floor number if the elevator is stopped
  45. float GetCurrentSpeed( void ) const; // Returns the z velocity of the elevator, or 0 if the elevator is stopped
  46. int GetFloorForHeight( float height ) const; // Returns the floor nearest the given height, or -1 if no floor is nearby
  47. EHANDLE GetButtonForHeight( float height ) const; // Returns a button near the current floor height that drives the elevator to the given height
  48. EHANDLE GetButtonAtCurrentHeight( void ) const; // Returns a button near the current floor that drives the elevator to *ANY* other height
  49. bool IsEnabled( void ) const; // Returns true if the elevator can be moved by buttons etc
  50. bool IsMoving( void ) const; // Returns true if the elevator is in motion
  51. void FindPlayersOnElevator( CUtlVector< CBasePlayer * > *players, int teamNumber = TEAM_UNASSIGNED ); // Fills in a vector of players on the elevator
  52. bool IsPlayerOnElevator( CBasePlayer *player ); // Returns true if a player is on the elevator
  53. float GetCurrentHeight( void );
  54. private:
  55. void MoveTo( float destinationZ );
  56. void StopMoveSoundThink( void );
  57. void AccelerationThink( void );
  58. // Input handlers
  59. void InputMoveToFloor( inputdata_t &inputdata ); // Start the brush moving to the specified floor
  60. void InputDisable( inputdata_t &inputdata ); // Prevent the elevator from moving again
  61. string_t m_soundStart; // start and looping sound
  62. string_t m_soundStop; // stop sound
  63. string_t m_soundDisable; // disable sound
  64. string_t m_currentSound; // sound I'm playing
  65. float m_flBlockDamage; // Damage inflicted when blocked.
  66. Vector m_topFloorPosition;
  67. Vector m_bottomFloorPosition;
  68. CNetworkVar( float, m_maxSpeed );
  69. CNetworkVar( float, m_currentSpeed );
  70. CNetworkVar( float, m_acceleration );
  71. IntervalTimer m_accelerationTimer;
  72. CNetworkVar( float, m_movementStartTime );
  73. CNetworkVar( float, m_movementStartSpeed );
  74. CNetworkVar( float, m_movementStartZ );
  75. CNetworkVar( float, m_destinationFloorPosition );
  76. CNetworkVar( bool, m_isMoving );
  77. EHANDLE m_targetFloor;
  78. bool m_enabled;
  79. // Outputs
  80. COutputEvent m_OnReachedTop;
  81. COutputEvent m_OnReachedBottom;
  82. CUtlVector< FloorInfo > m_floors;
  83. };
  84. //--------------------------------------------------------------------------------------------------------
  85. inline bool CFuncElevator::IsMoving( void ) const
  86. {
  87. return m_isMoving;
  88. }
  89. //--------------------------------------------------------------------------------------------------------
  90. inline int CFuncElevator::GetNumFloors( void ) const
  91. {
  92. return m_floors.Count();
  93. }
  94. //--------------------------------------------------------------------------------------------------------
  95. inline const FloorInfo *CFuncElevator::GetFloor( int floorNumber ) const
  96. {
  97. if ( floorNumber < 0 || floorNumber >= m_floors.Count() )
  98. return NULL;
  99. return &m_floors[ floorNumber ];
  100. }
  101. //--------------------------------------------------------------------------------------------------------
  102. inline float CFuncElevator::GetCurrentSpeed( void ) const
  103. {
  104. return m_currentSpeed;
  105. }
  106. //--------------------------------------------------------------------------------------------------------
  107. inline bool CFuncElevator::IsEnabled( void ) const
  108. {
  109. return m_enabled;
  110. }
  111. #endif // FUNC_ELEVATOR_H