Skip to main content
Version: 0.4.1

Class ModBase

Namespace: WukongMp.Sdk
Assembly: WukongMp.Sdk.dll

Base class for WukongMP SDK mods. Each mod should have exactly one class extending from this, which will be instantiated by the mod loader.

public abstract class ModBase : ICSharpModExV2, ICSharpModEx, ICSharpMod

Inheritance​

object ← ModBase

Implements​

ICSharpModExV2, ICSharpModEx, ICSharpMod

Inherited Members​

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors​

ModBase()​

protected ModBase()

Properties​

IsDebug​

Indicates whether the mod is running in a debug build. Can be used to enable debug-only features or logging.

public bool IsDebug { get; }

Property Value​

bool

Logger​

protected ILogger Logger { get; }

Property Value​

ILogger

ModDirectory​

This mod's own folder under Mods, which holds its assemblies, manifest and any config files.

protected string ModDirectory { get; }

Property Value​

string

Name​

Mod name, used for logging and patching.

public abstract string Name { get; }

Property Value​

string

Methods​

DeInit()​

Called by the mod loader on game closing.

public virtual void DeInit()

GetReloadContext()​

Called by the mod loader. Used in hot reload.

public virtual object? GetReloadContext()

Returns​

object?

Init()​

Called by the mod loader on game start.

public void Init()

Initialize(IDependencyContainer)​

protected abstract void Initialize(IDependencyContainer services)

Parameters​

services IDependencyContainer

LateInit()​

Called by the mod loader after all Init calls.

public virtual void LateInit()

RegisterArchetypes(Action<IArchetypeRegistry>)​

Register new archetypes or modify existing.

protected void RegisterArchetypes(Action<IArchetypeRegistry> configure)

Parameters​

configure Action<IArchetypeRegistry>

The configuration callback.

RegisterConfig<TConfig>(string)​

Reads fileName from this mod's folder and registers the result as a singleton.

protected void RegisterConfig<TConfig>(string fileName = "config.json") where TConfig : class, new()

Parameters​

fileName string

Type Parameters​

TConfig

Remarks​

A missing file yields defaults. A file that exists but does not parse, or that carries a key the config type does not declare, throws ModConfigException.

Reload(object?)​

Called by the mod loader. Used in hot reload.

public virtual void Reload(object? context)

Parameters​

context object?

SetLoggerFactory(ILoggerFactory)​

Called by the mod loader.

public void SetLoggerFactory(ILoggerFactory loggerFactory)

Parameters​

loggerFactory ILoggerFactory

SetModDirectory(string)​

Called by the mod loader, before Init.

public void SetModDirectory(string directory)

Parameters​

directory string

  • Constructors
    • ModBase()
  • Properties
    • IsDebug
    • Logger
    • ModDirectory
    • Name
  • Methods
    • DeInit()
    • GetReloadContext()
    • Init()
    • Initialize(IDependencyContainer)
    • LateInit()
    • RegisterArchetypes(Action<IArchetypeRegistry>)
    • RegisterConfig<TConfig>(string)
    • Reload(object?)
    • SetLoggerFactory(ILoggerFactory)
    • SetModDirectory(string)