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 LuckyItemUpgrade v1.0.3
LuckyItemUpgrade.dll
Decompiled 5 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; 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("LuckyItemUpgrade")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LuckyItemUpgrade")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4559f694-e6db-42c8-8b24-e2614217999f")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace LuckyItemUpgrade; [BepInPlugin("com.repo.kr.LuckyItemUpgrade", "LuckyItemUpgrade", "1.0.0")] public class ModBehaviour : BaseUnityPlugin { private Harmony harmony; private static ManualLogSource Log; private static ConfigEntry<float> TeamUpgrade; private static ConfigEntry<float> OneMore; private static ConfigEntry<float> LuckyPerson; private static ConfigEntry<int> MultUpgrade; private static ConfigEntry<int> TeamMultUpgrade; private static ConfigEntry<int> LuckyMultUpgrade; private static FieldInfo IDField; private static readonly Type[] UpgradeTypes = new Type[13] { typeof(ItemUpgradeDeathHeadBattery), typeof(ItemUpgradeMapPlayerCount), typeof(ItemUpgradePlayerCrouchRest), typeof(ItemUpgradePlayerEnergy), typeof(ItemUpgradePlayerExtraJump), typeof(ItemUpgradePlayerGrabRange), typeof(ItemUpgradePlayerGrabStrength), typeof(ItemUpgradePlayerGrabThrow), typeof(ItemUpgradePlayerHealth), typeof(ItemUpgradePlayerSprintSpeed), typeof(ItemUpgradePlayerTumbleClimb), typeof(ItemUpgradePlayerTumbleLaunch), typeof(ItemUpgradePlayerTumbleWings) }; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown harmony = new Harmony("com.repo.kr.LuckyItemUpgrade"); Type[] upgradeTypes = UpgradeTypes; foreach (Type type in upgradeTypes) { HarmonyMethod val = new HarmonyMethod(typeof(ModBehaviour), "Upgrade_Prefix", (Type[])null); harmony.Patch((MethodBase)type.GetMethod("Upgrade", BindingFlags.Instance | BindingFlags.Public), val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } TeamUpgrade = ((BaseUnityPlugin)this).Config.Bind<float>("LuckyItemUpgrade", "TeamUpgrade", 50f, new ConfigDescription("Team Upgrade Probability %", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 100f), Array.Empty<object>())); OneMore = ((BaseUnityPlugin)this).Config.Bind<float>("LuckyItemUpgrade", "OneMore", 10f, new ConfigDescription("One More Time Probability %", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 100f), Array.Empty<object>())); LuckyPerson = ((BaseUnityPlugin)this).Config.Bind<float>("LuckyItemUpgrade", "LuckyPerson", 0.01f, new ConfigDescription("Lucky Person Probability %", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 100f), Array.Empty<object>())); MultUpgrade = ((BaseUnityPlugin)this).Config.Bind<int>("LuckyItemUpgrade", "MultUpgrade", 1, new ConfigDescription("Upgrade multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>())); TeamMultUpgrade = ((BaseUnityPlugin)this).Config.Bind<int>("LuckyItemUpgrade", "TeamMultUpgrade", 1, new ConfigDescription("Team Upgrade multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>())); LuckyMultUpgrade = ((BaseUnityPlugin)this).Config.Bind<int>("LuckyItemUpgrade", "LuckyMultUpgrade", 999, new ConfigDescription("Lucky Upgrade multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>())); IDField = typeof(ItemToggle).GetField("playerTogglePhotonID", BindingFlags.Instance | BindingFlags.NonPublic); Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"LuckyItemUpgrade enble"); } private static bool Upgrade_Prefix(object __instance) { try { Component val = (Component)((__instance is Component) ? __instance : null); if (val == null) { Log.LogError((object)("__instance 不是Unity Component类型: " + __instance?.GetType().Name)); return true; } ItemToggle component = val.GetComponent<ItemToggle>(); if ((Object)(object)component == (Object)null) { Log.LogError((object)"未找到ItemToggle组件"); return true; } int num = (int)IDField.GetValue(component); PlayerAvatar val2 = SemiFunc.PlayerAvatarGetFromPhotonID(num); string text = SemiFunc.PlayerGetSteamID(val2); string upgradeMethodName = GetUpgradeMethodName(__instance.GetType()); MethodInfo method = typeof(PunManager).GetMethod(upgradeMethodName, BindingFlags.Instance | BindingFlags.Public); if (method == null) { Log.LogError((object)("找不到升级方法: " + upgradeMethodName)); return true; } int num2 = 0; int num3 = 0; int num4 = 0; while (true) { if (Random.Range(0f, 100f) < TeamUpgrade.Value) { Log.LogInfo((object)"触发团队升级"); num2++; foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { method.Invoke(PunManager.instance, new object[2] { SemiFunc.PlayerGetSteamID(item), TeamMultUpgrade.Value }); } } else if (Random.Range(0f, 100f) < LuckyPerson.Value) { Log.LogInfo((object)"触发欧皇附体"); num3++; method.Invoke(PunManager.instance, new object[2] { text, LuckyMultUpgrade.Value }); } else { method.Invoke(PunManager.instance, new object[2] { text, MultUpgrade.Value }); } if (Random.Range(0f, 100f) >= OneMore.Value) { break; } Log.LogInfo((object)"触发再来一次"); num4++; } if (num2 + num3 + num4 > 0) { string text2 = ((num2 > 0) ? $"TeamUpgrade{num2} " : "") + ((num3 > 0) ? $"LuckyPerson{num3} " : "") + ((num4 > 0) ? $"TryAgain{num4} " : ""); val2.ChatMessageSend(text2); } return false; } catch (Exception arg) { Log.LogError((object)$"升级补丁执行异常: {arg}"); return true; } } private static string GetUpgradeMethodName(Type upgradeType) { string name = upgradeType.Name; Log.LogInfo((object)(name ?? "")); if (name == "ItemUpgradePlayerGrabThrow") { return "UpgradePlayerThrowStrength"; } return "Upgrade" + name.Substring("ItemUpgrade".Length); } }