You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
815 B
35 lines
815 B
#pragma once
|
|
|
|
namespace Papyrus::ObjectReference
|
|
{
|
|
inline std::uint32_t GetItemCountInList(RE::StaticFunctionTag*,
|
|
RE::BGSListForm* a_containerList,
|
|
RE::TESBoundObject* a_form)
|
|
{
|
|
if (!a_containerList || !a_form) {
|
|
return 0;
|
|
}
|
|
|
|
std::uint32_t iResult = 0;
|
|
|
|
a_containerList->ForEachForm([&](RE::TESForm& a_container) {
|
|
const auto refrItem = a_container.As<RE::TESObjectREFR>();
|
|
if (refrItem) {
|
|
const auto inv = refrItem->GetInventory([&](RE::TESBoundObject& a_object) -> bool {
|
|
return a_form->formID == a_object.formID;
|
|
});
|
|
const auto it = inv.find(a_form);
|
|
iResult += it != inv.end() ? it->second.first : 0;
|
|
}
|
|
return true;
|
|
});
|
|
|
|
return iResult;
|
|
}
|
|
|
|
inline void Bind(VM& a_vm)
|
|
{
|
|
BIND(GetItemCountInList);
|
|
logger::info("Registered GetItemCountInList"sv);
|
|
}
|
|
}
|
|
|