Skip to content

Asphalt Plugin

lordmampf edited this page Mar 21, 2019 · 10 revisions

In order to create an Asphalt plugin you have to create a plugin class.

First, the class needs to implement IModKitPlugin. Next we need to implement the methods required by the IModKitPlugin. To make the just created ModKitPlugin an asphalt plugin we add the [AsphaltPlugin] attribute to the class.

This may look like follows:

[AsphaltPlugin]
public class SomeAsphaltPlugin : IModKitPlugin
{
    //defines the name of the plugin
    public override string ToString()
    {
        return "SomeAsphaltPlugin";
    }

    //returns the status of the plugin
    public string GetStatus()
    {
        return $"[v.1.0.0] Running...";
    }
}

Initialization Phases

Asphalt also introduces different initialization phases, which allow different checks and initializations to be performed. Just add the respective method to your AsphaltPlugin.

OnPreEnable

public void OnPreEnable()
{
}

If you need something to do before other plugins.

OnEnable

public void OnEnable()
{
}

Here the entire initialization of the plugin can now be carried out, e.g. for the creation of objects.

Please use this method and not the constructor!

OnPostEnable

public void OnPostEnable()
{
}

Use this method if you need something performed after other plugins are initialized.

Additional special initialization phases

Asphalt also provides some special initialization phases - use if you know what you are doing

public static void OnPreInject()
{
}

Called directly before the configs etc are injected - This is the earliest initialization phase which you should use. (Somilar to a static constructor in your own plugin, but guaranteed that Asphalt is initialized)

public static void OnInject()
{
}

Called after injection

public static void OnRecipesInitialized()
{
}

If you want to remove Recipes with the RecipeRemover class, you have to do in during this special initialization phase.

Home

Clone this wiki locally