From 79106649b74a42051b55529b07fc9c54f21323a9 Mon Sep 17 00:00:00 2001 From: Bepis <36346617+bbepis@users.noreply.github.com> Date: Mon, 19 Feb 2018 00:30:19 +1100 Subject: [PATCH] Remove redundant and old code --- BepInEx.Patcher/BepInEx.Patcher.csproj | 1 - BepInEx.Patcher/IPatchPlugin.cs | 13 ------ BepInEx/BepInComponent.cs | 61 -------------------------- BepInEx/BepInEx.csproj | 2 - BepInEx/Chainloader.cs | 26 +++++++---- BepInEx/ITranslationPlugin.cs | 12 ----- 6 files changed, 17 insertions(+), 98 deletions(-) delete mode 100644 BepInEx.Patcher/IPatchPlugin.cs delete mode 100644 BepInEx/BepInComponent.cs delete mode 100644 BepInEx/ITranslationPlugin.cs diff --git a/BepInEx.Patcher/BepInEx.Patcher.csproj b/BepInEx.Patcher/BepInEx.Patcher.csproj index a6df0c0..fb51d3a 100644 --- a/BepInEx.Patcher/BepInEx.Patcher.csproj +++ b/BepInEx.Patcher/BepInEx.Patcher.csproj @@ -55,7 +55,6 @@ - diff --git a/BepInEx.Patcher/IPatchPlugin.cs b/BepInEx.Patcher/IPatchPlugin.cs deleted file mode 100644 index 3635286..0000000 --- a/BepInEx.Patcher/IPatchPlugin.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Mono.Cecil; - -namespace BepInEx.Patcher -{ - public interface IPatchPlugin - { - void Patch(AssemblyDefinition assembly); - } -} diff --git a/BepInEx/BepInComponent.cs b/BepInEx/BepInComponent.cs deleted file mode 100644 index 54df290..0000000 --- a/BepInEx/BepInComponent.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using TMPro; -using UnityEngine; -using UnityEngine.SceneManagement; - -namespace BepInEx -{ - //Adapted from https://github.com/Eusth/IPA/blob/0df8b1ecb87fdfc9e169365cb4a8fd5a909a2ad6/IllusionInjector/PluginComponent.cs - public class BepInComponent : MonoBehaviour - { - List Plugins; - private bool quitting = false; - - public static GameObject Create() - { - var obj = new GameObject("BepInEx_Manager"); - - var manager = obj.AddComponent(); - - manager.Plugins = new List(); - - foreach (Type t in Chainloader.Plugins) - { - var plugin = (BaseUnityPlugin)obj.AddComponent(t); - manager.Plugins.Add(plugin); - Console.WriteLine($"Loaded [{plugin.Name}]"); - } - - - return obj; - } - - void Awake() - { - DontDestroyOnLoad(gameObject); - } - - void Start() - { - Console.WriteLine("Component ready"); - } - - void OnDestroy() - { - if (!quitting) - { - Create(); - } - } - - void OnApplicationQuit() - { - quitting = true; - } - } -} diff --git a/BepInEx/BepInEx.csproj b/BepInEx/BepInEx.csproj index 3a5a160..5976191 100644 --- a/BepInEx/BepInEx.csproj +++ b/BepInEx/BepInEx.csproj @@ -60,7 +60,6 @@ - @@ -70,7 +69,6 @@ - diff --git a/BepInEx/Chainloader.cs b/BepInEx/Chainloader.cs index 8051ca9..6daae63 100644 --- a/BepInEx/Chainloader.cs +++ b/BepInEx/Chainloader.cs @@ -14,8 +14,8 @@ namespace BepInEx public class Chainloader { static bool loaded = false; - public static IEnumerable Plugins { get; protected set; } - public static GameObject ManagerObject { get; protected set; } + public static List Plugins { get; protected set; } = new List(); + public static GameObject ManagerObject { get; protected set; } = new GameObject("BepInEx_Manager"); public static void Initialize() { @@ -25,26 +25,34 @@ namespace BepInEx UnityInjector.ConsoleUtil.ConsoleWindow.Attach(); Console.WriteLine("Chainloader started"); + UnityEngine.Object.DontDestroyOnLoad(ManagerObject); + + if (Directory.Exists(Utility.PluginsDirectory)) { - Plugins = LoadTypes(Utility.PluginsDirectory); + var pluginTypes = LoadTypes(Utility.PluginsDirectory); //UnityInjector.ConsoleUtil.ConsoleEncoding.ConsoleCodePage = 932; - Console.WriteLine($"{Plugins.Count()} plugins found"); + Console.WriteLine($"{pluginTypes.Count()} plugins found"); + + + foreach (Type t in pluginTypes) + { + var plugin = (BaseUnityPlugin)ManagerObject.AddComponent(t); + Plugins.Add(plugin); + Console.WriteLine($"Loaded [{plugin.Name}]"); + } } else { - Plugins = new List(); Console.WriteLine("Plugins directory not found, skipping"); } - - - ManagerObject = BepInComponent.Create(); + loaded = true; } - public static ICollection LoadTypes(string directory) + public static List LoadTypes(string directory) { List types = new List(); Type pluginType = typeof(T); diff --git a/BepInEx/ITranslationPlugin.cs b/BepInEx/ITranslationPlugin.cs deleted file mode 100644 index 6762b5b..0000000 --- a/BepInEx/ITranslationPlugin.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BepInEx -{ - public interface ITranslationPlugin - { - bool TryTranslate(string input, out string output); - } -}