Roles - All-Of-Us-Mods/MiraAPI-Docs GitHub Wiki

Implementation

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 RoleBehaviour, CrewmateRole, ImpostorRole, etc).
  2. Implement the ICustomRole interface from Mira API.
  3. Add the [RegisterCustomRole] attribute to the class.

Example

Below is a custom role class that we've wrote to demonstrate the Role API.

    [RegisterCustomRole]
    public class CustomRole : ImpostorRole, ICustomRole
    {
        public string RoleName => "fortnite killer";
        public string RoleLongDescription => "ok so your objective is to eliminate everyone with your fortnite tactical shotgun, good luck";
        public string RoleDescription => RoleLongDescription;
        public Color RoleColor => Palette.Orange;
        public ModdedRoleTeams Team => ModdedRoleTeams.Impostor;
        public LoadableAsset<Sprite> OptionsScreenshot => MiraAssets.Banner;

    }

Role Options

You can also specify a role type for an option or option group.

To set the role type for an entire group, set the AdvancedRole property on that group like this:

public class MyOptionsGroup : IModdedOptionGroup
{
    public string GroupName => "My Options";
    public Type AdvancedRole => typeof(MyRole); // this is the role that will have these options
    
    [ModdedNumberOption("Ability Uses", min: 0, max: 10)]
    public float AbilityUses { get; set; } = 5f;
}

To set the role type for individual options, specify the roleType parameter in the option like this:

// this group doesnt specify a role, so it will show up in the global settings
public class MyOptionsGroup : IModdedOptionGroup
{
    public string GroupName => "My Options";
    
    // this option will only show up in the settings for MyRole
    [ModdedNumberOption("Ability Uses", min: 0, max: 10, roleType: typeof(MyRole))]
    public float AbilityUses { get; set; } = 5f;
}

Example

public class CustomRoleSettings : IModdedOptionGroup
{
    public string GroupName => "Custom Role";
    public Type AdvancedRole => typeof(CustomRole); 
    [ModdedNumberOption("Testing level", min: 3, max: 9)] public float TestingLevel { get; set; } = 4;
}
⚠️ **GitHub.com Fallback** ⚠️