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

103 lines
2.6 KiB
C++
Raw Normal View History

2023-06-22 16:08:16 +02:00
/*
* CArtifactInstance.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 "bonuses/CBonusSystemNode.h"
#include "GameConstants.h"
VCMI_LIB_NAMESPACE_BEGIN
struct ArtifactLocation;
class DLL_LINKAGE CCombinedArtifactInstance
{
protected:
CCombinedArtifactInstance() = default;
public:
struct PartInfo
{
ConstTransitivePtr<CArtifactInstance> art;
ArtifactPosition slot;
template <typename Handler> void serialize(Handler & h, const int version)
{
h & art;
h & slot;
}
PartInfo(CArtifactInstance * art = nullptr, const ArtifactPosition & slot = ArtifactPosition::PRE_FIRST)
: art(art), slot(slot) {};
};
2023-07-03 18:15:40 +02:00
void addPart(CArtifactInstance * art, const ArtifactPosition & slot);
2023-06-22 16:08:16 +02:00
// Checks if supposed part inst is part of this combined art inst
bool isPart(const CArtifactInstance * supposedPart) const;
2023-07-03 18:15:40 +02:00
std::vector<PartInfo> & getPartsInfo();
const std::vector<PartInfo> & getPartsInfo() const;
2023-06-29 17:34:07 +02:00
template <typename Handler> void serialize(Handler & h, const int version)
{
h & partsInfo;
}
2023-07-03 18:15:40 +02:00
protected:
std::vector<PartInfo> partsInfo;
2023-06-22 16:08:16 +02:00
};
class DLL_LINKAGE CScrollArtifactInstance
{
protected:
CScrollArtifactInstance() = default;
public:
SpellID getScrollSpellID() const;
};
class DLL_LINKAGE CGrowingArtifactInstance
{
protected:
CGrowingArtifactInstance() = default;
public:
void growingUp();
};
class DLL_LINKAGE CArtifactInstance
: public CBonusSystemNode, public CCombinedArtifactInstance, public CScrollArtifactInstance, public CGrowingArtifactInstance
{
protected:
void init();
2023-07-03 22:11:56 +02:00
ArtifactInstanceID id;
2023-06-22 16:08:16 +02:00
public:
ConstTransitivePtr<CArtifact> artType;
CArtifactInstance(CArtifact * art);
CArtifactInstance();
void setType(CArtifact * art);
std::string nodeName() const override;
std::string getDescription() const;
ArtifactID getTypeId() const;
2023-07-03 22:11:56 +02:00
ArtifactInstanceID getId() const;
void setId(ArtifactInstanceID id);
2023-06-22 16:08:16 +02:00
bool canBePutAt(const ArtifactLocation & al, bool assumeDestRemoved = false) const;
2023-06-29 17:34:07 +02:00
bool isCombined() const;
2023-06-22 16:08:16 +02:00
void putAt(const ArtifactLocation & al);
void removeFrom(const ArtifactLocation & al);
void move(const ArtifactLocation & src, const ArtifactLocation & dst);
void deserializationFix();
template <typename Handler> void serialize(Handler & h, const int version)
{
h & static_cast<CBonusSystemNode&>(*this);
2023-06-29 17:34:07 +02:00
h & static_cast<CCombinedArtifactInstance&>(*this);
2023-06-22 16:08:16 +02:00
h & artType;
h & id;
BONUS_TREE_DESERIALIZATION_FIX
}
};
VCMI_LIB_NAMESPACE_END