using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreUpgrades;
using MoreUpgrades.Classes;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using VanillaUpgrades;
using VanillaUpgrades.Classes;
[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("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[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.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[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.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1")]
[assembly: AssemblyProduct("ItemBundles")]
[assembly: AssemblyTitle("ItemBundles")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.1.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_000c: Unknown result type (might be due to invalid IL or missing references)
int chanceInShop = ItemBundles.Instance.itemTypeBundleInfos[item.itemType].chanceInShop;
if (ItemBundles.Instance.itemBundleInfos[item.itemAssetName].chanceInShop >= 0)
{
chanceInShop = ItemBundles.Instance.itemBundleInfos[item.itemAssetName].chanceInShop;
}
return chanceInShop;
}
public static int GetItemBundleMax(Item item)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
int maxInShop = ItemBundles.Instance.itemTypeBundleInfos[item.itemType].maxInShop;
if (ItemBundles.Instance.itemBundleInfos[item.itemAssetName].maxInShop >= 0)
{
maxInShop = ItemBundles.Instance.itemBundleInfos[item.itemAssetName].maxInShop;
}
return maxInShop;
}
public static int GetItemBundleMinItem(Item item)
{
//IL_001c: 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)
int value = ItemBundles.Instance.config_minConsumablePerBundle.Value;
if (ItemBundles.Instance.itemTypeBundleInfos[item.itemType].config_minPerBundle.Value >= 0)
{
value = ItemBundles.Instance.itemTypeBundleInfos[item.itemType].config_minPerBundle.Value;
}
if (ItemBundles.Instance.itemBundleInfos[item.itemAssetName].config_minPerBundle.Value >= 0)
{
value = ItemBundles.Instance.itemBundleInfos[item.itemAssetName].config_minPerBundle.Value;
}
return value;
}
public static int GetItemBundleMinItem(string itemString, itemType itemType)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
int value = ItemBundles.Instance.config_minConsumablePerBundle.Value;
if (ItemBundles.Instance.itemTypeBundleInfos[itemType].config_minPerBundle.Value >= 0)
{
value = ItemBundles.Instance.itemTypeBundleInfos[itemType].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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
float value = ItemBundles.Instance.config_priceMultiplier.Value;
if (ItemBundles.Instance.itemTypeBundleInfos[itemType].config_priceMultiplier.Value >= 0f)
{
value = ItemBundles.Instance.itemTypeBundleInfos[itemType].config_priceMultiplier.Value;
}
if (ItemBundles.Instance.itemBundleInfos[itemString].config_priceMultiplier.Value >= 0f)
{
value = ItemBundles.Instance.itemBundleInfos[itemString].config_priceMultiplier.Value;
}
return value;
}
public static string GetItemStringFromBundle(Item bundleItem)
{
string itemAssetName = bundleItem.itemAssetName;
return GetItemStringFromBundle(itemAssetName);
}
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 void CallBundleUpgrade(string upgradeName)
{
List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
foreach (PlayerAvatar item in list)
{
switch (upgradeName)
{
case "Item Upgrade Map Player Count":
PunManager.instance.UpgradeMapPlayerCount(SemiFunc.PlayerGetSteamID(item));
break;
case "Item Upgrade Player Energy":
PunManager.instance.UpgradePlayerEnergy(SemiFunc.PlayerGetSteamID(item));
break;
case "Item Upgrade Player Extra Jump":
PunManager.instance.UpgradePlayerExtraJump(SemiFunc.PlayerGetSteamID(item));
break;
case "Item Upgrade Player Grab Range":
PunManager.instance.UpgradePlayerGrabRange(SemiFunc.PlayerGetSteamID(item));
break;
case "Item Upgrade Player Grab Strength":
PunManager.instance.UpgradePlayerGrabStrength(SemiFunc.PlayerGetSteamID(item));
break;
case "Item Upgrade Player Throw Strength":
PunManager.instance.UpgradePlayerThrowStrength(SemiFunc.PlayerGetSteamID(item));
break;
case "Item Upgrade Player Health":
PunManager.instance.UpgradePlayerHealth(SemiFunc.PlayerGetSteamID(item));
break;
case "Item Upgrade Player Sprint Speed":
PunManager.instance.UpgradePlayerSprintSpeed(SemiFunc.PlayerGetSteamID(item));
break;
case "Item Upgrade Player Tumble Launch":
PunManager.instance.UpgradePlayerTumbleLaunch(SemiFunc.PlayerGetSteamID(item));
break;
default:
DebugLogger.LogWarning(upgradeName + " not found in switch statement!");
break;
}
}
}
}
[HarmonyPatch(typeof(StatsManager))]
internal static class BundlePatch_StatsManager
{
[HarmonyPostfix]
[HarmonyPatch("AddItemsUpgradesPurchased")]
private static void AddItemsUpgradesPurchased_Postfix(StatsManager __instance, ref string itemName)
{
string value = " Bundle";
if (itemName.Contains(value))
{
string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(itemName);
Dictionary<string, int> itemsUpgradesPurchased = __instance.itemsUpgradesPurchased;
if (itemsUpgradesPurchased.TryGetValue(itemStringFromBundle, out var value2))
{
itemsUpgradesPurchased[itemStringFromBundle] = value2 + 1;
}
}
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
public static void Start_Postfix(StatsManager __instance)
{
ItemBundles.Instance.InitializeItemBundles();
}
}
[HarmonyPatch(typeof(ItemAttributes))]
internal static class BundlePatch_ItemAttributes
{
[HarmonyPrefix]
[HarmonyPatch("GetValue")]
private static void GetValue_Prefix(ItemAttributes __instance)
{
}
[HarmonyPostfix]
[HarmonyPatch("GetValue")]
[HarmonyPriority(0)]
private static void GetValue_Postfix(ItemAttributes __instance)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Invalid comparison between Unknown and I4
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Invalid comparison between Unknown and I4
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Invalid comparison between Unknown and I4
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
if (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 itemValueMultiplier = ShopManager.instance.itemValueMultiplier;
float upgradeValueIncrease = ShopManager.instance.upgradeValueIncrease;
if (itemAssetName.Contains("Modded") && MoreUpgradesCompat.enabled)
{
itemValueMultiplier = MoreUpgradesCompat.GetItemValueMultiplier(itemValueMultiplier, itemAssetName);
upgradeValueIncrease = MoreUpgradesCompat.GetUpgradeValueIncrease(upgradeValueIncrease, itemAssetName);
}
else if (VanillaUpgradesCompat.enabled)
{
upgradeValueIncrease = VanillaUpgradesCompat.GetUpgradeValueIncrease(upgradeValueIncrease, itemAssetName);
}
float num2 = Random.Range(__instance.itemValueMin, __instance.itemValueMax) * itemValueMultiplier;
num2 = Mathf.Max(num2, 1000f);
num2 = Mathf.CeilToInt(num2 / 1000f);
DebugLogger.LogInfo($"base {num2}, upgradeIncreaseMult {upgradeValueIncrease}, num items {(float)StatsManager.instance.GetItemsUpgradesPurchased(BundleHelper.GetItemStringFromBundle(__instance.itemAssetName))}", debugOnly: true);
num2 += num2 * upgradeValueIncrease * (float)StatsManager.instance.GetItemsUpgradesPurchased(BundleHelper.GetItemStringFromBundle(__instance.itemAssetName));
num = (int)num2;
}
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 num3 = BundleHelper.GetItemBundlePriceMult(BundleHelper.GetItemStringFromBundle(__instance.item), __instance.itemType) / 100f;
float num4 = (float)count * num3;
num = Mathf.RoundToInt((float)num * num4);
}
__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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: 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");
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)
});
DebugLogger.LogInfo("--- ShowingInfo(): ADDING NEW INSTRUCTIONS", debugOnly: true);
return val.InstructionEnumeration();
}
[HarmonyPostfix]
[HarmonyPatch("ShowingInfo")]
private static void ShowingInfo_Postfix(ItemAttributes __instance)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Invalid comparison between Unknown and I4
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Invalid comparison between Unknown and I4
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Invalid comparison between Unknown and I4
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
string promptName = __instance.promptName;
string value = "Bundle";
if (__instance.itemAssetName.Contains(value))
{
string text = "";
int num = SemiFunc.PlayerGetAll().Count + ItemBundles.Instance.config_debugFakePlayers.Value;
if ((int)__instance.itemType == 8)
{
int healAmount = ((Component)__instance).GetComponent<ItemHealthPackBundle>().healAmount;
text = BundleHelper.PlayerGetAllAlive().Count * healAmount + "hp";
}
else if ((int)__instance.itemType == 6 || (int)__instance.itemType == 11)
{
text = Mathf.Max(num, BundleHelper.GetItemBundleMinItem(BundleHelper.GetItemStringFromBundle(__instance.item), __instance.itemType)).ToString();
}
else if ((int)__instance.itemType == 3)
{
text = num.ToString();
}
promptName = promptName + "\n[Bundle 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("------ 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;
}
DebugLogger.LogInfo("------ Bundling Lists", debugOnly: true);
if (SemiFunc.IsMultiplayer() || !ItemBundles.Instance.config_disableBundlesSP.Value)
{
AttemptBundlesFromList(ref __instance.potentialItems);
AttemptBundlesFromList(ref __instance.potentialItemConsumables);
AttemptBundlesFromList(ref __instance.potentialItemUpgrades);
AttemptBundlesFromList(ref __instance.potentialItemHealthPacks);
}
}
private static void AttemptBundlesFromList(ref List<Item> itemList)
{
//IL_0065: 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.itemAssetName))
{
DebugLogger.LogInfo($"-{num}- Found {val.itemAssetName} entry", debugOnly: true);
ItemBundles.BundleShopInfo bundleShopInfo = ItemBundles.Instance.itemTypeBundleInfos[val.itemType];
ItemBundles.BundleShopInfo bundleShopInfo2 = ItemBundles.Instance.itemBundleInfos[val.itemAssetName];
float num2 = BundleHelper.GetItemBundleChance(val);
num2 /= 100f;
if (BundleHelper.GetItemBundleMax(val) == 0)
{
DebugLogger.LogWarning($"-{num}- Already have max bundles for {val.itemAssetName}!", debugOnly: true);
}
else
{
float num3 = Random.Range(0f, 1f);
if (num3 <= num2)
{
DebugLogger.LogWarning($"-{num}- 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.LogError($"-{num}- Failed with {num3} {num3 <= num2}, keeping item {list[num]}!", debugOnly: true);
}
}
}
}
ListExtension.Shuffle<Item>((IList<Item>)list);
itemList = list;
}
}
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.3.1")]
[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 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_minConsumablePerBundle { 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; }
private void Awake()
{
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();
RegisterItemBundles();
if (MoreUpgradesCompat.enabled)
{
MoreUpgradesCompat.InitCompat();
DebugLogger.LogInfo("MoreUpgradesCompat has loaded!", debugOnly: true);
}
if (VanillaUpgradesCompat.enabled)
{
VanillaUpgradesCompat.InitCompat();
DebugLogger.LogInfo("VanillaUpgradesCompat has loaded!", debugOnly: true);
}
DebugLogger.LogInfo($"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
}
public void RegisterItemBundles()
{
if ((Object)(object)assetBundle == (Object)null)
{
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(assetBundle, "Item Upgrade Map Player Count Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Energy Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Extra Jump Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Grab Range Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Grab Strength Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Health Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Sprint Speed Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Upgrade Player Tumble Launch Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Health Pack Small Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Health Pack Medium Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Health Pack Large Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Grenade Explosive Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Grenade Shockwave Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Grenade Stun Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Mine Explosive Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Mine Shockwave Bundle");
RegisterBundleItemRepoLib(assetBundle, "Item Mine Stun Bundle");
}
public void InitializeItemBundles()
{
if ((Object)(object)assetBundle == (Object)null)
{
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(assetBundle, "Item Upgrade Map Player Count Bundle");
InitializeBundle(assetBundle, "Item Upgrade Player Energy Bundle");
InitializeBundle(assetBundle, "Item Upgrade Player Extra Jump Bundle");
InitializeBundle(assetBundle, "Item Upgrade Player Grab Range Bundle");
InitializeBundle(assetBundle, "Item Upgrade Player Grab Strength Bundle");
InitializeBundle(assetBundle, "Item Upgrade Player Health Bundle");
InitializeBundle(assetBundle, "Item Upgrade Player Sprint Speed Bundle");
InitializeBundle(assetBundle, "Item Upgrade Player Tumble Launch Bundle");
InitializeBundle(assetBundle, "Item Health Pack Small Bundle");
InitializeBundle(assetBundle, "Item Health Pack Medium Bundle");
InitializeBundle(assetBundle, "Item Health Pack Large Bundle");
InitializeBundle(assetBundle, "Item Grenade Explosive Bundle");
InitializeBundle(assetBundle, "Item Grenade Shockwave Bundle");
InitializeBundle(assetBundle, "Item Grenade Stun Bundle");
InitializeBundle(assetBundle, "Item Mine Explosive Bundle");
InitializeBundle(assetBundle, "Item Mine Shockwave Bundle");
InitializeBundle(assetBundle, "Item Mine Stun Bundle");
if (MoreUpgradesCompat.enabled)
{
InitializeBundle(assetBundle, "Modded Item Upgrade Player Map Enemy Tracker Bundle", "MoreUpgrades ");
InitializeBundle(assetBundle, "Modded Item Upgrade Player Map Player Tracker Bundle", "MoreUpgrades ");
InitializeBundle(assetBundle, "Modded Item Upgrade Player Sprint Usage Bundle", "MoreUpgrades ");
InitializeBundle(assetBundle, "Modded Item Upgrade Player Valuable Count Bundle", "MoreUpgrades ");
}
}
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_0402: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Expected O, but got Unknown
//IL_043d: Unknown result type (might be due to invalid IL or missing references)
//IL_0447: Expected O, but got Unknown
//IL_047a: Unknown result type (might be due to invalid IL or missing references)
//IL_0484: 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_minConsumablePerBundle = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Mininum consumables per bundle", 0, new ConfigDescription("Minimum amount of items in consumable 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: Item 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: Item 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: Item 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: Item 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: Item 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: Item 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: Item 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: Item 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: Item 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: Item 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: Item 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: Item 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: Item Type", "Upgrades: Max", -1, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bundles: Item 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>("Dev", "Debug Logging", false, new ConfigDescription("Enables debug logging", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" }));
config_debugFakePlayers = ((BaseUnityPlugin)this).Config.Bind<int>("Dev", "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(AssetBundle assetBundle, string itemString)
{
Item val = assetBundle.LoadAsset<Item>(itemString);
if ((Object)(object)val == (Object)null)
{
DebugLogger.LogError("Item " + itemString + " not found!");
}
else
{
Items.RegisterItem(val);
}
}
internal void InitializeBundle(AssetBundle assetBundle, string bundleItemString, string configSectionPrefix = "")
{
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Invalid comparison between Unknown and I4
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Expected O, but got Unknown
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Expected O, but got Unknown
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Invalid comparison between Unknown and I4
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Invalid comparison between Unknown and I4
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Expected O, but got Unknown
Item val = assetBundle.LoadAsset<Item>(bundleItemString);
if ((Object)(object)val == (Object)null)
{
DebugLogger.LogError("--- Bundle Item \"" + bundleItemString + "\" not found!");
return;
}
string text = " Bundle";
if (!bundleItemString.Contains(text))
{
DebugLogger.LogError("--- Item " + bundleItemString + " is not a bundle! Add \" Bundle\" to item name (WITH THE SPACE)");
return;
}
string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(val);
Item val2 = StatsManager.instance.itemDictionary[itemStringFromBundle];
if (!Object.op_Implicit((Object)(object)val2))
{
DebugLogger.LogError("--- Didn't find " + itemStringFromBundle + "! Make sure itemAssetName of bundle Item and bundle Prefab is " + itemStringFromBundle + text);
return;
}
if (itemBundleInfos.ContainsKey(itemStringFromBundle))
{
DebugLogger.LogWarning($"--- bundleStringPairs {itemStringFromBundle} already has an entry {itemBundleInfos[itemStringFromBundle]}, we are overriding something!");
}
itemDictionaryShopBlacklist.Add(val.itemAssetName, val);
if ((int)val.itemType == 3)
{
val.value = ScriptableObject.CreateInstance<Value>();
val.value.valueMin = val2.value.valueMin;
val.value.valueMax = val2.value.valueMax;
}
string text2 = "Has Priority over Item Type entry. Ignored if set below 0";
BundleShopInfo bundleShopInfo = new BundleShopInfo
{
bundleItem = val,
config_chanceInShop = ((BaseUnityPlugin)this).Config.Bind<int>(configSectionPrefix + "Bundles: Item", val2.itemName + ": Chance", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100), Array.Empty<object>())),
config_maxInShop = ((BaseUnityPlugin)this).Config.Bind<int>(configSectionPrefix + "Bundles: Item", val2.itemName + ": Max", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())),
config_priceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>(configSectionPrefix + "Bundles: Item", val2.itemName + ": Price Multiplier", -1f, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 200f), Array.Empty<object>()))
};
if ((int)val.itemType == 6 || (int)val.itemType == 11)
{
bundleShopInfo.config_minPerBundle = ((BaseUnityPlugin)this).Config.Bind<int>(configSectionPrefix + "Bundles: Item", val2.itemName + ": Mininum per bundle", -1, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>()));
}
itemBundleInfos[itemStringFromBundle] = bundleShopInfo;
DebugLogger.LogInfo("--- Added bundleInfo { " + itemStringFromBundle + " | " + val.itemAssetName + " }", 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()
{
}
}
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;
}
}
public static void InitCompat()
{
Plugin instance = Plugin.instance;
foreach (UpgradeItem upgradeItem in instance.upgradeItems)
{
Item val = ItemBundles.Instance.assetBundle.LoadAsset<Item>(upgradeItem.fullName + " Bundle");
if (Object.op_Implicit((Object)(object)val))
{
Items.RegisterItem(val);
DebugLogger.LogInfo($"-- MoreUpgradesCompat found matching bundle item: {val}", debugOnly: true);
val.prefab.GetComponent<ModdedItemUpgradeBundle>().upgradeItemName = upgradeItem.name;
val.prefab.GetComponent<ModdedItemUpgradeBundle>().FixMaterial();
val.prefab.GetComponent<ModdedItemUpgradeBundle>().FixLight();
}
else
{
DebugLogger.LogError("-- MoreUpgradesCompat did not find bundle item", debugOnly: true);
}
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void CallUpgrade(string upgradeItemName, string steamId, int amount = 1)
{
MoreUpgradesManager.instance.Upgrade(upgradeItemName, steamId, amount);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static float GetItemValueMultiplier(float fallbackMult, string bundleAssetName)
{
string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(bundleAssetName);
return Plugin.ItemValueMultiplier(fallbackMult, itemStringFromBundle);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static float GetUpgradeValueIncrease(float fallbackMult, string bundleAssetName)
{
string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(bundleAssetName);
return Plugin.UpgradeValueIncrease(fallbackMult, itemStringFromBundle);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static Material? GetBoxMat(string upgradeItemName)
{
Plugin instance = Plugin.instance;
Item val = instance.assetBundle.LoadAsset<Item>(upgradeItemName);
if ((Object)(object)val == (Object)null)
{
DebugLogger.LogError("- GetBoxMat " + upgradeItemName + " failed", debugOnly: true);
return null;
}
Material result = ((Renderer)val.prefab.GetComponentInChildren<MeshRenderer>()).materials[0];
MeshFilter[] componentsInChildren = val.prefab.GetComponentsInChildren<MeshFilter>();
MeshFilter[] array = componentsInChildren;
foreach (MeshFilter val2 in array)
{
MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>();
if ((Object)(object)component != (Object)null && ((Object)((Renderer)component).materials[0]).name.Contains("upgrade"))
{
result = ((Renderer)component).materials[0];
break;
}
}
return result;
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static Light? GetLight(string upgradeItemName)
{
Plugin instance = Plugin.instance;
Item val = instance.assetBundle.LoadAsset<Item>(upgradeItemName);
if ((Object)(object)val == (Object)null)
{
DebugLogger.LogError("- GetLight " + upgradeItemName + " failed", debugOnly: true);
return null;
}
Transform val2 = val.prefab.transform.Find("Light - Small Lamp");
if ((Object)(object)val2 == (Object)null)
{
return null;
}
return ((Component)val2).GetComponent<Light>();
}
}
public class ItemConsumableBundle : MonoBehaviour
{
private ItemToggle itemToggle;
private PhotonView photonView;
private PhysGrabObjectImpactDetector impactDetector;
public GameObject itemPrefab;
private bool used;
private void Start()
{
itemToggle = ((Component)this).GetComponent<ItemToggle>();
photonView = ((Component)this).GetComponent<PhotonView>();
impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
}
private void Update()
{
if (!SemiFunc.RunIsShop() && SemiFunc.IsMasterClientOrSingleplayer() && itemToggle.toggleState && !used && !used && itemToggle.toggleState)
{
SpawnItems();
StatsManager.instance.ItemRemove(((Component)this).GetComponent<ItemAttributes>().instanceName);
impactDetector.destroyDisable = false;
impactDetector.DestroyObject(false);
used = true;
}
}
public void SpawnItems()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Invalid comparison between Unknown and I4
//IL_0097: 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)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
int num = SemiFunc.PlayerGetAll().Count;
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));
if (!SemiFunc.IsMultiplayer())
{
for (int i = 0; i < num + ItemBundles.Instance.config_debugFakePlayers.Value; i++)
{
Vector3 val2 = Vector3.zero;
if (i != 0)
{
val2 = Random.insideUnitSphere * num2;
}
GameObject val3 = Object.Instantiate<GameObject>(itemPrefab, ((Component)this).transform.position + val2, Quaternion.identity);
StatsManager.instance.ItemPurchase(val3.GetComponent<ItemAttributes>().item.itemAssetName);
}
}
else
{
if (!SemiFunc.IsMasterClient())
{
return;
}
for (int j = 0; j < num + ItemBundles.Instance.config_debugFakePlayers.Value; j++)
{
Vector3 val4 = Vector3.zero;
if (j != 0)
{
val4 = Random.insideUnitSphere * num2;
}
GameObject val5 = PhotonNetwork.Instantiate("Items/" + ((Object)itemPrefab).name, ((Component)this).transform.position + val4, Quaternion.identity, (byte)0, (object[])null);
StatsManager.instance.ItemPurchase(val5.GetComponent<ItemAttributes>().item.itemAssetName);
}
}
}
}
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;
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_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
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>();
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.itemAssetName];
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_0075: 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)
PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
if (val.isLocal)
{
val.physGrabber.ReleaseObjectRPC(false, 1f);
}
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 ItemUpgradeBundle : MonoBehaviour
{
public Item originalItem;
private void Start()
{
}
public void Upgrade()
{
if ((Object)(object)originalItem == (Object)null)
{
DebugLogger.LogError("originalItem is NULL! Either item was not assigned or was not found!");
}
else if (VanillaUpgradesCompat.enabled)
{
VanillaUpgradesCompat.CallBundleUpgrade(originalItem.itemAssetName);
}
else
{
BundleHelper.CallBundleUpgrade(originalItem.itemAssetName);
}
}
}
public class ModdedItemUpgradeBundle : MonoBehaviour
{
public string upgradeItemName;
public void FixMaterial()
{
Material boxMat = MoreUpgradesCompat.GetBoxMat(upgradeItemName);
if (!((Object)(object)boxMat != (Object)null))
{
return;
}
MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshFilter>();
MeshFilter[] array = componentsInChildren;
foreach (MeshFilter val in array)
{
MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
if ((Object)(object)component != (Object)null && ((Object)((Renderer)component).materials[0]).name.Contains("upgrade"))
{
Material[] materials = (Material[])(object)new Material[2]
{
boxMat,
((Renderer)component).materials[1]
};
((Renderer)component).materials = materials;
}
}
}
public void FixLight()
{
//IL_0042: 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 light = MoreUpgradesCompat.GetLight(upgradeItemName);
if ((Object)(object)component != (Object)null && (Object)(object)light != (Object)null)
{
component.color = light.color;
}
}
public void Upgrade()
{
if (string.IsNullOrEmpty(upgradeItemName))
{
DebugLogger.LogError("upgradeItemName was empty! Cannot upgrade");
return;
}
List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
foreach (PlayerAvatar item in list)
{
string steamId = SemiFunc.PlayerGetSteamID(item);
MoreUpgradesCompat.CallUpgrade(upgradeItemName, steamId);
}
}
}
public static class VanillaUpgradesCompat
{
private static bool? _enabled;
public static bool enabled
{
get
{
if (!_enabled.HasValue)
{
_enabled = Chainloader.PluginInfos.ContainsKey("bulletbot.vanillaupgrades");
}
return _enabled.Value;
}
}
public static void InitCompat()
{
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static float GetUpgradeValueIncrease(float fallbackMult, string bundleAssetName)
{
string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(bundleAssetName);
return Plugin.UpgradeValueIncrease(fallbackMult, itemStringFromBundle);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void CallBundleUpgrade(ItemToggle itemToggle)
{
string itemStringFromBundle = BundleHelper.GetItemStringFromBundle(((Component)itemToggle).gameObject.GetComponent<ItemAttributes>().item.itemAssetName);
CallBundleUpgrade(itemStringFromBundle);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void CallBundleUpgrade(string itemAssetName)
{
string itemAssetName2 = itemAssetName;
Plugin instance = Plugin.instance;
UpgradeItem val = ((IEnumerable<UpgradeItem>)instance.upgradeItems).FirstOrDefault((Func<UpgradeItem, bool>)((UpgradeItem x) => x.name == itemAssetName2));
if (val == null)
{
return;
}
foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
{
VanillaUpgradesManager.instance.Upgrade(val.name, SemiFunc.PlayerGetSteamID(item), 1);
}
}
}
}