mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-19 15:51:45 +00:00
Merge pull request #475 from js6pak/chainloader-events
Add chainloader events
This commit is contained in:
2 files changed
+18
-1
No files matched your search
@@ -125,6 +125,16 @@ public abstract class BaseChainloader<TPlugin>
|
||||
/// Contains information about what certain plugins were not loaded.
|
||||
/// </summary>
|
||||
public List<string> DependencyErrors { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after a plugin is loaded.
|
||||
/// </summary>
|
||||
public event Action<PluginInfo> PluginLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after all plugins are loaded.
|
||||
/// </summary>
|
||||
public event Action Finished;
|
||||
|
||||
public virtual void Initialize(string gameExePath = null)
|
||||
{
|
||||
@@ -305,6 +315,7 @@ public abstract class BaseChainloader<TPlugin>
|
||||
var plugins = DiscoverPlugins();
|
||||
Logger.Log(LogLevel.Info, $"{plugins.Count} plugin{(plugins.Count == 1 ? "" : "s")} to load");
|
||||
LoadPlugins(plugins);
|
||||
Finished?.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -400,7 +411,7 @@ public abstract class BaseChainloader<TPlugin>
|
||||
plugin.Instance = LoadPlugin(plugin, ass);
|
||||
loadedPlugins.Add(plugin);
|
||||
|
||||
//_plugins.Add((TPlugin)plugin.Instance);
|
||||
PluginLoaded?.Invoke(plugin);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -48,6 +48,11 @@ public class IL2CPPChainloader : BaseChainloader<BasePlugin>
|
||||
/// <param name="t">Type of the component to add</param>
|
||||
public static Il2CppObjectBase AddUnityComponent(Type t) => Il2CppUtils.AddComponent(t);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after a plugin is instantiated and just before <see cref="BasePlugin.Load"/> is called.
|
||||
/// </summary>
|
||||
public event Action<PluginInfo, Assembly, BasePlugin> PluginLoad;
|
||||
|
||||
public override void Initialize(string gameExePath = null)
|
||||
{
|
||||
base.Initialize(gameExePath);
|
||||
@@ -125,6 +130,7 @@ public class IL2CPPChainloader : BaseChainloader<BasePlugin>
|
||||
|
||||
var pluginInstance = (BasePlugin) Activator.CreateInstance(type);
|
||||
|
||||
PluginLoad?.Invoke(pluginInfo, pluginAssembly, pluginInstance);
|
||||
pluginInstance.Load();
|
||||
|
||||
return pluginInstance;
|
||||
|
||||
Reference in new issue
Block a user