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"
|
2023-08-19 23:22:31 +02:00
|
|
|
#include "ConstTransitivePtr.h"
|
2023-07-24 18:09:17 +02:00
|
|
|
#include "CArtHandler.h"
|
2023-06-22 16:08:16 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
struct ArtifactLocation;
|
|
|
|
|
|
|
|
class DLL_LINKAGE CCombinedArtifactInstance
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
CCombinedArtifactInstance() = default;
|
|
|
|
public:
|
|
|
|
struct PartInfo
|
|
|
|
{
|
2024-09-06 16:59:40 +02:00
|
|
|
CArtifactInstance * art;
|
2023-06-22 16:08:16 +02:00
|
|
|
ArtifactPosition slot;
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-06-22 16:08:16 +02:00
|
|
|
{
|
|
|
|
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;
|
2024-10-12 12:33:46 +02:00
|
|
|
bool hasParts() const;
|
2023-07-03 18:15:40 +02:00
|
|
|
const std::vector<PartInfo> & getPartsInfo() const;
|
2024-09-06 16:59:40 +02:00
|
|
|
void addPlacementMap(const CArtifactSet::ArtPlacementMap & placementMap);
|
2023-06-29 17:34:07 +02:00
|
|
|
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-06-29 17:34:07 +02:00
|
|
|
{
|
|
|
|
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;
|
2024-10-12 10:41:59 +02:00
|
|
|
ArtifactID artTypeID;
|
2023-06-22 16:08:16 +02:00
|
|
|
public:
|
|
|
|
|
2023-12-31 23:43:35 +02:00
|
|
|
CArtifactInstance(const CArtifact * art);
|
2023-06-22 16:08:16 +02:00
|
|
|
CArtifactInstance();
|
2023-12-31 23:43:35 +02:00
|
|
|
void setType(const CArtifact * art);
|
2023-06-22 16:08:16 +02:00
|
|
|
std::string nodeName() const override;
|
|
|
|
ArtifactID getTypeId() const;
|
2024-10-12 10:41:59 +02:00
|
|
|
const CArtifact * getType() const;
|
2023-07-03 22:11:56 +02:00
|
|
|
ArtifactInstanceID getId() const;
|
|
|
|
void setId(ArtifactInstanceID id);
|
2023-06-22 16:08:16 +02:00
|
|
|
|
2023-10-14 21:00:39 +02:00
|
|
|
bool canBePutAt(const CArtifactSet * artSet, ArtifactPosition slot = ArtifactPosition::FIRST_AVAILABLE,
|
|
|
|
bool assumeDestRemoved = false) const;
|
2023-06-29 17:34:07 +02:00
|
|
|
bool isCombined() const;
|
2023-11-13 23:16:02 +02:00
|
|
|
bool isScroll() const;
|
2023-06-22 16:08:16 +02:00
|
|
|
|
|
|
|
void deserializationFix();
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler & h)
|
2023-06-22 16:08:16 +02:00
|
|
|
{
|
|
|
|
h & static_cast<CBonusSystemNode&>(*this);
|
2023-06-29 17:34:07 +02:00
|
|
|
h & static_cast<CCombinedArtifactInstance&>(*this);
|
2024-10-12 10:41:59 +02:00
|
|
|
h & artTypeID;
|
2023-06-22 16:08:16 +02:00
|
|
|
h & id;
|
|
|
|
BONUS_TREE_DESERIALIZATION_FIX
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|