mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
feat: dump t6 accuracy graphs
This commit is contained in:
parent
36a2e48e5b
commit
879acd35bb
@ -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 <cassert>
|
||||
#include <cstring>
|
||||
@ -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<WeaponVariantDef>* ass
|
||||
return converter.Convert();
|
||||
}
|
||||
|
||||
void AssetDumperWeapon::DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo<WeaponVariantDef>* asset)
|
||||
{
|
||||
auto* accuracyGraphWriter = context.GetZoneAssetDumperState<AccuracyGraphWriter>();
|
||||
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<WeaponVariantDef>* asset)
|
||||
{
|
||||
return true;
|
||||
@ -438,4 +483,6 @@ void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo<Weapo
|
||||
const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON);
|
||||
stream.write(stringValue.c_str(), stringValue.size());
|
||||
}
|
||||
|
||||
DumpAccuracyGraphs(context, asset);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ namespace T6
|
||||
{
|
||||
static void CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef);
|
||||
static InfoString CreateInfoString(XAssetInfo<WeaponVariantDef>* asset);
|
||||
static void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo<WeaponVariantDef>* asset);
|
||||
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<WeaponVariantDef>* asset) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user