-
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;
}The ICustomRole interface contains various properties and methods that can be implemented to customize your role.
Here are the available properties: