add support for ComponentContainer (#454)

This commit is contained in:
Lyndsey Winter 2024-02-22 17:18:01 -04:00 committed by GitHub
parent 53bb6e1f90
commit f64151b0ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,6 +31,7 @@ public class BaseIcon : UCreator
{
// rarity
if (Object.TryGetValue(out FPackageIndex series, "Series")) GetSeries(series);
else if (Object.TryGetValue(out FStructFallback componentContainer, "ComponentContainer")) GetSeries(componentContainer);
else GetRarity(Object.GetOrDefault("Rarity", EFortRarity.Uncommon)); // default is uncommon
// preview
@ -127,6 +128,21 @@ public class BaseIcon : UCreator
GetSeries(export);
}
private void GetSeries(FStructFallback s)
{
if (!s.TryGetValue(out FPackageIndex[] components, "Components")) return;
foreach (var component in components)
{
if (!component.TryLoad(out var componentObj) ||
!componentObj!.TryGetValue(out UObject componentSeriesDef, "Series"))
continue;
GetSeries(componentSeriesDef);
break;
}
}
protected void GetSeries(UObject uObject)
{
if (uObject is UTexture2D texture2D)