CGResource.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * CGResource.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "CArmedInstance.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class ResourceInstanceConstructor;
  14. class DLL_LINKAGE CGResource : public CArmedInstance
  15. {
  16. friend class Inspector;
  17. friend class CMapLoaderH3M;
  18. friend class ResourceInstanceConstructor;
  19. MetaString message;
  20. static constexpr uint32_t RANDOM_AMOUNT = 0;
  21. uint32_t amount = RANDOM_AMOUNT; //0 if random
  22. std::shared_ptr<ResourceInstanceConstructor> getResourceHandler() const;
  23. int getAmountMultiplier() const;
  24. void collectRes(const PlayerColor & player) const;
  25. void serializeJsonOptions(JsonSerializeFormat & handler) override;
  26. public:
  27. using CArmedInstance::CArmedInstance;
  28. void onHeroVisit(const CGHeroInstance * h) const override;
  29. void initObj(vstd::RNG & rand) override;
  30. void pickRandomObject(vstd::RNG & rand) override;
  31. void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
  32. void blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const override;
  33. std::string getHoverText(PlayerColor player) const override;
  34. GameResID resourceID() const;
  35. uint32_t getAmount() const;
  36. template <typename Handler> void serialize(Handler &h)
  37. {
  38. h & static_cast<CArmedInstance&>(*this);
  39. h & amount;
  40. h & message;
  41. }
  42. };
  43. VCMI_LIB_NAMESPACE_END