Support for getting natures by index for iterating purposes.
This commit is contained in:
parent
ca087a7ed8
commit
de3ad4a9c8
|
@ -21,3 +21,8 @@ export uint8_t PkmnLib_NatureLibrary_GetRandomNatureName(NatureLibrary* p, ArbUt
|
||||||
export uint8_t PkmnLib_NatureLibrary_GetNatureName(NatureLibrary* p, const Nature* nature, const char*& out) {
|
export uint8_t PkmnLib_NatureLibrary_GetNatureName(NatureLibrary* p, const Nature* nature, const char*& out) {
|
||||||
Try(out = p->GetNatureName(nature).c_str());
|
Try(out = p->GetNatureName(nature).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SIMPLE_GET_FUNC(NatureLibrary, GetNatureCount, size_t)
|
||||||
|
export uint8_t PkmnLib_NatureLibrary_GetNatureByIndex(NatureLibrary* p, size_t index, const char*& out) {
|
||||||
|
Try(out = p->GetNatureFromIndex(index).c_str();)
|
||||||
|
}
|
|
@ -42,6 +42,11 @@ namespace PkmnLib::Library {
|
||||||
}
|
}
|
||||||
throw CreatureException("Nature not found.");
|
throw CreatureException("Nature not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t GetNatureCount() const noexcept { return _items.size(); }
|
||||||
|
inline const ArbUt::StringView& GetNatureFromIndex(size_t index) const {
|
||||||
|
return std::next(std::begin(_items), index)->first;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue