mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
* Failed type checks return null * Bad dependency numbers return null * Remove GetAsset methods * Make asset processing more lenient about null references
36 lines
816 B
C#
36 lines
816 B
C#
using AssetRipper.Assets;
|
|
using AssetRipper.Assets.Collections;
|
|
using AssetRipper.Assets.Metadata;
|
|
|
|
namespace AssetRipper.SourceGenerated.Extensions;
|
|
|
|
public static class PPtrExtensions
|
|
{
|
|
public static T? TryGetAsset<T>(this IPPtr<T> pptr, AssetCollection file) where T : IUnityObjectBase
|
|
{
|
|
pptr.TryGetAsset(file, out T? asset);
|
|
return asset;
|
|
}
|
|
|
|
public static bool IsAsset<T>(this IPPtr<T> pptr, IAssetContainer file, IUnityObjectBase asset) where T : IUnityObjectBase
|
|
{
|
|
if (asset.PathID != pptr.PathID)
|
|
{
|
|
return false;
|
|
}
|
|
else if (pptr.FileID == 0)
|
|
{
|
|
return file == asset.Collection;
|
|
}
|
|
else
|
|
{
|
|
return file.Dependencies[pptr.FileID - 1] == asset.Collection;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// PathID == 0
|
|
/// </summary>
|
|
public static bool IsNull(this IPPtr pptr) => pptr.PathID == 0;
|
|
}
|