public bool IsEgligible(RunAggregateData runData) { // If no clan is defined, it doesn't matter which role it shall play. if (Clan == CLAN_ANY) { return(true); } // Otherwise, try to find both clan ids ... int primary = 0; int secondary = 0; if (!clanKeys.TryGetValue(runData.GetMainClassID(), out primary)) { AdvancedRunHistory.Log("Can't find primary clan ID " + runData.GetMainClassID(), LogLevel.Warning); } if (!clanKeys.TryGetValue(runData.GetSubClassID(), out secondary)) { AdvancedRunHistory.Log("Can't find secondary clan ID " + runData.GetSubClassID(), LogLevel.Warning); } // ... and check whether they are the desired ones. switch (Role) { case AS_ANY: return(primary == Clan || secondary == Clan); case AS_PRIMARY: return(primary == Clan); case AS_SECONDARY: return(secondary == Clan); default: return(false); } }
/// <summary> /// Initalize a bunch of UI element templates: a dialog, a button, a dropdown menu, a slider, a toggle button and /// a label. /// </summary> /// <remarks> /// This method needs to be called before trying to instantiate any UI elements with <c>CreateCustomXXX</c> /// methods, otherwise those will throw unchecked NullPointerExceptions (I should probably handle those better). /// Currently, this is achieved by the <see cref="InitCustomUIElementsPatch"/>. Also, once it has been called, /// another call to this method has no effect. /// </remarks> /// <param name="settingsScreen">The settings screen. Using this to store the dialog template so that it doesn't /// get unloaded. There's probably a less hacky way to do this.</param> /// <param name="dialog">The dialog to be used as a template.</param> /// <param name="settingsDialog">The Settings Dialog, used to get a variety of UI elements.</param> public static void InitalizeTemplates(SettingsScreen settingsScreen, ScreenDialog dialog, SettingsDialog settingsDialog) { // This only needs to run once. if (!AreTemplatesInitalized()) { initalized = true; // Just store a bunch of UI elements from the settings screen as templates. They will always be loaded, // so we don't have to care about manipulating them in any way yet. buttonTemplate = Traverse.Create(settingsDialog).Field("keyMappingButton").GetValue <GameUISelectableButton>(); dropdownTemplate = Traverse.Create(settingsDialog).Field("gameSpeedDropdown").GetValue <GameUISelectableDropdown>();; toggleTemplate = Traverse.Create(settingsDialog).Field("googlyEyesToggle").GetValue <GameUISelectableToggle>(); sliderTemplate = Traverse.Create(Traverse.Create(settingsDialog).Field("scrollSensitivityControl").GetValue <ScrollSensitivityControl>()).Field("slider").GetValue <SelectableSliderHelper>(); // There don't seem to be any labels that are assigned to explicit fields, which kinda makes sense, so we'll have to search for one. // This unfortunately breaks pretty easily as shown by the latest update of the game, so I guess we need a long term solution. labelTemplate = settingsDialog.transform.Find("Content/Content/Audio Section/Global volume control").GetComponentInChildren <TextMeshProUGUI>(); // Print warnings if any initalization has been unsuccessful. if (buttonTemplate == null) { AdvancedRunHistory.Log("Button template is null.", LogLevel.Warning); } if (dropdownTemplate == null) { AdvancedRunHistory.Log("Dropdown template is null.", LogLevel.Warning); } if (toggleTemplate == null) { AdvancedRunHistory.Log("Toggle template is null.", LogLevel.Warning); } if (sliderTemplate == null) { AdvancedRunHistory.Log("Slider template is null.", LogLevel.Warning); } if (labelTemplate == null) { AdvancedRunHistory.Log("Label template is null.", LogLevel.Warning); } // We actually neeed to instantiate a copy of the dialog template right now, as the Patch Notes dialog will // unload as soon as you leave the Main Menu screen. Also, we can remove its contents while we're at it. dialogTemplate = GameObject.Instantiate(dialog, settingsScreen.transform); foreach (Transform child in dialogTemplate.transform.Find("Content")) { GameObject.Destroy(child.gameObject); } if (dialogTemplate == null) { AdvancedRunHistory.Log("Dialog template is null.", LogLevel.Warning); } } }