mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Remove redundant and old code
This commit is contained in:
1 parent
102411d7e3
commit
79106649b7
6 files changed
+17
-98
No files matched your search
@@ -55,7 +55,6 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IPatchPlugin.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<BaseUnityPlugin> Plugins;
|
||||
private bool quitting = false;
|
||||
|
||||
public static GameObject Create()
|
||||
{
|
||||
var obj = new GameObject("BepInEx_Manager");
|
||||
|
||||
var manager = obj.AddComponent<BepInComponent>();
|
||||
|
||||
manager.Plugins = new List<BaseUnityPlugin>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BepInComponent.cs" />
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="ConsoleUtil\ConsoleEncoding\ConsoleEncoding.Buffers.cs" />
|
||||
<Compile Include="ConsoleUtil\ConsoleEncoding\ConsoleEncoding.cs" />
|
||||
@@ -70,7 +69,6 @@
|
||||
<Compile Include="ConsoleUtil\Extensions.cs" />
|
||||
<Compile Include="ConsoleUtil\SafeConsole.cs" />
|
||||
<Compile Include="Chainloader.cs" />
|
||||
<Compile Include="ITranslationPlugin.cs" />
|
||||
<Compile Include="BaseUnityPlugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
+17
-9
@@ -14,8 +14,8 @@ namespace BepInEx
|
||||
public class Chainloader
|
||||
{
|
||||
static bool loaded = false;
|
||||
public static IEnumerable<Type> Plugins { get; protected set; }
|
||||
public static GameObject ManagerObject { get; protected set; }
|
||||
public static List<BaseUnityPlugin> Plugins { get; protected set; } = new List<BaseUnityPlugin>();
|
||||
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<BaseUnityPlugin>(Utility.PluginsDirectory);
|
||||
var pluginTypes = LoadTypes<BaseUnityPlugin>(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<Type>();
|
||||
Console.WriteLine("Plugins directory not found, skipping");
|
||||
}
|
||||
|
||||
|
||||
ManagerObject = BepInComponent.Create();
|
||||
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
public static ICollection<Type> LoadTypes<T>(string directory)
|
||||
public static List<Type> LoadTypes<T>(string directory)
|
||||
{
|
||||
List<Type> types = new List<Type>();
|
||||
Type pluginType = typeof(T);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user