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.

88 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //
  4. //
  5. //=============================================================================
  6. #ifndef TF_OBJ_SPY_TRAP_H
  7. #define TF_OBJ_SPY_TRAP_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_obj.h"
  12. #ifdef STAGING_ONLY
  13. #define SPY_TRAP_MAX_HEALTH 150
  14. // ------------------------------------------------------------------------ //
  15. // Base trap
  16. // ------------------------------------------------------------------------ //
  17. class CObjectSpyTrap : public CBaseObject
  18. {
  19. DECLARE_CLASS( CObjectSpyTrap, CBaseObject );
  20. DECLARE_DATADESC();
  21. public:
  22. //DECLARE_SERVERCLASS();
  23. CObjectSpyTrap();
  24. virtual void Spawn() OVERRIDE;
  25. virtual void Precache() OVERRIDE;
  26. virtual void SetObjectMode( int iVal ) OVERRIDE;
  27. virtual bool IsPlacementPosValid( void ) OVERRIDE;
  28. virtual void StartTouch( CBaseEntity *pOther ) OVERRIDE;
  29. virtual void EndTouch( CBaseEntity *pOther ) OVERRIDE;
  30. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const OVERRIDE;
  31. virtual void OnGoActive() OVERRIDE;
  32. virtual int GetBaseHealth( void ) OVERRIDE { return SPY_TRAP_MAX_HEALTH; }
  33. void SetTrapType( int nType ) { m_nTrapMode = nType; }
  34. int GetTrapType( void ) { return m_nTrapMode; }
  35. void SpyTrapThink();
  36. enum AttributeType
  37. {
  38. TRAP_TRIGGER_FRIENDLY = 1<<0, // Trap triggered by friendlies (a buff)
  39. TRAP_TRIGGER_ONBUILD = 1<<1, // Trap effect happens on placement
  40. TRAP_PULSE_EFFECT = 1<<2, // Trap's effect pulses on a timer
  41. };
  42. void SetAttribute( int attributeFlag );
  43. bool HasAttribute( int attributeFlag ) const;
  44. private:
  45. void Activate( CBaseEntity *pTouchEntity );
  46. void Destroy( void );
  47. void TriggerTrapEffects( void );
  48. // Sapper
  49. void TriggerTrap_RadiusCloak( void );
  50. bool IsValidRadiusCloakTarget( CTFPlayer *pTarget );
  51. // Reprogrammer
  52. void TriggerTrap_Reprogrammer( CBaseEntity *pTouchEntity );
  53. // Magnet
  54. void TriggerTrap_Magnet( void );
  55. int m_attributeFlags;
  56. bool m_bActive;
  57. int m_nTrapMode;
  58. float m_flNextTrapEffectTime;
  59. float m_flTrapExpireTime;
  60. float m_flNextPulseTime;
  61. };
  62. inline void CObjectSpyTrap::SetAttribute( int attributeFlag )
  63. {
  64. m_attributeFlags |= attributeFlag;
  65. }
  66. inline bool CObjectSpyTrap::HasAttribute( int attributeFlag ) const
  67. {
  68. return m_attributeFlags & attributeFlag ? true : false;
  69. }
  70. #endif // STAGING_ONLY
  71. #endif // TF_OBJ_SPY_TRAP_H