2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-13 20:31:21 +00:00
metaforce/Runtime/CTextureCache.cpp
Phillip Stephens dad7249927
RE COutput/InputStream and friends and migrate over
This branch is probably still horribly broken, but it's a good first step to migrating away from having hecl embedded in the runtime
2022-02-21 08:01:05 -08:00

27 lines
926 B
C++

#include "Runtime/CTextureCache.hpp"
#include "Runtime/CToken.hpp"
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));
}
} // namespace metaforce