Class MonkeyBase
- Namespace
- MonkeyLoader.Patching
- Assembly
- MonkeyLoader.dll
Abstract base for regular Monkey<TMonkey>s and EarlyMonkey<TMonkey>s.
public abstract class MonkeyBase : IMonkey, IRun, IShutdown, IComparable<IMonkey>, INestedIdentifiable<Mod>, INestedIdentifiable, IIdentifiable, IAuthorable
- Inheritance
-
MonkeyBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Properties
AssemblyName
Gets the name of the assembly this monkey is defined in.
public AssemblyName AssemblyName { get; }
Property Value
Authors
Gets the names of the authors of this particular monkey, which may differ from the Authors.
public virtual IEnumerable<string> Authors { get; }
Property Value
Remarks
CanBeDisabled
Gets whether this monkey can be disabled, that is, whether it's
permitted to set Enabled to false
,
and there is an EnabledToggle.
public virtual bool CanBeDisabled { get; }
Property Value
- bool
true
if this monkey respects the MonkeyToggles config.
Remarks
By default: false
.
Config
Gets the Config that this monkey can use to load ConfigSections.
public Config Config { get; }
Property Value
Enabled
Gets or sets whether this monkey should currently be active.
public bool Enabled { get; set; }
Property Value
Remarks
Can only be set to false
if the monkey
supports being disabled.
EnabledToggle
Gets the this monkey's toggle if it can be disabled.
public IDefiningConfigKey<bool>? EnabledToggle { get; }
Property Value
- IDefiningConfigKey<bool>
The toggle config item if this monkey can be disabled; otherwise,
null
.
Failed
Gets whether this monkey's Run() method failed when it was called.
public bool Failed { get; protected set; }
Property Value
FeaturePatches
Gets the impacts this (pre-)patcher has on certain features ordered by descending impact.
public IEnumerable<IFeaturePatch> FeaturePatches { get; }
Property Value
FullId
Gets fully unique identifier of this monkey.
public string FullId { get; }
Property Value
Remarks
Harmony
Gets the Harmony instance to be used by this patcher.
public Harmony Harmony { get; }
Property Value
- Harmony
Id
Gets the mod-unique identifier of this monkey.
public virtual string Id { get; }
Property Value
Remarks
By Default: The monkey's Type's Name.
Logger
Gets the Logger that this monkey can use to log messages to game-specific channels.
public Logger Logger { get; }
Property Value
Mod
Gets the mod that this monkey is a part of.
public Mod Mod { get; }
Property Value
Name
Gets the display name of this monkey.
public virtual string Name { get; }
Property Value
Remarks
By Default: The monkey's Id.
Ran
Gets whether this monkey's Run() method has been called.
public bool Ran { get; }
Property Value
ShutdownFailed
Gets whether this monkey's Shutdown() failed when it was called.
public bool ShutdownFailed { get; }
Property Value
ShutdownRan
Gets whether this monkey's Shutdown() method has been called.
public bool ShutdownRan { get; }
Property Value
Type
Gets the runtime type of this monkey.
public Type Type { get; }
Property Value
Methods
CompareTo(IMonkey)
public int CompareTo(IMonkey other)
Parameters
other
IMonkey
Returns
GetFeaturePatches()
Gets the impacts this (pre-)patcher has on certain features.
protected virtual IEnumerable<IFeaturePatch> GetFeaturePatches()
Returns
HasAuthor(string)
Determines whether a given name
is listed as an author for this authorable item.
public bool HasAuthor(string name)
Parameters
name
stringThe name to check for.
Returns
- bool
true
if the givenname
is listed as an author for this authorable item.
OnDisabled()
Lets this monkey react to being disabled at runtime.
Will only ever be called when CanBeDisabled is true
.
protected virtual void OnDisabled()
Remarks
By default: does nothing.
OnEnabled()
Lets this monkey react to being enabled at runtime.
Will only ever be called when CanBeDisabled is true
.
protected virtual void OnEnabled()
Remarks
By default: does nothing.
OnShutdown(bool)
Lets this monkey cleanup and shutdown.
protected virtual bool OnShutdown(bool applicationExiting)
Parameters
applicationExiting
boolWhether the shutdown was caused by the application exiting.
Returns
- bool
true
if it ran successfully; otherwise,false
.
Remarks
By default: Removes all HarmonyLib.Harmony patches done
using this Monkey's Harmony instance,
if not exiting, and returns true
.
Run()
Runs this monkey to let it patch.
Must only be called once.
public abstract bool Run()
Returns
- bool
true
if it ran successfully; otherwise,false
.
Exceptions
- InvalidOperationException
If it gets called more than once.
Shutdown(bool)
Lets this monkey cleanup and shutdown.
Must only be called once.
public bool Shutdown(bool applicationExiting)
Parameters
applicationExiting
boolWhether the shutdown was caused by the application exiting.
Returns
- bool
true
if it ran successfully; otherwise,false
.
Exceptions
- InvalidOperationException
If it gets called more than once.
ThrowIfRan()
Throws an InvalidOperationException if Ran is true
.
protected void ThrowIfRan()
Exceptions
- InvalidOperationException
If Ran is
true
.
ToString()
public override string ToString()
Returns
Remarks
Format: {Mod.Title}/{Name}
({(Ran ? (ShutdownRan ? "Ended" : (Enabled ? "Active" : "Inactive")) : "Pending")})
Events
ShutdownDone
Called when something has shut down.
public event ShutdownHandler? ShutdownDone
Event Type
ShuttingDown
Called when something is about to shut down.
public event ShutdownHandler? ShuttingDown