Skip to content

Custom Roles

XtraCube edited this page Aug 30, 2024 · 16 revisions

Custom Roles

Roles are very simple in Mira API. There are 3 things you need to do to create a custom role:

  1. Create a class that inherits from a base game role (like CrewmateRole, ImpostorRole, etc)
  2. Implement the ICustomRole interface from Mira API.
  3. Add the [RegisterCustomRole] attribute to the class.

Disclaimer: Make sure your plugin class has the following attribute [ReactorModFlags(ModFlags.RequireOnAllClients)] or else your roles will not register correctly.

Note: For step 1, if you are making neutral roles, choose either CrewmateRole or ImpostorRole as the base depending on if it can kill or not!

Mira API handles everything else, from adding the proper options to the settings menu, to managing the role assignment at the start of the game. There are no extra steps on the developer's part.

Example

Here is an example of a role class:

[RegisterCustomRole]
public class FreezerRole : ImpostorRole, ICustomRole
{
    public string RoleName => "Freezer";
    public string RoleLongDescription => "Freeze another player for a duration of time.";
    public string RoleDescription => this.RoleLongDescription;
    public Color RoleColor => Palette.Blue;
    public ModdedRoleTeams Team => ModdedRoleTeams.Impostor;
    public LoadableAsset<Sprite> OptionsScreenshot => ExampleAssets.Banner;
    public int MaxPlayers => 2;
}

ICustomRole Interface

The ICustomRole interface contains various properties and methods that can be implemented to customize your role.

Here are the available properties:

Clone this wiki locally