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.

141 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef WEAPON_PORTALGUN_H
  7. #define WEAPON_PORTALGUN_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "weapon_portalbasecombatweapon.h"
  12. #include "prop_portal.h"
  13. class CWeaponPortalgun : public CBasePortalCombatWeapon
  14. {
  15. DECLARE_DATADESC();
  16. public:
  17. DECLARE_CLASS( CWeaponPortalgun, CBasePortalCombatWeapon );
  18. DECLARE_NETWORKCLASS();
  19. DECLARE_PREDICTABLE();
  20. private:
  21. CNetworkVar( bool, m_bCanFirePortal1 ); // Is able to use primary fire
  22. CNetworkVar( bool, m_bCanFirePortal2 ); // Is able to use secondary fire
  23. CNetworkVar( int, m_iLastFiredPortal ); // Which portal was placed last
  24. CNetworkVar( bool, m_bOpenProngs ); // Which portal was placed last
  25. CNetworkVar( float, m_fCanPlacePortal1OnThisSurface ); // Tells the gun if it can place on the surface it's pointing at
  26. CNetworkVar( float, m_fCanPlacePortal2OnThisSurface ); // Tells the gun if it can place on the surface it's pointing at
  27. public:
  28. unsigned char m_iPortalLinkageGroupID; //which portal linkage group this gun is tied to, usually set by mapper, or inherited from owning player's index
  29. // HACK HACK! Used to make the gun visually change when going through a cleanser!
  30. CNetworkVar( float, m_fEffectsMaxSize1 );
  31. CNetworkVar( float, m_fEffectsMaxSize2 );
  32. public:
  33. virtual const Vector& GetBulletSpread( void )
  34. {
  35. static Vector cone = VECTOR_CONE_10DEGREES;
  36. return cone;
  37. }
  38. virtual void Precache ( void );
  39. virtual void CreateSounds( void );
  40. virtual void StopLoopingSounds( void );
  41. virtual void OnRestore( void );
  42. virtual void UpdateOnRemove( void );
  43. void Spawn( void );
  44. virtual void Activate();
  45. void DoEffectBlast( bool bPortal2, int iPlacedBy, const Vector &ptStart, const Vector &ptFinalPos, const QAngle &qStartAngles, float fDelay );
  46. virtual void OnPickedUp( CBaseCombatCharacter *pNewOwner );
  47. virtual bool ShouldDrawCrosshair( void );
  48. float GetPortal1Placablity( void ) { return m_fCanPlacePortal1OnThisSurface; }
  49. float GetPortal2Placablity( void ) { return m_fCanPlacePortal2OnThisSurface; }
  50. void SetLastFiredPortal( int iLastFiredPortal ) { m_iLastFiredPortal = iLastFiredPortal; }
  51. int GetLastFiredPortal( void ) { return m_iLastFiredPortal; }
  52. bool Reload( void );
  53. void FillClip( void );
  54. void CheckHolsterReload( void );
  55. void ItemHolsterFrame( void );
  56. bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL );
  57. bool Deploy( void );
  58. void SetCanFirePortal1( bool bCanFire = true );
  59. void SetCanFirePortal2( bool bCanFire = true );
  60. float CanFirePortal1( void ) { return m_bCanFirePortal1; }
  61. float CanFirePortal2( void ) { return m_bCanFirePortal2; }
  62. void PrimaryAttack( void );
  63. void SecondaryAttack( void );
  64. void DelayAttack( float fDelay );
  65. virtual bool PreThink( void );
  66. virtual void Think( void );
  67. void OpenProngs( bool bOpenProngs );
  68. void InputChargePortal1( inputdata_t &inputdata );
  69. void InputChargePortal2( inputdata_t &inputdata );
  70. void FirePortal1( inputdata_t &inputdata );
  71. void FirePortal2( inputdata_t &inputdata );
  72. void FirePortalDirection1( inputdata_t &inputdata );
  73. void FirePortalDirection2( inputdata_t &inputdata );
  74. float TraceFirePortal( bool bPortal2, const Vector &vTraceStart, const Vector &vDirection, trace_t &tr, Vector &vFinalPosition, QAngle &qFinalAngles, int iPlacedBy, bool bTest = false );
  75. float FirePortal( bool bPortal2, Vector *pVector = 0, bool bTest = false );
  76. CSoundPatch *m_pMiniGravHoldSound;
  77. // Outputs for portalgun
  78. COutputEvent m_OnFiredPortal1; // Fires when the gun's first (blue) portal is fired
  79. COutputEvent m_OnFiredPortal2; // Fires when the gun's second (red) portal is fired
  80. void DryFire( void );
  81. virtual float GetFireRate( void ) { return 0.7; };
  82. void WeaponIdle( void );
  83. PortalWeaponID GetWeaponID( void ) const { return WEAPON_PORTALGUN; }
  84. protected:
  85. void StartEffects( void ); // Initialize all sprites and beams
  86. void StopEffects( bool stopSound = true ); // Hide all effects temporarily
  87. void DestroyEffects( void ); // Destroy all sprites and beams
  88. // Portalgun effects
  89. void DoEffect( int effectType, Vector *pos = NULL );
  90. void DoEffectClosed( void );
  91. void DoEffectReady( void );
  92. void DoEffectHolding( void );
  93. void DoEffectNone( void );
  94. CNetworkVar( int, m_EffectState ); // Current state of the effects on the gun
  95. public:
  96. DECLARE_ACTTABLE();
  97. CWeaponPortalgun(void);
  98. private:
  99. CWeaponPortalgun( const CWeaponPortalgun & );
  100. };
  101. #endif // WEAPON_PORTALGUN_H