Decompiled source of PeakGeneralImprovements v1.0.8

PeakGeneralImprovements.dll

Decompiled 2 months 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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using PeakGeneralImprovements.Objects;
using PeakGeneralImprovements.Patches.Shared;
using PeakGeneralImprovements.Utilities;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace PeakGeneralImprovements
{
	public static class Enums
	{
		public enum eAirportElevatorOptions
		{
			Vanilla,
			UseAllInOrder,
			UseAllRandomly
		}

		public enum eEmoteLoopingOptions
		{
			None,
			NetworkedLooping,
			LocalLoopingOnly
		}

		public enum eRopeVineChainOptions
		{
			Vanilla,
			AllowClimbing,
			AutoDismount
		}

		public enum eHotSunCookingOptions
		{
			None,
			OnlyFood,
			AllCookables
		}
	}
	internal static class Metadata
	{
		public const string GUID = "ShaosilGaming.PeakGeneralImprovements";

		public const string PLUGIN_NAME = "PeakGeneralImprovements";

		public const string VERSION = "1.0.8";
	}
	[BepInPlugin("ShaosilGaming.PeakGeneralImprovements", "PeakGeneralImprovements", "1.0.8")]
	public class Plugin : BaseUnityPlugin
	{
		private const string CampfireSection = "Campfire";

		private const string CharacterSection = "Character";

		private const string ClimbingSection = "Climbing";

		private const string FixesSection = "Fixes";

		private const string FogSection = "Fog";

		private const string GameplaySection = "Gameplay";

		private const string GUISection = "GUI";

		private const string InventorySection = "Inventory";

		private const string LobbySection = "Lobby";

		private const string MenuSection = "Menu";

		public static int SkipAirportUsesAscentNum;

		public static ManualLogSource MLS { get; private set; }

		public static ConfigEntry<bool> CampfiresPreventHunger { get; private set; }

		public static ConfigEntry<bool> KilnCampfireIsSafeZone { get; private set; }

		public static ConfigEntry<Enums.eEmoteLoopingOptions> EmoteLoopMode { get; private set; }

		public static ConfigEntry<Enums.eRopeVineChainOptions> RopeVineChainBehavior { get; private set; }

		public static ConfigEntry<bool> FixAirportRope { get; private set; }

		public static ConfigEntry<bool> FixDeadPlayersPreventingFog { get; private set; }

		public static ConfigEntry<bool> DisableFogTimer { get; private set; }

		public static ConfigEntry<Enums.eHotSunCookingOptions> HotSunCooksShieldingItems { get; private set; }

		public static ConfigEntry<bool> SpawnMissingPropsOnLateJoins { get; private set; }

		public static ConfigEntry<bool> PlayFogRisesSoundEachTime { get; private set; }

		public static ConfigEntry<bool> BringPassportToIsland { get; private set; }

		public static ConfigEntry<bool> ConsumableItemsGetLighter { get; private set; }

		public static ConfigEntry<bool> AirportElevatorDoorsAlwaysAnimate { get; private set; }

		public static ConfigEntry<Enums.eAirportElevatorOptions> AirportElevatorSpawnBehavior { get; private set; }

		public static ConfigEntry<bool> SkipAirportLobby { get; private set; }

		public static ConfigEntry<string> SkipAirportUsesAscent { get; private set; }

		public static ConfigEntry<bool> SkipPretitleScreen { get; private set; }

		private void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			MLS = ((BaseUnityPlugin)this).Logger;
			BindConfigs();
			MigrateOldConfigValues();
			MLS.LogInfo((object)"Configuration Initialized.");
			Harmony val = new Harmony("ShaosilGaming.PeakGeneralImprovements");
			foreach (Type item in (from t in Assembly.GetExecutingAssembly().GetTypes()
				where t.Namespace == ((object)this).GetType().Namespace + ".Patches" && t.Name.EndsWith("Patch")
				select t).ToList())
			{
				val.PatchAll(item);
				MLS.LogInfo((object)(Regex.Replace(item.Name, "Patch$", string.Empty) + " patched."));
			}
			MLS.LogInfo((object)"PeakGeneralImprovements v1.0.8 fully loaded.");
		}

		public void BindConfigs()
		{
			CampfiresPreventHunger = ((BaseUnityPlugin)this).Config.Bind<bool>("Campfire", "CampfiresPreventHunger", true, "If set to true, player will not get hungry when near a campfire.");
			KilnCampfireIsSafeZone = ((BaseUnityPlugin)this).Config.Bind<bool>("Campfire", "KilnCampfireIsSafeZone", true, "[Host Only] If set to true, the kiln lava timer will not start counting down until at least one person leaves its campfire area.");
			EmoteLoopMode = ((BaseUnityPlugin)this).Config.Bind<Enums.eEmoteLoopingOptions>("Character", "EmoteLoopMode", Enums.eEmoteLoopingOptions.NetworkedLooping, "When enabled, all player emotes except ragdoll will loop until you move. Networked looping animations are synced to everyone but some don't look as fluid. Local looping only shows for you, no one else.");
			RopeVineChainBehavior = ((BaseUnityPlugin)this).Config.Bind<Enums.eRopeVineChainOptions>("Climbing", "RopeVineChainBehavior", Enums.eRopeVineChainOptions.AllowClimbing, $"Changes the behavior of rope/vine/chain climbing. {Enums.eRopeVineChainOptions.AllowClimbing} allows grabbing surfaces while still hanging on. {Enums.eRopeVineChainOptions.AutoDismount} will also automatically dismount at the ends and attempt to start climbing if possible.");
			FixAirportRope = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "FixAirportRope", true, "If set to true, fixes the vanilla bug where the airport climbing rope only spawns the first time you start a game and not on subsequent loads.");
			FixDeadPlayersPreventingFog = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "FixDeadPlayersPreventingFog", true, "If set to true, fixes the vanilla bug where dead players who are below the fog rising threshold will prevent it from rising before the time limit.");
			DisableFogTimer = ((BaseUnityPlugin)this).Config.Bind<bool>("Fog", "DisableFogTimer", true, "[Host Only] If set to true, the fog will stop at all campfires until a player triggers its rising again by climbing higher.");
			HotSunCooksShieldingItems = ((BaseUnityPlugin)this).Config.Bind<Enums.eHotSunCookingOptions>("Gameplay", "HotSunCooksShieldingItems", Enums.eHotSunCookingOptions.None, "Allows the hot sun (in mesa) to continuously cook items that are being held up to shade the player from heat damage.");
			SpawnMissingPropsOnLateJoins = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "SpawnMissingPropsOnLateJoins", true, "[Host Only] If set to true, missing items (like upcoming marshmallows) will spawn when a player joins in the middle of a game.");
			PlayFogRisesSoundEachTime = ((BaseUnityPlugin)this).Config.Bind<bool>("GUI", "PlayFogRisesSoundEachTime", true, "If set to true, the 'Fog Rises' sound effect will be played on all zones, not just the shore.");
			BringPassportToIsland = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory", "BringPassportToIsland", false, "If set to true, you will start on the island holding your passport. Useful when skipping airport.");
			ConsumableItemsGetLighter = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory", "ConsumableItemsGetLighter", false, "If set to true, multiple use items like cookies and ropes will get lighter the more you use them. May show minor stamina bar desyncs on other players who do not use this setting.");
			AirportElevatorDoorsAlwaysAnimate = ((BaseUnityPlugin)this).Config.Bind<bool>("Lobby", "AirportElevatorDoorsAlwaysAnimate", true, "If set to true, the elevator doors will animate each time a new player joins.");
			AirportElevatorSpawnBehavior = ((BaseUnityPlugin)this).Config.Bind<Enums.eAirportElevatorOptions>("Lobby", "AirportElevatorSpawnBehavior", Enums.eAirportElevatorOptions.UseAllInOrder, "[Host Only] Allows all players to spawn in the other elevators in the airport instead of all crowding into one.");
			SkipAirportLobby = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "SkipAirportLobby", false, "If set to true, clicking Host Game or Play Offline will go directly to the island, bypassing the airport.");
			SkipAirportUsesAscent = ((BaseUnityPlugin)this).Config.Bind<string>("Menu", "SkipAirportUsesAscent", string.Empty, "If using SkipAirportLobby, setting this will use the specified number as the ascent level. Leaving it blank will use the max ascent you've unlocked. Clamped from -1 to your max unlocked ascent.");
			SkipPretitleScreen = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "SkipPretitleScreen", false, "If set to true, pre-title (intro) screen will be skipped on startup.");
		}

		public static void CalculateQuickStartAscent()
		{
			if (SkipAirportLobby.Value)
			{
				int num = 0;
				if (SteamManager.Initialized)
				{
					SteamUserStats.GetStat("MaxAscent", ref num);
				}
				if (int.TryParse(SkipAirportUsesAscent.Value, out var result))
				{
					SkipAirportUsesAscentNum = Mathf.Clamp(num, -1, num);
					MLS.LogDebug((object)string.Format("{0} specified {1} (current max {2}). Using {3} for quick start.", "SkipAirportUsesAscent", result, num, SkipAirportUsesAscentNum));
				}
				else
				{
					MLS.LogDebug((object)string.Format("{0} not specified. Using current max ascent ({1}) for quick start.", "SkipAirportUsesAscent", num));
					SkipAirportUsesAscentNum = num;
				}
			}
		}

		private void MigrateOldConfigValues()
		{
			try
			{
				ConfigFile config = ((BaseUnityPlugin)this).Config;
				if (!((config == null) ? null : config.OrphanedEntries?.Any()).GetValueOrDefault())
				{
					return;
				}
				foreach (KeyValuePair<ConfigDefinition, string> orphanedEntry in ((BaseUnityPlugin)this).Config.OrphanedEntries)
				{
					MigrateSpecificValue(orphanedEntry);
				}
				((BaseUnityPlugin)this).Config.OrphanedEntries.Clear();
				((BaseUnityPlugin)this).Config.Save();
			}
			catch (Exception arg)
			{
				MLS.LogError((object)$"Error encountered while migrating old config values! This will not affect gameplay, but please verify your config file to ensure the settings are as you expect.\n\n{arg}");
			}
		}

		private void MigrateSpecificValue(KeyValuePair<ConfigDefinition, string> entry)
		{
			MLS.LogMessage((object)("Found unused config value: " + entry.Key.Key + ". Migrating and removing if possible..."));
			string key = entry.Key.Key;
			bool result2;
			if (!(key == "FogSection"))
			{
				if (key == "SkipPretitleScreen")
				{
					if (bool.TryParse(entry.Value, out var result))
					{
						SkipPretitleScreen.Value = result;
					}
				}
				else
				{
					MLS.LogDebug((object)"No matching migration");
				}
			}
			else if (bool.TryParse(entry.Value, out result2))
			{
				DisableFogTimer.Value = result2;
			}
		}
	}
}
namespace PeakGeneralImprovements.Utilities
{
	internal static class TranspilerHelpers
	{
		public static IEnumerable<CodeInstruction> ReturnWithMessage(this IEnumerable<CodeInstruction> instructions, string message)
		{
			Plugin.MLS.LogWarning((object)message);
			return instructions;
		}
	}
}
namespace PeakGeneralImprovements.Patches
{
	internal static class Action_ReduceUsesPatch
	{
		[HarmonyPatch(typeof(Action_ReduceUses), "ReduceUsesRPC")]
		[HarmonyPostfix]
		private static void ReduceUsesRPC(Action_ReduceUses __instance)
		{
			if (Plugin.ConsumableItemsGetLighter.Value && ((ItemActionBase)__instance).character.IsLocal)
			{
				((ItemActionBase)__instance).character.refs.afflictions.UpdateWeight();
			}
		}
	}
	internal static class AirportCheckInKioskPatch
	{
		[CompilerGenerated]
		private sealed class <WaitToSpawnRope>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitToSpawnRope>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => PhotonNetwork.InRoom));
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					RopeAnchorWithRope[] array = Object.FindObjectsByType<RopeAnchorWithRope>((FindObjectsSortMode)0);
					for (int i = 0; i < array.Length; i++)
					{
						array[i].SpawnRope();
					}
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[HarmonyPatch(typeof(AirportCheckInKiosk), "Start")]
		[HarmonyPostfix]
		private static void Start(AirportCheckInKiosk __instance)
		{
			//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_0079: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.FixAirportRope.Value)
			{
				((MonoBehaviour)__instance).StartCoroutine(WaitToSpawnRope());
			}
			if (Plugin.AirportElevatorSpawnBehavior.Value == Enums.eAirportElevatorOptions.Vanilla)
			{
				return;
			}
			SpawnPoint[] array = Object.FindObjectsByType<SpawnPoint>((FindObjectsSortMode)0);
			if (array.Length == 1)
			{
				Plugin.MLS.LogInfo((object)"Creating more spawn points in the other elevators.");
				array[0].index = 1;
				float[] array2 = new float[3] { -15.2f, -4.2f, 1.4f };
				for (int i = 0; i < array2.Length; i++)
				{
					Vector3 position = ((Component)array[0]).transform.position;
					Object.Instantiate<SpawnPoint>(array[0], new Vector3(array2[i], position.y, position.z), ((Component)array[0]).transform.rotation, ((Component)array[0]).transform.parent).index = ((i < 1) ? i : (i + 1));
				}
				((Component)__instance).gameObject.AddComponent<AirportCheckInKioskUpdater>();
			}
			else
			{
				Plugin.MLS.LogWarning((object)"Multiple active spawnpoints already found in airport! Not creating more for the other elevators.");
			}
		}

		[IteratorStateMachine(typeof(<WaitToSpawnRope>d__1))]
		private static IEnumerator WaitToSpawnRope()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitToSpawnRope>d__1(0);
		}
	}
	internal static class CampfirePatch
	{
		internal static HashSet<Campfire> AllCampfires = new HashSet<Campfire>();

		internal static Campfire CurrentFarthest
		{
			get
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Expected I4, but got Unknown
				MapHandler instance = Singleton<MapHandler>.Instance;
				int valueOrDefault = ((int?)((instance != null) ? new Segment?(instance.GetCurrentSegment()) : null)).GetValueOrDefault(-1);
				if (instance == null)
				{
					return null;
				}
				GameObject segmentCampfire = instance.segments[valueOrDefault].segmentCampfire;
				if (segmentCampfire == null)
				{
					return null;
				}
				return segmentCampfire.GetComponentInChildren<Campfire>();
			}
		}

		internal static bool CharacterIsInRangeOfAnyCampfire(Character character)
		{
			if (Object.op_Implicit((Object)(object)character))
			{
				return AllCampfires.Any((Campfire c) => Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).transform) && Vector3.Distance(((Component)c).transform.position, character.Center) <= 30f);
			}
			return false;
		}

		[HarmonyPatch(typeof(Campfire), "Awake")]
		[HarmonyPostfix]
		private static void Awake(Campfire __instance)
		{
			AllCampfires.Add(__instance);
		}
	}
	internal static class CharacterAfflictionsPatch
	{
		private static float _hungerSkipLogCountdown = 5f;

		[HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")]
		[HarmonyPrefix]
		private static bool AddStatus(CharacterAfflictions __instance, STATUSTYPE statusType, float amount)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			if (Plugin.CampfiresPreventHunger.Value && __instance.character.IsLocal && (int)statusType == 1 && amount > 0f)
			{
				bool num = CampfirePatch.CharacterIsInRangeOfAnyCampfire(__instance.character);
				if (num)
				{
					_hungerSkipLogCountdown -= Time.deltaTime;
					if (_hungerSkipLogCountdown <= 0f)
					{
						Plugin.MLS.LogDebug((object)"Skipping hunger growth since player is near a campfire.");
						_hungerSkipLogCountdown = 5f;
					}
				}
				return !num;
			}
			return true;
		}

		[HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> UpdateWeight_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			if (Plugin.ConsumableItemsGetLighter.Value)
			{
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(ItemSlot).GetField("prefab"), false)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(Item).GetMethod("get_CarryWeight"))), (string)null),
					new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null)
				});
				if (!val.IsValid)
				{
					return instructions.ReturnWithMessage("Unexpected IL code when trying to transpile CharacterAfflictions.UpdateWeight. Multi use items will not get lighter!");
				}
				Plugin.MLS.LogDebug((object)"Transpiling CharacterAfflictions.UpdateWeight to allow multi use consumable items to get lighter when used.");
				val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
				{
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0019: Expected O, but got Unknown
					m.Advance(1);
					m.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldarg_0, (object)null));
					m.SetInstructionAndAdvance(Transpilers.EmitDelegate<Func<ItemSlot, CharacterAfflictions, int>>((Func<ItemSlot, CharacterAfflictions, int>)CalculateModifiedCarryWeight));
				}, (Action<string>)null);
			}
			return val.InstructionEnumeration();
		}

		private static int CalculateModifiedCarryWeight(ItemSlot itemSlot, CharacterAfflictions characterAfflictions)
		{
			RopeSpool val = null;
			float num = 1f;
			if (characterAfflictions.character.IsLocal && (((Component)itemSlot.prefab).TryGetComponent<RopeSpool>(ref val) || itemSlot.prefab.totalUses > 0))
			{
				FloatItemData val2 = default(FloatItemData);
				OptionableIntItemData val3 = default(OptionableIntItemData);
				if (Object.op_Implicit((Object)(object)val) && itemSlot.data.TryGetDataEntry<FloatItemData>((DataEntryKey)10, ref val2))
				{
					num = val2.Value / val.ropeStartFuel;
				}
				else if (itemSlot.prefab.totalUses > 0 && itemSlot.data.TryGetDataEntry<OptionableIntItemData>((DataEntryKey)2, ref val3) && val3.HasData)
				{
					num = (float)val3.Value / (float)itemSlot.prefab.totalUses;
				}
				Plugin.MLS.LogDebug((object)$"Multi-use item weight calculation being overridden - {Math.Round(num * 100f, 2)}% of original weight ({itemSlot.prefab.CarryWeight}) being used.");
			}
			return (int)Math.Round((float)itemSlot.prefab.CarryWeight * num);
		}
	}
	internal static class CharacterAnimationsPatch
	{
		private static string _lastPlayedEmote = string.Empty;

		[HarmonyPatch(typeof(CharacterAnimations), "PlayEmote")]
		[HarmonyPostfix]
		private static void PlayEmote(Character ___character, string emoteName)
		{
			if (Plugin.EmoteLoopMode.Value != 0 && ___character.IsLocal)
			{
				_lastPlayedEmote = emoteName;
			}
		}

		[HarmonyPatch(typeof(CharacterAnimations), "Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			if (Plugin.EmoteLoopMode.Value != 0)
			{
				string message = "Unexpected IL code when trying to transpile CharacterAnimations.Update. Emotes will not loop!";
				FieldInfo sinceEmoteStartField = typeof(CharacterAnimations).GetField("sinceEmoteStart", BindingFlags.Instance | BindingFlags.NonPublic);
				Label? retLabel = null;
				Label? label = default(Label?);
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
				{
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, sinceEmoteStartField, false)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 2.0)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref label)), (string)null)
				});
				if (val.IsInvalid)
				{
					return instructions.ReturnWithMessage(message);
				}
				val.RemoveInstructions(4);
				val.MatchBack(true, (CodeMatch[])(object)new CodeMatch[4]
				{
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(CharacterAnimations).GetField("emoting", BindingFlags.Instance | BindingFlags.NonPublic), false)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref retLabel)), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null)
				});
				if (val.IsInvalid)
				{
					return instructions.ReturnWithMessage(message);
				}
				string text = ((Plugin.EmoteLoopMode.Value == Enums.eEmoteLoopingOptions.NetworkedLooping) ? "networked" : "local");
				Plugin.MLS.LogDebug((object)("Transpiling CharacterAnimations.Update to make emotes use " + text + " looping until player moves."));
				val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null)
				});
				val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<CharacterAnimations, bool>>((Func<CharacterAnimations, bool>)ShouldKeepEmoting) });
				val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Brtrue_S, (object)retLabel)
				});
			}
			return val.InstructionEnumeration();
		}

		private static bool ShouldKeepEmoting(CharacterAnimations anim)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = anim.character.IsLocal && anim.sinceEmoteStart > 1.8f && !string.IsNullOrWhiteSpace(_lastPlayedEmote) && _lastPlayedEmote != "A_Scout_Emote_Flex";
			bool flag2 = _lastPlayedEmote == "A_Scout_Emote_Nono";
			if (flag && (Plugin.EmoteLoopMode.Value == Enums.eEmoteLoopingOptions.NetworkedLooping || flag2))
			{
				if (Plugin.EmoteLoopMode.Value == Enums.eEmoteLoopingOptions.NetworkedLooping)
				{
					RpcTarget val = (RpcTarget)((!flag2) ? 1 : 0);
					anim.character.refs.view.RPC("RPCA_PlayRemove", val, new object[1] { _lastPlayedEmote });
				}
				else if (flag2)
				{
					anim.character.refs.view.RPC("RPCA_PlayRemove", PhotonNetwork.LocalPlayer, new object[1] { _lastPlayedEmote });
				}
				anim.sinceEmoteStart = 0f;
			}
			return flag;
		}
	}
	internal static class CharacterClimbingPatch
	{
		[HarmonyPatch(typeof(CharacterClimbing), "CanClimb")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> CanClimb_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			if (Plugin.RopeVineChainBehavior.Value != 0)
			{
				string message = "Unexpected IL code when trying to transpile CharacterClimbing.CanClimb. Rope/vine/chain behavior will not be changed!";
				Label? vineBranch = null;
				new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(CharacterData).GetField("isVineClimbing"), false)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref vineBranch)), (string)null)
				});
				Label? label3 = default(Label?);
				val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(CharacterData).GetField("sinceClimb"), false)), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref label3)), (string)null)
				});
				if (!val.IsValid)
				{
					return instructions.ReturnWithMessage(message);
				}
				val.SetOperandAndAdvance((object)vineBranch);
				val.RemoveInstructions(2);
				Label? label2 = default(Label?);
				val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(CharacterData).GetField("isRopeClimbing"), false)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref label2)), (string)null)
				});
				if (!val.IsValid)
				{
					return instructions.ReturnWithMessage(message);
				}
				val.SetAndAdvance(OpCodes.Brtrue_S, (object)vineBranch);
				val.RemoveInstructions(2);
				Label? label = default(Label?);
				val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(CharacterData).GetField("isVineClimbing"), false)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref label)), (string)null)
				});
				if (!val.IsValid)
				{
					return instructions.ReturnWithMessage(message);
				}
				Plugin.MLS.LogDebug((object)"Transpiling CharacterClimbing.CanClimb to allow direct climbing from a rope/vine/chain.");
				val.Opcode = OpCodes.Brtrue_S;
			}
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(CharacterClimbing), "TryToStartWallClimb")]
		[HarmonyPostfix]
		private static void Test()
		{
		}
	}
	internal static class CharacterItemsPatch
	{
		internal static Guid OurPassportGuid = Guid.Empty;

		[HarmonyPatch(typeof(CharacterItems), "DoDropping")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DoDropping_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[4]
			{
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(CharacterData).GetMethod("get_currentItem"))), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(Component).GetMethod("get_transform"))), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(Transform).GetMethod("get_position"))), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stloc_0), (string)null)
			});
			if (val.IsValid)
			{
				Plugin.MLS.LogDebug((object)"Transpiling CharacterItems.DoDropping to fix items being able to fall through terrain when placed.");
				val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[5]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldfld, (object)typeof(CharacterItems).GetField("character", BindingFlags.Instance | BindingFlags.NonPublic)),
					new CodeInstruction(OpCodes.Ldfld, (object)typeof(Character).GetField("data")),
					new CodeInstruction(OpCodes.Callvirt, (object)typeof(CharacterData).GetMethod("get_currentItem")),
					Transpilers.EmitDelegate<Func<Vector3, Item, Vector3>>((Func<Vector3, Item, Vector3>)delegate(Vector3 originalPos, Item curItem)
					{
						//IL_0036: 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_003e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0043: Unknown result type (might be due to invalid IL or missing references)
						//IL_0048: Unknown result type (might be due to invalid IL or missing references)
						//IL_004a: Unknown result type (might be due to invalid IL or missing references)
						//IL_004f: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
						//IL_008d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0093: Unknown result type (might be due to invalid IL or missing references)
						//IL_0099: Unknown result type (might be due to invalid IL or missing references)
						//IL_009e: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
						Transform transform = ((Component)Object.FindAnyObjectByType<MainCamera>()).transform;
						float num = curItem.colliders.Max(delegate(Collider c)
						{
							//IL_0001: Unknown result type (might be due to invalid IL or missing references)
							//IL_0006: Unknown result type (might be due to invalid IL or missing references)
							//IL_0009: Unknown result type (might be due to invalid IL or missing references)
							//IL_000e: Unknown result type (might be due to invalid IL or missing references)
							Bounds bounds = c.bounds;
							Vector3 extents = ((Bounds)(ref bounds)).extents;
							return ((Vector3)(ref extents)).magnitude;
						});
						Vector3 val2 = originalPos + transform.forward * num;
						RaycastHit val3 = default(RaycastHit);
						if (Physics.Linecast(transform.position, val2, ref val3, LayerMask.GetMask(new string[3] { "Terrain", "Map", "InvisWall" })))
						{
							Plugin.MLS.LogDebug((object)"Item dropped close to terrain! Using closest contact point instead.");
							originalPos = ((RaycastHit)(ref val3)).point - transform.forward * num;
						}
						return originalPos;
					})
				});
			}
			else
			{
				Plugin.MLS.LogWarning((object)"Unexpected IL code when trying to transpile CharacterItems.DoDropping. Item dropping will NOT be fixed!");
			}
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(CharacterItems), "AttachItem")]
		[HarmonyPostfix]
		private static void AttachItem(CharacterItems __instance, Character ___character, Item item)
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			Action_Passport val = default(Action_Passport);
			if (Plugin.BringPassportToIsland.Value && ((Component)item).TryGetComponent<Action_Passport>(ref val))
			{
				if (___character.IsLocal && OurPassportGuid == Guid.Empty)
				{
					Plugin.MLS.LogDebug((object)$"Holding passport for first time. Storing GUID {item.data.guid} as our own.");
					OurPassportGuid = item.data.guid;
				}
				else if (!___character.IsLocal && item.data.guid == OurPassportGuid)
				{
					Plugin.MLS.LogInfo((object)("Player " + ___character.characterName + " picked up our passport, forcing them to drop it."));
					((MonoBehaviourPun)__instance).photonView.RPC("DropItemRpc", (RpcTarget)0, new object[6]
					{
						0f,
						__instance.currentSelectedSlot.Value,
						((Component)item).transform.position,
						item.rig.linearVelocity,
						((Component)item).transform.rotation,
						___character.player.GetItemSlot(__instance.currentSelectedSlot.Value).data
					});
				}
			}
		}
	}
	internal static class CharacterRopeHandlingPatch
	{
		[HarmonyPatch(typeof(CharacterRopeHandling), "Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			RopesAndVines.TranspileRopeAndVineUpdate(val, typeof(CharacterRopeHandling));
			return val.InstructionEnumeration();
		}
	}
	internal static class CharacterSpawnerPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SpawnLocalPlayer_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			if (Plugin.AirportElevatorSpawnBehavior.Value == Enums.eAirportElevatorOptions.UseAllRandomly)
			{
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[6]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(PhotonNetwork).GetMethod("get_LocalPlayer"))), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(Player).GetMethod("get_ActorNumber"))), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(SpawnPoint).GetField("allSpawnPoints"), false)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(List<SpawnPoint>).GetMethod("get_Count"))), (string)null),
					new CodeMatch((OpCode?)OpCodes.Rem, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null)
				});
				if (!val.IsValid)
				{
					return instructions.ReturnWithMessage("Unexpected IL code when trying to transpile CharacterSpawner.SpawnLocalPlayer. Players will spawn in all elevators sequentially instead of randomly!");
				}
				Plugin.MLS.LogDebug((object)"Transpiling CharacterSpawner.SpawnLocalPlayer to allow players to spawn in all elevators randomly.");
				val.RemoveInstructions(4);
				val.SetInstruction(Transpilers.EmitDelegate<Func<int>>((Func<int>)(() => Random.Range(0, SpawnPoint.allSpawnPoints.Count))));
			}
			return val.InstructionEnumeration();
		}
	}
	internal static class CharacterVineClimbingPatch
	{
		[HarmonyPatch(typeof(CharacterVineClimbing), "Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			RopesAndVines.TranspileRopeAndVineUpdate(val, typeof(CharacterVineClimbing));
			return val.InstructionEnumeration();
		}
	}
	internal static class GUIManagerPatch
	{
		private static AudioSource fogSFX;

		private static AudioSource lavaSFX;

		[HarmonyPatch(typeof(GUIManager), "Start")]
		[HarmonyPostfix]
		private static void Start(GUIManager __instance)
		{
			fogSFX = __instance.fogRises.GetComponentInChildren<AudioSource>();
			lavaSFX = __instance.lavaRises.GetComponentInChildren<AudioSource>();
			if ((Object)(object)fogSFX != (Object)null)
			{
				fogSFX.playOnAwake = false;
			}
			if ((Object)(object)lavaSFX != (Object)null)
			{
				lavaSFX.playOnAwake = false;
			}
		}

		[HarmonyPatch(typeof(GUIManager), "TheFogRises")]
		[HarmonyPostfix]
		private static void TheFogRises()
		{
			if (Plugin.PlayFogRisesSoundEachTime.Value && (Object)(object)fogSFX != (Object)null)
			{
				fogSFX.Play();
			}
		}

		[HarmonyPatch(typeof(GUIManager), "TheLavaRises")]
		[HarmonyPostfix]
		private static void TheLavaRises()
		{
			if (Plugin.PlayFogRisesSoundEachTime.Value && (Object)(object)lavaSFX != (Object)null)
			{
				lavaSFX.Play();
			}
		}
	}
	internal static class HotSunPatch
	{
		private static ItemCooking _currentlyCookingItem = null;

		private static Dictionary<ItemCooking, float> _cookingItemsProgress = new Dictionary<ItemCooking, float>();

		[HarmonyPatch(typeof(HotSun), "Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			if (Plugin.HotSunCooksShieldingItems.Value != 0)
			{
				Label? retLabel = null;
				Label? label2 = default(Label?);
				val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[5]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref label2)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsStloc(i, (LocalBuilder)null)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref retLabel)), (string)null)
				});
				if (val.IsValid)
				{
					Plugin.MLS.LogDebug((object)("Transpiling HotSun.Update to cook held" + ((Plugin.HotSunCooksShieldingItems.Value == Enums.eHotSunCookingOptions.OnlyFood) ? " food " : " ") + "items when shading player."));
					val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action>((Action)ProcessCookingItems) });
					Label label = default(Label);
					val.CreateLabelAt(val.Pos + 1, ref label);
					val.SetAndAdvance(OpCodes.Brtrue_S, (object)label);
					val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldloc_S, (object)1)
					});
					val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action<RaycastHit>>((Action<RaycastHit>)delegate(RaycastHit r)
					{
						//IL_0000: Unknown result type (might be due to invalid IL or missing references)
						CheckItemCooking(r);
					}) });
					val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Br_S, (object)retLabel)
					});
				}
				else
				{
					Plugin.MLS.LogWarning((object)"Unexpected IL code when trying to transpile HotSun.Update. Items will NOT be cooked when used as shade!");
				}
			}
			return val.InstructionEnumeration();
		}

		private static void ProcessCookingItems()
		{
			List<ItemCooking> list = new List<ItemCooking>();
			foreach (KeyValuePair<ItemCooking, float> item in _cookingItemsProgress)
			{
				if ((Object)(object)item.Key != (Object)(object)_currentlyCookingItem)
				{
					list.Add(item.Key);
				}
			}
			foreach (ItemCooking item2 in list)
			{
				_cookingItemsProgress.Remove(item2);
				if (Object.op_Implicit((Object)(object)item2))
				{
					item2.CancelCookingVisuals();
					Plugin.MLS.LogDebug((object)("Item " + ((ItemComponent)item2).item.GetName() + " cancelled cooking while blocking the sun."));
				}
			}
			if (!Object.op_Implicit((Object)(object)_currentlyCookingItem))
			{
				return;
			}
			_cookingItemsProgress[_currentlyCookingItem] += 0.2f * Time.deltaTime;
			if (_cookingItemsProgress[_currentlyCookingItem] >= 1f)
			{
				_currentlyCookingItem.FinishCooking();
				if (((ItemComponent)_currentlyCookingItem).item.GetData<IntItemData>((DataEntryKey)1).Value < 4)
				{
					_currentlyCookingItem.StartCookingVisuals();
					_cookingItemsProgress[_currentlyCookingItem] = 0f;
				}
				string name = ((ItemComponent)_currentlyCookingItem).item.GetName();
				Plugin.MLS.LogDebug((object)("Item " + name + " finished cooking (" + ((ItemComponent)_currentlyCookingItem).item.GetItemName((ItemInstanceData)null).Replace(" " + name, "") + ") while blocking the sun."));
			}
			_currentlyCookingItem = null;
		}

		private static void CheckItemCooking(RaycastHit raycastHit)
		{
			ItemCooking val = default(ItemCooking);
			Action_RestoreHunger val2 = default(Action_RestoreHunger);
			if (Object.op_Implicit((Object)(object)((RaycastHit)(ref raycastHit)).transform) && ((Component)((RaycastHit)(ref raycastHit)).transform).TryGetComponent<ItemCooking>(ref val) && val.canBeCooked && (Object)(object)Character.localCharacter.data.currentItem == (Object)(object)((ItemComponent)val).item && ((((ItemComponent)val).item.GetData<IntItemData>((DataEntryKey)1).Value < 4 && Plugin.HotSunCooksShieldingItems.Value == Enums.eHotSunCookingOptions.AllCookables) || ((Component)val).TryGetComponent<Action_RestoreHunger>(ref val2)))
			{
				_currentlyCookingItem = val;
				if (_cookingItemsProgress.TryAdd(_currentlyCookingItem, 0f))
				{
					_currentlyCookingItem.StartCookingVisuals();
					Plugin.MLS.LogDebug((object)("Item " + ((ItemComponent)_currentlyCookingItem).item.GetName() + " started cooking while blocking the sun."));
				}
			}
		}
	}
	internal static class LavaPatch
	{
		[HarmonyPatch(typeof(Lava), "TryCookItems")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TryCookItems(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			Plugin.MLS.LogDebug((object)"Transpiling Lava.TryCookItems to destroy incinerated items.");
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(ItemCooking).GetMethod("FinishCooking"))), (string)null)
			}).SetInstruction(Transpilers.EmitDelegate<Action<ItemCooking>>((Action<ItemCooking>)delegate(ItemCooking i)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					if (((ItemComponent)i).item.GetData<IntItemData>((DataEntryKey)1).Value <= 3)
					{
						i.FinishCooking();
					}
					else
					{
						Plugin.MLS.LogInfo((object)(((ItemComponent)i).item.GetName() + " has been incinerated in lava. Destroying."));
						PhotonNetwork.Destroy(((MonoBehaviourPun)i).photonView);
					}
				}
			}));
			return val.InstructionEnumeration();
		}
	}
	internal static class LavaRisingPatch
	{
		[HarmonyPatch(typeof(LavaRising), "Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			if (Plugin.KilnCampfireIsSafeZone.Value)
			{
				Label? falseLabel = null;
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
				{
					new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.StoresField(i, typeof(LavaRising).GetField("syncTime", BindingFlags.Instance | BindingFlags.NonPublic))), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(LavaRising).GetMethod("get_started"))), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref falseLabel)), (string)null)
				});
				if (val.IsInvalid)
				{
					return instructions.ReturnWithMessage("Unexpected IL code when trying to transpile LavaRising.Update. Kiln campfire will NOT be a safe zone!");
				}
				Plugin.MLS.LogDebug((object)"Transpiling LavaRising.Update to allow the kiln campfire to act as a safe zone.");
				val.Advance(2);
				val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
				{
					new CodeInstruction(Transpilers.EmitDelegate<Func<bool>>((Func<bool>)EveryoneAtCampfire)),
					new CodeInstruction(OpCodes.Brtrue_S, (object)falseLabel)
				});
			}
			return val.InstructionEnumeration();
		}

		private static bool EveryoneAtCampfire()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				return Character.AllCharacters.All((Character c) => Object.op_Implicit((Object)(object)c) && (c.data.dead || CampfirePatch.CharacterIsInRangeOfAnyCampfire(c)));
			}
			return false;
		}
	}
	internal static class MainMenuPatch
	{
		[HarmonyPatch(typeof(MainMenu), "Start")]
		[HarmonyPostfix]
		private static void Start()
		{
			Plugin.CalculateQuickStartAscent();
		}

		[HarmonyPatch(typeof(MainMenu), "PlaySoloClicked")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PlaySoloClicked_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			AirportLobbySkip.ReplaceBasicLoadingScreenWithPlane(val, "MainMenu.PlaySoloClicked");
			return val.InstructionEnumeration();
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> StartOfflineModeRoutine_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			AirportLobbySkip.TranspileStartGameButtons(val, "MainMenu.StartOfflineModeRoutine");
			return val.InstructionEnumeration();
		}
	}
	internal static class MapHandlerPatch
	{
		[HarmonyPatch(typeof(MapHandler), "Awake")]
		[HarmonyPatch(typeof(MapHandler), "OnDestroy")]
		[HarmonyPostfix]
		private static void AwakeAndDestroy()
		{
			CampfirePatch.AllCampfires = new HashSet<Campfire>();
		}
	}
	internal static class OrbFogHandlerPatch
	{
		[HarmonyPatch(typeof(OrbFogHandler), "TimeToMove")]
		[HarmonyPrefix]
		private static bool TimeToMove(ref bool __result)
		{
			if (Plugin.DisableFogTimer.Value && PhotonNetwork.IsMasterClient)
			{
				__result = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(OrbFogHandler), "PlayersHaveMovedOn")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PlayersHaveMovedOn_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			if (Plugin.FixDeadPlayersPreventingFog.Value)
			{
				string message = "Unexpected IL code when trying to transpile OrbFogHandler.PlayersHaveMovedOn. Dead players will still affect fog trigger!";
				Label? continueLable = null;
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(OrbFogHandler).GetField("currentStartForward"), false)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref continueLable)), (string)null)
				});
				if (val.IsInvalid)
				{
					return instructions.ReturnWithMessage(message);
				}
				val.MatchBack(true, (CodeMatch[])(object)new CodeMatch[5]
				{
					new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref continueLable)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(Character).GetField("AllCharacters"), false)), (string)null)
				});
				if (val.IsInvalid)
				{
					return instructions.ReturnWithMessage(message);
				}
				Plugin.MLS.LogDebug((object)"Transpiling OrbFogHandler.PlayersHaveMovedOn to fix dead players affecting fog rising trigger.");
				val.Advance(-1);
				val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[6]
				{
					new CodeInstruction(OpCodes.Ldsfld, (object)typeof(Character).GetField("AllCharacters")),
					new CodeInstruction(OpCodes.Ldloc_0, (object)null),
					new CodeInstruction(OpCodes.Callvirt, (object)typeof(List<Character>).GetMethod("get_Item")),
					new CodeInstruction(OpCodes.Ldfld, (object)typeof(Character).GetField("data")),
					new CodeInstruction(OpCodes.Ldfld, (object)typeof(CharacterData).GetField("dead")),
					new CodeInstruction(OpCodes.Brtrue_S, (object)continueLable)
				});
			}
			return val.InstructionEnumeration();
		}
	}
	internal static class PretitlePatch
	{
		[HarmonyPatch(typeof(Pretitle), "Start")]
		[HarmonyPostfix]
		private static void Start()
		{
			if (Plugin.SkipPretitleScreen.Value)
			{
				Plugin.MLS.LogMessage((object)"Skipping pre-title screen.");
				SceneManager.LoadScene("Title", (LoadSceneMode)0);
			}
		}
	}
	internal static class RopeAnchorWithRopePatch
	{
		[HarmonyPatch(typeof(RopeAnchorWithRope), "OnJoinedRoom")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> OnJoinedRoom_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			if (Plugin.FixAirportRope.Value)
			{
				Plugin.MLS.LogDebug((object)"Transpiling RopeAnchorWithRope.OnJoinedRoom to fix climbing wall rope only working one time.");
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)0)), (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(RopeAnchorWithRope).GetMethod("SpawnRope"))), (string)null),
					new CodeMatch((OpCode?)OpCodes.Pop, (object)null, (string)null)
				});
				if (val.IsValid)
				{
					val.RemoveInstructions(3);
				}
				else
				{
					Plugin.MLS.LogWarning((object)"Unexpected IL code - Could not transpile RopeAnchorWithRope.OnJoinedRoom to fix climbing wall rope only working one time!");
				}
			}
			return val.InstructionEnumeration();
		}
	}
	internal static class RopeSpoolPatch
	{
		[HarmonyPatch(typeof(RopeSpool), "set_RopeFuel")]
		[HarmonyPostfix]
		private static void set_RopeFuel(Item ___item)
		{
			if (Plugin.ConsumableItemsGetLighter.Value && Object.op_Implicit((Object)(object)___item) && Object.op_Implicit((Object)(object)___item.holderCharacter) && ___item.holderCharacter.IsLocal)
			{
				___item.holderCharacter.refs.afflictions.UpdateWeight();
			}
		}
	}
	internal static class RunManagerPatch
	{
		[HarmonyPatch(typeof(RunManager), "StartRun")]
		[HarmonyPostfix]
		private static void StartRun()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.BringPassportToIsland.Value)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name != "Airport")
				{
					((Component)Character.localCharacter).gameObject.AddComponent<SpawnItemInHand>().item = Resources.Load<GameObject>("0_Items/Passport").GetComponent<Item>();
				}
			}
			CharacterItemsPatch.OurPassportGuid = Guid.Empty;
		}

		[HarmonyPatch(typeof(RunManager), "OnPlayerEnteredRoom")]
		[HarmonyPostfix]
		private static void OnPlayerEnteredRoom()
		{
			if (!Plugin.SpawnMissingPropsOnLateJoins.Value || !PhotonNetwork.IsMasterClient)
			{
				return;
			}
			foreach (SingleItemSpawner item in (from s in Object.FindObjectsByType<SingleItemSpawner>((FindObjectsSortMode)0)
				where s.playersInRoomRequirement == PhotonNetwork.PlayerList.Length && Object.op_Implicit((Object)(object)s.prefab)
				select s).ToList())
			{
				Plugin.MLS.LogInfo((object)("Trying to spawn missing " + ((Object)item.prefab).name + " when new player joined."));
				item.TrySpawnItems();
			}
		}
	}
	internal static class SimpleDrawMeshPatch
	{
		[HarmonyPatch(typeof(SimpleDrawMesh), "drawMeshes")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> drawMeshes_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			Plugin.MLS.LogDebug((object)"Transpiling SimpleDrawMesh.drawMeshes to fix object culling for spectated players.");
			val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(Character).GetField("localCharacter"), false)), (string)null)
			}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
			{
				m.SetAndAdvance(OpCodes.Call, (object)typeof(Character).GetMethod("get_observedCharacter"));
			}, (Action<string>)null);
			val.Advance(-1).SearchBack((Func<CodeInstruction, bool>)((CodeInstruction m) => m.operand is MethodBase methodBase && methodBase.Name == "DrawMeshInstanced"));
			val.SetInstruction(Transpilers.EmitDelegate<Action<Mesh, int, Material, Matrix4x4[], int>>((Action<Mesh, int, Material, Matrix4x4[], int>)delegate(Mesh mesh, int i, Material mat, Matrix4x4[] mtr, int count)
			{
				Graphics.DrawMeshInstanced(mesh, i, mat, mtr, count, (MaterialPropertyBlock)null, (ShadowCastingMode)1, false);
			}));
			return val.InstructionEnumeration();
		}
	}
	internal static class SpawnItemInHandPatch
	{
		[HarmonyPatch(typeof(SpawnItemInHand), "Start")]
		[HarmonyPostfix]
		private static void Start(SpawnItemInHand __instance)
		{
			if (Plugin.BringPassportToIsland.Value)
			{
				bool? obj;
				if (__instance == null)
				{
					obj = null;
				}
				else
				{
					Item item = __instance.item;
					Action_Passport val = default(Action_Passport);
					obj = ((item != null) ? new bool?(((Component)item).TryGetComponent<Action_Passport>(ref val)) : null);
				}
				bool? flag = obj;
				if (flag.GetValueOrDefault())
				{
					Plugin.MLS.LogDebug((object)"Overwriting Passport prefab to allow it to be dropped and thrown.");
					__instance.item.UIData.canDrop = true;
					__instance.item.UIData.canThrow = true;
				}
			}
		}
	}
	internal static class SteamLobbyHandlerPatch
	{
		[HarmonyPatch(typeof(SteamLobbyHandler), "OnLobbyCreated")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> OnLobbyCreated_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			AirportLobbySkip.ReplaceBasicLoadingScreenWithPlane(val, "SteamLobbyHandler.OnLobbyCreated");
			AirportLobbySkip.TranspileStartGameButtons(val);
			return val.InstructionEnumeration();
		}
	}
}
namespace PeakGeneralImprovements.Patches.Shared
{
	internal static class AirportLobbySkip
	{
		internal static void ReplaceBasicLoadingScreenWithPlane(CodeMatcher matcher, string methodDesc)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			if (Plugin.SkipAirportLobby.Value)
			{
				matcher.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 0L)), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldnull, (object)null, (string)null),
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i, 1L)), (string)null),
					new CodeMatch((OpCode?)OpCodes.Newarr, (object)null, (string)null)
				});
				if (matcher.IsValid)
				{
					Plugin.MLS.LogDebug((object)("Transpiling " + methodDesc + " to skip airport lobby."));
					matcher.SetOpcodeAndAdvance(OpCodes.Ldc_I4_1);
				}
				else
				{
					Plugin.MLS.LogWarning((object)("Unexpected IL code when trying to transpile " + methodDesc + ". Airport lobby may not be skipped!"));
				}
			}
		}

		public static void TranspileStartGameButtons(CodeMatcher matcher, string methodDesc = null)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			if (!Plugin.SkipAirportLobby.Value)
			{
				return;
			}
			matcher.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
			{
				new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Airport", (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i)), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i)), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsConstant(i)), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(LoadingScreenHandler).GetMethod("LoadSceneProcess", BindingFlags.Instance | BindingFlags.NonPublic))), (string)null)
			});
			if (matcher.IsValid)
			{
				if (!string.IsNullOrWhiteSpace(methodDesc))
				{
					Plugin.MLS.LogDebug((object)("Transpiling " + methodDesc + " to skip airport lobby."));
				}
				matcher.SetInstruction(Transpilers.EmitDelegate<Func<string>>((Func<string>)GetCurrentIslandName));
			}
			else
			{
				Plugin.MLS.LogWarning((object)("Unexpected IL code when trying to transpile " + methodDesc + ". Airport lobby may not be skipped!"));
			}
		}

		private static string GetCurrentIslandName()
		{
			//IL_0022: 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_007a: Expected O, but got Unknown
			NextLevelService service = GameHandler.GetService<NextLevelService>();
			MapBaker instance = SingletonAsset<MapBaker>.Instance;
			string text = null;
			if (service.Data.IsSome)
			{
				text = instance.GetLevel(service.Data.Value.CurrentLevelIndex);
			}
			else if (PhotonNetwork.OfflineMode)
			{
				text = instance.GetLevel(0);
			}
			if (string.IsNullOrWhiteSpace(text))
			{
				text = "WilIsland";
			}
			Plugin.MLS.LogInfo((object)$"Skipping airport lobby, going directly to level '{text}' at ascent level {Plugin.SkipAirportUsesAscentNum}.");
			GameHandler.AddStatus<SceneSwitchingStatus>((GameStatus)new SceneSwitchingStatus());
			Ascents.currentAscent = Plugin.SkipAirportUsesAscentNum;
			return text;
		}
	}
	internal static class RopesAndVines
	{
		public static void TranspileRopeAndVineUpdate(CodeMatcher matcher, Type classType)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Expected O, but got Unknown
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Expected O, but got Unknown
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			if (Plugin.RopeVineChainBehavior.Value == Enums.eRopeVineChainOptions.Vanilla)
			{
				return;
			}
			CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)classType.GetField("character", BindingFlags.Instance | BindingFlags.NonPublic))
			};
			string text = ((Plugin.RopeVineChainBehavior.Value == Enums.eRopeVineChainOptions.AllowClimbing) ? "allow climbing while on ropes/vines/chains." : "automatically dismount and attempt to climb at the end of ropes/vines/chains.");
			Label? trueLabel = null;
			Label? label2 = default(Label?);
			matcher.MatchForward(true, (CodeMatch[])(object)new CodeMatch[10]
			{
				new CodeMatch(array[0], (string)null),
				new CodeMatch(array[1], (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, typeof(Character).GetMethod("get_IsLocal"))), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref label2)), (string)null),
				new CodeMatch(array[0], (string)null),
				new CodeMatch(array[1], (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(Character).GetField("input"), false)), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.LoadsField(i, typeof(CharacterInput).GetField("jumpWasPressed"), false)), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Branches(i, ref trueLabel)), (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => true), (string)null)
			});
			if (matcher.IsValid)
			{
				Plugin.MLS.LogDebug((object)("Transpiling " + classType.Name + ".Update to " + text));
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[5]
				{
					array[0],
					array[1],
					new CodeInstruction(OpCodes.Ldfld, (object)typeof(Character).GetField("data")),
					new CodeInstruction(OpCodes.Ldfld, (object)typeof(CharacterData).GetField("isClimbing")),
					new CodeInstruction(OpCodes.Brtrue_S, (object)trueLabel)
				});
				if (Plugin.RopeVineChainBehavior.Value == Enums.eRopeVineChainOptions.AutoDismount)
				{
					Label label = default(Label);
					matcher.CreateLabel(ref label);
					matcher.Insert((CodeInstruction[])(object)new CodeInstruction[8]
					{
						array[0],
						array[1],
						Transpilers.EmitDelegate<Func<Character, bool>>((Func<Character, bool>)((Character c) => ShouldAutoDismount(c, classType))),
						new CodeInstruction(OpCodes.Brfalse_S, (object)label),
						array[0],
						array[1],
						Transpilers.EmitDelegate<Action<Character>>((Action<Character>)delegate(Character c)
						{
							//IL_0012: Unknown result type (might be due to invalid IL or missing references)
							c.refs.climbing.TryToStartWallClimb(true, c.data.lookDirection, false);
						}),
						new CodeInstruction(OpCodes.Br_S, (object)trueLabel)
					});
				}
			}
			else
			{
				Plugin.MLS.LogWarning((object)("Unexpected IL code when trying to transpile " + classType.Name + ".Update. Rope/vine/chain behavior will not be changed!"));
			}
		}

		private static bool ShouldAutoDismount(Character character, Type classType)
		{
			bool num = classType == typeof(CharacterRopeHandling);
			bool flag = character.input.movementInput.y > 0f;
			float num2 = (num ? character.data.ropePercent : character.data.vinePercent);
			bool flag2 = num2 <= 0.01f;
			bool flag3 = num2 >= 0.99f;
			if (!num)
			{
				if (MathF.Abs(character.input.movementInput.y) >= 0.1f)
				{
					return flag2 || flag3;
				}
				return false;
			}
			if (!(flag && flag3))
			{
				return !flag && flag2;
			}
			return true;
		}
	}
}
namespace PeakGeneralImprovements.Objects
{
	internal class AirportCheckInKioskUpdater : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass4_0
		{
			public Character character;

