2022-08-09 07:54:32 +02:00
|
|
|
/*
|
2023-04-23 10:08:16 +02:00
|
|
|
* TreasurePlacer.h, part of VCMI engine
|
2022-08-09 07:54:32 +02:00
|
|
|
*
|
|
|
|
* 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
|
2023-05-20 10:17:37 +02:00
|
|
|
#include "../Zone.h"
|
|
|
|
#include "../../mapObjects/ObjectTemplate.h"
|
2022-08-09 07:54:32 +02:00
|
|
|
|
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;
|
2023-04-23 10:08:16 +02:00
|
|
|
class CRandomGenerator;
|
2022-08-09 07:54:32 +02:00
|
|
|
|
|
|
|
struct ObjectInfo
|
|
|
|
{
|
2024-01-13 22:39:17 +02:00
|
|
|
ObjectInfo();
|
2023-12-24 10:36:26 +02:00
|
|
|
|
2023-09-30 23:06:38 +02:00
|
|
|
std::vector<std::shared_ptr<const ObjectTemplate>> templates;
|
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;
|
2024-01-19 16:17:59 +02:00
|
|
|
std::function<void(CGObjectInstance *)> destroyObject;
|
2022-08-09 07:54:32 +02:00
|
|
|
|
2023-11-05 19:13:18 +02:00
|
|
|
void setTemplates(MapObjectID type, MapObjectSubID subtype, TerrainId terrain);
|
2022-08-09 07:54:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class TreasurePlacer: public Modificator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MODIFICATOR(TreasurePlacer);
|
|
|
|
|
|
|
|
void process() override;
|
|
|
|
void init() override;
|
|
|
|
char dump(const int3 &) override;
|
|
|
|
|
|
|
|
void createTreasures(ObjectManager & manager);
|
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;
|
2023-05-05 10:30:36 +02:00
|
|
|
void setMaxPrisons(size_t count);
|
|
|
|
size_t getMaxPrisons() const;
|
2022-08-09 07:54:32 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool isGuardNeededForTreasure(int value);
|
|
|
|
|
2023-06-08 19:23:23 +02:00
|
|
|
ObjectInfo * getRandomObject(ui32 desiredValue, ui32 currentValue, bool allowLargeObjects);
|
2022-08-09 07:54:32 +02:00
|
|
|
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);
|
2023-04-23 10:08:16 +02:00
|
|
|
|
2023-04-17 23:11:16 +02:00
|
|
|
protected:
|
2022-08-09 07:54:32 +02:00
|
|
|
std::vector<ObjectInfo> possibleObjects;
|
|
|
|
int minGuardedValue = 0;
|
|
|
|
|
|
|
|
rmg::Area treasureArea;
|
|
|
|
rmg::Area treasureBlockArea;
|
|
|
|
rmg::Area guards;
|
2023-05-05 10:30:36 +02:00
|
|
|
|
|
|
|
size_t maxPrisons;
|
2022-08-09 07:54:32 +02:00
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|