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.

150 lines
4.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_WEAPON_PASSTIME_GUN_H
  8. #define TF_WEAPON_PASSTIME_GUN_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tf_weaponbase.h"
  13. class CPasstimeBall;
  14. #ifdef CLIENT_DLL
  15. #define CPasstimeBall C_PasstimeBall
  16. #define CPasstimeGun C_PasstimeGun
  17. class C_PasstimeBounceReticle;
  18. #else
  19. #include "passtime_ballcontroller_homing.h"
  20. #endif
  21. //-----------------------------------------------------------------------------
  22. class CPasstimeGun : public CTFWeaponBase, public ITFChargeUpWeapon
  23. {
  24. DECLARE_CLASS( CPasstimeGun, CTFWeaponBase );
  25. DECLARE_NETWORKCLASS();
  26. DECLARE_PREDICTABLE(); // this has to be here because the client's precache code uses it to get the classname of this entity...
  27. public:
  28. CPasstimeGun();
  29. ~CPasstimeGun();
  30. virtual float GetChargeBeginTime() OVERRIDE;
  31. virtual float GetCurrentCharge() OVERRIDE;
  32. static bool BValidPassTarget( CTFPlayer *pSource, CTFPlayer *pTarget, HudNotification_t *pReason = 0 );
  33. struct LaunchParams
  34. {
  35. Vector eyePos;
  36. Vector viewFwd;
  37. Vector viewRight;
  38. Vector viewUp;
  39. Vector traceHullSize;
  40. float traceHullDistance;
  41. Vector startPos;
  42. Vector startDir;
  43. Vector startVel;
  44. static LaunchParams Default( CTFPlayer *pPlayer );
  45. };
  46. static LaunchParams CalcLaunch( CTFPlayer *pPlayer, bool bHoming );
  47. protected:
  48. virtual int GetWeaponID() const OVERRIDE { return TF_WEAPON_PASSTIME_GUN; }
  49. virtual void Spawn() OVERRIDE;
  50. virtual void Equip( CBaseCombatCharacter *pOwner ) OVERRIDE;
  51. virtual void Precache() OVERRIDE;
  52. virtual bool CanHolster() const OVERRIDE;
  53. virtual bool Holster( CBaseCombatWeapon *pSwitchingTo ) OVERRIDE;
  54. virtual void WeaponReset() OVERRIDE;
  55. virtual bool CanCharge() OVERRIDE;
  56. virtual float GetChargeMaxTime() OVERRIDE;
  57. virtual void UpdateOnRemove() OVERRIDE;
  58. virtual bool VisibleInWeaponSelection() OVERRIDE;
  59. virtual acttable_t* ActivityList(int &iActivityCount) OVERRIDE;
  60. virtual void ItemPostFrame() OVERRIDE;
  61. virtual void ItemHolsterFrame() OVERRIDE;
  62. virtual bool Deploy() OVERRIDE;
  63. virtual bool CanDeploy() OVERRIDE;
  64. virtual const char *GetWorldModel() const OVERRIDE;
  65. virtual bool SendWeaponAnim( int actBase ) OVERRIDE;
  66. virtual Activity GetDrawActivity() OVERRIDE { return ACT_BALL_VM_CATCH; }
  67. // HasPrimaryAmmo, CanBeSelected, IsEnergyWeapon:
  68. // these exist to make other code have correct side-effects
  69. // search for where these are called to see the specifics.
  70. virtual bool HasPrimaryAmmo() OVERRIDE { return true; }
  71. virtual bool CanBeSelected() OVERRIDE { return true; }
  72. virtual bool IsEnergyWeapon() const OVERRIDE { return true; }
  73. #ifdef CLIENT_DLL
  74. virtual void UpdateAttachmentModels() OVERRIDE;
  75. virtual void ClientThink() OVERRIDE;
  76. void UpdateThrowArch();
  77. void DestroyThrowArch();
  78. C_PasstimeBounceReticle *m_pBounceReticle;
  79. #endif
  80. void Throw( CTFPlayer *pOwner );
  81. enum EThrowState
  82. {
  83. THROWSTATE_IDLE,
  84. THROWSTATE_CHARGING,
  85. THROWSTATE_CHARGED,
  86. THROWSTATE_THROWN,
  87. THROWSTATE_CANCELLED,
  88. THROWSTATE_DISABLED,
  89. };
  90. enum EButtonState
  91. {
  92. BUTTONSTATE_UP, // not pressed
  93. BUTTONSTATE_PRESSED, // was just pressed and is down
  94. BUTTONSTATE_DOWN, // continues to be down
  95. BUTTONSTATE_RELEASED, // was just released and is not down
  96. BUTTONSTATE_DISABLED, // ignore input
  97. };
  98. struct AttackInputState
  99. {
  100. AttackInputState( int button )
  101. : iButton( button ), eButtonState( BUTTONSTATE_UP )
  102. , bLatchedUp( false )
  103. {}
  104. const int iButton;
  105. EButtonState eButtonState;
  106. bool bLatchedUp;
  107. bool Is( EButtonState state ) const { return eButtonState == state; }
  108. void Disable() { eButtonState = BUTTONSTATE_DISABLED; }
  109. void Enable()
  110. {
  111. if ( eButtonState == BUTTONSTATE_DISABLED )
  112. eButtonState = BUTTONSTATE_UP;
  113. }
  114. void Update( int held, int pressed, int released );
  115. void LatchUp();
  116. void UnlatchUp();
  117. };
  118. int m_iHalloweenAttachmentIndex;
  119. int m_iAttachmentIndex;
  120. float m_flTargetResetTime;
  121. float m_flThrowLoopStartTime;
  122. AttackInputState m_attack, m_attack2;
  123. CNetworkVar( EThrowState, m_eThrowState );
  124. CNetworkVar( float, m_fChargeBeginTime );
  125. CHandle<CBaseCombatWeapon> m_hStoredLastWpn;
  126. #ifdef GAME_DLL
  127. CPasstimeBallControllerHoming m_ballController;
  128. #endif
  129. };
  130. #endif // TF_WEAPON_PASSTIME_GUN_H