Skip to content

BaseChainloader<TPlugin> Class

C#
public abstract class BaseChainloader<TPlugin>

TPlugin

Inheritance object

C#
protected static readonly string CurrentAssemblyName
C#
protected static readonly Version CurrentAssemblyVersion
C#
protected virtual string ConsoleTitle { get; }

List of all PluginInfo instances loaded via the chainloader.

C#
public Dictionary<string, PluginInfo> Plugins { get; }

Collection of error chainloader messages that occured during plugin loading. Contains information about what certain plugins were not loaded.

C#
public List<string> DependencyErrors { get; }

Analyzes the given type definition and attempts to convert it to a valid PluginInfo

C#
public static PluginInfo ToPluginInfo(TypeDefinition type, string assemblyLocation)

type TypeDefinition
Type definition to analyze.

assemblyLocation string
The filepath of the assembly, to keep as metadata.

PluginInfo
If the type represent a valid plugin, returns a PluginInfo instance. Otherwise, return null.

C#
protected static bool HasBepinPlugins(AssemblyDefinition ass)

ass AssemblyDefinition

bool

C#
protected static bool PluginTargetsWrongBepin(PluginInfo pluginInfo)

pluginInfo PluginInfo

bool

C#
public virtual void Initialize(string gameExePath = null)

gameExePath string

C#
protected virtual void InitializeLoggers()

Discovers all plugins in the plugin directory without loading them.

C#
protected IList<PluginInfo> DiscoverPluginsFrom(string path, string cacheName = "chainloader")

path string
Path from which to search the plugins.

cacheName string
Cache name to use. If null, results are not cached.

IList<PluginInfo>
List of discovered plugins and their metadata.

This is useful for discovering BepInEx plugin metadata.

Discovers plugins to load.

C#
protected virtual IList<PluginInfo> DiscoverPlugins()

IList<PluginInfo>
List of plugins to be loaded.

Preprocess the plugins and modify the load order.

C#
protected virtual IList<PluginInfo> ModifyLoadOrder(IList<PluginInfo> plugins)

plugins IList<PluginInfo>
Plugins to process.

IList<PluginInfo>
List of plugins to load in the correct load order.

Some plugins may be skipped if they cannot be loaded (wrong metadata, etc).

Run the chainloader and load all plugins from the plugins folder.

C#
public virtual void Execute()

Detects and loads all plugins in the specified directories.

C#
public IList<PluginInfo> LoadPlugins(params string[] pluginsPaths)

pluginsPaths string[]
Directories to search the plugins from.

IList<PluginInfo>
List of loaded plugin infos.

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.

C#
public abstract TPlugin LoadPlugin(PluginInfo pluginInfo, Assembly pluginAssembly)

pluginInfo PluginInfo

pluginAssembly Assembly

TPlugin

Occurs after a plugin is loaded.

C#
public event Action<PluginInfo> PluginLoaded

Action<PluginInfo>

Occurs after all plugins are loaded.

C#
public event Action Finished

Action