2022-08-09 07:54:32 +02:00
|
|
|
/*
|
|
|
|
* TreasurePlacer.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "Zone.h"
|
|
|
|
#include "../mapObjects/ObjectTemplate.h"
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
class CGObjectInstance;
|
|
|
|
class ObjectManager;
|
|
|
|
class RmgMap;
|
|
|
|
class CMapGenerator;
|
|
|
|
|
|
|
|
struct ObjectInfo
|
|
|
|
{
|
2022-09-11 15:12:35 +02:00
|
|
|
std::shared_ptr<const ObjectTemplate> templ;
|
2022-08-09 07:54:32 +02:00
|
|
|
ui32 value = 0;
|
|
|
|
ui16 probability = 0;
|
2023-02-11 18:05:02 +02:00
|
|
|
ui32 maxPerZone = 1;
|
2022-08-09 07:54:32 +02:00
|
|
|
//ui32 maxPerMap; //unused
|
|
|
|
std::function<CGObjectInstance *()> generateObject;
|
|
|
|
|
2022-09-29 11:44:46 +02:00
|
|
|
void setTemplate(si32 type, si32 subtype, TerrainId terrain);
|
2023-02-11 18:05:02 +02:00
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
bool operator==(const ObjectInfo& oi) const { return (templ == oi.templ); }
|
|
|
|
};
|
|
|
|
|
|
|
|
class TreasurePlacer: public Modificator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MODIFICATOR(TreasurePlacer);
|
|
|
|
|
|
|
|
void process() override;
|
|
|
|
void init() override;
|
|
|
|
char dump(const int3 &) override;
|
|
|
|
|
|
|
|
void createTreasures(ObjectManager & manager);
|
|
|
|
|
|
|
|
void setQuestArtZone(Zone * otherZone);
|
2023-03-27 09:09:58 +02:00
|
|
|
void addObjectToRandomPool(const ObjectInfo& oi);
|
2022-08-09 07:54:32 +02:00
|
|
|
void addAllPossibleObjects(); //add objects, including zone-specific, to possibleObjects
|
2023-03-27 09:09:58 +02:00
|
|
|
|
|
|
|
size_t getPossibleObjectsSize() const;
|
2022-08-09 07:54:32 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool isGuardNeededForTreasure(int value);
|
|
|
|
|
|
|
|
ObjectInfo * getRandomObject(ui32 desiredValue, ui32 currentValue, ui32 maxValue, bool allowLargeObjects);
|
|
|
|
std::vector<ObjectInfo*> prepareTreasurePile(const CTreasureInfo & treasureInfo);
|
2022-08-20 12:17:27 +02:00
|
|
|
rmg::Object constructTreasurePile(const std::vector<ObjectInfo*> & treasureInfos, bool densePlacement = false);
|
2022-08-09 07:54:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::vector<ObjectInfo> possibleObjects;
|
|
|
|
int minGuardedValue = 0;
|
|
|
|
|
|
|
|
rmg::Area treasureArea;
|
|
|
|
rmg::Area treasureBlockArea;
|
|
|
|
rmg::Area guards;
|
|
|
|
|
|
|
|
Zone * questArtZone = nullptr; //artifacts required for Seer Huts will be placed here - or not if null
|
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|