diff --git a/IPA/PatchContext.cs b/IPA/PatchContext.cs index 8e4df88..36427ee 100644 --- a/IPA/PatchContext.cs +++ b/IPA/PatchContext.cs @@ -49,7 +49,7 @@ namespace IPA context.ProjectName = Path.GetFileNameWithoutExtension(context.Executable); context.DataPathDst = Path.Combine(context.ProjectRoot, context.ProjectName + "_Data"); context.ManagedPath = Path.Combine(context.DataPathDst, "Managed"); - context.EngineFile = Path.Combine(context.ManagedPath, (File.Exists(Path.Combine(context.ManagedPath, "UnityEngine.CoreModule.dll")) ? "UnityEngine.CoreModule.dll" : "UnityEngine.dll")); + context.EngineFile = DetermineEngineFile(context.ManagedPath, "UnityEngine.dll", "UnityEngine.CoreModule.dll"); context.AssemblyFile = Path.Combine(context.ManagedPath, "Assembly-Csharp.dll"); context.BackupPath = Path.Combine(Path.Combine(context.IPARoot, "Backups"), context.ProjectName); string shortcutName = string.Format("{0} (Patch & Launch)", context.ProjectName); @@ -59,5 +59,19 @@ namespace IPA return context; } + + private static string DetermineEngineFile(string basePath, params string[] candidates) + { + foreach(var candidate in candidates) + { + var fullPath = Path.Combine(basePath, candidate); + if(File.Exists(fullPath)) + { + return fullPath; + } + } + + throw new FileNotFoundException("Could not find engine DLL!"); + } } }