Decompiled source of DropperFix v1.1.5

plugins/com.github.Arof2.Beast_Mode.dll

Decompiled 9 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKLib.Core;
using PEAKLib.Items;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;

[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.Arof2.Beast_Mode")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+c78cc2c6e2e5c74e115f58a7282d2dbd82c59564")]
[assembly: AssemblyProduct("com.github.Arof2.Beast_Mode")]
[assembly: AssemblyTitle("Dropper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 Dropper
{
	public class AddItemInNetwork : MonoBehaviourPun
	{
		private PhotonView photonView;

		private void Awake()
		{
			photonView = ((Component)this).GetComponent<PhotonView>();
		}

		public void AddItemIntoInventory(int itemID, int photonID)
		{
			photonView.RPC("AddItemIntoInventoryRPC", (RpcTarget)2, new object[2] { itemID, photonID });
			Plugin.Log.LogInfo((object)$"Client requesting item id: {itemID} to player with photonID: {photonID}");
		}

		[PunRPC]
		public void AddItemIntoInventoryRPC(int itemID, int photonID)
		{
			ItemSlot val = default(ItemSlot);
			((Component)PhotonNetwork.GetPhotonView(photonID)).GetComponent<Character>().player.AddItem((ushort)itemID, (ItemInstanceData)null, ref val);
			Plugin.Log.LogInfo((object)$"Host giving player {photonID} the item {(ushort)itemID}");
		}
	}
	public class InteractableBackPorter : MonoBehaviourPun, IInteractibleConstant, IInteractible
	{
		public Action<Character> Interacted;

		private MaterialPropertyBlock mpb;

		private MeshRenderer[] _mr;

		public float interactTime => 2f;

		public bool holdOnFinish
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		private MeshRenderer[] meshRenderers
		{
			get
			{
				if (_mr == null)
				{
					_mr = ((Component)this).GetComponentsInChildren<MeshRenderer>();
					MonoBehaviour.print((object)_mr.Length);
				}
				return _mr;
			}
			set
			{
				_mr = value;
			}
		}

		public void CancelCast(Character interactor)
		{
		}

		public void Awake()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			mpb = new MaterialPropertyBlock();
		}

		public Vector3 Center()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position;
		}

		public string GetInteractionText()
		{
			return "Teleport To Last Area";
		}

		public float GetInteractTime(Character interactor)
		{
			return interactTime;
		}

		public string GetName()
		{
			return "Reverse Teleporter";
		}

		public Transform GetTransform()
		{
			return ((Component)this).transform;
		}

		public void HoverEnter()
		{
			if (mpb == null)
			{
				return;
			}
			mpb.SetFloat(Item.PROPERTY_INTERACTABLE, 1f);
			for (int i = 0; i < meshRenderers.Length; i++)
			{
				if ((Object)(object)meshRenderers[i] != (Object)null)
				{
					((Renderer)meshRenderers[i]).SetPropertyBlock(mpb);
				}
			}
		}

		public void HoverExit()
		{
			if (mpb != null)
			{
				mpb.SetFloat(Item.PROPERTY_INTERACTABLE, 0f);
				for (int i = 0; i < meshRenderers.Length; i++)
				{
					((Renderer)meshRenderers[i]).SetPropertyBlock(mpb);
				}
			}
		}

		public void Interact(Character interactor)
		{
		}

		public void Interact_CastFinished(Character interactor)
		{
			Interacted?.Invoke(interactor);
		}

		public bool IsConstantlyInteractable(Character interactor)
		{
			return IsInteractible(interactor);
		}

		public bool IsInteractible(Character interactor)
		{
			return true;
		}

		public void ReleaseInteract(Character interactor)
		{
		}
	}
	public class InteractableBrewingStand : MonoBehaviourPun, IInteractibleConstant, IInteractible
	{
		private bool ineracted;

		public Action<Character> Interacted;

		private MaterialPropertyBlock mpb;

		private MeshRenderer[] _mr;

		public float interactTime => 0.5f;

		public bool holdOnFinish
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		private MeshRenderer[] meshRenderers
		{
			get
			{
				if (_mr == null)
				{
					_mr = ((Component)this).GetComponentsInChildren<MeshRenderer>();
					MonoBehaviour.print((object)_mr.Length);
				}
				return _mr;
			}
			set
			{
				_mr = value;
			}
		}

		public void Awake()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			mpb = new MaterialPropertyBlock();
		}

		public void CancelCast(Character interactor)
		{
		}

		public Vector3 Center()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position;
		}

		public string GetInteractionText()
		{
			return "Take Potion";
		}

		public float GetInteractTime(Character interactor)
		{
			return interactTime;
		}

		public string GetName()
		{
			return "Brewing stand";
		}

		public Transform GetTransform()
		{
			return ((Component)this).transform;
		}

		public void HoverEnter()
		{
			if (ineracted || mpb == null)
			{
				return;
			}
			mpb.SetFloat(Item.PROPERTY_INTERACTABLE, 1f);
			for (int i = 0; i < meshRenderers.Length; i++)
			{
				if ((Object)(object)meshRenderers[i] != (Object)null)
				{
					((Renderer)meshRenderers[i]).SetPropertyBlock(mpb);
				}
			}
		}

		public void HoverExit()
		{
			if (mpb != null)
			{
				mpb.SetFloat(Item.PROPERTY_INTERACTABLE, 0f);
				for (int i = 0; i < meshRenderers.Length; i++)
				{
					((Renderer)meshRenderers[i]).SetPropertyBlock(mpb);
				}
			}
		}

		public void Interact(Character interactor)
		{
		}

		public void Interact_CastFinished(Character interactor)
		{
			if (!ineracted)
			{
				((Component)this).gameObject.layer = 2;
				((Component)((Component)this).transform.GetChild(0)).gameObject.SetActive(false);
				((Component)((Component)this).transform.GetChild(1)).gameObject.SetActive(true);
				HarmonyPatches.SetupMaterial(((Component)((Component)this).transform.GetChild(1)).gameObject);
				ineracted = true;
				Interacted?.Invoke(interactor);
			}
		}

		public bool IsConstantlyInteractable(Character interactor)
		{
			return IsInteractible(interactor);
		}

		public bool IsInteractible(Character interactor)
		{
			return true;
		}

		public void ReleaseInteract(Character interactor)
		{
		}
	}
	public class InteratableFinisher : MonoBehaviourPun, IInteractibleConstant, IInteractible
	{
		public Action<Character> Interacted;

		private MaterialPropertyBlock mpb;

		private MeshRenderer[] _mr;

		public float interactTime => 2f;

		public bool holdOnFinish
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		private MeshRenderer[] meshRenderers
		{
			get
			{
				if (_mr == null)
				{
					_mr = ((Component)this).GetComponentsInChildren<MeshRenderer>();
					MonoBehaviour.print((object)_mr.Length);
				}
				return _mr;
			}
			set
			{
				_mr = value;
			}
		}

		public void Awake()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			mpb = new MaterialPropertyBlock();
		}

		public void CancelCast(Character interactor)
		{
		}

		public Vector3 Center()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position;
		}

		public string GetInteractionText()
		{
			Plugin.Log.LogDebug((object)$"Current Spawn point Index: {HarmonyPatches.CurrentSpawnPointIndex} | Max index: {HarmonyPatches.MaxSpawnPointIndex}");
			if (HarmonyPatches.CurrentSpawnPointIndex == HarmonyPatches.MaxSpawnPointIndex)
			{
				return "Finish the game for all players";
			}
			return "Breaking out of the map doesn't allow you to finish early";
		}

		public float GetInteractTime(Character interactor)
		{
			return interactTime;
		}

		public string GetName()
		{
			return "Goal";
		}

		public Transform GetTransform()
		{
			return ((Component)this).transform;
		}

		public void HoverEnter()
		{
			if (mpb == null)
			{
				return;
			}
			mpb.SetFloat(Item.PROPERTY_INTERACTABLE, 1f);
			for (int i = 0; i < meshRenderers.Length; i++)
			{
				if ((Object)(object)meshRenderers[i] != (Object)null)
				{
					((Renderer)meshRenderers[i]).SetPropertyBlock(mpb);
				}
			}
		}

		public void HoverExit()
		{
			if (mpb != null)
			{
				mpb.SetFloat(Item.PROPERTY_INTERACTABLE, 0f);
				for (int i = 0; i < meshRenderers.Length; i++)
				{
					((Renderer)meshRenderers[i]).SetPropertyBlock(mpb);
				}
			}
		}

		public void Interact(Character interactor)
		{
		}

		public void Interact_CastFinished(Character interactor)
		{
			if (HarmonyPatches.CurrentSpawnPointIndex == HarmonyPatches.MaxSpawnPointIndex)
			{
				Interacted?.Invoke(interactor);
			}
		}

		public bool IsConstantlyInteractable(Character interactor)
		{
			return IsInteractible(interactor);
		}

		public bool IsInteractible(Character interactor)
		{
			return true;
		}

		public void ReleaseInteract(Character interactor)
		{
		}
	}
	public class InteratableTeleporter : MonoBehaviourPun, IInteractibleConstant, IInteractible
	{
		public Action<Character> Interacted;

		private MaterialPropertyBlock mpb;

		private MeshRenderer[] _mr;

		public float interactTime => 2f;

		public bool holdOnFinish
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		private MeshRenderer[] meshRenderers
		{
			get
			{
				if (_mr == null)
				{
					_mr = ((Component)this).GetComponentsInChildren<MeshRenderer>();
					MonoBehaviour.print((object)_mr.Length);
				}
				return _mr;
			}
			set
			{
				_mr = value;
			}
		}

		public void CancelCast(Character interactor)
		{
		}

		public void Awake()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			mpb = new MaterialPropertyBlock();
		}

		public Vector3 Center()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position;
		}

		public string GetInteractionText()
		{
			return "Teleport To Next Area";
		}

		public float GetInteractTime(Character interactor)
		{
			return interactTime;
		}

		public string GetName()
		{
			return "Teleporter";
		}

		public Transform GetTransform()
		{
			return ((Component)this).transform;
		}

		public void HoverEnter()
		{
			if (mpb == null)
			{
				return;
			}
			mpb.SetFloat(Item.PROPERTY_INTERACTABLE, 1f);
			for (int i = 0; i < meshRenderers.Length; i++)
			{
				if ((Object)(object)meshRenderers[i] != (Object)null)
				{
					((Renderer)meshRenderers[i]).SetPropertyBlock(mpb);
				}
			}
		}

		public void HoverExit()
		{
			if (mpb != null)
			{
				mpb.SetFloat(Item.PROPERTY_INTERACTABLE, 0f);
				for (int i = 0; i < meshRenderers.Length; i++)
				{
					((Renderer)meshRenderers[i]).SetPropertyBlock(mpb);
				}
			}
		}

		public void Interact(Character interactor)
		{
		}

		public void Interact_CastFinished(Character interactor)
		{
			Interacted?.Invoke(interactor);
		}

		public bool IsConstantlyInteractable(Character interactor)
		{
			return IsInteractible(interactor);
		}

		public bool IsInteractible(Character interactor)
		{
			return true;
		}

		public void ReleaseInteract(Character interactor)
		{
		}
	}
	public class LoadCorrectDropper : MonoBehaviourPun
	{
		[PunRPC]
		public void LoadDropper(int ascentIndex)
		{
			switch (ascentIndex)
			{
			default:
				Plugin.ToggleModpack(-1);
				break;
			case -101:
				Plugin.ToggleModpack(0);
				break;
			case -102:
				Plugin.ToggleModpack(1);
				break;
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.github.Beast.Dropper", "Dropper", "1.1.3")]
	public class Plugin : BaseUnityPlugin
	{
		public static Action<int> ToggleModpack;

		public static bool alreadyPatched;

		public static bool PlayingDropperMap;

		public static Item ResetBerryItem;

		public static Item HealthPotion;

		internal static ManualLogSource Log { get; private set; }

		public static AssetBundle Bundle { get; private set; }

		internal static ModDefinition Definition { get; set; }

		public static string PluginName => "Dropper";

		public static Version PLuginVersion => new Version(1, 1, 3);

		public static string PLuginID => "com.github.Beast.Dropper";

		private void Awake()
		{
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			LoadBundle();
			ToggleModpack = delegate(int mode)
			{
				Log.LogInfo((object)$"Setting up Modpack with mode {mode}");
				switch (mode)
				{
				case 0:
					PlayingDropperMap = true;
					HarmonyPatches.Mode = HarmonyPatches.GameMode.Dropper;
					if (!alreadyPatched)
					{
						alreadyPatched = true;
						Harmony.CreateAndPatchAll(typeof(HarmonyPatches), "com.github.Beast.Dropper.runtime");
					}
					break;
				case 1:
					PlayingDropperMap = true;
					HarmonyPatches.Mode = HarmonyPatches.GameMode.Descend;
					if (!alreadyPatched)
					{
						Harmony.CreateAndPatchAll(typeof(HarmonyPatches), "com.github.Beast.Dropper.runtime");
						alreadyPatched = true;
					}
					break;
				default:
					PlayingDropperMap = false;
					alreadyPatched = false;
					Harmony.UnpatchID("com.github.Beast.Dropper.runtime");
					break;
				}
			};
			Log.LogInfo((object)"Adding Localisation");
			LocalizedText.mainTable.Add("Name_Reset".ToUpperInvariant(), GetLocalisationOf("Resetter"));
			LocalizedText.mainTable.Add("Force reset on #targetchar".ToUpperInvariant(), GetLocalisationOf("force reset #targetchar"));
			LocalizedText.mainTable.Add("Name_Instant Health I".ToUpperInvariant(), GetLocalisationOf("Instant Health I"));
			LocalizedText.mainTable.Add("administer #targetchar".ToUpperInvariant(), GetLocalisationOf("administer #targetchar"));
			LocalizedText.mainTable.Add("Dropper".ToUpperInvariant(), GetLocalisationOf("Dropper"));
			LocalizedText.mainTable.Add("Immense dread".ToUpperInvariant(), GetLocalisationOf("Immense dread"));
			LocalizedText.mainTable.Add("Desc_Dropper".ToUpperInvariant(), GetLocalisationOf("Does falling from 50 meters and crushing all your bones hurt? YES! But the adrenaline keeps you alive and ready to hit the portal next time!"));
			LocalizedText.mainTable.Add("Dropper - Descend".ToUpperInvariant(), GetLocalisationOf("Dropper - Descent"));
			LocalizedText.mainTable.Add("Desc_Dropper - Descend".ToUpperInvariant(), GetLocalisationOf("Instead of doing it all in one jump, how about we mix it up with some parkour to climb down. Why would you do that? Well let's finish the first map an you will see why"));
			Log.LogInfo((object)"Applying MandatoryHarmonyPatches");
			Harmony.CreateAndPatchAll(typeof(MandatoryHarmonyPatches), (string)null);
			Log.LogInfo((object)"Done Applying MandatoryHarmonyPatches");
			Definition = ModDefinition.GetOrCreate(PLuginID, PluginName, PLuginVersion);
			Log.LogInfo((object)"Adding Custom Items via PeakLibItems");
			ResetBerryItem = Bundle.LoadAsset<GameObject>("ResetBerry").GetComponent<Item>();
			new ItemContent(ResetBerryItem).Register(Definition);
			HealthPotion = Bundle.LoadAsset<GameObject>("Health potion").GetComponent<Item>();
			new ItemContent(HealthPotion).Register(Definition);
			Log.LogInfo((object)"Plugin Dropper is loaded!");
		}

		private List<string> GetLocalisationOf(string input)
		{
			List<string> list = new List<string>();
			for (int i = 0; i < 15; i++)
			{
				list.Add(input);
			}
			return list;
		}

		private void LoadBundle()
		{
			Log.LogInfo((object)"Loading AssetBundle...");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string path = "dropper_assets";
			string text = Path.Combine(directoryName, path);
			if (File.Exists(text))
			{
				Log.LogInfo((object)"Found AssetBundle");
				Bundle = AssetBundle.LoadFromFile(text);
				if ((Object)(object)Bundle == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load AssetBundle!");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"AssetBundle loaded successfully!");
				}
			}
			else
			{
				Log.LogError((object)("AssetBundle not found at " + text));
			}
		}
	}
	internal class HarmonyPatches
	{
		public enum GameMode
		{
			Dropper,
			Descend
		}

		[CompilerGenerated]
		private sealed class <<UnPassOut>g__Wait3s|14_0>d : 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 <<UnPassOut>g__Wait3s|14_0>d(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

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

			private bool MoveNext()
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					gainFullControlOfCharacter = true;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					gainFullControlOfCharacter = false;
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_0
		{
			public int localindex;

			public TriggerTeleporter component;

			internal void <DelayedActivation>b__0(Character character)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass12_1 CS$<>8__locals0 = new <>c__DisplayClass12_1
				{
					character = character
				};
				if (CS$<>8__locals0.character.IsLocal)
				{
					Character character2 = CS$<>8__locals0.character;
					Vector3 val = spawnPoints[localindex + 1].position - Vector3.up;
					PhotonMessageInfo val2 = default(PhotonMessageInfo);
					PhotonMessageInfo val3 = default(PhotonMessageInfo);
					character2.WarpPlayerRPC(val, true, default(PhotonMessageInfo));
					Plugin.Log.LogInfo((object)$"Teleported {((Object)CS$<>8__locals0.character).name} to Spawn Point {localindex + 1} from Teleporter {((Object)((Component)component).gameObject).name}");
					CurrentSpawnPointIndex = localindex + 1;
					((MonoBehaviour)CS$<>8__locals0.character).StartCoroutine(FixPassout());
				}
				[IteratorStateMachine(typeof(<>c__DisplayClass12_1.<<DelayedActivation>g__FixPassout|1>d))]
				IEnumerator FixPassout()
				{
					//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
					return new <>c__DisplayClass12_1.<<DelayedActivation>g__FixPassout|1>d(0)
					{
						<>4__this = CS$<>8__locals0
					};
				}
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_1
		{
			public Character character;
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_2
		{
			public int localindex;

			public InteratableTeleporter component;

			internal void <DelayedActivation>b__2(Character character)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass12_3 CS$<>8__locals0 = new <>c__DisplayClass12_3
				{
					character = character
				};
				if (CS$<>8__locals0.character.IsLocal)
				{
					Character character2 = CS$<>8__locals0.character;
					Vector3 val = spawnPoints[localindex + 1].position - Vector3.up;
					PhotonMessageInfo val2 = default(PhotonMessageInfo);
					PhotonMessageInfo val3 = default(PhotonMessageInfo);
					character2.WarpPlayerRPC(val, true, default(PhotonMessageInfo));
					Plugin.Log.LogInfo((object)$"Teleported {((Object)CS$<>8__locals0.character).name} to Spawn Point {localindex + 1} from Teleporter {((Object)((Component)component).gameObject).name}");
					CurrentSpawnPointIndex = localindex + 1;
					CS$<>8__locals0.character.refs.afflictions.ClearAllStatus(false);
					((MonoBehaviour)CS$<>8__locals0.character).StartCoroutine(FixPassout());
				}
				[IteratorStateMachine(typeof(<>c__DisplayClass12_3.<<DelayedActivation>g__FixPassout|3>d))]
				IEnumerator FixPassout()
				{
					//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
					return new <>c__DisplayClass12_3.<<DelayedActivation>g__FixPassout|3>d(0)
					{
						<>4__this = CS$<>8__locals0
					};
				}
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_3
		{
			public Character character;
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass12_4
		{
			public int localindex;

			internal void <DelayedActivation>b__4(Character character)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				if (character.IsLocal)
				{
					Vector3 val = spawnPoints[localindex].position - Vector3.up;
					PhotonMessageInfo val2 = default(PhotonMessageInfo);
					PhotonMessageInfo val3 = default(PhotonMessageInfo);
					character.WarpPlayerRPC(val, true, default(PhotonMessageInfo));
					CurrentSpawnPointIndex = localindex;
					Plugin.Log.LogInfo((object)$"reverse Teleported {((Object)character).name} to Spawn Point {localindex}");
					character.refs.afflictions.ClearAllStatus(false);
					GiveResetBerry(character);
				}
			}
		}

		[CompilerGenerated]
		private sealed class <DelayedActivation>d__12 : 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 <DelayedActivation>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

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

			private bool MoveNext()
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Expected O, but got Unknown
				//IL_062d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0635: Unknown result type (might be due to invalid IL or missing references)
				//IL_063d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0645: Unknown result type (might be due to invalid IL or missing references)
				//IL_064b: 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_00ac: Expected O, but got Unknown
				//IL_0179: Unknown result type (might be due to invalid IL or missing references)
				//IL_0183: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0200: Expected O, but got Unknown
				//IL_026b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0272: Expected O, but got Unknown
				//IL_0540: Unknown result type (might be due to invalid IL or missing references)
				//IL_0547: Expected O, but got Unknown
				//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0600: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Plugin.Log.LogInfo((object)"Delaying Activation of ScoutmasterSpawner ------------------------------------ new Round ----------------------------------------------");
					CurrentSpawnPointIndex = 0;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					Plugin.Log.LogInfo((object)"Moving Peak Finisher So that we can use it later");
					((Component)Singleton<PeakHandler>.Instance).transform.SetParent((Transform)null, true);
					Plugin.Log.LogInfo((object)"Deactivating Map Parts");
					foreach (Transform item2 in GameObject.Find("Map").transform)
					{
						Transform val3 = item2;
						((Component)val3).gameObject.SetActive(false);
					}
					GameObject.Find("EdgeWalls").SetActive(false);
					GameObject.Find("FogCutouts").SetActive(false);
					GameObject.Find("MountainProgress").SetActive(false);
					GameObject.Find("FogSphereSystem").SetActive(false);
					GameObject.Find("BlindPost").SetActive(false);
					GameObject.Find("Post Fog").SetActive(false);
					GameObject.Find("WaterMesh").SetActive(false);
					GameObject.Find("WaterZone").SetActive(false);
					Plugin.Log.LogInfo((object)"Instantiating Cutom Map Prefab");
					GameObject val4 = Plugin.Bundle.LoadAsset<GameObject>("Dropper Prefab");
					GameObject val5 = Object.Instantiate<GameObject>(val4, Vector3.up * 10f, Quaternion.identity);
					Plugin.Log.LogInfo((object)"Setting up Networking objects");
					GameObject val6 = GameObject.Find("GAME");
					addItemScript = val6.gameObject.AddComponent<AddItemInNetwork>();
					photonScript = val6.gameObject.GetComponent<PhotonView>();
					Plugin.Log.LogInfo((object)"Setting up Default Material");
					DefaultMaterial = new Material(((Renderer)((Component)val5.transform.Find("Dummy test object (1)")).GetComponent<MeshRenderer>()).material);
					DefaultMaterial.shader = Shader.Find("W/Peak_Standard");
					Plugin.Log.LogInfo((object)"Setting up Materials");
					SetupMaterial(val5);
					Plugin.Log.LogInfo((object)"Setting up Spawn Points");
					Transform val7 = val5.gameObject.transform.Find("Spawn Points Modding");
					spawnPoints = new List<Transform>();
					foreach (Transform item3 in val7)
					{
						Transform item = item3;
						spawnPoints.Add(item);
					}
					Plugin.Log.LogInfo((object)$"Found {spawnPoints.Count} Spawn points");
					Plugin.Log.LogInfo((object)"Setting Up Teleporation Cubes");
					if (Mode == GameMode.Dropper)
					{
						GameObject val8 = GameObject.Find("ohter parent");
						Plugin.Log.LogInfo((object)$"Found {val8.transform.childCount} End Portals");
						MaxSpawnPointIndex = val8.transform.childCount;
						for (int i = 0; i < val8.transform.childCount; i++)
						{
							<>c__DisplayClass12_0 CS$<>8__locals0 = new <>c__DisplayClass12_0
							{
								localindex = i,
								component = ((Component)val8.transform.GetChild(i)).gameObject.AddComponent<TriggerTeleporter>()
							};
							TriggerTeleporter component = CS$<>8__locals0.component;
							component.Interacted = (Action<Character>)Delegate.Combine(component.Interacted, (Action<Character>)delegate(Character character)
							{
								//IL_0033: Unknown result type (might be due to invalid IL or missing references)
								//IL_0038: Unknown result type (might be due to invalid IL or missing references)
								//IL_003d: Unknown result type (might be due to invalid IL or missing references)
								//IL_0045: Unknown result type (might be due to invalid IL or missing references)
								//IL_004d: Unknown result type (might be due to invalid IL or missing references)
								//IL_0055: Unknown result type (might be due to invalid IL or missing references)
								//IL_005b: Unknown result type (might be due to invalid IL or missing references)
								<>c__DisplayClass12_1 CS$<>8__locals4 = new <>c__DisplayClass12_1
								{
									character = character
								};
								if (CS$<>8__locals4.character.IsLocal)
								{
									Character character3 = CS$<>8__locals4.character;
									Vector3 val18 = spawnPoints[CS$<>8__locals0.localindex + 1].position - Vector3.up;
									PhotonMessageInfo val19 = default(PhotonMessageInfo);
									PhotonMessageInfo val20 = default(PhotonMessageInfo);
									character3.WarpPlayerRPC(val18, true, default(PhotonMessageInfo));
									Plugin.Log.LogInfo((object)$"Teleported {((Object)CS$<>8__locals4.character).name} to Spawn Point {CS$<>8__locals0.localindex + 1} from Teleporter {((Object)((Component)CS$<>8__locals0.component).gameObject).name}");
									CurrentSpawnPointIndex = CS$<>8__locals0.localindex + 1;
									((MonoBehaviour)CS$<>8__locals4.character).StartCoroutine(FixPassout());
								}
								[IteratorStateMachine(typeof(<>c__DisplayClass12_1.<<DelayedActivation>g__FixPassout|1>d))]
								IEnumerator FixPassout()
								{
									//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
									return new <>c__DisplayClass12_1.<<DelayedActivation>g__FixPassout|1>d(0)
									{
										<>4__this = CS$<>8__locals4
									};
								}
							});
						}
					}
					else if (Mode == GameMode.Descend)
					{
						GameObject val9 = GameObject.Find("Next Stage Parent");
						Plugin.Log.LogInfo((object)$"Found {val9.transform.childCount} Teleporters");
						MaxSpawnPointIndex = val9.transform.childCount;
						for (int j = 0; j < val9.transform.childCount; j++)
						{
							<>c__DisplayClass12_2 CS$<>8__locals1 = new <>c__DisplayClass12_2
							{
								localindex = j,
								component = ((Component)val9.transform.GetChild(j).GetChild(0)).gameObject.AddComponent<InteratableTeleporter>()
							};
							InteratableTeleporter component2 = CS$<>8__locals1.component;
							component2.Interacted = (Action<Character>)Delegate.Combine(component2.Interacted, (Action<Character>)delegate(Character character)
							{
								//IL_0033: Unknown result type (might be due to invalid IL or missing references)
								//IL_0038: Unknown result type (might be due to invalid IL or missing references)
								//IL_003d: Unknown result type (might be due to invalid IL or missing references)
								//IL_0045: Unknown result type (might be due to invalid IL or missing references)
								//IL_004d: Unknown result type (might be due to invalid IL or missing references)
								//IL_0055: Unknown result type (might be due to invalid IL or missing references)
								//IL_005b: Unknown result type (might be due to invalid IL or missing references)
								<>c__DisplayClass12_3 CS$<>8__locals3 = new <>c__DisplayClass12_3
								{
									character = character
								};
								if (CS$<>8__locals3.character.IsLocal)
								{
									Character character2 = CS$<>8__locals3.character;
									Vector3 val15 = spawnPoints[CS$<>8__locals1.localindex + 1].position - Vector3.up;
									PhotonMessageInfo val16 = default(PhotonMessageInfo);
									PhotonMessageInfo val17 = default(PhotonMessageInfo);
									character2.WarpPlayerRPC(val15, true, default(PhotonMessageInfo));
									Plugin.Log.LogInfo((object)$"Teleported {((Object)CS$<>8__locals3.character).name} to Spawn Point {CS$<>8__locals1.localindex + 1} from Teleporter {((Object)((Component)CS$<>8__locals1.component).gameObject).name}");
									CurrentSpawnPointIndex = CS$<>8__locals1.localindex + 1;
									CS$<>8__locals3.character.refs.afflictions.ClearAllStatus(false);
									((MonoBehaviour)CS$<>8__locals3.character).StartCoroutine(FixPassout());
								}
								[IteratorStateMachine(typeof(<>c__DisplayClass12_3.<<DelayedActivation>g__FixPassout|3>d))]
								IEnumerator FixPassout()
								{
									//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
									return new <>c__DisplayClass12_3.<<DelayedActivation>g__FixPassout|3>d(0)
									{
										<>4__this = CS$<>8__locals3
									};
								}
							});
						}
					}
					Plugin.Log.LogInfo((object)"Setting up Reverse Teleporters");
					GameObject val10 = GameObject.Find("Reverse Teleporters");
					for (int k = 0; k < val10.transform.childCount; k++)
					{
						<>c__DisplayClass12_4 CS$<>8__locals2 = new <>c__DisplayClass12_4();
						Transform child = val10.transform.GetChild(k);
						CS$<>8__locals2.localindex = k;
						InteractableBackPorter interactableBackPorter = ((Component)child).gameObject.AddComponent<InteractableBackPorter>();
						interactableBackPorter.Interacted = (Action<Character>)Delegate.Combine(interactableBackPorter.Interacted, (Action<Character>)delegate(Character character)
						{
							//IL_001a: Unknown result type (might be due to invalid IL or missing references)
							//IL_001f: Unknown result type (might be due to invalid IL or missing references)
							//IL_0024: Unknown result type (might be due to invalid IL or missing references)
							//IL_002c: Unknown result type (might be due to invalid IL or missing references)
							//IL_0034: Unknown result type (might be due to invalid IL or missing references)
							//IL_003c: Unknown result type (might be due to invalid IL or missing references)
							//IL_0042: Unknown result type (might be due to invalid IL or missing references)
							if (character.IsLocal)
							{
								Vector3 val12 = spawnPoints[CS$<>8__locals2.localindex].position - Vector3.up;
								PhotonMessageInfo val13 = default(PhotonMessageInfo);
								PhotonMessageInfo val14 = default(PhotonMessageInfo);
								character.WarpPlayerRPC(val12, true, default(PhotonMessageInfo));
								CurrentSpawnPointIndex = CS$<>8__locals2.localindex;
								Plugin.Log.LogInfo((object)$"reverse Teleported {((Object)character).name} to Spawn Point {CS$<>8__locals2.localindex}");
								character.refs.afflictions.ClearAllStatus(false);
								GiveResetBerry(character);
							}
						});
					}
					InteratableFinisher interatableFinisher = GameObject.Find("Finisher").AddComponent<InteratableFinisher>();
					interatableFinisher.Interacted = (Action<Character>)Delegate.Combine(interatableFinisher.Interacted, (Action<Character>)delegate(Character character)
					{
						MethodInfo method = typeof(Character).GetMethod("TestWin", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
						method.Invoke(character, new object[0]);
					});
					foreach (Transform item4 in GameObject.Find("Brewing stands").transform)
					{
						Transform val11 = item4;
						InteractableBrewingStand interactableBrewingStand = ((Component)val11).gameObject.AddComponent<InteractableBrewingStand>();
						interactableBrewingStand.Interacted = (Action<Character>)Delegate.Combine(interactableBrewingStand.Interacted, (Action<Character>)delegate(Character character)
						{
							Plugin.Log.LogInfo((object)$"Character  {character.characterName} has interacted with the brewing stand | Is character local: {character.IsLocal}");
							_ = character.IsLocal;
							addItemScript.AddItemIntoInventory(Plugin.HealthPotion.itemID, ((MonoBehaviourPun)character).photonView.ViewID);
						});
					}
					if (Mode == GameMode.Dropper)
					{
						GameObject.Find("Dropper Map").SetActive(true);
						GameObject.Find("Descend map").SetActive(false);
					}
					else
					{
						GameObject.Find("Dropper Map").SetActive(false);
						GameObject.Find("Descend map").SetActive(true);
					}
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 2;
					return true;
				}
				case 2:
					<>1__state = -1;
					if (spawnPoints.Count > 0)
					{
						Character localCharacter = Character.localCharacter;
						Vector3 position = spawnPoints[0].position;
						PhotonMessageInfo val = default(PhotonMessageInfo);
						PhotonMessageInfo val2 = default(PhotonMessageInfo);
						localCharacter.WarpPlayerRPC(position, true, default(PhotonMessageInfo));
						Plugin.Log.LogInfo((object)$"Teleporting Players to Spawn Point {0} | {((Object)((Component)spawnPoints[0]).gameObject).name}");
					}
					else
					{
						Plugin.Log.LogError((object)"No spawn points found in the prefab!");
					}
					GiveResetBerry(Character.localCharacter);
					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();
			}
		}

		public static Material DefaultMaterial;

		public static List<Transform> spawnPoints;

		public static int CurrentSpawnPointIndex = 0;

		public static int MaxSpawnPointIndex = 0;

		public static PhotonView photonScript;

		public static AddItemInNetwork addItemScript;

		public static GameMode Mode = GameMode.Dropper;

		public static bool gainFullControlOfCharacter = false;

		public static string ResetBerryName = Plugin.PLuginID + ":ResetBerry";

		public static string HealthPotionName = Plugin.PLuginID + ":Health potion";

		private static Dictionary<string, Shader> _peakShaders = null;

		internal static Dictionary<string, Shader> PeakShaders
		{
			get
			{
				if (_peakShaders == null)
				{
					List<string> list = new List<string>
					{
						"W/Peak_Standard", "W/Character", "W/Peak_Transparent", "W/Peak_Glass", "W/Peak_Clip", "W/Peak_glass_liquid", "W/Peak_GroundTransition", "W/Peak_Guidebook", "W/Peak_Honey", "W/Peak_Ice",
						"W/Peak_Rock", "W/Peak_Rope", "W/Peak_Splash", "W/Peak_Waterfall", "W/Vine", "Universal Render Pipeline/Lit"
					};
					_peakShaders = new Dictionary<string, Shader>();
					foreach (string item in list)
					{
						Shader val = Shader.Find(item);
						if ((Object)(object)val == (Object)null)
						{
							Plugin.Log.LogWarning((object)("Shader " + item + " not found, skipping."));
						}
						else
						{
							_peakShaders[item] = val;
						}
					}
				}
				return _peakShaders;
			}
		}

		[HarmonyPatch(typeof(ScoutmasterSpawner), "Awake")]
		[HarmonyPostfix]
		private static void ScoutmasterSpawner_Awake_Postfix(ScoutmasterSpawner __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(DelayedActivation());
		}

		[IteratorStateMachine(typeof(<DelayedActivation>d__12))]
		public static IEnumerator DelayedActivation()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayedActivation>d__12(0);
		}

		public static void GiveResetBerry(Character character)
		{
			if ((Object)(object)character.player.itemSlots[0].prefab == (Object)(object)Plugin.ResetBerryItem || (Object)(object)character.player.itemSlots[1].prefab == (Object)(object)Plugin.ResetBerryItem || (Object)(object)character.player.itemSlots[2].prefab == (Object)(object)Plugin.ResetBerryItem)
			{
				Plugin.Log.LogInfo((object)("Not giving charater: " + character.characterName));
			}
			else
			{
				addItemScript.AddItemIntoInventory(Plugin.ResetBerryItem.itemID, ((MonoBehaviourPun)character).photonView.ViewID);
			}
		}

		private static void UnPassOut(Character character)
		{
			FieldInfo field = typeof(Character).GetField("UnPassOutCalled", BindingFlags.Instance | BindingFlags.NonPublic);
			field.SetValue(character, false);
			((MonoBehaviour)character).StartCoroutine(Wait3s());
			[IteratorStateMachine(typeof(<<UnPassOut>g__Wait3s|14_0>d))]
			static IEnumerator Wait3s()
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <<UnPassOut>g__Wait3s|14_0>d(0);
			}
		}

		[HarmonyPatch(typeof(CharacterData), "GetTargetRagdollControll")]
		[HarmonyPrefix]
		public static bool Prefix(CharacterData __instance, ref float __result)
		{
			if (gainFullControlOfCharacter)
			{
				__result = 1f;
				__instance.fallSeconds = 0f;
				__instance.passedOut = false;
				__instance.passOutValue = 0f;
				__instance.fullyPassedOut = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(AchievementManager), "ThrowAchievement")]
		[HarmonyPrefix]
		private static bool AchievementManager_ThrowAchievement_Prefix(AchievementManager __instance)
		{
			return false;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		public static bool OverrideHungerRateMultiplier(ref float __result)
		{
			__result = 0f;
			return false;
		}

		[HarmonyPatch(typeof(BerryBush), "SpawnItems")]
		[HarmonyPrefix]
		private static void BerryBush_SpawnItems_Prefix(BerryBush __instance, ref List<Transform> spawnSpots)
		{
			spawnSpots.Clear();
		}

		[HarmonyPatch(typeof(ScoutmasterSpawner), "SpawnScoutmaster")]
		[HarmonyPrefix]
		private static bool ScoutmasterSpawner_SpawnScoutmaster_Prefix(ScoutmasterSpawner __instance)
		{
			return false;
		}

		[HarmonyPatch(typeof(Character), "RPCA_PassOut")]
		[HarmonyPrefix]
		private static bool Character_RPCA_PassOut_Prefix(Character __instance)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogInfo((object)$"Preventing {((Object)__instance).name} from passing out and respawning him at spawnpointIndex: {CurrentSpawnPointIndex}");
			__instance.refs.afflictions.ClearAllStatus(false);
			Vector3 position = spawnPoints[CurrentSpawnPointIndex].position;
			PhotonMessageInfo val = default(PhotonMessageInfo);
			PhotonMessageInfo val2 = default(PhotonMessageInfo);
			__instance.WarpPlayerRPC(position, true, default(PhotonMessageInfo));
			return false;
		}

		[HarmonyPatch(typeof(CharacterItems), "DoDropping")]
		[HarmonyPrefix]
		private static bool CharacterItems_DoDropping_Prefix(CharacterItems __instance)
		{
			return false;
		}

		[HarmonyPatch(typeof(ItemSlot), "EmptyOut")]
		[HarmonyPrefix]
		private static bool ItemSlot_EmptyOut_Prefix(ItemSlot __instance)
		{
			Plugin.Log.LogInfo((object)("Preventing " + ((Object)((Component)__instance.prefab).gameObject).name + " from being dropped isntead " + ResetBerryName));
			if (((Object)((Component)__instance.prefab).gameObject).name == ResetBerryName)
			{
				return false;
			}
			return true;
		}

		private static void CheckEveryMaterialShader(GameObject gameObject)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				for (int j = 0; j < val.materials.Length; j++)
				{
					Material val2 = val.materials[j];
					Plugin.Log.LogInfo((object)("Rendere " + ((Object)((Component)val).gameObject).name + " with Material " + ((Object)val2).name + " uses shader " + ((Object)val2.shader).name));
				}
			}
		}

		public static void SetupMaterial(GameObject gameObject)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				Material[] materials = val.materials;
				foreach (Material val2 in materials)
				{
					if (PeakShaders.TryGetValue(((Object)val2.shader).name, out Shader value))
					{
						val2.shader = value;
					}
				}
			}
			Renderer[] componentsInChildren2 = gameObject.GetComponentsInChildren<Renderer>();
			foreach (Renderer val3 in componentsInChildren2)
			{
				Material[] materials2 = val3.materials;
				foreach (Material val4 in materials2)
				{
					if (((Object)val4.shader).name == "Universal Render Pipeline/Lit" && !val4.IsKeywordEnabled("_EMISSION") && !IsTransparent(val4) && !HasAlphaClipping(val4))
					{
						Texture texture = val4.GetTexture("_BaseMap");
						if ((Object)(object)texture == (Object)null)
						{
							Plugin.Log.LogInfo((object)("No texture found for material " + ((Object)val4).name + ", skipping conversion."));
							continue;
						}
						val4.shader = DefaultMaterial.shader;
						val4.SetTexture("_BaseTexture", texture);
					}
				}
				val3.materials = materials2;
			}
		}

		private static bool IsTransparent(Material mat)
		{
			if (mat.HasProperty("_Surface"))
			{
				float @float = mat.GetFloat("_Surface");
				return @float > 0.5f;
			}
			return mat.renderQueue >= 3000;
		}

		private static bool HasAlphaClipping(Material mat)
		{
			return mat.IsKeywordEnabled("_ALPHATEST_ON");
		}
	}
	internal class MandatoryHarmonyPatches
	{
		private static bool modifiedBoardpass;

		private static LoadCorrectDropper loader;

		[HarmonyPatch(typeof(AchievementManager), "GetMaxAscent")]
		[HarmonyPostfix]
		public static void AchievementManager_GetMaxAscent_Postfix(ref int __result)
		{
		}

		[HarmonyPatch(typeof(AirportCheckInKiosk), "Awake")]
		[HarmonyPostfix]
		private static void AirportCheckInKiosk_Awake_Postfix(AirportCheckInKiosk __instance)
		{
			Plugin.Log.LogInfo((object)"Starting To add in additional Game Modes");
			loader = ((Component)__instance).gameObject.AddComponent<LoadCorrectDropper>();
			AddGameModes();
		}

		private static void AddGameModes()
		{
		}

		[HarmonyPatch(typeof(BoardingPass), "Initialize")]
		[HarmonyPrefix]
		public static void Prefix(BoardingPass __instance)
		{
		}

		[HarmonyPatch(typeof(BoardingPass), "StartGame")]
		[HarmonyPrefix]
		public static void BoardingPass_StartGame_Prefix(BoardingPass __instance)
		{
		}

		[HarmonyPatch(typeof(AscentUI), "Start")]
		[HarmonyPostfix]
		public static void AscentUI_Update_Postfix(AscentUI __instance)
		{
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		public static void OverrideAscentDifficulty(ref int __result)
		{
			if (Plugin.PlayingDropperMap)
			{
				__result = 0;
			}
		}
	}
	public class TriggerTeleporter : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <EnableCharactersDelayed>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public TriggerTeleporter <>4__this;

			public int id;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				int num = <>1__state;
				TriggerTeleporter triggerTeleporter = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					triggerTeleporter.charactersInTrigger.Remove(id);
					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();
			}
		}

		public Action<Character> Interacted;

		public List<int> charactersInTrigger = new List<int>();

		private void OnTriggerEnter(Collider other)
		{
			Character componentInParent = ((Component)((Component)other).transform).GetComponentInParent<Character>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				int viewID = ((Component)componentInParent).GetComponent<PhotonView>().ViewID;
				if (!charactersInTrigger.Contains(viewID))
				{
					charactersInTrigger.Add(viewID);
					Interacted?.Invoke(componentInParent);
					((MonoBehaviour)componentInParent).StartCoroutine(EnableCharactersDelayed(viewID));
				}
			}
		}

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

