refactor: accuracy graph subassets (#847)

* refactor: use subassets to load accuracy graphs for iw4,iw5,t5,t6

* fix: not dumping anim names for t5 weapons and t6 attachment unique

* refactor: dump accuracy graphs like a subasset

* refactor: use shared method for accuracy graph filenames
This commit is contained in:
Jan
2026-06-20 17:16:37 +02:00
committed by GitHub
parent b5acacf680
commit b4477ac1a9
29 changed files with 464 additions and 354 deletions
@@ -190,6 +190,10 @@ namespace
break;
}
case WFT_ANIM_NAME:
FillFromString(std::string(field.szName), field.iOffset);
break;
case WFT_NUM_FIELD_TYPES:
default:
assert(false);
@@ -225,23 +229,6 @@ namespace
}
};
GenericGraph2D ConvertAccuracyGraph(const char* graphName, const vec2_t* originalKnots, const unsigned originalKnotCount)
{
GenericGraph2D graph;
graph.name = graphName;
graph.knots.resize(originalKnotCount);
for (auto i = 0u; i < originalKnotCount; i++)
{
auto& knot = graph.knots[i];
knot.x = originalKnots[i].x;
knot.y = originalKnots[i].y;
}
return graph;
}
void CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef)
{
fullDef->weapVariantDef = *weapon;
@@ -341,6 +328,23 @@ namespace
return converter.Convert();
}
GenericGraph2D ConvertAccuracyGraph(std::string graphName, const vec2_t* originalKnots, const unsigned originalKnotCount)
{
GenericGraph2D graph;
graph.name = std::move(graphName);
graph.knots.resize(originalKnotCount);
for (auto i = 0u; i < originalKnotCount; i++)
{
auto& knot = graph.knots[i];
knot.x = originalKnots[i].x;
knot.y = originalKnots[i].y;
}
return graph;
}
void DumpAccuracyGraphs(AssetDumpingContext& context, const XAssetInfo<WeaponVariantDef>& asset)
{
auto* accuracyGraphWriter = context.GetZoneAssetDumperState<AccuracyGraphWriter>();
@@ -350,22 +354,26 @@ namespace
if (!weapDef)
return;
if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots
&& accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName))
if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots)
{
AccuracyGraphWriter::DumpAiVsAiGraph(context,
ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName,
weapDef->originalAiVsAiAccuracyGraphKnots,
weapDef->originalAiVsAiAccuracyGraphKnotCount));
auto graphName = weapon::GetAssetNameForAiVsAiAccuracyGraph(weapDef->aiVsAiAccuracyGraphName);
if (accuracyGraphWriter->ShouldDumpGraph(graphName))
{
const auto graph =
ConvertAccuracyGraph(std::move(graphName), weapDef->originalAiVsAiAccuracyGraphKnots, weapDef->originalAiVsAiAccuracyGraphKnotCount);
AccuracyGraphWriter::DumpGraph(context, graph);
}
}
if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots
&& accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName))
if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots)
{
AccuracyGraphWriter::DumpAiVsPlayerGraph(context,
ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName,
weapDef->originalAiVsPlayerAccuracyGraphKnots,
weapDef->originalAiVsPlayerAccuracyGraphKnotCount));
auto graphName = weapon::GetAssetNameForAiVsPlayerAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName);
if (accuracyGraphWriter->ShouldDumpGraph(graphName))
{
const auto graph = ConvertAccuracyGraph(
std::move(graphName), weapDef->originalAiVsPlayerAccuracyGraphKnots, weapDef->originalAiVsPlayerAccuracyGraphKnotCount);
AccuracyGraphWriter::DumpGraph(context, graph);
}
}
}