Some of DFDs core features use type discovery to set up a couple things like engine entry points and network messages. To enable this for your project, put
[assembly:DFDAssembly]
at the top of any of your .cs files in your project. You only need this once.
Unless you want to mod the main menu, you should not use the default MonoBehaviour Awake/Start/OnEnable methods to access anything that happens on a DFD map. BepInEx will spawn your plugin instance MonoBehaviour in the menu (or one of our setup scenes). You can instead get a static entry point for your mod using the
[Initialize(InitializationPhase)]
attribute by adding it to a static method that takes an IEngine parameter like this:
[Initialize(InitializationPhase.OnPostMapLoad), Priority(100)]
private static void OnMapLoaded(IEngine e)
{
//do things here
}
Caution: When using this attribute in a class and another inherits from it, you should use the second optional [Initialize] attribute parameter and set it to false
, unless you want this method to be called once for every inheriting type from that class.
If you’re feeling adventurous (and don’t want to wait until we can take time to document this some more), write this in your IDE and see what your code completion brings up