Show / Hide Table of Contents

Class Mod

A mod for Daggerfall Unity.

Inheritance
Object
Mod
Namespace: DaggerfallWorkshop.Game.Utility.ModSupport
Assembly: Assembly-CSharp.dll
Syntax
[Serializable]
[fsObject(MemberSerialization = fsMemberSerialization.OptIn)]
public class Mod

Constructors

| Improve this Doc View Source

Mod()

Declaration
public Mod()
| Improve this Doc View Source

Mod(String, String, AssetBundle)

Makes a mod from an assetbundle.

Declaration
public Mod(string name, string dirPath, AssetBundle ab)
Parameters
Type Name Description
String name

Mod filename without the extension.

String dirPath

Path to mod file directory.

AssetBundle ab

The assetbundle to associate to new mod instance.

Properties

| Improve this Doc View Source

AssetBundle

If not null, this is the assetbundle where all the assets for this mod are stored. Assets should be retrieved with GetAsset<T>(String, Boolean) which benefits of a cache system.

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

AssetNames

Cached list of all asset names (not the relative paths).

Declaration
public string[] AssetNames { get; }
Property Value
Type Description
String[]
| Improve this Doc View Source

DirPath

The directory where the mod file is stored. This is equal or a sub-directory of ModDirectory.

Declaration
public string DirPath { get; }
Property Value
Type Description
String
| Improve this Doc View Source

Enabled

If this mod is enabled from the mods window, it will be loaded by the Mod Manager and methods marked with the Invoke attribute will be called at the specified state.

