Decompiled source of guffs updated tools v1.1.2

BepInEx/plugins/GuffsUpdatedTools/GuffsInteractionRepair.dll

Decompiled a day ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace GuffsInteractionRepair;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("guffs.updated.tools.interactionrepair", "guffs updated tools - Interaction Repair", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
	private Harmony harmony;

	private void Awake()
	{
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Expected O, but got Unknown
		if (!Chainloader.PluginInfos.ContainsKey("Szumi57.LethalInternship"))
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Interaction Repair: LethalInternship is not enabled; no patch needed.");
			return;
		}
		Type type = FindType("LethalInternship.Patches.Utils.PatchesUtil");
		Type type2 = FindType("LethalInternship.SharedAbstractions.ManagerProviders.UIManagerProvider");
		MethodInfo methodInfo = ((type == null) ? null : AccessTools.DeclaredMethod(type, "IsAnyMenuOpened", Type.EmptyTypes, (Type[])null));
		MethodInfo method = ((type2 == null) ? null : AccessTools.DeclaredMethod(type2, "get_IsReady", Type.EmptyTypes, (Type[])null));
		if (!Supported(methodInfo) || !Supported(method))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Interaction Repair: unsupported LethalInternship API; no patch applied. Expected static bool IsAnyMenuOpened() and UIManagerProvider.IsReady.");
			return;
		}
		InteractionGuard.IsReady = (Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), method);
		InteractionGuard.OnFallback = delegate
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Interaction Repair: LethalInternship UIManager is not ready. Treating its command menu as closed so normal game input can continue. This does not repair the missing intern UI itself.");
		};
		harmony = new Harmony("guffs.updated.tools.interactionrepair");
		harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(InteractionGuard), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"guffs updated tools - Interaction Repair 1.0.0 loaded; guarding LethalInternship's command-menu readiness check only.");
	}

	private static bool Supported(MethodInfo method)
	{
		if (method != null && method.IsStatic && method.ReturnType == typeof(bool))
		{
			return method.GetParameters().Length == 0;
		}
		return false;
	}

	private static Type FindType(string fullName)
	{
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			Type type = assembly.GetType(fullName, throwOnError: false);
			if (type != null)
			{
				return type;
			}
		}
		return null;
	}

	private void OnDestroy()
	{
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		InteractionGuard.IsReady = null;
		InteractionGuard.OnFallback = null;
	}
}
public static class InteractionGuard
{
	public static Func<bool> IsReady;

	public static Action OnFallback;

	private static bool reported;

	public static bool Prefix(ref bool __result)
	{
		if (IsReady == null || IsReady())
		{
			return true;
		}
		__result = false;
		if (!reported)
		{
			reported = true;
			if (OnFallback != null)
			{
				OnFallback();
			}
		}
		return false;
	}
}

BepInEx/plugins/GuffsUpdatedTools/GuffsRansomSceneFix.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace GuffsRansomSceneFix;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("guffs.updated.tools.ransomscenefix", "guffs updated tools - RansomLC Scene Fix", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
	private Harmony harmony;

	private void Awake()
	{
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Expected O, but got Unknown
		if (!Chainloader.PluginInfos.ContainsKey("WaterGun.ransomLC"))
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"RansomLC Scene Fix: RansomLC not enabled; no patch needed.");
			return;
		}
		Type type = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			type = assembly.GetType("RansomLC.Plugin+StartOfRound_Patch", throwOnError: false);
			if (type != null)
			{
				break;
			}
		}
		MethodInfo methodInfo = ((type == null) ? null : AccessTools.DeclaredMethod(type, "SceneManager_OnLoadComplete1_Post", (Type[])null, (Type[])null));
		if (methodInfo == null || !methodInfo.IsStatic || methodInfo.ReturnType != typeof(void))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"RansomLC Scene Fix: unsupported RansomLC API; no patch applied.");
			return;
		}
		SceneLookupFix.OnMissing = delegate(string moon)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("RansomLC Scene Fix: missing moon config for '" + moon + "'; allowing RansomLC's existing default-config fallback. This does not repair host/client content or dungeon generation."));
		};
		harmony = new Harmony("guffs.updated.tools.ransomscenefix");
		harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(SceneLookupFix), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"guffs updated tools - RansomLC Scene Fix 1.0.0 loaded; guarded one moon-config lookup only.");
	}

	private void OnDestroy()
	{
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		SceneLookupFix.OnMissing = null;
	}
}
public static class SceneLookupFix
{
	public static Action<string> OnMissing;

	private static readonly HashSet<string> Reported = new HashSet<string>();

	public static T GetOrDefault<T>(Dictionary<string, T> dictionary, string key) where T : class
	{
		if (dictionary.TryGetValue(key, out var value))
		{
			return value;
		}
		if (Reported.Add(key) && OnMissing != null)
		{
			OnMissing(key);
		}
		return null;
	}

	public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		List<CodeInstruction> list2 = new List<CodeInstruction>();
		foreach (CodeInstruction item in list)
		{
			MethodInfo methodInfo = item.operand as MethodInfo;
			if (item.opcode != OpCodes.Callvirt || methodInfo == null || methodInfo.Name != "get_Item")
			{
				continue;
			}
			Type declaringType = methodInfo.DeclaringType;
			if (declaringType.IsGenericType && !(declaringType.GetGenericTypeDefinition() != typeof(Dictionary<, >)))
			{
				Type[] genericArguments = declaringType.GetGenericArguments();
				if (genericArguments[0] == typeof(string) && genericArguments[1].FullName == "RansomLC.MoonConfig")
				{
					list2.Add(item);
				}
			}
		}
		if (list2.Count != 1)
		{
			throw new InvalidOperationException("RansomLC scene lookup shape changed; expected exactly one moon-config indexer.");
		}
		CodeInstruction val = list2[0];
		Type type = ((MethodInfo)val.operand).DeclaringType.GetGenericArguments()[1];
		val.opcode = OpCodes.Call;
		val.operand = typeof(SceneLookupFix).GetMethod("GetOrDefault").MakeGenericMethod(type);
		return list;
	}
}