1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00
vcmi/lib/mapObjectConstructors/CommonConstructors.h

131 lines
3.6 KiB
C++
Raw Normal View History

/*
* 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"
2023-07-15 18:29:11 +02:00
#include "../mapObjects/CGCreature.h"
VCMI_LIB_NAMESPACE_BEGIN
class CGArtifact;
class CGObjectInstance;
class CGTownInstance;
class CGHeroInstance;
class CGMarket;
class CHeroClass;
2023-07-15 13:50:09 +02:00
class CGCreature;
class CBank;
class CGBoat;
class CFaction;
class CStackBasicDescriptor;
class CObstacleConstructor : public CDefaultObjectTypeHandler<CGObjectInstance>
{
public:
bool isStaticObject() override;
};
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;
};
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;
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, CRandomGenerator & rng) const override;
void afterLoadFinalization() override;
2023-07-15 13:50:09 +02:00
bool hasNameTextID() const override;
std::string getNameTextID() const override;
};
class CHeroInstanceConstructor : public CDefaultObjectTypeHandler<CGHeroInstance>
{
JsonNode filtersJson;
protected:
2023-02-12 22:39:17 +02:00
bool objectFilter(const CGObjectInstance * obj, std::shared_ptr<const ObjectTemplate> tmpl) const override;
void initTypeData(const JsonNode & input) override;
public:
const CHeroClass * heroClass = nullptr;
std::map<std::string, LogicalExpression<HeroTypeID>> filters;
void initializeObject(CGHeroInstance * object) const override;
void randomizeObject(CGHeroInstance * object, CRandomGenerator & rng) const override;
void afterLoadFinalization() override;
2023-07-15 13:50:09 +02:00
bool hasNameTextID() const override;
std::string getNameTextID() const override;
};
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
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:
void initializeObject(CGBoat * object) const override;
/// Returns boat preview animation, for use in Shipyards
AnimationPath getBoatAnimationName() const;
2023-04-18 15:27:39 +02:00
};
2023-04-28 03:16:10 +02:00
class MarketInstanceConstructor : public CDefaultObjectTypeHandler<CGMarket>
{
protected:
void initTypeData(const JsonNode & config) override;
std::set<EMarketMode> marketModes;
2023-04-28 03:16:10 +02:00
JsonNode predefinedOffer;
int marketEfficiency;
2023-04-28 03:16:10 +02:00
std::string title;
std::string speech;
2023-04-28 03:16:10 +02:00
public:
2024-01-01 16:37:48 +02:00
CGMarket * createObject(IGameCallback * cb) const override;
void initializeObject(CGMarket * object) const override;
void randomizeObject(CGMarket * object, CRandomGenerator & rng) const override;
2023-04-28 03:16:10 +02:00
};
VCMI_LIB_NAMESPACE_END