mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-26 18:00:38 +00:00
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:
@@ -536,23 +536,6 @@ namespace
|
||||
const WeaponFullDef* m_weapon;
|
||||
};
|
||||
|
||||
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 WeaponCompleteDef* weapon, WeaponFullDef* fullDef)
|
||||
{
|
||||
fullDef->weapCompleteDef = *weapon;
|
||||
@@ -702,6 +685,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<WeaponCompleteDef>& asset)
|
||||
{
|
||||
auto* accuracyGraphWriter = context.GetZoneAssetDumperState<AccuracyGraphWriter>();
|
||||
@@ -711,22 +711,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user