/// <summary> /// Trashes an entry. /// </summary> /// <param name="entry">Entry to trash</param> /// <param name="trashContainer">Container for trash. Pass null if you want to create the trash container from the passed in value.</param> /// <param name="packageClassIdx">Idx for package class. Prevents multiple calls to find it</param> /// <returns>New trash container, otherwise will be null</returns> public static ExportEntry TrashEntry(IEntry entry, ExportEntry trashContainer, int packageClassIdx) { IMEPackage pcc = entry.FileRef; if (entry is ImportEntry imp) { if (trashContainer == null) { trashContainer = TrashEntry(new ExportEntry(pcc), null, packageClassIdx); pcc.addExport(trashContainer); trashContainer.indexValue = 0; } imp.idxClassName = pcc.FindNameOrAdd("Package"); imp.idxPackageFile = pcc.FindNameOrAdd("Core"); imp.idxLink = trashContainer.UIndex; imp.idxObjectName = pcc.FindNameOrAdd("Trash"); imp.indexValue = 0; } else if (entry is ExportEntry exp) { MemoryStream trashData = new MemoryStream(); trashData.WriteInt32(-1); trashData.WriteInt32(pcc.findName("None")); trashData.WriteInt32(0); exp.Data = trashData.ToArray(); exp.idxArchtype = 0; exp.idxSuperClass = 0; exp.indexValue = 0; exp.idxClass = packageClassIdx; exp.ObjectFlags &= ~UnrealFlags.EObjectFlags.HasStack; if (trashContainer == null) { exp.idxObjectName = pcc.FindNameOrAdd(UnrealPackageFile.TrashPackageName); exp.idxLink = 0; if (exp.idxLink == exp.UIndex) { Debugger.Break(); } exp.PackageGUID = UnrealPackageFile.TrashPackageGuid; trashContainer = exp; } else { exp.idxLink = trashContainer.UIndex; if (exp.idxLink == exp.UIndex) { //This should not occur Debugger.Break(); } exp.idxObjectName = pcc.FindNameOrAdd("Trash"); exp.PackageGUID = Guid.Empty; } } return(trashContainer); }