Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SurvivorFolders v1.0.0
SurvivorFolders.dll
Decompiled a day agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HG; using HarmonyLib; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.UI; using RoR2; using RoR2.ContentManagement; using RoR2.UI; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SurvivorFolders")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SurvivorFolders")] [assembly: AssemblyTitle("SurvivorFolders")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SurvivorFolders { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Thylord.SurvivorFolders", "SurvivorFolders", "1.0.0")] public class SurvivorFolders : BaseUnityPlugin { public class SurvivorGroup { public SurvivorDef[] Survivors; public string Name; public Sprite Icon; public int Order; public Color32 Color; public string[] Packnames; } public const string PluginGUID = "Thylord.SurvivorFolders"; public const string PluginAuthor = "Thylord"; public const string PluginName = "SurvivorFolders"; public const string PluginVersion = "1.0.0"; public Dictionary<string, SurvivorGroup> SurvivorGroups = new Dictionary<string, SurvivorGroup>(); internal static AssetBundle assetbundle; private Transform SafeArea; private GameObject buttonbar; private GameObject buttonbar_blur; private GameObject borderimage; private GameObject blurpanel; private GameObject basebutton; private List<GameObject> groupbuttons; private UILayerKey layerkey; internal static SurvivorFolders Instance { get; private set; } private Sprite GetImage(string name) { return assetbundle.LoadAsset<Sprite>("assets/groupsmodicon/" + name + ".png"); } private void LoadBundle() { assetbundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "groupsmodicon")); } private Color32 HexColor(string hex) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); bool flag = ColorUtility.TryParseHtmlString(hex, ref val); return Color32.op_Implicit(val); } public void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log.Init(((BaseUnityPlugin)this).Logger); LoadBundle(); CharacterSelectBarController component = ((Component)this).GetComponent<CharacterSelectBarController>(); new Harmony("com.KingEnderBrine.ScrollableLobbyUI").PatchAll(); SurvivorCatalog.Init += new hook_Init(SurvivorCatalogInit); CharacterSelectBarController.Awake += new hook_Awake(SelectBarAwake); CharacterSelectController.Awake += new hook_Awake(SelectAwake); CreateSurvGroup("all", "All", GetImage("allicon"), HexColor("#FFCCEC"), new string[1] { "cement? das conc creet baybee" }); CreateSurvGroup("misc", "Misc", GetImage("misc"), HexColor("#C3E0F7"), new string[1] { "ily sm azzy" }, 99); CreateSurvGroup("basegame", "Risk of Rain 2", GetImage("basegameicon"), HexColor("#BD7DBC"), new string[1] { "RoR2.BaseContent" }); CreateSurvGroup("dlc", "Expansions", GetImage("alldlcsicon"), HexColor("#C6FFF3"), new string[1] { "RoR2.DLC" }); CreateSurvGroup("returns", "Risk of Rain", GetImage("returns"), HexColor("#6E8ECD"), new string[6] { "HANDOverclocked", "ChefMod", "SniperClassic", "Robomando", "DiggerUnearthed", "Pilot" }); CreateSurvGroup("modded", "Vanillia-Esque", GetImage("modded"), HexColor("#60ECFF"), new string[4] { "Cloudburst", "Morris", "Sandswept", "Arsonist" }); CreateSurvGroup("starstorm", "Starstorm", GetImage("starstorm"), HexColor("#FF4C51"), new string[4] { "Starstorm", "TeamMoonstorm", "SS2", "RMOR" }); CreateSurvGroup("monmash", "Monster Mash", GetImage("monstermash"), HexColor("#BA2E32"), new string[1] { "MonsterMash" }); CreateSurvGroup("kenko", "Tsuyoikenko", GetImage("kenko"), HexColor("#9D4E5E"), new string[1] { "kenko" }); CreateSurvGroup("rob", "Rob", GetImage("rob"), HexColor("#CD344E"), new string[1] { ".rob." }); } public void CreateSurvGroup(string nameid, string name, Sprite Icon, Color32 Color, string[] Packnames, int order = -1) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (order == -1) { order = SurvivorGroups.Count; } Log.Info("Created group: " + nameid); SurvivorGroups[nameid] = new SurvivorGroup { Survivors = Array.Empty<SurvivorDef>(), Name = name, Icon = Icon, Color = Color, Packnames = Packnames, Order = order }; } private string SpecialCaseSort(SurvivorDef survivorDef, string Context) { return survivorDef.cachedName switch { "NemesisEnforcer" => "starstorm", "Enforcer" => "returns", "Robomando" => "returns", "RocketSurvivor" => "modded", "RobPaladin" => "modded", "Rifter" => "modded", "BOG_PATHFINDER_BODY_NAME" => "modded", _ => null, }; } private void SortSurvivor(SurvivorDef survivorDef, string Context) { if (survivorDef.CheckLocalUserHasRequiredEntitlement() || survivorDef.hidden) { return; } List<string> list = new List<string> { "all" }; bool flag = false; string text = SpecialCaseSort(survivorDef, Context); if (text != null) { list.Add(text); flag = true; } else { foreach (KeyValuePair<string, SurvivorGroup> survivorGroup in SurvivorGroups) { string[] packnames = survivorGroup.Value.Packnames; foreach (string value in packnames) { if (Context.Contains(value)) { list.Add(survivorGroup.Key); flag = true; break; } } } } if (!flag) { list.Add("misc"); } foreach (string item in list) { SurvivorGroups[item].Survivors = SurvivorGroups[item].Survivors.Append(survivorDef).ToArray(); } } private void SelectBarAwake(orig_Awake orig, CharacterSelectBarController self) { orig.Invoke(self); Scrollablelobbyui_patches.selectControllerInstance = ((Component)self).GetComponent(Scrollablelobbyui_patches.selectcontroller); } private void SelectAwake(orig_Awake orig, CharacterSelectController self) { orig.Invoke(self); ((MonoBehaviour)self).StartCoroutine(GroupPanel(self)); } private void SetupGroupMenu() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) int num = 50; borderimage = GameObject.Find("LeftHandPanel (Layer: Main)/BorderImage"); blurpanel = GameObject.Find("LeftHandPanel (Layer: Main)/BlurPanel"); GameObject val = Object.Instantiate<GameObject>(borderimage, SafeArea); ((Object)val).name = "GB offset"; val.transform.SetAsFirstSibling(); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 0.15f); component.anchorMax = new Vector2(0.35f, 1f); ((Transform)component).eulerAngles = new Vector3(0f, 355f, 0f); component.offsetMax = new Vector2(0f, 0f); component.offsetMin = new Vector2(0f, 0f); component.pivot = new Vector2(0f, 0.5f); buttonbar_blur = Object.Instantiate<GameObject>(blurpanel, SafeArea); ((Object)buttonbar_blur).name = "GB blur"; buttonbar_blur.transform.SetParent(val.transform, false); component = buttonbar_blur.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.sizeDelta = new Vector2(80f, 0f); component.anchoredPosition = new Vector2((float)num, 0f); buttonbar = Object.Instantiate<GameObject>(borderimage, SafeArea); ((Object)buttonbar).name = "GB menuactual"; buttonbar.transform.SetParent(val.transform, false); component = buttonbar.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.sizeDelta = new Vector2(80f, 0f); component.anchoredPosition = new Vector2((float)num, 0f); } private void CreateGroupButton(int buttOffset, KeyValuePair<string, SurvivorGroup> survgroup) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown GameObject button = Object.Instantiate<GameObject>(basebutton, buttonbar.transform); Object.Destroy((Object)(object)button.GetComponent<MPEventSystemLocator>()); Object.Destroy((Object)(object)button.GetComponent<RuleChoiceController>()); button.transform.SetAsFirstSibling(); ((Object)button).name = "GB: " + survgroup.Key; RectTransform component = button.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.anchoredPosition = new Vector2(-40f, (float)(-40 - buttOffset)); component.sizeDelta = new Vector2(70f, 70f); Transform val = button.transform.Find("Button"); Object.Destroy((Object)(object)((Component)button.transform.GetChild(2)).gameObject); Object.Destroy((Object)(object)((Component)button.transform.GetChild(3)).gameObject); Object.Destroy((Object)(object)((Component)button.transform.GetChild(4)).gameObject); Object.Destroy((Object)(object)((Component)button.transform.GetChild(5)).gameObject); Object.Destroy((Object)(object)((Component)button.transform.GetChild(6)).gameObject); Image component2 = ((Component)((Component)val).transform.Find("Icon")).GetComponent<Image>(); TooltipProvider component3 = ((Component)val).GetComponent<TooltipProvider>(); groupbuttons.Add(button); component2.overrideSprite = survgroup.Value.Icon; component3.titleColor = Color32.op_Implicit(survgroup.Value.Color); component3.bodyToken = ""; component3.overrideTitleText = survgroup.Value.Name; string text = "Contains:\n"; int num = 0; int num2 = 16; SurvivorDef[] survivors = survgroup.Value.Survivors; foreach (SurvivorDef val2 in survivors) { num++; text += Language.GetString(val2.displayNameToken); if (num > num2) { text = text + "and +" + (survgroup.Value.Survivors.Length - num2) + " other Survivors"; break; } text += ", "; } component3.overrideBodyText = text; HGButton component4 = ((Component)val).GetComponent<HGButton>(); ((UnityEventBase)((Button)component4).onClick).RemoveAllListeners(); ((UnityEvent)((Button)component4).onClick).AddListener((UnityAction)delegate { SelectGroup(survgroup.Key, button); }); ((MPButton)component4).requiredTopLayer = layerkey; } private IEnumerator GroupPanel(CharacterSelectController self) { while ((Object)(object)GameObject.Find("Choice (Difficulty.Easy)") == (Object)null) { yield return (object)new WaitForSeconds(0.02f); } groupbuttons = new List<GameObject>(); SafeArea = ((Component)self).transform.Find("SafeArea"); basebutton = GameObject.Find("Choice (Difficulty.Easy)"); layerkey = GameObject.Find("SafeArea/LeftHandPanel (Layer: Main)").GetComponent<UILayerKey>().GetUILayerKey(); SetupGroupMenu(); int offsetperbutton = 74; foreach (KeyValuePair<string, SurvivorGroup> survgroup in SurvivorGroups.OrderBy((KeyValuePair<string, SurvivorGroup> entry) => entry.Value.Order)) { if (survgroup.Value.Survivors.Length != 0) { CreateGroupButton(offsetperbutton * groupbuttons.Count, survgroup); } } SelectGroup("basegame", GameObject.Find("GB: basegame")); RectTransform rect = buttonbar.GetComponent<RectTransform>(); rect.pivot = new Vector2(0.5f, 1f); rect.anchorMax = new Vector2(1f, 1f); rect.anchorMin = new Vector2(1f, 1f); rect.sizeDelta = new Vector2(80f, (float)(offsetperbutton * groupbuttons.Count + 6)); rect = buttonbar_blur.GetComponent<RectTransform>(); rect.pivot = new Vector2(0.5f, 1f); rect.anchorMax = new Vector2(1f, 1f); rect.anchorMin = new Vector2(1f, 1f); rect.sizeDelta = new Vector2(80f, (float)(offsetperbutton * groupbuttons.Count + 6)); } private void SurvivorCatalogInit(orig_Init orig) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Enumerator<ReadOnlyContentPack> enumerator = ContentManager.allLoadedContentPacks.GetEnumerator(); try { while (enumerator.MoveNext()) { ReadOnlyContentPack current = enumerator.Current; AssetEnumerator<SurvivorDef> enumerator2 = ((ReadOnlyContentPack)(ref current)).survivorDefs.GetEnumerator(); try { while (enumerator2.MoveNext()) { SurvivorDef current2 = enumerator2.Current; string cachedName = current2.cachedName; SortSurvivor(current2, ((ReadOnlyContentPack)(ref current)).identifier); } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } orig.Invoke(); } private List<SurvivorDef> GetSurvivorListFromGroup(string group) { return SurvivorGroups[group].Survivors.ToList(); } private void SelectGroup(string group, GameObject button = null) { SurvList(group); if (!((Object)(object)button != (Object)null)) { return; } foreach (GameObject groupbutton in groupbuttons) { ((Component)groupbutton.transform.GetChild(1)).gameObject.SetActive(false); } ((Component)button.transform.GetChild(1)).gameObject.SetActive(true); } private void SurvList(string group) { List<SurvivorDef> survivors = (from surv in GetSurvivorListFromGroup(@group) orderby surv.desiredSortPosition select surv).ToList(); Scrollablelobbyui_patches.SetSurvivors(survivors); Scrollablelobbyui_patches.Runbuild(); } } [HarmonyPatch] public static class Scrollablelobbyui_patches { public static Type selectcontroller = AccessTools.TypeByName("ScrollableLobbyUI.CharacterSelectBarControllerExtra"); public static object selectControllerInstance; [HarmonyPrefix] public static void Build_patch(object __instance) { } public static MethodBase TargetMethod() { return AccessTools.Method(selectcontroller, "Build", (Type[])null, (Type[])null); } public static void Runbuild() { AccessTools.Method(selectcontroller, "Build", (Type[])null, (Type[])null).Invoke(selectControllerInstance, null); } public static void SetSurvivors(List<SurvivorDef> Survivorlist) { FieldInfo fieldInfo = AccessTools.Field(selectcontroller, "survivorDefList"); List<SurvivorDef> list = (List<SurvivorDef>)fieldInfo.GetValue(selectControllerInstance); list.Clear(); list.AddRange(Survivorlist); } } }