Documentation Help

Integrating Multiple Plugins

Introduction

AnchorChain provides a few methods to ensure that mods can both be dependent on each other and modify each other.

All dependencies in AnchorChain are hard dependencies, meaning that even an implication that another mod should exist will be taken to mean that it must. To make this as clear as possible, anything implying a dependency will be in the implicit dependencies section.

Explicit Dependencies

ACDependency

The ACDependency attribute is AnchorChain's way of adding explicit dependencies to a plugin. It also allows for version-specific dependencies with SemVer.


public class ACDependency([NotNull] string guid, string minVersion, string maxVersion)

Arguments

  • string guid

    The GUID of the dependency as specified in its ACPlugin attribute.

  • string minVersion

    The minimum version of the dependency, as specified in its ACPlugin attribute. If this is set to null, it will be assumed that there is no minimum version. This must be in a format acceptable by System.Version.

  • string maxVersion

    The maximum version of the dependency, as specified in its ACPlugin attribute. If this is set to null, it will be assumed that there is no maximum version. This must be in a format acceptable by System.Version.

To add other-plugin as a versionless dependency to the NewPlugin class we created in Writing A Basic Plugin, we can add the line [ACDependency("<GUID of plugin>")] as seen below.


using AnchorChain; using UnityEngine; namespace NewPlugin; [ACPlugin("io.github.your-url.new-plugin", "New Plugin", "0.1.0")] [ACDependency("io.github.other-creator.other-plugin")] public class NewPlugin : IAnchorChainMod { public void TriggerEntryPoint() { Debug.Log("Hello Anchor Chain!"); } }

Implicit Dependencies

ACPlugin Ordering Dependencies

ACPlugin has two arguments (before and after) which create implicit dependencies. As mentioned in the introduction, all dependencies in AnchorChain are hard dependencies, so your plugin will not load without these implicit dependencies. These tags are discussed at more length in the ordering dependencies section.

Incompatibilities

ACIncompatibility

The ACIncompatibility attribute adds explicit incompatibilities to a plugin. It does not allow for version-specific incompatibility.


public class ACIncompatibility([NotNull] string guid)

Arguments

  • string guid The GUID of the incompatibility as specified in its ACPlugin attribute.

To make our example plugin incompatible with the other-plugin plugin, we can add the line [ACIncompatibility("io.github.other-creator.other-plugin")] as shown below.


using AnchorChain; using UnityEngine; namespace NewPlugin; [ACPlugin("io.github.your-url.new-plugin", "New Plugin", "0.1.0")] [ACIncompatibility("io.github.other-creator.other-plugin")] public class NewPlugin : IAnchorChainMod { public void TriggerEntryPoint() { Debug.Log("Hello Anchor Chain!"); } }

ACPlugin Ordering Incompatibilities

When plugin load order is resolved, AnchorChain screens for any "ordering loops" formed by two plugins that both want to load before or after the other. If AnchorChain detects an ordering loop, it will not load either plugin, as the ordering is understood as a hard dependency as discussed here.

Ordering Dependency Loading

ACPlugin Ordering

The ACPlugin attribute provides built-in plugin ordering for dependent plugins. For your convenience, the ACPlugin documentation is copied below. If you need a refresher on its purpose, look here.

Ordering Independent Plugins

Since ordering plugins creates implicit dependencies, we must use another method to order non-dependent plugins. In AnchorChain, it is best practice to create a plugin that depends on both and orders them as desired. Doing so introduces minimal overhead within the main plugins and allows for adding context-specific patches. The general structure of such a plugin would be as follows.

using AnchorChain; using UnityEngine; namespace NewPlugin; [ACPlugin( "io.github.your-url.connector-plugin", "Connector Plugin", "0.1.0", ["io.github.other-creator.first-plugin"], ["io.github.other-creator.other-plugin"] )] [ACDependency("io.github.other-creator.first-plugin")] [ACDependency("io.github.other-creator.other-plugin")] public class NewPlugin : IAnchorChainMod { public void TriggerEntryPoint() { // Other patching here if necessary } }
Last modified: 24 January 2025