Skip to content

Follower Commands

Creating Commands

To create a command, you first need to make a class overriding CustomFollowerCommand.
Example:

using COTL_API.CustomFollowerCommand;
using COTL_API.Helpers;
using UnityEngine;
using System.IO;
internal class ExampleFollowerCommand : CustomFollowerCommand
{
public override string InternalName => "Example_Follower_Command";
public override string GetTitle(Follower follower) { return "Example Follower Command"; }
public override string GetDescription(Follower follower) { return "This is an example follower command"; }
public override Sprite CommandIcon => TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("Assets", "example_follower_command.png"));
public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand)
{
interaction.follower.Brain.MakeOld();
interaction.Close(true, reshowMenu: false);
}
}

CustomFollowerCommand supports the following overrides:

TypeNameDefault
stringInternalName[REQUIRED]
SpriteInventoryIconTextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath(“placeholder.png”))
List<FollowerCommandCategory>Categoriesnew() { FollowerCommandCategory.DEFAULT_COMMAND }
stringGetTitle(Follower follower)LocalizationManager.GetTranslation($“FollowerInteractions/{ModPrefix}.{InternalName}“)
stringGetDescription(Follower follower)LocalizationManager.GetTranslation($“FollowerInteractions/{ModPrefix}.{InternalName}/Description”)
stringGetLockedDescription(Follower follower)LocalizationManager.GetTranslation($“FollowerInteractions/{ModPrefix}.{InternalName}/NotAvailable”)
boolShouldAppearFor(Follower follower)true
boolIsAvailable(Follower follower)true
voidExecute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand = FollowerCommands.None)interaction.Close(true, reshowMenu: false);

Coroutines

Some actions, such as changing tasks, require starting a coroutine using interaction.StartCoroutine(interaction.FrameDelayCallback()).
Example:

public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand)
{
interaction.StartCoroutine(interaction.FrameDelayCallback(delegate
{
interaction.eventListener.PlayFollowerVO(interaction.generalAcknowledgeVO);
interaction.follower.Brain.HardSwapToTask(new FollowerTask_Vomit());
}));
interaction.Close(true, reshowMenu: false);
}

Adding Commands

To add a command to the game, simply use CustomFollowerCommandManager.Add().
Example:

using COTL_API.CustomFollowerCommand;
CustomFollowerCommandManager.Add(new ExampleFollowerCommand());

Final Steps

For the icon to load, you need to put it in the appropriate location. For the example, this would be /Assets/example_follower_command.png relative to the root folder containing the .dll
Directory structure:

📂plugins
┣📂Assets
┃ ┗🖼️example_follower_command.png
┗📜mod_name.dll