2014-06-14 18:42:13 +03:00
|
|
|
/*
|
2021-05-16 19:53:11 +02:00
|
|
|
* CommonConstructors.h, 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
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-06 17:32:53 +02:00
|
|
|
#include "CDefaultObjectTypeHandler.h"
|
2023-06-02 20:47:37 +02:00
|
|
|
#include "../LogicalExpression.h"
|
2014-06-14 18:42:13 +03:00
|
|
|
|
2023-06-08 16:29:29 +02:00
|
|
|
#include "../mapObjects/MiscObjects.h"
|
2023-07-15 18:29:11 +02:00
|
|
|
#include "../mapObjects/CGCreature.h"
|
2024-08-27 15:44:30 +02:00
|
|
|
#include "../mapObjects/CGHeroInstance.h"
|
2024-04-05 08:31:05 +02:00
|
|
|
#include "../mapObjects/ObstacleSetHandler.h"
|
2023-06-08 16:29:29 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-06-07 23:42:47 +02:00
|
|
|
class CGArtifact;
|
2014-07-06 23:14:37 +03:00
|
|
|
class CGObjectInstance;
|
2014-06-14 18:42:13 +03:00
|
|
|
class CGTownInstance;
|
|
|
|
class CGHeroInstance;
|
2023-06-07 23:42:47 +02:00
|
|
|
class CGMarket;
|
2014-06-14 18:42:13 +03:00
|
|
|
class CHeroClass;
|
2023-07-15 13:50:09 +02:00
|
|
|
class CGCreature;
|
2023-06-07 23:42:47 +02:00
|
|
|
class CGBoat;
|
2023-06-02 20:47:37 +02:00
|
|
|
class CFaction;
|
2014-06-22 13:39:40 +03:00
|
|
|
class CStackBasicDescriptor;
|
2014-06-14 18:42:13 +03:00
|
|
|
|
|
|
|
class CObstacleConstructor : public CDefaultObjectTypeHandler<CGObjectInstance>
|
|
|
|
{
|
|
|
|
public:
|
2015-10-12 15:47:10 +02:00
|
|
|
bool isStaticObject() override;
|
2024-04-05 08:31:05 +02:00
|
|
|
|
2014-06-14 18:42:13 +03:00
|
|
|
};
|
|
|
|
|
2023-07-15 13:50:09 +02:00
|
|
|
class CreatureInstanceConstructor : public CDefaultObjectTypeHandler<CGCreature>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool hasNameTextID() const override;
|
|
|
|
std::string getNameTextID() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ResourceInstanceConstructor : public CDefaultObjectTypeHandler<CGResource>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool hasNameTextID() const override;
|
|
|
|
std::string getNameTextID() const override;
|
|
|
|
};
|
|
|
|
|
2014-06-14 18:42:13 +03:00
|
|
|
class CTownInstanceConstructor : public CDefaultObjectTypeHandler<CGTownInstance>
|
|
|
|
{
|
|
|
|
JsonNode filtersJson;
|
|
|
|
protected:
|
2023-02-12 22:39:17 +02:00
|
|
|
bool objectFilter(const CGObjectInstance * obj, std::shared_ptr<const ObjectTemplate> tmpl) const override;
|
2015-10-12 15:47:10 +02:00
|
|
|
void initTypeData(const JsonNode & input) override;
|
2014-06-14 18:42:13 +03:00
|
|
|
|
|
|
|
public:
|
2023-12-31 23:43:35 +02:00
|
|
|
const CFaction * faction = nullptr;
|
2014-06-14 18:42:13 +03:00
|
|
|
std::map<std::string, LogicalExpression<BuildingID>> filters;
|
|
|
|
|
2023-06-07 23:42:47 +02:00
|
|
|
void initializeObject(CGTownInstance * object) const override;
|
2024-06-01 17:28:17 +02:00
|
|
|
void randomizeObject(CGTownInstance * object, vstd::RNG & rng) const override;
|
2015-10-12 15:47:10 +02:00
|
|
|
void afterLoadFinalization() override;
|
2014-06-16 19:27:26 +03:00
|
|
|
|
2023-07-15 13:50:09 +02:00
|
|
|
bool hasNameTextID() const override;
|
|
|
|
std::string getNameTextID() const override;
|
2014-06-14 18:42:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class CHeroInstanceConstructor : public CDefaultObjectTypeHandler<CGHeroInstance>
|
|
|
|
{
|
2024-11-03 20:50:47 +02:00
|
|
|
struct HeroFilter
|
|
|
|
{
|
|
|
|
HeroTypeID fixedHero;
|
|
|
|
bool allowMale;
|
|
|
|
bool allowFemale;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::map<std::string, HeroFilter> filters;
|
|
|
|
const CHeroClass * heroClass = nullptr;
|
|
|
|
|
|
|
|
std::shared_ptr<const ObjectTemplate> getOverride(TerrainId terrainType, const CGObjectInstance * object) const override;
|
2015-10-12 15:47:10 +02:00
|
|
|
void initTypeData(const JsonNode & input) override;
|
2014-06-14 18:42:13 +03:00
|
|
|
|
|
|
|
public:
|
2024-06-01 17:28:17 +02:00
|
|
|
void randomizeObject(CGHeroInstance * object, vstd::RNG & rng) const override;
|
2014-06-16 19:27:26 +03:00
|
|
|
|
2023-07-15 13:50:09 +02:00
|
|
|
bool hasNameTextID() const override;
|
|
|
|
std::string getNameTextID() const override;
|
2014-06-14 18:42:13 +03:00
|
|
|
};
|
|
|
|
|
2023-06-07 18:51:44 +02:00
|
|
|
class DLL_LINKAGE BoatInstanceConstructor : public CDefaultObjectTypeHandler<CGBoat>
|
2023-04-18 15:27:39 +02:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
void initTypeData(const JsonNode & config) override;
|
|
|
|
|
2023-04-18 23:11:51 +02:00
|
|
|
std::vector<Bonus> bonuses;
|
2023-04-18 22:14:15 +02:00
|
|
|
EPathfindingLayer layer;
|
2023-04-19 00:11:24 +02:00
|
|
|
bool onboardAssaultAllowed; //if true, hero can attack units from transport
|
|
|
|
bool onboardVisitAllowed; //if true, hero can visit objects from transport
|
2023-04-18 23:11:51 +02:00
|
|
|
|
2023-08-23 14:07:50 +02:00
|
|
|
AnimationPath actualAnimation; //for OH3 boats those have actual animations
|
|
|
|
AnimationPath overlayAnimation; //waves animations
|
|
|
|
std::array<AnimationPath, PlayerColor::PLAYER_LIMIT_I> flagAnimations;
|
2023-04-18 15:27:39 +02:00
|
|
|
|
|
|
|
public:
|
2023-06-07 23:42:47 +02:00
|
|
|
void initializeObject(CGBoat * object) const override;
|
2023-06-07 18:51:44 +02:00
|
|
|
|
|
|
|
/// Returns boat preview animation, for use in Shipyards
|
2023-08-23 14:07:50 +02:00
|
|
|
AnimationPath getBoatAnimationName() const;
|
2023-04-18 15:27:39 +02:00
|
|
|
};
|
|
|
|
|
2023-04-28 03:16:10 +02:00
|
|
|
class MarketInstanceConstructor : public CDefaultObjectTypeHandler<CGMarket>
|
|
|
|
{
|
2024-11-19 16:38:27 +02:00
|
|
|
std::string descriptionTextID;
|
|
|
|
std::string speechTextID;
|
2023-04-28 03:16:10 +02:00
|
|
|
|
2023-08-19 20:43:50 +02:00
|
|
|
std::set<EMarketMode> marketModes;
|
2023-04-28 03:16:10 +02:00
|
|
|
JsonNode predefinedOffer;
|
2023-05-01 02:07:31 +02:00
|
|
|
int marketEfficiency;
|
2024-11-19 16:38:27 +02:00
|
|
|
|
|
|
|
void initTypeData(const JsonNode & config) override;
|
2023-04-28 03:16:10 +02:00
|
|
|
public:
|
2024-01-01 16:37:48 +02:00
|
|
|
CGMarket * createObject(IGameCallback * cb) const override;
|
2024-06-01 17:28:17 +02:00
|
|
|
void randomizeObject(CGMarket * object, vstd::RNG & rng) const override;
|
2023-04-28 03:16:10 +02:00
|
|
|
|
2024-08-27 15:44:30 +02:00
|
|
|
const std::set<EMarketMode> & availableModes() const;
|
2024-10-30 15:20:21 +02:00
|
|
|
bool hasDescription() const;
|
2024-08-27 15:44:30 +02:00
|
|
|
|
2024-11-19 16:38:27 +02:00
|
|
|
std::string getSpeechTranslated() const;
|
|
|
|
int getMarketEfficiency() const;
|
2023-04-28 03:16:10 +02:00
|
|
|
};
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|