Decompiled source of UseOriginalMapInDead v1.0.0

UseOriginalMapInDead.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UseOriginalMapInDead")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UseOriginalMapInDead")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1d40467d-dbce-4914-bbb2-6a665ee6efb4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UseOriginalMapInDead;

[BepInPlugin("com.repo.kr.UseOriginalMapInDead", "UseOriginalMapInDead", "1.0.0")]
public class ModBehaviour : BaseUnityPlugin
{
	[HarmonyPatch(typeof(MapToolController), "Update")]
	public class MapToolController_path
	{
		private static FieldInfo positionField;

		static MapToolController_path()
		{
			positionField = typeof(PlayerAvatar).GetField("LastNavmeshPosition", BindingFlags.Instance | BindingFlags.NonPublic);
		}

		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldfld && list[i].operand is FieldInfo)
				{
					FieldInfo fieldInfo = (FieldInfo)list[i].operand;
					MethodInfo methodInfo = AccessTools.Method(typeof(MapToolController_path), "setFalseBool", (Type[])null, (Type[])null);
					if (fieldInfo.Name == "isDisabled")
					{
						Debug.Log((object)"find isDisabled");
						list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo));
						i++;
					}
					else if (fieldInfo.Name == "isTumbling")
					{
						Debug.Log((object)"find isTumbling");
						list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo));
						i++;
					}
					else if (fieldInfo.Name == "sprinting")
					{
						Debug.Log((object)"find sprinting");
						list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo));
						break;
					}
				}
			}
			return list;
		}

		private static bool setFalseBool(bool dataOriginal)
		{
			return false;
		}

		[HarmonyPostfix]
		private static void Update_Postfix()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			if (isDead)
			{
				Transform transform = ((Component)PlayerController.instance).transform;
				Transform transform2 = ((Component)PlayerController.instance.cameraAim).transform;
				transform.position = transform2.position;
				Quaternion rotation = transform.rotation;
				float x = ((Quaternion)(ref rotation)).eulerAngles.x;
				rotation = transform2.rotation;
				float y = ((Quaternion)(ref rotation)).eulerAngles.y;
				rotation = transform.rotation;
				transform.rotation = Quaternion.Euler(x, y, ((Quaternion)(ref rotation)).eulerAngles.z);
				positionField.SetValue(PlayerController.instance.playerAvatarScript, transform2.position);
			}
		}
	}

	[HarmonyPatch(typeof(SpectateCamera))]
	public class SpectateCamera_path
	{
		[HarmonyPrefix]
		[HarmonyPatch("StateNormal")]
		private static void StateNormal_Prefix()
		{
			isDead = true;
		}
	}

	[HarmonyPatch(typeof(GameDirector))]
	public class GameDirectorPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Revive")]
		private static void Revive_Prefix()
		{
			isDead = false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("gameStateStart")]
		private static void gameStateStart_Prefix()
		{
			isDead = false;
		}
	}

	private Harmony harmony;

	private static ManualLogSource Log;

	private static bool isDead;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		harmony = new Harmony("com.repo.kr.UseOriginalMapInDead");
		harmony.PatchAll();
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"UseOriginalMapInDead enble");
	}
}