From 0df8b1ecb87fdfc9e169365cb4a8fd5a909a2ad6 Mon Sep 17 00:00:00 2001 From: Eusth Date: Sat, 22 Apr 2017 21:15:36 +0200 Subject: [PATCH] Improve shutdown handling and disable virtualizing when no Assembly is available. --- IPA/Program.cs | 17 ++++++++++------- IllusionInjector/PluginComponent.cs | 11 ++++++++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/IPA/Program.cs b/IPA/Program.cs index 3d36efa..b056da1 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -48,7 +48,7 @@ static void Main(string[] args) private static void Validate(PatchContext c) { if (!File.Exists(c.LauncherPathSrc)) Fail("Couldn't find DLLs! Make sure you extracted all contents of the release archive."); - if (!Directory.Exists(c.DataPathDst) || !File.Exists(c.EngineFile) || !File.Exists(c.AssemblyFile)) + if (!Directory.Exists(c.DataPathDst) || !File.Exists(c.EngineFile)) { Fail("Game does not seem to be a Unity project. Could not find the libraries to patch."); } @@ -86,13 +86,16 @@ private static void Install(PatchContext context) } // Virtualizing - var virtualizedModule = VirtualizedModule.Load(context.AssemblyFile); - if (!virtualizedModule.IsVirtualized) + if (File.Exists(context.AssemblyFile)) { - Console.Write("Virtualizing Assembly-Csharp.dll... "); - backup.Add(context.AssemblyFile); - virtualizedModule.Virtualize(); - Console.WriteLine("Done!"); + var virtualizedModule = VirtualizedModule.Load(context.AssemblyFile); + if (!virtualizedModule.IsVirtualized) + { + Console.Write("Virtualizing Assembly-Csharp.dll... "); + backup.Add(context.AssemblyFile); + virtualizedModule.Virtualize(); + Console.WriteLine("Done!"); + } } // Creating shortcut diff --git a/IllusionInjector/PluginComponent.cs b/IllusionInjector/PluginComponent.cs index 1f40032..d3dc578 100644 --- a/IllusionInjector/PluginComponent.cs +++ b/IllusionInjector/PluginComponent.cs @@ -9,6 +9,7 @@ public class PluginComponent : MonoBehaviour { private CompositePlugin plugins; private bool freshlyLoaded = false; + private bool quitting = false; public static PluginComponent Create() { @@ -49,10 +50,18 @@ void FixedUpdate() } void OnDestroy() + { + if (!quitting) + { + Create(); + } + } + + void OnApplicationQuit() { plugins.OnApplicationQuit(); - Create(); + quitting = true; } void OnLevelWasLoaded(int level)