Make empty linking asset if asset is ignored

This commit is contained in:
Jan
2021-03-13 19:32:51 +01:00
parent d65f906ecb
commit 94230cefb0
13 changed files with 189 additions and 92 deletions

View File

@ -11,7 +11,7 @@ using namespace T6;
ZoneCreator::ZoneCreator()
{
for(auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
for (auto assetType = 0; assetType < ASSET_TYPE_COUNT; assetType++)
{
AddAssetTypeName(assetType, GameAssetPoolT6::AssetTypeNameByType(assetType));
}
@ -22,6 +22,33 @@ void ZoneCreator::AddAssetTypeName(asset_type_t assetType, std::string name)
m_asset_types_by_name.emplace(std::make_pair(std::move(name), assetType));
}
std::vector<Gdt*> ZoneCreator::CreateGdtList(ZoneCreationContext& context)
{
std::vector<Gdt*> gdtList;
gdtList.reserve(context.m_gdt_files.size());
for (const auto& gdt : context.m_gdt_files)
gdtList.push_back(gdt.get());
return gdtList;
}
bool ZoneCreator::CreateIgnoredAssetMap(ZoneCreationContext& context, std::unordered_map<std::string, asset_type_t>& ignoredAssetMap) const
{
for (const auto& ignoreEntry : context.m_ignored_assets)
{
const auto foundAssetTypeEntry = m_asset_types_by_name.find(ignoreEntry.m_type);
if (foundAssetTypeEntry == m_asset_types_by_name.end())
{
std::cout << "Unknown asset type \"" << ignoreEntry.m_type << "\" for ignore \"" << ignoreEntry.m_name << "\"" << std::endl;
return false;
}
ignoredAssetMap[ignoreEntry.m_name] = foundAssetTypeEntry->second;
}
return true;
}
void ZoneCreator::CreateZoneAssetPools(Zone* zone) const
{
zone->m_pools = std::make_unique<GameAssetPoolT6>(zone, zone->m_priority);
@ -40,19 +67,22 @@ std::unique_ptr<Zone> ZoneCreator::CreateZoneForDefinition(ZoneCreationContext&
auto zone = std::make_unique<Zone>(context.m_zone_name, 0, &g_GameT6);
CreateZoneAssetPools(zone.get());
std::vector<Gdt*> gdtList;
gdtList.reserve(context.m_gdt_files.size());
for (const auto& gdt : context.m_gdt_files)
gdtList.push_back(gdt.get());
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, std::move(gdtList));
for(const auto& assetEntry : context.m_definition->m_assets)
for (const auto& assetEntry : context.m_definition->m_assets)
{
if (assetEntry.m_is_reference)
if(!assetEntry.m_is_reference)
continue;
context.m_ignored_assets.emplace_back(assetEntry.m_asset_type, assetEntry.m_asset_name);
}
const auto assetLoadingContext = std::make_unique<AssetLoadingContext>(zone.get(), context.m_asset_search_path, CreateGdtList(context));
if (!CreateIgnoredAssetMap(context, assetLoadingContext->m_ignored_asset_map))
return nullptr;
for (const auto& assetEntry : context.m_definition->m_assets)
{
const auto foundAssetTypeEntry = m_asset_types_by_name.find(assetEntry.m_asset_type);
if(foundAssetTypeEntry == m_asset_types_by_name.end())
if (foundAssetTypeEntry == m_asset_types_by_name.end())
{
std::cout << "Unknown asset type \"" << assetEntry.m_asset_type << "\"" << std::endl;
return nullptr;