public static void Init() { /*Assets*/ RegisterAssets(); /*Options menu for lobby*/ //Header RuleCategoryDef PVPHeader = VoteAPI.AddVoteHeader("PVP", new Color(1.0f, 0.0f, 0.0f, 1.0f), false); //Selection RuleDef PVPSelection = VoteAPI.AddVoteSelection(PVPHeader, "PVP", new ChoiceMenu("Free For All PVP On", new Color(0.0f, 1.0f, 0.0f, 0.4f), "Enables free for all game mode", Color.black, "@TeamPVP:Assets/Resources/UI/FreeForAllPVPSelected.png", "artifact_teampvp", Settings.FreeForAllPVPToggle.Item2)); VoteAPI.AddVoteChoice(PVPSelection, new ChoiceMenu("Team PVP On", new Color(0.0f, 1.0f, 0.0f, 0.4f), "Enables team pvp game mode", Color.black, "@TeamPVP:Assets/Resources/UI/TeamPVPSelected.png", "artifact_teampvp", Settings.TeamPVPToggle.Item2)); VoteAPI.AddVoteChoice(PVPSelection, new ChoiceMenu("PVP Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Disables Mod", Color.black, "@TeamPVP:Assets/Resources/UI/TeamPVPDeselected.png", "artifact_teampvp", -1)); PVPSelection.defaultChoiceIndex = 2; RuleDef randomTeamsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Random Teams", new ChoiceMenu("Random Teams On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Teams will be shuffled every round (only for team pvp game mode)", Color.black, "@TeamPVP:Assets/Resources/UI/RandomTeamsSelected.png", "artifact_teampvp", Settings.RandomTeams.Item2)); VoteAPI.AddVoteChoice(randomTeamsSelection, new ChoiceMenu("Random Teams Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Teams will stay the same every round (only for team pvp game mode)", Color.black, "@TeamPVP:Assets/Resources/UI/RandomTeamsDeselected.png", "artifact_teampvp", -1)); randomTeamsSelection.defaultChoiceIndex = Settings.RandomTeams.Item1 ? 0 : 1; RuleDef mobSpawnSelection = VoteAPI.AddVoteSelection(PVPHeader, "Mob Spawn", new ChoiceMenu("Mob Spawn On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Mobs will spawn", Color.black, "@TeamPVP:Assets/Resources/UI/MobSpawnSelected.png", "artifact_teampvp", Settings.MobSpawn.Item2)); VoteAPI.AddVoteChoice(mobSpawnSelection, new ChoiceMenu("Mob Spawn Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Mobs will not spawn", Color.black, "@TeamPVP:Assets/Resources/UI/MobSpawnDeselected.png", "artifact_teampvp", -1)); mobSpawnSelection.defaultChoiceIndex = Settings.MobSpawn.Item1 ? 0 : 1; RuleDef banItemsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Ban Items", new ChoiceMenu("Ban Items On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Banned items configured in the config will be blacklisted", Color.black, "@TeamPVP:Assets/Resources/UI/BanItemsSelected.png", "artifact_teampvp", Settings.BanItems.Item2)); VoteAPI.AddVoteChoice(banItemsSelection, new ChoiceMenu("Ban Items Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Banned Items will not be blacklisted", Color.black, "@TeamPVP:Assets/Resources/UI/BanItemsDeselected.png", "artifact_teampvp", -1)); banItemsSelection.defaultChoiceIndex = Settings.BanItems.Item1 ? 0 : 1; RuleDef companionsShareItemsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Companions Share Items", new ChoiceMenu("Companions Share Items On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Items picked up by the player will be shared with their drones etc", Color.black, "@TeamPVP:Assets/Resources/UI/CompanionsShareItemsSelected.png", "artifact_teampvp", Settings.CompanionsShareItems.Item2)); VoteAPI.AddVoteChoice(companionsShareItemsSelection, new ChoiceMenu("Companions Share Items Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Items will not be shared with drones etc", Color.black, "@TeamPVP:Assets/Resources/UI/CompanionsShareItemsDeselected.png", "artifact_teampvp", -1)); companionsShareItemsSelection.defaultChoiceIndex = Settings.CompanionsShareItems.Item1 ? 0 : 1; RuleDef customPlayableCharactersSelection = VoteAPI.AddVoteSelection(PVPHeader, "Custom Playable Characters", new ChoiceMenu("Custom Playable Characters On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Play custom characters configured in the config", Color.black, "@TeamPVP:Assets/Resources/UI/CustomPlayableCharactersSelected.png", "artifact_teampvp", Settings.CustomPlayableCharacters.Item2)); VoteAPI.AddVoteChoice(customPlayableCharactersSelection, new ChoiceMenu("Custom Playable Characters Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Play the default vanilla characters (unbalanced)", Color.black, "@TeamPVP:Assets/Resources/UI/CustomPlayableCharactersDeselected.png", "artifact_teampvp", -1)); customPlayableCharactersSelection.defaultChoiceIndex = Settings.CustomPlayableCharacters.Item1 ? 0 : 1; RuleDef customInteractablesSpawnerSelection = VoteAPI.AddVoteSelection(PVPHeader, "Custom Interactables Spawner", new ChoiceMenu("Custom Interactables Spawner On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Spawn custom objects (chests, drones, etc) at custom rates configured in the config", Color.black, "@TeamPVP:Assets/Resources/UI/CustomInteractablesSpawnerSelected.png", "artifact_teampvp", Settings.CustomInteractablesSpawner.Item2)); VoteAPI.AddVoteChoice(customInteractablesSpawnerSelection, new ChoiceMenu("Custom Interactables Spawner Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Spawn objects (chests, drones, etc) normally as vanilla", Color.black, "@TeamPVP:Assets/Resources/UI/CustomInteractablesSpawnerDeselected.png", "artifact_teampvp", -1)); customInteractablesSpawnerSelection.defaultChoiceIndex = Settings.CustomInteractablesSpawner.Item1 ? 0 : 1; RuleDef useDeathPlaneFailsafeSelection = VoteAPI.AddVoteSelection(PVPHeader, "Use Death Plane Failsafe", new ChoiceMenu("Use Death Plane Failsafe On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Force players to die should they fall off the map to prevent softlock", Color.black, "@TeamPVP:Assets/Resources/UI/UseDeathPlaneFailsafeSelected.png", "artifact_teampvp", Settings.UseDeathPlaneFailsafe.Item2)); VoteAPI.AddVoteChoice(useDeathPlaneFailsafeSelection, new ChoiceMenu("Use Death Plane Failsafe Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Disables the death plane. Only turn off if your using a custom map!", Color.black, "@TeamPVP:Assets/Resources/UI/UseDeathPlaneFailsafeDeselected.png", "artifact_teampvp", -1)); useDeathPlaneFailsafeSelection.defaultChoiceIndex = Settings.UseDeathPlaneFailsafe.Item1 ? 0 : 1; RuleDef widerStageTransitionsSelection = VoteAPI.AddVoteSelection(PVPHeader, "Wider Stage Transitions", new ChoiceMenu("Wider Stage Transitions On", new Color(0.0f, 0.58f, 1.0f, 0.4f), "Transitions through a wider selection of stages when using the teleporter", Color.black, "@TeamPVP:Assets/Resources/UI/WiderStageTransitionsSelected.png", "artifact_teampvp", Settings.WiderStageTransitions.Item2)); VoteAPI.AddVoteChoice(widerStageTransitionsSelection, new ChoiceMenu("Wider Stage Transitions Off", new Color(1.0f, 0.0f, 0.0f, 0.4f), "Vanilla stage transitions. Also turn off when using custom stages", Color.black, "@TeamPVP:Assets/Resources/UI/WiderStageTransitionsDeselected.png", "artifact_teampvp", -1)); widerStageTransitionsSelection.defaultChoiceIndex = Settings.WiderStageTransitions.Item1 ? 0 : 1; }
public static RuleDef AddVoteSelection(RuleCategoryDef header, string selectionName, ChoiceMenu choiceMenu) { RuleDef selection = new RuleDef("Votes." + selectionName, selectionName); selection.category = header; AddVoteChoice(selection, choiceMenu); header.children.Add(selection); VoteSelections.Add(selection); return(selection); }
// Token: 0x060024FD RID: 9469 RVA: 0x000A1408 File Offset: 0x0009F608 public void SetData(RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook) { this.currentCategory = categoryDef; this.rulesToDisplay.Clear(); List <RuleDef> children = categoryDef.children; for (int i = 0; i < children.Count; i++) { RuleDef ruleDef = children[i]; int num = 0; foreach (RuleChoiceDef ruleChoiceDef in ruleDef.choices) { if (availability[ruleChoiceDef.globalIndex]) { num++; } } bool flag = (!availability[ruleDef.choices[ruleDef.defaultChoiceIndex].globalIndex] && num != 0) || num > 1; if (flag) { this.rulesToDisplay.Add(children[i]); } } this.AllocateStrips(this.rulesToDisplay.Count); List <RuleChoiceDef> list = new List <RuleChoiceDef>(); for (int j = 0; j < this.rulesToDisplay.Count; j++) { RuleDef ruleDef2 = this.rulesToDisplay[j]; list.Clear(); foreach (RuleChoiceDef ruleChoiceDef2 in ruleDef2.choices) { if (availability[ruleChoiceDef2.globalIndex]) { list.Add(ruleChoiceDef2); } } this.strips[j].GetComponent <RuleBookViewerStrip>().SetData(list, ruleBook.GetRuleChoiceIndex(ruleDef2)); } if (this.headerObject) { this.headerObject.GetComponent <Image>().color = categoryDef.color; this.headerObject.GetComponentInChildren <LanguageTextMeshController>().token = categoryDef.displayToken; } this.SetTip(this.isEmpty ? categoryDef.emptyTipToken : null); }
/// <summary> /// Adds a rule to the category. DO NOT ADD CHOICES AFTER THIS. /// </summary> /// <param name="category">The category to add this rule to.</param> /// <param name="rule">The rule to add.</param> /// <typeparam name="T">The type of value this rule holds.</typeparam> public static void AddToCategory <T>(RuleCategoryDef category, LobbyRule <T> rule) { rule._ruleDef.globalIndex = RuleCatalog.ruleCount; _addRule.Invoke(null, new object[] { rule._ruleDef }); RuleCatalog.allCategoryDefs.Last()?.children.Remove(rule._ruleDef); RuleCatalog.allCategoryDefs.FirstOrDefault(x => x == category)?.children.Add(rule._ruleDef); rule._ruleDef.category = category; rule._ruleDef.choices.ForEach(x => { x.globalIndex = RuleCatalog.choiceCount; _ruleChoices.Add(x); }); Array.Resize(ref PreGameRuleVoteController.votesForEachChoice, RuleCatalog.choiceCount); UpdateValues += (sender, args) => rule.UpdateValue((RuleBook)sender); }
public static RuleCategoryDef AddVoteHeader(string categoryToken, Color color, bool addAfterVanillaHeaders = false) { RuleCategoryDef header = new RuleCategoryDef { position = -1, displayToken = categoryToken, color = color, emptyTipToken = null, hiddenTest = new Func <bool>(HiddenTestFalse) }; if (addAfterVanillaHeaders) { VoteHeadersBottom.Add(header); } else { VoteHeadersTop.Add(header); } return(header); }
/// <summary> /// Wraps a rule category for the lobby. /// </summary> /// <param name="category">The category.</param> public LobbyCategory(RuleCategoryDef category) { Def = category; }
public static void AddToCategory <T>(RuleCategoryDef category, LobbyRule <T> rule) { new LobbyCategory(category).PushRule(rule); }
private void RuleCategoryController_SetData(On.RoR2.UI.RuleCategoryController.orig_SetData orig, RoR2.UI.RuleCategoryController self, RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook) { if (categoryDef.displayToken == "RULE_HEADER_DIFFICULTY" && EDrule != null) { try { var localUser1 = LocalUserManager.GetFirstLocalUser(); if (localUser1 != null) { bool knowsED = AchievementManager.GetUserAchievementManager(localUser1).userProfile.HasAchievement("COMPLETE_MAINENDING_DILUVIAN"); if (knowsED) { Syzygy.Unlocked(); } else { Syzygy.Locked(); } EDrule.spritePath = assetString + Syzygy.def.IconPath; ReloadLanguage(); } } catch (Exception e) { Logger.LogWarning(e); } } orig(self, categoryDef, availability, ruleBook); }
static void RegisterVoteHeader(RuleCategoryDef header) { (typeof(RuleCatalog)).GetFieldValue <List <RuleCategoryDef> >("allCategoryDefs").Add(header); RegisteredVoteHeaders.Add(header); }
internal static void RuleCategoryControllerSetData(On.RoR2.UI.RuleCategoryController.orig_SetData orig, RoR2.UI.RuleCategoryController self, RuleCategoryDef categoryDef, RuleChoiceMask availability, RuleBook ruleBook) { orig(self, categoryDef, availability, ruleBook); var stripContainer = self.transform.Find("StripContainer"); if (!stripContainer.gameObject.activeInHierarchy) { return; } stripContainer.Find("FrameContainer").gameObject.SetActive(false); for (var i = 0; i < stripContainer.childCount; i++) { var child = stripContainer.GetChild(i); if (child.gameObject.activeSelf) { SetupStripPrefab(child); } } }