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.

94 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "baseprojectile.h"
  9. IMPLEMENT_NETWORKCLASS_ALIASED( BaseProjectile, DT_BaseProjectile )
  10. BEGIN_NETWORK_TABLE( CBaseProjectile, DT_BaseProjectile )
  11. #if !defined( CLIENT_DLL )
  12. SendPropEHandle( SENDINFO( m_hOriginalLauncher ) ),
  13. #else
  14. RecvPropEHandle( RECVINFO( m_hOriginalLauncher ) ),
  15. #endif // CLIENT_DLL
  16. END_NETWORK_TABLE()
  17. #ifndef CLIENT_DLL
  18. IMPLEMENT_AUTO_LIST( IBaseProjectileAutoList );
  19. #endif // !CLIENT_DLL
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Constructor.
  22. //-----------------------------------------------------------------------------
  23. CBaseProjectile::CBaseProjectile()
  24. {
  25. #ifdef GAME_DLL
  26. m_iDestroyableHitCount = 0;
  27. m_bCanCollideWithTeammates = false;
  28. #endif
  29. m_hOriginalLauncher = NULL;
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Purpose:
  33. //-----------------------------------------------------------------------------
  34. void CBaseProjectile::SetLauncher( CBaseEntity *pLauncher )
  35. {
  36. if ( m_hOriginalLauncher == NULL )
  37. {
  38. m_hOriginalLauncher = pLauncher;
  39. }
  40. #ifdef GAME_DLL
  41. ResetCollideWithTeammates();
  42. #endif // GAME_DLL
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. void CBaseProjectile::Spawn()
  48. {
  49. BaseClass::Spawn();
  50. #ifdef GAME_DLL
  51. ResetCollideWithTeammates();
  52. #endif // GAME_DLL
  53. }
  54. #ifdef GAME_DLL
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. //-----------------------------------------------------------------------------
  58. void CBaseProjectile::CollideWithTeammatesThink()
  59. {
  60. m_bCanCollideWithTeammates = true;
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Purpose:
  64. //-----------------------------------------------------------------------------
  65. void CBaseProjectile::ResetCollideWithTeammates()
  66. {
  67. // Don't collide with players on the owner's team for the first bit of our life
  68. m_bCanCollideWithTeammates = false;
  69. SetContextThink( &CBaseProjectile::CollideWithTeammatesThink, gpGlobals->curtime + GetCollideWithTeammatesDelay(), "CollideWithTeammates" );
  70. }
  71. #endif // GAME_DLL