From 879acd35bbd1d9cb5846b0712ead870776831685 Mon Sep 17 00:00:00 2001 From: Jan Date: Sat, 18 May 2024 23:41:23 +0200 Subject: [PATCH] feat: dump t6 accuracy graphs --- .../T6/AssetDumpers/AssetDumperWeapon.cpp | 47 +++++++++++++++++++ .../Game/T6/AssetDumpers/AssetDumperWeapon.h | 1 + 2 files changed, 48 insertions(+) diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp index d067b584..030cb80d 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp @@ -4,6 +4,7 @@ #include "Game/T6/InfoString/InfoStringFromStructConverter.h" #include "Game/T6/InfoString/WeaponFields.h" #include "Game/T6/ObjConstantsT6.h" +#include "Weapon/AccuracyGraphWriter.h" #include #include @@ -263,6 +264,23 @@ namespace T6 { } }; + + GenericAccuracyGraph ConvertAccuracyGraph(const char* graphName, const vec2_t* originalKnots, const unsigned originalKnotCount) + { + GenericAccuracyGraph 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; + } } // namespace T6 void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef) @@ -411,6 +429,33 @@ InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo* ass return converter.Convert(); } +void AssetDumperWeapon::DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset) +{ + auto* accuracyGraphWriter = context.GetZoneAssetDumperState(); + const auto weapon = asset->Asset(); + const auto* weapDef = weapon->weapDef; + + if (!weapDef) + return; + + if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsAiGraph( + context, + ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName, weapDef->originalAiVsAiAccuracyGraphKnots, weapDef->originalAiVsAiAccuracyGraphKnotCount)); + } + + if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsPlayerGraph(context, + ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName, + weapDef->originalAiVsPlayerAccuracyGraphKnots, + weapDef->originalAiVsPlayerAccuracyGraphKnotCount)); + } +} + bool AssetDumperWeapon::ShouldDump(XAssetInfo* asset) { return true; @@ -438,4 +483,6 @@ void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset); + static void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset); protected: bool ShouldDump(XAssetInfo* asset) override;