Decompiled source of ExperimentiumMod v1.1.2

ExperimentiumMod.dll

Decompiled 3 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ExperimentiumMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ExperimentiumMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("457a460f-08a3-4e5f-9083-5f4e1e31f0b9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.NGeorge.ExperimentiumMod", "Experimentium Mod", "1.1.2")]
public class Main : BaseUnityPlugin
{
	public static class GlobalState
	{
		public static int ModDebugging;
	}

	public class ExperimentiumModBehaviour : MonoBehaviour
	{
		private float nextUpdateTime;

		public void Awake()
		{
			nextUpdateTime = Time.time + Random.Range(1f, 2f);
		}

		public void Update()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between Unknown and I4
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Invalid comparison between Unknown and I4
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			SpecialObj18 obj = Object.FindObjectOfType<SpecialObj18>();
			SpecialObj101Reroll obj2 = Object.FindObjectOfType<SpecialObj101Reroll>();
			SpecialObj101Compound val = Object.FindObjectOfType<SpecialObj101Compound>();
			SpecialObj21 obj3 = Object.FindObjectOfType<SpecialObj21>();
			LevelMgr val2 = Object.FindObjectOfType<LevelMgr>();
			FieldInfo field = typeof(SpecialObj18).GetField("useTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = typeof(SpecialObj101Reroll).GetField("useTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field3 = typeof(SpecialObj21).GetField("useTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			Scene sceneByName = SceneManager.GetSceneByName("Battle");
			if (((Scene)(ref sceneByName)).isLoaded && (int)val2.CurrentRewardType == 6 && (Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			if (field != null)
			{
				sceneByName = SceneManager.GetSceneByName("Battle");
				if (((Scene)(ref sceneByName)).isLoaded && (int)val2.CurrentRewardType == 5)
				{
					field.SetValue(obj, 0);
				}
			}
			if (field2 != null)
			{
				sceneByName = SceneManager.GetSceneByName("Battle");
				if (((Scene)(ref sceneByName)).isLoaded && (int)val2.CurrentRewardType == 6)
				{
					field2.SetValue(obj2, 0);
				}
			}
			if (field3 != null)
			{
				sceneByName = SceneManager.GetSceneByName("Battle");
				if (((Scene)(ref sceneByName)).isLoaded && BattleMgr.Inst.CurrentStage == 7)
				{
					field3.SetValue(obj3, 0);
				}
			}
			if (Input.GetKeyDown((KeyCode)282))
			{
				Start_EndlessMode();
				FieldInfo[] fields = typeof(BattleData).GetFields();
				foreach (FieldInfo fieldInfo in fields)
				{
					Debug.Log((object)fieldInfo.Name);
				}
			}
		}

		public void Start_EndlessMode()
		{
			Debug.Log((object)"This seems to work right ?");
		}
	}

	private GameObject modObject;

	public void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.NGeorge.ExperimentiumMod");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod has loaded!");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Have fun :)))");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"-------------------------------------------------------------------------------------------------");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"                                                                                                 ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"This mod might have bugs soo if you find any please report them to our discord server.");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"https://discord.gg/WFaxE6A5Ae");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"                                                                                                 ");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"-------------------------------------------------------------------------------------------------");
		val.PatchAll();
		IEnumerable<MethodBase> patchedMethods = val.GetPatchedMethods();
		foreach (MethodBase item in patchedMethods)
		{
			Debug.Log((object)("Successfully patched: " + item.DeclaringType?.Name + "." + item.Name));
		}
		Debug.Log((object)"Harmony patches applied!");
		CreatePersistentObject();
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void CreatePersistentObject()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		if ((Object)(object)modObject == (Object)null)
		{
			modObject = new GameObject("ExperimentiumMod");
			modObject.AddComponent<ExperimentiumModBehaviour>();
			Object.DontDestroyOnLoad((Object)(object)modObject);
		}
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name));
		CreatePersistentObject();
	}
}
namespace ExperimentiumMod.Patches;

[HarmonyPatch(typeof(BattleData))]
public class PatchMaxSpellLevel
{
	[HarmonyPatch("GetSpellFromPool")]
	[HarmonyPrefix]
	public static bool Prefix(ref int level)
	{
		level = 3;
		return true;
	}
}
[HarmonyPatch(typeof(Item), "SetDiscount")]
public class PatchShopDiscount
{
	[HarmonyPrefix]
	public static void Prefix(ref float priceFactor)
	{
		priceFactor = 0f;
	}
}
[HarmonyPatch(typeof(Item), "UpdatePrice")]
public class PatchShopUpdateDiscount
{
	[HarmonyPostfix]
	public static void Postfix(Item __instance)
	{
		__instance.SetDiscount(100f);
	}
}
[HarmonyPatch(typeof(UIRerollRelic), "_Reroll")]
public class PatchRemoveLimitRestartKey
{
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i].opcode == OpCodes.Ldc_I4 && (int)list[i].operand == 66)
			{
				list.RemoveAt(i);
				list.RemoveAt(i);
				break;
			}
		}
		return list;
	}
}
[HarmonyPatch(typeof(UnitConfig))]
public class PatchTempShield
{
	[HarmonyPatch("Copy")]
	[HarmonyPostfix]
	public static void Postfix(UnitConfig __instance)
	{
		if (Main.GlobalState.ModDebugging == 0)
		{
			typeof(UnitConfig).GetField("shieldTemp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(__instance, 500f);
		}
	}
}