Show / Hide Table of Contents

    Making a mod

    Overview

    What follows is a very barebones, and frankly not very useful plugin class, even as a starting point, but it should be enough to give a decent idea of how to do quick upgrades of existing mods for those who want to.

    using System;
    using IPA;
    using IPA.Logging;
    
    namespace Demo
    {
        [Plugin(RuntimeOptions.SingleStartInit)]
        internal class Plugin
        {
            public static Logger log { get; private set; }
    
            [Init]
            public Plugin(Logger logger)
            {
                log = logger;
                log.Debug("Basic plugin running!");
    
                // setup that does not require game code
                // this is only called once ever, so do once-ever initialization
            }
    
            [OnStart]
            public void OnStart()
            {
                // setup that requires game code
            }
    
            [OnExit]
            public void OnExit()
            {
                // teardown
            }
        }
    }
    

    There are basically 4 major concepts here:

    1. Logger, the logging system.
    2. PluginAttribute, which declares that this class is a plugin and how it should behave.
    3. InitAttribute, which declares the constructor (and optionally other methods) as being used for initialization.
    4. The lifecycle event attributes OnStartAttribute and OnExitAttribute.

    Read the docs at those links for a better idea of what they do.

    TODO: expand this to explain more, and expand on the base example

    • Improve this Doc
    Back to top Generated by DocFX