DwellingInstanceConstructor.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * DwellingInstanceConstructor.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 "CDefaultObjectTypeHandler.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class CGDwelling;
  14. class DwellingInstanceConstructor : public CDefaultObjectTypeHandler<CGDwelling>
  15. {
  16. std::vector<std::vector<const CCreature *>> availableCreatures;
  17. JsonNode guards;
  18. protected:
  19. bool objectFilter(const CGObjectInstance * obj, std::shared_ptr<const ObjectTemplate> tmpl) const override;
  20. void initTypeData(const JsonNode & input) override;
  21. public:
  22. bool hasNameTextID() const override;
  23. void initializeObject(CGDwelling * object) const override;
  24. void randomizeObject(CGDwelling * object, CRandomGenerator & rng) const override;
  25. bool producesCreature(const CCreature * crea) const;
  26. std::vector<const CCreature *> getProducedCreatures() const;
  27. template <typename Handler> void serialize(Handler &h, const int version)
  28. {
  29. h & availableCreatures;
  30. h & guards;
  31. h & static_cast<CDefaultObjectTypeHandler<CGDwelling>&>(*this);
  32. }
  33. };
  34. VCMI_LIB_NAMESPACE_END