From 9f7cc2d7724da7319f32a799d5dd1caa76996ee2 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Sun, 7 Jan 2024 16:21:59 -0500 Subject: [PATCH] Delete IAssetContainer --- .../Collections/AssetCollection.cs | 2 +- .../Collections/IAssetContainer.cs | 29 ------------------- .../Export/IExportContainer.cs | 2 +- .../ProjectAssetContainer.cs | 17 +---------- .../OcclusionCullingDataExtensions.cs | 17 +++++------ .../PPtrExtensions.cs | 2 +- 6 files changed, 11 insertions(+), 58 deletions(-) delete mode 100644 Source/AssetRipper.Assets/Collections/IAssetContainer.cs diff --git a/Source/AssetRipper.Assets/Collections/AssetCollection.cs b/Source/AssetRipper.Assets/Collections/AssetCollection.cs index 22b468b06..f9a9eb451 100644 --- a/Source/AssetRipper.Assets/Collections/AssetCollection.cs +++ b/Source/AssetRipper.Assets/Collections/AssetCollection.cs @@ -10,7 +10,7 @@ namespace AssetRipper.Assets.Collections; /// /// A collection of assets. /// -public abstract class AssetCollection : IReadOnlyCollection, IAssetContainer +public abstract class AssetCollection : IReadOnlyCollection { protected AssetCollection(Bundle bundle) { diff --git a/Source/AssetRipper.Assets/Collections/IAssetContainer.cs b/Source/AssetRipper.Assets/Collections/IAssetContainer.cs deleted file mode 100644 index 3e7981590..000000000 --- a/Source/AssetRipper.Assets/Collections/IAssetContainer.cs +++ /dev/null @@ -1,29 +0,0 @@ -using AssetRipper.IO.Files; -using AssetRipper.IO.Files.SerializedFiles; - -namespace AssetRipper.Assets.Collections -{ - public interface IAssetContainer - { - /// - /// Try to find an asset in the current serialized file - /// - /// Path ID of the asset - /// Found asset or null - IUnityObjectBase? TryGetAsset(long pathID); - /// - /// Try to get asset in the dependency file with specified file index - /// - /// Dependent file index - /// Path ID of the asset - /// Found asset or null - IUnityObjectBase? TryGetAsset(int fileIndex, long pathID); - - string Name { get; } - UnityVersion Version { get; } - BuildTarget Platform { get; } - TransferInstructionFlags Flags { get; } - - IReadOnlyList Dependencies { get; } - } -} diff --git a/Source/AssetRipper.Assets/Export/IExportContainer.cs b/Source/AssetRipper.Assets/Export/IExportContainer.cs index e8afeeb22..a2e556f85 100644 --- a/Source/AssetRipper.Assets/Export/IExportContainer.cs +++ b/Source/AssetRipper.Assets/Export/IExportContainer.cs @@ -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); diff --git a/Source/AssetRipper.Export.UnityProjects/ProjectAssetContainer.cs b/Source/AssetRipper.Export.UnityProjects/ProjectAssetContainer.cs index 8e532710a..cc30564c9 100644 --- a/Source/AssetRipper.Export.UnityProjects/ProjectAssetContainer.cs +++ b/Source/AssetRipper.Export.UnityProjects/ProjectAssetContainer.cs @@ -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 Dependencies => File.Dependencies; + private readonly TransferInstructionFlags _exportFlags; private readonly ProjectExporter m_exporter; private readonly Dictionary m_assetCollections = new(); diff --git a/Source/AssetRipper.SourceGenerated.Extensions/OcclusionCullingDataExtensions.cs b/Source/AssetRipper.SourceGenerated.Extensions/OcclusionCullingDataExtensions.cs index a12b486d0..ba091c8ae 100644 --- a/Source/AssetRipper.SourceGenerated.Extensions/OcclusionCullingDataExtensions.cs +++ b/Source/AssetRipper.SourceGenerated.Extensions/OcclusionCullingDataExtensions.cs @@ -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 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; diff --git a/Source/AssetRipper.SourceGenerated.Extensions/PPtrExtensions.cs b/Source/AssetRipper.SourceGenerated.Extensions/PPtrExtensions.cs index 455592daf..8ca5ba3c4 100644 --- a/Source/AssetRipper.SourceGenerated.Extensions/PPtrExtensions.cs +++ b/Source/AssetRipper.SourceGenerated.Extensions/PPtrExtensions.cs @@ -12,7 +12,7 @@ public static class PPtrExtensions return asset; } - public static bool IsAsset(this IPPtr pptr, IAssetContainer file, IUnityObjectBase asset) where T : IUnityObjectBase + public static bool IsAsset(this IPPtr pptr, AssetCollection file, IUnityObjectBase asset) where T : IUnityObjectBase { if (asset.PathID != pptr.PathID) {