Class Feature
The root interface for a mod Feature.
Inherited Members
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 SourceInvalidMessage
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 |
---|---|
String | the message to show when the feature is marked invalid |
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 |
---|---|
Boolean | true if this Feature will be stored on the plugin metadata, false otherwise |
Methods
| Improve this Doc View SourceAfterInit(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 |
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 |
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 |
---|---|
Boolean | whether or not to call the Init method |
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 |
---|---|
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.
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 |
---|---|
Boolean | the truthiness of the Feature. |
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 |
String[] | parameters | the parameters passed to the feature definition, or null |
Returns
Type | Description |
---|---|
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.
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. |