Show / Hide Table of Contents

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.

Inheritance
Object
Object
Component
Behaviour
MonoBehaviour
ModManager
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
| Improve this Doc View Source

MODCONFIGFILENAME

Declaration
public const string MODCONFIGFILENAME = "Mod_Settings.json"
Field Value
Type Description
String
| Improve this Doc View Source

MODEXTENSION

Declaration
public const string MODEXTENSION = ".dfmod"
Field Value
Type Description
String
| Improve this Doc View Source

MODINFOEXTENSION

Declaration
public const string MODINFOEXTENSION = ".dfmod.json"
Field Value
Type Description
String
| Improve this Doc View Source

textExtensions

Declaration
public static string[] textExtensions
Field Value
Type Description
String[]

Properties

| Improve this Doc View Source

Instance

Declaration
public static ModManager Instance { get; }
Property Value
Type Description
ModManager
| Improve this Doc View Source

LoadedModCount

The number of mods loaded by Mod Manager.

Declaration
public int LoadedModCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

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
| Improve this Doc View Source

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 Source

CombinePaths(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

GetAllModInfo()

Get array of ModInfo objects for each loaded mod

Declaration
public ModInfo[] GetAllModInfo()
Returns
Type Description
ModInfo[]

A collection with all mod informations.

| Improve this Doc View Source

GetAllMods()

Returns all loaded mods in array. See also Mods.

Declaration
public Mod[] GetAllMods()
Returns
Type Description
Mod[]

A collection with all the mods.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

GetAllModTitles()

Get modtitle string for each loaded mod

Declaration
public string[] GetAllModTitles()
Returns
Type Description
String[]

A collection with all mod titles.

| Improve this Doc View Source

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

| Improve this Doc View Source

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

assetPath is null.

FormatException

assetPath is not a valid asset path.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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>
| Improve this Doc View Source

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.

| Improve this Doc View Source

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 path1.

String path1

A path to a subdirectory or file inside path0.

Returns
Type Description
String

path1 converted to a relative path of path0 or null.

| Improve this Doc View Source

Refresh()

Look for changes in mod directory before the compiling / loading process has begun.

Declaration
public void Refresh()
| Improve this Doc View Source

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.

| Improve this Doc View Source

StateManager_OnStateChange(StateManager.StateTypes)

Declaration
public void StateManager_OnStateChange(StateManager.StateTypes state)
Parameters
Type Name Description
StateManager.StateTypes state
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

OnLoadAssetEvent

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
| Improve this Doc View Source

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

Extension Methods

MBExtensions.Invoke(MonoBehaviour, Action, Single)
MBExtensions.Invoke<T>(MonoBehaviour, Action<T>, T, Single)
MBExtensions.Invoke<T1, T2>(MonoBehaviour, Action<T1, T2>, T1, T2, Single)
MBExtensions.Invoke<T1, T2, T3>(MonoBehaviour, Action<T1, T2, T3>, T1, T2, T3, Single)
MBExtensions.Invoke<T1, T2, T3, T4>(MonoBehaviour, Action<T1, T2, T3, T4>, T1, T2, T3, T4, Single)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX