You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw/components/esm3/magiceffects.hpp

56 lines
1.2 KiB
C++

#ifndef COMPONENTS_ESM_MAGICEFFECTS_H
#define COMPONENTS_ESM_MAGICEFFECTS_H
#include <components/esm/refid.hpp>
#include <map>
#include <string>
#include <tuple>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct MagicEffects
{
// <Effect Id, Base value, Modifier>
std::map<int, std::pair<int, float>> mEffects;
void load(ESMReader& esm);
void save(ESMWriter& esm) const;
};
struct SummonKey
{
SummonKey(int effectId, const ESM::RefId& sourceId, int index)
: mEffectId(effectId)
, mSourceId(sourceId)
, mEffectIndex(index)
{
}
int mEffectId;
ESM::RefId mSourceId;
int mEffectIndex;
};
inline auto makeTupleRef(const SummonKey& value) noexcept
{
return std::tie(value.mEffectId, value.mSourceId, value.mEffectIndex);
}
inline bool operator==(const SummonKey& l, const SummonKey& r) noexcept
{
return makeTupleRef(l) == makeTupleRef(r);
}
inline bool operator<(const SummonKey& l, const SummonKey& r) noexcept
{
return makeTupleRef(l) < makeTupleRef(r);
}
}
#endif