metaforce/Runtime/CTextureCache.cpp

27 lines
926 B
C++
Raw Normal View History

#include "Runtime/CTextureCache.hpp"
#include "Runtime/CToken.hpp"
2019-12-10 20:51:23 -08:00
2021-04-10 01:42:06 -07:00
namespace metaforce {
CTextureCache::CTextureCache(CInputStream& in) {
u32 textureCount = in.ReadLong();
for (u32 i = 0; i < textureCount; ++i) {
CAssetId uid(in);
if (m_textureInfo.find(uid) == m_textureInfo.end())
m_textureInfo.emplace(uid, in.Get<CTextureInfo>());
}
}
const CTextureInfo* CTextureCache::GetTextureInfo(CAssetId id) const {
auto it = m_textureInfo.find(id);
if (it == m_textureInfo.end())
return nullptr;
return &it->second;
}
CFactoryFnReturn FTextureCacheFactory([[maybe_unused]] const SObjectTag& tag, CInputStream& in,
[[maybe_unused]] const CVParamTransfer& vparms,
[[maybe_unused]] CObjectReference* selfRef) {
return TToken<CTextureCache>::GetIObjObjectFor(std::make_unique<CTextureCache>(in));
}
2022-01-31 16:06:54 -08:00
} // namespace metaforce