Roles - All-Of-Us-Mods/MiraAPI-Docs GitHub Wiki
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
RoleBehaviour
,CrewmateRole
,ImpostorRole
, etc). - Implement the
ICustomRole
interface from Mira API. - Add the
[RegisterCustomRole]
attribute to the class.
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;
}
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;
}
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;
}