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.

99 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "c_tf_passtime_ball.h"
  9. #include "passtime_convars.h"
  10. #include "tf_shareddefs.h"
  11. #include "c_tf_player.h"
  12. #include "c_playerresource.h"
  13. #include "c_tf_player.h"
  14. #include "tf_gamerules.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. //-----------------------------------------------------------------------------
  18. IMPLEMENT_CLIENTCLASS_DT( C_PasstimeBall, DT_PasstimeBall, CPasstimeBall )
  19. RecvPropInt(RECVINFO(m_iCollisionCount)),
  20. RecvPropEHandle(RECVINFO(m_hHomingTarget)),
  21. RecvPropEHandle(RECVINFO(m_hCarrier)),
  22. RecvPropEHandle(RECVINFO(m_hPrevCarrier)),
  23. END_RECV_TABLE()
  24. //-----------------------------------------------------------------------------
  25. LINK_ENTITY_TO_CLASS( passtime_ball, C_PasstimeBall );
  26. PRECACHE_REGISTER( passtime_ball );
  27. C_TFPlayer *C_PasstimeBall::GetCarrier() { return m_hCarrier.Get(); }
  28. C_TFPlayer *C_PasstimeBall::GetPrevCarrier() { return m_hPrevCarrier.Get(); }
  29. //-----------------------------------------------------------------------------
  30. C_PasstimeBall::C_PasstimeBall()
  31. {
  32. UseClientSideAnimation();
  33. m_fDrawTime = 0.0f;
  34. }
  35. //-----------------------------------------------------------------------------
  36. C_PasstimeBall::~C_PasstimeBall()
  37. {
  38. }
  39. //-----------------------------------------------------------------------------
  40. unsigned int C_PasstimeBall::PhysicsSolidMaskForEntity() const
  41. {
  42. return MASK_PLAYERSOLID; // must match server
  43. }
  44. //-----------------------------------------------------------------------------
  45. bool C_PasstimeBall::ShouldCollide( int collisionGroup, int contentsMask ) const
  46. {
  47. // note: returning false for COLLISION_GROUP_PLAYER_MOVEMENT means the ball won't
  48. // stop player movement. the only real visible effect when this function doesn't
  49. // return false for COLLISION_GROUP_PLAYER_MOVEMENT is that the ball is unable
  50. // to impart physics forces on the ball when the ball is blocked, since the player
  51. // will set velocity to zero due to being "stuck" on the ball, even though the
  52. // ball won't actually prevent the player from moving through it.
  53. return (collisionGroup != COLLISION_GROUP_PLAYER_MOVEMENT);
  54. // && (contentsMask & MASK_SHOT_HULL);
  55. //return BaseClass::ShouldCollide( collisionGroup, contentsMask );
  56. }
  57. //-----------------------------------------------------------------------------
  58. void C_PasstimeBall::OnDataChanged( DataUpdateType_t updateType )
  59. {
  60. BaseClass::OnDataChanged( updateType );
  61. if ( updateType == DATA_UPDATE_CREATED )
  62. {
  63. return;
  64. }
  65. if ( TFGameRules()->IsPasstimeMode() )
  66. {
  67. bool bIsVisible = !(GetEffects() & EF_NODRAW);
  68. if ( bIsVisible && !m_bWasVisible )
  69. {
  70. float nextValidTime = gpGlobals->curtime + 0.1f;
  71. m_fDrawTime = nextValidTime;
  72. }
  73. m_bWasVisible = bIsVisible;
  74. }
  75. }
  76. //-----------------------------------------------------------------------------
  77. int C_PasstimeBall::DrawModel( int flags )
  78. {
  79. if( gpGlobals->curtime < m_fDrawTime )
  80. {
  81. return 0;
  82. }
  83. return BaseClass::DrawModel( flags );
  84. }