Skip to main content

Overview

The PluginManager class is the core plugin manager responsible for loading and managing plugin extensions in Frosty Toolsuite. It discovers plugins from the Plugins/ directory, validates them, and provides access to various extension types.

Constructor

PluginManager

public PluginManager(ILogger logger, PluginManagerType context)
Initializes a new instance of the PluginManager with the specified logger and context.
logger
ILogger
required
The logging interface the plugin manager should use
context
PluginManagerType
required
The context which this plugin should load for (Editor, ModManager, or Both)
var logger = new MyLogger();
var pluginManager = new PluginManager(logger, PluginManagerType.Editor);

Properties

ManagerType

public PluginManagerType ManagerType { get; }
Retrieves the enum defining which manager is being loaded (Editor, ModManager, or Both).

Plugins

public IEnumerable<Plugin> Plugins { get; }
An enumerable collection of all plugins that have been found in the Plugins directory.

LoadedPlugins

public IEnumerable<Plugin> LoadedPlugins { get; }
A collection of plugins that have been successfully loaded and validated for the current profile.
public IEnumerable<MenuExtension> MenuExtensions { get; }
Retrieves menu extensions that have been loaded from plugins.

TabExtensions

public IEnumerable<TabExtension> TabExtensions { get; }
Retrieves tab extensions that have been loaded from plugins.

DataExplorerContextMenuExtensions

public IEnumerable<DataExplorerContextMenuExtension> DataExplorerContextMenuExtensions { get; }
Retrieves data explorer context menu item extensions loaded from plugins.

ExecutionActions

public IEnumerable<ExecutionAction> ExecutionActions { get; }
Retrieves execution actions that have been loaded from plugins for mod launching.

OptionsExtensions

public IEnumerable<Type> OptionsExtensions { get; }
Retrieves options extensions that have been loaded from plugins.

Profiles

public IEnumerable<Profile> Profiles { get; }
Retrieves game profiles that have been loaded from plugins.

StartupActions

public IEnumerable<StartupAction> StartupActions { get; }
Retrieves startup actions that have been loaded from plugins.

Methods

Initialize

public void Initialize()
Initializes all post-profile assembly plugins. This method must be called after the game profile is loaded to initialize profile-specific plugins.
pluginManager.Initialize();

GetAssetDefinition

public AssetDefinition GetAssetDefinition(string type)
Returns the AssetDefinition for the specified asset type.
type
string
required
The type of the asset definition to obtain (case-insensitive)
return
AssetDefinition
The AssetDefinition for the specified type, or null if not found
AssetDefinition meshDef = pluginManager.GetAssetDefinition("MeshAsset");
if (meshDef != null)
{
    var editor = meshDef.GetEditor(logger);
}

GetTypeEditor

public Type GetTypeEditor(string lookupName)
Returns the Type to use to construct the property grid type editor with the specified lookup name.
lookupName
string
required
The lookup name of the type editor to obtain (case-insensitive)
return
Type
The Type of the type editor, or null if not found
Type editorType = pluginManager.GetTypeEditor("Vec3");
if (editorType != null)
{
    var editor = Activator.CreateInstance(editorType);
}

GetTypeOverride

public Type GetTypeOverride(string lookupName)
Returns the Type of the type override class with the specified lookup name.
lookupName
string
required
The lookup name of the type override to obtain (case-insensitive)
return
Type
The Type of the type override, or null if not found

GetCustomHandler

public ICustomActionHandler GetCustomHandler(string ebxType)
public ICustomActionHandler GetCustomHandler(uint handlerHash)
public ICustomActionHandler GetCustomHandler(ResourceType resType)
Returns a custom action handler for the specified EBX type, handler hash, or resource type.
ebxType
string
The EBX type name to get a handler for
handlerHash
uint
The FNV1 hash of the EBX type
resType
ResourceType
The resource type to get a handler for
return
ICustomActionHandler
A new instance of the custom handler, or null if not found
// Get handler by EBX type name
var handler = pluginManager.GetCustomHandler("MeshAsset");

// Get handler by resource type
var resHandler = pluginManager.GetCustomHandler(ResourceType.MeshSet);

GetPluginAssembly

public Assembly GetPluginAssembly(string name)
Returns the Assembly of the specified plugin if it is loaded.
name
string
required
The name of the plugin to obtain
return
Assembly
The Assembly of the plugin, or null if not found
Assembly meshPlugin = pluginManager.GetPluginAssembly("MeshSetPlugin");
if (meshPlugin != null)
{
    // Use plugin assembly
}

GetLocalizedStringDatabase

public ILocalizedStringDatabase GetLocalizedStringDatabase()
Creates and returns the localized string database, or a default one if none was specified by any loaded plugin.
return
ILocalizedStringDatabase
The constructed localized string database instance

GetShader

public byte[] GetShader(ShaderType type, string name)
Returns the shader bytecode of the shader specified by the name and shader type.
type
ShaderType
required
The type of shader (VertexShader, PixelShader, or ComputeShader)
name
string
required
The resource name of the shader
return
byte[]
The bytecode of the shader, or null if not found
byte[] vertexShader = pluginManager.GetShader(ShaderType.VertexShader, "MeshShader");
byte[] pixelShader = pluginManager.GetShader(ShaderType.PixelShader, "MeshShader");

GetUserShaders

public IEnumerable<string> GetUserShaders()
Returns an enumerable collection of user-defined shader names.
return
IEnumerable<string>
Collection of user shader descriptors

IsThirdPartyDll

public bool IsThirdPartyDll(string name)
Returns true if a plugin has registered the specified name as a third-party DLL.
name
string
required
The name of the DLL to check (case-insensitive)
return
bool
True if the DLL is registered as third-party

IsManagerType

public bool IsManagerType(PluginManagerType type)
Returns true if the loaded manager matches the specified manager type.
type
PluginManagerType
required
The manager type to check (Editor, ModManager, or Both)
return
bool
True if the manager type matches
if (pluginManager.IsManagerType(PluginManagerType.Editor))
{
    // Editor-specific code
}

LoadPlugin

public Plugin LoadPlugin(string pluginPath, PluginLoadType? loadType = null)
Attempts to load a plugin located at the specified path.
pluginPath
string
required
The path to the target plugin DLL
loadType
PluginLoadType?
Optional. Determines what should be loaded from the plugin (Startup or Initialize)
return
Plugin
A Plugin instance. Check the Status property for load success/failure
Plugin plugin = pluginManager.LoadPlugin("Plugins/MyPlugin.dll", PluginLoadType.Startup);
if (plugin.Status == PluginLoadStatus.Loaded)
{
    logger.Log($"Plugin {plugin.Assembly.GetName().Name} loaded successfully");
}
else if (plugin.LoadException != null)
{
    logger.LogError($"Failed to load plugin: {plugin.LoadException.Message}");
}

Enumerations

PluginManagerType

public enum PluginManagerType
{
    Editor,
    ModManager,
    Both
}
Defines the context in which the plugin manager operates.

PluginLoadType

public enum PluginLoadType
{
    Startup,
    Initialize
}
Defines when a plugin should be loaded:
  • Startup: Loaded before profile initialization (profiles, type overrides, global editors)
  • Initialize: Loaded after profile initialization (asset definitions, menu extensions, handlers)

PluginLoadStatus

public enum PluginLoadStatus
{
    Loaded,
    LoadedInvalid,
    FailedToLoad
}
Indicates the load status of a plugin.

See Also

Build docs developers (and LLMs) love