mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
chore: remove scriptstring and dependency registration from ZoneLoad template
This commit is contained in:
@ -10,73 +10,10 @@ AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStr
|
||||
{
|
||||
}
|
||||
|
||||
void AssetLoader::AddDependency(XAssetInfoGeneric* assetInfo)
|
||||
XAssetInfoGeneric*
|
||||
AssetLoader::LinkAsset(std::string name, void* asset, std::vector<scr_string_t> scriptStrings, std::vector<XAssetInfoGeneric*> dependencies) const
|
||||
{
|
||||
if (assetInfo == nullptr)
|
||||
return;
|
||||
|
||||
const auto existingEntry = std::find(m_dependencies.begin(), m_dependencies.end(), assetInfo);
|
||||
if (existingEntry != m_dependencies.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_dependencies.push_back(assetInfo);
|
||||
}
|
||||
|
||||
scr_string_t AssetLoader::UseScriptString(const scr_string_t scrString)
|
||||
{
|
||||
assert(scrString < m_zone->m_script_strings.Count());
|
||||
|
||||
if (scrString >= m_zone->m_script_strings.Count())
|
||||
return 0u;
|
||||
|
||||
m_used_script_strings.emplace(scrString);
|
||||
return scrString;
|
||||
}
|
||||
|
||||
void AssetLoader::LoadScriptStringArray(const bool atStreamStart, const size_t count)
|
||||
{
|
||||
assert(varScriptString != nullptr);
|
||||
|
||||
if (atStreamStart)
|
||||
m_stream->Load<scr_string_t>(varScriptString, count);
|
||||
|
||||
auto* ptr = varScriptString;
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
*ptr = UseScriptString(*ptr);
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
void AssetLoader::MarkScriptStringArrayAsUsed(const scr_string_t* scrStringArray, const size_t count)
|
||||
{
|
||||
for (size_t index = 0; index < count; index++)
|
||||
{
|
||||
const auto scrString = scrStringArray[index];
|
||||
if (scrString >= m_zone->m_script_strings.Count())
|
||||
continue;
|
||||
|
||||
m_used_script_strings.emplace(scrString);
|
||||
}
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* AssetLoader::LinkAsset(std::string name, void* asset)
|
||||
{
|
||||
std::vector<scr_string_t> usedScriptStrings;
|
||||
if (!m_used_script_strings.empty())
|
||||
{
|
||||
for (auto scrString : m_used_script_strings)
|
||||
{
|
||||
usedScriptStrings.push_back(scrString);
|
||||
}
|
||||
|
||||
std::sort(usedScriptStrings.begin(), usedScriptStrings.end());
|
||||
m_used_script_strings.clear();
|
||||
}
|
||||
|
||||
return m_zone->m_pools->AddAsset(m_asset_type, std::move(name), asset, std::move(m_dependencies), std::move(usedScriptStrings));
|
||||
return m_zone->m_pools->AddAsset(m_asset_type, std::move(name), asset, std::move(dependencies), std::move(scriptStrings));
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* AssetLoader::GetAssetInfo(std::string name) const
|
||||
|
@ -11,21 +11,12 @@ class AssetLoader : public ContentLoaderBase
|
||||
{
|
||||
asset_type_t m_asset_type;
|
||||
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
std::unordered_set<scr_string_t> m_used_script_strings;
|
||||
|
||||
protected:
|
||||
scr_string_t* varScriptString;
|
||||
|
||||
AssetLoader(asset_type_t assetType, Zone* zone, IZoneInputStream* stream);
|
||||
|
||||
void AddDependency(XAssetInfoGeneric* assetInfo);
|
||||
XAssetInfoGeneric* LinkAsset(std::string name, void* asset, std::vector<scr_string_t> scriptStrings, std::vector<XAssetInfoGeneric*> dependencies) const;
|
||||
|
||||
scr_string_t UseScriptString(scr_string_t scrString);
|
||||
void LoadScriptStringArray(bool atStreamStart, size_t count);
|
||||
void MarkScriptStringArrayAsUsed(const scr_string_t* scrStringArray, size_t count);
|
||||
|
||||
XAssetInfoGeneric* LinkAsset(std::string name, void* asset);
|
||||
|
||||
XAssetInfoGeneric* GetAssetInfo(std::string name) const;
|
||||
_NODISCARD XAssetInfoGeneric* GetAssetInfo(std::string name) const;
|
||||
};
|
||||
|
Reference in New Issue
Block a user