Counter Strike : Global Offensive Source Code
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.

86 lines
2.5 KiB

  1. //========= Copyright � 1996-2005, 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. #if defined(ENABLE_DAMAGE_MODIFIERS)
  12. //-----------------------------------------------------------------------------
  13. // Purpose:
  14. //-----------------------------------------------------------------------------
  15. CDamageModifier::CDamageModifier()
  16. {
  17. m_flModifier = 1;
  18. m_bDoneToMe = false;
  19. }
  20. //-----------------------------------------------------------------------------
  21. // Purpose:
  22. //-----------------------------------------------------------------------------
  23. void CDamageModifier::AddModifierToEntity( CBaseEntity *pEntity )
  24. {
  25. RemoveModifier();
  26. pEntity->m_DamageModifiers.AddToTail( this );
  27. m_hEnt = pEntity;
  28. }
  29. //-----------------------------------------------------------------------------
  30. // Purpose:
  31. //-----------------------------------------------------------------------------
  32. void CDamageModifier::RemoveModifier()
  33. {
  34. if ( m_hEnt.Get() )
  35. {
  36. m_hEnt->m_DamageModifiers.FindAndRemove( this );
  37. m_hEnt = 0;
  38. }
  39. }
  40. //-----------------------------------------------------------------------------
  41. // Purpose:
  42. //-----------------------------------------------------------------------------
  43. void CDamageModifier::SetModifier( float flScale )
  44. {
  45. m_flModifier = flScale;
  46. }
  47. //-----------------------------------------------------------------------------
  48. // Purpose:
  49. //-----------------------------------------------------------------------------
  50. float CDamageModifier::GetModifier() const
  51. {
  52. return m_flModifier;
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Purpose:
  56. //-----------------------------------------------------------------------------
  57. CBaseEntity* CDamageModifier::GetCharacter() const
  58. {
  59. return m_hEnt.Get();
  60. }
  61. //-----------------------------------------------------------------------------
  62. // Purpose:
  63. //-----------------------------------------------------------------------------
  64. void CDamageModifier::SetDoneToMe( bool bDoneToMe )
  65. {
  66. m_bDoneToMe = bDoneToMe;
  67. }
  68. //-----------------------------------------------------------------------------
  69. // Purpose:
  70. //-----------------------------------------------------------------------------
  71. bool CDamageModifier::IsDamageDoneToMe() const
  72. {
  73. return m_bDoneToMe;
  74. }
  75. #endif