using System; using AmongUs.GameOptions; using Il2CppInterop.Runtime.Attributes; using MiraAPI.GameModes; using MiraAPI.Patches.Freeplay; using MiraAPI.Utilities.Assets; using TMPro; using UnityEngine; namespace MiraAPI.Roles; /// /// Used to configure the specific settings of a role. /// public record struct CustomRoleConfiguration { #pragma warning disable S1133 [Obsolete("Default constructor is not supported. Please use the constructor that takes an ICustomRole parameter.")] #pragma warning restore S1133 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public CustomRoleConfiguration() #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member { throw new NotImplementedException("Default constructor is not supported. Please use the constructor that takes an ICustomRole parameter."); } /// /// Initializes a new instance of the struct. /// /// The in which you are configuring. public CustomRoleConfiguration(ICustomRole role) { var roleBehaviour = role as RoleBehaviour; AffectedByLightOnAirship = role.Team == ModdedRoleTeams.Crewmate; KillButtonOutlineColor = role.Team switch { ModdedRoleTeams.Impostor => Palette.ImpostorRed, ModdedRoleTeams.Crewmate => Palette.CrewmateBlue, _ => role.RoleColor, }; GhostRole = role.Team is ModdedRoleTeams.Impostor ? RoleTypes.ImpostorGhost : RoleTypes.CrewmateGhost; CanGetKilled = roleBehaviour?.IsDead == false && role.Team is not ModdedRoleTeams.Impostor; UseVanillaKillButton = role.Team is ModdedRoleTeams.Impostor; CanUseVent = role.Team is ModdedRoleTeams.Impostor; CanUseSabotage = role.Team is ModdedRoleTeams.Impostor; TasksCountForProgress = role.Team is ModdedRoleTeams.Crewmate; HideSettings = roleBehaviour?.IsDead == true; ShowInFreeplay = roleBehaviour?.IsDead == false; FreeplayFolder = role.Team switch { ModdedRoleTeams.Crewmate => TranslationController.Instance.GetString(StringNames.Crewmate), ModdedRoleTeams.Impostor => TranslationController.Instance.GetString(StringNames.Impostor), _ => TaskAdderPatches.NeutralName, }; IntroSound = role.Team is ModdedRoleTeams.Crewmate ? CustomRoleManager.CrewmateIntroSound : CustomRoleManager.ImpostorIntroSound; } /// /// Gets or sets the hard limit of players that can have this role. This property is used to set a limit in the Role Options menu. If set to 0, the role will not be assigned at start. /// public int MaxRoleCount { get; set; } = 15; /// /// Gets or sets the default role count. /// public int DefaultRoleCount { get; set; } = 0; /// /// Gets or sets the default role chance. /// public int DefaultChance { get; set; } = 0; /// /// Gets or sets a value indicating whether the chance option can be changed or not. /// public bool CanModifyChance { get; set; } = true; /// /// Gets or sets the used for the Role Options menu screenshot. /// [HideFromIl2Cpp] public LoadableAsset? OptionsScreenshot { get; set; } = null; /// /// Gets or sets the used for the Role Icon. /// [HideFromIl2Cpp] public LoadableAsset? Icon { get; set; } = null; /// /// Gets or sets the for the Role Icon. /// [HideFromIl2Cpp] public TMP_SpriteAsset IconTmp { get; set; } /// /// Gets or sets the Intro sound for the Role. /// [HideFromIl2Cpp] public LoadableAsset? IntroSound { get; set; } = null; /// /// Gets or sets the associated game mode for this role. This is used to determine if the role should be available in a specific game mode. /// public Type AssociatedGameMode { get; set; } = typeof(ClassicMode); /// /// Gets or sets a value indicating whether the role is affected by light affectors on Airship. /// public bool AffectedByLightOnAirship { get; set; } /// /// Gets or sets a value indicating whether the role can be killed by vanilla murder system. /// public bool CanGetKilled { get; set; } /// /// Gets or sets a value indicating whether the role should use the vanilla kill button. /// public bool UseVanillaKillButton { get; set; } /// /// Gets or sets a value indicating whether the role can use s. Also sends vanilla data. /// public bool CanUseVent { get; set; } /// /// Gets or sets a value indicating whether the role can receive vanilla data. /// public bool GetsVentData { get; set; } /// /// Gets or sets a value indicating whether the role can use the sabotage button. /// public bool CanUseSabotage { get; set; } /// /// Gets or sets a value indicating whether the role's tasks count towards task progress. /// public bool TasksCountForProgress { get; set; } /// /// Gets or sets a value indicating whether the role should show up in the Role Options menu. /// public bool HideSettings { get; set; } /// /// Gets or sets a value indicating whether the role should show up in the Freeplay Role Selection menu. /// public bool ShowInFreeplay { get; set; } /// /// Gets or sets a freeplay folder this role belongs to. Defaults to team folder. /// public string FreeplayFolder { get; set; } /// /// Gets or sets the outline for the if is . /// public Color KillButtonOutlineColor { get; set; } /// /// Gets or sets the role hint style. See for all options. /// public RoleHintType RoleHintType { get; set; } = RoleHintType.RoleTab; /// /// Gets or sets the Ghost role that is applied when the player is killed. /// public RoleTypes GhostRole { get; set; } }