ExperienceTracker.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: ExperienceTracker.h //////////////////////////////////////////////////////////////////////
  24. // Author: Graham Smallwood, February 2002
  25. // Desc: Keeps track of experience points so Veterance levels can be gained
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef EXPERIENCE_TRACKER_H
  29. #define EXPERIENCE_TRACKER_H
  30. #include "Common/GameCommon.h"
  31. #include "Common/GameType.h"
  32. #include "Common/GameMemory.h"
  33. #include "Common/Snapshot.h"
  34. class Object;
  35. class ExperienceTracker : public MemoryPoolObject, public Snapshot
  36. {
  37. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ExperienceTracker, "ExperienceTrackerPool" )
  38. public:
  39. ExperienceTracker(Object *parent);
  40. VeterancyLevel getVeterancyLevel() const { return m_currentLevel; } ///< What level am I?
  41. Int getExperienceValue( const Object* killer ) const; ///< How much do give for being killed
  42. Int getCurrentExperience( void ) const { return m_currentExperience; }; ///< How much experience do I have at the moment?
  43. Bool isTrainable() const; ///< Can I gain experience?
  44. Bool isAcceptingExperiencePoints() const; ///< Either I am trainable, or I have a Sink set up
  45. void setVeterancyLevel( VeterancyLevel newLevel ); ///< Set Level to this
  46. void setMinVeterancyLevel( VeterancyLevel newLevel ); ///< Set Level to AT LEAST this... if we are already >= this level, do nothing.
  47. void addExperiencePoints( Int experienceGain, Bool canScaleForBonus = TRUE ); ///< Gain this many exp.
  48. Bool gainExpForLevel(Int levelsToGain, Bool canScaleForBonus = TRUE ); ///< Gain enough exp to gain a level. return false if can't gain a level.
  49. Bool canGainExpForLevel(Int levelsToGain) const; ///< return same value as gainExpForLevel, but don't change anything
  50. void setExperienceAndLevel(Int experienceIn);
  51. void setExperienceSink( ObjectID sink ); ///< My experience actually goes to this person (loose couple)
  52. Real getExperienceScalar() const { return m_experienceScalar; }
  53. void setExperienceScalar( Real scalar ) { m_experienceScalar = scalar; }
  54. // --------------- inherited from Snapshot interface --------------
  55. void crc( Xfer *xfer );
  56. void xfer( Xfer *xfer );
  57. void loadPostProcess( void );
  58. private:
  59. Object* m_parent; ///< Object I am owned by
  60. VeterancyLevel m_currentLevel; ///< Level of experience
  61. Int m_currentExperience; ///< Number of experience points
  62. ObjectID m_experienceSink; ///< ID of object I have pledged my experience point gains to
  63. Real m_experienceScalar; ///< Scales any experience gained by this multiplier.
  64. };
  65. #endif