Skip to main content
Version: 0.2.0

Class ModBase

Namespace: ReadyM.Sdk.Common
Assembly: ReadyM.Sdk.Common.dll

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

public abstract class ModBase : ICSharpMod

Inheritance

objectModBase

Implements

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; set; }

Property Value

ILogger

ModDirectory

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

protected string ModDirectory { get; }

Property Value

string

Name

The mod name

public abstract string Name { get; }

Property Value

string

Methods

DeInit()

Called by the mod loader on game closing.

public virtual void DeInit()

GetReloadContext()

public virtual object? GetReloadContext()

Returns

object?

Init(IDependencyContainer)

public virtual void Init(IDependencyContainer services)

Parameters

services IDependencyContainer

RegisterArchetypes(Action<IArchetypeRegistry>)

Register new archetypes or modify existing ones.

protected void RegisterArchetypes(Action<IArchetypeRegistry> configure)

Parameters

configure Action<IArchetypeRegistry>

Runs once while the ECS schema is built.

RegisterConfig<TConfig>(string)

Reads fileName from this mod's folder and registers the result as a singleton, so other classes can take it as a constructor parameter. Opt in by calling this; nothing is read or written for a mod that does not.

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.

RegisterServices(IDependencyContainer)

protected abstract void RegisterServices(IDependencyContainer services)

Parameters

services IDependencyContainer

Reload(object?)

public virtual void Reload(object? context)

Parameters

context object?

SetModDirectory(string)

Called by the mod loader, before IDependencyContainer).

public void SetModDirectory(string directory)

Parameters

directory string

Start()

Called after all mods have called RegisterServices.

public virtual void Start()
  • Constructors
    • ModBase()
  • Properties
    • IsDebug
    • Logger
    • ModDirectory
    • Name
  • Methods
    • DeInit()
    • GetReloadContext()
    • Init(IDependencyContainer)
    • RegisterArchetypes(Action<IArchetypeRegistry>)
    • RegisterConfig<TConfig>(string)
    • RegisterServices(IDependencyContainer)
    • Reload(object?)
    • SetModDirectory(string)
    • Start()