mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-07-09 04:31:49 +00:00
Rename ZoneLoader and ZoneWriter components to ZoneLoading and ZoneWriting to make a difference between the executive class and the component class
This commit is contained in:
53
src/ZoneLoading/Loading/AssetLoader.cpp
Normal file
53
src/ZoneLoading/Loading/AssetLoader.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "AssetLoader.h"
|
||||
|
||||
AssetLoader::AssetLoader(const asset_type_t assetType, IZoneScriptStringProvider* scriptStringProvider, Zone* zone, IZoneInputStream* stream)
|
||||
{
|
||||
m_asset_type = assetType;
|
||||
m_script_string_provider = scriptStringProvider;
|
||||
m_zone = zone;
|
||||
m_stream = stream;
|
||||
}
|
||||
|
||||
void AssetLoader::AddDependency(const asset_type_t type, std::string& name)
|
||||
{
|
||||
for(auto& existingDependency : m_dependencies)
|
||||
{
|
||||
if(existingDependency.m_type == type
|
||||
&& existingDependency.m_name == name)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XAssetDependency dependency;
|
||||
dependency.m_type = type;
|
||||
dependency.m_name = name;
|
||||
|
||||
m_dependencies.push_back(dependency);
|
||||
}
|
||||
|
||||
scr_string_t AssetLoader::UseScriptString(const scr_string_t scrString)
|
||||
{
|
||||
std::string& scrStringValue = m_script_string_provider->GetZoneScriptString(scrString);
|
||||
|
||||
scr_string_t scriptStringIndex = 0;
|
||||
for(auto& existingScriptString : m_used_script_strings)
|
||||
{
|
||||
if(existingScriptString == scrStringValue)
|
||||
{
|
||||
return scriptStringIndex;
|
||||
}
|
||||
|
||||
scriptStringIndex++;
|
||||
}
|
||||
|
||||
scriptStringIndex = static_cast<scr_string_t>(m_used_script_strings.size());
|
||||
m_used_script_strings.push_back(scrStringValue);
|
||||
|
||||
return scriptStringIndex;
|
||||
}
|
||||
|
||||
void* AssetLoader::LinkAsset(std::string name, void* asset)
|
||||
{
|
||||
return m_zone->GetPools()->AddAsset(m_asset_type, std::move(name), asset, m_used_script_strings, m_dependencies);
|
||||
}
|
Reference in New Issue
Block a user