TreasurePlacer.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * TreasurePlacer.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 "../ObjectInfo.h"
  12. #include "../Zone.h"
  13. #include "../../mapObjects/ObjectTemplate.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class CGObjectInstance;
  16. class ObjectManager;
  17. class RmgMap;
  18. class CMapGenerator;
  19. class ObjectConfig;
  20. class TreasurePlacer: public Modificator
  21. {
  22. public:
  23. MODIFICATOR(TreasurePlacer);
  24. void process() override;
  25. void init() override;
  26. char dump(const int3 &) override;
  27. void createTreasures(ObjectManager & manager);
  28. void addObjectToRandomPool(const ObjectInfo& oi);
  29. void setBasicProperties(ObjectInfo & oi, CompoundMapObjectID objid) const;
  30. // TODO: Can be defaulted to addAllPossibleObjects, but then each object will need to be configured
  31. void addCommonObjects();
  32. void addDwellings();
  33. void addPandoraBoxes();
  34. void addPandoraBoxesWithGold();
  35. void addPandoraBoxesWithExperience();
  36. void addPandoraBoxesWithCreatures();
  37. void addPandoraBoxesWithSpells();
  38. void addSeerHuts();
  39. void addPrisons();
  40. void addScrolls();
  41. void addAllPossibleObjects(); //add objects, including zone-specific, to possibleObjects
  42. // TODO: Read custom object config from zone file
  43. /// Get all objects for this terrain
  44. void setMaxPrisons(size_t count);
  45. size_t getMaxPrisons() const;
  46. int creatureToCount(const CCreature * creature) const;
  47. protected:
  48. bool isGuardNeededForTreasure(int value);
  49. ObjectInfo * getRandomObject(ui32 desiredValue, ui32 currentValue, bool allowLargeObjects);
  50. std::vector<ObjectInfo*> prepareTreasurePile(const CTreasureInfo & treasureInfo);
  51. rmg::Object constructTreasurePile(const std::vector<ObjectInfo*> & treasureInfos, bool densePlacement = false);
  52. protected:
  53. class ObjectPool
  54. {
  55. public:
  56. void addObject(const ObjectInfo & info);
  57. void updateObject(MapObjectID id, MapObjectSubID subid, ObjectInfo info);
  58. std::vector<ObjectInfo> & getPossibleObjects();
  59. void patchWithZoneConfig(const Zone & zone, TreasurePlacer * tp);
  60. void sortPossibleObjects();
  61. void discardObjectsAboveValue(ui32 value);
  62. ObjectConfig::EObjectCategory getObjectCategory(CompoundMapObjectID id);
  63. private:
  64. std::vector<ObjectInfo> possibleObjects;
  65. std::map<CompoundMapObjectID, ObjectInfo> customObjects;
  66. } objects;
  67. // TODO: Need to nagivate and update these
  68. int minGuardedValue = 0;
  69. rmg::Area treasureArea;
  70. rmg::Area treasureBlockArea;
  71. rmg::Area guards;
  72. size_t maxPrisons;
  73. std::vector<const CCreature *> creatures; //native creatures for this zone
  74. std::vector<int> tierValues;
  75. };
  76. VCMI_LIB_NAMESPACE_END