UKMod - Temperz87/ultra-mod-manager GitHub Wiki

UKMod is a class that UMM will look for when injecting mods, all UKMods must have a UKPlugin attribute on them, however you can also specify an UKDependency via an attribute. while UKDependency's are optional, and only work for other UKMod's, UKPlugin's are necessary, so let's start off there:

UKPlugin

UKPlugin-docs UKPlugin defines metadata for UMM to use when loading your mod, and features 6 arguments when constructing it, as well as 6 fields to set:

public string GUID

Defines the GUID of your mod, which is what's suppied if another mod depends on yours. Ideally, this would be the same as your Harmony's GUID name, however it doesn't matter as long as it's unique.

public string name

Defines the modName of a UKMod, which is what you see in the Mods menu.

public string version

Defines the version of the mod

public string description

The description, note that these two arguments will also be accessible via a file once cyrgrind.xyz integration is added, and will be made obsolete.

public bool allowCyberGrindSubmission

Tells UMM whether or not to allow Cybergrind score submissions while your mod is loaded, and UMM will automatically account for this if the mod is unloaded

public bool unloadingSupported

Set by bool supportsUnloading in the constructor, and tells UMM whether or not your mod can be unloaded, note that you have to override virtual void UKMod.OnModUnload in order for this functionality to actually work.

UKDependency

UKDependency-docs If an UKMod is dependent on another UKMod, and subsequent must be loaded after it, the attribute UKDependency can be used to tell UMM this. UKDependency has two fields and required parameters to construct it.

string GUID

Specifies the GUID of the UKMod that's the dependency.

string MinimumVersion

Specifies the minimum required version of the UKMod that's the dependency. If the dependency is found but doesn't meet the minimum required version, the mod with the dependency will not be loaded.

UKMod

A class that inherits from UKMod will be detected by UMM as being a mod, and will be injected into the game. If a UKMod doesn't inherit form UKPlugin, then the mod will not be loaded. UKMod also inherits form MonoBehaviour, which gives you access to all Unity functions (such as Update, Awake, and Start).

Fields

public string modFolder

The folder where the mod is, note that a mod in "UMM\UKSoundReplacement" will have a modFolder of "UMM\UKSoundReplacement".

public UKPlugin metaData

Gives you access to a mods UKPlugin.

public UnityEvent OnModUnloaded

By default this value is equal to new UnityEvent(), and is invoked when a mod is unloaded.

Methods

public virtual void OnModLoaded()

Runs once when the mod gets loaded.

public virtual void OnModUnload()

Runs once when the mod gets unloaded, note that if you specified that your mod is unloadable, then you must override this method and add your unloading functions here, including unpatching harmony.

Persistent data

UKMods have access to reading and writing from a save file located at "UMM\persistent mod data.json", there are a lot of functions to handle this data. You can read/write data from your own mod, to another mod, or universally.

Setting Persistent Data

public void SetPersistentModData(string key, string value)

Sets persistent mod data to a save file provided a key and a string value.

public static void SetPersistentModData(string key, string value, string modName)

Sets persistent mod data to a specific mod to a save file, provided a key, string value, and modName.

public static void SetPersistentUniversalModData(string key, string value)

Sets persistent mod data shared across all mods to a save file, provided a key and string value. Note that this method is the same as calling SetPersistentModData(key, value, "allPersistentModData")

Retrieving data

Data can be retrieved by string, int, float, or bool type. Note that if you retrieve data and it cannot be converted to said type, an exception will be thrown.

public string RetrieveStringPersistentModData(string key)

Gets persistent mod data from a save file as a string, provided a key.

public static string RetrieveStringPersistentModData(string key, string modName)

Gets persistent mod data from a save file as a string, provided a key and a modName.

public static string RetrieveStringPersistentUniversalModData(string key)

Gets universal persistent mod data from a save file as a string, provided a key.

public int RetrieveIntPersistentModData(string key)

Gets persistent mod data from a save file as an integer, provided a key.

public static int RetrieveIntPersistentModData(string key, string modName)

Gets persistent mod data from a save file as an integer, provided a key and a modName.

public static int RetrieveIntPersistentUniversalModData(string key)

Gets universal persistent mod data from a save file as an integer, provided a key.

public float RetrieveFloatPersistentModData(string key)

public static float RetrieveFloatPersistentModData(string key, string modName)

Gets persistent mod data from a save file as a float, provided a key and a modName.

public static float RetrieveFloatPersistentUniversalModData(string key)

Gets universal persistent mod data from a save file as a float, provided a key.

public bool RetrieveBooleanPersistentModData(string key)

Gets persistent mod data from a save file as a boolean, provided a key.

public static bool RetrieveBooleanPersistentModData(string key, string modName)

Gets persistent mod data from a save file as a boolean, provided a key and a modName.

public static bool RetrieveBooleanPersistentUniversalModData(string key)

Gets universal persistent mod data from a save file as a boolean, provided a key.

Ensuring data exists

UMM also provides 3 methods to ensure that data exists, however it does not ensure their type.

public bool PersistentModDataExists(string key)

Ensures that persistent data exists provided a key.

public static bool PersistentModDataExists(string key, string modName)

Ensures that persistent data exists provided a key and a modName.

public static bool UniversalModDataExists(string key)

Ensures that persistent data exists provided a key.