mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-13 00:08:26 -05:00
refactor: make LoadDependency and LoadIndirectAssetReference functions work with Asset template types
This commit is contained in:
@ -117,14 +117,14 @@ bool AssetLoaderFontIcon::ReadIconRow(const std::vector<std::string>& row,
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* materialDependency = manager->LoadDependency(ASSET_TYPE_MATERIAL, row[ROW_ICON_MATERIAL]);
|
||||
auto* materialDependency = manager->LoadDependency<AssetMaterial>(row[ROW_ICON_MATERIAL]);
|
||||
if (materialDependency == nullptr)
|
||||
{
|
||||
std::cout << ErrorPrefix(assetName, rowIndex) << "Failed to load material \"" << row[ROW_ICON_MATERIAL] << "\"\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
icon.fontIconMaterialHandle = static_cast<Material*>(materialDependency->m_ptr);
|
||||
icon.fontIconMaterialHandle = materialDependency->Asset();
|
||||
icon.fontIconName.string = memory->Dup(row[ROW_ICON_NAME].c_str());
|
||||
icon.fontIconName.hash = Common::Com_HashString(icon.fontIconName.string);
|
||||
|
||||
|
@ -132,11 +132,11 @@ namespace T6
|
||||
{
|
||||
if (value.empty())
|
||||
{
|
||||
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
|
||||
*reinterpret_cast<WeaponCamo**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* camo = m_loading_manager->LoadDependency(ASSET_TYPE_WEAPON_CAMO, value);
|
||||
auto* camo = m_loading_manager->LoadDependency<AssetWeaponCamo>(value);
|
||||
|
||||
if (camo == nullptr)
|
||||
{
|
||||
@ -145,7 +145,7 @@ namespace T6
|
||||
}
|
||||
|
||||
m_dependencies.emplace(camo);
|
||||
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = camo->m_ptr;
|
||||
*reinterpret_cast<WeaponCamo**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = camo->Asset();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -163,14 +163,14 @@ namespace T6
|
||||
|
||||
for (const auto& attachmentName : valueArray)
|
||||
{
|
||||
auto* attachmentAssetInfo = m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT, attachmentName);
|
||||
auto* attachmentAssetInfo = m_loading_manager->LoadDependency<AssetAttachment>(attachmentName);
|
||||
if (attachmentAssetInfo == nullptr)
|
||||
{
|
||||
std::cerr << "Failed to load attachment asset \"" << attachmentName << "\"\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* attachmentAsset = static_cast<WeaponAttachment*>(attachmentAssetInfo->m_ptr);
|
||||
auto* attachmentAsset = attachmentAssetInfo->Asset();
|
||||
|
||||
if (static_cast<unsigned>(attachmentAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
|
||||
{
|
||||
@ -212,14 +212,14 @@ namespace T6
|
||||
|
||||
for (const auto& attachmentUniqueName : valueArray)
|
||||
{
|
||||
auto* attachmentUniqueAssetInfo = m_loading_manager->LoadDependency(ASSET_TYPE_ATTACHMENT_UNIQUE, attachmentUniqueName);
|
||||
auto* attachmentUniqueAssetInfo = m_loading_manager->LoadDependency<AssetAttachmentUnique>(attachmentUniqueName);
|
||||
if (attachmentUniqueAssetInfo == nullptr)
|
||||
{
|
||||
std::cerr << "Failed to load attachment unique asset \"" << attachmentUniqueName << "\"\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* attachmentUniqueAsset = static_cast<WeaponAttachmentUnique*>(attachmentUniqueAssetInfo->m_ptr);
|
||||
auto* attachmentUniqueAsset = attachmentUniqueAssetInfo->Asset();
|
||||
|
||||
if (HasMoreThanOneAttachmentSetInMask(attachmentUniqueAsset->combinedAttachmentTypeMask))
|
||||
{
|
||||
@ -263,7 +263,7 @@ namespace T6
|
||||
if (ConvertString(value, field.iOffset))
|
||||
{
|
||||
if (!value.empty())
|
||||
m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value));
|
||||
m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference<AssetXAnim>(value));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -62,11 +62,11 @@ namespace T6
|
||||
{
|
||||
if (value.empty())
|
||||
{
|
||||
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
|
||||
*reinterpret_cast<WeaponCamo**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* camo = m_loading_manager->LoadDependency(ASSET_TYPE_WEAPON_CAMO, value);
|
||||
auto* camo = m_loading_manager->LoadDependency<AssetWeaponCamo>(value);
|
||||
|
||||
if (camo == nullptr)
|
||||
{
|
||||
@ -75,7 +75,7 @@ namespace T6
|
||||
}
|
||||
|
||||
m_dependencies.emplace(camo);
|
||||
*reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = camo->m_ptr;
|
||||
*reinterpret_cast<WeaponCamo**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset) = camo->Asset();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -85,7 +85,7 @@ namespace T6
|
||||
if (ConvertString(value, field.iOffset))
|
||||
{
|
||||
if (!value.empty())
|
||||
m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value));
|
||||
m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference<AssetXAnim>(value));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user