diff --git a/CInterface/Library/BaseLibrary.cpp b/CInterface/Library/BaseLibrary.cpp index 06ab3ce..217d74a 100644 --- a/CInterface/Library/BaseLibrary.cpp +++ b/CInterface/Library/BaseLibrary.cpp @@ -37,4 +37,7 @@ Try(out = p->Get(hashedKey).GetRaw();) \ } \ \ - export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } + export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } \ + export uint8_t simpleName##_GetAtIndex(fullname* p, size_t index, const returnType*& out) { \ + Try(out = p->GetAtIndex(index).GetRaw();) \ + } diff --git a/src/Library/BaseLibrary.hpp b/src/Library/BaseLibrary.hpp index b11306a..7eb80e7 100644 --- a/src/Library/BaseLibrary.hpp +++ b/src/Library/BaseLibrary.hpp @@ -85,6 +85,9 @@ namespace CreatureLib::Library { } [[nodiscard]] size_t GetCount() const noexcept { return _values.Count(); } + ArbUt::BorrowedPtr GetAtIndex(size_t index) const { + return std::next(std::begin(_values), index)->second; + } inline ArbUt::BorrowedPtr GetRandomValue(ArbUt::Random& rand) const noexcept { auto i = rand.Get(_listValues.Count());