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(PluginMetadata) or BeforeInit(PluginMetadata) 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(PluginMetadata)
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(PluginMetadata plugin)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | plugin | the plugin that was just initialized |
AfterInit(PluginMetadata, Object)
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(PluginMetadata plugin, object pluginInstance)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | plugin | the plugin that was just initialized |
Object | pluginInstance | the instance of the plugin being initialized |
BeforeInit(PluginMetadata)
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(PluginMetadata plugin)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | plugin | the plugin to be initialized |
Returns
Type | Description |
---|---|
Boolean | whether or not to call the Init method |
BeforeLoad(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(PluginMetadata plugin)
Parameters
Type | Name | Description |
---|---|---|
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(PluginMetadata, String[])
Declaration
public virtual bool Evaluate()
Returns
Type | Description |
---|---|
Boolean | the truthiness of the Feature. |
Initialize(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(PluginMetadata meta, string[] parameters)
Parameters
Type | Name | Description |
---|---|---|
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(PluginMetadata)
Ensures a plugin's assembly is loaded. Do not use unless you need to.
Declaration
protected void RequireLoaded(PluginMetadata plugin)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | plugin | the plugin to ensure is loaded. |