ObjectInfo.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * ObjectInfo.cpp, 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. #include "StdInc.h"
  11. #include "ObjectInfo.h"
  12. #include "../VCMI_Lib.h"
  13. #include "../mapObjectConstructors/CObjectClassesHandler.h"
  14. #include "../mapObjectConstructors/AObjectTypeHandler.h"
  15. #include "../serializer/JsonSerializeFormat.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. ObjectInfo::ObjectInfo():
  18. destroyObject([](CGObjectInstance * obj){}),
  19. maxPerZone(std::numeric_limits<ui32>::max())
  20. {
  21. }
  22. ObjectInfo::ObjectInfo(const ObjectInfo & other)
  23. {
  24. templates = other.templates;
  25. value = other.value;
  26. probability = other.probability;
  27. maxPerZone = other.maxPerZone;
  28. generateObject = other.generateObject;
  29. destroyObject = other.destroyObject;
  30. }
  31. ObjectInfo & ObjectInfo::operator=(const ObjectInfo & other)
  32. {
  33. if (this == &other)
  34. return *this;
  35. templates = other.templates;
  36. value = other.value;
  37. probability = other.probability;
  38. maxPerZone = other.maxPerZone;
  39. generateObject = other.generateObject;
  40. destroyObject = other.destroyObject;
  41. return *this;
  42. }
  43. void ObjectInfo::setAllTemplates(MapObjectID type, MapObjectSubID subtype)
  44. {
  45. auto templHandler = VLC->objtypeh->getHandlerFor(type, subtype);
  46. if(!templHandler)
  47. return;
  48. templates = templHandler->getTemplates();
  49. }
  50. void ObjectInfo::setTemplates(MapObjectID type, MapObjectSubID subtype, TerrainId terrainType)
  51. {
  52. auto templHandler = VLC->objtypeh->getHandlerFor(type, subtype);
  53. if(!templHandler)
  54. return;
  55. templates = templHandler->getTemplates(terrainType);
  56. }
  57. VCMI_LIB_NAMESPACE_END