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.

64 lines
1.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "tf_wearable_levelable_item.h"
  8. #ifdef CLIENT_DLL
  9. #include "c_tf_player.h"
  10. #else
  11. #include "tf_player.h"
  12. #endif
  13. LINK_ENTITY_TO_CLASS( tf_wearable_levelable_item, CTFWearableLevelableItem );
  14. IMPLEMENT_NETWORKCLASS_ALIASED( TFWearableLevelableItem, DT_TFWearableLevelableItem )
  15. BEGIN_NETWORK_TABLE( CTFWearableLevelableItem, DT_TFWearableLevelableItem )
  16. #if defined( CLIENT_DLL )
  17. RecvPropInt( RECVINFO( m_unLevel ) ),
  18. #else
  19. SendPropInt( SENDINFO( m_unLevel ), -1, SPROP_VARINT | SPROP_UNSIGNED ),
  20. #endif
  21. END_NETWORK_TABLE()
  22. BEGIN_DATADESC( CTFWearableLevelableItem )
  23. END_DATADESC()
  24. CTFWearableLevelableItem::CTFWearableLevelableItem()
  25. {
  26. m_unLevel = 0;
  27. }
  28. void CTFWearableLevelableItem::IncrementLevel()
  29. {
  30. int nBodyGroup = FindBodygroupByName( LEVELABLE_ITEM_BODYGROUP_NAME );
  31. if ( nBodyGroup == -1 )
  32. {
  33. AssertMsg( 0, "This model needs a bodygroup called \"level\"\n" );
  34. return;
  35. }
  36. if ( m_unLevel < (uint)GetBodygroupCount(nBodyGroup) - 1 )
  37. {
  38. m_unLevel++;
  39. SetBodygroup( nBodyGroup, m_unLevel );
  40. }
  41. }
  42. void CTFWearableLevelableItem::ResetLevel()
  43. {
  44. int nBodyGroup = FindBodygroupByName( LEVELABLE_ITEM_BODYGROUP_NAME );
  45. if ( nBodyGroup == -1 )
  46. {
  47. AssertMsg( 0, "This model needs a bodygroup called \"level\"\n" );
  48. return;
  49. }
  50. m_unLevel = 0;
  51. SetBodygroup( nBodyGroup, m_unLevel );
  52. }