2019-12-29 14:29:52 +00:00
|
|
|
#ifndef PKMNLIB_SPECIESLIBRARY_HPP
|
|
|
|
#define PKMNLIB_SPECIESLIBRARY_HPP
|
|
|
|
|
2020-02-08 18:22:29 +00:00
|
|
|
#include <CreatureLib/Library/SpeciesLibrary.hpp>
|
2019-12-29 14:29:52 +00:00
|
|
|
#include "PokemonSpecies.hpp"
|
|
|
|
|
|
|
|
namespace PkmnLib::Library {
|
2020-10-15 16:13:00 +00:00
|
|
|
class SpeciesLibrary final : public CreatureLib::Library::SpeciesLibrary {
|
2020-08-11 19:46:22 +00:00
|
|
|
ArbUt::Dictionary<ArbUt::BorrowedPtr<const PokemonSpecies>, ArbUt::BorrowedPtr<const PokemonSpecies>>
|
|
|
|
_preEvolutionCache;
|
|
|
|
|
2019-12-29 14:29:52 +00:00
|
|
|
public:
|
2021-06-26 11:36:21 +00:00
|
|
|
SpeciesLibrary(size_t initialCapacity = 32) : CreatureLib::Library::SpeciesLibrary(initialCapacity) {}
|
|
|
|
|
2022-05-16 16:16:15 +00:00
|
|
|
inline std::optional<ArbUt::BorrowedPtr<const PokemonSpecies>> TryGet(const ArbUt::StringView& name) const {
|
2020-12-12 13:25:27 +00:00
|
|
|
auto res = CreatureLib::Library::SpeciesLibrary::TryGet(name);
|
|
|
|
if (!res.has_value())
|
|
|
|
return {};
|
|
|
|
return res.value().ForceAs<const PokemonSpecies>();
|
2020-02-01 15:56:09 +00:00
|
|
|
}
|
|
|
|
|
2022-05-16 16:16:15 +00:00
|
|
|
inline std::optional<ArbUt::BorrowedPtr<const PokemonSpecies>> TryGetByHash(u32 hashedKey) const {
|
|
|
|
auto res = CreatureLib::Library::SpeciesLibrary::TryGetByHash(hashedKey);
|
|
|
|
if (!res.has_value())
|
|
|
|
return {};
|
|
|
|
return res.value().ForceAs<const PokemonSpecies>();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ArbUt::BorrowedPtr<const PokemonSpecies> Get(const ArbUt::StringView& name) const {
|
2020-05-27 15:26:25 +00:00
|
|
|
return CreatureLib::Library::SpeciesLibrary::Get(name).As<const PokemonSpecies>();
|
2019-12-29 14:29:52 +00:00
|
|
|
}
|
2022-05-16 16:16:15 +00:00
|
|
|
inline ArbUt::BorrowedPtr<const PokemonSpecies> GetByHash(u32 hashedKey) const {
|
|
|
|
return CreatureLib::Library::SpeciesLibrary::GetByHash(hashedKey).As<const PokemonSpecies>();
|
|
|
|
}
|
2019-12-29 14:29:52 +00:00
|
|
|
|
2022-06-07 21:23:40 +00:00
|
|
|
ArbUt::BorrowedPtr<const PokemonSpecies> operator[](const ArbUt::StringView& name) const { return Get(name); }
|
2019-12-29 14:29:52 +00:00
|
|
|
|
2020-12-12 13:25:27 +00:00
|
|
|
std::optional<ArbUt::BorrowedPtr<const PokemonSpecies>>
|
2020-08-11 19:46:22 +00:00
|
|
|
FindPreEvolution(const ArbUt::BorrowedPtr<const PokemonSpecies>& species) const noexcept;
|
2019-12-29 14:29:52 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PKMNLIB_SPECIESLIBRARY_HPP
|