Declaration
[SerializeField]
public bool Enabled { get; set; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

FileName

The name of the mod file on disk without extension.

Declaration
[SerializeField]
public string FileName { get; }
Property Value
Type Description
String
Remarks

While GUID can be used behind the scenes, a short, unique and readable name for the mod is needed when it surface to users or other mod developers (for example for presets and dependencies). Filename is the best candidate because it can't contain invalid path chars. A good name should be lowercase and without spaces (i.e "example-mod"). A new "Name" property may be created to allow filename to be changed.

| Improve this Doc View Source

GUID

An unique identifier for this mod or "invalid" if not defined.

Declaration
public string GUID { get; }
Property Value
Type Description
String
| Improve this Doc View Source

HasSettings

If this mod has settings, they can be retrieved with GetSettings().

Declaration
public bool HasSettings { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

IsReady

A value indicating whether this mod is ready; It should be set by the mod itself after initialization.

Declaration
public bool IsReady { get; set; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

LoadPriority

The position in the load order, which affects the invocation order and the automatic asset loading by the Asset-Injection framework.

Declaration
[SerializeField]
public int LoadPriority { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

LoadSettingsCallback

If not null, this callback is invoked when settings are changed or when raised with LoadSettings().

Declaration
public Action<ModSettings, ModSettingsChange> LoadSettingsCallback { set; }
Property Value
Type Description
Action<ModSettings, ModSettingsChange>
| Improve this Doc View Source

MessageReceiver

An optional callback that allows to efficiently send messages to this mod without using reflections.

Declaration
public DFModMessageReceiver MessageReceiver { get; set; }
Property Value
Type Description
DFModMessageReceiver
| Improve this Doc View Source

ModInfo

Mod informations defined from the mod builder.

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

PersistentDataDirectory

A directory for persistent mod data. It is ensured that the directory is writable but not that exists. Use CreateDirectory(String) before accessing it.

Declaration
public string PersistentDataDirectory { get; }
Property Value
Type Description
String
| Improve this Doc View Source

SaveDataInterface

An optional implementation of the interface that allows mods to take part of load/save process and store custom data associated to a specific save on disk.

Declaration
public IHasModSaveData SaveDataInterface { set; }
Property Value
Type Description
IHasModSaveData
| Improve this Doc View Source

TemporaryCacheDirectory

A directory for temporary mod cache. It is ensured that the directory is writable but not that exists. Use CreateDirectory(String) before accessing it.

Declaration
public string TemporaryCacheDirectory { get; }
Property Value
Type Description
String
| Improve this Doc View Source

Title

The readable title of the mod, which may contain invalid path characters.

Declaration
[SerializeField]
public string Title { get; }
Property Value
Type Description
String

Methods

| Improve this Doc View Source

CompileSourceToAssemblies()

Compiles all source files to assembly

Declaration
public List<Assembly> CompileSourceToAssemblies()
Returns
Type Description
List<Assembly>
| Improve this Doc View Source

FindAssetNames(ref List<String>, String, String)

Seeks assets inside a directory provided by this mod. 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 int FindAssetNames(ref List<string> names, string relativeDirectory, string extension = null)
Parameters
Type Name Description
List<String> names

Null or a buffer of names. Will be filled with matches with the extension but without the directory.

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
Int32

The number of assets found.

| Improve this Doc View Source

FindModLoaders(StateManager.StateTypes)

Returns a list of any valid mod setup functions.

Declaration
public List<SetupOptions> FindModLoaders(StateManager.StateTypes state)
Parameters
Type Name Description
StateManager.StateTypes state
Returns
Type Description
List<SetupOptions>
| Improve this Doc View Source

GetAsset<T>(String, Boolean)

Loads an asset from the assetbundle of this mod and cache it. If required, the assetbundle will be automatically loaded.

Declaration
public T GetAsset<T>(string assetName, bool clone = false)
    where T : Object
Parameters
Type Name Description
String assetName

The name of the asset with or without extension.

Boolean clone

Instantiate a cloned instance if true.

Returns
Type Description
T

A reference to the loaded asset or a cloned instance.

Type Parameters
Name Description
T

The asset type.

| Improve this Doc View Source

GetAsset<T>(String, out Boolean, Boolean)

Loads an asset from the assetbundle of this mod and cache it. If required, the assetbundle will be automatically loaded.

Declaration
public T GetAsset<T>(string assetName, out bool loadedBundle, bool clone = false)
    where T : Object
Parameters
Type Name Description
String assetName
Boolean loadedBundle

True if assetbundle had to be loaded.

Boolean clone

Instantiate a cloned instance if true.

Returns
Type Description
T

A reference to the loaded asset or a cloned instance.

Type Parameters
Name Description
T

The asset type.

| Improve this Doc View Source

GetCompiledType(String)

Return Type from Assemblies using name of type

Declaration
public Type GetCompiledType(string type)
Parameters
Type Name Description
String type

name of Type

Returns
Type Description
Type

System.Type

| Improve this Doc View Source

GetSettings()

Imports settings for this mod and provides a sanitized read-only access. Use LoadSettings() if you want to support live changes.

Declaration
public ModSettings GetSettings()
Returns
Type Description
ModSettings
| Improve this Doc View Source

HasAsset(String)

Checks if this mod contains an asset with the given name.

Declaration
public bool HasAsset(string assetName)
Parameters
Type Name Description
String assetName

The name of the asset.

Returns
Type Description
Boolean

True if asset is provided by this mod.

| Improve this Doc View Source

IsAssetLoaded(String)

Checks if an asset has already been loaded and can be retrieved without loading it again.

Declaration
public bool IsAssetLoaded(string assetName)
Parameters
Type Name Description
String assetName

The name of the asset.

Returns
Type Description
Boolean

True if the asset is already loaded.

| Improve this Doc View Source

LoadAllAssetsFromBundle(Boolean)

Loads all assets from asset bundle immediately. Invidual assets can then be retrieved with GetAsset<T>(String, Boolean). Assets are permanently cached until requested once; then they benefit of memory management.

Declaration
public bool LoadAllAssetsFromBundle(bool unloadBundle = true)
Parameters
Type Name Description
Boolean unloadBundle

Unload asset bundle if true

Returns
Type Description
Boolean

True if assetbundle has been loaded succesfully.

| Improve this Doc View Source

LoadAllAssetsFromBundleAsync(Boolean)

Load all assets from asset bundle asynchronously. Invidual assets can then be retrieved with GetAsset<T>(String, Boolean). Assets are permanently cached until requested once; then they benefit of memory management.

Declaration
public IEnumerator LoadAllAssetsFromBundleAsync(bool unloadBundle = true)
Parameters
Type Name Description
Boolean unloadBundle

Unload asset bundle if true.

Returns
Type Description
IEnumerator
| Improve this Doc View Source

LoadAssetBundle()

Loads the asset bundle associated to this mod.

Declaration
public AssetBundle LoadAssetBundle()
Returns
Type Description
AssetBundle

The loaded asset bundle or null.

| Improve this Doc View Source

LoadAssetBundleAsync()

Loads the asset bundle associated to this mod asynchronously.

Declaration
public IEnumerator LoadAssetBundleAsync()
Returns
Type Description
IEnumerator
| Improve this Doc View Source

LoadSettings()

Loads mod settings using LoadSettingsCallback with an event where all settings are considered changed. Use GetSettings() if you don't want to support live changes.

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

Localize(String)

Gets a localized string from the text table associated with this mod.

Declaration
public string Localize(string key)
Parameters
Type Name Description
String key

Key used in the text table.

Returns
Type Description
String

Localized string.

| Improve this Doc View Source

Localize(String[])

Gets a localized string from the text table associated with this mod.

Declaration
public string Localize(params string[] keyParts)
Parameters
Type Name Description
String[] keyParts

Key used in the text table as a concatenation of names.

Returns
Type Description
String

Localized string.

| Improve this Doc View Source

UnloadAssetBundle(Boolean)

Unloads the asset bundle associated to this mod. Loaded assets can still be retrieved from cache, unless they are also unloaded.

Declaration
public void UnloadAssetBundle(bool unloadAllObjects)
Parameters
Type Name Description
Boolean unloadAllObjects

Remove all loaded assets from memory.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX