using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Assets.Scripts.Actors;
using Assets.Scripts.Actors.Player;
using Assets.Scripts.Game.Combat;
using Assets.Scripts.Game.Combat.ConstantAttacks;
using Assets.Scripts.Game.MapGeneration;
using Assets.Scripts.Inventory__Items__Pickups;
using Assets.Scripts.Inventory__Items__Pickups.AbilitiesPassive;
using Assets.Scripts.Inventory__Items__Pickups.AbilitiesPassive.Implementations;
using Assets.Scripts.Inventory__Items__Pickups.Chests;
using Assets.Scripts.Inventory__Items__Pickups.Interactables;
using Assets.Scripts.Inventory__Items__Pickups.Items;
using Assets.Scripts.Inventory__Items__Pickups.Items.ItemImplementations;
using Assets.Scripts.Inventory__Items__Pickups.Pickups;
using Assets.Scripts.Inventory__Items__Pickups.Stats;
using Assets.Scripts.Inventory__Items__Pickups.Upgrades;
using Assets.Scripts.Inventory__Items__Pickups.Weapons;
using Assets.Scripts.Managers;
using Assets.Scripts.Menu.Shop;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using Assets.Scripts.Saves___Serialization.Progression.Unlocks;
using Assets.Scripts.Steam;
using Assets.Scripts.Steam.LeaderboardsNew;
using Assets.Scripts.UI.HUD;
using Assets.Scripts.UI.InGame.Rewards;
using Assets.Scripts.UI.InGame.Rewards.Effects;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Inventory__Items__Pickups.Xp_and_Levels;
using Steamworks;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MegaBonkMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MegaBonkMod")]
[assembly: AssemblyTitle("MegaBonkMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MegaBonkMod;
public class ModGui : MonoBehaviour
{
internal static readonly ConcurrentQueue<Action> MainThread = new ConcurrentQueue<Action>();
private bool _visible;
private bool _authenticated;
private bool _promptVisible;
private string _passwordInput = "";
private const string Password = "kittens";
internal static bool ChartDisabled;
internal static bool NeedVersionPatch;
internal static bool UpdateAvailable;
private GameObject _statsParent;
private GameObject _damageWindow;
private GameObject _statsWindowObj;
private GameObject _questsWindow;
private Vector2 _winPos = new Vector2(20f, 20f);
private bool _dragging;
private Vector2 _dragOffset;
private bool _powerupOpen = true;
private const float FastFallSpeed = 15f;
private const float FastFallRampTime = 0.2f;
private float _fastFallTimer;
private const float WinW = 440f;
private const float PadX = 8f;
private const float LineH = 22f;
public ModGui(IntPtr ptr)
: base(ptr)
{
}//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
private unsafe void Update()
{
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_0394: Unknown result type (might be due to invalid IL or missing references)
//IL_0399: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
Action result;
while (MainThread.TryDequeue(out result))
{
try
{
result();
}
catch
{
}
}
if (NeedVersionPatch)
{
string version = Application.version;
foreach (TextMeshProUGUI item in Object.FindObjectsOfType<TextMeshProUGUI>())
{
if (((TMP_Text)item).text != null && ((TMP_Text)item).text.Contains(version))
{
BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(typeof(Plugin), typeof(BepInPlugin));
string text = (((int)val == 0) ? null : ((object)val.Version)?.ToString()) ?? "?";
((TMP_Text)item).text = "Mod v" + text + " | " + ((TMP_Text)item).text;
NeedVersionPatch = false;
break;
}
}
}
if (Input.GetKeyDown((KeyCode)282))
{
if (_authenticated)
{
_visible = !_visible;
}
else
{
_promptVisible = !_promptVisible;
_passwordInput = "";
}
}
if (_promptVisible && !_authenticated)
{
string inputString = Input.inputString;
for (int i = 0; i < inputString.Length; i++)
{
char c = inputString[i];
switch (c)
{
case '\b':
if (_passwordInput.Length > 0)
{
_passwordInput = _passwordInput.Substring(0, _passwordInput.Length - 1);
}
break;
case '\n':
case '\r':
if (_passwordInput == "kittens")
{
_authenticated = true;
_promptVisible = false;
_visible = true;
}
else
{
_passwordInput = "";
}
break;
default:
_passwordInput += c;
break;
}
}
}
if (Input.GetKeyDown((KeyCode)283) && !ChartDisabled)
{
ToggleDamageChart();
}
try
{
PlayerMovement instance = PlayerMovement.Instance;
if ((Object)(object)instance != (Object)null)
{
if (*(byte*)(void*)(((Il2CppObjectBase)instance).Pointer + 223) == 0 && MyInputManager.GetButton(MyInputManager.Slide))
{
_fastFallTimer = Mathf.Min(_fastFallTimer + Time.deltaTime, 0.2f);
float num = _fastFallTimer / 0.2f;
float num2 = 15f * (num * num);
if (num2 > 0.01f)
{
Rigidbody component = ((Component)instance).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
Vector3 velocity = component.velocity;
if (velocity.y <= 0f)
{
component.velocity = new Vector3(velocity.x, Mathf.Min(velocity.y, 0f - num2), velocity.z);
}
}
}
}
else
{
_fastFallTimer = 0f;
}
}
}
catch
{
}
if (!_visible)
{
return;
}
float x = Input.mousePosition.x;
float num3 = (float)Screen.height - Input.mousePosition.y;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(x, num3);
if (Input.GetMouseButtonDown(0))
{
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(_winPos.x, _winPos.y, 440f, 26f);
if (((Rect)(ref val3)).Contains(val2))
{
_dragging = true;
_dragOffset = val2 - _winPos;
}
}
if (Input.GetMouseButtonUp(0))
{
_dragging = false;
}
if (_dragging && Input.GetMouseButton(0))
{
_winPos = val2 - _dragOffset;
}
}
internal void ResetChartCache()
{
_statsParent = null;
}
private void ToggleDamageChart()
{
//IL_014d: 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_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)_statsParent == (Object)null)
{
_statsParent = GameObject.Find("GameUI/GameUI/DeathScreen/StatsWindows");
if ((Object)(object)_statsParent != (Object)null)
{
Transform obj = _statsParent.transform.Find("W_Damage");
_damageWindow = ((obj != null) ? ((Component)obj).gameObject : null);
Transform obj2 = _statsParent.transform.Find("W_Stats");
_statsWindowObj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
Transform obj3 = _statsParent.transform.Find("W_Quests");
_questsWindow = ((obj3 != null) ? ((Component)obj3).gameObject : null);
}
}
if ((Object)(object)_statsParent == (Object)null)
{
return;
}
bool flag = !_statsParent.activeSelf;
_statsParent.SetActive(flag);
if ((Object)(object)_statsWindowObj != (Object)null)
{
_statsWindowObj.SetActive(!flag);
}
if ((Object)(object)_questsWindow != (Object)null)
{
_questsWindow.SetActive(!flag);
}
if (flag)
{
GameOverDamageSourcesUi componentInChildren = _statsParent.GetComponentInChildren<GameOverDamageSourcesUi>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.Start();
}
RectTransform component = _statsParent.GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
component.anchorMin = new Vector2(0f, 0.5f);
component.anchorMax = new Vector2(0f, 0.5f);
component.pivot = new Vector2(0f, 0.5f);
component.anchoredPosition = new Vector2(20f, 0f);
}
}
}
catch
{
}
}
private void OnGUI()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
if (UpdateAvailable)
{
float num = 420f;
float num2 = 36f;
float num3 = ((float)Screen.width - num) / 2f;
float num4 = 8f;
GUI.Box(new Rect(num3, num4, num, num2), "");
GUI.Label(new Rect(num3 + 8f, num4 + 8f, num - 16f, 20f), "!! MegaBonk Mod is outdated — please update to the latest version !!");
}
if (_promptVisible && !_authenticated)
{
float num5 = 240f;
float num6 = 72f;
float num7 = ((float)Screen.width - num5) / 2f;
float num8 = ((float)Screen.height - num6) / 2f;
GUI.Box(new Rect(num7, num8, num5, num6), "Mod Menu Password");
GUI.Label(new Rect(num7 + 8f, num8 + 26f, num5 - 16f, 22f), new string('*', _passwordInput.Length));
GUI.Label(new Rect(num7 + 8f, num8 + 50f, num5 - 16f, 18f), "Type password + Enter");
}
else
{
if (!_visible)
{
return;
}
float x = _winPos.x;
float y = _winPos.y;
float num9 = 424f;
float num10 = x + 8f;
float num11 = 32f;
num11 += 22f;
if (_powerupOpen)
{
num11 += 88f;
}
num11 += 26f;
num11 += 30f;
GUI.Box(new Rect(x, y, 440f, num11), "MegaBonk Mod");
float num12 = y + 22f + 6f;
GUIStyle button = GUI.skin.button;
_ = GUI.skin.toggle;
_powerupOpen = GUI.Toggle(new Rect(num10, num12, num9, 22f), _powerupOpen, (_powerupOpen ? "[-] " : "[+] ") + "Spawn Powerup", button);
num12 += 24f;
if (_powerupOpen)
{
PickupManager instance = PickupManager.Instance;
PlayerMovement instance2 = PlayerMovement.Instance;
Vector3 pos = (((Object)(object)instance2 != (Object)null) ? ((Component)instance2).transform.position : Vector3.zero);
SpawnPowerupRow(instance, pos, num10, ref num12, num9, (EPickup)2, "Health", (EPickup)3, "Nuke");
SpawnPowerupRow(instance, pos, num10, ref num12, num9, (EPickup)4, "Clock", (EPickup)5, "Shield");
SpawnPowerupRow(instance, pos, num10, ref num12, num9, (EPickup)6, "Rage", (EPickup)7, "Haste");
SpawnPowerupRow(instance, pos, num10, ref num12, num9, (EPickup)8, "Stonks", (EPickup)9, "Magnet");
}
float num13 = (num9 - 4f) / 2f;
if (GUI.Button(new Rect(num10, num12, num13, 22f), "+1000 XP"))
{
GameManager instance3 = GameManager.Instance;
PlayerInventory val = ((instance3 != null) ? instance3.GetPlayerInventory() : null);
if (val != null)
{
val.AddXp(1000);
}
}
if (GUI.Button(new Rect(num10 + num13 + 4f, num12, num13, 22f), "+1000 Gold"))
{
GameManager instance4 = GameManager.Instance;
PlayerInventory val2 = ((instance4 != null) ? instance4.GetPlayerInventory() : null);
if (val2 != null)
{
val2.ChangeGold(1000);
}
}
num12 += 26f;
GUI.Label(new Rect(num10, num12 + 4f, num9, 22f), "F1 to toggle | F2 dmg chart | Drag title bar");
}
}
private static void SpawnPowerupRow(PickupManager pm, Vector3 pos, float x, ref float y, float cw, EPickup left, string leftLabel, EPickup right, string rightLabel)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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)
float num = (cw - 4f) / 2f;
if (GUI.Button(new Rect(x, y, num, 22f), leftLabel) && (Object)(object)pm != (Object)null)
{
pm.SpawnPickup(left, pos, 1, false, 0f);
}
if (GUI.Button(new Rect(x + num + 4f, y, num, 22f), rightLabel) && (Object)(object)pm != (Object)null)
{
pm.SpawnPickup(right, pos, 1, false, 0f);
}
y += 22f;
}
}
[HarmonyPatch(typeof(RunUnlockables), "Init")]
internal static class Patch_RunUnlockables_Init
{
[HarmonyPostfix]
private static void Postfix()
{
RemoveItemCaps();
CacheAndApplyStatBlacklist();
CacheAndApplyShrineStatBlacklist();
}
internal static void RemoveItemCaps()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
Dictionary<EItemRarity, List<ItemData>> availableItems = RunUnlockables.availableItems;
if (availableItems == null)
{
return;
}
Enumerator<EItemRarity, List<ItemData>> enumerator = availableItems.GetEnumerator();
while (enumerator.MoveNext())
{
KeyValuePair<EItemRarity, List<ItemData>> current = enumerator.Current;
if (current.Value == null)
{
continue;
}
Enumerator<ItemData> enumerator2 = current.Value.GetEnumerator();
while (enumerator2.MoveNext())
{
ItemData current2 = enumerator2.Current;
if (Plugin.ActiveUncappedItems.Contains(current2.eItem))
{
current2.maxAmount = Plugin.GetItemCap(current2.eItem);
current2.maxAmountPerRun = 9999;
}
}
}
}
private static void CacheAndApplyStatBlacklist()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected I4, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
List<EStat> upgradableStatsChaosAndGamble = EncounterUtility.upgradableStatsChaosAndGamble;
if (upgradableStatsChaosAndGamble == null)
{
return;
}
if (Plugin.FullStatPool.Count == 0)
{
Enumerator<EStat> enumerator = upgradableStatsChaosAndGamble.GetEnumerator();
while (enumerator.MoveNext())
{
EStat current = enumerator.Current;
Plugin.FullStatPool.Add((int)current);
}
}
foreach (int blacklistedStat in Plugin.BlacklistedStats)
{
EStat val = (EStat)blacklistedStat;
if (upgradableStatsChaosAndGamble.Contains(val))
{
upgradableStatsChaosAndGamble.Remove(val);
}
}
}
private static void CacheAndApplyShrineStatBlacklist()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected I4, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
List<EStat> upgradableStatsShrines = EncounterUtility.upgradableStatsShrines;
if (upgradableStatsShrines == null)
{
return;
}
if (Plugin.FullShrineStatPool.Count == 0)
{
Enumerator<EStat> enumerator = upgradableStatsShrines.GetEnumerator();
while (enumerator.MoveNext())
{
EStat current = enumerator.Current;
Plugin.FullShrineStatPool.Add((int)current);
}
}
foreach (int blacklistedShrineStat in Plugin.BlacklistedShrineStats)
{
EStat val = (EStat)blacklistedShrineStat;
if (upgradableStatsShrines.Contains(val))
{
upgradableStatsShrines.Remove(val);
}
}
}
}
[HarmonyPatch(typeof(RunUnlockables), "OnNewRunStarted")]
internal static class Patch_RunUnlockables_OnNewRunStarted
{
[HarmonyPostfix]
private static void Postfix()
{
Patch_RunUnlockables_Init.RemoveItemCaps();
}
}
[HarmonyPatch(typeof(MicrowaveItemButton), "SelectUpgrade")]
internal static class Patch_MicrowaveItemButton_SelectUpgrade
{
[HarmonyPrefix]
private unsafe static void Prefix(MicrowaveItemButton __instance)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
long num = *(long*)(void*)(((Il2CppObjectBase)__instance).Pointer + 104);
if (num == 0L)
{
return;
}
EItem item = (EItem)(*(int*)(num + 84));
if (Plugin.ActiveUncappedItems.Contains(item))
{
int num2 = *(int*)(num + 112);
if (num2 > 0)
{
*(int*)(num + 112) = num2 + 1;
}
}
}
}
[HarmonyPatch(typeof(ItemGrandmasSecretTonic), "OnInitOrAmountChanged")]
internal static class Patch_GrandmasTonic_SizeCap
{
private const float BaseRadius = 4f;
private const float RadiusPerAmount = 2f;
private const float MaxRadius = 16f;
private const int MaxStacks = 6;
[HarmonyPrefix]
private unsafe static void Prefix(ItemGrandmasSecretTonic __instance)
{
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 60) = 16f;
}
[HarmonyPostfix]
private unsafe static void Postfix(ItemGrandmasSecretTonic __instance)
{
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 52) = 4f;
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 56) = 2f;
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 60) = 16f;
int num = *(int*)(void*)(((Il2CppObjectBase)__instance).Pointer + 24);
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 64) = Math.Min(4f + (float)num * 2f, 16f);
DataManager instance = DataManager.Instance;
ItemData val = ((instance != null) ? instance.GetItem((EItem)11) : null);
if (!((Object)(object)val == (Object)null))
{
int maxAmount = (val.maxAmountPerRun = 6);
val.maxAmount = maxAmount;
}
}
}
[HarmonyPatch(typeof(ItemSpicyMeatball), "OnInitOrAmountChanged")]
internal static class Patch_SpicyMeatball_Radius
{
private const float BaseRadius = 8f;
private const float RadiusPerAmount = 4f;
private const float MaxRadius = 32f;
[HarmonyPrefix]
private unsafe static void Prefix(ItemSpicyMeatball __instance)
{
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 56) = 32f;
}
[HarmonyPostfix]
private unsafe static void Postfix(ItemSpicyMeatball __instance)
{
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 48) = 8f;
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 52) = 4f;
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 56) = 32f;
int num = *(int*)(void*)(((Il2CppObjectBase)__instance).Pointer + 24);
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 60) = Math.Min(8f + (float)num * 4f, 32f);
}
}
[HarmonyPatch(typeof(ItemBobLantern), "OnInitOrAmountChanged")]
internal static class Patch_BobLantern_FireRate
{
[HarmonyPostfix]
private unsafe static void Postfix(ItemBobLantern __instance)
{
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 60) /= 2f;
}
}
[HarmonyPatch(typeof(ItemBrassKnuckles), "OnInitOrAmountChanged")]
internal static class Patch_BrassKnuckles_SizeCap
{
[HarmonyPrefix]
private unsafe static void Prefix(ItemBrassKnuckles __instance)
{
*(float*)(void*)(((Il2CppObjectBase)__instance).Pointer + 56) = float.MaxValue;
}
}
[HarmonyPatch(typeof(ItemBackpack), "OnInitOrAmountChanged")]
internal static class Patch_ItemBackpack_Projectiles
{
[HarmonyPrefix]
private unsafe static void Prefix(ItemBackpack __instance)
{
*(int*)(void*)(((Il2CppObjectBase)__instance).Pointer + 24) *= 2;
}
[HarmonyPostfix]
private unsafe static void Postfix(ItemBackpack __instance)
{
*(int*)(void*)(((Il2CppObjectBase)__instance).Pointer + 24) /= 2;
}
}
[HarmonyPatch(typeof(ItemData), "CompareTo", new Type[] { typeof(UnlockableBase) })]
internal static class Patch_ItemData_CompareTo_SuckyMagnet
{
private static readonly HashSet<EItem> SortsFirst = new HashSet<EItem>
{
(EItem)33,
(EItem)40,
(EItem)32,
(EItem)55,
(EItem)56,
(EItem)19,
(EItem)38,
(EItem)82,
(EItem)7,
(EItem)0
};
private static readonly HashSet<EItem> SortsLast = new HashSet<EItem>
{
(EItem)58,
(EItem)1,
(EItem)2,
(EItem)43,
(EItem)72,
(EItem)8,
(EItem)59,
(EItem)4,
(EItem)42,
(EItem)23
};
[HarmonyPrefix]
private static bool Prefix(ItemData __instance, UnlockableBase other, ref int __result)
{
//IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
ItemData val = (ItemData)(object)((other is ItemData) ? other : null);
if (val == null)
{
return true;
}
if (__instance.rarity != val.rarity)
{
return true;
}
bool flag = SortsFirst.Contains(__instance.eItem);
bool flag2 = SortsFirst.Contains(val.eItem);
bool flag3 = SortsLast.Contains(__instance.eItem);
bool flag4 = SortsLast.Contains(val.eItem);
if (flag && !flag2)
{
__result = -1;
return false;
}
if (flag2 && !flag)
{
__result = 1;
return false;
}
if (flag3 && !flag4)
{
__result = 1;
return false;
}
if (flag4 && !flag3)
{
__result = -1;
return false;
}
if (flag3 && flag4)
{
__result = 0;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(MyAchievements), "CanToggleActivation")]
internal static class Patch_CanToggleActivation_NonToggleable
{
[HarmonyPrefix]
private static bool Prefix(UnlockableBase unlockable, ref bool __result)
{
DataManager instance = DataManager.Instance;
if ((Object)(object)instance == (Object)null)
{
return true;
}
if ((Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)40) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)33) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)32) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)55) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)56) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)19))
{
__result = false;
return false;
}
if ((Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)72) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)8) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)59) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)4) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)42) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)23))
{
__result = true;
return false;
}
if ((Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)38) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)82) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)7) || (Object)(object)unlockable == (Object)(object)instance.GetItem((EItem)0))
{
__result = false;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(MyAchievements), "IsAvailable")]
internal static class Patch_IsAvailable_ForcedItems
{
[HarmonyPrefix]
private static bool Prefix(UnlockableBase unlockable, ref bool __result)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
DataManager instance = DataManager.Instance;
if ((Object)(object)instance == (Object)null)
{
return true;
}
foreach (EItem forcedPoolItem in Plugin.ForcedPoolItems)
{
if ((Object)(object)unlockable == (Object)(object)instance.GetItem(forcedPoolItem))
{
__result = true;
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(DataManager), "Load")]
internal static class Patch_DataManager_Load
{
[HarmonyPostfix]
private unsafe static void Postfix(DataManager __instance)
{
//IL_0644: Unknown result type (might be due to invalid IL or missing references)
//IL_0649: Unknown result type (might be due to invalid IL or missing references)
//IL_064c: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_051c: Unknown result type (might be due to invalid IL or missing references)
//IL_051f: Unknown result type (might be due to invalid IL or missing references)
//IL_0567: Unknown result type (might be due to invalid IL or missing references)
//IL_056e: Invalid comparison between Unknown and I4
List<TomeData> allTomes = __instance.GetAllTomes();
if (allTomes != null)
{
for (int i = 0; i < allTomes.Count; i++)
{
((UnlockableBase)allTomes[i]).canAlwaysToggle = true;
}
}
List<WeaponData> allWeapons = __instance.GetAllWeapons();
if (allWeapons != null)
{
for (int j = 0; j < allWeapons.Count; j++)
{
((UnlockableBase)allWeapons[j]).canAlwaysToggle = true;
UpgradeData upgradeData = allWeapons[j].upgradeData;
if (((upgradeData != null) ? upgradeData.upgradeModifiers : null) != null)
{
AddUpgradeStat(upgradeData.upgradeModifiers, (EStat)18, 0.1f);
AddUpgradeStat(upgradeData.upgradeModifiers, (EStat)19, 0.2f);
RemoveStat(upgradeData.upgradeModifiers, 24);
}
}
}
ItemData item = __instance.GetItem((EItem)58);
if ((Object)(object)item != (Object)null)
{
((UnlockableBase)item).canAlwaysToggle = true;
}
ItemData item2 = __instance.GetItem((EItem)85);
ItemData item3 = __instance.GetItem((EItem)44);
if ((Object)(object)item2 != (Object)null)
{
item2.rarity = (EItemRarity)3;
}
if ((Object)(object)item3 != (Object)null)
{
item3.rarity = (EItemRarity)2;
}
ItemData item4 = __instance.GetItem((EItem)45);
ItemData item5 = __instance.GetItem((EItem)2);
if ((Object)(object)item4 != (Object)null)
{
item4.rarity = (EItemRarity)2;
}
if ((Object)(object)item5 != (Object)null)
{
item5.rarity = (EItemRarity)1;
((UnlockableBase)item5).canAlwaysToggle = true;
}
ItemData item6 = __instance.GetItem((EItem)33);
ItemData item7 = __instance.GetItem((EItem)40);
if ((Object)(object)item6 != (Object)null)
{
item6.rarity = (EItemRarity)2;
((UnlockableBase)item6).canAlwaysToggle = false;
((UnlockableBase)item6).sortingPriority = -1000;
}
if ((Object)(object)item7 != (Object)null)
{
item7.rarity = (EItemRarity)1;
((UnlockableBase)item7).canAlwaysToggle = false;
}
ItemData item8 = __instance.GetItem((EItem)34);
ItemData item9 = __instance.GetItem((EItem)43);
if ((Object)(object)item8 != (Object)null)
{
item8.rarity = (EItemRarity)0;
((UnlockableBase)item8).canAlwaysToggle = false;
}
if ((Object)(object)item9 != (Object)null)
{
item9.rarity = (EItemRarity)3;
((UnlockableBase)item9).canAlwaysToggle = true;
}
ItemData item10 = __instance.GetItem((EItem)1);
if ((Object)(object)item10 != (Object)null)
{
((UnlockableBase)item10).canAlwaysToggle = true;
}
ItemData item11 = __instance.GetItem((EItem)32);
ItemData item12 = __instance.GetItem((EItem)55);
ItemData item13 = __instance.GetItem((EItem)56);
ItemData item14 = __instance.GetItem((EItem)19);
if ((Object)(object)item11 != (Object)null)
{
((UnlockableBase)item11).canAlwaysToggle = false;
}
if ((Object)(object)item12 != (Object)null)
{
((UnlockableBase)item12).canAlwaysToggle = false;
}
if ((Object)(object)item13 != (Object)null)
{
((UnlockableBase)item13).canAlwaysToggle = false;
}
if ((Object)(object)item14 != (Object)null)
{
((UnlockableBase)item14).canAlwaysToggle = false;
}
ItemData item15 = __instance.GetItem((EItem)72);
ItemData item16 = __instance.GetItem((EItem)8);
if ((Object)(object)item15 != (Object)null)
{
((UnlockableBase)item15).canAlwaysToggle = true;
}
if ((Object)(object)item16 != (Object)null)
{
item16.rarity = (EItemRarity)1;
((UnlockableBase)item16).canAlwaysToggle = true;
}
EItem[] array = new EItem[4];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
EItem[] array2 = (EItem[])(object)array;
foreach (EItem val in array2)
{
ItemData item17 = __instance.GetItem(val);
if ((Object)(object)item17 != (Object)null)
{
((UnlockableBase)item17).canAlwaysToggle = true;
}
}
EItem[] array3 = new EItem[4];
RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
array2 = (EItem[])(object)array3;
foreach (EItem val2 in array2)
{
ItemData item18 = __instance.GetItem(val2);
if ((Object)(object)item18 != (Object)null)
{
((UnlockableBase)item18).canAlwaysToggle = false;
}
}
List<CharacterData> unsortedCharacterData = __instance.unsortedCharacterData;
if (unsortedCharacterData != null)
{
for (int l = 0; l < unsortedCharacterData.Count; l++)
{
CharacterData val3 = unsortedCharacterData[l];
if (((val3 != null) ? val3.statModifiers : null) == null)
{
continue;
}
List<StatModifier> statModifiers = val3.statModifiers;
float num = 0f;
float num2 = 0f;
float num3 = 0f;
for (int m = 0; m < statModifiers.Count; m++)
{
StatModifier val4 = statModifiers[m];
if (val4 != null)
{
int num4 = *(int*)(void*)(((Il2CppObjectBase)val4).Pointer + 16);
float num5 = *(float*)(void*)(((Il2CppObjectBase)val4).Pointer + 24);
switch (num4)
{
case 25:
num += num5;
break;
case 26:
num2 += num5;
break;
case 29:
num3 += num5;
break;
}
}
}
float num6 = 0.2f - num;
float value = 3f - num2;
float value2 = 5f - num3;
if (num6 > 0.001f)
{
AppendFlat(val3.statModifiers, (EStat)25, num6);
}
if (Math.Abs(value) > 0.001f)
{
AppendFlat(val3.statModifiers, (EStat)26, value);
}
if (Math.Abs(value2) > 0.001f)
{
AppendFlat(val3.statModifiers, (EStat)29, value2);
}
float num7 = 0f;
for (int n = 0; n < statModifiers.Count; n++)
{
StatModifier val5 = statModifiers[n];
if (val5 != null && *(int*)(void*)(((Il2CppObjectBase)val5).Pointer + 16) == 2)
{
num7 += *(float*)(void*)(((Il2CppObjectBase)val5).Pointer + 24);
}
}
if (num7 < 1f)
{
AppendFlat(val3.statModifiers, (EStat)2, 10f);
}
}
}
EWeapon[] array4 = (EWeapon[])(object)new EWeapon[2]
{
(EWeapon)6,
(EWeapon)3
};
foreach (EWeapon val6 in array4)
{
WeaponData weapon = __instance.GetWeapon(val6);
object obj;
if (weapon == null)
{
obj = null;
}
else
{
UpgradeData upgradeData2 = weapon.upgradeData;
obj = ((upgradeData2 != null) ? upgradeData2.upgradeModifiers : null);
}
if (obj == null)
{
continue;
}
bool flag = false;
for (int num8 = 0; num8 < weapon.upgradeData.upgradeModifiers.Count; num8++)
{
StatModifier val7 = weapon.upgradeData.upgradeModifiers[num8];
if (val7 != null && (int)val7.stat == 16)
{
val7.modification = 2f;
flag = true;
break;
}
}
if (!flag)
{
AddUpgradeStat(weapon.upgradeData.upgradeModifiers, (EStat)16, 2f);
}
}
try
{
IntPtr intPtr = IL2CPP.il2cpp_class_from_name(IL2CPP.il2cpp_class_get_image(IL2CPP.il2cpp_object_get_class(((Il2CppObjectBase)__instance).Pointer)), "Assets.Scripts.Game.Combat", "CombatScaling");
if (intPtr != IntPtr.Zero)
{
IntPtr intPtr2 = *(IntPtr*)(void*)(intPtr + 184);
if (intPtr2 != IntPtr.Zero)
{
*(float*)(void*)(intPtr2 + 12) = 0f;
}
}
}
catch
{
}
foreach (EItem forcedPoolItem in Plugin.ForcedPoolItems)
{
ItemData item19 = __instance.GetItem(forcedPoolItem);
if ((Object)(object)item19 != (Object)null)
{
item19.inItemPool = true;
((UnlockableBase)item19).isEnabled = true;
}
}
}
private unsafe static void RemoveStat(List<StatModifier> mods, int statInt)
{
for (int num = mods.Count - 1; num >= 0; num--)
{
StatModifier val = mods[num];
if (val != null && *(int*)(void*)(((Il2CppObjectBase)val).Pointer + 16) == statInt)
{
mods.RemoveAt(num);
}
}
}
private static void AppendFlat(List<StatModifier> mods, EStat stat, float value)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
StatModifier val = new StatModifier();
val.stat = stat;
val.modifyType = (EStatModifyType)2;
val.modification = value;
mods.Add(val);
}
private static void AddUpgradeStat(List<StatModifier> mods, EStat stat, float modification)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < mods.Count; i++)
{
if (mods[i].stat == stat)
{
return;
}
}
StatModifier val = new StatModifier();
val.stat = stat;
val.modifyType = (EStatModifyType)2;
val.modification = modification;
mods.Add(val);
}
}
[HarmonyPatch(typeof(InteractableChest), "Start")]
internal static class Patch_Chest_MinimapIcon
{
[HarmonyPostfix]
private static void Postfix(InteractableChest __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Invalid comparison between Unknown and I4
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
//IL_0062: 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_0074: Unknown result type (might be due to invalid IL or missing references)
Color color = default(Color);
if ((int)__instance.chestType == 0)
{
((Color)(ref color))..ctor(0.55f, 0.28f, 0.08f);
}
else
{
if ((int)__instance.chestType != 2 && (int)__instance.chestType != 3)
{
return;
}
((Color)(ref color))..ctor(1f, 0.85f, 0.1f);
}
Transform icon = __instance.icon;
if (!((Object)(object)icon == (Object)null))
{
IconColorHelper.ApplyColor(((Component)icon).gameObject, color);
icon.localScale *= 0.5f;
}
}
}
[HarmonyPatch(typeof(InteractableMicrowave), "Start")]
internal static class Patch_Microwave_Start
{
[HarmonyPostfix]
private static void Postfix(InteractableMicrowave __instance)
{
MicrowaveIconHelper.ApplyMicrowaveColor(__instance, scaleDown: true);
}
}
[HarmonyPatch(typeof(InteractableMicrowave), "set_rarity")]
internal static class Patch_Microwave_SetRarity
{
[HarmonyPostfix]
private static void Postfix(InteractableMicrowave __instance)
{
MicrowaveIconHelper.ApplyMicrowaveColor(__instance);
}
}
internal static class MicrowaveIconHelper
{
private const int MinimapIconOffset = 216;
internal unsafe static void ApplyMicrowaveColor(InteractableMicrowave instance, bool scaleDown = false)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
GameObject val = instance.minimapIcon;
if ((Object)(object)val == (Object)null)
{
IntPtr intPtr = *(IntPtr*)(void*)(((Il2CppObjectBase)instance).Pointer + 216);
if (intPtr == IntPtr.Zero)
{
return;
}
val = new GameObject(intPtr);
}
IconColorHelper.ApplyColor(val, IconColorHelper.MicrowaveRarityColor(instance.rarity));
if (scaleDown)
{
Transform transform = val.transform;
transform.localScale *= 0.5f;
}
}
}
internal static class IconColorHelper
{
internal static Color MicrowaveRarityColor(EItemRarity rarity)
{
//IL_0000: 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_0014: Expected I4, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
return (Color)((rarity - 1) switch
{
0 => new Color(0.5f, 0.75f, 1f),
1 => new Color(0.8f, 0.6f, 1f),
2 => new Color(1f, 0.95f, 0.6f),
_ => Color.white,
});
}
internal static Color ShadyGuyRarityColor(EItemRarity rarity)
{
//IL_0000: 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_0014: Expected I4, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_0070: 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_006f: Unknown result type (might be due to invalid IL or missing references)
return (Color)((rarity - 1) switch
{
0 => new Color(0.1f, 0.25f, 0.7f),
1 => new Color(0.35f, 0.05f, 0.6f),
2 => new Color(0.7f, 0.5f, 0.05f),
_ => new Color(0.6f, 0.6f, 0.6f),
});
}
internal static void ApplyColor(GameObject go, Color color)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
Renderer val = go.GetComponent<Renderer>();
if ((Object)(object)val == (Object)null)
{
val = go.GetComponentInChildren<Renderer>();
}
if (!((Object)(object)val == (Object)null))
{
Material material = val.material;
material.mainTexture = (Texture)(object)Texture2D.whiteTexture;
material.color = color;
}
}
}
[HarmonyPatch(typeof(BaseInteractable), "Start")]
internal static class Patch_BaseInteractable_Start
{
[HarmonyPostfix]
private static void Postfix(BaseInteractable __instance)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: 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)
InteractableShrineCursed val = ((Il2CppObjectBase)__instance).TryCast<InteractableShrineCursed>();
if ((Object)(object)val != (Object)null)
{
ApplyShrineColor(val.minimapIcon, 88, ((Il2CppObjectBase)val).Pointer, new Color(1f, 0.4f, 0.4f));
return;
}
InteractableShrineChallenge val2 = ((Il2CppObjectBase)__instance).TryCast<InteractableShrineChallenge>();
if ((Object)(object)val2 != (Object)null)
{
ApplyShrineColor(val2.minimapIcon, 88, ((Il2CppObjectBase)val2).Pointer, new Color(1f, 0.4f, 0.7f));
return;
}
InteractableShrineMagnet val3 = ((Il2CppObjectBase)__instance).TryCast<InteractableShrineMagnet>();
if ((Object)(object)val3 != (Object)null)
{
ApplyShrineColor(val3.minimapIcon, 88, ((Il2CppObjectBase)val3).Pointer, Color.black);
}
}
private unsafe static void ApplyShrineColor(GameObject icon, int offset, IntPtr ptr, Color color)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
if ((Object)(object)icon == (Object)null)
{
IntPtr intPtr = *(IntPtr*)(void*)(ptr + offset);
if (intPtr == IntPtr.Zero)
{
return;
}
icon = new GameObject(intPtr);
}
IconColorHelper.ApplyColor(icon, color);
Transform transform = icon.transform;
transform.localScale *= 0.5f;
}
}
[HarmonyPatch(typeof(InteractableShadyGuy), "Start")]
internal static class Patch_ShadyGuy_Start
{
[HarmonyPostfix]
private static void Postfix(InteractableShadyGuy __instance)
{
//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_0053: Unknown result type (might be due to invalid IL or missing references)
Transform parent = ((Component)__instance).transform.parent;
if ((Object)(object)parent == (Object)null)
{
return;
}
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
if (((Component)child).gameObject.layer == 14)
{
IconColorHelper.ApplyColor(((Component)child).gameObject, IconColorHelper.ShadyGuyRarityColor(__instance.rarity));
child.localScale *= 0.5f;
break;
}
}
}
}
[HarmonyPatch]
internal static class Patch_MicrowaveSpawnCount
{
private static MethodBase TargetMethod()
{
return AccessTools.Method(typeof(RandomObjectPlacer), "RandomObjectSpawner", new Type[2]
{
typeof(RandomMapObject),
typeof(float)
}, (Type[])null);
}
[HarmonyPrefix]
private static void Prefix(RandomMapObject randomObject)
{
if (((randomObject != null) ? randomObject.prefabs : null) == null)
{
return;
}
foreach (GameObject item in (Il2CppArrayBase<GameObject>)(object)randomObject.prefabs)
{
if (!((Object)(object)item == (Object)null) && ((Object)item).name.IndexOf("Microwave", StringComparison.OrdinalIgnoreCase) >= 0)
{
randomObject.amount = 2;
randomObject.maxAmount = 3;
break;
}
}
}
}
[HarmonyPatch(typeof(InteractableShrineGreed), "Interact")]
internal static class Patch_ShrineGreed_Stats
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("MegaBonkMod.ShrineGreed");
private static bool _wasNotDone;
[HarmonyPrefix]
private static void Prefix(InteractableShrineGreed __instance)
{
_wasNotDone = !__instance.done;
}
[HarmonyPostfix]
private static void Postfix(InteractableShrineGreed __instance)
{
if (_wasNotDone && __instance.done)
{
Apply((EStat)32, 0.05f, (EStatModifyType)0);
Apply((EStat)30, 0.05f, (EStatModifyType)2);
}
}
private static void Apply(EStat stat, float amount, EStatModifyType modType = 2)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0070: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
try
{
StatModifier val = new StatModifier();
val.stat = stat;
val.modifyType = modType;
val.modification = amount;
new EffectStat
{
effectType = (EEncounterEffect)0,
statModifier = val,
permanent = true
}.ApplyEffect();
try
{
UiManager instance = UiManager.Instance;
if (instance != null)
{
ScoreUi scoreUi = instance.scoreUi;
if (scoreUi != null)
{
scoreUi.AddScore(val, true, true, 1f);
}
}
}
catch
{
}
}
catch (Exception ex)
{
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(14, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Apply ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<EStat>(stat);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" threw: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
Log.LogError(val2);
}
}
}
[HarmonyPatch(typeof(InteractablePot), "SpawnStuff")]
internal static class Patch_InteractablePot_SpawnStuff
{
private static readonly EPickup[] Powerups;
[HarmonyPrefix]
private static void Prefix(ref EPickup ePickup)
{
if ((int)ePickup == 2)
{
ePickup = Powerups[Random.Range(0, Powerups.Length)];
}
}
static Patch_InteractablePot_SpawnStuff()
{
EPickup[] array = new EPickup[8];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
Powerups = (EPickup[])(object)array;
}
}
[HarmonyPatch(typeof(PlayerHealth), "OnPickup")]
internal static class Patch_PlayerHealth_OnPickup_FullHeal
{
[HarmonyPrefix]
private static bool Prefix(PlayerHealth __instance, Pickup pickup)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
if ((Object)(object)pickup == (Object)null || (int)pickup.ePickup != 2)
{
return true;
}
__instance.Heal((float)__instance.maxHp, false);
return false;
}
}
[HarmonyPatch(typeof(ItemInventory), "AddItem", new Type[]
{
typeof(EItem),
typeof(int)
})]
internal static class Patch_GoldenRing_Add
{
[HarmonyPostfix]
private static void Postfix(EItem eItem, int count)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)eItem != 79)
{
return;
}
try
{
PlayerInventory playerInventory = MapController.GetPlayerInventory((CharacterData)null);
if (playerInventory != null)
{
playerInventory.banishes += count;
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(ItemInventory), "RemoveItem", new Type[]
{
typeof(EItem),
typeof(bool)
})]
internal static class Patch_GoldenRing_Remove
{
[HarmonyPostfix]
private static void Postfix(EItem eItem)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)eItem != 79)
{
return;
}
try
{
PlayerInventory playerInventory = MapController.GetPlayerInventory((CharacterData)null);
if (playerInventory != null)
{
playerInventory.banishes = Math.Max(0, playerInventory.banishes - 1);
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(ItemEchoShard), "GetExtraShards")]
internal static class Patch_EchoShard_Overflow
{
[HarmonyPostfix]
private static void Postfix(ItemEchoShard __instance, ref int __result)
{
float chance = __instance.chance;
if (!(chance <= 1f))
{
int num = (int)chance;
float num2 = chance - (float)num;
__result = num + ((Random.value < num2) ? 1 : 0);
}
}
}
[HarmonyPatch(typeof(Leaderboards), "UploadScore")]
internal static class Patch_Leaderboard_UploadScore_Entry
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("MegaBonkMod.LbUpload");
private static int _lastScore;
private static float _lastTime = -999f;
[HarmonyPrefix]
private unsafe static bool Prefix(int score)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
try
{
if (score == _lastScore && Time.realtimeSinceStartup - _lastTime < 5f)
{
return false;
}
_lastScore = score;
_lastTime = Time.realtimeSinceStartup;
int character = 0;
PlayerMovement instance = PlayerMovement.Instance;
if ((Object)(object)instance != (Object)null)
{
character = *(int*)(void*)(((Il2CppObjectBase)instance).Pointer + 440);
}
LeaderboardRelay.SendBothBoards(score, character);
}
catch (Exception ex)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(16, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Capture failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
Log.LogWarning(val);
}
return false;
}
}
[HarmonyPatch(typeof(SteamLeaderboardsManagerNew), "QueueLeaderboardUpload")]
internal static class Patch_Leaderboard_Queue
{
[HarmonyPrefix]
private static bool Prefix()
{
return false;
}
}
[HarmonyPatch(typeof(EffectManager), "SpawnTornadoes")]
internal static class Patch_DisableTornadoes
{
[HarmonyPrefix]
private static bool Prefix()
{
return false;
}
}
[HarmonyPatch(typeof(SteamLeaderboardsManagerNew), "UploadLeaderboardScore")]
internal static class Patch_Leaderboard_UploadDirect
{
[HarmonyPrefix]
private static bool Prefix()
{
return false;
}
}
[HarmonyPatch(typeof(Leaderboards), "CanShowScore")]
internal static class Patch_CanShowScore
{
[HarmonyPrefix]
private static bool Prefix(int score, ref string s, ref bool __result)
{
s = score.ToString("N0");
__result = true;
return false;
}
}
[HarmonyPatch(typeof(SteamLeaderboardsManagerNew), "DownloadLeaderboardEntries")]
internal static class Patch_Leaderboard_Download
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("MegaBonkMod.LbDownload");
[HarmonyPrefix]
private static bool Prefix(string lbName)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
if (!LeaderboardRelay.Enabled)
{
return true;
}
SteamLeaderboardNew val = FindBoard(lbName);
if (val != null)
{
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(42, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Starting fetch for board '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(val.lbName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' (requested '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(lbName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("')");
}
Log.LogInfo(val2);
LeaderboardInjector.BeginFetch(val);
}
return true;
}
internal static SteamLeaderboardNew FindBoard(string lbName)
{
SteamLeaderboardNew leaderboardKillsAllTime = SteamLeaderboardsManagerNew.leaderboardKillsAllTime;
SteamLeaderboardNew leaderboardKillsWeekly = SteamLeaderboardsManagerNew.leaderboardKillsWeekly;
if (leaderboardKillsAllTime != null && (leaderboardKillsAllTime.lbName == lbName || leaderboardKillsAllTime.lbNameFriends == lbName))
{
return leaderboardKillsAllTime;
}
if (leaderboardKillsWeekly != null && (leaderboardKillsWeekly.lbName == lbName || leaderboardKillsWeekly.lbNameFriends == lbName))
{
return leaderboardKillsWeekly;
}
return null;
}
}
[HarmonyPatch(typeof(SteamLeaderboardNew), "OnDownloadResultsGlobal")]
internal static class Patch_OnDownloadResultsGlobal
{
[HarmonyPostfix]
private static void Postfix(SteamLeaderboardNew __instance)
{
if (LeaderboardRelay.Enabled)
{
LeaderboardInjector.ReplaceEntriesIfReady(__instance);
}
}
}
[HarmonyPatch(typeof(SteamLeaderboardNew), "OnDownloadResultsFriends")]
internal static class Patch_OnDownloadResultsFriends
{
[HarmonyPostfix]
private static void Postfix(SteamLeaderboardNew __instance)
{
if (!LeaderboardRelay.Enabled)
{
return;
}
SteamLeaderboardNew leaderboardKillsAllTime = SteamLeaderboardsManagerNew.leaderboardKillsAllTime;
SteamLeaderboardNew leaderboardKillsWeekly = SteamLeaderboardsManagerNew.leaderboardKillsWeekly;
if (__instance == leaderboardKillsAllTime || __instance == leaderboardKillsWeekly)
{
LeaderboardInjector.ServerEntry[] cachedEntries = LeaderboardInjector.CachedEntries;
if (cachedEntries != null && cachedEntries.Length != 0)
{
__instance.friendsEntries = LeaderboardInjector.BuildFriendsList(cachedEntries);
}
}
}
}
internal static class LeaderboardRelay
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("MegaBonkMod.Leaderboard");
private static string Base => Plugin.LeaderboardServer.TrimEnd('/');
internal static bool Enabled => !string.IsNullOrEmpty(Plugin.LeaderboardServer);
internal static void SendBothBoards(int score, int character)
{
Send("kills", score, character);
}
internal static void Send(string board, int score, int character)
{
if (!Enabled)
{
return;
}
Task.Run<Task>((Func<Task>)async delegate
{
bool flag = default(bool);
try
{
ulong steamID = SteamUser.GetSteamID().m_SteamID;
string name = SteamFriends.GetPersonaName();
string content = $"{{\"board\":\"{board}\",\"score\":{score},\"steamId\":\"{steamID}\",\"name\":{JsonSerializer.Serialize(name)},\"characterIndex\":{character},\"modVersion\":\"{"1.3.10"}\",\"timestamp\":{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}}}";
using HttpClient client = new HttpClient
{
Timeout = TimeSpan.FromSeconds(5.0)
};
StringContent content2 = new StringContent(content, Encoding.UTF8, "application/json");
await client.PostAsync(Base + "/submit", content2);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Submitted score ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(score);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" char=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(character);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" on '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(board);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' as ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
}
Log.LogInfo(val);
}
catch (Exception ex)
{
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Leaderboard server unreachable: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
Log.LogWarning(val2);
}
});
}
internal static async Task<string> FetchEntries(string board, int count = 20)
{
if (!Enabled)
{
return "";
}
try
{
using HttpClient client = new HttpClient
{
Timeout = TimeSpan.FromSeconds(5.0)
};
return await client.GetStringAsync($"{Base}/entries?board={Uri.EscapeDataString(board)}&count={count}");
}
catch
{
return "";
}
}
}
[HarmonyPatch(typeof(ProjectileBluetooth), "HitTarget")]
internal static class Patch_BT_HitTarget_ElementFix
{
internal static bool Active;
[HarmonyPrefix]
private static void Prefix()
{
Active = true;
}
[HarmonyPostfix]
private static void Postfix()
{
Active = false;
}
}
[HarmonyPatch]
internal static class Patch_GetDamageContainer_BluetoothFix
{
private static MethodBase TargetMethod()
{
return AccessTools.Method(typeof(WeaponUtility), "GetDamageContainer", new Type[5]
{
typeof(WeaponBase),
AccessTools.TypeByName("ProjectileBase"),
AccessTools.TypeByName("Enemy"),
typeof(Vector3),
typeof(float)
}, (Type[])null);
}
[HarmonyPostfix]
private static void Postfix(DamageContainer __result)
{
if (Patch_BT_HitTarget_ElementFix.Active && __result != null)
{
__result.element = (EElement)1;
}
}
}
internal static class LeaderboardInjector
{
internal class ServerEntry
{
[JsonPropertyName("score")]
public int Score { get; set; }
[JsonPropertyName("steamId")]
public string SteamId { get; set; } = "";
[JsonPropertyName("name")]
public string Name { get; set; } = "";
[JsonPropertyName("characterIndex")]
public int CharacterIndex { get; set; }
}
private static readonly ManualLogSource Log = Logger.CreateLogSource("MegaBonkMod.LbInject");
private static volatile ServerEntry[] _cache = null;
private static volatile bool _fetching = false;
private static volatile SteamLeaderboardNew _pending = null;
internal static ServerEntry[] CachedEntries => _cache;
internal static bool IsFetching => _fetching;
internal static void BeginFetch(SteamLeaderboardNew lb)
{
if (_fetching)
{
return;
}
_fetching = true;
Task.Run<Task>((Func<Task>)async delegate
{
try
{
ServerEntry[] entries = Parse(await LeaderboardRelay.FetchEntries("kills", 50));
ModGui.MainThread.Enqueue(delegate
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
_cache = entries;
_fetching = false;
bool flag2 = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Fetch 'kills' complete: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(entries.Length);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" entries");
}
Log.LogInfo(val2);
SteamLeaderboardNew pending = _pending;
_pending = null;
if (pending != null && entries.Length != 0)
{
Replace(pending, entries);
}
});
}
catch (Exception ex)
{
_fetching = false;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Fetch 'kills' error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
Log.LogError(val);
}
});
}
internal static void ReplaceEntriesIfReady(SteamLeaderboardNew lb)
{
SteamLeaderboardNew leaderboardKillsAllTime = SteamLeaderboardsManagerNew.leaderboardKillsAllTime;
SteamLeaderboardNew leaderboardKillsWeekly = SteamLeaderboardsManagerNew.leaderboardKillsWeekly;
if (lb == leaderboardKillsAllTime || lb == leaderboardKillsWeekly)
{
if (_cache != null)
{
Replace(lb, _cache);
}
else
{
_pending = lb;
}
}
}
private static void Replace(SteamLeaderboardNew lb, ServerEntry[] entries)
{
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
for (int i = 0; i < entries.Length; i++)
{
if (ulong.TryParse(entries[i].SteamId, out var result) && result != 0L)
{
SteamFriends.RequestUserInformation(new CSteamID(result), true);
}
}
lb.globalEntries = BuildList(entries);
lb.friendsEntries = BuildFriendsList(entries);
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(64, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Replaced global(");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(entries.Length);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") + friends(");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(lb.friendsEntries.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") on '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(lb.lbName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("', invoking A_LeaderboardReady");
}
Log.LogInfo(val);
try
{
Action<SteamLeaderboardNew> a_LeaderboardReady = SteamLeaderboardNew.A_LeaderboardReady;
if ((Delegate)(object)a_LeaderboardReady == (Delegate)null)
{
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("A_LeaderboardReady is null for '");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(lb.lbName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
}
Log.LogWarning(val2);
return;
}
a_LeaderboardReady.Invoke(lb);
val = new BepInExInfoLogInterpolatedStringHandler(36, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("A_LeaderboardReady invoked OK for '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(lb.lbName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
}
Log.LogInfo(val);
}
catch (Exception ex)
{
BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(28, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("A_LeaderboardReady threw ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.GetType().Name);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("\n");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.StackTrace);
}
Log.LogError(val3);
}
}
internal static List<LeaderboardEntry> BuildList(ServerEntry[] entries)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
List<LeaderboardEntry> val = new List<LeaderboardEntry>();
if (entries == null)
{
return val;
}
for (int i = 0; i < entries.Length; i++)
{
ServerEntry serverEntry = entries[i];
ulong result;
ulong num = (ulong.TryParse(serverEntry.SteamId, out result) ? result : 0);
int[] array = new int[64];
array[1] = serverEntry.CharacterIndex;
LeaderboardEntry_t val2 = default(LeaderboardEntry_t);
val2.m_steamIDUser = new CSteamID(num);
val2.m_nGlobalRank = i + 1;
val2.m_nScore = serverEntry.Score;
val2.m_cDetails = array.Length;
LeaderboardEntry_t val3 = val2;
val.Add(new LeaderboardEntry(val3, Il2CppStructArray<int>.op_Implicit(array)));
}
return val;
}
private static HashSet<ulong> GetSteamFriendIds()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
HashSet<ulong> hashSet = new HashSet<ulong>();
try
{
hashSet.Add(SteamUser.GetSteamID().m_SteamID);
int friendCount = SteamFriends.GetFriendCount((EFriendFlags)4);
for (int i = 0; i < friendCount; i++)
{
hashSet.Add(SteamFriends.GetFriendByIndex(i, (EFriendFlags)4).m_SteamID);
}
}
catch (Exception ex)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(19, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("GetSteamFriendIds: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
Log.LogWarning(val);
}
return hashSet;
}
internal static List<LeaderboardEntry> BuildFriendsList(ServerEntry[] entries)
{
HashSet<ulong> steamFriendIds = GetSteamFriendIds();
List<ServerEntry> list = new List<ServerEntry>();
foreach (ServerEntry serverEntry in entries)
{
if (ulong.TryParse(serverEntry.SteamId, out var result) && steamFriendIds.Contains(result))
{
list.Add(serverEntry);
}
}
return BuildList(list.ToArray());
}
private static ServerEntry[] Parse(string json)
{
if (string.IsNullOrEmpty(json) || json == "[]")
{
return new ServerEntry[0];
}
try
{
return JsonSerializer.Deserialize<ServerEntry[]>(json) ?? new ServerEntry[0];
}
catch
{
return new ServerEntry[0];
}
}
}
[HarmonyPatch(typeof(ItemCreditCardGreen), "OnInitOrAmountChanged")]
internal static class Patch_CreditCardGreen_ChestCost
{
[HarmonyPostfix]
private static void Postfix(ItemCreditCardGreen __instance)
{
__instance.chestPriceIncreasePerAmount = 0.02f;
}
}
[HarmonyPatch(typeof(ItemCreditCardGreen), "GetDescription")]
internal static class Patch_CreditCardGreen_Desc
{
[HarmonyPostfix]
private static void Postfix(ref string __result)
{
if (__result != null)
{
__result = __result.Replace("10%", "2%").Replace("10 %", "2%");
}
}
}
[HarmonyPatch(typeof(ItemBase), "GetDescription")]
internal static class Patch_Backpack_Desc
{
[HarmonyPostfix]
private static void Postfix(ref string __result)
{
if (__result != null)
{
__result = __result.Replace("+1 Projectile Count", "+2 Projectile Count").Replace("+1 projectile count", "+2 projectile count");
}
}
}
[HarmonyPatch(typeof(ItemCursedDoll), "OnInitOrAmountChanged")]
internal static class Patch_CursedDoll_Buff
{
[HarmonyPostfix]
private unsafe static void Postfix(ItemCursedDoll __instance)
{
IntPtr pointer = ((Il2CppObjectBase)__instance).Pointer;
int num = *(int*)(void*)(pointer + 24);
*(float*)(void*)(pointer + 52) = 0.5f;
*(int*)(void*)(pointer + 56) = 7;
*(int*)(void*)(pointer + 48) = 7 * num;
}
}
[HarmonyPatch(typeof(ItemCursedDoll), "GetDescription")]
internal static class Patch_CursedDoll_Desc
{
[HarmonyPostfix]
private static void Postfix(ref string __result)
{
if (__result != null)
{
__result = __result.Replace("30%", "50%").Replace("30 %", "50%");
}
}
}
[HarmonyPatch(typeof(SaveManager), "Init")]
internal static class Patch_SaveManager_Init_LockUploadOff
{
[HarmonyPostfix]
private static void Postfix(SaveManager __instance)
{
SteamUploadLocker.ForceOff(__instance);
}
}
[HarmonyPatch(typeof(SaveManager), "SaveConfig")]
internal static class Patch_SaveManager_SaveConfig_LockUploadOff
{
[HarmonyPrefix]
private static void Prefix(SaveManager __instance)
{
SteamUploadLocker.ForceOff(__instance);
}
}
internal static class SteamUploadLocker
{
internal const string FieldName = "upload_score_to_leaderboard";
internal unsafe static void ForceOff(SaveManager sm)
{
if ((Object)(object)sm == (Object)null)
{
return;
}
IntPtr pointer = ((Il2CppObjectBase)sm).Pointer;
if (pointer == IntPtr.Zero)
{
return;
}
IntPtr intPtr = *(IntPtr*)(void*)(pointer + 32);
if (!(intPtr == IntPtr.Zero))
{
IntPtr intPtr2 = *(IntPtr*)(void*)(intPtr + 24);
if (!(intPtr2 == IntPtr.Zero))
{
*(int*)(void*)(intPtr2 + 68) = 0;
}
}
}
}
[HarmonyPatch(typeof(BetterSetting), "SetSetting")]
internal static class Patch_BetterSetting_SetSetting_DisableUpload
{
[HarmonyPostfix]
private static void Postfix(BetterSetting __instance, string settingName)
{
if (!(settingName != "upload_score_to_leaderboard"))
{
TextMeshProUGUI t_disabledText = __instance.t_disabledText;
if ((Object)(object)t_disabledText != (Object)null)
{
((TMP_Text)t_disabledText).text = "Disabled";
}
GameObject disabledOverlay = __instance.disabledOverlay;
if ((Object)(object)disabledOverlay != (Object)null)
{
disabledOverlay.SetActive(true);
}
}
}
}
[HarmonyPatch(typeof(CurrentSettings), "BetterUpdateCfSettings")]
internal static class Patch_CurrentSettings_BetterUpdateCfSettings_BlockUpload
{
[HarmonyPrefix]
private static bool Prefix(string settingName)
{
return settingName != "upload_score_to_leaderboard";
}
}
[HarmonyPatch(typeof(PassiveAbilityZooma), "Init")]
internal static class Patch_Zooma_Init_Projectiles
{
private static readonly MethodInfo _setStat = AccessTools.Method(typeof(PassiveAbility), "SetStat", (Type[])null, (Type[])null);
private static Action<int> _handler;
[HarmonyPostfix]
private static void Postfix(PassiveAbilityZooma __instance)
{
if (_handler != null)
{
PlayerXp.A_LevelUp -= Action<int>.op_Implicit(_handler);
}
_handler = delegate(int level)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
try
{
StatModifier val = new StatModifier();
val.stat = (EStat)16;
val.modifyType = (EStatModifyType)2;
val.modification = 0.25f * (float)level;
_setStat.Invoke(__instance, new object[1] { val });
}
catch
{
}
};
PlayerXp.A_LevelUp += Action<int>.op_Implicit(_handler);
}
}
[HarmonyPatch(typeof(ItemGoldenShield), "OnPlayerTakeDamage")]
internal static class Patch_GoldenShield_NoKevinReduction
{
[HarmonyPrefix]
private static void Prefix(DamageContainer dc)
{
if (dc != null && dc.damageSource == ItemKevin.damageSource)
{
dc.damageSource = "";
}
}
}
[HarmonyPatch(typeof(MainMenu), "Start")]
internal static class Patch_MainMenu_Start_Version
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("MegaBonkMod.Version");
[HarmonyPostfix]
private static void Postfix()
{
ModGui.MainThread.Enqueue(delegate
{
ModGui.NeedVersionPatch = true;
});
CheckVersionAsync();
}
private static void CheckVersionAsync()
{
Task.Run<Task>((Func<Task>)async delegate
{
bool flag = default(bool);
try
{
using HttpClient client = new HttpClient
{
Timeout = TimeSpan.FromSeconds(5.0)
};
using JsonDocument jsonDocument = JsonDocument.Parse(await client.GetStringAsync(Plugin.LeaderboardServer.TrimEnd('/') + "/version"));
if (jsonDocument.RootElement.TryGetProperty("required", out var value))
{
string text = value.GetString() ?? "";
if (!string.IsNullOrEmpty(text) && text != "1.3.10")
{
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Mod outdated: local=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.3.10");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" required=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
}
Log.LogWarning(val);
ModGui.MainThread.Enqueue(delegate
{
ModGui.UpdateAvailable = true;
});
}
else
{
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Mod version OK (");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.3.10");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
}
Log.LogInfo(val2);
}
}
}
catch (Exception ex)
{
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Version check failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
Log.LogWarning(val);
}
});
}
}
[HarmonyPatch(typeof(GameOverDamageSourcesUi), "Start")]
internal static class Patch_GameOverDamageSourcesUi_Start
{
[HarmonyPrefix]
private static void Prefix()
{
GameObject val = GameObject.Find("GameUI/GameUI/DeathScreen/StatsWindows/W_Damage/WindowLayers/Content/ScrollRect/ContentEntries");
if (!((Object)(object)val == (Object)null))
{
Transform transform = val.transform;
for (int num = transform.childCount - 1; num >= 3; num--)
{
Object.Destroy((Object)(object)((Component)transform.GetChild(num)).gameObject);
}
}
}
}
[HarmonyPatch(typeof(GameManager), "StartPlaying")]
internal static class Patch_GameManager_StartPlaying_Chart
{
[HarmonyPostfix]
private static void Postfix()
{
ModGui.ChartDisabled = false;
Object.FindObjectOfType<ModGui>()?.ResetChartCache();
}
}
[HarmonyPatch(typeof(GameManager), "OnDied")]
internal static class Patch_GameManager_OnDied_Chart
{
[HarmonyPostfix]
private static void Postfix()
{
ModGui.ChartDisabled = true;
}
}
[HarmonyPatch(typeof(CombatScaling), "GetStageHpMultiplier")]
internal static class Patch_CombatScaling_HpMultiplier
{
[HarmonyPostfix]
private static void Postfix(ref float __result)
{
__result = 2f * __result - 1f;
}
}
[HarmonyPatch(typeof(CombatScaling), "GetStageDamageMultiplier")]
internal static class Patch_CombatScaling_DamageMultiplier
{
[HarmonyPostfix]
private static void Postfix(ref float __result)
{
__result = 2f * __result - 1f;
}
}
[BepInPlugin("com.megabonk.mod", "MegaBonk Mod", "1.3.10")]
public class Plugin : BasePlugin
{
internal static string LeaderboardServer = "http://67.5.111.0:9000";
internal const string ModVersion = "1.3.10";
internal const bool PatchGrandmasTonic = true;
internal static readonly HashSet<EItem> ActiveUncappedItems = new HashSet<EItem>
{
(EItem)41,
(EItem)26,
(EItem)25
};
internal static readonly HashSet<EItem> ForcedPoolItems = new HashSet<EItem>
{
(EItem)7,
(EItem)38,
(EItem)82,
(EItem)55,
(EItem)19,
(EItem)56,
(EItem)33
};
internal static readonly HashSet<int> BlacklistedStats = new HashSet<int>
{
0, 1, 2, 3, 4, 5, 10, 11, 24, 25,
29
};
internal static readonly HashSet<int> BlacklistedShrineStats = new HashSet<int>
{
0, 1, 2, 3, 4, 5, 10, 11, 24, 25,
29
};
internal static readonly List<int> FullStatPool = new List<int>();
internal static readonly List<int> FullShrineStatPool = new List<int>();
internal static ManualLogSource Log { get; private set; }
public override void Load()
{
//IL_003e: 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_006e: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
LeaderboardServer = ((BasePlugin)this).Config.Bind<string>("Leaderboard", "ServerUrl", "http://67.5.111.0:9000", "DO NOT CHANGE THIS. Only modify if you are the server host running locally (use http://localhost:9000).").Value;
ClassInjector.RegisterTypeInIl2Cpp<ModGui>();
new Harmony("com.megabonk.mod").PatchAll(typeof(Plugin).Assembly);
((BasePlugin)this).AddComponent<ModGui>();
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MegaBonkMod] Loaded. Server=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LeaderboardServer);
}
log.LogInfo(val);
}
internal static int GetItemCap(EItem item)
{
//IL_0000: 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_0008: Invalid comparison between Unknown and I4
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
if ((int)item != 25)
{
if ((int)item != 26)
{
if ((int)item == 41)
{
return 2;
}
return 5;
}
return 3;
}
return 10;
}
}
internal static class SpaceNoodleState
{
internal static readonly Dictionary<IntPtr, Vector3[]> ExtraTargetPos = new Dictionary<IntPtr, Vector3[]>();
internal static readonly Dictionary<IntPtr, List<LineRenderer>> ExtraRenderers = new Dictionary<IntPtr, List<LineRenderer>>();
internal static readonly Collider[] Buf = (Collider[])(object)new Collider[64];
internal static MethodInfo HitEnemyMi;
}
[HarmonyPatch(typeof(LaserBeamAttack), "FixedUpdate")]
internal static class Patch_SpaceNoodle_ExtraPhysics
{
private unsafe static void Postfix(LaserBeamAttack __instance)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: 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_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
if (((ConstantAttack)__instance).weaponBase == null)
{
return;
}
int num = WeaponUtility.GetAttackQuantity(((ConstantAttack)__instance).weaponBase) - 1;
IntPtr pointer = ((Il2CppObjectBase)__instance).Pointer;
byte num2 = *(byte*)(void*)(((Il2CppObjectBase)__instance).Pointer + 100);
nint num3 = *(nint*)(void*)(((Il2CppObjectBase)__instance).Pointer + 80);
if (num2 == 0 || num <= 0 || num3 == 0)
{
SpaceNoodleState.ExtraTargetPos[pointer] = Array.Empty<Vector3>();
return;
}
GameManager instance = GameManager.Instance;
if ((Object)(object)((instance != null) ? instance.player : null) == (Object)null)
{
return;
}
HashSet<IntPtr> hashSet = new HashSet<IntPtr>();
if (num3 != ((Il2CppObjectBase)__instance).Pointer)
{
IntPtr intPtr = *(IntPtr*)(num3 + 80);
if (intPtr != (IntPtr)0)
{
hashSet.Add(intPtr);
}
}
int num4 = Physics.OverlapSphereNonAlloc(((Component)instance.player).transform.position, 30f, Il2CppReferenceArray<Collider>.op_Implicit(SpaceNoodleState.Buf), LayerMask.op_Implicit(instance.whatIsEnemy));
if ((object)SpaceNoodleState.HitEnemyMi == null)
{
SpaceNoodleState.HitEnemyMi = AccessTools.Method(typeof(LaserBeamAttack), "HitEnemy", (Type[])null, (Type[])null);
}
List<Vector3> list = new List<Vector3>(num);
*(IntPtr*)(void*)(((Il2CppObjectBase)__instance).Pointer + 80) = ((Il2CppObjectBase)__instance).Pointer;
object[] array = new object[1];
for (int i = 0; i < num4; i++)
{
if (list.Count >= num)
{
break;
}
Collider val = SpaceNoodleState.Buf[i];
if ((Object)(object)val == (Object)null)
{
continue;
}
Rigidbody attachedRigidbody = val.attachedRigidbody;
if (!((Object)(object)attachedRigidbody == (Object)null))
{
IntPtr pointer2 = ((Il2CppObjectBase)attachedRigidbody).Pointer;
if (hashSet.Add(pointer2))
{
array[0] = val;
SpaceNoodleState.HitEnemyMi.Invoke(__instance, array);
Bounds bounds = val.bounds;
list.Add(((Bounds)(ref bounds)).center);
}
}
}
*(nint*)(void*)(((Il2CppObjectBase)__instance).Pointer + 80) = num3;
SpaceNoodleState.ExtraTargetPos[pointer] = list.ToArray();
}
}
[HarmonyPatch(typeof(LaserBeamAttack), "Update")]
internal static class Patch_SpaceNoodle_ExtraVisual
{
private static void Postfix(LaserBeamAttack __instance)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: 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_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: 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)
IntPtr pointer = ((Il2CppObjectBase)__instance).Pointer;
SpaceNoodleState.ExtraTargetPos.TryGetValue(pointer, out var value);
int num = ((value != null) ? value.Length : 0);
if (!SpaceNoodleState.ExtraRenderers.TryGetValue(pointer, out var value2))
{
value2 = new List<LineRenderer>();
SpaceNoodleState.ExtraRenderers[pointer] = value2;
}
while (value2.Count < num)
{
LineRenderer val = new GameObject("SpaceNoodleExtraBeam").AddComponent<LineRenderer>();
if ((Object)(object)__instance.linerenderer != (Object)null)
{
((Renderer)val).sharedMaterial = ((Renderer)__instance.linerenderer).sharedMaterial;
val.widthMultiplier = __instance.linerenderer.widthMultiplier;
val.startColor = __instance.linerenderer.startColor;
val.endColor = __instance.linerenderer.endColor;
}
val.positionCount = 2;
val.useWorldSpace = true;
value2.Add(val);
}
Vector3 val2;
if ((Object)(object)__instance.laserStart != (Object)null)
{
val2 = __instance.laserStart.transform.position;
}
else
{
GameManager instance = GameManager.Instance;
MyPlayer val3 = ((instance != null) ? instance.player : null);
val2 = (((Object)(object)val3 != (Object)null) ? (((Component)val3).transform.position + Vector3.up * 1.2f) : ((Component)__instance).transform.position);
}
for (int i = 0; i < value2.Count; i++)
{
LineRenderer val4 = value2[i];
if (!((Object)(object)val4 == (Object)null))
{
if (i < num)
{
((Renderer)val4).enabled = true;
val4.SetPosition(0, val2);
val4.SetPosition(1, value[i]);
}
else
{
((Renderer)val4).enabled = false;
}
}
}
}
}
[HarmonyPatch(typeof(LaserBeamAttack), "OnDestroy")]
internal static class Patch_SpaceNoodle_Cleanup
{
private static void Postfix(LaserBeamAttack __instance)
{
IntPtr pointer = ((Il2CppObjectBase)__instance).Pointer;
SpaceNoodleState.ExtraTargetPos.Remove(pointer);
if (!SpaceNoodleState.ExtraRenderers.TryGetValue(pointer, out var value))
{
return;
}
foreach (LineRenderer item in value)
{
if ((Object)(object)item != (Object)null && (Object)(object)((Component)item).gameObject != (Object)null)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
}
SpaceNoodleState.ExtraRenderers.Remove(pointer);
}
}