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.

157 lines
5.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DOORS_H
  8. #define DOORS_H
  9. #pragma once
  10. #include "locksounds.h"
  11. #include "entityoutput.h"
  12. //Since I'm here, might as well explain how these work. Base.fgd is the file that connects
  13. //flags to entities. It is full of lines with this number, a label, and a default value.
  14. //Voila, dynamicly generated checkboxes on the Flags tab of Entity Properties.
  15. // doors
  16. #define SF_DOOR_ROTATE_YAW 0 // yaw by default
  17. #define SF_DOOR_START_OPEN_OBSOLETE 1
  18. #define SF_DOOR_ROTATE_BACKWARDS 2
  19. #define SF_DOOR_NONSOLID_TO_PLAYER 4
  20. #define SF_DOOR_PASSABLE 8
  21. #define SF_DOOR_ONEWAY 16
  22. #define SF_DOOR_NO_AUTO_RETURN 32
  23. #define SF_DOOR_ROTATE_ROLL 64
  24. #define SF_DOOR_ROTATE_PITCH 128
  25. #define SF_DOOR_PUSE 256 // door can be opened by player's use button.
  26. #define SF_DOOR_NONPCS 512 // NPC can't open
  27. #define SF_DOOR_PTOUCH 1024 // player touch opens
  28. #define SF_DOOR_LOCKED 2048 // Door is initially locked
  29. #define SF_DOOR_SILENT 4096 // Door plays no audible sound, and does not alert NPCs when opened
  30. #define SF_DOOR_USE_CLOSES 8192 // Door can be +used to close before its autoreturn delay has expired.
  31. #define SF_DOOR_SILENT_TO_NPCS 16384 // Does not alert NPC's when opened.
  32. #define SF_DOOR_IGNORE_USE 32768 // Completely ignores player +use commands.
  33. #define SF_DOOR_NEW_USE_RULES 65536 // For func_door entities, behave more like prop_door_rotating with respect to +USE (changelist 242482)
  34. #define SF_DOOR_START_BREAKABLE 524288
  35. enum FuncDoorSpawnPos_t
  36. {
  37. FUNC_DOOR_SPAWN_CLOSED = 0,
  38. FUNC_DOOR_SPAWN_OPEN,
  39. };
  40. class CBaseDoor : public CBaseToggle
  41. {
  42. public:
  43. DECLARE_CLASS( CBaseDoor, CBaseToggle );
  44. DECLARE_SERVERCLASS();
  45. void Spawn( void );
  46. void Precache( void );
  47. bool CreateVPhysics();
  48. bool KeyValue( const char *szKeyName, const char *szValue );
  49. virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  50. virtual void StartBlocked( CBaseEntity *pOther );
  51. virtual void Blocked( CBaseEntity *pOther );
  52. virtual void EndBlocked( void );
  53. void Activate( void );
  54. virtual int ObjectCaps( void )
  55. {
  56. int flags = BaseClass::ObjectCaps();
  57. if ( HasSpawnFlags( SF_DOOR_PUSE ) )
  58. return flags | FCAP_IMPULSE_USE | FCAP_USE_IN_RADIUS;
  59. return flags;
  60. };
  61. DECLARE_DATADESC();
  62. // This is ONLY used by the node graph to test movement through a door
  63. void InputSetToggleState( inputdata_t &inputdata );
  64. virtual void SetToggleState( int state );
  65. virtual bool IsRotatingDoor() { return false; }
  66. virtual bool ShouldSavePhysics();
  67. // used to selectivly override defaults
  68. void DoorTouch( CBaseEntity *pOther );
  69. // local functions
  70. int DoorActivate( );
  71. void DoorGoUp( void );
  72. void DoorGoDown( void );
  73. void DoorHitTop( void );
  74. void DoorHitBottom( void );
  75. void UpdateAreaPortals( bool isOpen );
  76. void Unlock( void );
  77. void Lock( void );
  78. int GetDoorMovementGroup( CBaseDoor *pDoorList[], int listMax );
  79. // Input handlers
  80. void InputClose( inputdata_t &inputdata );
  81. void InputLock( inputdata_t &inputdata );
  82. void InputOpen( inputdata_t &inputdata );
  83. void InputToggle( inputdata_t &inputdata );
  84. void InputUnlock( inputdata_t &inputdata );
  85. void InputSetSpeed( inputdata_t &inputdata );
  86. Vector m_vecMoveDir; // The direction of motion for linear moving doors.
  87. locksound_t m_ls; // door lock sounds
  88. byte m_bLockedSentence;
  89. byte m_bUnlockedSentence;
  90. bool m_bForceClosed; // If set, always close, even if we're blocked.
  91. bool m_bDoorGroup;
  92. bool m_bLocked; // Whether the door is locked
  93. bool m_bIgnoreDebris;
  94. FuncDoorSpawnPos_t m_eSpawnPosition;
  95. float m_flBlockDamage; // Damage inflicted when blocked.
  96. string_t m_NoiseMoving; //Start/Looping sound
  97. string_t m_NoiseArrived; //End sound
  98. string_t m_NoiseMovingClosed; //Start/Looping sound
  99. string_t m_NoiseArrivedClosed; //End sound
  100. string_t m_ChainTarget; ///< Entity name to pass Touch and Use events to
  101. CNetworkVar( float, m_flWaveHeight );
  102. // Outputs
  103. COutputEvent m_OnBlockedClosing; // Triggered when the door becomes blocked while closing.
  104. COutputEvent m_OnBlockedOpening; // Triggered when the door becomes blocked while opening.
  105. COutputEvent m_OnUnblockedClosing; // Triggered when the door becomes unblocked while closing.
  106. COutputEvent m_OnUnblockedOpening; // Triggered when the door becomes unblocked while opening.
  107. COutputEvent m_OnFullyClosed; // Triggered when the door reaches the fully closed position.
  108. COutputEvent m_OnFullyOpen; // Triggered when the door reaches the fully open position.
  109. COutputEvent m_OnClose; // Triggered when the door is told to close.
  110. COutputEvent m_OnOpen; // Triggered when the door is told to open.
  111. COutputEvent m_OnLockedUse; // Triggered when the user tries to open a locked door.
  112. void StartMovingSound( void );
  113. virtual void StopMovingSound( void );
  114. void MovingSoundThink( void );
  115. bool ShouldLoopMoveSound( void ) { return m_bLoopMoveSound; }
  116. bool m_bLoopMoveSound; // Move sound loops until stopped
  117. private:
  118. void ChainUse( void ); ///< Chains +use on through to m_ChainTarget
  119. void ChainTouch( CBaseEntity *pOther ); ///< Chains touch on through to m_ChainTarget
  120. void SetChaining( bool chaining ) { m_isChaining = chaining; } ///< Latch to prevent recursion
  121. bool m_isChaining;
  122. void CloseAreaPortalsThink( void ); ///< Delays turning off area portals when closing doors to prevent visual artifacts
  123. };
  124. #endif // DOORS_H