Decompiled source of Duplicate Traits And Items v1.0.0

Hero & item.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using RTM.UISystem;
using UnityEngine;
using Voxels.TowerDefense.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Hero & item")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Hero & item")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("417a027b-2cc0-4c76-a99c-351bf4db5faf")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BadNorthMergedMod;

[BepInPlugin("com.zazaxc.multiselect", "Multi-Select & Menu Fix", "7.0.0")]
public class MultiSelectPlugin : BaseUnityPlugin
{
	[HarmonyPatch]
	public class DisableLocking_Patch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(CarouselType, "SetUnavailableUpgrade", (Type[])null, (Type[])null);
		}

		private static bool Prefix()
		{
			return false;
		}
	}

	[HarmonyPatch]
	public class CutConnection_Patch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(HeroSelectorType, "Init", (Type[])null, (Type[])null);
		}

		private static void Postfix(MonoBehaviour __instance)
		{
			object value = AccessTools.Field(HeroSelectorType, "traitCarousel").GetValue(__instance);
			object value2 = AccessTools.Field(HeroSelectorType, "itemCarousel").GetValue(__instance);
			if (value != null)
			{
				AccessTools.Field(CarouselType, "forceOtherToChange").SetValue(value, null);
			}
			if (value2 != null)
			{
				AccessTools.Field(CarouselType, "forceOtherToChange").SetValue(value2, null);
			}
		}
	}

	[HarmonyPatch]
	public class PreventReconnection_Patch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(HeroSelectorType, "OnParentMenuOpened", (Type[])null, (Type[])null);
		}

		private static void Postfix(MonoBehaviour __instance)
		{
			object value = AccessTools.Field(HeroSelectorType, "other").GetValue(__instance);
			if (value != null)
			{
				object value2 = AccessTools.Field(HeroSelectorType, "traitCarousel").GetValue(value);
				object value3 = AccessTools.Field(HeroSelectorType, "itemCarousel").GetValue(value);
				if (value2 != null)
				{
					ClearEvents(value2, "onSelectedUpgradeChanged");
				}
				if (value3 != null)
				{
					ClearEvents(value3, "onSelectedUpgradeChanged");
				}
			}
		}

		private static void ClearEvents(object targetObj, string eventName)
		{
			FieldInfo fieldInfo = AccessTools.Field(targetObj.GetType(), eventName);
			if (fieldInfo != null)
			{
				fieldInfo.SetValue(targetObj, null);
			}
		}
	}

	[HarmonyPatch(typeof(NewGameOptionsPopup), "StartCampaign")]
	public class ForceCloseMenu_Patch
	{
		private static void Postfix(NewGameOptionsPopup __instance)
		{
			((UIMenu)__instance).CloseMenu();
			if (((Component)__instance).gameObject.activeSelf)
			{
				((Component)__instance).gameObject.SetActive(false);
			}
		}
	}

	public static Type HeroSelectorType => AccessTools.TypeByName("Voxels.TowerDefense.UI.NewGameHeroSelector");

	public static Type CarouselType => AccessTools.TypeByName("Voxels.TowerDefense.UI.UpgradeCarousel");

	private 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.zazaxc.multiselect");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"MOD ENABLED: Multi-Select V87 (Director's Cut).");
	}
}