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