Class BaseChainloader<TPlugin>
Syntax
public abstract class BaseChainloader<TPlugin>
Type Parameters
Name | Description |
---|---|
TPlugin |
Fields
CurrentAssemblyName
Declaration
protected static readonly string CurrentAssemblyName
Field Value
Type | Description |
---|---|
System.String |
CurrentAssemblyVersion
Declaration
protected static readonly Version CurrentAssemblyVersion
Field Value
Type | Description |
---|---|
System.Version |
Properties
Declaration
protected virtual string ConsoleTitle { get; }
Property Value
Type | Description |
---|---|
System.String |
Collection of error chainloader messages that occured during plugin loading. Contains information about what certain plugins were not loaded.
Declaration
public List<string> DependencyErrors { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
List of all PluginInfo instances loaded via the chainloader.
Declaration
public Dictionary<string, PluginInfo> Plugins { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, PluginInfo> |
Methods
Discovers plugins to load.
Declaration
protected virtual IList<PluginInfo> DiscoverPlugins()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<PluginInfo> |
List of plugins to be loaded. |
Discovers all plugins in the plugin directory without loading them.
Declaration
protected IList<PluginInfo> DiscoverPluginsFrom(string path, string cacheName = "chainloader")
Parameters
Type | Name | Description |
---|---|---|
System.String |
path |
Path from which to search the plugins. |
System.String |
cacheName |
Cache name to use. If null, results are not cached. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<PluginInfo> |
List of discovered plugins and their metadata. |
Remarks
This is useful for discovering BepInEx plugin metadata.
Run the chainloader and load all plugins from the plugins folder.
Declaration
public virtual void Execute()
Declaration
protected static bool HasBepinPlugins(AssemblyDefinition ass)
Parameters
Type | Name | Description |
---|---|---|
AssemblyDefinition |
ass |
Returns
Type | Description |
---|---|
System.Boolean |
Declaration
public virtual void Initialize(string gameExePath = null)
Parameters
Type | Name | Description |
---|---|---|
System.String |
gameExePath |
Declaration
protected virtual void InitializeLoggers()
Declaration
public abstract TPlugin LoadPlugin(PluginInfo pluginInfo, Assembly pluginAssembly)
Parameters
Type | Name | Description |
---|---|---|
PluginInfo |
pluginInfo |
|
System.Reflection.Assembly |
pluginAssembly |
Returns
Type | Description |
---|---|
TPlugin |
Detects and loads all plugins in the specified directories.
Declaration
public IList<PluginInfo> LoadPlugins(params string[] pluginsPaths)
Parameters
Type | Name | Description |
---|---|---|
System.String[] |
pluginsPaths |
Directories to search the plugins from. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<PluginInfo> |
List of loaded plugin infos. |
Remarks
It is better to collect all paths at once and use a single call to LoadPlugins than multiple calls. This allows to run proper dependency resolving and to load all plugins in one go.
Preprocess the plugins and modify the load order.
Declaration
protected virtual IList<PluginInfo> ModifyLoadOrder(IList<PluginInfo> plugins)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<PluginInfo> |
plugins |
Plugins to process. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<PluginInfo> |
List of plugins to load in the correct load order. |
Remarks
Some plugins may be skipped if they cannot be loaded (wrong metadata, etc).
Declaration
protected static bool PluginTargetsWrongBepin(PluginInfo pluginInfo)
Parameters
Type | Name | Description |
---|---|---|
PluginInfo |
pluginInfo |
Returns
Type | Description |
---|---|
System.Boolean |
Analyzes the given type definition and attempts to convert it to a valid PluginInfo
Declaration
public static PluginInfo ToPluginInfo(TypeDefinition type, string assemblyLocation)
Parameters
Type | Name | Description |
---|---|---|
TypeDefinition |
type |
Type definition to analyze. |
System.String |
assemblyLocation |
The filepath of the assembly, to keep as metadata. |
Returns
Type | Description |
---|---|
PluginInfo |
If the type represent a valid plugin, returns a PluginInfo instance. Otherwise, return null. |
Events
Finished
Occurs after all plugins are loaded.
Declaration
public event Action Finished
Event Type
Type | Description |
---|---|
System.Action |
PluginLoaded
Occurs after a plugin is loaded.
Declaration
public event Action<PluginInfo> PluginLoaded
Event Type
Type | Description |
---|---|
System.Action<PluginInfo> |