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.

85 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "damagemodifier.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. //-----------------------------------------------------------------------------
  12. // Purpose:
  13. //-----------------------------------------------------------------------------
  14. CDamageModifier::CDamageModifier()
  15. {
  16. m_flModifier = 1;
  17. m_bDoneToMe = false;
  18. }
  19. //-----------------------------------------------------------------------------
  20. // Purpose:
  21. //-----------------------------------------------------------------------------
  22. void CDamageModifier::AddModifierToEntity( CBaseEntity *pEntity )
  23. {
  24. RemoveModifier();
  25. pEntity->m_DamageModifiers.AddToTail( this );
  26. m_hEnt = pEntity;
  27. }
  28. //-----------------------------------------------------------------------------
  29. // Purpose:
  30. //-----------------------------------------------------------------------------
  31. void CDamageModifier::RemoveModifier()
  32. {
  33. if ( m_hEnt.Get() )
  34. {
  35. m_hEnt->m_DamageModifiers.FindAndRemove( this );
  36. m_hEnt = 0;
  37. }
  38. }
  39. //-----------------------------------------------------------------------------
  40. // Purpose:
  41. //-----------------------------------------------------------------------------
  42. void CDamageModifier::SetModifier( float flScale )
  43. {
  44. m_flModifier = flScale;
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Purpose:
  48. //-----------------------------------------------------------------------------
  49. float CDamageModifier::GetModifier() const
  50. {
  51. return m_flModifier;
  52. }
  53. //-----------------------------------------------------------------------------
  54. // Purpose:
  55. //-----------------------------------------------------------------------------
  56. CBaseEntity* CDamageModifier::GetCharacter() const
  57. {
  58. return m_hEnt.Get();
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Purpose:
  62. //-----------------------------------------------------------------------------
  63. void CDamageModifier::SetDoneToMe( bool bDoneToMe )
  64. {
  65. m_bDoneToMe = bDoneToMe;
  66. }
  67. //-----------------------------------------------------------------------------
  68. // Purpose:
  69. //-----------------------------------------------------------------------------
  70. bool CDamageModifier::IsDamageDoneToMe() const
  71. {
  72. return m_bDoneToMe;
  73. }