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.

131 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_POWERUP_BOTTLE_H
  7. #define TF_POWERUP_BOTTLE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_shareddefs.h"
  12. #include "tf_item_wearable.h"
  13. #if defined( CLIENT_DLL )
  14. #define CTFPowerupBottle C_TFPowerupBottle
  15. #include "econ_notifications.h"
  16. #endif
  17. class CTFPowerupBottle : public CTFWearable
  18. {
  19. DECLARE_CLASS( CTFPowerupBottle, CTFWearable );
  20. public:
  21. DECLARE_NETWORKCLASS();
  22. DECLARE_DATADESC();
  23. CTFPowerupBottle();
  24. virtual ~CTFPowerupBottle() { }
  25. PowerupBottleType_t GetPowerupType( void ) const;
  26. virtual void Precache( void );
  27. // reset the bottle to its initial state
  28. void Reset( void );
  29. // Unequips the item as usual, but also removes any effect it may have been granting
  30. virtual void UnEquip( CBasePlayer* pOwner );
  31. // Overridden so that this item can apply the effect only when it is active
  32. virtual void ReapplyProvision();
  33. // @return true if the effect was applied and a charge was consumed, false otherwise
  34. bool Use();
  35. // Remove the effect applied by the item
  36. void RemoveEffect();
  37. // set the number of charges availabe on this item
  38. // @param usNumCharges
  39. void SetNumCharges( uint8 usNumCharges );
  40. // @return the number of charges the item has
  41. uint8 GetNumCharges() const;
  42. // @return the maximum number of charges this item can hold
  43. uint8 GetMaxNumCharges() const;
  44. bool AllowedToUse();
  45. const char* GetEffectLabelText( void );
  46. const char* GetEffectIconName( void );
  47. float GetProgress( void ) { return 0.0f; }
  48. virtual int GetSkin();
  49. bool IsBasePowerUpBottle( void ) const { int iMode = 0; CALL_ATTRIB_HOOK_INT( iMode, set_weapon_mode ); return (iMode == 1); };
  50. protected:
  51. // Used internally to remove the effect after a tunable amount of time
  52. void StatusThink();
  53. CNetworkVar( bool, m_bActive );
  54. CNetworkVar( uint8, m_usNumCharges );
  55. private:
  56. #ifdef TF_CLIENT_DLL
  57. virtual void FireGameEvent( IGameEvent *event );
  58. virtual int GetWorldModelIndex( void );
  59. #endif
  60. float m_flLastSpawnTime;
  61. };
  62. #ifdef CLIENT_DLL
  63. // ******************************************************************************************
  64. // CEquipMvMCanteenNotification - Client notification to equip a canteen
  65. // ******************************************************************************************
  66. class CEquipMvMCanteenNotification : public CEconNotification
  67. {
  68. public:
  69. CEquipMvMCanteenNotification() : CEconNotification()
  70. {
  71. m_bHasTriggered = false;
  72. }
  73. ~CEquipMvMCanteenNotification()
  74. {
  75. if ( !m_bHasTriggered )
  76. {
  77. m_bHasTriggered = true;
  78. }
  79. }
  80. virtual void MarkForDeletion()
  81. {
  82. m_bHasTriggered = true;
  83. CEconNotification::MarkForDeletion();
  84. }
  85. virtual EType NotificationType() { return eType_AcceptDecline; }
  86. virtual bool BShowInGameElements() const { return true; }
  87. virtual void Accept();
  88. virtual void Trigger() { Accept(); }
  89. virtual void Decline() { MarkForDeletion(); }
  90. virtual void UpdateTick();
  91. static bool IsNotificationType( CEconNotification *pNotification ) { return dynamic_cast<CEquipMvMCanteenNotification *>( pNotification ) != NULL; }
  92. private:
  93. bool m_bHasTriggered;
  94. };
  95. #endif // client
  96. #endif // TF_POWERUP_BOTTLE_H