Skip to content
This repository has been archived by the owner on Nov 12, 2018. It is now read-only.

Developing

Anairkoen Schno edited this page Sep 23, 2018 · 13 revisions

Developing for IPA

This is quite similar to normal IPA (and supports standard IPA plugins, though not for long), however it is recommended that you inherit IBeatSaberPlugin instead of IPlugin and IEnhancedBeatSaberPlugin instead of IEnhancedPlugin. This variant sports a couple of changes.

  1. Instead of referencing IllusionPlugin, you now reference IPA.Loader. Everything formerly in both IllusionPlugin and IllusionInjector is now in this one file. The root namespace is now IPA. The loader WILL fix references, but that is probably temporary until this is fully adopted as the standard for Beat Saber.
  2. The old level change events were replaced with
public void OnActiveSceneChanged(Scene prevScene, Scene nextScene);
public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode);
public void OnSceneUnloaded(Scene scene);
  1. The inclusion of public ModsaberModInfo ModInfo { get; }. This allows your mod to tell IPA what to look for on Modsaber.ML when trying to update it. Here is an example property definition:
public ModsaberModInfo ModInfo => new ModsaberModInfo
{
    InternalName = "exampleplugin",
    CurrentVersion = "0.0.0"
};

Your plugin can also ask for a Logger, IModPrefs, or IConfigProvider object by using them as types in the argument list for an Init() method. Ordering and name doesn't matter, and Init() can be omitted.

For example, if you wanted a Logger and IModPrefs you could define Init() as

public void Init(Logger logger, IModPrefs prefs)

but if you only wanted a Logger, you could put this:

public void Init(object thisWillBeNull, Logger logger)

Any unrecognized types will just be passed as their default value (given by default(Type)).

Additional Libraries

This distro of IPA comes with Ionic.Zip, Newtonsoft.Json, Harmony, SemVer, Mono.Cecil, as well as the Mono project's I18N.dll and I18N.West.dll to provide codepage 437, and Microsoft.CSharp.dll.

All third party libraries exist in the Libs folder, with a naming scheme of assemblyName.version.dll. This should be used by any plugins that want their own third-party libraries. Libraries may be put in subdirectories, however this is only recommended for additional modules that are part of your plugin, and not 3rd party libraries. Names must be unique among all subdirectories and the root. By including the version in the filename, it allows multiple plugins to use different versions of the libraries without conflicts.

Any native library should be placed in Libs\Native for it to be loaded correctly.

THE VERSION MUST BE CORRECT OR THE LIBRARY WILL NOT LOAD!

Take a look at this file to see what kind of process works for this.

Clone this wiki locally