Class ModManager
Handles setup and execution of mods and provides support for features related to modding support. Mods can also use this singleton to find and interact with other mods.
Namespace: DaggerfallWorkshop.Game.Utility.ModSupport
Assembly: Assembly-CSharp.dll
Syntax
public class ModManager : MonoBehaviour
Fields
| Improve this Doc View Source_serializer
Declaration
public static readonly fsSerializer _serializer
Field Value
Type | Description |
---|---|
FullSerializer.fsSerializer |
MODCONFIGFILENAME
Declaration
public const string MODCONFIGFILENAME = "Mod_Settings.json"
Field Value
Type | Description |
---|---|
String |
MODEXTENSION
Declaration
public const string MODEXTENSION = ".dfmod"
Field Value
Type | Description |
---|---|
String |
MODINFOEXTENSION
Declaration
public const string MODINFOEXTENSION = ".dfmod.json"
Field Value
Type | Description |
---|---|
String |
textExtensions
Declaration
public static string[] textExtensions
Field Value
Type | Description |
---|---|
String[] |
Properties
| Improve this Doc View SourceInstance
Declaration
public static ModManager Instance { get; }
Property Value
Type | Description |
---|---|
ModManager |
LoadedModCount
The number of mods loaded by Mod Manager.
Declaration
public int LoadedModCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
ModDirectory
The directory where mods are stored. It's not writable on all platforms.
Declaration
public string ModDirectory { get; set; }
Property Value
Type | Description |
---|---|
String |
Mods
An enumeration of mods sorted by load order. See EnumerateModsReverse() for reversed order.
Declaration
public IEnumerable<Mod> Mods { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Mod> |
Methods
| Improve this Doc View SourceCombinePaths(String[])
Combines an array of strings into a path. This is a substitute of Combine(String[]), which was not available with previously used .NET version.
Declaration
[Obsolete("Use string Path.Combine(params string[] paths")]
public static string CombinePaths(params string[] paths)
Parameters
Type | Name | Description |
---|---|---|
String[] | paths | An array of parts of the path. |
Returns
Type | Description |
---|---|
String | The combined paths. |
CompileFromSourceAssets(String[])
Compiles source files in mod bundle to assembly.
Declaration
public static Assembly CompileFromSourceAssets(string[] source)
Parameters
Type | Name | Description |
---|---|---|
String[] | source | The content of source files. |
Returns
Type | Description |
---|---|
Assembly | The compiled assembly or null. |
EnumerateModsReverse()
Enumerates all mods with reverse load order. Unlike Reverse<TSource>(IEnumerable<TSource>), this method doesn't allocate memory for a new collection.
Declaration
public IEnumerable<Mod> EnumerateModsReverse()
Returns
Type | Description |
---|---|
IEnumerable<Mod> | An enumeration of mods sorted by reverse load order. |
FindAssets<T>(String, String)
Seeks assets inside a directory from all mods with load order. An asset is accepted if its directory ends with the given subdirectory. For example "Assets/Textures" matches "Water.png" from "Assets/Game/Mods/Example/Assets/Textures/Water.png".
Declaration
public List<T> FindAssets<T>(string relativeDirectory, string extension = null)
where T : Object
Parameters
Type | Name | Description |
---|---|---|
String | relativeDirectory | A relative directory with forward slashes (i.e. "Assets/Textures"). |
String | extension | An extension including the dots (i.e ".json") or null. |
Returns
Type | Description |
---|---|
List<T> | A list of assets or null if there are no matches. |
Type Parameters
Name | Description |
---|---|
T |
GetAllChildren(Transform, ref List<Transform>)
Helper function to assist with serializing and deserializing prefabs.
Declaration
public static List<Transform> GetAllChildren(Transform trans, ref List<Transform> transforms)
Parameters
Type | Name | Description |
---|---|---|
Transform | trans | Parent transform. |
List<Transform> | transforms | A list already containing data or null to request a new list. |
Returns
Type | Description |
---|---|
List<Transform> | The list of transforms. |
GetAllModFileNames()
Get mod file name string for each loaded mod
Declaration
public string[] GetAllModFileNames()
Returns
Type | Description |
---|---|
String[] | A collection with all mod file names. |
GetAllModGUID()
Gets all the mod GUIDs which are defined and valid.
Declaration
public string[] GetAllModGUID()
Returns
Type | Description |
---|---|
String[] | A collection of valid mod GUIDs. |
GetAllModInfo()
Get array of ModInfo objects for each loaded mod
Declaration
public ModInfo[] GetAllModInfo()
Returns
Type | Description |
---|---|
ModInfo[] | A collection with all mod informations. |
GetAllMods()
Returns all loaded mods in array. See also Mods.
Declaration
public Mod[] GetAllMods()
Returns
Type | Description |
---|---|
Mod[] | A collection with all the mods. |
GetAllMods(Boolean)
Returns all loaded mods in array. See also Mods.
Declaration
[Obsolete("Mods now are always sorted by load order. Use overload without parameters or Mods property.")]
public Mod[] GetAllMods(bool loadOrder)
Parameters
Type | Name | Description |
---|---|---|
Boolean | loadOrder | ordered by load priority if true |
Returns
Type | Description |
---|---|
Mod[] | A collection with all the mods. |
GetAllModsWithSaveData()
Gets all mods wich provide contributes to save data.
Declaration
public IEnumerable<Mod> GetAllModsWithSaveData()
Returns
Type | Description |
---|---|
IEnumerable<Mod> | An enumeration of mods with save data. |
GetAllModTitles()
Get modtitle string for each loaded mod
Declaration
public string[] GetAllModTitles()
Returns
Type | Description |
---|---|
String[] | A collection with all mod titles. |
GetAssetFromMod<T>(String, String, Boolean, out Boolean)
Get type t asset from mod using name of asset
Declaration
public T GetAssetFromMod<T>(string assetName, string modTitle, bool clone, out bool check)
where T : Object
Parameters
Type | Name | Description |
---|---|---|
String | assetName | asset name |
String | modTitle | title of mod |
Boolean | clone | return copy of asset |
Boolean | check | true if loaded sucessfully |
Returns
Type | Description |
---|---|
T | The loaded asset or null if not found. |
Type Parameters
Name | Description |
---|---|
T | Asset Type |
GetAssetName(String)
Converts an asset path to only the asset name, preserving the extension, converted to invariant lower case.
The parameter assetPath
must be a Unity Editor asset path, using only the "/"
separator, or an asset name.
For example "Assets/Texture.png"
to "texture.png"
, "Assets/Texture"
to "texture"
and "Texture"
to "texture"
.
Declaration
public static string GetAssetName(string assetPath)
Parameters
Type | Name | Description |
---|---|---|
String | assetPath | An asset path or asset name itself. |
Returns
Type | Description |
---|---|
String | Asset name converted to lower case. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
FormatException |
|
GetMod(Int32)
Get mod using index
Declaration
public Mod GetMod(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of a mod. |
Returns
Type | Description |
---|---|
Mod | The mod at the given index or null if the index is invalid. |
GetMod(String)
Get mod using Mod Title
Declaration
public Mod GetMod(string modTitle)
Parameters
Type | Name | Description |
---|---|---|
String | modTitle | The title of a mod. |
Returns
Type | Description |
---|---|
Mod | The mod with the given title or null if not found. |
GetModAssetNames(String)
Get all asset names from mod
Declaration
public string[] GetModAssetNames(string modTitle)
Parameters
Type | Name | Description |
---|---|---|
String | modTitle | The title of a mod. |
Returns
Type | Description |
---|---|
String[] | A collection with the names of all assets from a mod or null if not found. |
GetModFromGUID(String)
Get mod from GUID
Declaration
public Mod GetModFromGUID(string modGUID)
Parameters
Type | Name | Description |
---|---|---|
String | modGUID | The unique identifier of a mod. |
Returns
Type | Description |
---|---|
Mod | The mod with the given GUID or null if not found. |
GetModIndex(String)
Get index for mod by title
Declaration
public int GetModIndex(string modTitle)
Parameters
Type | Name | Description |
---|---|---|
String | modTitle | The title of a mod. |
Returns
Type | Description |
---|---|
Int32 | The index of the mod with the given title or -1 if not found. |
GetModTitleFromGUID(String)
Get mod title from GUID
Declaration
public string GetModTitleFromGUID(string modGUID)
Parameters
Type | Name | Description |
---|---|---|
String | modGUID | The unique identifier of a mod. |
Returns
Type | Description |
---|---|
String | The title of the mod with the given GUID or null if not found. |
GetTextAssetLines(TextAsset)
Utility method for gettings lines of text from a text asset
Declaration
public static List<string> GetTextAssetLines(TextAsset asset)
Parameters
Type | Name | Description |
---|---|---|
TextAsset | asset |
Returns
Type | Description |
---|---|
List<String> |
LoadModSettings()
Attempts to load saved mod settings from file and updates loaded mods.
Declaration
public static bool LoadModSettings()
Returns
Type | Description |
---|---|
Boolean | True if settings loaded successfully. |
MakeRelativePath(String, String)
Determines the difference between two paths.
Declaration
public static string MakeRelativePath(string path0, string path1)
Parameters
Type | Name | Description |
---|---|---|
String | path0 | The main path that contains |
String | path1 | A path to a subdirectory or file inside |
Returns
Type | Description |
---|---|
String |
|
Refresh()
Look for changes in mod directory before the compiling / loading process has begun.
Declaration
public void Refresh()
SendModMessage(String, String, Object, DFModMessageCallback)
Send data to a mod that has a valid DFModMessageReceiver delegate.
Declaration
public void SendModMessage(string modTitle, string message, object data = null, DFModMessageCallback callback = null)
Parameters
Type | Name | Description |
---|---|---|
String | modTitle | The title of the target mod. |
String | message | A string to be sent to the target mod. |
Object | data | Data to send with the message. |
DFModMessageCallback | callback | An optional message callback. |
StateManager_OnStateChange(StateManager.StateTypes)
Declaration
public void StateManager_OnStateChange(StateManager.StateTypes state)
Parameters
Type | Name | Description |
---|---|---|
StateManager.StateTypes | state |
TryGetAsset<T>(String, Nullable<Boolean>, out T)
Seek asset in all mods with load order.
Declaration
public bool TryGetAsset<T>(string name, bool? clone, out T asset)
where T : Object
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of asset to seek. |
Nullable<Boolean> | clone | Make a copy of asset? If null is loaded without cache. |
T | asset | Loaded asset or null. |
Returns
Type | Description |
---|---|
Boolean | True if asset is found and loaded sucessfully. |
Type Parameters
Name | Description |
---|---|
T |
Remarks
If multiple mods contain an asset with given name, priority is defined by load order.
TryGetAsset<T>(String[], Nullable<Boolean>, out T)
Seek asset in all mods with load order. Check all names for each mod with the given priority.
Declaration
public bool TryGetAsset<T>(string[] names, bool? clone, out T asset)
where T : Object
Parameters
Type | Name | Description |
---|---|---|
String[] | names | Names of asset to seek ordered by priority. |
Nullable<Boolean> | clone | Make a copy of asset? If null is loaded without cache. |
T | asset | Loaded asset or null. |
Returns
Type | Description |
---|---|
Boolean | True if asset is found and loaded sucessfully. |
Type Parameters
Name | Description |
---|---|
T |
Remarks
If multiple mods contain an asset with any of the given names, priority is defined by load order. If chosen mod contains multiple assets, priority is defined by order of names list.
WriteModSettings()
Writes mod settings (title, priority, enabled) to file.
Declaration
public static bool WriteModSettings()
Returns
Type | Description |
---|---|
Boolean | True if settings written successfully. |
Events
| Improve this Doc View SourceOnLoadAssetEvent
An event that is raised when an asset is loaded from an AssetBundle and is cached. It's not raised again if the asset is cloned and instantiated multiple times.
Declaration
public static event ModManager.AssetUpdate OnLoadAssetEvent
Event Type
Type | Description |
---|---|
ModManager.AssetUpdate |
OnUnloadModEvent
An event that is raised when a mod is removed and its AssetBundle is unloaded.
Declaration
public static event ModManager.ModUpdate OnUnloadModEvent
Event Type
Type | Description |
---|---|
ModManager.ModUpdate |