Class StateTransitionTransaction
A class to represent a transaction for changing the state of loaded mods.
Namespace: IPA.Loader
Assembly: IPA.Loader.dll
Syntax
public sealed class StateTransitionTransaction : IDisposable
Properties
| Improve this Doc View SourceDisabledPlugins
Gets a list of plugins that are disabled according to this transaction's current state.
Declaration
public IEnumerable<PluginMetadata> DisabledPlugins { get; }
Property Value
Type | Description |
---|---|
IEnumerable<PluginMetadata> |
EnabledPlugins
Gets a list of plugins that are enabled according to this transaction's current state.
Declaration
public IEnumerable<PluginMetadata> EnabledPlugins { get; }
Property Value
Type | Description |
---|---|
IEnumerable<PluginMetadata> |
HasStateChanged
Gets whether or not the current state has changed.
Declaration
public bool HasStateChanged { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the current state of the transaction is different from its construction, false otherwise |
WillNeedRestart
Gets whether or not a game restart will be necessary to fully apply this transaction.
Declaration
public bool WillNeedRestart { get; }
Property Value
Type | Description |
---|---|
Boolean | true if any mod who's state is changed cannot be changed at runtime, false otherwise |
Methods
| Improve this Doc View SourceClone()
Clones this transaction to be identical, but with unrelated underlying sets.
Declaration
public StateTransitionTransaction Clone()
Returns
Type | Description |
---|---|
StateTransitionTransaction | the new StateTransitionTransaction |
Commit()
Commits this transaction to actual state, enabling and disabling plugins as necessary.
Declaration
public Task Commit()
Returns
Type | Description |
---|---|
Task | a |
Remarks
After this completes, this transaction will be disposed.
The
// get your transaction...
var complete = transaction.Commit();
await complete.ContinueWith(t => {
if (t.IsFaulted)
Logger.log.Error($"Error disabling plugins: {t.Exception}");
});
If you are running in a coroutine, you can use WaitForTask(Task) instead of await.
If you are running on the Unity main thread, this will block until all enabling is done, and will return a task representing the disables. Otherwise, the task returned represents both, and will not complete until Unity has done (possibly) several updates, depending on the number of plugins being disabled, and the time they take.
Disable(PluginMetadata, Boolean)
Disables a plugin in this transaction.
Declaration
public bool Disable(PluginMetadata meta, bool autoDependents = true)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to disable |
Boolean | autoDependents | whether or not to automatically disable all dependents of the plugin |
Returns
Type | Description |
---|---|
Boolean | true if the transaction's state was changed, false otherwise |
Disable(PluginMetadata, out Nullable<IEnumerable<PluginMetadata>>, Boolean)
Disables a plugin in this transaction.
Declaration
public bool Disable(PluginMetadata meta, out IEnumerable<PluginMetadata>? enabledDependents, bool autoDependents = false)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to disable |
Nullable<IEnumerable<PluginMetadata>> | enabledDependents | null if successful, otherwise a set of plugins that need to be disabled first |
Boolean | autoDependents | whether or not to automatically disable all dependents of the plugin |
Returns
Type | Description |
---|---|
Boolean | true if the transaction's state was changed, false otherwise |
Remarks
enabledDependents
will only be set when autoDependents
is false.
Dispose()
Disposes and discards this transaction without committing it.
Declaration
public void Dispose()
Enable(PluginMetadata, Boolean)
Enables a plugin in this transaction.
Declaration
public bool Enable(PluginMetadata meta, bool autoDeps = true)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to enable |
Boolean | autoDeps | whether or not to automatically enable all dependencies of the plugin |
Returns
Type | Description |
---|---|
Boolean | true if the transaction's state was changed, false otherwise |
Enable(PluginMetadata, out Nullable<IEnumerable<PluginMetadata>>, Boolean)
Enables a plugin in this transaction.
Declaration
public bool Enable(PluginMetadata meta, out IEnumerable<PluginMetadata>? disabledDeps, bool autoDeps = false)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to enable |
Nullable<IEnumerable<PluginMetadata>> | disabledDeps | null if successful, otherwise a set of plugins that need to be enabled first |
Boolean | autoDeps | whether or not to automatically enable all dependencies |
Returns
Type | Description |
---|---|
Boolean | true if the transaction's state was changed, false otherwise |
Remarks
disabledDeps
will only be set when autoDeps
is false.
IsDisabled(PluginMetadata)
Checks if a plugin is disabled according to this transaction's current state.
Declaration
public bool IsDisabled(PluginMetadata meta)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to check |
Returns
Type | Description |
---|---|
Boolean | true if the plugin is disabled, false otherwise |
Remarks
This should be roughly equivalent to DisabledPlugins.Contains(meta)
, but more performant.
This should also always return the inverse of IsEnabled(PluginMetadata) for valid plugins.
See Also
| Improve this Doc View SourceIsEnabled(PluginMetadata)
Checks if a plugin is enabled according to this transaction's current state.
Declaration
public bool IsEnabled(PluginMetadata meta)
Parameters
Type | Name | Description |
---|---|---|
PluginMetadata | meta | the plugin to check |
Returns
Type | Description |
---|---|
Boolean | true if the plugin is enabled, false otherwise |
Remarks
This should be roughly equivalent to EnabledPlugins.Contains(meta)
, but more performant.
This should also always return the inverse of IsDisabled(PluginMetadata) for valid plugins.