Show / Hide Table of Contents

Class Feature

The root interface for a mod Feature.

Inheritance
System.Object
Feature
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: IPA.Loader.Features
Assembly: IPA.Loader.dll
Syntax
public abstract class Feature
Remarks

Avoid storing any data in any subclasses. If you do, it may result in a failure to load the feature.

Properties

| Improve this Doc View Source

InvalidMessage

The message to be logged when the feature is not valid for a plugin. This should also be set whenever either BeforeLoad(PluginLoader.PluginMetadata) or BeforeInit(PluginLoader.PluginInfo) returns false.

Declaration
public virtual string InvalidMessage { get; protected set; }
Property Value
Type Description
System.String

the message to show when the feature is marked invalid

| Improve this Doc View Source

StoreOnPlugin

Defines whether or not this feature will be accessible from the plugin metadata once loaded.

Declaration
protected virtual bool StoreOnPlugin { get; }
Property Value
Type Description
System.Boolean

true if this Feature will be stored on the plugin metadata, false otherwise

Methods

| Improve this Doc View Source

AfterInit(PluginLoader.PluginInfo)

Called after a plugin has been fully initialized, whether or not there is an Init method. This should never throw an exception.

Declaration
public virtual void AfterInit(PluginLoader.PluginInfo plugin)
Parameters
Type Name Description
PluginLoader.PluginInfo plugin

the plugin that was just initialized

| Improve this Doc View Source

AfterInit(PluginLoader.PluginInfo, IBeatSaberPlugin)

Called after a plugin has been fully initialized, whether or not there is an Init method. This should never throw an exception.

Declaration
public virtual void AfterInit(PluginLoader.PluginInfo plugin, IBeatSaberPlugin pluginInstance)
Parameters
Type Name Description
PluginLoader.PluginInfo plugin

the plugin that was just initialized

IBeatSaberPlugin pluginInstance

the instance of the plugin being initialized

| Improve this Doc View Source

BeforeInit(PluginLoader.PluginInfo)

Called before a plugin's Init method is called. This will not be called if there is no Init method. This should never throw an exception. An exception will abort the loading of the plugin with an error.

Declaration
public virtual bool BeforeInit(PluginLoader.PluginInfo plugin)
Parameters
Type Name Description
PluginLoader.PluginInfo plugin

the plugin to be initialized

Returns
Type Description
System.Boolean

whether or not to call the Init method

| Improve this Doc View Source

BeforeLoad(PluginLoader.PluginMetadata)

Called before a plugin is loaded. This should never throw an exception. An exception will abort the loading of the plugin with an error.

Declaration
public virtual bool BeforeLoad(PluginLoader.PluginMetadata plugin)
Parameters
Type Name Description
PluginLoader.PluginMetadata plugin

the plugin about to be loaded

Returns
Type Description
System.Boolean

whether or not the plugin should be loaded

Remarks

The assembly will still be loaded, but the plugin will not be constructed if this returns false. Any features it defines, for example, will still be loaded.

| Improve this Doc View Source

Evaluate()

Evaluates the Feature for use in conditional meta-Features. This should be re-calculated on every call, unless it can be proven to not change.

This will be called on every feature that returns true from Initialize(PluginLoader.PluginMetadata, String[])

Declaration
public virtual bool Evaluate()
Returns
Type Description
System.Boolean

the truthiness of the Feature.

| Improve this Doc View Source

Initialize(PluginLoader.PluginMetadata, String[])

Initializes the feature with the parameters provided in the definition.

Note: When no parenthesis are provided, parameters is an empty array.

Declaration
public abstract bool Initialize(PluginLoader.PluginMetadata meta, string[] parameters)
Parameters
Type Name Description
PluginLoader.PluginMetadata meta

the metadata of the plugin that is being prepared

System.String[] parameters

the parameters passed to the feature definition, or null

Returns
Type Description
System.Boolean

true if the feature is valid for the plugin, false otherwise

Remarks

This gets called BEFORE your Init method.

Returning false does not prevent the plugin from being loaded. It simply prevents the feature from being used.

| Improve this Doc View Source

RequireLoaded(PluginLoader.PluginMetadata)

Ensures a plugin's assembly is loaded. Do not use unless you need to.

Declaration
protected void RequireLoaded(PluginLoader.PluginMetadata plugin)
Parameters
Type Name Description
PluginLoader.PluginMetadata plugin

the plugin to ensure is loaded.

Extension Methods

ReflectionUtil.SetPrivateField(Object, String, Object)
ReflectionUtil.GetPrivateField<T>(Object, String)
ReflectionUtil.SetPrivateProperty(Object, String, Object)
ReflectionUtil.InvokePrivateMethod(Object, String, Object[])
ReflectionUtil.InvokePrivateMethod<T>(Object, String, Object[])
  • Improve this Doc
  • View Source
Back to top Generated by DocFX