Delete IAssetContainer

This commit is contained in:
ds5678 2024-01-07 16:21:59 -05:00
parent bde19f1e47
commit 9f7cc2d772
6 changed files with 11 additions and 58 deletions

View File

@ -10,7 +10,7 @@ namespace AssetRipper.Assets.Collections;
/// <summary>
/// A collection of <see cref="IUnityObjectBase"/> assets.
/// </summary>
public abstract class AssetCollection : IReadOnlyCollection<IUnityObjectBase>, IAssetContainer
public abstract class AssetCollection : IReadOnlyCollection<IUnityObjectBase>
{
protected AssetCollection(Bundle bundle)
{

View File

@ -1,29 +0,0 @@
using AssetRipper.IO.Files;
using AssetRipper.IO.Files.SerializedFiles;
namespace AssetRipper.Assets.Collections
{
public interface IAssetContainer
{
/// <summary>
/// Try to find an asset in the current serialized file
/// </summary>
/// <param name="pathID">Path ID of the asset</param>
/// <returns>Found asset or null</returns>
IUnityObjectBase? TryGetAsset(long pathID);
/// <summary>
/// Try to get asset in the dependency file with specified file index
/// </summary>
/// <param name="fileIndex">Dependent file index</param>
/// <param name="pathID">Path ID of the asset</param>
/// <returns>Found asset or null</returns>
IUnityObjectBase? TryGetAsset(int fileIndex, long pathID);
string Name { get; }
UnityVersion Version { get; }
BuildTarget Platform { get; }
TransferInstructionFlags Flags { get; }
IReadOnlyList<AssetCollection?> Dependencies { get; }
}
}

View File

@ -5,7 +5,7 @@ using AssetRipper.IO.Files.SerializedFiles;
namespace AssetRipper.Assets.Export
{
public interface IExportContainer : IAssetContainer
public interface IExportContainer
{
long GetExportID(IUnityObjectBase asset);
AssetType ToExportType(Type type);

View File

@ -42,16 +42,6 @@ namespace AssetRipper.Export.UnityProjects
m_scenes = scenes.ToArray();
}
public IUnityObjectBase? TryGetAsset(long pathID)
{
return File.TryGetAsset(pathID);
}
public virtual IUnityObjectBase? TryGetAsset(int fileIndex, long pathID)
{
return File.TryGetAsset(fileIndex, pathID);
}
public long GetExportID(IUnityObjectBase asset)
{
if (m_assetCollections.TryGetValue(asset, out IExportCollection? collection))
@ -93,16 +83,11 @@ namespace AssetRipper.Export.UnityProjects
public IExportCollection CurrentCollection { get; set; }
public AssetCollection File => CurrentCollection.File;
public string Name => File.Name;
public UnityVersion Version => File.Version;
public BuildTarget Platform => File.Platform;
public TransferInstructionFlags Flags => File.Flags;
public UnityVersion ExportVersion { get; }
public BuildTarget ExportPlatform { get; }
private readonly TransferInstructionFlags _exportFlags;
public TransferInstructionFlags ExportFlags => _exportFlags | CurrentCollection.Flags;
public IReadOnlyList<AssetCollection?> Dependencies => File.Dependencies;
private readonly TransferInstructionFlags _exportFlags;
private readonly ProjectExporter m_exporter;
private readonly Dictionary<IUnityObjectBase, IExportCollection> m_assetCollections = new();

View File

@ -54,21 +54,21 @@ namespace AssetRipper.SourceGenerated.Extensions
public static void SetExportData(this IOcclusionCullingData occlusionCullingData, IExportContainer container)
{
// if < 3.0.0 this asset doesn't exist
// If < 3.0.0, this asset doesn't exist.
// 3.0.0 to 5.5.0 this asset is created by culling settings so it has set data already
if (container.Version.LessThan(5, 5))
// For 3.0.0 to 5.5.0, this asset is created by culling settings, so its data is already set.
if (occlusionCullingData.Collection.Version.LessThan(5, 5))
{
return;
}
// if >= 5.5.0 and !Release this asset containts renderer data
if (!container.Flags.IsRelease())
// If >= 5.5.0 and not Release, this asset contains renderer data,
if (!occlusionCullingData.Collection.Flags.IsRelease())
{
return;
}
// if >= 5.5.0 and Release this asset doesn't containt renderers data so we need to create it
// If >= 5.5.0 and Release. this asset doesn't contain renderer data, so we need to create it.
List<IOcclusionCullingSettings> cullingSettings = new();
foreach (IUnityObjectBase asset in occlusionCullingData.Collection.Bundle.FetchAssetsInHierarchy())
{
@ -131,10 +131,7 @@ namespace AssetRipper.SourceGenerated.Extensions
private static void SetObjectID(this ISceneObjectIdentifier sceneObjectIdentifier, IExportContainer container, IUnityObjectBase? asset)
{
if (sceneObjectIdentifier is null)
{
throw new ArgumentNullException(nameof(sceneObjectIdentifier));
}
ArgumentNullException.ThrowIfNull(sceneObjectIdentifier);
long lid = asset == null ? 0 : container.GetExportID(asset);
sceneObjectIdentifier.TargetObject = lid;

View File

@ -12,7 +12,7 @@ public static class PPtrExtensions
return asset;
}
public static bool IsAsset<T>(this IPPtr<T> pptr, IAssetContainer file, IUnityObjectBase asset) where T : IUnityObjectBase
public static bool IsAsset<T>(this IPPtr<T> pptr, AssetCollection file, IUnityObjectBase asset) where T : IUnityObjectBase
{
if (asset.PathID != pptr.PathID)
{