1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
/*
* 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
*
*/
#pragma once
#include "CDefaultObjectTypeHandler.h"
#include "../LogicalExpression.h"
#include "../mapObjects/MiscObjects.h"
#include "../mapObjects/CGCreature.h"
#include "../mapObjects/CGHeroInstance.h"
#include "../mapObjects/CGMarket.h"
#include "../mapObjects/CGResource.h"
#include "../mapObjects/CGTownInstance.h"
#include "../mapObjects/ObstacleSetHandler.h"
VCMI_LIB_NAMESPACE_BEGIN
class CGArtifact;
class CGObjectInstance;
class CGTownInstance;
class CGHeroInstance;
class CGMarket;
class CHeroClass;
class CGCreature;
class CGBoat;
class CFaction;
class CStackBasicDescriptor;
class CObstacleConstructor : public CDefaultObjectTypeHandler<CGObjectInstance>
{
public:
bool isStaticObject() override;
};
class CreatureInstanceConstructor : public CDefaultObjectTypeHandler<CGCreature>
{
public:
bool hasNameTextID() const override;
std::string getNameTextID() const override;
};
class ResourceInstanceConstructor : public CDefaultObjectTypeHandler<CGResource>
{
JsonNode config;
GameResID resourceType;
public:
void initTypeData(const JsonNode & input) override;
bool hasNameTextID() const override;
std::string getNameTextID() const override;
GameResID getResourceType() const;
int getAmountMultiplier() const;
int getBaseAmount(vstd::RNG & rng) const;
void randomizeObject(CGResource * object, vstd::RNG & rng) const override;
};
class CTownInstanceConstructor : public CDefaultObjectTypeHandler<CGTownInstance>
{
JsonNode filtersJson;
protected:
bool objectFilter(const CGObjectInstance * obj, std::shared_ptr<const ObjectTemplate> tmpl) const override;
void initTypeData(const JsonNode & input) override;
public:
const CFaction * faction = nullptr;
std::map<std::string, LogicalExpression<BuildingID>> filters;
void initializeObject(CGTownInstance * object) const override;
void randomizeObject(CGTownInstance * object, vstd::RNG & rng) const override;
void afterLoadFinalization() override;
bool hasNameTextID() const override;
std::string getNameTextID() const override;
};
class CHeroInstanceConstructor : public CDefaultObjectTypeHandler<CGHeroInstance>
{
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;
void initTypeData(const JsonNode & input) override;
public:
void randomizeObject(CGHeroInstance * object, vstd::RNG & rng) const override;
bool hasNameTextID() const override;
std::string getNameTextID() const override;
};
class DLL_LINKAGE BoatInstanceConstructor : public CDefaultObjectTypeHandler<CGBoat>
{
protected:
void initTypeData(const JsonNode & config) override;
std::vector<Bonus> bonuses;
EPathfindingLayer layer;
bool onboardAssaultAllowed; //if true, hero can attack units from transport
bool onboardVisitAllowed; //if true, hero can visit objects from transport
AnimationPath actualAnimation; //for OH3 boats those have actual animations
AnimationPath overlayAnimation; //waves animations
std::array<AnimationPath, PlayerColor::PLAYER_LIMIT_I> flagAnimations;
public:
void initializeObject(CGBoat * object) const override;
/// Returns boat preview animation, for use in Shipyards
AnimationPath getBoatAnimationName() const;
};
class MarketInstanceConstructor : public CDefaultObjectTypeHandler<CGMarket>
{
std::string descriptionTextID;
std::string speechTextID;
std::set<EMarketMode> marketModes;
JsonNode predefinedOffer;
int marketEfficiency;
void initTypeData(const JsonNode & config) override;
public:
CGMarket * createObject(IGameCallback * cb) const override;
void randomizeObject(CGMarket * object, vstd::RNG & rng) const override;
const std::set<EMarketMode> & availableModes() const;
bool hasDescription() const;
std::string getSpeechTranslated() const;
int getMarketEfficiency() const;
};
VCMI_LIB_NAMESPACE_END
|