-
Notifications
You must be signed in to change notification settings - Fork 28
Custom Roles
Roles are very simple in Mira API. There are 3 things you need to do to create a custom role:
- Create a class that inherits from a base game role (like
CrewmateRole,ImpostorRole, etc) - Implement the
ICustomRoleinterface from Mira API. - 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.
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;
}And an in-game screenshot of the role:

The ICustomRole interface contains various properties and methods that can be implemented to customize your role.
Keep in mind that since custom roles are required to inherit from a RoleBehaviour class, you can also override any of the methods from RoleBehaviour to further customize your role.
Here are the available properties:
| Property | Type | Required | Default Value | Description |
|---|---|---|---|---|
RoleName |
string |
Yes | None | The name of the role. |
RoleDescription |
string |
Yes | None | A short description of the role. |
RoleLongDescription |
string |
Yes | None | A longer description of the role. |
RoleColor |
UnityEngine.Color |
Yes | None | The color of the role. |
Team |
ModdedRoleTeams |
Yes | None | The team of the role. |
MaxPlayers |
int |
No | 15 | The maximum number of players that can have this role. |
OptionsScreenshot |
LoadableAsset<Sprite> |
No | MiraAssets.Empty | The screenshot that will be displayed in the settings menu. |
Icon |
LoadableAsset<Sprite> |
No | MiraAssets.Empty | The role's icon. |
AffectedByLight |
bool |
No | Team == Crewmate | Whether the role is affected by the lights sabotage. |
CanGetKilled |
bool |
No | Team == Crewmate | Whether the role can be killed. |
CanKill |
bool |
No | Team == Impostor | Whether the role can kill. |
CanUseVent |
bool |
No | Team == Impostor | Whether the role is able to use vents. |
TasksCount |
bool |
No | Team == Crewmate | Whether the role's tasks count towards task progress. |
IsGhostRole |
bool |
No | false | Whether the role is a Ghost role or not. |
HideSettings |
bool |
No | IsGhostRole == True | Whether the role should be hidden in the role settings menu. |
GhostRole |
RoleTypes |
No | Team == Crewmate ? CrewmateGhost : ImpostorGhost | The RoleTypes/RoleId of the Ghost Role that this Role should become on death. |
Here are the available methods:
| Method Signature | Required | Default Behavior | Description |
|---|---|---|---|
void PlayerControlFixedUpdate(PlayerControl playerControl) |
No | None | Runs on the PlayerControl.FixedUpdate method for ALL players who have this role |
void HudUpdate(HudManager hudManager) |
No | None | Runs on the HudManager.Update method for the LOCAL player only! |
string? GetCustomEjectionMessage(NetworkedPlayerInfo player) |
No | Returns $"{player.PlayerName} was The {this.RoleName}" if the role is an Impostor role. Otherwise returns null. | Gets a custom ejection message for when a player with this role is voted out. |
StringBuilder SetTabText() |
No | Returns Helpers.CreateForThisRole(this)
|
Gets a StringBuilder to get the text for this role on the role tab. |
bool IsModifierApplicable(BaseModifier modifier) |
No | Returns true | Checks if a given modifier is applicable to this role. |