Skip to content

Get mod status info at runtime using QModServices

AlexejheroYTB edited this page Aug 15, 2020 · 4 revisions

If you need a little more info about one or more mods and their status during run time, you can access QModServices under the QModManager.API namespace.

You will have access to the following methods for getting info at run time.

/// <summary>
/// Finds a specific mod by its unique <see cref="IQMod.Id"/> value.
/// </summary>
/// <param name="modId">The mod ID.</param>
/// <returns>The <see cref="IQMod"/> instance of the mod if found; otherwise returns <c>null</c>.</returns>
IQMod FindModById(string modId);

/// <summary>
/// Finds a specific mod with a <see cref="IQMod.LoadedAssembly"/> that matches the provided one.
/// </summary>
/// <param name="modAssembly">The mod assembly.</param>
/// <returns>The <see cref="IQMod"/> instance of the mod if found; otherwise returns <c>null</c.></returns>
IQMod FindModByAssembly(Assembly modAssembly);

/// <summary>
/// Gets a list all mods being tracked by QModManager.
/// </summary>
/// <returns>A read only list of mods containing all of the loaded mods</returns>
ReadOnlyCollection<IQMod> GetAllMods();

/// <summary>
/// Returns the mod from the assembly which called this method
/// </summary>
IQMod GetMyMod();

/// <summary>
/// Checks whether or not a mod is present based on its unique <see cref="IQMod.Id"/> value.
/// </summary>
/// <param name="id">The mod ID.</param>
/// <returns><c>True</c> if the mod is in the collection of mods to load; Otherwise <c>false</c>.</returns>
bool ModPresent(string id);

You can invoke these via the singleton property Main on QModServices.
Example

using QModManager.API;

// ...

var mods = QModServices.Main.GetAllMods();
  翻译: