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 UpgradeableWisplight v0.0.1
UpgradableWisplight.dll
Decompiled 6 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("UpgradableWisplight")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("UpgradableWisplight")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("46812190-4158-4589-bb95-4fd4c132fcb2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace UpgradeableWisplight; [BepInPlugin("mtsukn.upgradeablewisplight", "UpgradeableWisplight", "0.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class UpgradeableWisplight : BaseUnityPlugin { [HarmonyPatch(typeof(Requirement))] [HarmonyPatch("GetAmount")] public static class GetAmount_Patch { private static bool Prefix(Requirement __instance, int qualityLevel, ref int __result) { if (upgradeTable.TryGetValue(__instance, out var value)) { __result = ((value.quality + 1 == qualityLevel) ? __instance.m_amount : 0); return false; } return true; } } [HarmonyPatch(typeof(SE_Demister))] [HarmonyPatch("UpdateStatusEffect")] public static class SE_Demister_Patch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Stfld && list[i].operand.ToString() == "UnityEngine.GameObject m_ballInstance" && list[i + 1].opcode == OpCodes.Ret) { list.InsertRange(i + 1, new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(SE_Demister), "m_ballInstance")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UpgradeableWisplight), "UpdateBall", (Type[])null, (Type[])null)) }); } } return list.AsEnumerable(); } } private const string pluginGUID = "mtsukn.upgradeablewisplight"; private const string pluginName = "UpgradeableWisplight"; private const string pluginVersion = "0.0.1"; private readonly Harmony HarmonyInstance = new Harmony("mtsukn.upgradeablewisplight"); public static ManualLogSource logger = Logger.CreateLogSource("UpgradeableWisplight"); private FileSystemWatcher configFileWatcher; private const float defaultRange = 10f; public static ConditionalWeakTable<Requirement, UpgradeRequirement> upgradeTable = new ConditionalWeakTable<Requirement, UpgradeRequirement>(); public static ConfigEntry<string> requirementsEntry { get; private set; } public static ConfigEntry<string> qualityEntry { get; private set; } public void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown ConfigFile config = ((BaseUnityPlugin)this).Config; object[] array = new object[1]; ConfigurationManagerAttributes val = new ConfigurationManagerAttributes(); val.CustomDrawer = QualityDrawer; array[0] = val; qualityEntry = config.Bind<string>("Quality and Range", "Qualities", "10,14,18,24", new ConfigDescription("Sets the reveal range for each quality tier (vanilla=10)", (AcceptableValueBase)null, array)); ConfigFile config2 = ((BaseUnityPlugin)this).Config; object[] array2 = new object[1]; val = new ConfigurationManagerAttributes(); val.CustomDrawer = RequirementsDrawer; array2[0] = val; requirementsEntry = config2.Bind<string>("Requirements", "Requirements", "Silver:1,Wisp:1$YggdrasilWood:2,Wisp:10$Sap:10,Wisp:25$DvergrKeyFragment:1,Eitr:10,Wisp:50", new ConfigDescription("Crafting requirements for each quality upgrade (quality 0 is initial crafting recipe)", (AcceptableValueBase)null, array2)); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); PrefabManager.OnVanillaPrefabsAvailable += ModifyItems; configFileWatcher = new FileSystemWatcher(Paths.ConfigPath, Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath)); configFileWatcher.NotifyFilter = NotifyFilters.LastWrite; configFileWatcher.Changed += ModifyItems; configFileWatcher.EnableRaisingEvents = true; } public void ModifyItems(object sender, FileSystemEventArgs e) { ModifyItems(); } public void ModifyItems() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown try { List<float> list = UnserializeQuality(); List<List<Requirement>> list2 = UnserializeRequirements(); ItemDrop prefab = Cache.GetPrefab<ItemDrop>("Demister"); prefab.m_itemData.m_shared.m_maxQuality = list.Count; Recipe prefab2 = Cache.GetPrefab<Recipe>("Recipe_Demister"); List<Requirement> list3 = new List<Requirement>(); for (int i = 0; (list.Count <= list2.Count && i < list.Count) || (list.Count > list2.Count && i < list2.Count); i++) { foreach (Requirement item in list2[i]) { Requirement val = new Requirement { m_resItem = Cache.GetPrefab<ItemDrop>(item.itemName), m_amount = item.amount }; list3.Add(val); upgradeTable.Add(val, new UpgradeRequirement { quality = i }); } } prefab2.m_resources = list3.ToArray(); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while modifing weapons: {arg}"); } finally { PrefabManager.OnVanillaPrefabsAvailable -= ModifyItems; } } private static void UpdateBall(GameObject ballInstance) { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || (Object)(object)ballInstance == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; foreach (ItemData equippedItem in ((Humanoid)localPlayer).m_inventory.GetEquippedItems()) { if (equippedItem.m_shared.m_name == "$item_demister") { float num = 6f; try { num = UnserializeQuality()[equippedItem.m_quality - 1]; } catch (Exception ex) { logger.LogWarning((object)("Index out of bounds UpgradeableWisplight.SE_Demister_Patch " + ex)); break; } ParticleSystemForceField component = ((Component)Utils.FindChild(ballInstance.transform, "Particle System Force Field", (IterativeSearchType)0)).GetComponent<ParticleSystemForceField>(); if ((Object)(object)component == (Object)null) { break; } component.endRange = num; } } } private static void QualityDrawer(ConfigEntryBase cfg) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown bool flag = false; List<float> list = UnserializeQuality(); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Add", new GUIStyle(GUI.skin.button), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { list.Add(10f); flag = true; } if (GUILayout.Button("Remove", new GUIStyle(GUI.skin.button), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }) && list.Count > 1) { list.RemoveAt(list.Count - 1); flag = true; } GUILayout.EndHorizontal(); for (int i = 0; i < list.Count; i++) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Quality " + i, new GUIStyle(GUI.skin.label) { fixedWidth = 60f }, Array.Empty<GUILayoutOption>()); float num = list[i]; if (float.TryParse(GUILayout.TextField(num.ToString(), new GUIStyle(GUI.skin.textField), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }), out var result) && num != result) { flag = true; list[i] = result; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = SerializeQuality(list); } } private static void RequirementsDrawer(ConfigEntryBase cfg) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00ce: 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_00e9: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown List<float> list = UnserializeQuality(); List<List<Requirement>> list2 = UnserializeRequirements(); List<List<Requirement>> list3 = new List<List<Requirement>>(); bool flag = false; while (list.Count > list2.Count) { list2.Add(new List<Requirement> { new Requirement("Silver", 1), new Requirement("Wisp", 1) }); flag = true; } GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); for (int i = 0; i < list.Count; i++) { List<Requirement> list4 = list2[i]; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Quality " + i, new GUIStyle(GUI.skin.label) { fixedWidth = 60f }, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("+", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>())) { list4.Add(new Requirement()); flag = true; } if (GUILayout.Button("-", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>())) { list4.RemoveAt(list4.Count - 1); flag = true; } GUILayout.EndHorizontal(); List<Requirement> list5 = new List<Requirement>(); foreach (Requirement item in list4) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Name: ", new GUIStyle(GUI.skin.label), Array.Empty<GUILayoutOption>()); string text = GUILayout.TextField(item.itemName, new GUIStyle(GUI.skin.textField) { fixedWidth = 130f }, Array.Empty<GUILayoutOption>()); if (text != item.itemName) { flag = true; } GUILayout.Label(" Amount: ", new GUIStyle(GUI.skin.label), Array.Empty<GUILayoutOption>()); int num = item.amount; if (int.TryParse(GUILayout.TextField(num.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 30f }, Array.Empty<GUILayoutOption>()), out var result) && result != num) { num = result; flag = true; } GUILayout.EndHorizontal(); list5.Add(new Requirement(text, num)); } list3.Add(list5); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = SerializeRequirements(list3); } } public static string SerializeQuality(List<float> ranges) { string text = ""; for (int i = 0; i < ranges.Count; i++) { text = text + ranges[i] + ","; } return text.TrimEnd(new char[1] { ',' }); } public static List<float> UnserializeQuality() { List<float> list = new List<float>(); string[] array = qualityEntry.Value.Split(new char[1] { ',' }); string[] array2 = array; foreach (string s in array2) { if (float.TryParse(s, out var result)) { list.Add(result); } } return list; } public static string SerializeRequirements(List<List<Requirement>> requirements) { string text = ""; foreach (List<Requirement> requirement in requirements) { foreach (Requirement item in requirement) { string[] obj = new string[5] { text, item.itemName, ":", null, null }; int amount = item.amount; obj[3] = amount.ToString(); obj[4] = ","; text = string.Concat(obj); } text = text.TrimEnd(new char[1] { ',' }); text += "$"; } return text.TrimEnd(new char[1] { '$' }); } public static List<List<Requirement>> UnserializeRequirements() { List<List<Requirement>> list = new List<List<Requirement>>(); string[] array = requirementsEntry.Value.Split(new char[1] { '$' }); string[] array2 = array; foreach (string text in array2) { List<Requirement> list2 = new List<Requirement>(); string[] array3 = text.Split(new char[1] { ',' }); string[] array4 = array3; foreach (string text2 in array4) { string[] array5 = text2.Split(new char[1] { ':' }); if (array5.Length >= 2) { int.TryParse(array5[1], out var result); list2.Add(new Requirement(array5[0], result)); } } list.Add(list2); } return list; } } public struct Requirement { public string itemName; public int amount; public Requirement() { itemName = "Wisp"; amount = 1; } public Requirement(string name, int amt) { itemName = name; amount = amt; } } public class UpgradeRequirement { public int quality; }