Skip to content

Doorways API Reference

Nicolas Suarez edited this page Dec 10, 2022 · 13 revisions

Attributes

[assembly:Doorways]

The Doorways Assembly-wide attribute signals to doorways that the assembly should be loaded as a doorways plug-in. Regardless of what the DLL does, if it does not have this assembly attribute it will not be loaded by Doorways.

Usage

[assembly: Doorways(Name = string, Prefix = string)]

Fields

  • string Name: This is the display name Doorways will use for your mod when emitting log messages and error reports. If left unspecified, Doorways will use your Assembly Title.
  • string Prefix: This is the ID of your mod. All your mod's content will be prefixed with this string, so it should be kept short. These must be unique - Doorways will not load your mod if another previously loaded Doorways mod has the same prefix. If left unspecified, Doorways will use the full path of the namespace your objects are defined in.

[DoorwaysInit]

Attach this attribute to any static method in your mod assembly, and Doorways will call it once when your mod is loaded and before Doorways loads any of your mod's content.

There are constraints on the allowed function signature of the tagged method. For more information see Event OnInit.

It is strongly recommended to only tag a single method as your mod init method. However, Doorways will not stop you from defining multiple such methods. In the case that multiple init methods are defined, Doorways will execute them all in an undefined order.

Usage

public class MyModMain 
{
    [DoorwaysInit]
    internal static void Init()
    {
        // Init code
    }
}

[DoorwaysObject]

Any classes tagged with this attribute will be considered by Doorways to be automatically processed as game entities. In order for them to be added, they must either derive from one of Doorways' base entity classes, or declare the DoorwaysFactory attribute on at least one of their methods.

If those conditions are satisfied, then Doorways will automatically instantiate the class and add it as a new game entity.

[DoorwaysFactory]

Any methods in a [DoorwaysObject]-tagged class that have this attribute will be invoked and their output processed as game entities.

The method must have the signature static IEnumerable<IEntityWithId> Func(void), but may have any visibility modifier. For example:

[DoorwaysObject]
public class MyCustomFactory
{
    [DoorwaysFactory]
    public static IEnumerable<IEntityWithId> MyFactoryFunction()
    {
        yield return ... etc
    }
}

Events

On Init

This event is different from all other events in that it cannot be subscribed to. Instead, tell Doorways about your desired Initialization method using the Doorways assembly attribute.

Init functions can have any access level - they are called with reflection which ignores access protections. In fact, it may be better to make your initialization function private or internal so other mods cannot call your mod's initialization routine easily.

An init function can either accept no parameters or a single IDoorwaysMod:

internal static void Init();
internal static void Init(IDoorwaysPlugin mod);

Game Content Types

Interfaces and Mixins

IDoorwaysPlugin

Content Classes