diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs index c66ea52..c5e63be 100644 --- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs @@ -476,6 +476,10 @@ public static class RoleSettingMenuPatches if (role.Configuration.CanModifyChance) { role.SetChance(roleSetting.RoleChance); + if (roleSetting.RoleChance == 0 && role.Configuration.MaxRoleCount != 0) + { + role.SetCount(0); + } } } catch (Exception e) diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs index 33bbd7e..f3f13d1 100644 --- a/MiraAPI/Roles/ICustomRole.cs +++ b/MiraAPI/Roles/ICustomRole.cs @@ -128,6 +128,10 @@ public interface ICustomRole : IOptionable if (presetConfig.TryGetEntry(ChanceConfigDefinition, out ConfigEntry chanceEntry)) { SetChance(chanceEntry.Value); + if (chanceEntry.Value == 0) + { + SetCount(0); + } } } @@ -156,6 +160,10 @@ public interface ICustomRole : IOptionable /// The role count option. public virtual int? GetCount() { + if (ParentMod.PluginConfig.TryGetEntry(ChanceConfigDefinition, out ConfigEntry entry2) && entry2.Value == 0) + { + return 0; + } if (ParentMod.PluginConfig.TryGetEntry(NumConfigDefinition, out ConfigEntry entry)) { return Mathf.Clamp(entry.Value, 0, Configuration.MaxRoleCount);