feat: add DumpOfferings
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using CUE4Parse.Compression;
|
using CUE4Parse.Compression;
|
||||||
using CUE4Parse.Encryption.Aes;
|
using CUE4Parse.Encryption.Aes;
|
||||||
using CUE4Parse.FileProvider;
|
using CUE4Parse.FileProvider;
|
||||||
|
using CUE4Parse.FileProvider.Objects;
|
||||||
using CUE4Parse.MappingsProvider.Usmap;
|
using CUE4Parse.MappingsProvider.Usmap;
|
||||||
using CUE4Parse.UE4.Assets;
|
using CUE4Parse.UE4.Assets;
|
||||||
using CUE4Parse.UE4.Assets.Exports.Engine;
|
using CUE4Parse.UE4.Assets.Exports.Engine;
|
||||||
@@ -28,6 +29,14 @@ struct ItemInfo
|
|||||||
public string iconFilePath;
|
public string iconFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct OfferingInfo
|
||||||
|
{
|
||||||
|
public string id;
|
||||||
|
public string name;
|
||||||
|
public string iconFilePath;
|
||||||
|
public EPlayerRole role;
|
||||||
|
}
|
||||||
|
|
||||||
class Dumper
|
class Dumper
|
||||||
{
|
{
|
||||||
private DefaultFileProvider? _provider;
|
private DefaultFileProvider? _provider;
|
||||||
@@ -38,6 +47,7 @@ class Dumper
|
|||||||
|
|
||||||
private readonly Dictionary<int, CharacterInfo> _characterMap = new();
|
private readonly Dictionary<int, CharacterInfo> _characterMap = new();
|
||||||
private readonly Dictionary<string, ItemInfo> _itemMap = new();
|
private readonly Dictionary<string, ItemInfo> _itemMap = new();
|
||||||
|
private readonly Dictionary<string, OfferingInfo> _offeringMap = new();
|
||||||
|
|
||||||
public Dumper(string outDir)
|
public Dumper(string outDir)
|
||||||
{
|
{
|
||||||
@@ -238,6 +248,59 @@ class Dumper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DumpOfferings()
|
||||||
|
{
|
||||||
|
if (_dataPak == null || _provider == null)
|
||||||
|
throw new InvalidOperationException("Attempted to call dump function without dumper initialization/state");
|
||||||
|
|
||||||
|
_log.Info("Dumping offerings");
|
||||||
|
|
||||||
|
List<string> offeringDBPaths = _dataPak.Files.Keys.Where(x => x.Contains("/OfferingDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
|
||||||
|
foreach (string path in offeringDBPaths)
|
||||||
|
{
|
||||||
|
string cleanPath = path.Contains('.') ? path[..path.LastIndexOf('.')] : path;
|
||||||
|
|
||||||
|
if (_provider.TryLoadPackageObject<UDataTable>(cleanPath, out UDataTable? dataTable))
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<FName, FStructFallback> row in dataTable.RowMap)
|
||||||
|
{
|
||||||
|
List<FPropertyTag> props = row.Value.Properties;
|
||||||
|
|
||||||
|
string offeringId = row.Key.Text;
|
||||||
|
|
||||||
|
if (!TryGetProp(props, "Role", out EPlayerRole role)
|
||||||
|
|| !TryGetProp(props, "UIData", out FStructFallback uiDataFb)
|
||||||
|
|| !TryGetProp(props, "Inventory", out bool isInventory)
|
||||||
|
|| !TryGetProp(props, "IsFakeItem", out bool isFakeItem)
|
||||||
|
)
|
||||||
|
throw new KeyNotFoundException("Role, UIData, Inventory or IsFakeItem was not found");
|
||||||
|
|
||||||
|
UIDataStruct uiData = uiDataFb.MapToStruct<UIDataStruct>();
|
||||||
|
|
||||||
|
if (!isInventory || isFakeItem)
|
||||||
|
{
|
||||||
|
_log.Verbose("Ignoring invalid offering ({0})", offeringDBPaths);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uiData.IconAssetList.Length == 0)
|
||||||
|
throw new InvalidDataException("Offerings's UIData had no icons");
|
||||||
|
|
||||||
|
_offeringMap[offeringId] = new OfferingInfo
|
||||||
|
{
|
||||||
|
id = offeringId,
|
||||||
|
name = uiData.DisplayName.ToString(),
|
||||||
|
iconFilePath = uiData.IconAssetList[0].ToString(),
|
||||||
|
role = role
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteJson("offerings", _offeringMap.Values);
|
||||||
|
_log.Info("Dumped {0} offerings", _offeringMap.Count);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* internal helper functions
|
* internal helper functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user