Decompiled source of PeakCinema v0.4.0

plugins/com.github.megalon.peakcinema.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.megalon.peakcinema")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.4.0.0")]
[assembly: AssemblyInformationalVersion("0.4.0+3cdc552e68bed97287b5877d467f47955bda46a5")]
[assembly: AssemblyProduct("com.github.megalon.peakcinema")]
[assembly: AssemblyTitle("PeakCinema")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PeakCinema
{
	[BepInPlugin("com.github.megalon.peakcinema", "PeakCinema", "0.4.0")]
	public class Plugin : BaseUnityPlugin
	{
		public class PluginModConfig
		{
			public readonly ConfigEntry<KeyCode> toggleCinemaCamControlKey;

			public readonly ConfigEntry<KeyCode> exitCinemaCamKey;

			public readonly ConfigEntry<KeyCode> keyTogglePlayer;

			public readonly ConfigEntry<KeyCode> keyMoveForward;

			public readonly ConfigEntry<KeyCode> keyMoveBackward;

			public readonly ConfigEntry<KeyCode> keyMoveLeft;

			public readonly ConfigEntry<KeyCode> keyMoveRight;

			public readonly ConfigEntry<KeyCode> keyMoveUp;

			public readonly ConfigEntry<KeyCode> keyMoveDown;

			public readonly ConfigEntry<KeyCode> keyMoveFaster;

			public readonly ConfigEntry<KeyCode> keySmoothToggle;

			public readonly ConfigEntry<float> velLerpValue;

			public readonly ConfigEntry<float> rotLerpValue;

			public readonly ConfigEntry<float> normalSpeed;

			public readonly ConfigEntry<float> fastSpeed;

			public readonly ConfigEntry<float> rotationSensitivity;

			public readonly ConfigEntry<KeyCode> keyFOVReset;

			public readonly ConfigEntry<float> defaultFOV;

			public readonly ConfigEntry<float> fovSensitivity;

			public PluginModConfig(ConfigFile config)
			{
				toggleCinemaCamControlKey = config.Bind<KeyCode>("General", "Toggle Cinema Cam Control", (KeyCode)284, "Hold F3 to reset camera position to player, press F3 to toggle on/off.");
				exitCinemaCamKey = config.Bind<KeyCode>("General", "Exit Cinema Cam", (KeyCode)27, "Exits the cinema camera and re-enables player input.");
				keyTogglePlayer = config.Bind<KeyCode>("General", "Toggle Player Visibility", (KeyCode)285, "Toggles your character model (body/head/cosmetics) on/off.");
				keyMoveFaster = config.Bind<KeyCode>("Movement", "Move Faster", (KeyCode)304, "Hold to move at the fast speed setting.");
				keyMoveUp = config.Bind<KeyCode>("Movement", "Move Up", (KeyCode)32, "Camera movement up key.");
				keyMoveDown = config.Bind<KeyCode>("Movement", "Move Down", (KeyCode)306, "Camera movement down key.");
				keyMoveForward = config.Bind<KeyCode>("Movement", "Move Forward", (KeyCode)119, "Camera movement forward key.");
				keyMoveLeft = config.Bind<KeyCode>("Movement", "Move Left", (KeyCode)97, "Camera movement left key.");
				keyMoveBackward = config.Bind<KeyCode>("Movement", "Move Backward", (KeyCode)115, "Camera movement backward key.");
				keyMoveRight = config.Bind<KeyCode>("Movement", "Move Right", (KeyCode)100, "Camera movement right key.");
				keySmoothToggle = config.Bind<KeyCode>("Camera", "Toggle Camera Smoothing", (KeyCode)301, "Toggles velocity damping and movement smoothing.");
				normalSpeed = config.Bind<float>("Camera", "Normal Speed", 2f, "The default movement speed of the camera.");
				fastSpeed = config.Bind<float>("Camera", "Fast Speed", 6f, "The movement speed when holding the 'Move Faster' key.");
				rotationSensitivity = config.Bind<float>("Camera", "Rotation Sensitivity", 1.5f, "Mouse sensitivity for looking around.");
				velLerpValue = config.Bind<float>("Camera", "Smoothing Velocity", 2f, "Control how quickly the camera stops moving.");
				rotLerpValue = config.Bind<float>("Camera", "Smoothing Rotation", 3f, "Control how quickly the camera stops rotating.");
				keyFOVReset = config.Bind<KeyCode>("FOV", "Reset FOV", (KeyCode)325, "Key to reset the Field of View to the default value.");
				defaultFOV = config.Bind<float>("FOV", "Default FOV", 60f, "The default Field of View value (used for reset).");
				fovSensitivity = config.Bind<float>("FOV", "FOV Scroll Sensitivity", 15f, "Multiplier for how fast the FOV changes when scrolling the mouse wheel.");
			}
		}

		internal static GameObject HUD = null;

		internal static float InitialFOV = 60f;

		internal static List<VoiceObscuranceFilter> VoiceFilters = new List<VoiceObscuranceFilter>();

		public const string Id = "com.github.megalon.peakcinema";

		internal static ManualLogSource Log { get; private set; } = null;


		internal static PluginModConfig ModConfig { get; private set; } = null;


		internal static bool CinemaCamActive { get; private set; }

		internal static Transform? CamTransform { get; private set; }

		internal static Camera? CinemaCamComponent { get; private set; }

		internal static bool CameraWasSpawned { get; private set; }

		internal static bool Smoothing { get; private set; } = true;


		internal static float HoldTimer { get; private set; }

		internal static float InitHoldTimer { get; private set; } = 1.5f;


		internal static Vector3 DeathLocation { get; private set; }

		internal static bool PlayerVisibilityToggled { get; private set; } = false;


		public static string Name => "PeakCinema";

		public static string Version => "0.4.0";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			ModConfig = new PluginModConfig(((BaseUnityPlugin)this).Config);
			HoldTimer = InitHoldTimer;
		}

		[HarmonyPatch(typeof(VoiceObscuranceFilter), "Start")]
		[HarmonyPostfix]
		private static void VoiceObscuranceFilter_Start(VoiceObscuranceFilter __instance)
		{
			if (CinemaCamActive)
			{
				SetVoiceFilterToCinemaCam(__instance);
			}
			VoiceFilters.Add(__instance);
		}

		[HarmonyPatch(typeof(CinemaCamera), "Start")]
		[HarmonyPostfix]
		private static void CinemaCamera_Start(CinemaCamera __instance)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			CamTransform = __instance.cam;
			CinemaCamComponent = ((Component)__instance.cam).GetComponent<Camera>();
			if ((Object)(object)CinemaCamComponent != (Object)null)
			{
				InitialFOV = ModConfig.defaultFOV.Value;
				CinemaCamComponent.fieldOfView = ModConfig.defaultFOV.Value;
			}
			CameraWasSpawned = false;
			HoldTimer = InitHoldTimer;
			DeathLocation = Vector3.zero;
			if ((Object)(object)HUD == (Object)null)
			{
				HUD = GameObject.Find("Canvas_HUD");
			}
		}

		[HarmonyPatch(typeof(CinemaCamera), "Update")]
		[HarmonyPrefix]
		private static bool CinemaCameraFix(CinemaCamera __instance)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: 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_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_067d: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
			HandlePlayerVisibilityInput();
			if (Input.GetKeyDown(ModConfig.exitCinemaCamKey.Value))
			{
				CinemaCamActive = false;
				__instance.on = false;
				GameObject hUD = HUD;
				if (hUD != null)
				{
					hUD.SetActive(true);
				}
				((Component)__instance.cam).gameObject.SetActive(false);
				if ((Object)(object)__instance.fog != (Object)null)
				{
					((Component)__instance.fog).gameObject.SetActive(true);
				}
				if ((Object)(object)__instance.oldCam != (Object)null)
				{
					((Component)__instance.oldCam).gameObject.SetActive(true);
				}
				foreach (VoiceObscuranceFilter voiceFilter in VoiceFilters)
				{
					if (!((Object)(object)voiceFilter == (Object)null))
					{
						voiceFilter.head = ((Component)MainCamera.instance).transform;
					}
				}
				ApplyPlayerVisibility(cameraActive: false);
			}
			else if (Input.GetKey(ModConfig.toggleCinemaCamControlKey.Value))
			{
				HoldTimer -= Time.deltaTime;
				if (HoldTimer <= 0f)
				{
					MoveCameraToPlayerPosition(__instance);
					if (!__instance.on)
					{
						__instance.on = true;
					}
					HoldTimer = -1f;
				}
			}
			else if (Input.GetKeyUp(ModConfig.toggleCinemaCamControlKey.Value))
			{
				if (!CinemaCamActive)
				{
					CinemaCamActive = true;
					HandleVoiceFilters();
				}
				if (HoldTimer > -1f)
				{
					__instance.on = !__instance.on;
				}
				HoldTimer = InitHoldTimer;
			}
			if (__instance.on)
			{
				InputSystem.actions.Disable();
				GameObject hUD2 = HUD;
				if (hUD2 != null)
				{
					hUD2.SetActive(false);
				}
				ApplyPlayerVisibility(cameraActive: true);
				__instance.ambience.parent = ((Component)__instance).transform;
				if (Object.op_Implicit((Object)(object)__instance.fog))
				{
					((Component)__instance.fog).gameObject.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)__instance.oldCam))
				{
					((Component)__instance.oldCam).gameObject.SetActive(false);
				}
				((Component)__instance).transform.parent = null;
				__instance.cam.parent = null;
				if (!CameraWasSpawned)
				{
					MoveCameraToPlayerPosition(__instance);
				}
				((Component)__instance.cam).gameObject.SetActive(true);
				if ((Object)(object)CinemaCamComponent != (Object)null)
				{
					float axis = Input.GetAxis("Mouse ScrollWheel");
					if (axis != 0f)
					{
						Camera? cinemaCamComponent = CinemaCamComponent;
						cinemaCamComponent.fieldOfView -= axis * ModConfig.fovSensitivity.Value;
						CinemaCamComponent.fieldOfView = Mathf.Clamp(CinemaCamComponent.fieldOfView, 5f, 120f);
					}
					if (Input.GetKeyDown(ModConfig.keyFOVReset.Value))
					{
						CinemaCamComponent.fieldOfView = ModConfig.defaultFOV.Value;
					}
				}
				if (Input.GetKeyDown(ModConfig.keySmoothToggle.Value))
				{
					Smoothing = !Smoothing;
				}
				float num = 0f;
				float value = ModConfig.normalSpeed.Value;
				float value2 = ModConfig.fastSpeed.Value;
				float value3 = ModConfig.rotationSensitivity.Value;
				float num2 = (((Object)(object)CinemaCamComponent != (Object)null) ? CinemaCamComponent.fieldOfView : 60f);
				float num3 = Mathf.Pow(60f / Mathf.Clamp(num2, 5f, 180f), 0.1f);
				float num4 = value3 * num3;
				if (Smoothing)
				{
					__instance.vel = Vector3.Lerp(__instance.vel, Vector3.zero, ModConfig.velLerpValue.Value * Time.deltaTime);
					__instance.rot = Vector3.Lerp(__instance.rot, Vector3.zero, ModConfig.rotLerpValue.Value * Time.deltaTime);
					num = (Input.GetKey(ModConfig.keyMoveFaster.Value) ? (value2 / 10f) : (value / 10f));
					__instance.rot.y += Input.GetAxis("Mouse X") * num * num4 * 0.05f;
					__instance.rot.x += Input.GetAxis("Mouse Y") * num * num4 * 0.05f;
				}
				else
				{
					__instance.vel = Vector3.zero;
					__instance.rot = Vector3.zero;
					num = (Input.GetKey(ModConfig.keyMoveFaster.Value) ? value2 : value);
					__instance.rot.y += Input.GetAxis("Mouse X") * num4 * 0.1f;
					__instance.rot.x += Input.GetAxis("Mouse Y") * num4 * 0.1f;
				}
				float num5 = num * Time.deltaTime;
				if (Input.GetKey(ModConfig.keyMoveRight.Value))
				{
					__instance.vel.x = (Smoothing ? (__instance.vel.x + num5) : num5);
				}
				if (Input.GetKey(ModConfig.keyMoveLeft.Value))
				{
					__instance.vel.x = (Smoothing ? (__instance.vel.x - num5) : (0f - num5));
				}
				if (Input.GetKey(ModConfig.keyMoveForward.Value))
				{
					__instance.vel.z = (Smoothing ? (__instance.vel.z + num5) : num5);
				}
				if (Input.GetKey(ModConfig.keyMoveBackward.Value))
				{
					__instance.vel.z = (Smoothing ? (__instance.vel.z - num5) : (0f - num5));
				}
				if (Input.GetKey(ModConfig.keyMoveUp.Value))
				{
					__instance.vel.y = (Smoothing ? (__instance.vel.y + num5) : num5);
				}
				if (Input.GetKey(ModConfig.keyMoveDown.Value))
				{
					__instance.vel.y = (Smoothing ? (__instance.vel.y - num5) : (0f - num5));
				}
				((Component)__instance.cam).transform.Rotate(Vector3.up * __instance.rot.y, (Space)0);
				((Component)__instance.cam).transform.Rotate(((Component)__instance).transform.right * (0f - __instance.rot.x));
				((Component)__instance.cam).transform.Translate(Vector3.right * __instance.vel.x, (Space)1);
				((Component)__instance.cam).transform.Translate(Vector3.forward * __instance.vel.z, (Space)1);
				((Component)__instance.cam).transform.Translate(Vector3.up * __instance.vel.y, (Space)0);
				__instance.t = true;
				CameraWasSpawned = true;
			}
			else
			{
				InputSystem.actions.Enable();
				ApplyPlayerVisibility(cameraActive: false);
			}
			return false;
		}

		private static void HandlePlayerVisibilityInput()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(ModConfig.keyTogglePlayer.Value))
			{
				PlayerVisibilityToggled = !PlayerVisibilityToggled;
				Log.LogInfo((object)$"Player visibility set to {PlayerVisibilityToggled}");
			}
		}

		private static void ApplyPlayerVisibility(bool cameraActive)
		{
			CharacterCustomization val = ((IEnumerable<Character>)Character.AllCharacters).FirstOrDefault((Func<Character, bool>)((Character c) => c.IsLocal))?.refs?.customization;
			if (!((Object)(object)val == (Object)null))
			{
				if (cameraActive && PlayerVisibilityToggled)
				{
					val.HideAllRenderers();
				}
				else
				{
					val.ShowAllRenderers();
				}
			}
		}

		private static void MoveCameraToPlayerPosition(CinemaCamera __instance)
		{
			//IL_006d: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			Character val = ((IEnumerable<Character>)Character.AllCharacters).FirstOrDefault((Func<Character, bool>)((Character c) => c.IsLocal));
			if ((Object)(object)val != (Object)null)
			{
				if (val.data.dead)
				{
					((Component)__instance.cam).transform.position = DeathLocation;
				}
				else
				{
					((Component)__instance.cam).transform.position = val.refs.animationPositionTransform.position;
				}
				Transform transform = ((Component)__instance.cam).transform;
				transform.position += new Vector3(0f, 1.5f, -2f);
			}
		}

		private static void HandleVoiceFilters()
		{
			for (int num = VoiceFilters.Count - 1; num >= 0; num--)
			{
				VoiceObscuranceFilter val = VoiceFilters[num];
				if ((Object)(object)val == (Object)null)
				{
					VoiceFilters.RemoveAt(num);
				}
			}
			foreach (VoiceObscuranceFilter voiceFilter in VoiceFilters)
			{
				if (!((Object)(object)voiceFilter == (Object)null))
				{
					SetVoiceFilterToCinemaCam(voiceFilter);
				}
			}
			Log.LogInfo((object)$"Adjusted {VoiceFilters.Count} voice filters!");
		}

		private static void SetVoiceFilterToCinemaCam(VoiceObscuranceFilter filter)
		{
			if (!((Object)(object)CamTransform == (Object)null) && !((Object)(object)filter == (Object)null))
			{
				filter.head = CamTransform;
			}
		}

		[HarmonyPatch(typeof(AmbienceAudio), "Update")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			FieldInfo fieldInfo = AccessTools.Field(typeof(AmbienceAudio), "character");
			FieldInfo fieldInfo2 = AccessTools.Field(typeof(Character), "data");
			FieldInfo fieldInfo3 = AccessTools.Field(typeof(Character), "localCharacter");
			FieldInfo fieldInfo4 = AccessTools.Field(typeof(Character), "data");
			for (int i = 0; i < list.Count - 2; i++)
			{
				if (list[i].opcode == OpCodes.Ldarg_0 && list[i + 1].opcode == OpCodes.Ldfld && list[i + 1].operand as FieldInfo == fieldInfo && list[i + 2].opcode == OpCodes.Ldfld && list[i + 2].operand as FieldInfo == fieldInfo2)
				{
					Log.LogInfo((object)"Patching AmbienceAudio.Update...");
					list.RemoveRange(i, 3);
					list.InsertRange(i, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[2]
					{
						new CodeInstruction(OpCodes.Ldsfld, (object)fieldInfo3),
						new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo4)
					}));
					Log.LogInfo((object)"Successfully patched AmbienceAudio.Update!");
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				Log.LogFatal((object)"Failed to patch AmbienceAudio.Update.");
			}
			return list;
		}

		[HarmonyPatch(typeof(Character), "RPCA_Die")]
		[HarmonyPrefix]
		private static bool Character_RPCA_Die(Character __instance)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.IsLocal)
			{
				return true;
			}
			DeathLocation = __instance.refs.animationPositionTransform.position;
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}