CBank.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * CBank.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. struct BankConfig;
  14. class CBankInstanceConstructor;
  15. class DLL_LINKAGE CBank : public CArmedInstance
  16. {
  17. std::unique_ptr<BankConfig> bankConfig;
  18. ui32 daycounter;
  19. ui32 resetDuration;
  20. bool coastVisitable;
  21. bool regularUnitPlacement;
  22. void setPropertyDer(ObjProperty what, ObjPropertyID identifier) override;
  23. void doVisit(const CGHeroInstance * hero) const;
  24. public:
  25. CBank(IGameCallback *cb);
  26. ~CBank() override;
  27. void setConfig(const BankConfig & bc);
  28. void initObj(vstd::RNG & rand) override;
  29. std::string getHoverText(PlayerColor player) const override;
  30. void newTurn(vstd::RNG & rand) const override;
  31. bool wasVisited (PlayerColor player) const override;
  32. bool isCoastVisitable() const override;
  33. void onHeroVisit(const CGHeroInstance * h) const override;
  34. void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
  35. void blockingDialogAnswered(const CGHeroInstance *hero, int32_t answer) const override;
  36. std::vector<Component> getPopupComponents(PlayerColor player) const override;
  37. template <typename Handler> void serialize(Handler &h)
  38. {
  39. h & static_cast<CArmedInstance&>(*this);
  40. h & daycounter;
  41. h & bankConfig;
  42. h & resetDuration;
  43. h & coastVisitable;
  44. if (h.version >= Handler::Version::BANK_UNIT_PLACEMENT)
  45. h & regularUnitPlacement;
  46. else if (!h.saving)
  47. regularUnitPlacement = false;
  48. }
  49. friend class CBankInstanceConstructor;
  50. };
  51. VCMI_LIB_NAMESPACE_END