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.

129 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_PASSTIME_BALL_H
  8. #define TF_PASSTIME_BALL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "passtime_ballcontroller_playerseek.h"
  13. #include "predictable_entity.h"
  14. #include "util_shared.h"
  15. #include "baseanimating.h"
  16. #include "utllinkedlist.h"
  17. class CSpriteTrail;
  18. class CBallPlayerToucher;
  19. //-----------------------------------------------------------------------------
  20. class CPasstimeBall : public CBaseAnimating
  21. {
  22. public:
  23. DECLARE_CLASS( CPasstimeBall, CBaseAnimating );
  24. DECLARE_NETWORKCLASS();
  25. CPasstimeBall();
  26. ~CPasstimeBall();
  27. virtual void Spawn() OVERRIDE;
  28. virtual void Precache() OVERRIDE;
  29. virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent ) OVERRIDE;
  30. virtual int OnTakeDamage( const CTakeDamageInfo &info ) OVERRIDE;
  31. virtual unsigned int PhysicsSolidMaskForEntity() const OVERRIDE;
  32. virtual void ChangeTeam( int iTeamNum ) OVERRIDE;
  33. virtual bool IsDeflectable() OVERRIDE;
  34. virtual void Deflected( CBaseEntity *pDeflectedBy, Vector& vecDir ) OVERRIDE;
  35. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const OVERRIDE;
  36. virtual int UpdateTransmitState() OVERRIDE;
  37. CTFPlayer *GetCarrier() const;
  38. CTFPlayer *GetPrevCarrier() const;
  39. CTFPlayer *GetThrower() const;
  40. int GetCollisionCount() const;
  41. int GetCarryDuration() const;
  42. void ResetTrail();
  43. void HideTrail();
  44. void MoveTo( const Vector &pos, const Vector &vel );
  45. void MoveToSpawner( const Vector &pos );
  46. void SetStateOutOfPlay();
  47. void SetStateFree();
  48. void SetStateCarried( CTFPlayer *pCarrier );
  49. bool BOutOfPlay() const;
  50. static CPasstimeBall *Create( Vector position, QAngle angles );
  51. void SetHomingTarget( CTFPlayer *pPlayer );
  52. CTFPlayer *GetHomingTarget() const;
  53. float GetAirtimeSec() const;
  54. float GetAirtimeDistance() const;
  55. void StartLagCompensation( CBasePlayer *player, CUserCmd *cmd );
  56. void FinishLagCompensation( CBasePlayer *player );
  57. private:
  58. friend class CBallPlayerToucher;
  59. void OnTouch( CBaseEntity *pOther );
  60. void DefaultThink();
  61. void TouchPlayer( CTFPlayer *pPlayer );
  62. void BlockReflect( CTFPlayer *pPlayer, const Vector& origin, const Vector& ballvel );
  63. void BlockDamage( CTFPlayer *pPlayer, const Vector& ballvel );
  64. bool BIgnorePlayer( CTFPlayer *pPlayer );
  65. void OnCollision();
  66. void UpdateLagCompensationHistory();
  67. void SetThrower( CTFPlayer *pPlayer );
  68. void OnBecomeNotCarried();
  69. void SetIdleRespawnTime();
  70. void DisableIdleRespawnTime();
  71. bool BShouldPanicRespawn() const;
  72. bool CreateModelCollider();
  73. void CreateSphereCollider();
  74. enum EState
  75. {
  76. STATE_OUT_OF_PLAY,
  77. STATE_FREE,
  78. STATE_CARRIED
  79. };
  80. EState m_eState;
  81. CHandle<CTFPlayer> m_hThrower;
  82. EHANDLE m_hBlocker;
  83. CSpriteTrail *m_pTrail;
  84. bool m_bTrailActive;
  85. bool m_bLeftOwner;
  86. CSoundPatch *m_pHumLoop;
  87. CSoundPatch *m_pBeepLoop;
  88. CBaseEntity *m_pPlayerToucher;
  89. CPasstimeBallControllerPlayerSeek m_playerSeek;
  90. bool m_bTouchedSinceSpawn;
  91. float m_flLastCollisionTime;
  92. float m_flAirtimeDistance;
  93. Vector m_vecPrevOrigin; // note: C_BaseEntity has m_vecOldOrigin in client code only
  94. float m_flLastTeamChangeTime; // for stats
  95. float m_flBeginCarryTime;
  96. float m_flIdleRespawnTime;
  97. struct LagRecord
  98. {
  99. float flSimulationTime;
  100. Vector vecOrigin;
  101. };
  102. CUtlFixedLinkedList<LagRecord> m_lagCompensationHistory;
  103. LagRecord m_lagCompensationRestore;
  104. bool m_bLagCompensationNeedsRestore;
  105. float m_flLagCompensationTeleportDistanceSqr;
  106. CNetworkVar( int, m_iCollisionCount );
  107. CNetworkHandle( CTFPlayer, m_hHomingTarget );
  108. CNetworkHandle( CTFPlayer, m_hCarrier );
  109. CNetworkHandle( CTFPlayer, m_hPrevCarrier );
  110. };
  111. #endif // TF_PASSTIME_BALL_H