Skip to main content

ModBase

An abstract class in Root.Township, the global namespace.

Old in-game base class for a mod component: subclass it, add it to a GameObject, and it calls Initialize on start and Terminate on destroy, logging each. Used by the game's own debug mods such as FixMod.

Constructors​

MemberWhat it is
protected ModBase()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Properties​

MemberWhat it is
abstract string Name { get; }Display name used in the load and unload log lines.

Methods​

MemberWhat it is
protected abstract void Initialize()Your mod's setup. If it throws, the error is logged and the component destroys itself.
protected void OnDestroy()Calls Terminate and logs that the mod unloaded, or logs the error.
protected void Start()Destroys any other component on the GameObject with the same type name (a reload), then calls Initialize.
protected abstract void Terminate()Your mod's cleanup, called when the component is destroyed.