plugins/DropperPeakLevelSelectSwitcher.dll

Decompiled 9 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using Dropper;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DropperPeakLevelSelectSwitcher
{
	[BepInPlugin("com.github.Beast.Dropper.PeakLevelSelectSwitcher", "Dropper PeakLevelSelect Switcher", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class SwitcherPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.github.Beast.Dropper.PeakLevelSelectSwitcher";

		public const string PluginName = "Dropper PeakLevelSelect Switcher";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			DropperText.Install();
			Harmony.CreateAndPatchAll(typeof(BoardingPassSwitcher), "com.github.Beast.Dropper.PeakLevelSelectSwitcher");
			Log.LogInfo((object)"Dropper/PeakLevelSelect boarding pass switcher loaded.");
		}
	}
	internal static class DropperText
	{
		private const int ChineseLanguageIndex = 9;

		public static bool IsChinese
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Invalid comparison between Unknown and I4
				try
				{
					return (int)LocalizedText.CURRENT_LANGUAGE == 9;
				}
				catch
				{
					return false;
				}
			}
		}

		public static string Choose(string english, string chinese)
		{
			return IsChinese ? chinese : english;
		}

		public static void Install()
		{
			Set("Name_Reset", "Resetter", "重置器");
			Set("Force reset on #targetchar", "force reset #targetchar", "强制重置 #targetchar");
			Set("Name_Instant Health I", "Instant Health I", "瞬间治疗 I");
			Set("administer #targetchar", "administer #targetchar", "使用于 #targetchar");
			Set("Dropper", "Dropper", "坠落挑战");
			Set("Immense dread", "Immense dread", "无尽恐惧");
			Set("Desc_Dropper", "Does falling from 50 meters and crushing all your bones hurt? YES! But the adrenaline keeps you alive and ready to hit the portal next time!", "从 50 米高空坠落并摔碎全身骨头会痛吗?当然会!但肾上腺素会让你活下来,准备好下一次冲进传送门!");
			Set("Dropper - Descend", "Dropper - Descent", "坠落挑战 - 下降");
			Set("Desc_Dropper - Descend", "Instead of doing it all in one jump, how about we mix it up with some parkour to climb down. Why would you do that? Well let's finish the first map an you will see why", "不再一次跳到底,而是加入一些跑酷向下推进。为什么要这样做?先完成第一张地图,你就会明白。");
		}

		private static void Set(string key, string english, string chinese)
		{
			List<string> list = new List<string>();
			for (int i = 0; i < 15; i++)
			{
				list.Add(english);
			}
			list[9] = chinese;
			LocalizedText.mainTable[key.ToUpperInvariant()] = list;
		}
	}
	[HarmonyAfter(new string[] { "PeakLevelSelect", "com.github.Beast.Dropper" })]
	internal static class BoardingPassSwitcher
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__39_0;

			public static UnityAction <>9__39_1;

			internal void <EnsureButtons>b__39_0()
			{
				useDropperControls = !useDropperControls;
				SwitcherPlugin.Log.LogInfo((object)("Dropper feature switch clicked. Dropper controls: " + useDropperControls));
				if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.boardingPass != (Object)null)
				{
					InvokeUpdateAscent(GUIManager.instance.boardingPass);
				}
			}

			internal void <EnsureButtons>b__39_1()
			{
				dropperMode = ((dropperMode == 0) ? 1 : 0);
				SwitcherPlugin.Log.LogInfo((object)("Dropper mode switch clicked. Mode: " + dropperMode));
				if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.boardingPass != (Object)null)
				{
					InvokeUpdateAscent(GUIManager.instance.boardingPass);
				}
			}
		}

		private const int OffSentinel = -1;

		private const int DropperSentinel = -101;

		private const int DescendSentinel = -102;

		private const string RoomDropperModeKey = "DropperFix.Mode";

		private const string RoomPeakLevelKey = "DropperFix.PeakLevel";

		private const string RoomPeakAscentKey = "DropperFix.PeakAscent";

		private static bool useDropperControls;

		private static int dropperMode;

		private static GameObject switchButton;

		private static GameObject dropperModeButton;

		private static TextMeshProUGUI switchButtonText;

		private static TextMeshProUGUI dropperModeButtonText;

		private static bool checkedPeakLevelSelect;

		private static Type peakLevelSelectPatchType;

		private static bool dropperUiApplied;

		private static bool capturedDescLayout;

		private static bool defaultDescAutoSizing;

		private static float defaultDescLineSpacing;

		private static float defaultDescParagraphSpacing;

		private static Vector4 defaultDescMargin;

		private static float defaultDescFontSizeMin;

		private static float defaultDescFontSizeMax;

		private static RectTransform ascentTitleRect;

		private static Vector2 defaultAscentTitleAnchoredPosition;

		private static Vector2 defaultAscentTitleSizeDelta;

		private static bool capturedTitleLayout;

		private static bool capturedRewardState;

		private static bool defaultRewardActive;

		private static bool capturedCustomOptionsState;

		private static bool defaultCustomOptionsActive;

		private static bool peakLevelSelectHiddenByDropper;

		private static readonly Color Blue = new Color(0.1922f, 0.2941f, 0.9804f, 1f);

		private static readonly Color Yellow = new Color(0.9804f, 0.8075f, 0.1922f, 1f);

		private static readonly MethodInfo UpdateAscentMethod = typeof(BoardingPass).GetMethod("UpdateAscent", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch(typeof(AirportCheckInKiosk), "BeginIslandLoadRPC")]
		[HarmonyPrefix]
		private static void AirportCheckInKiosk_BeginIslandLoadRPC_Prefix()
		{
			ApplyRoomSelection("BeginIslandLoadRPC");
		}

		[HarmonyPatch(typeof(AirportCheckInKiosk), "LoadIslandMaster")]
		[HarmonyPrefix]
		private static void AirportCheckInKiosk_LoadIslandMaster_Prefix()
		{
			ApplyRoomSelection("LoadIslandMaster");
		}

		[HarmonyPatch(typeof(GUIManager), "Start")]
		[HarmonyPostfix]
		private static void GUIManager_Start_Postfix()
		{
			if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.boardingPass != (Object)null)
			{
				EnsureButtons(GUIManager.instance.boardingPass);
				Refresh(GUIManager.instance.boardingPass);
			}
		}

		[HarmonyPatch(typeof(BoardingPass), "UpdateAscent")]
		[HarmonyPostfix]
		private static void BoardingPass_UpdateAscent_Postfix(BoardingPass __instance)
		{
			EnsureButtons(__instance);
			Refresh(__instance);
		}

		[HarmonyPatch(typeof(BoardingPass), "StartGame")]
		[HarmonyPrefix]
		private static bool BoardingPass_StartGame_Prefix(BoardingPass __instance)
		{
			if ((Object)(object)__instance == (Object)null || LoadingScreenHandler.loading)
			{
				return true;
			}
			if (RunSettings.IsCustomRun || !useDropperControls)
			{
				PublishRoomSelection(-1);
				return true;
			}
			RunSettings.IsCustomRun = false;
			int mode = ((dropperMode == 0) ? (-101) : (-102));
			PublishRoomSelection(mode);
			SendDropperMode(__instance, mode);
			return true;
		}

		private static void EnsureButtons(BoardingPass pass)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			if ((Object)(object)pass == (Object)null || (Object)(object)switchButton != (Object)null)
			{
				return;
			}
			Transform val = ((Component)pass).transform.Find("BoardingPass/Panel");
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)pass).transform.Find("Panel");
			}
			if ((Object)(object)val == (Object)null || (Object)(object)pass.incrementAscentButton == (Object)null)
			{
				SwitcherPlugin.Log.LogWarning((object)"Could not find boarding pass panel/reference button for Dropper switcher.");
				return;
			}
			GameObject gameObject = ((Component)pass.incrementAscentButton).gameObject;
			Transform parent = val;
			Vector2 position = new Vector2(545f, 405f);
			Vector2 size = new Vector2(120f, 30f);
			object obj = <>c.<>9__39_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					useDropperControls = !useDropperControls;
					SwitcherPlugin.Log.LogInfo((object)("Dropper feature switch clicked. Dropper controls: " + useDropperControls));
					if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.boardingPass != (Object)null)
					{
						InvokeUpdateAscent(GUIManager.instance.boardingPass);
					}
				};
				<>c.<>9__39_0 = val2;
				obj = (object)val2;
			}
			switchButton = CreateButton(pass, gameObject, parent, "DropperFeatureSwitch", position, size, (UnityAction)obj, out switchButtonText);
			GameObject gameObject2 = ((Component)pass.incrementAscentButton).gameObject;
			Transform parent2 = val;
			Vector2 position2 = new Vector2(690f, 405f);
			Vector2 size2 = new Vector2(135f, 30f);
			object obj2 = <>c.<>9__39_1;
			if (obj2 == null)
			{
				UnityAction val3 = delegate
				{
					dropperMode = ((dropperMode == 0) ? 1 : 0);
					SwitcherPlugin.Log.LogInfo((object)("Dropper mode switch clicked. Mode: " + dropperMode));
					if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.boardingPass != (Object)null)
					{
						InvokeUpdateAscent(GUIManager.instance.boardingPass);
					}
				};
				<>c.<>9__39_1 = val3;
				obj2 = (object)val3;
			}
			dropperModeButton = CreateButton(pass, gameObject2, parent2, "DropperModeSwitch", position2, size2, (UnityAction)obj2, out dropperModeButtonText);
			SwitcherPlugin.Log.LogInfo((object)"Created Dropper switcher buttons on boarding pass.");
		}

		private static GameObject CreateButton(BoardingPass pass, GameObject referenceButton, Transform parent, string name, Vector2 position, Vector2 size, UnityAction onClick, out TextMeshProUGUI label)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(referenceButton, parent, false);
			((Object)val).name = name;
			Animator component = val.GetComponent<Animator>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Transform val2 = val.transform.Find("Image");
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			RectTransform component2 = val.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.zero;
			component2.pivot = Vector2.zero;
			component2.anchoredPosition = position;
			component2.sizeDelta = size;
			Button component3 = val.GetComponent<Button>();
			((UnityEventBase)component3.onClick).RemoveAllListeners();
			((UnityEvent)component3.onClick).AddListener(onClick);
			((Selectable)component3).interactable = true;
			label = val.GetComponentInChildren<TextMeshProUGUI>(true);
			if ((Object)(object)label == (Object)null)
			{
				GameObject val3 = new GameObject("Text (TMP)");
				val3.transform.SetParent(val.transform, false);
				RectTransform val4 = val3.AddComponent<RectTransform>();
				val4.anchorMin = Vector2.zero;
				val4.anchorMax = Vector2.one;
				val4.offsetMin = Vector2.zero;
				val4.offsetMax = Vector2.zero;
				label = val3.AddComponent<TextMeshProUGUI>();
			}
			((TMP_Text)label).alignment = (TextAlignmentOptions)514;
			if ((Object)(object)pass.ascentTitle != (Object)null && (Object)(object)pass.ascentTitle.font != (Object)null)
			{
				((TMP_Text)label).font = pass.ascentTitle.font;
			}
			((TMP_Text)label).enableAutoSizing = true;
			((TMP_Text)label).fontSizeMin = 10f;
			((TMP_Text)label).fontSizeMax = 15f;
			((TMP_Text)label).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)label).overflowMode = (TextOverflowModes)1;
			((TMP_Text)label).margin = new Vector4(8f, 0f, 8f, 0f);
			((Graphic)label).raycastTarget = false;
			val.transform.SetAsLastSibling();
			return val;
		}

		private static void Refresh(BoardingPass pass)
		{
			//IL_0086: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)switchButton == (Object)null) && !((Object)(object)dropperModeButton == (Object)null))
			{
				bool isCustomRun = RunSettings.IsCustomRun;
				switchButton.SetActive(!isCustomRun);
				bool flag = useDropperControls && !isCustomRun;
				dropperModeButton.SetActive(flag);
				MakeButtonUsable(switchButton);
				if (flag)
				{
					MakeButtonUsable(dropperModeButton);
				}
				SetButtonColor(switchButton, useDropperControls ? Yellow : Blue);
				SetButtonColor(dropperModeButton, Yellow);
				SetText(switchButtonText, GetFeatureButtonText());
				SetText(dropperModeButtonText, GetModeButtonText());
				if (!flag)
				{
					RestoreBoardingPassUi(pass);
				}
				else
				{
					ApplyDropperBoardingPassUi(pass);
				}
			}
		}

		private static void SetOriginalAscentButtons(BoardingPass pass, bool visible)
		{
			if ((Object)(object)pass.incrementAscentButton != (Object)null)
			{
				((Component)pass.incrementAscentButton).gameObject.SetActive(visible);
			}
			if ((Object)(object)pass.decrementAscentButton != (Object)null)
			{
				((Component)pass.decrementAscentButton).gameObject.SetActive(visible);
			}
		}

		private static void ApplyDropperBoardingPassUi(BoardingPass pass)
		{
			if ((Object)(object)pass == (Object)null)
			{
				return;
			}
			peakLevelSelectHiddenByDropper = true;
			SetPeakLevelSelectVisible(visible: false);
			if (!dropperUiApplied)
			{
				dropperUiApplied = true;
				if ((Object)(object)pass.reward != (Object)null && !capturedRewardState)
				{
					capturedRewardState = true;
					defaultRewardActive = pass.reward.activeSelf;
				}
				if ((Object)(object)pass.customOptionsButton != (Object)null && !capturedCustomOptionsState)
				{
					capturedCustomOptionsState = true;
					defaultCustomOptionsActive = ((Component)pass.customOptionsButton).gameObject.activeSelf;
				}
			}
			SetOriginalAscentButtons(pass, visible: false);
			ApplyDropperDescriptionLayout(pass);
			pass.ascentTitle.text = GetModeTitle();
			pass.ascentDesc.text = GetModeDescription();
			if ((Object)(object)pass.reward != (Object)null)
			{
				pass.reward.SetActive(false);
			}
			if ((Object)(object)pass.customOptionsButton != (Object)null)
			{
				((Component)pass.customOptionsButton).gameObject.SetActive(false);
			}
		}

		private static void RestoreBoardingPassUi(BoardingPass pass)
		{
			if (!((Object)(object)pass == (Object)null) && dropperUiApplied)
			{
				RestoreDescriptionLayout(pass);
				SetOriginalAscentButtons(pass, visible: true);
				if (peakLevelSelectHiddenByDropper)
				{
					SetPeakLevelSelectVisible(visible: true);
					peakLevelSelectHiddenByDropper = false;
				}
				if (capturedRewardState && (Object)(object)pass.reward != (Object)null)
				{
					pass.reward.SetActive(defaultRewardActive);
				}
				if (capturedCustomOptionsState && (Object)(object)pass.customOptionsButton != (Object)null)
				{
					((Component)pass.customOptionsButton).gameObject.SetActive(defaultCustomOptionsActive);
				}
				dropperUiApplied = false;
			}
		}

		private static void ApplyDropperDescriptionLayout(BoardingPass pass)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)pass == (Object)null) && !((Object)(object)pass.ascentDesc == (Object)null))
			{
				if (!capturedDescLayout)
				{
					capturedDescLayout = true;
					defaultDescAutoSizing = pass.ascentDesc.enableAutoSizing;
					defaultDescLineSpacing = pass.ascentDesc.lineSpacing;
					defaultDescParagraphSpacing = pass.ascentDesc.paragraphSpacing;
					defaultDescMargin = pass.ascentDesc.margin;
					defaultDescFontSizeMin = pass.ascentDesc.fontSizeMin;
					defaultDescFontSizeMax = pass.ascentDesc.fontSizeMax;
				}
				CaptureTitleLayout(pass);
				ApplyTitleLayout(pass);
				pass.ascentDesc.enableAutoSizing = true;
				pass.ascentDesc.lineSpacing = (DropperText.IsChinese ? 10f : 1f);
				pass.ascentDesc.paragraphSpacing = 0f;
				pass.ascentDesc.fontSizeMin = (DropperText.IsChinese ? defaultDescFontSizeMin : 22f);
				pass.ascentDesc.fontSizeMax = (DropperText.IsChinese ? defaultDescFontSizeMax : 29f);
				pass.ascentDesc.margin = (DropperText.IsChinese ? new Vector4(0f, 10f, 0f, 0f) : new Vector4(0f, 4f, 12f, 0f));
			}
		}

		private static void RestoreDescriptionLayout(BoardingPass pass)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (capturedDescLayout && !((Object)(object)pass == (Object)null) && !((Object)(object)pass.ascentDesc == (Object)null))
			{
				pass.ascentDesc.lineSpacing = defaultDescLineSpacing;
				pass.ascentDesc.paragraphSpacing = defaultDescParagraphSpacing;
				pass.ascentDesc.margin = defaultDescMargin;
				pass.ascentDesc.enableAutoSizing = defaultDescAutoSizing;
				pass.ascentDesc.fontSizeMin = defaultDescFontSizeMin;
				pass.ascentDesc.fontSizeMax = defaultDescFontSizeMax;
				RestoreTitleLayout();
			}
		}

		private static void CaptureTitleLayout(BoardingPass pass)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (!capturedTitleLayout && !((Object)(object)pass == (Object)null) && !((Object)(object)pass.ascentTitle == (Object)null))
			{
				ascentTitleRect = pass.ascentTitle.rectTransform;
				if (!((Object)(object)ascentTitleRect == (Object)null))
				{
					capturedTitleLayout = true;
					defaultAscentTitleAnchoredPosition = ascentTitleRect.anchoredPosition;
					defaultAscentTitleSizeDelta = ascentTitleRect.sizeDelta;
				}
			}
		}

		private static void ApplyTitleLayout(BoardingPass pass)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)pass?.ascentTitle == (Object)null) && !((Object)(object)ascentTitleRect == (Object)null))
			{
				if (DropperText.IsChinese)
				{
					ascentTitleRect.anchoredPosition = defaultAscentTitleAnchoredPosition;
					ascentTitleRect.sizeDelta = defaultAscentTitleSizeDelta;
				}
				else
				{
					ascentTitleRect.anchoredPosition = defaultAscentTitleAnchoredPosition + new Vector2(12f, 0f);
					ascentTitleRect.sizeDelta = new Vector2(defaultAscentTitleSizeDelta.x - 12f, defaultAscentTitleSizeDelta.y);
				}
			}
		}

		private static void RestoreTitleLayout()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (capturedTitleLayout && !((Object)(object)ascentTitleRect == (Object)null))
			{
				ascentTitleRect.anchoredPosition = defaultAscentTitleAnchoredPosition;
				ascentTitleRect.sizeDelta = defaultAscentTitleSizeDelta;
			}
		}

		private static void SetPeakLevelSelectVisible(bool visible)
		{
			try
			{
				Type type = GetPeakLevelSelectPatchType();
				if (type == null)
				{
					return;
				}
				object? obj = AccessTools.Field(type, "dropDown")?.GetValue(null);
				GameObject val = (GameObject)((obj is GameObject) ? obj : null);
				if ((Object)(object)val != (Object)null)
				{
					val.SetActive(visible);
				}
				if (!(AccessTools.Property(type, "buttons")?.GetValue(null, null) is IEnumerable enumerable))
				{
					return;
				}
				foreach (object item in enumerable)
				{
					GameObject val2 = (GameObject)((item is GameObject) ? item : null);
					if (val2 != null)
					{
						val2.SetActive(visible);
					}
				}
			}
			catch (Exception ex)
			{
				SwitcherPlugin.Log.LogDebug((object)("PeakLevelSelect visibility refresh skipped: " + ex.Message));
			}
		}

		private static Type GetPeakLevelSelectPatchType()
		{
			if (checkedPeakLevelSelect)
			{
				return peakLevelSelectPatchType;
			}
			checkedPeakLevelSelect = true;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				peakLevelSelectPatchType = assembly.GetType("PeakLevelSelect.GUIManagerPatch", throwOnError: false);
				if (peakLevelSelectPatchType != null)
				{
					break;
				}
			}
			return peakLevelSelectPatchType;
		}

		private static void SendDropperMode(BoardingPass pass, int mode)
		{
			try
			{
				SwitcherPlugin.Log.LogInfo((object)("Sending Dropper mode: " + mode));
				AirportCheckInKiosk kiosk = pass.kiosk;
				if (!((Object)(object)kiosk == (Object)null))
				{
					LoadCorrectDropper val = ((Component)kiosk).GetComponent<LoadCorrectDropper>();
					if ((Object)(object)val == (Object)null)
					{
						val = ((Component)kiosk).gameObject.AddComponent<LoadCorrectDropper>();
					}
					PhotonView component = ((Component)kiosk).GetComponent<PhotonView>();
					if ((Object)(object)component != (Object)null)
					{
						component.RPC("LoadDropper", (RpcTarget)0, new object[1] { mode });
					}
					else
					{
						val.LoadDropper(mode);
					}
				}
			}
			catch (Exception ex)
			{
				SwitcherPlugin.Log.LogError((object)("Failed to send Dropper mode: " + ex));
			}
		}

		private static void PublishRoomSelection(int mode)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			try
			{
				Plugin.ToggleModpack(mode switch
				{
					-102 => 1, 
					-101 => 0, 
					_ => -1, 
				});
				SyncPeakLevelSelectFromLocal(out var selectedLevel, out var selectedAscent);
				if (PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null)
				{
					Hashtable val = new Hashtable
					{
						[(object)"DropperFix.Mode"] = mode,
						[(object)"DropperFix.PeakLevel"] = selectedLevel,
						[(object)"DropperFix.PeakAscent"] = selectedAscent
					};
					PhotonNetwork.CurrentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
					SwitcherPlugin.Log.LogInfo((object)$"Published host selection: mode={mode}, peakLevel={selectedLevel}, peakAscent={selectedAscent}");
				}
			}
			catch (Exception ex)
			{
				SwitcherPlugin.Log.LogWarning((object)("Failed to publish host selection: " + ex.Message));
			}
		}

		private static void ApplyRoomSelection(string source)
		{
			try
			{
				if (!PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom == null)
				{
					return;
				}
				Hashtable customProperties = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties;
				if (customProperties != null)
				{
					if (TryGetInt(customProperties, "DropperFix.PeakLevel", out var value))
					{
						SetPeakLevelSelectValue("SelectedLevel", value);
					}
					if (TryGetInt(customProperties, "DropperFix.PeakAscent", out var value2))
					{
						SetPeakLevelSelectValue("SelectedAscent", value2);
					}
					if (TryGetInt(customProperties, "DropperFix.Mode", out var value3))
					{
						Plugin.ToggleModpack(value3 switch
						{
							-102 => 1, 
							-101 => 0, 
							_ => -1, 
						});
						SwitcherPlugin.Log.LogInfo((object)$"Applied room selection from {source}: mode={value3}, peakLevel={value}, peakAscent={value2}");
					}
				}
			}
			catch (Exception ex)
			{
				SwitcherPlugin.Log.LogWarning((object)("Failed to apply room selection: " + ex.Message));
			}
		}

		private static bool TryGetInt(Hashtable table, string key, out int value)
		{
			value = 0;
			if (!((Dictionary<object, object>)(object)table).ContainsKey((object)key))
			{
				return false;
			}
			object obj = table[(object)key];
			if (obj is int num)
			{
				value = num;
				return true;
			}
			if (obj is short num2)
			{
				value = num2;
				return true;
			}
			if (obj is byte b)
			{
				value = b;
				return true;
			}
			return int.TryParse(obj?.ToString(), out value);
		}

		private static void SyncPeakLevelSelectFromLocal(out int selectedLevel, out int selectedAscent)
		{
			selectedLevel = GetPeakLevelSelectValue("SelectedLevel", -9999);
			selectedAscent = GetPeakLevelSelectValue("SelectedAscent", -9999);
		}

		private static int GetPeakLevelSelectValue(string propertyName, int fallback)
		{
			object obj = GetPeakLevelSelectPluginType()?.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public)?.GetValue(null, null);
			return (obj?.GetType().GetProperty("Value")?.GetValue(obj, null) is int num) ? num : fallback;
		}

		private static void SetPeakLevelSelectValue(string propertyName, int value)
		{
			if (value != -9999)
			{
				object obj = GetPeakLevelSelectPluginType()?.GetProperty(propertyName, BindingFlags.Static | BindingFlags.Public)?.GetValue(null, null);
				obj?.GetType().GetProperty("Value")?.SetValue(obj, value, null);
			}
		}

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

		private static void InvokeUpdateAscent(BoardingPass pass)
		{
			UpdateAscentMethod?.Invoke(pass, Array.Empty<object>());
		}

		private static void SetButtonColor(GameObject button, Color color)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Image component = button.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Graphic)component).color = color;
				((Graphic)component).raycastTarget = true;
			}
		}

		private static void MakeButtonUsable(GameObject button)
		{
			if ((Object)(object)button == (Object)null)
			{
				return;
			}
			Button component = button.GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				((Selectable)component).interactable = true;
			}
			Image component2 = button.GetComponent<Image>();
			if ((Object)(object)component2 != (Object)null)
			{
				((Graphic)component2).raycastTarget = true;
				if ((Object)(object)component != (Object)null)
				{
					((Selectable)component).targetGraphic = (Graphic)(object)component2;
				}
			}
			button.transform.SetAsLastSibling();
		}

		private static void SetText(TextMeshProUGUI label, string text)
		{
			if ((Object)(object)label != (Object)null)
			{
				((TMP_Text)label).text = text;
			}
		}

		private static string GetFeatureButtonText()
		{
			return useDropperControls ? DropperText.Choose("Dropper", "坠落") : DropperText.Choose("Default", "原版");
		}

		private static string GetModeButtonText()
		{
			return (dropperMode == 0) ? DropperText.Choose("Classic", "经典") : DropperText.Choose("Descend", "下降");
		}

		private static string GetModeTitle()
		{
			return (dropperMode == 0) ? DropperText.Choose("Dropper", "坠落挑战") : DropperText.Choose("Dropper - Descent", "坠落挑战 - 下降");
		}

		private static string GetModeDescription()
		{
			return (dropperMode == 0) ? DropperText.Choose("Jump from high platforms, survive,\nthen take the portal to the next drop.", "坠落模式:从高处平台跳下,\n存活后通过传送门进入下一段。") : DropperText.Choose("Climb and parkour down in stages\ninstead of dropping straight down.", "下降模式:不再直接坠到底部,\n需要分段攀爬和跑酷向下推进。");
		}
	}
}