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 ItemBundles v1.5.0
ItemBundles.dll
Decompiled 5 months agousing System; using System.Collections; 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.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GoldItems; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreUpgrades.Classes; using Photon.Pun; using REPOLib; using REPOLib.Modules; using UnityEngine; using VanillaUpgrades; [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-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("GoldItems")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("MoreUpgrades")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("VanillaUpgrades")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("SeroRonin")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.5.0.0")] [assembly: AssemblyInformationalVersion("1.5.0")] [assembly: AssemblyProduct("ItemBundles")] [assembly: AssemblyTitle("ItemBundles")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 ItemBundles { public static class BundleHelper { public static int GetItemBundleChance(Item item) { //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_0012: Unknown result type (might be due to invalid IL or missing references) itemType key = ValidateItemType(item); int chanceInShop = ItemBundles.Instance.itemTypeBundleInfos[key].chanceInShop; if (ItemBundles.Instance.itemBundleInfos[item.prefab.prefabName].chanceInShop >= 0) { chanceInShop = ItemBundles.Instance.itemBundleInfos[item.prefab.prefabName].chanceInShop; } return chanceInShop; } public static int GetItemBundleMax(Item item) { //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_0012: Unknown result type (might be due to invalid IL or missing references) itemType key = ValidateItemType(item); int maxInShop = ItemBundles.Instance.itemTypeBundleInfos[key].maxInShop; if (ItemBundles.Instance.itemBundleInfos[item.prefab.prefabName].maxInShop >= 0) { maxInShop = ItemBundles.Instance.itemBundleInfos[item.prefab.prefabName].maxInShop; } return maxInShop; } public static int GetItemBundleMinItem(Item item) { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) itemType key = ValidateItemType(item); int value = ItemBundles.Instance.config_minPerBundle.Value; if (ItemBundles.Instance.itemTypeBundleInfos[key].config_minPerBundle.Value >= 0) { value = ItemBundles.Instance.itemTypeBundleInfos[key].config_minPerBundle.Value; } if (ItemBundles.Instance.itemBundleInfos[item.prefab.prefabName].config_minPerBundle.Value >= 0) { value = ItemBundles.Instance.itemBundleInfos[item.prefab.prefabName].config_minPerBundle.Value; } return value; } public static int GetItemBundleMinItem(string itemString, itemType itemType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) itemType key = ValidateItemType(itemType); int value = ItemBundles.Instance.config_minPerBundle.Value; if (ItemBundles.Instance.itemTypeBundleInfos[key].config_minPerBundle.Value >= 0) { value = ItemBundles.Instance.itemTypeBundleInfos[key].config_minPerBundle.Value; } if (ItemBundles.Instance.itemBundleInfos[itemString].config_minPerBundle.Value >= 0) { value = ItemBundles.Instance.itemBundleInfos[itemString].config_minPerBundle.Value; } return value; } public static float GetItemBundlePriceMult(string itemString, itemType itemType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0022: 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) itemType key = ValidateItemType(itemType); float value = ItemBundles.Instance.config_priceMultiplier.Value; if (ItemBundles.Instance.itemTypeBundleInfos[key].config_priceMultiplier.Value >= 0f) { value = ItemBundles.Instance.itemTypeBundleInfos[key].config_priceMultiplier.Value; } if (ItemBundles.Instance.itemBundleInfos[itemString].config_priceMultiplier.Value >= 0f) { value = ItemBundles.Instance.itemBundleInfos[itemString].config_priceMultiplier.Value; } return value; } public static itemType ValidateItemType(Item item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000b: 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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return (itemType)(((int)item.itemType == 4) ? 3 : ((int)item.itemType)); } public static itemType ValidateItemType(itemType itemType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return (itemType)(((int)itemType == 4) ? 3 : ((int)itemType)); } public static string GetItemStringFromBundle(Item bundleItem) { string prefabName = bundleItem.prefab.prefabName; return GetItemStringFromBundle(prefabName); } public static string GetItemStringFromBundle(string bundleItemString) { string removeString = " Bundle"; return RemoveString(bundleItemString, removeString); } public static string RemoveString(string baseString, string removeString) { int num = baseString.IndexOf(removeString); return (num < 0) ? baseString : baseString.Remove(num, removeString.Length); } public static List<PlayerAvatar> PlayerGetAllAlive() { List<PlayerAvatar> list = new List<PlayerAvatar>(); foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { if (item.playerHealth.health > 0) { list.Add(item); } } return list; } public static bool IsObjectBundlePrefab(GameObject obj) { ItemUpgradeBundleGenerated component = obj.GetComponent<ItemUpgradeBundleGenerated>(); if (Object.op_Implicit((Object)(object)component)) { return component.isPrefab; } return false; } public static bool SceneIsPrefabStage() { if (!ItemBundles.Instance.mainMenuReached || SemiFunc.MenuLevel()) { return true; } return (Object)(object)RunManager.instance == (Object)null; } } public class BundleManager : MonoBehaviour { public static BundleManager instance; public void Awake() { if (!Object.op_Implicit((Object)(object)instance)) { instance = this; } } } [HarmonyPatch(typeof(StatsManager))] internal static class BundlePatch_StatsManager { [HarmonyPostfix] [HarmonyPatch("Start")] public static void Start_Postfix(StatsManager __instance) { BundleLoader.OnAllBundlesLoaded += ItemBundles.Instance.InitializeItemBundles; } } [HarmonyPatch(typeof(ItemAttributes))] internal static class BundlePatch_ItemAttributes { [HarmonyPrefix] [HarmonyPatch("ShopInTruckLogic")] private static bool ShopInTruckLogic_Prefix(ItemAttributes __instance) { return !BundleHelper.IsObjectBundlePrefab(((Component)__instance).gameObject); } [HarmonyPrefix] [HarmonyPatch("GetValue")] private static bool GetValue_Prefix(ItemAttributes __instance) { return !BundleHelper.SceneIsPrefabStage(); } [HarmonyPostfix] [HarmonyPatch("GetValue")] [HarmonyPriority(0)] private static void GetValue_Postfix(ItemAttributes __instance) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Invalid comparison between Unknown and I4 //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Invalid comparison between Unknown and I4 //IL_014a: 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) if (BundleHelper.SceneIsPrefabStage() || (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)) { return; } string value = "Bundle"; string itemAssetName = __instance.itemAssetName; if (!itemAssetName.Contains(value)) { return; } int num = __instance.value; int count = SemiFunc.PlayerGetAll().Count; count += ItemBundles.Instance.config_debugFakePlayers.Value; if ((int)__instance.itemType == 3) { float num2 = ShopManager.instance.itemValueMultiplier; float upgradeValueIncrease = ShopManager.instance.upgradeValueIncrease; if (itemAssetName.Contains("Modded") && MoreUpgradesCompat.enabled) { num2 = MoreUpgradesCompat.GetOriginalValueMultiplier(itemAssetName); upgradeValueIncrease = MoreUpgradesCompat.GetUpgradeValueIncrease(itemAssetName); } float num3 = Random.Range(__instance.itemValueMin, __instance.itemValueMax) * num2; num3 = Mathf.Max(num3, 1000f); num3 = Mathf.CeilToInt(num3 / 1000f); num3 += num3 * upgradeValueIncrease * (float)StatsManager.instance.GetItemsUpgradesPurchased(BundleHelper.GetItemStringFromBundle(__instance.itemAssetName)); num = (int)num3; } if ((int)__instance.itemType == 6 || (int)__instance.itemType == 11) { count = Mathf.Max(count, BundleHelper.GetItemBundleMinItem(BundleHelper.GetItemStringFromBundle(__instance.item), __instance.itemType)); } if (count > 1) { float num4 = BundleHelper.GetItemBundlePriceMult(BundleHelper.GetItemStringFromBundle(__instance.item), __instance.itemType) / 100f; float num5 = (float)count * num4; int num6 = Mathf.RoundToInt((float)num * num5); num = num6; } __instance.value = num; if (GameManager.Multiplayer()) { __instance.photonView.RPC("GetValueRPC", (RpcTarget)1, new object[1] { __instance.value }); } } [HarmonyTranspiler] [HarmonyPatch("ShowingInfo")] private static IEnumerable<CodeInstruction> ShowingInfo_Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Beq, (object)null, (string)null) }).ThrowIfInvalid("|---- ShowingInfo(): Couldn't find matching code"); DebugLogger.LogInfo("|---- ShowingInfo(): ADDING NEW INSTRUCTIONS", debugOnly: true); object operand = val.Operand; val.Advance(1); val.Insert((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(ItemAttributes), "itemAssetName")), new CodeInstruction(OpCodes.Ldstr, (object)"Bundle"), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(string), "Contains", new Type[1] { typeof(string) }, (Type[])null)), new CodeInstruction(OpCodes.Brtrue, operand) }); return val.InstructionEnumeration(); } [HarmonyPostfix] [HarmonyPatch("ShowingInfo")] private static void ShowingInfo_Postfix(ItemAttributes __instance) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Invalid comparison between Unknown and I4 //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (!__instance.itemAssetName.Contains("Bundle")) { return; } string promptName = __instance.promptName; string text = ""; int num = SemiFunc.PlayerGetAll().Count + ItemBundles.Instance.config_debugFakePlayers.Value; ItemBundleShopPrompter component = ((Component)__instance).GetComponent<ItemBundleShopPrompter>(); if ((Object)(object)component == (Object)null) { return; } component.previousPrompt = promptName; itemType itemType = __instance.itemType; itemType val = itemType; if ((int)val <= 6) { if ((int)val != 3) { if ((int)val == 6) { goto IL_00d8; } } else { text = num.ToString(); } } else if ((int)val != 8) { if ((int)val == 11) { goto IL_00d8; } } else { int healAmount = ((Component)__instance).GetComponent<ItemHealthPackBundle>().healAmount; text = (BundleHelper.PlayerGetAllAlive().Count + ItemBundles.Instance.config_debugFakePlayers.Value) * healAmount + "hp"; } goto IL_010c; IL_00d8: text = Mathf.Max(num, BundleHelper.GetItemBundleMinItem(BundleHelper.GetItemStringFromBundle(__instance.item), __instance.itemType)).ToString(); goto IL_010c; IL_010c: bool grabbedLocal = __instance.physGrabObject.grabbedLocal; if (component.shopConfirm && grabbedLocal) { string text2 = InputManager.instance.InputDisplayGet(InputManager.instance.tagDictionary["[interact]"], (KeyType)0, (MovementDirection)0); promptName = component.confirmUnbundlePrompt + " <color=#FFFFFF>[<u><b>" + text2 + "</b></u>]</color>"; } else { promptName = promptName + "\n[Bundle" + (string.IsNullOrEmpty(text) ? text : (" of " + text)) + "]"; } __instance.promptName = promptName; } } [HarmonyPatch(typeof(ShopManager))] [HarmonyPriority(0)] internal static class BundlePatch_ShopManager { [HarmonyPrefix] [HarmonyPatch("GetAllItemsFromStatsManager")] private static void GetAllItemsFromStatsManager_Prefix(ShopManager __instance) { if (SemiFunc.IsNotMasterClient()) { return; } DebugLogger.LogInfo("|---- GetAllItemsFromStatsManager_Prefix(): Overriding Shop List ----|", debugOnly: true); ItemBundles.Instance.itemDictionaryShop.Clear(); foreach (KeyValuePair<string, Item> item in StatsManager.instance.itemDictionary) { List<string> list = ItemBundles.Instance.itemDictionaryShopBlacklist.Keys.ToList(); List<Item> list2 = ItemBundles.Instance.itemDictionaryShopBlacklist.Values.ToList(); if (list.Contains(item.Key) || list2.Contains(item.Value)) { DebugLogger.LogInfo($"|----- Blacklisting {item.Key} or {item.Value} from shop list", debugOnly: true); continue; } DebugLogger.LogInfo($"|---- Adding {item.Key} or {item.Value} to shop list", debugOnly: true); ItemBundles.Instance.itemDictionaryShop.Add(item.Key, item.Value); } } [HarmonyTranspiler] [HarmonyPatch("GetAllItemsFromStatsManager")] private static IEnumerable<CodeInstruction> GetAllItemsFromStatsManager_Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null) }).ThrowIfInvalid("|---- GetAllItemsFromStatsManager(): Couldn't find matching code"); DebugLogger.LogInfo("|---- GetAllItemsFromStatsManager(): ADDING NEW INSTRUCTIONS", debugOnly: true); val.Opcode = OpCodes.Call; val.Operand = AccessTools.PropertyGetter(typeof(ItemBundles), "Instance"); val.Advance(1); val.Operand = AccessTools.Field(typeof(ItemBundles), "itemDictionaryShop"); return val.InstructionEnumeration(); } [HarmonyPostfix] [HarmonyPatch("GetAllItemsFromStatsManager")] private static void GetAllItemsFromStatsManager_Postfix(ShopManager __instance) { foreach (KeyValuePair<itemType, ItemBundles.BundleShopInfo> itemTypeBundleInfo in ItemBundles.Instance.itemTypeBundleInfos) { itemTypeBundleInfo.Value.chanceInShop = ((itemTypeBundleInfo.Value.config_chanceInShop.Value == -1) ? ItemBundles.Instance.config_chanceBundlesInShop.Value : itemTypeBundleInfo.Value.config_chanceInShop.Value); itemTypeBundleInfo.Value.maxInShop = ((itemTypeBundleInfo.Value.config_maxInShop.Value == -1) ? ItemBundles.Instance.config_maxBundlesInShop.Value : itemTypeBundleInfo.Value.config_maxInShop.Value); } foreach (KeyValuePair<string, ItemBundles.BundleShopInfo> itemBundleInfo in ItemBundles.Instance.itemBundleInfos) { itemBundleInfo.Value.chanceInShop = itemBundleInfo.Value.config_chanceInShop.Value; itemBundleInfo.Value.maxInShop = itemBundleInfo.Value.config_maxInShop.Value; } if (SemiFunc.IsMultiplayer() || !ItemBundles.Instance.config_disableBundlesSP.Value) { AttemptBundlesFromList(ref __instance.potentialItems); AttemptBundlesFromList(ref __instance.potentialItemConsumables); AttemptBundlesFromList(ref __instance.potentialItemUpgrades); AttemptBundlesFromList(ref __instance.potentialItemHealthPacks); DebugLogger.LogInfo("|---- GetAllItemsFromStatsManager_Postfix(): Bundling Lists ----|", debugOnly: true); } } private static void AttemptBundlesFromList(ref List<Item> itemList) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) List<Item> list = new List<Item>(itemList); for (int num = list.Count - 1; num >= 0; num--) { Item val = list[num]; if (ItemBundles.Instance.itemBundleInfos.ContainsKey(val.prefab.prefabName)) { itemType key = BundleHelper.ValidateItemType(val); ItemBundles.BundleShopInfo bundleShopInfo = ItemBundles.Instance.itemTypeBundleInfos[key]; ItemBundles.BundleShopInfo bundleShopInfo2 = ItemBundles.Instance.itemBundleInfos[val.prefab.prefabName]; if (!Object.op_Implicit((Object)(object)bundleShopInfo2.bundleItem.prefab.Prefab)) { DebugLogger.LogError($"|---- {bundleShopInfo2.bundleItem} prefab was null! Skipping entry"); } else { float num2 = BundleHelper.GetItemBundleChance(val); num2 /= 100f; if (BundleHelper.GetItemBundleMax(val) == 0) { DebugLogger.LogWarning("|---- Already have max bundles for " + val.prefab.prefabName + "!", debugOnly: true); } else { float num3 = Random.Range(0f, 1f); if (num3 <= num2) { DebugLogger.LogWarning($"|---- Passed with {num3} {num3 <= num2}, Replacing item {list[num]} with {bundleShopInfo2.bundleItem}!", debugOnly: true); list[num] = bundleShopInfo2.bundleItem; if (bundleShopInfo.maxInShop > 0) { bundleShopInfo.maxInShop--; } if (bundleShopInfo2.maxInShop > 0) { bundleShopInfo2.maxInShop--; } } else { DebugLogger.LogInfo($"|---- Failed with {num3} {num3 <= num2}, keeping item {list[num]}!", debugOnly: true); } } } } } ListExtension.Shuffle<Item>((IList<Item>)list); itemList = list; } } [HarmonyPatch(typeof(PhysGrabObject))] internal static class BundlePatch_PhysGrabObject { [HarmonyPrefix] [HarmonyPatch("OnEnable")] private static bool OnEnable_Prefix(PhysGrabObject __instance) { return !BundleHelper.SceneIsPrefabStage(); } } [HarmonyPatch(typeof(RoomVolumeCheck))] internal static class BundlePatch_RoomVolumeCheck { [HarmonyPrefix] [HarmonyPatch("CheckStart")] private static bool CheckStart_Prefix(RoomVolumeCheck __instance) { return !BundleHelper.SceneIsPrefabStage(); } } internal static class DebugLogger { public static ManualLogSource ManualLogSource { get; private set; } public static void Init(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void Log(LogLevel level, object data, bool debugOnly = false) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!debugOnly || ItemBundles.Instance.config_debugLogging.Value) { ManualLogSource.Log(level, data); } } public static void LogFatal(object data, bool debugOnly = false) { Log((LogLevel)1, data, debugOnly); } public static void LogError(object data, bool debugOnly = false) { Log((LogLevel)2, data, debugOnly); } public static void LogWarning(object data, bool debugOnly = false) { Log((LogLevel)4, data, debugOnly); } public static void LogMessage(object data, bool debugOnly = false) { Log((LogLevel)8, data, debugOnly); } public static void LogInfo(object data, bool debugOnly = false) { Log((LogLevel)16, data, debugOnly); } public static void LogDebug(object data, bool debugOnly = false) { Log((LogLevel)32, data, debugOnly); } } [BepInPlugin("SeroRonin.ItemBundles", "ItemBundles", "1.5.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ItemBundles : BaseUnityPlugin { public class BundleShopInfo { public Item bundleItem; public int chanceInShop; public int maxInShop; public ConfigEntry<int> config_chanceInShop; public ConfigEntry<int> config_maxInShop; public ConfigEntry<int> config_minPerBundle; public ConfigEntry<float> config_priceMultiplier; } public AssetBundle assetBundle; public Dictionary<string, Item> itemDictionaryShop = new Dictionary<string, Item>(); public Dictionary<string, Item> itemDictionaryShopBlacklist = new Dictionary<string, Item>(); public Dictionary<itemType, BundleShopInfo> itemTypeBundleInfos = new Dictionary<itemType, BundleShopInfo>(); public Dictionary<string, BundleShopInfo> itemBundleInfos = new Dictionary<string, BundleShopInfo>(); public Dictionary<Item, GameObject> generatedBundles = new Dictionary<Item, GameObject>(); public Dictionary<Item, string> upgradeParentModDict = new Dictionary<Item, string>(); public List<Mesh> upgradeBundleMeshes = new List<Mesh>(); public static ItemBundles Instance { get; private set; } internal Harmony? Harmony { get; set; } public ConfigEntry<bool> config_disableBundlesSP { get; private set; } public ConfigEntry<int> config_chanceBundlesInShop { get; private set; } public ConfigEntry<int> config_maxBundlesInShop { get; private set; } public ConfigEntry<int> config_minPerBundle { get; private set; } public ConfigEntry<float> config_priceMultiplier { get; private set; } public ConfigEntry<int> config_debugFakePlayers { get; private set; } public ConfigEntry<bool> config_debugLogging { get; private set; } public bool mainMenuReached { get; set; } public GameObject templateUpgradeBundlePrefab { get; set; } private void Awake() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; DebugLogger.Init(((BaseUnityPlugin)this).Logger); string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = Path.Combine(directoryName, "itembundles"); assetBundle = AssetBundle.LoadFromFile(text); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; CreateConfigs(); Patch(); GameObject val = new GameObject("Bundle Manager"); val.AddComponent<BundleManager>(); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); BundleLoader.OnAllBundlesLoaded += RegisterItemBundles; DebugLogger.LogInfo($"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } } public void RegisterItemBundles() { if (!Object.op_Implicit((Object)(object)assetBundle)) { DebugLogger.LogError("Assetbundle \"itembundles\" not found! Please make sure that it exists in the same folder as the mod DLL"); DebugLogger.LogError("ItemBundles has run into a fatal error! The mod will not work correctly and may cause issues elsewhere!"); return; } RegisterBundleItemRepoLib("Item Health Pack Small Bundle"); RegisterBundleItemRepoLib("Item Health Pack Medium Bundle"); RegisterBundleItemRepoLib("Item Health Pack Large Bundle"); RegisterBundleItemRepoLib("Item Grenade Explosive Bundle"); RegisterBundleItemRepoLib("Item Grenade Shockwave Bundle"); RegisterBundleItemRepoLib("Item Grenade Stun Bundle"); RegisterBundleItemRepoLib("Item Mine Explosive Bundle"); RegisterBundleItemRepoLib("Item Mine Shockwave Bundle"); RegisterBundleItemRepoLib("Item Mine Stun Bundle"); Item val = assetBundle.LoadAsset<Item>("Item Upgrade Bundle Template"); templateUpgradeBundlePrefab = assetBundle.LoadAsset<GameObject>("Item Upgrade Bundle Template"); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)templateUpgradeBundlePrefab)) { DebugLogger.LogError("Template bundle item or prefab was null! Unable to generate upgrade bundles"); DebugLogger.LogError("ItemBundles has run into a fatal error! The mod will not work correctly and may cause issues elsewhere!"); return; } List<Item> list = (from item in Resources.LoadAll<Item>("items/items") where (int)item.itemType == 3 select item).ToList(); foreach (Item item3 in list) { upgradeParentModDict.Add(item3, "Vanilla"); } foreach (PlayerUpgrade playerUpgrade in Upgrades.PlayerUpgrades) { Item item2 = playerUpgrade.Item; if (!((Object)(object)item2 == (Object)null) && !((Object)(object)((item2 != null) ? item2.prefab.Prefab : null) == (Object)null)) { upgradeParentModDict.Add(item2, "REPOLib"); } } foreach (KeyValuePair<string, Item> item4 in StatsManager.instance.itemDictionary.Where((KeyValuePair<string, Item> itemKV) => (int)itemKV.Value.itemType == 3).ToList()) { Item value = item4.Value; if (!upgradeParentModDict.ContainsKey(value)) { upgradeParentModDict.Add(value, "Modded"); } } foreach (KeyValuePair<Item, string> item5 in upgradeParentModDict) { DebugLogger.LogInfo("|- " + item5.Value + " Upgrade found and registered for bundles: " + item5.Key.itemName, debugOnly: true); } upgradeBundleMeshes = (from mesh in assetBundle.LoadAllAssets<Mesh>() where ((Object)mesh).name.ToLower().Contains("mesh_bundle_upgrade") select mesh).ToList(); foreach (Item key in upgradeParentModDict.Keys) { GenerateUpgradeBundle(key); } } public void GenerateUpgradeBundle(Item baseItem) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown DebugLogger.LogInfo("|-- Generating Upgrade Bundle: " + ((Object)baseItem).name, debugOnly: true); Item val = ScriptableObject.CreateInstance<Item>(); GameObject itemPrefab = Object.Instantiate<GameObject>(templateUpgradeBundlePrefab, new Vector3(0f, 100f, 0f), Quaternion.identity); ((Object)itemPrefab).name = ((Object)baseItem).name + " Bundle"; ((Object)val).name = ((Object)baseItem).name + " Bundle"; val.itemName = baseItem.itemName + "s"; val.itemType = BundleHelper.ValidateItemType(baseItem.itemType); val.emojiIcon = baseItem.emojiIcon; val.itemVolume = baseItem.itemVolume; val.itemSecretShopType = baseItem.itemSecretShopType; val.colorPreset = baseItem.colorPreset; val.value = baseItem.value; val.maxAmount = baseItem.maxAmount; val.maxAmountInShop = baseItem.maxAmountInShop; val.maxPurchase = baseItem.maxPurchase; val.maxPurchaseAmount = baseItem.maxPurchaseAmount; val.spawnRotationOffset = baseItem.spawnRotationOffset; val.physicalItem = baseItem.physicalItem; string text = baseItem.prefab.prefabName + " Bundle"; PrefabRef prefab = new PrefabRef { prefabName = text, resourcePath = "Items/" + text }; val.prefab = prefab; ItemAttributes component = itemPrefab.GetComponent<ItemAttributes>(); component.item = val; ItemUpgradeBundleGenerated component2 = itemPrefab.GetComponent<ItemUpgradeBundleGenerated>(); component2.originalItem = baseItem; if (((Object)baseItem).name.ToLower().Contains("gold") && GoldItemsCompat.enabled) { GoldItemsCompat.TryAddGoldMarker(baseItem.prefab.Prefab, ref itemPrefab); } int index = Random.RandomRangeInt(0, upgradeBundleMeshes.Count); component2.SetBoxMesh(upgradeBundleMeshes[index]); Items.RegisterItem(component); generatedBundles[val] = itemPrefab; } public void InitializeItemBundles() { if (!Object.op_Implicit((Object)(object)assetBundle)) { DebugLogger.LogError("Assetbundle \"itembundles\" not found! Please make sure that it exists in the same folder as the mod DLL"); DebugLogger.LogError("ItemBundles has run into a fatal error! The mod will not work correctly and may cause issues elsewhere!"); return; } InitializeBundle("Item Health Pack Small Bundle", "Health Packs"); InitializeBundle("Item Health Pack Medium Bundle", "Health Packs"); InitializeBundle("Item Health Pack Large Bundle", "Health Packs"); InitializeBundle("Item Grenade Explosive Bundle", "Weapons"); InitializeBundle("Item Grenade Shockwave Bundle", "Weapons"); InitializeBundle("Item Grenade Stun Bundle", "Weapons"); InitializeBundle("Item Mine Explosive Bundle", "Weapons"); InitializeBundle("Item Mine Shockwave Bundle", "Weapons"); InitializeBundle("Item Mine Stun Bundle", "Weapons"); foreach (Item key in generatedBundles.Keys) { ItemUpgradeBundleGenerated component = key.prefab.Prefab.GetComponent<ItemUpgradeBundleGenerated>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.originalItem == (Object)null)) { if (!upgradeParentModDict.TryGetValue(component.originalItem, out string value)) { DebugLogger.LogError("InitializeItemsBundles(): Base item was not found in upgradeParentModDict! Something is broken, skipping bundle initialization"); } else { InitializeBundle(key, "Upgrades (" + value + ")"); } } } } public void CreateConfigs() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Expected O, but got Unknown //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Expected O, but got Unknown //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Expected O, but got Unknown //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Expected O, but got Unknown //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Expected O, but got Unknown //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Expected O, but got Unknown //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Expected O, but got Unknown //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Expected O, but got Unknown //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Expected O, but got Unknown config_disableBundlesSP = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Disable Bundles in Singleplayer", true, new ConfigDescription("Whether bundles are disabled when doing a singleplayer run", (AcceptableValueBase)null, Array.Empty<object>())); config_chanceBundlesInShop = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Bundle Chance", 20, new ConfigDescription("Percent chance that an item will be replaced with a bundle variant", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); config_maxBundlesInShop = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Maximum Bundles In Shop", -1, new ConfigDescription("Maximum number of bundles that can appear of ANY one type. Setting to -1 makes shop ignore this entry", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())); config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Mininum consumables per bundle", 0, new ConfigDescription("Minimum amount of items in valid bundles. Price still scales. Default: 0", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>())); config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Bundle Price Multiplier", 66.66f, new ConfigDescription("Multiplier of total item costs that bundles have", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>())); string text = "Has priority over General entry. Ignored if set below 0"; itemTypeBundleInfos[(itemType)11] = new BundleShopInfo { config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Mines: Chance", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())), config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Mines: Chance", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())), config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Mines: Mininum per bundle", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())), config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles by Type", "Mines: Price Multiplier", -1f, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>())) }; itemTypeBundleInfos[(itemType)6] = new BundleShopInfo { config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Grenades: Chance", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())), config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Grenades: Max", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())), config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Grenades: Mininum per bundle", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())), config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles by Type", "Grenades: Price Multiplier", -1f, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>())) }; itemTypeBundleInfos[(itemType)8] = new BundleShopInfo { config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Health Packs: Chance", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())), config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Health Packs: Max", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())), config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles by Type", "Health Packs: Price Multiplier", -1f, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>())) }; itemTypeBundleInfos[(itemType)3] = new BundleShopInfo { config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Upgrades: Chance", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())), config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Upgrades: Max", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())), config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>("Bundles by Type", "Upgrades: Mininum per bundle", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())), config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles by Type", "Upgrades: Price Multiplier", -1f, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>())) }; config_debugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Developer", "Debug Logging", false, new ConfigDescription("Enables debug logging", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" })); config_debugFakePlayers = ((BaseUnityPlugin)this).Config.Bind<int>("Developer", "Number of Fake Players", 0, new ConfigDescription("Adds fake players to bundle player calculations", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), new object[1] { "HideFromREPOConfig" })); } internal void RegisterBundleItemRepoLib(string itemString) { GameObject val = assetBundle.LoadAsset<GameObject>(itemString); ItemAttributes component = val.GetComponent<ItemAttributes>(); if (!Object.op_Implicit((Object)(object)component)) { DebugLogger.LogError("RegisterBundleItemRepoLib() Failed: ItemAttributes for " + itemString + " was null!"); } else { Items.RegisterItem(component); } } internal void InitializeBundle(string bundleItemString, string configSection = "") { Item val = assetBundle.LoadAsset<Item>(bundleItemString); if (!Object.op_Implicit((Object)(object)val)) { DebugLogger.LogError("InitializeBundle() Failed: Bundle Item \"" + bundleItemString + "\" not found!"); } else { InitializeBundle(val, configSection); } } internal void InitializeBundle(Item item, string configSection = "") { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Invalid comparison between Unknown and I4 //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Invalid comparison between Unknown and I4 //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Invalid comparison between Unknown and I4 //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Invalid comparison between Unknown and I4 //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)item)) { DebugLogger.LogError("InitializeBundle() Failed: Bundle Item was null!"); return; } string text = " Bundle"; if (!((Object)item).name.Contains(text)) { DebugLogger.LogError("InitializeBundle() Failed: Item " + ((Object)item).name + " is not a bundle! Add \" Bundle\" to item name (WITH THE SPACE)"); return; } string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(item); Item val = StatsManager.instance.itemDictionary[itemStringFromBundle]; if (!Object.op_Implicit((Object)(object)val)) { DebugLogger.LogError("InitializeBundle() Failed: Didn't find " + itemStringFromBundle + "! Make sure itemAssetName of bundle Item and bundle Prefab is " + itemStringFromBundle + text); return; } if (itemBundleInfos.ContainsKey(itemStringFromBundle)) { DebugLogger.LogWarning($"InitializeBundle() Warning: bundleStringPairs {itemStringFromBundle} already has an entry {itemBundleInfos[itemStringFromBundle]}, we are overriding something!"); } itemDictionaryShopBlacklist.Add(item.prefab.resourcePath, item); if ((int)item.itemType == 3) { item.value = ScriptableObject.CreateInstance<Value>(); item.value.valueMin = val.value.valueMin; item.value.valueMax = val.value.valueMax; } string text2 = "Has Priority over Item Type entry. Ignored if set below 0"; BundleShopInfo bundleShopInfo = new BundleShopInfo { bundleItem = item, config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>(configSection ?? "", val.itemName + ": Chance", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())), config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>(configSection ?? "", val.itemName + ": Max", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())), config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>(configSection ?? "", val.itemName + ": Price Multiplier", -1f, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>())) }; if ((int)item.itemType == 6 || (int)item.itemType == 11 || (int)item.itemType == 3) { bundleShopInfo.config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>(configSection ?? "", val.itemName + ": Mininum per bundle", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())); } itemBundleInfos[itemStringFromBundle] = bundleShopInfo; DebugLogger.LogInfo("InitializeBundle(): Created BundleShopInfo [" + itemStringFromBundle + " | " + item.prefab.prefabName + "]", debugOnly: true); } 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(); } } private void Update() { if (!mainMenuReached && Object.op_Implicit((Object)(object)RunManager.instance)) { mainMenuReached = SemiFunc.IsMainMenu(); } } } public static class GoldItemsCompat { private static bool? _enabled; public static bool enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("WorthyOtter.GoldItems"); } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void TryAddGoldMarker(GameObject baseItem, ref GameObject itemPrefab) { if (Object.op_Implicit((Object)(object)baseItem.GetComponent<GoldItemMarker>())) { DebugLogger.LogInfo("|---- GoldItem shop item found!"); GoldItemMarker val = default(GoldItemMarker); if (!itemPrefab.TryGetComponent<GoldItemMarker>(ref val)) { itemPrefab.AddComponent<GoldItemMarker>(); } } } } public static class MoreUpgradesCompat { private static bool? _enabled; public static bool enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("bulletbot.moreupgrades"); } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static float GetOriginalValueMultiplier(string bundleAssetName) { string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(bundleAssetName); Item val = StatsManager.instance.itemDictionary[itemStringFromBundle]; return MoreUpgradesAPI.ItemValueMultiplier(val); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static float GetUpgradeValueIncrease(string bundleAssetName) { string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(bundleAssetName); Item val = StatsManager.instance.itemDictionary[itemStringFromBundle]; return MoreUpgradesAPI.UpgradeValueIncrease(val); } } public static class VanillaUpgradesCompat { private static bool? _enabled; public static bool enabled { get { if (!_enabled.HasValue) { _enabled = false; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static float GetUpgradeValueIncrease(float fallbackMult, string bundleAssetName) { string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(bundleAssetName); return Plugin.UpgradeValueIncrease(fallbackMult, itemStringFromBundle); } } public class ItemBundleShopPrompter : MonoBehaviour { public string confirmUnbundlePrompt = "Confirm Unbundle?"; public string previousPrompt = ""; public bool shopConfirm; public void Start() { } } public class ItemConsumableBundle : MonoBehaviour { private ItemToggle itemToggle; private PhotonView photonView; private PhysGrabObject physGrabObject; private PhysGrabObjectImpactDetector impactDetector; public ItemBundleShopPrompter shopPrompter; private Vector3 startPosition; private Quaternion startRotation; public GameObject itemPrefab; private bool used; private void Start() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) itemToggle = ((Component)this).GetComponent<ItemToggle>(); photonView = ((Component)this).GetComponent<PhotonView>(); physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); startPosition = ((Component)this).transform.position; startRotation = ((Component)this).transform.rotation; if (!((Component)this).TryGetComponent<ItemBundleShopPrompter>(ref shopPrompter)) { shopPrompter = ((Component)this).gameObject.AddComponent<ItemBundleShopPrompter>(); } } private void Update() { if (physGrabObject.playerGrabbing.Count == 0 && shopPrompter.shopConfirm) { shopPrompter.shopConfirm = false; } if (!itemToggle.toggleState || used || used || !itemToggle.toggleState) { return; } if (SemiFunc.RunIsShop() && !shopPrompter.shopConfirm) { shopPrompter.shopConfirm = true; itemToggle.ToggleItem(false, -1); } else if (SemiFunc.IsMasterClientOrSingleplayer()) { SpawnItems(); if (!SemiFunc.RunIsShop()) { StatsManager.instance.ItemRemove(((Component)this).GetComponent<ItemAttributes>().instanceName); } impactDetector.destroyDisable = false; impactDetector.DestroyObject(false); used = true; } } public void SpawnItems() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) int num = SemiFunc.PlayerGetAll().Count + ItemBundles.Instance.config_debugFakePlayers.Value; Item item = ((Component)this).GetComponent<ItemAttributes>().item; if ((int)item.itemType == 6 || (int)item.itemType == 11) { num = Mathf.Max(num, BundleHelper.GetItemBundleMinItem(BundleHelper.GetItemStringFromBundle(item), item.itemType)); } itemType itemType = item.itemType; itemType val = itemType; float num2 = (((int)val == 6) ? 0.25f : (((int)val != 11) ? 0f : 0.5f)); for (int i = 0; i < num; i++) { GameObject val2 = null; Vector3 val3 = ((i == 0) ? Vector3.zero : (Random.insideUnitSphere * num2)); if (!SemiFunc.IsMultiplayer()) { val2 = Object.Instantiate<GameObject>(itemPrefab, ((Component)this).transform.position + val3, Quaternion.identity); } else if (SemiFunc.IsMasterClient()) { val2 = PhotonNetwork.Instantiate("Items/" + ((Object)itemPrefab).name, ((Component)this).transform.position + val3, Quaternion.identity, (byte)0, (object[])null); } if ((Object)(object)val2 == (Object)null) { break; } val2.AddComponent<ItemLateImpulse>(); ItemLateStartSetter itemLateStartSetter = val2.AddComponent<ItemLateStartSetter>(); itemLateStartSetter.newStartPosition = startPosition; itemLateStartSetter.newStartRotation = startRotation; itemLateStartSetter.enable = true; if ((SemiFunc.IsMasterClient() || !SemiFunc.IsMultiplayer()) && !SemiFunc.RunIsShop()) { StatsManager.instance.ItemPurchase(val2.GetComponent<ItemAttributes>().item.prefab.prefabName); } } } } public class ItemHealthPackBundle : MonoBehaviour { public int healAmount; private int healingBank; private ItemToggle itemToggle; private ItemEquippable itemEquippable; private ItemAttributes itemAttributes; private PhotonView photonView; private PhysGrabObject physGrabObject; public ItemBundleShopPrompter shopPrompter; private List<PlayerAvatar> playersToHeal; [Space] public ParticleSystem[] particles; public ParticleSystem[] rejectParticles; [Space] public PropLight propLight; public AnimationCurve lightIntensityCurve; private float lightIntensityLerp; public MeshRenderer mesh; private Material material; private Color materialEmissionOriginal; private int materialPropertyEmission = Shader.PropertyToID("_EmissionColor"); [Space] public Sound soundUse; public Sound soundReject; private bool used; private void Start() { //IL_008c: 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) itemToggle = ((Component)this).GetComponent<ItemToggle>(); itemEquippable = ((Component)this).GetComponent<ItemEquippable>(); itemAttributes = ((Component)this).GetComponent<ItemAttributes>(); photonView = ((Component)this).GetComponent<PhotonView>(); physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); if (!((Component)this).TryGetComponent<ItemBundleShopPrompter>(ref shopPrompter)) { shopPrompter = ((Component)this).gameObject.AddComponent<ItemBundleShopPrompter>(); } playersToHeal = new List<PlayerAvatar>(); material = ((Renderer)mesh).material; materialEmissionOriginal = material.GetColor(materialPropertyEmission); } private void Update() { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.RunIsShop()) { return; } LightLogic(); if (!SemiFunc.IsMasterClientOrSingleplayer() || !itemToggle.toggleState || used) { return; } playersToHeal.Clear(); foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { if (item.playerHealth.health < item.playerHealth.maxHealth && item.playerHealth.health > 0) { healingBank += healAmount; playersToHeal.Add(item); } } healingBank += healAmount * ItemBundles.Instance.config_debugFakePlayers.Value; if (playersToHeal.Count <= 0) { if (SemiFunc.IsMultiplayer()) { photonView.RPC("RejectRPC", (RpcTarget)0, Array.Empty<object>()); } else { RejectRPC(); } itemToggle.ToggleItem(false, -1); physGrabObject.rb.AddForce(Vector3.up * 2f, (ForceMode)1); physGrabObject.rb.AddTorque(-((Component)physGrabObject).transform.right * 0.05f, (ForceMode)1); return; } Dictionary<PlayerAvatar, int> dictionary = new Dictionary<PlayerAvatar, int>(); foreach (PlayerAvatar item2 in playersToHeal) { dictionary[item2] = 0; } while (healingBank > 0 && playersToHeal.Count > 0) { List<PlayerAvatar> list = new List<PlayerAvatar>(playersToHeal); foreach (PlayerAvatar item3 in playersToHeal) { int num = item3.playerHealth.maxHealth - (item3.playerHealth.health + dictionary[item3]); int num2 = Mathf.Min(healingBank, healAmount); int num3 = Mathf.Min(num, num2); if (num <= num2) { list.Remove(item3); } healingBank = Mathf.Max(healingBank - num3, 0); dictionary[item3] += num3; } playersToHeal = list; } foreach (KeyValuePair<PlayerAvatar, int> item4 in dictionary) { DebugLogger.LogInfo($"{item4.Key.playerName} missing {item4.Key.playerHealth.maxHealth - item4.Key.playerHealth.health} health, healing for {healAmount} base + {item4.Value - healAmount} excess!", debugOnly: true); item4.Key.playerHealth.HealOther(item4.Value, true); } _ = StatsManager.instance.itemsPurchased[itemAttributes.item.prefab.prefabName]; StatsManager.instance.ItemRemove(itemAttributes.instanceName); physGrabObject.impactDetector.destroyDisable = false; physGrabObject.impactDetector.indestructibleBreakEffects = true; if (SemiFunc.IsMultiplayer()) { photonView.RPC("UsedRPC", (RpcTarget)0, Array.Empty<object>()); } else { UsedRPC(); } } private void LightLogic() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (used && lightIntensityLerp < 1f) { lightIntensityLerp += 1f * Time.deltaTime; propLight.lightComponent.intensity = lightIntensityCurve.Evaluate(lightIntensityLerp); propLight.originalIntensity = propLight.lightComponent.intensity; material.SetColor(materialPropertyEmission, Color.Lerp(Color.black, materialEmissionOriginal, lightIntensityCurve.Evaluate(lightIntensityLerp))); } } [PunRPC] private void UsedRPC() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f); itemToggle.ToggleDisable(true); itemAttributes.DisableUI(true); Object.Destroy((Object)(object)itemEquippable); ParticleSystem[] array = particles; for (int i = 0; i < array.Length; i++) { array[i].Play(); } soundUse.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); used = true; } [PunRPC] private void RejectRPC() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID); if (val.isLocal) { val.physGrabber.ReleaseObjectRPC(false, 1f, photonView.ViewID); } ParticleSystem[] array = rejectParticles; for (int i = 0; i < array.Length; i++) { array[i].Play(); } GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)this).transform.position, 0.2f); soundReject.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } public void OnDestroy() { //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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) ParticleSystem[] array = particles; ParticleSystem[] array2 = array; foreach (ParticleSystem val in array2) { if (Object.op_Implicit((Object)(object)val) && val.isPlaying) { ((Component)val).transform.SetParent((Transform)null); MainModule main = val.main; ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)2; } } array = rejectParticles; ParticleSystem[] array3 = array; foreach (ParticleSystem val2 in array3) { if (Object.op_Implicit((Object)(object)val2) && val2.isPlaying) { ((Component)val2).transform.SetParent((Transform)null); MainModule main2 = val2.main; ((MainModule)(ref main2)).stopAction = (ParticleSystemStopAction)2; } } } } public class ItemLateImpulse : MonoBehaviour { private PhysGrabObject physGrabObject; private Rigidbody rb; private Vector3 direction = Vector3.zero; private float forceMin = 1f; private float forceMax = 5f; private float forceMult = 1f; public void Start() { physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); rb = ((Component)this).GetComponent<Rigidbody>(); ((MonoBehaviour)this).StartCoroutine(LateSpawn()); } private IEnumerator LateSpawn() { while (!physGrabObject.spawned || rb.isKinematic) { yield return null; } Vector3 vector = ((direction == Vector3.zero) ? Random.insideUnitSphere : direction); rb.AddForce(vector * forceMult * Random.Range(forceMin, forceMax), (ForceMode)1); rb.AddTorque(Random.insideUnitSphere * forceMult * Random.Range(forceMin, forceMax), (ForceMode)1); } } public class ItemLateStartSetter : MonoBehaviour { private PhysGrabObject physGrabObject; private Rigidbody rb; public Vector3 newStartPosition = Vector3.zero; public Quaternion newStartRotation = Quaternion.identity; public bool enable; public void Start() { physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); rb = ((Component)this).GetComponent<Rigidbody>(); ((MonoBehaviour)this).StartCoroutine(LateSpawn()); } private IEnumerator LateSpawn() { while (!physGrabObject.spawned || rb.isKinematic || !enable) { yield return null; } ItemGrenade grenadeComponent = ((Component)this).GetComponent<ItemGrenade>(); if ((Object)(object)grenadeComponent != (Object)null) { grenadeComponent.grenadeStartPosition = newStartPosition; grenadeComponent.grenadeStartRotation = newStartRotation; } ItemMine mineComponent = ((Component)this).GetComponent<ItemMine>(); if ((Object)(object)mineComponent != (Object)null) { mineComponent.startPosition = newStartPosition; mineComponent.startRotation = newStartRotation; } } } public class ItemUpgradeBundleGenerated : MonoBehaviour { private ItemToggle itemToggle; private bool used; private Rigidbody rb; private PhotonTransformView photonTransformView; private PhysGrabObject physGrabObject; private PhysGrabObjectImpactDetector impactDetector; public ItemBundleShopPrompter shopPrompter; public Item? originalItem; public bool isPrefab; private void Awake() { itemToggle = ((Component)this).GetComponent<ItemToggle>(); rb = ((Component)this).GetComponent<Rigidbody>(); photonTransformView = ((Component)this).GetComponent<PhotonTransformView>(); physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); if (!((Component)this).TryGetComponent<ItemBundleShopPrompter>(ref shopPrompter)) { shopPrompter = ((Component)this).gameObject.AddComponent<ItemBundleShopPrompter>(); } if (BundleHelper.SceneIsPrefabStage()) { ((Object)this).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); impactDetector.destroyDisable = true; ((Component)this).transform.parent = ((Component)BundleManager.instance).transform; rb.isKinematic = true; isPrefab = true; } else { impactDetector.destroyDisable = false; rb.isKinematic = false; } } private void Start() { if (BundleHelper.SceneIsPrefabStage()) { ((MonoBehaviour)this).StartCoroutine(LateStart(0.1f)); } else { if (SemiFunc.RunIsLobby() || SemiFunc.RunIsLevel()) { ((MonoBehaviour)this).StartCoroutine(LateTruckStart(0.01f)); } rb.isKinematic = false; isPrefab = false; ((Behaviour)photonTransformView).enabled = true; } UpdateMaterial(); UpdateLightColor(); } private IEnumerator LateStart(float waitTime) { yield return (object)new WaitForSeconds(waitTime); ((Component)this).transform.parent = ((Component)BundleManager.instance).transform; rb.isKinematic = true; rb.rotation = Quaternion.identity; } private IEnumerator LateTruckStart(float waitTime) { yield return (object)new WaitForSeconds(waitTime); Rigidbody obj = rb; obj.position += new Vector3(-0.25f, 0f, 0f); } private void Update() { if (SemiFunc.RunIsShop()) { ((Behaviour)itemToggle).enabled = true; } if (physGrabObject.playerGrabbing.Count == 0 && shopPrompter.shopConfirm) { shopPrompter.shopConfirm = false; } if (!itemToggle.toggleState || used || (Object)(object)originalItem == (Object)null || used || !itemToggle.toggleState) { return; } if (SemiFunc.RunIsShop() && !shopPrompter.shopConfirm) { shopPrompter.shopConfirm = true; itemToggle.ToggleItem(false, -1); } else if (SemiFunc.IsMasterClientOrSingleplayer()) { SpawnItems(); if (!SemiFunc.RunIsShop()) { StatsManager.instance.ItemRemove(((Component)this).GetComponent<ItemAttributes>().instanceName); } impactDetector.destroyDisable = false; impactDetector.DestroyObject(false); used = true; } } public void SpawnItems() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //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_0071: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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) int count = SemiFunc.PlayerGetAll().Count; count = Mathf.Max(count, BundleHelper.GetItemBundleMinItem(originalItem)); for (int i = 0; i < count + ItemBundles.Instance.config_debugFakePlayers.Value; i++) { float num = 0.075f; Vector3 val = -((Component)this).transform.forward * num * (float)(i - 1); GameObject val2 = null; if (SemiFunc.IsMasterClient()) { val2 = PhotonNetwork.Instantiate(originalItem.prefab.resourcePath, ((Component)this).transform.position + val, ((Component)this).gameObject.transform.rotation, (byte)0, (object[])null); } else if (!SemiFunc.IsMultiplayer()) { val2 = Object.Instantiate<GameObject>(originalItem.prefab.Prefab, ((Component)this).transform.position + val, ((Component)this).gameObject.transform.rotation); } if ((Object)(object)val2 == (Object)null) { break; } if ((SemiFunc.IsMasterClient() || !SemiFunc.IsMultiplayer()) && !SemiFunc.RunIsShop()) { StatsManager.instance.ItemPurchase(val2.GetComponent<ItemAttributes>().item.prefab.prefabName); StatsManager.instance.AddItemsUpgradesPurchased(val2.GetComponent<ItemAttributes>().item.prefab.prefabName); } } } public void SetBoxMesh(Mesh mesh) { if (Object.op_Implicit((Object)(object)mesh)) { Transform val = ((Component)this).gameObject.transform.Find("Mesh"); MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); component.mesh = mesh; } } public Material? GetOriginalBoxMat() { if ((Object)(object)originalItem == (Object)null) { return null; } Item val = originalItem; Material val2 = null; Transform val3 = val.prefab.Prefab.transform.Find("Mesh"); MeshRenderer component = ((Component)val3).GetComponent<MeshRenderer>(); if (Object.op_Implicit((Object)(object)component)) { val2 = ((Renderer)component).materials[0]; } if (!Object.op_Implicit((Object)(object)val2)) { DebugLogger.LogError("- GetBoxMat " + originalItem.prefab.prefabName + " failed, returning NULL", debugOnly: true); } else { DebugLogger.LogInfo($"- GetBoxMat returning {val2}", debugOnly: true); } return val2; } public Light? GetOriginalLight() { Item val = originalItem; if ((Object)(object)val == (Object)null) { return null; } Transform val2 = val.prefab.Prefab.transform.Find("Light - Small Lamp"); if (!Object.op_Implicit((Object)(object)val2)) { return null; } return ((Component)val2).GetComponent<Light>(); } public void UpdateMaterial() { Material originalBoxMat = GetOriginalBoxMat(); if (!((Object)(object)originalBoxMat == (Object)null)) { Transform val = ((Component)this).transform.Find("Mesh"); MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>(); if (((Object)((Renderer)component).materials[0]).name.Contains("upgrade")) { Material[] materials = (Material[])(object)new Material[2] { originalBoxMat, ((Renderer)component).materials[1] }; ((Renderer)component).materials = materials; } } } public void UpdateLightColor() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) Light component = ((Component)((Component)this).gameObject.transform.Find("Light - Small Lamp")).GetComponent<Light>(); Light originalLight = GetOriginalLight(); if ((Object)(object)component != (Object)null && (Object)(object)originalLight != (Object)null) { component.color = originalLight.color; } } public void OnDestroy() { } } }