L2Bot2.0/L2BotDll/Versions/Interlude/Factories/AbnormalEffectFactory.h
2023-10-18 13:28:29 +04:00

51 lines
1.3 KiB
C++

#pragma once
#include <memory>
#include <map>
#include <chrono>
#include "../GameStructs/L2GameDataWrapper.h"
#include "../GameStructs/FName.h"
#include "../../../Common/Common.h"
#include "Domain/Entities/AbnormalEffect.h"
#include "Domain/Exceptions.h"
using namespace L2Bot::Domain;
namespace Interlude
{
class AbnormalEffectFactory
{
public:
AbnormalEffectFactory(const L2GameDataWrapper& l2GameData, const FName& fName) :
m_L2GameData(l2GameData),
m_FName(fName)
{
}
AbnormalEffectFactory() = delete;
virtual ~AbnormalEffectFactory() = default;
std::shared_ptr<Entities::AbnormalEffect> Create(const uint32_t skillId, const uint32_t level) const
{
const auto data = m_L2GameData.GetMSData(skillId, level);
if (!data) {
throw RuntimeException(std::format(L"cannot load MSData for abnormal effect {}", skillId));
}
const auto iconEntry = m_FName.GetEntry(data->iconNameIndex);
return std::make_shared<Entities::AbnormalEffect>(
skillId,
static_cast<uint8_t>(level),
data->name ? std::wstring(data->name) : L"",
data->description ? std::wstring(data->description) : L"",
iconEntry ? std::wstring(iconEntry->value) : L""
);
}
private:
const L2GameDataWrapper& m_L2GameData;
const FName& m_FName;
};
}