Class Mod
- Namespace
- MonkeyLoader.Meta
- Assembly
- MonkeyLoader.dll
Contains the base metadata and references for a mod.
public abstract class Mod : IConfigOwner, IIdentifiableOwner<IConfigOwner, Config>, IIdentifiableOwner<Config>, IShutdown, ILoadedNuGetPackage, IComparable<Mod>, INestedIdentifiableOwner<ConfigSection>, INestedIdentifiableOwner<IDefiningConfigKey>, IIdentifiableOwner<Mod, IMonkey>, IIdentifiableOwner<IMonkey>, IIdentifiableOwner<Mod, IEarlyMonkey>, IIdentifiableOwner<IEarlyMonkey>, IIdentifiable, IAuthorable
- Inheritance
-
Mod
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
Mod(MonkeyLoader, string?, bool)
Creates a new mod instance with the given details.
protected Mod(MonkeyLoader loader, string? location, bool isGamePack)
Parameters
loaderMonkeyLoaderThe loader instance that loaded this mod.
locationstringThe absolute path to this mod's file. May be
nullif the mod only exists in memory.isGamePackboolWhether this mod is a game pack.
Fields
AssemblyExtension
The file extension for mods' assemblies.
protected const string AssemblyExtension = ".dll"
Field Value
assemblyPaths
Stores the paths to the mod's assemblies inside the mod's FileSystem.
protected readonly SortedSet<UPath> assemblyPaths
Field Value
- SortedSet<UPath>
authors
Stores the authors of this mod.
protected readonly HashSet<string> authors
Field Value
contentPaths
Stores the paths to the mod's content files inside the mod's FileSystem.
protected readonly SortedSet<UPath> contentPaths
Field Value
- SortedSet<UPath>
dependencies
Stores the dependencies of this mod.
protected readonly Dictionary<string, DependencyReference> dependencies
Field Value
earlyMonkeys
Stores the pre-patchers of this mod.
protected readonly SortedSet<IEarlyMonkey> earlyMonkeys
Field Value
monkeys
Stores the patchers of this mod.
protected readonly SortedSet<IMonkey> monkeys
Field Value
tags
Stores the tags of this mod.
protected readonly HashSet<string> tags
Field Value
Properties
AllDependenciesLoaded
Gets whether all dependencies of this package are loaded.
public bool AllDependenciesLoaded { get; }
Property Value
AscendingComparer
Gets an IComparer<T> that keeps Mods sorted in topological order.
public static IComparer<Mod> AscendingComparer { get; }
Property Value
AssemblyPaths
Gets the paths to the mod's assemblies inside the mod's FileSystem.
public IEnumerable<UPath> AssemblyPaths { get; }
Property Value
- IEnumerable<UPath>
Authors
Gets the names of the authors of this mod.
public IEnumerable<string> Authors { get; }
Property Value
Config
Gets the config that this mod's (pre-)patcher(s) can use to load ConfigSections.
public Config Config { get; }
Property Value
ConfigPath
Gets the path where this mod's config file should be.
public string ConfigPath { get; }
Property Value
ContentPaths
Gets the paths to the mod's content files inside the mod's FileSystem.
public IEnumerable<UPath> ContentPaths { get; }
Property Value
- IEnumerable<UPath>
Dependencies
Gets the dependencies of this mod.
public IEnumerable<DependencyReference> Dependencies { get; }
Property Value
DescendingComparer
Gets an IComparer<T> that keeps Mods sorted in reverse topological order.
public static IComparer<Mod> DescendingComparer { get; }
Property Value
Description
Gets the description of this mod.
public abstract string Description { get; }
Property Value
EarlyMonkeys
Gets the available IEarlyMonkeys of this mod, with the highest impact ones coming first.
public IEnumerable<IEarlyMonkey> EarlyMonkeys { get; }
Property Value
FileSystem
Gets the readonly file system of this mod's file.
public abstract IFileSystem FileSystem { get; }
Property Value
- IFileSystem
HasPatchers
Gets whether this mod has any monkeys.
public bool HasPatchers { get; }
Property Value
HasPrePatchers
Gets whether this mod has any early monkeys.
public bool HasPrePatchers { get; }
Property Value
IconPath
Gets the path to the mod's icon inside the mod's FileSystem.
null if it wasn't given or doesn't exist.
public abstract UPath? IconPath { get; }
Property Value
- UPath?
IconUrl
Gets the Url to the mod's icon on the web.
null if it wasn't given or was invalid.
public abstract Uri? IconUrl { get; }
Property Value
Id
Gets the unique identifier of this mod.
public string Id { get; }
Property Value
Identity
Gets the identity of this mod.
public abstract PackageIdentity Identity { get; }
Property Value
- PackageIdentity
IsGamePack
Gets whether this mod is a game pack.
public bool IsGamePack { get; }
Property Value
LoadEarlyMonkeysFailed
Gets whether this mod's LoadEarlyMonkeys() failed when it was called.
public bool LoadEarlyMonkeysFailed { get; }
Property Value
LoadFailed
Gets whether this mod's LoadEarlyMonkeys() or LoadMonkeys() failed when they were called.
public bool LoadFailed { get; }
Property Value
LoadMonkeysFailed
Gets whether this mod's LoadMonkeys() failed when it was called.
public bool LoadMonkeysFailed { get; }
Property Value
LoadedEarlyMonkeys
Gets whether this mod's LoadEarlyMonkeys() method has been called.
public bool LoadedEarlyMonkeys { get; }
Property Value
LoadedMonkeys
Gets whether this mod's LoadMonkeys() method has been called.
public bool LoadedMonkeys { get; }
Property Value
Loader
Gets the MonkeyLoader instance that loaded this mod.
public MonkeyLoader Loader { get; }
Property Value
Location
Gets the absolute path to this mod's file. May be null if the mod only exists in memory.
public string? Location { get; }
Property Value
Logger
Gets the logger to be used by this mod.
public Logger Logger { get; }
Property Value
Remarks
They all share the Loader's LoggingController.
MonkeyToggles
Gets the toggles for this mod's monkeys that support disabling.
public MonkeyTogglesConfigSection MonkeyToggles { get; }
Property Value
Monkeys
Gets the available IMonkeys of this mod, with the highest impact ones coming first.
public IEnumerable<IMonkey> Monkeys { get; }
Property Value
ProjectUrl
Gets the Url to this mod's project website.
null if it wasn't given or was invalid.
public abstract Uri? ProjectUrl { get; }
Property Value
ReleaseNotes
Gets the release notes for this mod's version.
public abstract string? ReleaseNotes { get; }
Property Value
ShutdownFailed
Gets whether this Mod's Shutdown(bool) method failed when it was called.
public bool ShutdownFailed { get; }
Property Value
ShutdownRan
Gets whether this Mod's Shutdown(bool) method has been called.
public bool ShutdownRan { get; }
Property Value
SupportsHotReload
Gets whether this type of mod supports hot reloading.
public abstract bool SupportsHotReload { get; }
Property Value
Tags
Gets the tags of this mod.
public IEnumerable<string> Tags { get; }
Property Value
TargetFramework
Gets the framework targeted by this mod.
public abstract NuGetFramework TargetFramework { get; }
Property Value
- NuGetFramework
Title
Gets the nice identifier of this mod.
public virtual string Title { get; }
Property Value
Version
Gets this mod's version.
public NuGetVersion Version { get; }
Property Value
- NuGetVersion
Methods
CompareTo(Mod)
Compares this mod with another and returns a value indicating whether one is dependent on the other, independent, or the other dependent on this.
public int CompareTo(Mod other)
Parameters
otherModA mod to compare with this instance.
Returns
- int
A signed integer that indicates the dependency relation:
Less than zero: this is a dependency ofother.
Zero: this andotherare independent.
Greater than zero: this is dependent onother.
DependsOn(ILoadedNuGetPackage)
Determines whether this package depends on otherPackage directly or transitively.
public bool DependsOn(ILoadedNuGetPackage otherPackage)
Parameters
otherPackageILoadedNuGetPackageThe other package to check for.
Returns
- bool
trueif this package (transitively) depends onotherPackage; otherwise,false.
DependsOn(string)
Determines whether this package depends on otherId directly or transitively.
public bool DependsOn(string otherId)
Parameters
otherIdstring
Returns
- bool
trueif this package (transitively) depends onotherId; otherwise,false.
HasAuthor(string)
Efficiently determines whether the given
name is listed as an author for this mod.
public bool HasAuthor(string name)
Parameters
namestringThe name to check for.
Returns
- bool
trueif the givennameis listed as an author for this mod.
HasTag(string)
Efficiently checks, whether a given tag is listed for this mod.
public bool HasTag(string tag)
Parameters
tagstringThe tag to check for.
Returns
- bool
trueif the given tag is listed for this mod; otherwise,false.
OnLoadEarlyMonkeys()
Loads the mod's early monkeys.
protected abstract bool OnLoadEarlyMonkeys()
Returns
- bool
trueif it ran successfully; otherwise,false.
OnLoadMonkeys()
Loads the mod's monkeys.
protected abstract bool OnLoadMonkeys()
Returns
- bool
trueif it ran successfully; otherwise,false.
OnShutdown(bool)
Lets this mod cleanup and shutdown.
protected virtual bool OnShutdown(bool applicationExiting)
Parameters
applicationExitingboolWhether the shutdown was caused by the application exiting.
Returns
- bool
trueif it ran successfully; otherwise,false.
Remarks
RegisterEventHandler<TEvent>(IAsyncEventHandler<TEvent>)
Registers the given async event handler for this mod.
public bool RegisterEventHandler<TEvent>(IAsyncEventHandler<TEvent> asyncEventHandler) where TEvent : AsyncEvent
Parameters
asyncEventHandlerIAsyncEventHandler<TEvent>The async event handler to register.
Returns
- bool
trueif theasyncEventHandlerwas newly registered; otherwise,false.
Type Parameters
TEventThe type of async events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
RegisterEventHandler<TEvent>(ICancelableAsyncEventHandler<TEvent>)
Registers the given cancelable async event handler for this mod.
public bool RegisterEventHandler<TEvent>(ICancelableAsyncEventHandler<TEvent> cancelableAsyncEventHandler) where TEvent : CancelableAsyncEvent
Parameters
cancelableAsyncEventHandlerICancelableAsyncEventHandler<TEvent>The cancelable async event handler to register.
Returns
- bool
trueif thecancelableAsyncEventHandlerwas newly registered; otherwise,false.
Type Parameters
TEventThe type of cancelable async events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
RegisterEventHandler<TEvent>(ICancelableEventHandler<TEvent>)
Registers the given cancelable event handler for this mod.
public bool RegisterEventHandler<TEvent>(ICancelableEventHandler<TEvent> cancelableEventHandler) where TEvent : CancelableSyncEvent
Parameters
cancelableEventHandlerICancelableEventHandler<TEvent>The cancelable event handler to register.
Returns
- bool
trueif thecancelableEventHandlerwas newly registered; otherwise,false.
Type Parameters
TEventThe type of cancelable events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
RegisterEventHandler<TEvent>(IEventHandler<TEvent>)
Registers the given event handler for this mod.
public bool RegisterEventHandler<TEvent>(IEventHandler<TEvent> eventHandler) where TEvent : SyncEvent
Parameters
eventHandlerIEventHandler<TEvent>The event handler to register.
Returns
- bool
trueif theeventHandlerwas newly registered; otherwise,false.
Type Parameters
TEventThe type of events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
RegisterEventSource<TEvent>(IAsyncEventSource<TEvent>)
Registers the given event source for this mod.
public bool RegisterEventSource<TEvent>(IAsyncEventSource<TEvent> eventSource) where TEvent : AsyncEvent
Parameters
eventSourceIAsyncEventSource<TEvent>The event source to register.
Returns
- bool
trueif theeventSourcewas newly registered; otherwise,false.
Type Parameters
TEventThe type of async events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
RegisterEventSource<TEvent>(ICancelableAsyncEventSource<TEvent>)
Registers the given cancelable event source for this mod.
public bool RegisterEventSource<TEvent>(ICancelableAsyncEventSource<TEvent> cancelableAsyncEventSource) where TEvent : CancelableAsyncEvent
Parameters
cancelableAsyncEventSourceICancelableAsyncEventSource<TEvent>The cancelable event source to register.
Returns
- bool
trueif thecancelableAsyncEventSourcewas newly registered; otherwise,false.
Type Parameters
TEventThe type of async events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
RegisterEventSource<TEvent>(ICancelableEventSource<TEvent>)
Registers the given cancelable event source for this mod.
public bool RegisterEventSource<TEvent>(ICancelableEventSource<TEvent> cancelableEventSource) where TEvent : CancelableSyncEvent
Parameters
cancelableEventSourceICancelableEventSource<TEvent>The cancelable event source to register.
Returns
- bool
trueif thecancelableEventSourcewas newly registered; otherwise,false.
Type Parameters
TEventThe type of events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
RegisterEventSource<TEvent>(IEventSource<TEvent>)
Registers the given event source for this mod.
public bool RegisterEventSource<TEvent>(IEventSource<TEvent> eventSource) where TEvent : SyncEvent
Parameters
eventSourceIEventSource<TEvent>The event source to register.
Returns
- bool
trueif theeventSourcewas newly registered; otherwise,false.
Type Parameters
TEventThe type of events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
Shutdown(bool)
Lets this mod cleanup and shutdown.
Must only be called once.
public bool Shutdown(bool applicationExiting)
Parameters
applicationExitingboolWhether the shutdown was caused by the application exiting.
Returns
- bool
trueif it ran successfully; otherwise,false.
Exceptions
- InvalidOperationException
If it gets called more than once.
ToString()
public override string ToString()
Returns
TryResolveDependencies()
Tries to resolve all dependencies of this package.
public bool TryResolveDependencies()
Returns
UnregisterEventHandler<TEvent>(IAsyncEventHandler<TEvent>)
Unregisters the given event handler for this mod.
public bool UnregisterEventHandler<TEvent>(IAsyncEventHandler<TEvent> asyncEventHandler) where TEvent : AsyncEvent
Parameters
asyncEventHandlerIAsyncEventHandler<TEvent>The event handler to unregister.
Returns
- bool
trueif theasyncEventHandlerwas found and unregistered; otherwise,false.
Type Parameters
TEventThe type of async events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
UnregisterEventHandler<TEvent>(ICancelableAsyncEventHandler<TEvent>)
Unregisters the given cancelable async event handler for this mod.
public bool UnregisterEventHandler<TEvent>(ICancelableAsyncEventHandler<TEvent> cancelableAsyncEventHandler) where TEvent : CancelableAsyncEvent
Parameters
cancelableAsyncEventHandlerICancelableAsyncEventHandler<TEvent>The cancelable async event handler to unregister.
Returns
- bool
trueif thecancelableAsyncEventHandlerwas found and unregistered; otherwise,false.
Type Parameters
TEventThe type of cancelable async events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
UnregisterEventHandler<TEvent>(ICancelableEventHandler<TEvent>)
Unregisters the given cancelable event handler for this mod.
public bool UnregisterEventHandler<TEvent>(ICancelableEventHandler<TEvent> cancelableEventHandler) where TEvent : CancelableSyncEvent
Parameters
cancelableEventHandlerICancelableEventHandler<TEvent>The cancelable event handler to unregister.
Returns
- bool
trueif thecancelableEventHandlerwas found and unregistered; otherwise,false.
Type Parameters
TEventThe type of cancelable events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
UnregisterEventHandler<TEvent>(IEventHandler<TEvent>)
Unregisters the given event handler for this mod.
public bool UnregisterEventHandler<TEvent>(IEventHandler<TEvent> eventHandler) where TEvent : SyncEvent
Parameters
eventHandlerIEventHandler<TEvent>The event handler to unregister.
Returns
- bool
trueif theeventHandlerwas found and unregistered; otherwise,false.
Type Parameters
TEventThe type of events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
UnregisterEventSource<TEvent>(IAsyncEventSource<TEvent>)
Unregisters the given event source for this mod.
public bool UnregisterEventSource<TEvent>(IAsyncEventSource<TEvent> asyncEventSource) where TEvent : AsyncEvent
Parameters
asyncEventSourceIAsyncEventSource<TEvent>The event source to unregister.
Returns
- bool
trueif theasyncEventSourcewas found and unregistered; otherwise,false.
Type Parameters
TEventThe type of async events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
UnregisterEventSource<TEvent>(ICancelableAsyncEventSource<TEvent>)
Unregisters the given cancelable async event source for this mod.
public bool UnregisterEventSource<TEvent>(ICancelableAsyncEventSource<TEvent> cancelableAsyncEventSource) where TEvent : CancelableAsyncEvent
Parameters
cancelableAsyncEventSourceICancelableAsyncEventSource<TEvent>The cancelable async event source to unregister.
Returns
- bool
trueif thecancelableAsyncEventSourcewas found and unregistered; otherwise,false.
Type Parameters
TEventThe type of async events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
UnregisterEventSource<TEvent>(ICancelableEventSource<TEvent>)
Unregisters the given cancelable event source for this mod.
public bool UnregisterEventSource<TEvent>(ICancelableEventSource<TEvent> cancelableEventSource) where TEvent : CancelableSyncEvent
Parameters
cancelableEventSourceICancelableEventSource<TEvent>The cancelable event source to unregister.
Returns
- bool
trueif thecancelableEventSourcewas found and unregistered; otherwise,false.
Type Parameters
TEventThe type of events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
UnregisterEventSource<TEvent>(IEventSource<TEvent>)
Unregisters the given event source for this mod.
public bool UnregisterEventSource<TEvent>(IEventSource<TEvent> eventSource) where TEvent : SyncEvent
Parameters
eventSourceIEventSource<TEvent>The event source to unregister.
Returns
- bool
trueif theeventSourcewas found and unregistered; otherwise,false.
Type Parameters
TEventThe type of events handled.
Remarks
Handlers are automatically unregistered when the mod is shutdown.
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