chore: update usages of AddAsset for template asset struct api

This commit is contained in:
Jan
2024-04-23 00:06:48 +02:00
parent 931fe695e1
commit ae43a994b9
49 changed files with 66 additions and 84 deletions

View File

@ -265,7 +265,7 @@ bool AssetLoaderFontIcon::LoadFromRaw(
else
fontIcon->fontIconAlias = nullptr;
manager->AddAsset(ASSET_TYPE_FONTICON, assetName, fontIcon);
manager->AddAsset<AssetFontIcon>(assetName, fontIcon);
return true;
}

View File

@ -66,7 +66,7 @@ bool AssetLoaderGfxImage::LoadFromRaw(
image->streamedParts[0].hash = dataHash & 0x1FFFFFFF;
image->streamedPartCount = 1;
manager->AddAsset(ASSET_TYPE_IMAGE, assetName, image);
manager->AddAsset<AssetImage>(assetName, image);
return true;
}

View File

@ -29,7 +29,7 @@ bool AssetLoaderLocalizeEntry::LoadFromRaw(
localizeEntry->name = memory->Dup(entry.m_key.c_str());
localizeEntry->value = memory->Dup(entry.m_value.c_str());
manager->AddAsset(ASSET_TYPE_LOCALIZE_ENTRY, entry.m_key, localizeEntry);
manager->AddAsset<AssetLocalize>(entry.m_key, localizeEntry);
});
return commonLoader.LoadLocalizeAsset(assetName, searchPath, manager, zone);

View File

@ -51,7 +51,7 @@ bool AssetLoaderMaterial::LoadFromRaw(
std::vector<XAssetInfoGeneric*> dependencies;
if (LoadMaterialAsJson(*file.m_stream, *material, memory, manager, dependencies))
manager->AddAsset(ASSET_TYPE_MATERIAL, assetName, material, std::move(dependencies));
manager->AddAsset<AssetMaterial>(assetName, material, std::move(dependencies));
else
std::cerr << "Failed to load material \"" << assetName << "\"\n";

View File

@ -95,7 +95,7 @@ bool AssetLoaderPhysConstraints::LoadFromInfoString(
auto scrStrings = converter.GetUsedScriptStrings();
scrStrings.push_back(zone->m_script_strings.AddOrGetScriptString(""));
manager->AddAsset(ASSET_TYPE_PHYSCONSTRAINTS, assetName, physConstraints, converter.GetDependencies(), scrStrings);
manager->AddAsset<AssetPhysConstraints>(assetName, physConstraints, converter.GetDependencies(), scrStrings);
return true;
}

View File

@ -78,7 +78,7 @@ bool AssetLoaderPhysPreset::LoadFromInfoString(
CopyFromPhysPresetInfo(presetInfo.get(), physPreset);
physPreset->name = memory->Dup(assetName.c_str());
manager->AddAsset(ASSET_TYPE_PHYSPRESET, assetName, physPreset, converter.GetDependencies(), converter.GetUsedScriptStrings());
manager->AddAsset<AssetPhysPreset>(assetName, physPreset, converter.GetDependencies(), converter.GetUsedScriptStrings());
return true;
}

View File

@ -37,7 +37,7 @@ bool AssetLoaderQdb::LoadFromRaw(const std::string& assetName, ISearchPath* sear
fileBuffer[qdb->len] = '\0';
qdb->buffer = static_cast<char16*>(fileBuffer);
manager->AddAsset(ASSET_TYPE_QDB, assetName, qdb);
manager->AddAsset<AssetQdb>(assetName, qdb);
return true;
}

View File

@ -74,7 +74,7 @@ bool AssetLoaderRawFile::LoadAnimtree(
deflateEnd(&zs);
manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile);
manager->AddAsset<AssetRawFile>(assetName, rawFile);
return true;
}
@ -93,7 +93,7 @@ bool AssetLoaderRawFile::LoadDefault(
fileBuffer[rawFile->len] = '\0';
rawFile->buffer = static_cast<char16*>(fileBuffer);
manager->AddAsset(ASSET_TYPE_RAWFILE, assetName, rawFile);
manager->AddAsset<AssetRawFile>(assetName, rawFile);
return true;
}

View File

@ -38,7 +38,7 @@ bool AssetLoaderScriptParseTree::LoadFromRaw(
fileBuffer[scriptParseTree->len] = '\0';
scriptParseTree->buffer = static_cast<char16*>(fileBuffer);
manager->AddAsset(ASSET_TYPE_SCRIPTPARSETREE, assetName, scriptParseTree);
manager->AddAsset<AssetScript>(assetName, scriptParseTree);
return true;
}

View File