			internal float <OpenElevatorDoors>b__0(KeyValuePair<SpawnPoint, Animator> e)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				return Vector3.Distance(((Component)e.Key).transform.position, character.Center);
			}
		}

		[CompilerGenerated]
		private sealed class <OpenElevatorDoors>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Character character;

			public AirportCheckInKioskUpdater <>4__this;

			private <>c__DisplayClass4_0 <>8__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OpenElevatorDoors>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>8__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Expected O, but got Unknown
				int num = <>1__state;
				AirportCheckInKioskUpdater airportCheckInKioskUpdater = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>8__1 = new <>c__DisplayClass4_0();
					<>8__1.character = character;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					KeyValuePair<SpawnPoint, Animator> keyValuePair = airportCheckInKioskUpdater._spawnPointElevatorAnimators.OrderBy((KeyValuePair<SpawnPoint, Animator> e) => Vector3.Distance(((Component)e.Key).transform.position, <>8__1.character.Center)).FirstOrDefault();
					if (Object.op_Implicit((Object)(object)keyValuePair.Value))
					{
						Plugin.MLS.LogInfo((object)$"Playing elevator index {keyValuePair.Key.index}'s animation locally for {<>8__1.character.characterName}'s spawn position.");
						keyValuePair.Value.Play(string.Empty);
					}
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private HashSet<int> _spawnedPlayerIDs = new HashSet<int>();

		private Dictionary<SpawnPoint, Animator> _spawnPointElevatorAnimators = new Dictionary<SpawnPoint, Animator>();

		private void Start()
		{
			if (!Plugin.AirportElevatorDoorsAlwaysAnimate.Value)
			{
				return;
			}
			List<Animator> source = (from g in Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0).Where(delegate(GameObject g)
				{
					Animator val = default(Animator);
					if (g.TryGetComponent<Animator>(ref val))
					{
						RuntimeAnimatorController runtimeAnimatorController = val.runtimeAnimatorController;
						return ((runtimeAnimatorController != null) ? ((Object)runtimeAnimatorController).name : null) == "Elevator";
					}
					return false;
				})
				select g.GetComponent<Animator>()).ToList();
			foreach (SpawnPoint sp in SpawnPoint.allSpawnPoints)
			{
				_spawnPointElevatorAnimators[sp] = source.OrderBy((Animator e) => Vector3.Distance(((Component)e).transform.position, ((Component)sp).transform.position)).FirstOrDefault();
			}
		}

		private void Update()
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			int[] connectedPlayerIDs = PhotonNetwork.PlayerList.Select((Player p) => p.ActorNumber).ToArray();
			int[] array = connectedPlayerIDs;
			Character val = default(Character);
			foreach (int num in array)
			{
				if (_spawnedPlayerIDs.Contains(num) || !PlayerHandler.TryGetCharacter(num, ref val))
				{
					continue;
				}
				_spawnedPlayerIDs.Add(num);
				if (val.IsLocal)
				{
					continue;
				}
				if (PhotonNetwork.IsMasterClient)
				{
					int elevatorIndex = ((Plugin.AirportElevatorSpawnBehavior.Value == Enums.eAirportElevatorOptions.UseAllInOrder) ? (num % SpawnPoint.allSpawnPoints.Count) : Random.Range(0, SpawnPoint.allSpawnPoints.Count));
					SpawnPoint val2 = ((IEnumerable<SpawnPoint>)SpawnPoint.allSpawnPoints).FirstOrDefault((Func<SpawnPoint, bool>)((SpawnPoint s) => s.index == elevatorIndex)) ?? SpawnPoint.allSpawnPoints.ElementAtOrDefault(elevatorIndex) ?? SpawnPoint.allSpawnPoints[0];
					Plugin.MLS.LogInfo((object)$"{val.characterName} joined - warping them to elevator spawn index {val2.index}.");
					((MonoBehaviourPun)val).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
					{
						((Component)val2).transform.position,
						false
					});
				}
				if (Plugin.AirportElevatorDoorsAlwaysAnimate.Value)
				{
					((MonoBehaviour)this).StartCoroutine(OpenElevatorDoors(val));
				}
			}
			_spawnedPlayerIDs.RemoveWhere((int p) => !connectedPlayerIDs.Contains(p));
		}

		[IteratorStateMachine(typeof(<OpenElevatorDoors>d__4))]
		private IEnumerator OpenElevatorDoors(Character character)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OpenElevatorDoors>d__4(0)
			{
				<>4__this = this,
				character = character
			};
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}