/// <summary> /// Determines which imports and exports are not referenced and will be dropped when the file loads /// </summary> public static void CheckImportsWithPersistence() { var file = @"B:\SteamLibrary\steamapps\common\Mass Effect 2\BioGame\DLC\DLC_MOD_ME2Randomizer\CookedPC\BioD_CitHub_300UpperWing_LOC_INT.pcc"; //var file = @"B:\SteamLibrary\steamapps\common\Mass Effect 2\BioGame\CookedPC\BioP_JnkKgA.pcc"; var persistP = MEPackageHandler.OpenMEPackage(file); var persistentLevel = persistP.FindExport("TheWorld.PersistentLevel"); var objectReferencer = persistP.Exports.FirstOrDefault(x => x.idxLink == 0 && x.ClassName == "ObjectReferencer"); if (persistentLevel == null && objectReferencer == null) { Debugger.Break(); } var importableObjects = EntryImporter.GetAllReferencesOfExport(persistentLevel ?? objectReferencer, true); Debug.WriteLine($"Referenced objects: {importableObjects.Count}. {importableObjects.Count(x => x is ImportEntry)} imports, {importableObjects.Count(x => x is ExportEntry)} exports"); Debug.WriteLine($"Unreferenced objects: {(persistP.ImportCount + persistP.ExportCount) - importableObjects.Count}. {persistP.ImportCount - importableObjects.Count(x => x is ImportEntry)} imports, {persistP.ExportCount - importableObjects.Count(x => x is ExportEntry)} exports:"); var droppedImports = persistP.Imports.Except(importableObjects); var droppedExports = persistP.Exports.Except(importableObjects); foreach (var imp in droppedImports) { Debug.WriteLine($" >> Dropped import: {imp.UIndex} {imp.InstancedFullPath}"); } foreach (var exp in droppedExports) { Debug.WriteLine($" >> Dropped export: {exp.UIndex} {exp.InstancedFullPath}"); } }