@ -37,7 +37,7 @@ bool AssetLoaderSlug::LoadFromRaw(const std::string& assetName, ISearchPath* sea
fileBuffer[slug->len] = '\0';
slug->buffer = static_cast<char16*>(fileBuffer);
manager->AddAsset(ASSET_TYPE_SLUG, assetName, slug);
manager->AddAsset<AssetSlug>(assetName, slug);
return true;
}

View File

@ -569,6 +569,6 @@ bool AssetLoaderSoundBank::LoadFromRaw(
}
}
manager->AddAsset(ASSET_TYPE_SOUND, assetName, sndBank);
manager->AddAsset<AssetSoundBank>(assetName, sndBank);
return true;
}

View File

@ -33,7 +33,7 @@ bool AssetLoaderStringTable::LoadFromRaw(
string_table::StringTableLoaderV3<StringTable, Common::Com_HashString> loader;
auto* stringTable = loader.LoadFromStream(assetName, *memory, *file.m_stream);
manager->AddAsset(ASSET_TYPE_STRINGTABLE, assetName, stringTable);
manager->AddAsset<AssetStringTable>(assetName, stringTable);
return true;
}

View File

@ -61,7 +61,7 @@ bool AssetLoaderTracer::LoadFromInfoString(
tracer->name = memory->Dup(assetName.c_str());
manager->AddAsset(ASSET_TYPE_TRACER, assetName, tracer, converter.GetDependencies(), converter.GetUsedScriptStrings());
manager->AddAsset<AssetTracer>(assetName, tracer, converter.GetDependencies(), converter.GetUsedScriptStrings());
return true;
}

View File

@ -124,7 +124,7 @@ bool AssetLoaderVehicle::LoadFromInfoString(
vehicleDef->name = memory->Dup(assetName.c_str());
manager->AddAsset(ASSET_TYPE_VEHICLEDEF, assetName, vehicleDef, converter.GetDependencies(), converter.GetUsedScriptStrings());
manager->AddAsset<AssetVehicle>(assetName, vehicleDef, converter.GetDependencies(), converter.GetUsedScriptStrings());
return true;
}

View File

@ -567,12 +567,8 @@ bool AssetLoaderWeapon::LoadFromInfoString(
CalculateWeaponFields(weaponFullDef);
CalculateAttachmentFields(weaponFullDef);
manager->AddAsset(ASSET_TYPE_WEAPON,
assetName,
&weaponFullDef->weapVariantDef,
converter.GetDependencies(),
converter.GetUsedScriptStrings(),
converter.GetIndirectAssetReferences());
manager->AddAsset<AssetWeapon>(
assetName, &weaponFullDef->weapVariantDef, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences());
return true;
}

View File

@ -112,8 +112,8 @@ bool AssetLoaderWeaponAttachment::LoadFromInfoString(
CalculateAttachmentFields(attachment);
attachment->szInternalName = memory->Dup(assetName.c_str());
manager->AddAsset(
ASSET_TYPE_ATTACHMENT, assetName, attachment, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences());
manager->AddAsset<AssetAttachment>(
assetName, attachment, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences());
return true;
}

View File

@ -231,12 +231,8 @@ bool AssetLoaderWeaponAttachmentUnique::LoadFromInfoString(
attachmentUniqueFull->attachment.szInternalName = memory->Dup(assetName.c_str());
manager->AddAsset(ASSET_TYPE_ATTACHMENT_UNIQUE,
assetName,
&attachmentUniqueFull->attachment,
converter.GetDependencies(),
converter.GetUsedScriptStrings(),
converter.GetIndirectAssetReferences());
manager->AddAsset<AssetAttachmentUnique>(
assetName, &attachmentUniqueFull->attachment, converter.GetDependencies(), converter.GetUsedScriptStrings(), converter.GetIndirectAssetReferences());
return true;
}

View File

@ -37,7 +37,7 @@ bool AssetLoaderWeaponCamo::LoadFromRaw(
std::vector<XAssetInfoGeneric*> dependencies;
if (LoadWeaponCamoAsJson(*file.m_stream, *weaponCamo, memory, manager, dependencies))
manager->AddAsset(ASSET_TYPE_WEAPON_CAMO, assetName, weaponCamo, std::move(dependencies));
manager->AddAsset<AssetWeaponCamo>(assetName, weaponCamo, std::move(dependencies));
else
std::cerr << "Failed to load weapon camo \"" << assetName << "\"\n";

View File

@ -74,7 +74,7 @@ bool AssetLoaderZBarrier::LoadFromInfoString(
CalculateZBarrierFields(zbarrier);
zbarrier->name = memory->Dup(assetName.c_str());
manager->AddAsset(ASSET_TYPE_ZBARRIER, assetName, zbarrier, converter.GetDependencies(), converter.GetUsedScriptStrings());
manager->AddAsset<AssetZBarrier>(assetName, zbarrier, converter.GetDependencies(), converter.GetUsedScriptStrings());
return true;
}