30 lines
1.2 KiB
C++
30 lines
1.2 KiB
C++
#ifndef PKMNLIB_ITEMLIBRARY_HPP
|
|
#define PKMNLIB_ITEMLIBRARY_HPP
|
|
|
|
#include <CreatureLib/Library/ItemLibrary.hpp>
|
|
#include "Item.hpp"
|
|
namespace PkmnLib::Library {
|
|
class ItemLibrary final : public CreatureLib::Library::ItemLibrary {
|
|
public:
|
|
inline std::optional<ArbUt::BorrowedPtr<const Item>> TryGet(const ArbUt::StringView& name) const {
|
|
auto res = CreatureLib::Library::ItemLibrary::TryGet(name);
|
|
if (!res.has_value())
|
|
return {};
|
|
return res.value().ForceAs<const Item>();
|
|
}
|
|
inline std::optional<ArbUt::BorrowedPtr<const Item>> TryGet(u32 hashedKey) const {
|
|
auto res = CreatureLib::Library::ItemLibrary::TryGetByHash(hashedKey);
|
|
if (!res.has_value())
|
|
return {};
|
|
return res.value().ForceAs<const Item>();
|
|
}
|
|
|
|
inline ArbUt::BorrowedPtr<const Item> Get(const ArbUt::StringView& name) const {
|
|
return CreatureLib::Library::ItemLibrary::Get(name).ForceAs<const Item>();
|
|
}
|
|
inline ArbUt::BorrowedPtr<const Item> operator[](const ArbUt::StringView& name) const { return Get(name); }
|
|
};
|
|
}
|
|
|
|
#endif // PKMNLIB_ITEMLIBRARY_HPP
|