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 Loadout v1.3.3
BepInEx/plugins/sbb-loadout/loadout.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; 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.Configuration; using BepInEx.Logging; using HarmonyLib; using MenuLib; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using WebSocketSharp; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("plspls")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.3.3.0")] [assembly: AssemblyInformationalVersion("1.3.3+1ab8b0ed5b3a0d03f7c46a863000f4d8141aa3bb")] [assembly: AssemblyProduct("givegun")] [assembly: AssemblyTitle("givegun")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 givegun { [BepInPlugin("plspls.Loadout", "Loadout", "1.3.2")] public class GiveGun : BaseUnityPlugin { public static ConfigEntry<bool> mod_enabled; public static ConfigEntry<string> item_list; public static Dictionary<string, int> loadout = new Dictionary<string, int>(); internal static GiveGun Instance { get; private set; } = null; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; mod_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the mod."); item_list = ((BaseUnityPlugin)this).Config.Bind<string>("Items", "ItemList", "Item Gun Handgun", "A list of items you want to start with separated by a semicolon. Use a hash to denote quantity. Items without quantity will be spawned for each player.\nDefault game item list:\nItem Cart Medium\nItem Cart Small\nItem Drone Battery\nItem Drone Feather\nItem Drone Indestructible\nItem Drone Torque\nItem Drone Zero Gravity\nItem Extraction Tracker\nItem Grenade Duct Taped\nItem Grenade Explosive\nItem Grenade Human\nItem Grenade Shockwave\nItem Grenade Stun\nItem Gun Handgun\nItem Gun Shotgun\nItem Gun Tranq\nItem Health Pack Large\nItem Health Pack Medium\nItem Health Pack Small\nItem Melee Baseball Bat\nItem Melee Frying Pan\nItem Melee Inflatable Hammer\nItem Melee Sledge Hammer\nItem Melee Sword\nItem Mine Explosive\nItem Mine Shockwave\nItem Mine Stun\nItem Orb Zero Gravity\nItem Power Crystal\nItem Rubber Duck\nItem Upgrade Map Player Count\nItem Upgrade Player Energy\nItem Upgrade Player Extra Jump\nItem Upgrade Player Grab Range\nItem Upgrade Player Grab Strength\nItem Upgrade Player Health\nItem Upgrade Player Sprint Speed\nItem Upgrade Player Tumble Launch\nItem Valuable Tracker\n"); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); GiveGun_UI.CreateMenus(); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal static class GiveGun_UI { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ScrollViewBuilderDelegate <>9__1_0; public static ScrollViewBuilderDelegate <>9__1_1; public static ScrollViewBuilderDelegate <>9__1_2; public static ScrollViewBuilderDelegate <>9__1_5; public static ScrollViewBuilderDelegate <>9__1_3; public static ShouldCloseMenuDelegate <>9__2_0; public static BuilderDelegate <>9__3_0; public static BuilderDelegate <>9__3_1; internal RectTransform <CreateItemEntries>b__1_0(Transform view) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 20f); return ((REPOElement)MenuAPI.CreateREPOSpacer(view, default(Vector2), val)).rectTransform; } internal RectTransform <CreateItemEntries>b__1_1(Transform view) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) REPOLabel val = MenuAPI.CreateREPOLabel("Set an item quantity to -1 to spawn one for each player.", view, Vector2.zero); ((TMP_Text)val.labelTMP).fontSize = 12f; return ((REPOElement)val).rectTransform; } internal RectTransform <CreateItemEntries>b__1_2(Transform view) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 20f); return ((REPOElement)MenuAPI.CreateREPOSpacer(view, default(Vector2), val)).rectTransform; } internal RectTransform <CreateItemEntries>b__1_5(Transform scrollView) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 10f); return ((REPOElement)MenuAPI.CreateREPOSpacer(scrollView, default(Vector2), val)).rectTransform; } internal RectTransform <CreateItemEntries>b__1_3(Transform scrollView) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 20f); return ((REPOElement)MenuAPI.CreateREPOSpacer(scrollView, default(Vector2), val)).rectTransform; } internal bool <Loadout_OpenUI>b__2_0() { string text = ""; foreach (KeyValuePair<string, int> item in GiveGun.loadout) { if (item.Value != 0) { string text2 = ((item.Value > 0) ? $"#{item.Value}" : ""); text = text + item.Key + text2 + ";"; } } GiveGun.item_list.Value = text; return true; } internal void <CreateMenus>b__3_0(Transform parent) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Loadout", (Action)Loadout_OpenUI, parent, new Vector2(350f, 50f)); } internal void <CreateMenus>b__3_1(Transform parent) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Loadout", (Action)Loadout_OpenUI, parent, new Vector2(350f, 50f)); } } private static void FetchItems() { if (!GiveGun.mod_enabled.Value || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (GiveGun.loadout.Count == 0) { GiveGun.Logger.LogMessage((object)"Logging items."); GiveGun.loadout = new Dictionary<string, int>(); foreach (string key in StatsManager.instance.itemDictionary.Keys) { GiveGun.loadout[key] = 0; } } string[] array = GiveGun.item_list.Value.Split(';'); string[] array2 = array; foreach (string text in array2) { List<string> list = text.Split('#').ToList(); string text2 = list[0].TrimStart().TrimEnd(); int result = ((list.Count > 1 && int.TryParse(list[1], out result)) ? result : (-1)); GiveGun.loadout[list[0]] = result; } } private static void CreateItemEntries(REPOPopupPage menu) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown object obj = <>c.<>9__1_0; if (obj == null) { ScrollViewBuilderDelegate val = delegate(Transform view) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector2 val6 = default(Vector2); ((Vector2)(ref val6))..ctor(0f, 20f); return ((REPOElement)MenuAPI.CreateREPOSpacer(view, default(Vector2), val6)).rectTransform; }; <>c.<>9__1_0 = val; obj = (object)val; } menu.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f); object obj2 = <>c.<>9__1_1; if (obj2 == null) { ScrollViewBuilderDelegate val2 = delegate(Transform view) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) REPOLabel val6 = MenuAPI.CreateREPOLabel("Set an item quantity to -1 to spawn one for each player.", view, Vector2.zero); ((TMP_Text)val6.labelTMP).fontSize = 12f; return ((REPOElement)val6).rectTransform; }; <>c.<>9__1_1 = val2; obj2 = (object)val2; } menu.AddElementToScrollView((ScrollViewBuilderDelegate)obj2, 0f, 0f); object obj3 = <>c.<>9__1_2; if (obj3 == null) { ScrollViewBuilderDelegate val3 = delegate(Transform view) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector2 val6 = default(Vector2); ((Vector2)(ref val6))..ctor(0f, 20f); return ((REPOElement)MenuAPI.CreateREPOSpacer(view, default(Vector2), val6)).rectTransform; }; <>c.<>9__1_2 = val3; obj3 = (object)val3; } menu.AddElementToScrollView((ScrollViewBuilderDelegate)obj3, 0f, 0f); foreach (string s in StatsManager.instance.itemDictionary.Keys) { menu.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform view) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) REPOSlider val6 = MenuAPI.CreateREPOSlider(s, string.Empty, (Action<int>)delegate(int nv) { int result = GiveGun.loadout[s]; if (int.TryParse(nv.ToString(), out result)) { GiveGun.loadout[s] = result; } }, view, default(Vector2), -1, 20, GiveGun.loadout[s], "", "", (BarBehavior)0); return ((REPOElement)val6).rectTransform; }, 0f, 0f); object obj4 = <>c.<>9__1_5; if (obj4 == null) { ScrollViewBuilderDelegate val4 = delegate(Transform scrollView) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector2 val6 = default(Vector2); ((Vector2)(ref val6))..ctor(0f, 10f); return ((REPOElement)MenuAPI.CreateREPOSpacer(scrollView, default(Vector2), val6)).rectTransform; }; <>c.<>9__1_5 = val4; obj4 = (object)val4; } menu.AddElementToScrollView((ScrollViewBuilderDelegate)obj4, 0f, 0f); } object obj5 = <>c.<>9__1_3; if (obj5 == null) { ScrollViewBuilderDelegate val5 = delegate(Transform scrollView) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector2 val6 = default(Vector2); ((Vector2)(ref val6))..ctor(0f, 20f); return ((REPOElement)MenuAPI.CreateREPOSpacer(scrollView, default(Vector2), val6)).rectTransform; }; <>c.<>9__1_3 = val5; obj5 = (object)val5; } menu.AddElementToScrollView((ScrollViewBuilderDelegate)obj5, 0f, 0f); } private static void Loadout_OpenUI() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown FetchItems(); REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Loadout", (PresetSide)1, false, false, 0f); val.OpenPage(false); ShouldCloseMenuDelegate onEscapePressed = val.onEscapePressed; object obj = <>c.<>9__2_0; if (obj == null) { ShouldCloseMenuDelegate val2 = delegate { string text = ""; foreach (KeyValuePair<string, int> item in GiveGun.loadout) { if (item.Value != 0) { string text2 = ((item.Value > 0) ? $"#{item.Value}" : ""); text = text + item.Key + text2 + ";"; } } GiveGun.item_list.Value = text; return true; }; <>c.<>9__2_0 = val2; obj = (object)val2; } val.onEscapePressed = (ShouldCloseMenuDelegate)Delegate.Combine((Delegate?)(object)onEscapePressed, (Delegate?)obj); CreateItemEntries(val); } public static void CreateMenus() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown object obj = <>c.<>9__3_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Loadout", (Action)Loadout_OpenUI, parent, new Vector2(350f, 50f)); }; <>c.<>9__3_0 = val; obj = (object)val; } MenuAPI.AddElementToEscapeMenu((BuilderDelegate)obj); object obj2 = <>c.<>9__3_1; if (obj2 == null) { BuilderDelegate val2 = delegate(Transform parent) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Loadout", (Action)Loadout_OpenUI, parent, new Vector2(350f, 50f)); }; <>c.<>9__3_1 = val2; obj2 = (object)val2; } MenuAPI.AddElementToLobbyMenu((BuilderDelegate)obj2); } } [HarmonyPatch(typeof(RunManager))] internal static class GiveGun_Giver { private const int ITEM_COUNT = 30; private static void SetItemMax(string item_name, int count) { Item[] array = Resources.FindObjectsOfTypeAll<Item>(); Item[] array2 = array; foreach (Item val in array2) { if (((Object)val).name == item_name) { val.maxAmount = Math.Max(val.maxAmount, count); } } } private static void PurchaseItems(string item_name, int count) { if (!Ext.IsNullOrEmpty(item_name)) { Dictionary<string, int> itemsPurchased = StatsManager.instance.itemsPurchased; int valueOrDefault = itemsPurchased.GetValueOrDefault(item_name, 0); itemsPurchased[item_name] = Math.Max(count, valueOrDefault); GiveGun.Logger.LogMessage((object)$"Spawning {count} {item_name}."); } } [HarmonyPostfix] [HarmonyPatch("ChangeLevel")] private static void Patch() { if (!GiveGun.mod_enabled.Value || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } foreach (KeyValuePair<string, Item> item in StatsManager.instance.itemDictionary) { SetItemMax(item.Key, 30); } if (!SemiFunc.RunIsLevel() || RunManager.instance.loadLevel != 0) { return; } List<PlayerAvatar> list = SemiFunc.PlayerGetList(); int num = Math.Max(1, list.Count); foreach (KeyValuePair<string, int> item2 in GiveGun.loadout) { if (item2.Value != 0) { int count = ((item2.Value > 0) ? item2.Value : num); PurchaseItems(item2.Key, count); } } } } }