Decompiled source of Giant Extension Ladders v3.3.0

BepInEx/plugins/inoyu.GiantExtensionLadders.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using GiantExtensionLaddersV2.Behaviours;
using GiantExtensionLaddersV2.ConfigStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UIElements.Collections;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("inoyu.GiantExtensionLadders")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("3.3.0.0")]
[assembly: AssemblyInformationalVersion("3.3.0+a134e7e52cc75729e305413139ef9c98cd830c46")]
[assembly: AssemblyProduct("GiantExtensionLaddersV2")]
[assembly: AssemblyTitle("inoyu.GiantExtensionLadders")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.3.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 GiantExtensionLaddersV2
{
	[BepInPlugin("inoyu.GiantExtensionLadders", "GiantExtensionLaddersV2", "3.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("com.sigurd.csync", "5.0.0")]
	public class GiantExtensionLaddersV2 : BaseUnityPlugin
	{
		internal static MySyncedConfigs mySyncedConfigs;

		private const string ladderAssetbundleName = "allLadderAssets";

		private const string tinyLadderAssetbundleName = "TinyLadderAssets";

		private const string bigLadderAssetbundleName = "BigLadderAssets";

		private const string hugeLadderAssetbundleName = "HugeLadderAssets";

		private const string ultimateLadderAssetbundleName = "UltimateLadderAssets";

		private const string ladderCollectorAssetBundleName = "laddercollector";

		private const string tinyLadderItemPropertiesLocation = "Assets/extLadderTest/tinyLadder/TinyLadder.asset";

		private const string bigLadderItemPropertiesLocation = "Assets/extLadderTest/BigLadder/BigLadder.asset";

		private const string hugeLadderItemPropertiesLocation = "Assets/extLadderTest/HugeLadder/HugeLadder.asset";

		private const string ultimateLadderItemPropertiesLocation = "Assets/extLadderTest/Gigantic ladder/UltimateLadderItem.asset";

		private const string ladderCollectorItemLocation = "Assets/LethalCompany/Mods/Items/LadderCollector/LadderCollectorItem.asset";

		private const int MAX_PROPERTY_AMOUNT = 19;

		internal static int propertyCounter = 0;

		internal LadderObject tinyLadder = new LadderObject(10.3f, 75f, 0.15f, ladderIsClimbable: false, GiantLadderType.TINY);

		internal LadderObject bigLadder = new LadderObject(17f, 60f, 0.15f, ladderIsClimbable: true, GiantLadderType.BIG);

		internal LadderObject hugeLadder = new LadderObject(34.4f, 60f, 0.2f, ladderIsClimbable: true, GiantLadderType.HUGE);

		internal LadderObject ultimateLadder = new LadderObject(68f, 60f, 0.25f, ladderIsClimbable: true, GiantLadderType.ULTIMATE);

		internal static Item? tinyLadderItem;

		internal static Item? bigLadderItem;

		internal static Item? hugeLadderItem;

		internal static Item? ultimateLadderItem;

		internal static Item? ladderCollectorItem;

		internal static TerminalNode? tinyLadderNode;

		internal static TerminalNode? bigLadderNode;

		internal static TerminalNode? hugeLadderNode;

		internal static TerminalNode? ultimateLadderNode;

		internal static TerminalNode? ladderCollectorNode;

		internal static Dictionary<Item, string> originalItemNames = new Dictionary<Item, string>();

		internal static bool isBuildSuccess = true;

		internal static bool isPlayerOnTinyLadder = false;

		internal static GiantExtensionLaddersV2 Instance { get; private set; } = null;


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


		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("inoyu.GiantExtensionLadders");
			}
			mls = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			mySyncedConfigs = new MySyncedConfigs(((BaseUnityPlugin)this).Config);
			mls.LogInfo((object)"loading assetbundles");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TinyLadderAssets");
			string text2 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BigLadderAssets");
			string text3 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "HugeLadderAssets");
			string text4 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "UltimateLadderAssets");
			string text5 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "laddercollector");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			AssetBundle val2 = AssetBundle.LoadFromFile(text2);
			AssetBundle val3 = AssetBundle.LoadFromFile(text3);
			AssetBundle val4 = AssetBundle.LoadFromFile(text4);
			AssetBundle val5 = AssetBundle.LoadFromFile(text5);
			if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val == (Object)null || (Object)(object)val4 == (Object)null)
			{
				mls.LogError((object)"failed to load assetbundles");
				return;
			}
			tinyLadderItem = val.LoadAsset<Item>("Assets/extLadderTest/tinyLadder/TinyLadder.asset");
			bigLadderItem = val2.LoadAsset<Item>("Assets/extLadderTest/BigLadder/BigLadder.asset");
			hugeLadderItem = val3.LoadAsset<Item>("Assets/extLadderTest/HugeLadder/HugeLadder.asset");
			ultimateLadderItem = val4.LoadAsset<Item>("Assets/extLadderTest/Gigantic ladder/UltimateLadderItem.asset");
			ladderCollectorItem = val5.LoadAsset<Item>("Assets/LethalCompany/Mods/Items/LadderCollector/LadderCollectorItem.asset");
			if ((Object)(object)bigLadderItem == (Object)null || (Object)(object)hugeLadderItem == (Object)null || (Object)(object)tinyLadderItem == (Object)null || (Object)(object)ultimateLadderItem == (Object)null || (Object)(object)ladderCollectorItem == (Object)null)
			{
				mls.LogError((object)"failed to load items from item assetbundles");
				return;
			}
			mls.LogInfo((object)"building tiny ladder...");
			tinyLadder.ladderPrefab = tinyLadderItem.spawnPrefab;
			tinyLadder.meshRenderers = tinyLadder.ladderPrefab.GetComponentsInChildren<MeshRenderer>().ToList();
			tinyLadder.animators = tinyLadder.ladderPrefab.GetComponentsInChildren<Animator>().ToList();
			tinyLadder.transforms = tinyLadder.ladderPrefab.GetComponentsInChildren<Transform>().ToList();
			tinyLadder.audioClips = val.LoadAllAssets<AudioClip>().ToList();
			tinyLadder.audioSources = tinyLadder.ladderPrefab.GetComponentsInChildren<AudioSource>().ToList();
			tinyLadder.interactTriggers = tinyLadder.ladderPrefab.GetComponentsInChildren<InteractTrigger>().ToList();
			tinyLadder.boxColliders = tinyLadder.ladderPrefab.GetComponentsInChildren<BoxCollider>().ToList();
			LadderItemScript ladderItemScript = tinyLadder.ladderPrefab.AddComponent<LadderItemScript>();
			if ((Object)(object)tinyLadder.ladderPrefab.GetComponent<LadderItemScript>() == (Object)null)
			{
				mls.LogError((object)"tinyLadderItemPrefab failed");
				return;
			}
			((GrabbableObject)ladderItemScript).grabbable = true;
			((GrabbableObject)ladderItemScript).grabbableToEnemies = true;
			((GrabbableObject)ladderItemScript).itemProperties = tinyLadderItem;
			ladderItemScript.maxExtension = tinyLadder.LADDER_MAX_EXTENSION;
			ladderItemScript.minInteractableRotation = tinyLadder.LADDER_MIN_ROTATION_FOR_INTERACTION;
			ladderItemScript.ladderRotateSpeedMultiplier = tinyLadder.LADDER_ROTATE_SPEED;
			ladderItemScript.isClimbable = true;
			ladderItemScript.isClimbableInShip = true;
			ladderItemScript.giantLadderType = tinyLadder.ladderType;
			BuildLadderItemScript(tinyLadder.meshRenderers, tinyLadder.animators, tinyLadder.transforms, tinyLadder.audioClips, tinyLadder.audioSources, tinyLadder.interactTriggers, tinyLadder.boxColliders, ladderItemScript);
			tinyLadderItem.canBeGrabbedBeforeGameStart = true;
			mls.LogInfo((object)"building big ladder...");
			bigLadder.ladderPrefab = bigLadderItem.spawnPrefab;
			bigLadder.meshRenderers = bigLadder.ladderPrefab.GetComponentsInChildren<MeshRenderer>().ToList();
			bigLadder.animators = bigLadder.ladderPrefab.GetComponentsInChildren<Animator>().ToList();
			bigLadder.transforms = bigLadder.ladderPrefab.GetComponentsInChildren<Transform>().ToList();
			bigLadder.audioClips = val2.LoadAllAssets<AudioClip>().ToList();
			bigLadder.audioSources = bigLadder.ladderPrefab.GetComponentsInChildren<AudioSource>().ToList();
			bigLadder.interactTriggers = bigLadder.ladderPrefab.GetComponentsInChildren<InteractTrigger>().ToList();
			bigLadder.boxColliders = bigLadder.ladderPrefab.GetComponentsInChildren<BoxCollider>().ToList();
			LadderItemScript ladderItemScript2 = bigLadder.ladderPrefab.AddComponent<LadderItemScript>();
			if ((Object)(object)bigLadder.ladderPrefab.GetComponent<LadderItemScript>() == (Object)null)
			{
				mls.LogError((object)"bigLadderScript failed");
				return;
			}
			((GrabbableObject)ladderItemScript2).grabbable = true;
			((GrabbableObject)ladderItemScript2).grabbableToEnemies = true;
			((GrabbableObject)ladderItemScript2).itemProperties = bigLadderItem;
			ladderItemScript2.maxExtension = bigLadder.LADDER_MAX_EXTENSION;
			ladderItemScript2.minInteractableRotation = bigLadder.LADDER_MIN_ROTATION_FOR_INTERACTION;
			ladderItemScript2.ladderRotateSpeedMultiplier = bigLadder.LADDER_ROTATE_SPEED;
			ladderItemScript2.isClimbable = bigLadder.LADDER_IS_CLIMBABLE;
			ladderItemScript2.giantLadderType = bigLadder.ladderType;
			BuildLadderItemScript(bigLadder.meshRenderers, bigLadder.animators, bigLadder.transforms, bigLadder.audioClips, bigLadder.audioSources, bigLadder.interactTriggers, bigLadder.boxColliders, ladderItemScript2);
			mls.LogInfo((object)"building huge ladder...");
			hugeLadder.ladderPrefab = hugeLadderItem.spawnPrefab;
			hugeLadder.meshRenderers = hugeLadder.ladderPrefab.GetComponentsInChildren<MeshRenderer>().ToList();
			hugeLadder.animators = hugeLadder.ladderPrefab.GetComponentsInChildren<Animator>().ToList();
			hugeLadder.transforms = hugeLadder.ladderPrefab.GetComponentsInChildren<Transform>().ToList();
			hugeLadder.audioClips = val3.LoadAllAssets<AudioClip>().ToList();
			hugeLadder.audioSources = hugeLadder.ladderPrefab.GetComponentsInChildren<AudioSource>().ToList();
			hugeLadder.interactTriggers = hugeLadder.ladderPrefab.GetComponentsInChildren<InteractTrigger>().ToList();
			hugeLadder.boxColliders = hugeLadder.ladderPrefab.GetComponentsInChildren<BoxCollider>().ToList();
			LadderItemScript ladderItemScript3 = hugeLadder.ladderPrefab.AddComponent<LadderItemScript>();
			if ((Object)(object)hugeLadder.ladderPrefab.GetComponent<LadderItemScript>() == (Object)null)
			{
				mls.LogError((object)"hugeLadderScript failed");
				return;
			}
			((GrabbableObject)ladderItemScript3).grabbable = true;
			((GrabbableObject)ladderItemScript3).grabbableToEnemies = true;
			((GrabbableObject)ladderItemScript3).itemProperties = hugeLadderItem;
			ladderItemScript3.maxExtension = hugeLadder.LADDER_MAX_EXTENSION;
			ladderItemScript3.minInteractableRotation = hugeLadder.LADDER_MIN_ROTATION_FOR_INTERACTION;
			ladderItemScript3.ladderRotateSpeedMultiplier = hugeLadder.LADDER_ROTATE_SPEED;
			ladderItemScript3.isClimbable = hugeLadder.LADDER_IS_CLIMBABLE;
			ladderItemScript3.giantLadderType = hugeLadder.ladderType;
			BuildLadderItemScript(hugeLadder.meshRenderers, hugeLadder.animators, hugeLadder.transforms, hugeLadder.audioClips, hugeLadder.audioSources, hugeLadder.interactTriggers, hugeLadder.boxColliders, ladderItemScript3);
			mls.LogInfo((object)"building ultimate ladder...");
			ultimateLadder.ladderPrefab = ultimateLadderItem.spawnPrefab;
			ultimateLadder.meshRenderers = ultimateLadder.ladderPrefab.GetComponentsInChildren<MeshRenderer>().ToList();
			ultimateLadder.animators = ultimateLadder.ladderPrefab.GetComponentsInChildren<Animator>().ToList();
			ultimateLadder.transforms = ultimateLadder.ladderPrefab.GetComponentsInChildren<Transform>().ToList();
			ultimateLadder.audioClips = val4.LoadAllAssets<AudioClip>().ToList();
			ultimateLadder.audioSources = ultimateLadder.ladderPrefab.GetComponentsInChildren<AudioSource>().ToList();
			ultimateLadder.interactTriggers = ultimateLadder.ladderPrefab.GetComponentsInChildren<InteractTrigger>().ToList();
			ultimateLadder.boxColliders = ultimateLadder.ladderPrefab.GetComponentsInChildren<BoxCollider>().ToList();
			LadderItemScript ladderItemScript4 = ultimateLadder.ladderPrefab.AddComponent<LadderItemScript>();
			if ((Object)(object)ultimateLadder.ladderPrefab.GetComponent<LadderItemScript>() == (Object)null)
			{
				mls.LogError((object)"ultimateLadderScript failed");
				return;
			}
			((GrabbableObject)ladderItemScript4).grabbable = true;
			((GrabbableObject)ladderItemScript4).grabbableToEnemies = true;
			((GrabbableObject)ladderItemScript4).itemProperties = ultimateLadderItem;
			ladderItemScript4.maxExtension = ultimateLadder.LADDER_MAX_EXTENSION;
			ladderItemScript4.minInteractableRotation = ultimateLadder.LADDER_MIN_ROTATION_FOR_INTERACTION;
			ladderItemScript4.ladderRotateSpeedMultiplier = ultimateLadder.LADDER_ROTATE_SPEED;
			ladderItemScript4.isClimbable = ultimateLadder.LADDER_IS_CLIMBABLE;
			ladderItemScript4.giantLadderType = ultimateLadder.ladderType;
			BuildLadderItemScript(ultimateLadder.meshRenderers, ultimateLadder.animators, ultimateLadder.transforms, ultimateLadder.audioClips, ultimateLadder.audioSources, ultimateLadder.interactTriggers, ultimateLadder.boxColliders, ladderItemScript4);
			if (!isBuildSuccess)
			{
				mls.LogError((object)"Ran into a problem finding all ladder components on some ladders. If you see this, please add it as an issue on this mod's GitHub page.");
				return;
			}
			LadderCollectorScript ladderCollectorScript = ladderCollectorItem.spawnPrefab.AddComponent<LadderCollectorScript>();
			if ((Object)(object)ladderCollectorScript == (Object)null)
			{
				mls.LogError((object)"ladderCollectorScript failed");
				return;
			}
			((GrabbableObject)ladderCollectorScript).grabbable = true;
			((GrabbableObject)ladderCollectorScript).grabbableToEnemies = false;
			((GrabbableObject)ladderCollectorScript).itemProperties = ladderCollectorItem;
			ladderCollectorScript.lcAudioSource = ladderCollectorItem.spawnPrefab.GetComponent<AudioSource>();
			ladderCollectorScript.teleportationLight = ladderCollectorItem.spawnPrefab.GetComponentInChildren<Light>();
			List<Transform> list = ladderCollectorItem.spawnPrefab.GetComponentsInChildren<Transform>().ToList();
			List<AudioClip> list2 = val5.LoadAllAssets<AudioClip>().ToList();
			foreach (Transform item in list)
			{
				if (((Object)item).name.Equals("BaseNode"))
				{
					ladderCollectorScript.baseNode = item;
				}
				else if (((Object)item).name.Equals("LadderSpawnNode"))
				{
					ladderCollectorScript.ladderSpawnNode = item;
				}
			}
			foreach (AudioClip item2 in list2)
			{
				if (((Object)item2).name.Equals("spawnSFX3"))
				{
					ladderCollectorScript.spawnAudio = item2;
				}
			}
			if ((Object)(object)ladderCollectorScript.baseNode == (Object)null || (Object)(object)ladderCollectorScript.ladderSpawnNode == (Object)null || (Object)(object)ladderCollectorScript.spawnAudio == (Object)null || (Object)(object)ladderCollectorScript.lcAudioSource == (Object)null || (Object)(object)ladderCollectorScript.teleportationLight == (Object)null)
			{
				mls.LogError((object)"some components for ladderCollector couldn't be found!");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(tinyLadderItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(bigLadderItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(hugeLadderItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(ultimateLadderItem.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(ladderCollectorItem.spawnPrefab);
			Utilities.FixMixerGroups(tinyLadderItem.spawnPrefab);
			Utilities.FixMixerGroups(bigLadderItem.spawnPrefab);
			Utilities.FixMixerGroups(hugeLadderItem.spawnPrefab);
			Utilities.FixMixerGroups(ultimateLadderItem.spawnPrefab);
			Utilities.FixMixerGroups(ladderCollectorItem.spawnPrefab);
			tinyLadderNode = ScriptableObject.CreateInstance<TerminalNode>();
			tinyLadderNode.clearPreviousText = true;
			tinyLadderNode.displayText = "Awwww... tiny ladder! Can be used if the person climbing is also tiny!\n\n";
			Items.RegisterShopItem(tinyLadderItem, (TerminalNode)null, (TerminalNode)null, tinyLadderNode, SyncedEntry<int>.op_Implicit(mySyncedConfigs.tinyLadderPrice));
			bigLadderNode = ScriptableObject.CreateInstance<TerminalNode>();
			bigLadderNode.clearPreviousText = true;
			bigLadderNode.displayText = "This ladder is 17m high, thats about 1,75x height of the standard ladder.\n\n";
			Items.RegisterShopItem(bigLadderItem, (TerminalNode)null, (TerminalNode)null, bigLadderNode, SyncedEntry<int>.op_Implicit(mySyncedConfigs.bigLadderPrice));
			hugeLadderNode = ScriptableObject.CreateInstance<TerminalNode>();
			hugeLadderNode.clearPreviousText = true;
			hugeLadderNode.displayText = "This ladder is 34m high, thats about 3,5x height of the standard ladder.\n\n";
			Items.RegisterShopItem(hugeLadderItem, (TerminalNode)null, (TerminalNode)null, hugeLadderNode, SyncedEntry<int>.op_Implicit(mySyncedConfigs.hugeLadderPrice));
			ultimateLadderNode = ScriptableObject.CreateInstance<TerminalNode>();
			ultimateLadderNode.clearPreviousText = true;
			ultimateLadderNode.displayText = "This ladder is 68m high, thats about 7x height of the standard ladder.\n\n";
			Items.RegisterShopItem(ultimateLadderItem, (TerminalNode)null, (TerminalNode)null, ultimateLadderNode, SyncedEntry<int>.op_Implicit(mySyncedConfigs.ultimateLadderPrice));
			ladderCollectorNode = ScriptableObject.CreateInstance<TerminalNode>();
			ladderCollectorNode.clearPreviousText = true;
			ladderCollectorNode.displayText = "This device somehow detects and attracts ladders within an huge range.\n\n";
			Items.RegisterShopItem(ladderCollectorItem, (TerminalNode)null, (TerminalNode)null, ladderCollectorNode, 75);
			originalItemNames.Add(tinyLadderItem, tinyLadderItem.itemName);
			originalItemNames.Add(bigLadderItem, bigLadderItem.itemName);
			originalItemNames.Add(hugeLadderItem, hugeLadderItem.itemName);
			originalItemNames.Add(ultimateLadderItem, ultimateLadderItem.itemName);
			originalItemNames.Add(ladderCollectorItem, ladderCollectorItem.itemName);
			Harmony.PatchAll();
			mls.LogInfo((object)"builds completed and items should be in shop.");
			mls.LogInfo((object)"inoyu.GiantExtensionLadders v3.3.0 has fully loaded!");
		}

		private void BuildLadderItemScript(List<MeshRenderer> meshRenderers, List<Animator> animators, List<Transform> transforms, List<AudioClip> audioClips, List<AudioSource> audioSources, List<InteractTrigger> interactTriggers, List<BoxCollider> boxColliders, LadderItemScript ladderItemScript)
		{
			propertyCounter = 0;
			foreach (MeshRenderer meshRenderer in meshRenderers)
			{
				if (((Object)meshRenderer).name.Equals("LadderBox"))
				{
					propertyCounter++;
					((GrabbableObject)ladderItemScript).mainObjectRenderer = meshRenderer;
					break;
				}
			}
			foreach (Animator animator in animators)
			{
				if (((Object)animator).name.Equals("AnimContainer"))
				{
					propertyCounter++;
					ladderItemScript.ladderAnimator = animator;
				}
				if (((Object)animator).name.Equals("MeshContainer"))
				{
					propertyCounter++;
					ladderItemScript.ladderRotateAnimator = animator;
				}
			}
			foreach (Transform transform in transforms)
			{
				if (((Object)transform).name.Equals("Base"))
				{
					propertyCounter++;
					ladderItemScript.baseNode = transform;
				}
				if (((Object)transform).name.Equals("TopPosition"))
				{
					propertyCounter++;
					ladderItemScript.topNode = transform;
				}
				if (((Object)transform).name.Equals("TopCollisionNode"))
				{
					propertyCounter++;
					ladderItemScript.topCollisionNode = transform;
				}
				if (((Object)transform).name.Equals("MovableNode"))
				{
					propertyCounter++;
					ladderItemScript.moveableNode = transform;
				}
			}
			foreach (AudioClip audioClip in audioClips)
			{
				if (((Object)audioClip).name.Equals("ExtensionLadderHitWall"))
				{
					propertyCounter++;
					ladderItemScript.hitRoof = audioClip;
				}
				if (((Object)audioClip).name.Equals("ExtensionLadderHitWall2"))
				{
					propertyCounter += 2;
					ladderItemScript.fullExtend = audioClip;
					ladderItemScript.hitWall = audioClip;
				}
				if (((Object)audioClip).name.Equals("ExtensionLadderExtend"))
				{
					propertyCounter++;
					ladderItemScript.ladderExtendSFX = audioClip;
				}
				if (((Object)audioClip).name.Equals("ExtensionLadderShrink"))
				{
					propertyCounter++;
					ladderItemScript.ladderShrinkSFX = audioClip;
				}
				if (((Object)audioClip).name.Equals("ExtensionLadderAlarm"))
				{
					propertyCounter++;
					ladderItemScript.blinkWarningSFX = audioClip;
				}
				if (((Object)audioClip).name.Equals("ExtensionLadderLidOpen"))
				{
					propertyCounter++;
					ladderItemScript.lidOpenSFX = audioClip;
				}
			}
			foreach (AudioSource audioSource in audioSources)
			{
				if (((Object)audioSource).name.Equals("LadderAudio"))
				{
					propertyCounter++;
					ladderItemScript.ladderAudio = audioSource;
					break;
				}
			}
			foreach (InteractTrigger interactTrigger in interactTriggers)
			{
				if (((Object)interactTrigger).name.Equals("ExtLadderTrigger"))
				{
					ladderItemScript.ladderScript = interactTrigger;
					propertyCounter++;
					break;
				}
			}
			foreach (BoxCollider boxCollider in boxColliders)
			{
				if (((Object)boxCollider).name.Equals("ExtLadderTrigger"))
				{
					propertyCounter++;
					ladderItemScript.interactCollider = (Collider)(object)boxCollider;
				}
				if (((Object)boxCollider).name.Equals("LadderBridgeCollider"))
				{
					propertyCounter++;
					ladderItemScript.bridgeCollider = (Collider)(object)boxCollider;
				}
				if (((Object)boxCollider).name.Equals("KillTrigger"))
				{
					propertyCounter++;
					ladderItemScript.killTrigger = (Collider)(object)boxCollider;
				}
			}
			if (propertyCounter != 19)
			{
				mls.LogError((object)("Some Components of " + ((Object)ladderItemScript).name + " are missing!"));
				isBuildSuccess = false;
			}
		}
	}
	internal enum GiantLadderType
	{
		TINY,
		BIG,
		HUGE,
		ULTIMATE
	}
	internal class LadderObject
	{
		internal List<MeshRenderer> meshRenderers { get; set; }

		internal List<Animator> animators { get; set; }

		internal List<Transform> transforms { get; set; }

		internal List<AudioClip> audioClips { get; set; }

		internal List<AudioSource> audioSources { get; set; }

		internal List<InteractTrigger> interactTriggers { get; set; }

		internal List<BoxCollider> boxColliders { get; set; }

		internal GameObject ladderPrefab { get; set; }

		internal GiantLadderType ladderType { get; private set; }

		internal float LADDER_MAX_EXTENSION { get; private set; }

		internal float LADDER_MIN_ROTATION_FOR_INTERACTION { get; private set; }

		internal int LADDER_LINECAST_CHECKS_MULTIPLIER { get; private set; }

		internal int LADDER_LINECAST_MIN_CHECK_HEIGHT { get; private set; }

		internal float LADDER_HEIGHT_MULTIPLIER { get; private set; }

		internal float LADDER_ROTATE_SPEED { get; private set; }

		internal bool LADDER_IS_CLIMBABLE { get; private set; }

		public LadderObject(float ladderMaxExtension, float ladderMinRotationForInteraction, float ladderRotateSpeed, bool ladderIsClimbable, GiantLadderType type)
		{
			LADDER_MAX_EXTENSION = ladderMaxExtension;
			LADDER_MIN_ROTATION_FOR_INTERACTION = ladderMinRotationForInteraction;
			LADDER_ROTATE_SPEED = ladderRotateSpeed;
			LADDER_IS_CLIMBABLE = ladderIsClimbable;
			ladderType = type;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "inoyu.GiantExtensionLadders";

		public const string PLUGIN_NAME = "GiantExtensionLaddersV2";

		public const string PLUGIN_VERSION = "3.3.0";
	}
}
namespace GiantExtensionLaddersV2.Patches
{
	[HarmonyPatch(typeof(InteractTrigger))]
	internal class LadderPlayerSnapPatch
	{
		private const float NEGATIVE_OFFSET_BASE_VALUE = 0.25f;

		private const float TINY_LADDER_OFFSET_BASE_VALUE = -0.215f;

		private const float OFFSET_BASE_VALUE = 0.035f;

		private const float BIGGER_LADDER_SIZE_START = 20f;

		private const int CLOSE_POS_ADDITIONAL_CHECKS = 10;

		private const int LADDER_BOT_RESET_AMOUNT = 2;

		private const int LADDER_TOP_RESET_AMOUNT = 5;

		private const float GROUND_OFFSET = 0.5f;

		private const float TINY_LADDER_GROUND_OFFSET = 0.05f;

		[HarmonyPrefix]
		[HarmonyPatch("ladderClimbAnimation")]
		public static void PatchLadderPlayerSnap(InteractTrigger __instance, ref PlayerControllerB playerController)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			LadderItemScript componentInParent = ((Component)__instance).GetComponentInParent<LadderItemScript>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				if (componentInParent.giantLadderType == GiantLadderType.TINY)
				{
					__instance.bottomOfLadderPosition.position = new Vector3(__instance.bottomOfLadderPosition.position.x, playerController.thisPlayerBody.position.y - 0.2f, __instance.bottomOfLadderPosition.position.z);
					GiantExtensionLaddersV2.isPlayerOnTinyLadder = true;
				}
				else
				{
					GiantExtensionLaddersV2.isPlayerOnTinyLadder = false;
				}
				Vector3 val = __instance.topOfLadderPosition.position - __instance.bottomOfLadderPosition.position;
				Vector3 val2 = Vector3.Normalize(val);
				float num = Vector3.Dot(Vector3.up, val2);
				float vector3CloseToLadder = GetVector3CloseToLadder(__instance.bottomOfLadderPosition.position, __instance.topOfLadderPosition.position, val2, playerController.thisPlayerBody.position);
				Vector3 val3 = __instance.bottomOfLadderPosition.position + vector3CloseToLadder * val2;
				float num2 = Vector3.Distance(__instance.topOfLadderPosition.position, __instance.bottomOfLadderPosition.position);
				Vector3 val4 = default(Vector3);
				((Vector3)(ref val4))..ctor(0f, 0.035f, 0f);
				val4 *= vector3CloseToLadder;
				if (val3.y + val4.y >= __instance.topOfLadderPosition.position.y && vector3CloseToLadder > 5f)
				{
					val3 = __instance.bottomOfLadderPosition.position + (vector3CloseToLadder - 5f) * val2;
				}
				else if (vector3CloseToLadder < 2f && num2 >= 20f)
				{
					val4 += __instance.bottomOfLadderPosition.forward * 0.25f;
				}
				if (componentInParent.giantLadderType == GiantLadderType.TINY)
				{
					if (((GrabbableObject)componentInParent).isInShipRoom)
					{
						Vector3 val5 = __instance.bottomOfLadderPosition.forward * -0.215f * (1.3f - (num * 2f - 1f));
						val4 += val5;
						val4 += val2 * 0.05f;
					}
					else
					{
						Vector3 val6 = __instance.bottomOfLadderPosition.forward * -0.215f * 0.75f;
						val4 += val6;
						val4 += val2 * 0.05f;
					}
				}
				else
				{
					val4 += val2 * 0.5f;
				}
				val3 += val4;
				__instance.ladderPlayerPositionNode.position = val3;
				playerController.thisPlayerBody.position = val3;
			}
			else
			{
				GiantExtensionLaddersV2.isPlayerOnTinyLadder = false;
			}
		}

		private static float GetVector3CloseToLadder(Vector3 bottomPos, Vector3 topPos, Vector3 normalizedLDV, Vector3 playerVector)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			float num2 = float.MaxValue;
			float num3 = Vector3.Distance(bottomPos, topPos) + 10f;
			for (int i = 0; (float)i < num3; i++)
			{
				Vector3 val = bottomPos + (float)i * normalizedLDV;
				float num4 = Vector3.Distance(playerVector, val);
				if (num4 < num2)
				{
					num2 = num4;
					num = i;
					continue;
				}
				return num;
			}
			return num3 / 2f;
		}
	}
	[HarmonyPatch]
	public class LoadLadderConfigsPatch
	{
		private const bool debugLogsActive = false;

		internal const string DISABLED_LADDER_PREFIX = "- - - ";

		internal const string DISABLED_ITEM_NAME = "- - - (removed item: {0})";

		internal const int DISABLED_ITEM_PRICE = 99999;

		private static List<Item> removedItemsTerminalFix = new List<Item>();

		private static List<Item> removedItemsSafeFix = new List<Item>();

		private static float methodUptime = 10f;

		private static float updateConfigStart = 3.5f;

		private static bool isPatchActive = true;

		private static bool isFirstPatch = true;

		private static bool wasFirstPatchFail = false;

		private static int amountOfRemovedItems = 0;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPriority(0)]
		public static void PatchLaddersConfigs()
		{
			if (isPatchActive && methodUptime > 0f)
			{
				methodUptime -= Time.deltaTime;
				if (methodUptime < updateConfigStart)
				{
					SyncLadderPrices();
				}
			}
			else if (isPatchActive && methodUptime <= 0f)
			{
				EvaluateConfigSync();
				if (isFirstPatch && wasFirstPatchFail)
				{
					GiantExtensionLaddersV2.mls.LogWarning((object)"Initial config sync failed, trying again...");
					isFirstPatch = false;
					methodUptime = 10f;
					removedItemsTerminalFix = new List<Item>();
				}
				else
				{
					isPatchActive = false;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		public static void PlayerLeave()
		{
			removedItemsTerminalFix = new List<Item>();
			removedItemsSafeFix = new List<Item>();
			methodUptime = 10f;
			updateConfigStart = 4f;
			isPatchActive = true;
			isFirstPatch = true;
			wasFirstPatchFail = false;
		}

		private static void EvaluateConfigSync()
		{
			bool flag = true;
			foreach (ShopItem shopItem in Items.shopItems)
			{
				if (!shopItem.item.itemName.StartsWith("- - - ") && shopItem.item.itemName.Equals(GiantExtensionLaddersV2.tinyLadderItem.itemName) && shopItem.item.creditsWorth != GiantExtensionLaddersV2.mySyncedConfigs.tinyLadderPrice.Value)
				{
					flag = false;
				}
				else if (!shopItem.item.itemName.StartsWith("- - - ") && shopItem.item.itemName.Equals(GiantExtensionLaddersV2.bigLadderItem.itemName) && shopItem.item.creditsWorth != GiantExtensionLaddersV2.mySyncedConfigs.bigLadderPrice.Value)
				{
					flag = false;
				}
				else if (!shopItem.item.itemName.StartsWith("- - - ") && shopItem.item.itemName.Equals(GiantExtensionLaddersV2.hugeLadderItem.itemName) && shopItem.item.creditsWorth != GiantExtensionLaddersV2.mySyncedConfigs.hugeLadderPrice.Value)
				{
					flag = false;
				}
				else if (!shopItem.item.itemName.StartsWith("- - - ") && shopItem.item.itemName.Equals(GiantExtensionLaddersV2.ultimateLadderItem.itemName) && shopItem.item.creditsWorth != GiantExtensionLaddersV2.mySyncedConfigs.ultimateLadderPrice.Value)
				{
					flag = false;
				}
			}
			if (flag)
			{
				GiantExtensionLaddersV2.mls.LogInfo((object)"Config sync success! All settings should now be synced with the host's settings.");
				GiantExtensionLaddersV2.mls.LogInfo((object)"Updating sales...");
				Object.FindObjectOfType<Terminal>().SetItemSales();
				GiantExtensionLaddersV2.mls.LogInfo((object)"done!");
			}
			else if (isFirstPatch)
			{
				wasFirstPatchFail = true;
			}
			else
			{
				GiantExtensionLaddersV2.mls.LogError((object)"Config sync failed! \n Some of your settings are not synchronized with the host settings! This can lead to players having differently priced ladders.");
			}
		}

		private static void SyncLadderPrices()
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)val == (Object)null)
			{
				GiantExtensionLaddersV2.mls.LogWarning((object)"Terminal was not found in scene!");
				return;
			}
			amountOfRemovedItems = 0;
			UpdatePriceOrRemove(GiantExtensionLaddersV2.tinyLadderItem, SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isTinyLadderEnabled), SyncedEntry<int>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.tinyLadderPrice));
			UpdatePriceOrRemove(GiantExtensionLaddersV2.bigLadderItem, SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isBigLadderEnabled), SyncedEntry<int>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.bigLadderPrice));
			UpdatePriceOrRemove(GiantExtensionLaddersV2.hugeLadderItem, SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isHugeLadderEnabled), SyncedEntry<int>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.hugeLadderPrice));
			UpdatePriceOrRemove(GiantExtensionLaddersV2.ultimateLadderItem, SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isUltimateLadderEnabled), SyncedEntry<int>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.ultimateLadderPrice));
			UpdatePriceOrRemove(GiantExtensionLaddersV2.ladderCollectorItem, SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isLadderCollectorEnabled), SyncedEntry<int>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.ladderCollectorPrice));
		}

		private static void UpdatePriceOrRemove(Item item, bool isItemEnabled, int updatedPrice)
		{
			if ((Object)(object)item != (Object)null)
			{
				if (isItemEnabled)
				{
					if (item.itemName.StartsWith("- - - "))
					{
						try
						{
							item.itemName = DictionaryExtensions.Get<Item, string>((IDictionary<Item, string>)GiantExtensionLaddersV2.originalItemNames, item, (string)null);
						}
						catch (Exception)
						{
							GiantExtensionLaddersV2.mls.LogError((object)"There was an error with resetting a removed item name. If you are not the host, please restart your game.");
						}
					}
					Items.UpdateShopItemPrice(item, updatedPrice);
				}
				else
				{
					amountOfRemovedItems++;
					RemoveItem(item, Items.terminal, amountOfRemovedItems);
				}
			}
			else
			{
				GiantExtensionLaddersV2.mls.LogDebug((object)"item was null");
			}
		}

		private static void RemoveItem(Item targetItem, Terminal terminal, int amountOfRemovedItems)
		{
			if (SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isSalesFixEasyActive) && !SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isDontFix))
			{
				Item val = FindBuyableItem(targetItem, terminal);
				if ((Object)(object)val != (Object)null)
				{
					if (!removedItemsSafeFix.Contains(val))
					{
						removedItemsSafeFix.Add(val);
						val.itemName = $"- - - (removed item: {removedItemsSafeFix.Count})";
						val.creditsWorth = 99999;
						val.highestSalePercentage = 0;
					}
				}
				else
				{
					GiantExtensionLaddersV2.mls.LogWarning((object)"Item to be removed could not be found. Will remove the item the old way, this can lead to sales being displayed falsely!");
					Items.RemoveShopItem(targetItem);
				}
			}
			else if (SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isSalesFixTerminalActive) && !SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isSalesFixEasyActive) && !SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isDontFix))
			{
				int num = 0;
				for (int i = 0; i < terminal.buyableItemsList.Length; i++)
				{
					if (terminal.buyableItemsList[i].itemName == targetItem.itemName)
					{
						num = i;
						break;
					}
				}
				Item val2 = terminal.buyableItemsList[num];
				Item val3 = terminal.buyableItemsList[terminal.buyableItemsList.Length - amountOfRemovedItems];
				UpdateBuyItemIndex(val2, terminal.buyableItemsList.Length - amountOfRemovedItems);
				UpdateBuyItemIndex(val3, num);
				terminal.buyableItemsList[num] = val3;
				terminal.buyableItemsList[terminal.buyableItemsList.Length - amountOfRemovedItems] = val2;
				if (!removedItemsTerminalFix.Contains(targetItem))
				{
					removedItemsTerminalFix.Add(targetItem);
					Items.RemoveShopItem(targetItem);
				}
			}
			else
			{
				Items.RemoveShopItem(targetItem);
			}
		}

		private static Item? FindBuyableItem(Item item, Terminal terminal)
		{
			Item[] buyableItemsList = terminal.buyableItemsList;
			foreach (Item val in buyableItemsList)
			{
				if (val.itemName.Equals(item.itemName))
				{
					return val;
				}
			}
			return null;
		}

		private static void UpdateBuyItemIndex(Item item, int newIndex)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			Item item2 = item;
			TerminalKeyword val = Items.terminal.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == "buy");
			TerminalNode result = val.compatibleNouns[0].result.terminalOptions[1].result;
			List<CompatibleNoun> source = val.compatibleNouns.ToList();
			if (!Items.buyableItemAssetInfos.Any((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)item2))
			{
				bool flag = false;
				return;
			}
			BuyableItemAssetInfo asset = Items.buyableItemAssetInfos.First((BuyableItemAssetInfo x) => (Object)(object)x.itemAsset == (Object)(object)item2);
			if (!source.Any((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword))
			{
				bool flag2 = false;
				return;
			}
			TerminalNode result2 = source.First((CompatibleNoun noun) => (Object)(object)noun.noun == (Object)(object)asset.keyword).result;
			bool flag3 = false;
			result2.buyItemIndex = newIndex;
			if (result2.terminalOptions.Length == 0)
			{
				bool flag4 = false;
				return;
			}
			CompatibleNoun[] terminalOptions = result2.terminalOptions;
			CompatibleNoun[] array = terminalOptions;
			foreach (CompatibleNoun val2 in array)
			{
				if ((Object)(object)val2.result != (Object)null && val2.result.buyItemIndex != -1)
				{
					val2.result.buyItemIndex = newIndex;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ExtensionLadderItem))]
	internal class NormalLadderFallPatch
	{
		private static bool isLadderOnAnotherLadder;

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void LadderFallPatch(ExtensionLadderItem __instance)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (!((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null) || ((GrabbableObject)__instance).isHeld || ((GrabbableObject)__instance).isHeldByEnemy || !((GrabbableObject)__instance).reachedFloorTarget || !__instance.ladderActivated || !Physics.Raycast(((Component)__instance).transform.position, Vector3.down, ref val, 80f, 268437760, (QueryTriggerInteraction)1))
			{
				return;
			}
			if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<LadderItemScript>() != (Object)null)
			{
				isLadderOnAnotherLadder = true;
				return;
			}
			if (isLadderOnAnotherLadder)
			{
				((GrabbableObject)__instance).FallToGround(false);
			}
			isLadderOnAnotherLadder = false;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("ShipLeave")]
		[HarmonyPrefix]
		public static void CollectLadders(StartOfRound __instance)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			if (!SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isAutoCollectLaddersEnabled))
			{
				return;
			}
			LadderItemScript[] array = Object.FindObjectsOfType<LadderItemScript>();
			List<GrabbableObject> list = new List<GrabbableObject>(array.Length);
			list.AddRange((IEnumerable<GrabbableObject>)(object)array);
			List<GrabbableObject> list2 = list;
			List<GrabbableObject> list3 = list2;
			ExtensionLadderItem[] array2 = Object.FindObjectsOfType<ExtensionLadderItem>();
			int num = 0;
			GrabbableObject[] array3 = (GrabbableObject[])(object)new GrabbableObject[array2.Length];
			ExtensionLadderItem[] array4 = array2;
			foreach (ExtensionLadderItem val in array4)
			{
				array3[num] = (GrabbableObject)(object)val;
				num++;
			}
			list3.AddRange(new <>z__ReadOnlyArray<GrabbableObject>(array3));
			for (int j = 0; j < list2.Count; j++)
			{
				LadderItemScript ladderItemScript = list2[j] as LadderItemScript;
				GrabbableObject obj = list2[j];
				ExtensionLadderItem val2 = (ExtensionLadderItem)(object)((obj is ExtensionLadderItem) ? obj : null);
				if (!((Object)(object)ladderItemScript == (Object)null) || !((Object)(object)val2 == (Object)null))
				{
					TeleportLadderItem(ladderItemScript, val2, __instance.middleOfShipNode.position);
				}
			}
		}

		private static void TeleportLadderItem(LadderItemScript? ladder, ExtensionLadderItem? normalLadder, Vector3 position)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject val = (GrabbableObject)(((object)ladder) ?? ((object)normalLadder));
			if (!((Object)(object)val == (Object)null))
			{
				bool flag = ((GrabbableObject)(ladder?)).isPocketed ?? ((GrabbableObject)(normalLadder?)).isPocketed ?? false;
				bool flag2 = ((GrabbableObject)(ladder?)).isHeld ?? ((GrabbableObject)(normalLadder?)).isHeld ?? false;
				bool flag3 = ((GrabbableObject)(ladder?)).isHeldByEnemy ?? ((GrabbableObject)(normalLadder?)).isHeldByEnemy ?? false;
				bool flag4 = ((GrabbableObject)(ladder?)).isBeingUsed ?? ((GrabbableObject)(normalLadder?)).isBeingUsed ?? false;
				if (!flag && !flag2 && !flag3 && (!flag4 || SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isCollectExtendedLaddersEnabled)))
				{
					((Component)val).transform.position = position;
					val.FallToGround(false);
					StartOfRound.Instance.localPlayerController.SetItemInElevator(true, false, val);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class TinyLadderClimbingSpeedPatch
	{
		private static float defaultClimbSpeed;

		private static bool isDefaultClimbSpeedSet;

		private const float CLIMB_SPEED_MULTIPLIER = 0.25f;

		[HarmonyPatch("Update")]
		[HarmonyPriority(200)]
		[HarmonyPostfix]
		private static void CrankThatClimbingSpeed(PlayerControllerB __instance)
		{
			if (!isDefaultClimbSpeedSet)
			{
				defaultClimbSpeed = __instance.climbSpeed;
				isDefaultClimbSpeedSet = true;
			}
			if (GiantExtensionLaddersV2.isPlayerOnTinyLadder)
			{
				if (__instance.isPlayerControlled && __instance.isClimbingLadder)
				{
					__instance.climbSpeed = defaultClimbSpeed * 0.25f;
				}
			}
			else
			{
				__instance.climbSpeed = defaultClimbSpeed;
			}
		}
	}
	[HarmonyPatch(typeof(InteractTrigger))]
	internal class UseLadderInShipPatch
	{
		internal static bool changedPlayerLocation;

		internal static PlayerControllerB playerWithChangedLocation;

		private const float minPlayerSizeForTinyLadder = 0.25f;

		[HarmonyPatch("Interact")]
		[HarmonyPrefix]
		public static void PlayerIsInShipPatch(InteractTrigger __instance, ref Transform playerTransform)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			LadderItemScript componentInParent = ((Component)__instance).GetComponentInParent<LadderItemScript>();
			PlayerControllerB component = ((Component)playerTransform).GetComponent<PlayerControllerB>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)component != (Object)null && !component.isInHangarShipRoom)
			{
				if (componentInParent.giantLadderType == GiantLadderType.TINY && component.thisPlayerBody.localScale.y > 0.25f)
				{
					changedPlayerLocation = true;
					component.isInHangarShipRoom = true;
					playerWithChangedLocation = component;
				}
			}
			else if ((Object)(object)componentInParent != (Object)null && (Object)(object)component != (Object)null && component.isInHangarShipRoom && componentInParent.giantLadderType == GiantLadderType.TINY && component.thisPlayerBody.localScale.y <= 0.25f)
			{
				changedPlayerLocation = true;
				component.isInHangarShipRoom = false;
				playerWithChangedLocation = component;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPriority(700)]
		[HarmonyPrefix]
		public static void ResetPlayerIsInShipPatch()
		{
			if ((Object)(object)playerWithChangedLocation != (Object)null && changedPlayerLocation)
			{
				playerWithChangedLocation.isInHangarShipRoom = !playerWithChangedLocation.isInHangarShipRoom;
				changedPlayerLocation = false;
				playerWithChangedLocation = null;
			}
		}
	}
}
namespace GiantExtensionLaddersV2.ConfigStuff
{
	[DataContract]
	internal class MySyncedConfigs : SyncedConfig2<MySyncedConfigs>
	{
		private const int MIN_LADDER_PRICE = 1;

		private const int MAX_LADDER_PRICE = 9999;

		private const float MIN_EXT_TIME = 3f;

		private const float MAX_EXT_TIME = 999f;

		private const float MIN_TP_FREQ = 1f;

		private const float MAX_TP_FREQ = 60f;

		private const int tinyLadderBasePrice = 15;

		private const int bigLadderBasePrice = 75;

		private const int hugeLadderBasePrice = 160;

		private const int ultimateLadderBasePrice = 250;

		private const int ladderCollectorBasePrice = 75;

		private const float tinyLadderExtensionTimeBase = 10f;

		private const float bigLadderExtensionTimeBase = 25f;

		private const float hugeLadderExtensionTimeBase = 30f;

		private const float ultimateLadderExtensionTimeBase = 60f;

		private const float teleportFrequencyBase = 0.8f;

		[SyncedEntryField]
		internal SyncedEntry<bool> isTinyLadderEnabled;

		[SyncedEntryField]
		internal SyncedEntry<bool> isBigLadderEnabled;

		[SyncedEntryField]
		internal SyncedEntry<bool> isHugeLadderEnabled;

		[SyncedEntryField]
		internal SyncedEntry<bool> isUltimateLadderEnabled;

		[SyncedEntryField]
		internal SyncedEntry<bool> isLadderCollectorEnabled;

		[SyncedEntryField]
		internal SyncedEntry<float> tinyLadderExtTime;

		[SyncedEntryField]
		internal SyncedEntry<float> bigLadderExtTime;

		[SyncedEntryField]
		internal SyncedEntry<float> hugeLadderExtTime;

		[SyncedEntryField]
		internal SyncedEntry<float> ultimateLadderExtTime;

		[SyncedEntryField]
		internal SyncedEntry<int> tinyLadderPrice;

		[SyncedEntryField]
		internal SyncedEntry<int> bigLadderPrice;

		[SyncedEntryField]
		internal SyncedEntry<int> hugeLadderPrice;

		[SyncedEntryField]
		internal SyncedEntry<int> ultimateLadderPrice;

		[SyncedEntryField]
		internal SyncedEntry<int> ladderCollectorPrice;

		[SyncedEntryField]
		internal SyncedEntry<bool> isTinyLadderAlwaysActive;

		[SyncedEntryField]
		internal SyncedEntry<bool> isBigLadderAlwaysActive;

		[SyncedEntryField]
		internal SyncedEntry<bool> isHugeLadderAlwaysActive;

		[SyncedEntryField]
		internal SyncedEntry<bool> isUltimateLadderAlwaysActive;

		[SyncedEntryField]
		internal SyncedEntry<bool> isAutoCollectLaddersEnabled;

		[SyncedEntryField]
		internal SyncedEntry<bool> isTeleportFromShipRoomEnabled;

		[SyncedEntryField]
		internal SyncedEntry<bool> isCollectExtendedLaddersEnabled;

		[SyncedEntryField]
		internal SyncedEntry<float> teleportFrequency;

		[SyncedEntryField]
		internal SyncedEntry<bool> isSalesFixEasyActive;

		[SyncedEntryField]
		internal SyncedEntry<bool> isSalesFixTerminalActive;

		[SyncedEntryField]
		internal SyncedEntry<bool> isDontFix;

		internal ConfigEntry<string> salesFixHeader;

		private static ManualLogSource mlsConfig = Logger.CreateLogSource("inoyu.GiantExtensionLadders.Config");

		internal MySyncedConfigs(ConfigFile cfg)
			: base("GiantExtensionLaddersV2")
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Expected O, but got Unknown
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Expected O, but got Unknown
			isTinyLadderEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "DeactivateLadders", "isTinyLadderEnabled", true, "Tiny ladder doesn't appear in the shop if this is set to false.");
			isBigLadderEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "DeactivateLadders", "isBigLadderEnabled", true, "Big ladder doesn't appear in the shop if this is set to false.");
			isHugeLadderEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "DeactivateLadders", "isHugeLadderEnabled", true, "Huge ladder doesn't appear in the shop if this is set to false.");
			isUltimateLadderEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "DeactivateLadders", "isUltimateLadderEnabled", true, "Ultimate ladder doesn't appear in the shop if this is set to false.");
			isLadderCollectorEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "DeactivateLadders", "isLadderCollectorEnabled", true, "Ladder Collector doesn't appear in the shop if this is set to false.");
			AcceptableValueRange<int> val = new AcceptableValueRange<int>(1, 9999);
			tinyLadderPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "LadderPrices", "tinyLadderPrice", 15, new ConfigDescription("Sets the price of the tiny ladder.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			bigLadderPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "LadderPrices", "bigLadderPrice", 75, new ConfigDescription("Sets the price of the big ladder.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			hugeLadderPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "LadderPrices", "hugeLadderPrice", 160, new ConfigDescription("Sets the price of the huge ladder.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			ultimateLadderPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "LadderPrices", "ultimateLadderPrice", 250, new ConfigDescription("Sets the price of the ultimate ladder.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			ladderCollectorPrice = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "LadderPrices", "ladderCollectorItemPrice", 75, new ConfigDescription("Sets the price of ladder collector.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			isTinyLadderAlwaysActive = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "LadderAlwaysActive", "isTinyLadderAlwaysActive", false, "Sets the tiny ladder to always being extended.");
			isBigLadderAlwaysActive = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "LadderAlwaysActive", "isBigLadderAlwaysActive", false, "Sets the big ladder to always being extended.");
			isHugeLadderAlwaysActive = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "LadderAlwaysActive", "isHugeLadderAlwaysActive", false, "Sets the huge ladder to always being extended.");
			isUltimateLadderAlwaysActive = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "LadderAlwaysActive", "isUltimateLadderAlwaysActive", false, "Sets the ultimate ladder to always being extended.");
			AcceptableValueRange<float> val2 = new AcceptableValueRange<float>(3f, 999f);
			tinyLadderExtTime = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "LadderExtensionTime", "tinyLadderExtensionTime", 10f, new ConfigDescription("Amount of seconds the tiny ladder stays extended.", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
			bigLadderExtTime = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "LadderExtensionTime", "bigLadderExtensionTime", 25f, new ConfigDescription("Amount of seconds the big ladder stays extended.", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
			hugeLadderExtTime = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "LadderExtensionTime", "hugeLadderExtensionTime", 30f, new ConfigDescription("Amount of seconds the huge ladder stays extended.", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
			ultimateLadderExtTime = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "LadderExtensionTime", "ultimateLadderExtensionTime", 60f, new ConfigDescription("Amount of seconds the ultimate ladder stays extended.", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
			salesFixHeader = cfg.Bind<string>("SalesBugfixMethod", "WhatIsThisConfigSection?", "(„• ᴗ •„) I am a happy placeholder!", "The sales bug is a relatively small bug that shifts sales by one slot occasionally. " + Environment.NewLine + "To fix this I have two solutions: the safe one, which will most likely always work and the experimental one, which looks way nicer in the terminal but could cause some issues.");
			isSalesFixEasyActive = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "SalesBugfixMethod", "safeSalesFix", true, "This will fix sales in a very safe way, but disabled ladders will appear as an item named \"- - - (removed item: {0})\" in the store.");
			isSalesFixTerminalActive = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "SalesBugfixMethod", "experimentalSalesFix", false, "This will fix sales and fully remove disabled ladders from the store without \"- - - (removed item: {0})\" being displayed." + Environment.NewLine + "WARNING: This might cause store related bugs or have influence on the compatibility with other mods!");
			isDontFix = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "SalesBugfixMethod", "dontFixSales", false, "This will not fix the sales, resulting in sales sometimes being displayed on an item which is not on sale (or the opposite of that).");
			isAutoCollectLaddersEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "LadderCollector", "enableAutoCollectLadders", false, "This will try to teleport all remaining ladders on the map to the ship when pulling the lever to leave the planet.");
			isTeleportFromShipRoomEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "LadderCollector", "allowTeleportFromShipRoom", true, "This allows the ladder collector to teleport ladders that are in the ship room (or very close to it).");
			teleportFrequency = SyncedBindingExtensions.BindSyncedEntry<float>(cfg, "LadderCollector", "ladderTeleportFrequency", 0.8f, new ConfigDescription("Time between ladder-teleports (in seconds)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
			isCollectExtendedLaddersEnabled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "LadderCollector", "collectExtendedLadders", true, "This allows the ladder collector to teleport ladders that are extended.");
			ConfigManager.Register<MySyncedConfigs>((SyncedConfig2<MySyncedConfigs>)(object)this);
		}
	}
}
namespace GiantExtensionLaddersV2.Behaviours
{
	internal class LadderCollectorScript : GrabbableObject
	{
		public Transform? baseNode;

		public Transform? ladderSpawnNode;

		public AudioSource? lcAudioSource;

		public AudioClip? spawnAudio;

		public Light? teleportationLight;

		private bool wasPlayerInShipRoom = false;

		private float teleportTimer = 0f;

		private bool isTimerActive = false;

		private float waitBetweenTeleport = 0.8f;

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (isTimerActive && teleportTimer > 0f)
			{
				teleportTimer -= Time.deltaTime;
			}
			else if (isTimerActive)
			{
				isTimerActive = false;
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			waitBetweenTeleport = GiantExtensionLaddersV2.mySyncedConfigs.teleportFrequency.Value;
			if (!StartOfRound.Instance.inShipPhase && !isTimerActive)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					base.playerHeldBy.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
				}
				wasPlayerInShipRoom = false;
				if (StartOfRound.Instance.localPlayerController.isInHangarShipRoom)
				{
					wasPlayerInShipRoom = true;
				}
				CollectLadders();
			}
		}

		private void CollectLadders()
		{
			LadderItemScript[] array = Object.FindObjectsOfType<LadderItemScript>();
			List<GrabbableObject> list = new List<GrabbableObject>(array.Length);
			list.AddRange((IEnumerable<GrabbableObject>)(object)array);
			List<GrabbableObject> list2 = list;
			List<GrabbableObject> list3 = list2;
			ExtensionLadderItem[] array2 = Object.FindObjectsOfType<ExtensionLadderItem>();
			int num = 0;
			GrabbableObject[] array3 = (GrabbableObject[])(object)new GrabbableObject[array2.Length];
			ExtensionLadderItem[] array4 = array2;
			foreach (ExtensionLadderItem val in array4)
			{
				array3[num] = (GrabbableObject)(object)val;
				num++;
			}
			list3.AddRange(new <>z__ReadOnlyArray<GrabbableObject>(array3));
			((MonoBehaviour)this).StartCoroutine(SpawnLaddersAnim(list2));
		}

		private IEnumerator SpawnLaddersAnim(List<GrabbableObject> ladders)
		{
			List<GrabbableObject> laddersToTeleport = new List<GrabbableObject>();
			foreach (GrabbableObject ladder2 in ladders)
			{
				if (ladder2.isInFactory == StartOfRound.Instance.localPlayerController.isInsideFactory && (!ladder2.isInShipRoom || SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isTeleportFromShipRoomEnabled)))
				{
					laddersToTeleport.Add(ladder2);
				}
			}
			teleportTimer = (float)laddersToTeleport.Count * waitBetweenTeleport + 1f;
			isTimerActive = true;
			for (int i = 0; i < laddersToTeleport.Count; i++)
			{
				LadderItemScript ladder = laddersToTeleport[i] as LadderItemScript;
				GrabbableObject obj = laddersToTeleport[i];
				ExtensionLadderItem normalLadder = (ExtensionLadderItem)(object)((obj is ExtensionLadderItem) ? obj : null);
				float baseNodeRotationAmount = 360f / (float)laddersToTeleport.Count;
				((Component)baseNode).transform.rotation = Quaternion.Euler(0f, (float)i * baseNodeRotationAmount, 0f);
				if ((Object)(object)ladder == (Object)null && (Object)(object)normalLadder == (Object)null)
				{
					yield return null;
				}
				else
				{
					yield return TeleportLadderItem(ladder, normalLadder, ladderSpawnNode.position, ((Component)baseNode).transform.rotation);
				}
			}
		}

		private IEnumerator TeleportLadderItem(LadderItemScript? ladder, ExtensionLadderItem? normalLadder, Vector3 position, Quaternion rotation)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject item = (GrabbableObject)(((object)ladder) ?? ((object)normalLadder));
			if ((Object)(object)item == (Object)null)
			{
				yield return null;
				yield break;
			}
			bool isPocketed = ((GrabbableObject)(ladder?)).isPocketed ?? ((GrabbableObject)(normalLadder?)).isPocketed ?? false;
			bool isHeld = ((GrabbableObject)(ladder?)).isHeld ?? ((GrabbableObject)(normalLadder?)).isHeld ?? false;
			bool isHeldByEnemy = ((GrabbableObject)(ladder?)).isHeldByEnemy ?? ((GrabbableObject)(normalLadder?)).isHeldByEnemy ?? false;
			bool isBeingUsed = ((GrabbableObject)(ladder?)).isBeingUsed ?? ((GrabbableObject)(normalLadder?)).isBeingUsed ?? false;
			bool ladderAnimationBegun = ladder?.ladderAnimationBegun ?? normalLadder?.ladderAnimationBegun ?? false;
			if (!isPocketed && !isHeld && !isHeldByEnemy && !isBeingUsed && (!ladderAnimationBegun || SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isCollectExtendedLaddersEnabled)))
			{
				teleportationLight.intensity = 0f;
				((MonoBehaviour)this).StartCoroutine(TeleportLightAnim());
				lcAudioSource.pitch = Random.Range(0.94f, 1.06f);
				lcAudioSource.PlayOneShot(spawnAudio);
				((Component)item).transform.position = position;
				((Component)item).transform.localEulerAngles = Vector3.zero;
				((Component)item).transform.eulerAngles = Vector3.zero;
				((Component)item).transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
				((Component)item).transform.rotation = rotation;
				item.FallToGround(false);
				StartOfRound.Instance.localPlayerController.SetItemInElevator(wasPlayerInShipRoom, false, item);
				yield return (object)new WaitForSeconds(waitBetweenTeleport);
			}
		}

		private IEnumerator TeleportLightAnim()
		{
			float numberOfSteps = 100f * waitBetweenTeleport / 2f;
			float maxIntensity = 800f;
			float intensityPerStep = maxIntensity / numberOfSteps;
			for (int j = 0; (float)j < numberOfSteps; j++)
			{
				Light? obj = teleportationLight;
				obj.intensity += intensityPerStep;
				yield return (object)new WaitForSeconds(0.01f);
			}
			for (int i = 0; (float)i < numberOfSteps; i++)
			{
				Light? obj2 = teleportationLight;
				obj2.intensity -= intensityPerStep;
				yield return (object)new WaitForSeconds(0.01f);
			}
			teleportationLight.intensity = 0f;
		}

		public override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		public override string __getTypeName()
		{
			return "LadderCollector";
		}
	}
	internal class LadderItemScript : GrabbableObject
	{
		private bool ladderActivated;

		internal bool ladderAnimationBegun;

		private Coroutine ladderAnimationCoroutine;

		private RaycastHit hit;

		private int layerMask = 268437761;

		private float rotateAmount;

		private float extendAmount;

		private float ladderTimer;

		private bool ladderBlinkWarning;

		private bool ladderShrunkAutomatically;

		private AudioClip ladderFallSFX;

		public Animator ladderAnimator;

		public Animator ladderRotateAnimator;

		public Transform baseNode;

		public Transform topNode;

		public Transform moveableNode;

		public AudioClip hitRoof;

		public AudioClip fullExtend;

		public AudioClip hitWall;

		public AudioClip ladderExtendSFX;

		public AudioClip ladderShrinkSFX;

		public AudioClip blinkWarningSFX;

		public AudioClip lidOpenSFX;

		public AudioSource ladderAudio;

		public InteractTrigger ladderScript;

		public Collider interactCollider;

		public Collider bridgeCollider;

		public Collider killTrigger;

		public GiantLadderType giantLadderType;

		public float ladderAlarmTime;

		public float ladderExtensionTime;

		public float maxExtension;

		public float minInteractableRotation;

		public float ladderRotateSpeedMultiplier;

		public bool isClimbable = true;

		public bool isClimbableInShip = false;

		public bool isAlwaysExtended = false;

		public Transform topCollisionNode;

		private const float RAYCAST_DISTANCE_CORRECTION = 4f;

		private bool isOnAnotherLadder = false;

		private bool hasFallenOnALadder = false;

		private bool isLeaningAgainstALadder = false;

		private bool hasHitRoof = false;

		private Vector3 linecastStart = Vector3.zero;

		private Vector3 linecastEnd = Vector3.zero;

		private const int checkpointsPerTenMeters = 10;

		private const int minAmountOfChecksPerCheckpoints = 50;

		private const float amountOfChecksMulitplier = 1.2f;

		private const float minDegrees = 9f;

		private const int startingCheckPointNumber = 2;

		public override void Update()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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)
			((GrabbableObject)this).Update();
			calculateExtensionTimes();
			if (!isClimbableInShip)
			{
				if (base.isInShipRoom)
				{
					isClimbable = false;
				}
				else
				{
					isClimbable = true;
				}
			}
			if ((Object)(object)base.playerHeldBy == (Object)null && !base.isHeld && !base.isHeldByEnemy && base.reachedFloorTarget && ladderActivated)
			{
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val, 80f, 268437760, (QueryTriggerInteraction)1))
				{
					if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<LadderItemScript>() != (Object)null)
					{
						isOnAnotherLadder = true;
					}
					else
					{
						if (isOnAnotherLadder)
						{
							((GrabbableObject)this).FallToGround(false);
						}
						isOnAnotherLadder = false;
					}
				}
				if (!ladderAnimationBegun)
				{
					ladderTimer = 0f;
					StartLadderAnimation(isSkipExtension: false, -1f);
				}
				else
				{
					if (!ladderAnimationBegun)
					{
						return;
					}
					RaycastHit val2 = default(RaycastHit);
					if (hasFallenOnALadder && !Physics.Linecast(linecastStart, linecastEnd, ref val2, layerMask, (QueryTriggerInteraction)1))
					{
						StartLadderAnimation(isSkipExtension: true, rotateAmount);
						hasFallenOnALadder = false;
					}
					if (!isAlwaysExtended)
					{
						ladderTimer += Time.deltaTime;
						if (!ladderBlinkWarning && ladderTimer > ladderAlarmTime)
						{
							ladderBlinkWarning = true;
							ladderAnimator.SetBool("blinkWarning", true);
							ladderAudio.clip = blinkWarningSFX;
							ladderAudio.Play();
						}
						else if (ladderTimer >= ladderExtensionTime)
						{
							ladderActivated = false;
							ladderBlinkWarning = false;
							ladderAudio.Stop();
							ladderAnimator.SetBool("blinkWarning", false);
						}
					}
				}
				return;
			}
			if (ladderAnimationBegun)
			{
				ladderAnimationBegun = false;
				ladderAudio.Stop();
				killTrigger.enabled = false;
				bridgeCollider.enabled = false;
				interactCollider.enabled = false;
				if (ladderAnimationCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(ladderAnimationCoroutine);
				}
				ladderAnimator.SetBool("blinkWarning", false);
				((Component)ladderAudio).transform.position = ((Component)this).transform.position;
				ladderAudio.PlayOneShot(ladderShrinkSFX);
				ladderActivated = false;
			}
			if ((Object)(object)killTrigger != (Object)null)
			{
				killTrigger.enabled = false;
			}
			ladderScript.interactable = false;
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController.currentTriggerInAnimationWith == (Object)(object)ladderScript)
			{
				ladderScript.CancelAnimationExternally();
			}
			if (rotateAmount > 0f)
			{
				rotateAmount = Mathf.Max(rotateAmount - Time.deltaTime * 2f, 0f);
				ladderRotateAnimator.SetFloat("rotationAmount", rotateAmount);
			}
			else
			{
				ladderRotateAnimator.SetFloat("rotationAmount", 0f);
			}
			if (extendAmount > 0f)
			{
				extendAmount = Mathf.Max(extendAmount - Time.deltaTime * 2f, 0f);
				ladderAnimator.SetFloat("extensionAmount", extendAmount);
			}
			else
			{
				ladderAnimator.SetBool("openLid", false);
				ladderAnimator.SetBool("extend", false);
				ladderAnimator.SetFloat("extensionAmount", 0f);
			}
		}

		private void calculateExtensionTimes()
		{
			switch (giantLadderType)
			{
			case GiantLadderType.TINY:
				isAlwaysExtended = SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isTinyLadderAlwaysActive);
				ladderAlarmTime = SyncedEntry<float>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.tinyLadderExtTime) - 4f;
				ladderExtensionTime = SyncedEntry<float>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.tinyLadderExtTime);
				break;
			case GiantLadderType.BIG:
				isAlwaysExtended = SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isBigLadderAlwaysActive);
				ladderAlarmTime = SyncedEntry<float>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.bigLadderExtTime) - 5f;
				ladderExtensionTime = SyncedEntry<float>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.bigLadderExtTime);
				break;
			case GiantLadderType.HUGE:
				isAlwaysExtended = SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isHugeLadderAlwaysActive);
				ladderAlarmTime = SyncedEntry<float>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.hugeLadderExtTime) - 5f;
				ladderExtensionTime = SyncedEntry<float>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.hugeLadderExtTime);
				break;
			case GiantLadderType.ULTIMATE:
				isAlwaysExtended = SyncedEntry<bool>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.isUltimateLadderAlwaysActive);
				ladderAlarmTime = SyncedEntry<float>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.ultimateLadderExtTime) - 5f;
				ladderExtensionTime = SyncedEntry<float>.op_Implicit(GiantExtensionLaddersV2.mySyncedConfigs.ultimateLadderExtTime);
				break;
			default:
				isAlwaysExtended = false;
				ladderExtensionTime = 25f;
				ladderAlarmTime = 20f;
				break;
			}
		}

		private void StartLadderAnimation(bool isSkipExtension, float externalRotNormalTime)
		{
			ladderAnimationBegun = true;
			ladderScript.interactable = false;
			if (ladderAnimationCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(ladderAnimationCoroutine);
			}
			ladderAnimationCoroutine = ((MonoBehaviour)this).StartCoroutine(LadderAnimation(isSkipExtension, externalRotNormalTime));
		}

		private IEnumerator LadderAnimation(bool isSkipExtension, float externalRotNormalTime)
		{
			float ladderMaxExtension = GetLadderExtensionDistance();
			float ladderExtendAmountNormalized = ladderMaxExtension / maxExtension;
			float currentNormalizedTime = 0f;
			float extensionSpeedMultiplier3 = 0.1f;
			ladderAudio.volume = 1f;
			ladderScript.interactable = false;
			interactCollider.enabled = false;
			bridgeCollider.enabled = false;
			killTrigger.enabled = false;
			if (!isSkipExtension)
			{
				ladderAnimator.SetBool("openLid", false);
				ladderAnimator.SetBool("extend", false);
				yield return null;
				ladderAnimator.SetBool("openLid", true);
				((Component)ladderAudio).transform.position = ((Component)this).transform.position;
				ladderAudio.PlayOneShot(lidOpenSFX, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)ladderAudio).transform.position, 18f, 0.8f, 0, base.isInShipRoom, 0);
				yield return (object)new WaitForSeconds(1f);
				ladderAnimator.SetBool("extend", true);
				ladderAudio.clip = ladderExtendSFX;
				ladderAudio.Play();
				ladderMaxExtension += ((Component)baseNode).transform.position.y + 4f;
				while (currentNormalizedTime < 2f && topCollisionNode.position.y < ladderMaxExtension)
				{
					extensionSpeedMultiplier3 += Time.deltaTime * 2f;
					currentNormalizedTime = Mathf.Min(currentNormalizedTime + Time.deltaTime * extensionSpeedMultiplier3, 2f);
					ladderAnimator.SetFloat("extensionAmount", currentNormalizedTime);
					yield return null;
				}
				if (topCollisionNode.position.y >= ladderMaxExtension)
				{
					hasHitRoof = true;
				}
				else
				{
					hasHitRoof = false;
				}
				extendAmount = currentNormalizedTime;
				interactCollider.enabled = true;
				bridgeCollider.enabled = false;
				killTrigger.enabled = false;
				ladderAudio.Stop();
				if (ladderExtendAmountNormalized == 1f)
				{
					((Component)ladderAudio).transform.position = ((Component)baseNode).transform.position + ((Component)baseNode).transform.up * maxExtension;
					ladderAudio.PlayOneShot(fullExtend, 0.7f);
					WalkieTalkie.TransmitOneShotAudio(ladderAudio, fullExtend, 0.7f);
					RoundManager.Instance.PlayAudibleNoise(((Component)ladderAudio).transform.position, 8f, 0.5f, 0, base.isInShipRoom, 0);
				}
				else
				{
					((Component)ladderAudio).transform.position = ((Component)baseNode).transform.position + ((Component)baseNode).transform.up * (ladderExtendAmountNormalized * maxExtension);
					ladderAudio.PlayOneShot(hitRoof);
					WalkieTalkie.TransmitOneShotAudio(ladderAudio, hitRoof, 1f);
					RoundManager.Instance.PlayAudibleNoise(((Component)ladderAudio).transform.position, 17f, 0.8f, 0, base.isInShipRoom, 0);
				}
				yield return (object)new WaitForSeconds(0.4f);
			}
			ladderAudio.clip = ladderFallSFX;
			ladderAudio.Play();
			ladderAudio.volume = 0f;
			extensionSpeedMultiplier3 = ladderRotateSpeedMultiplier;
			currentNormalizedTime = 0f;
			float ladderRotateAmountNormalized = Mathf.Clamp(GetLadderRotationDegrees(90f) / -90f, 0f, 0.99f);
			if (externalRotNormalTime > 0.01f)
			{
				ladderRotateAmountNormalized = 0.99f;
			}
			if (externalRotNormalTime > 0f)
			{
				currentNormalizedTime = externalRotNormalTime;
			}
			while (currentNormalizedTime < ladderRotateAmountNormalized)
			{
				extensionSpeedMultiplier3 += Time.deltaTime * 2f;
				currentNormalizedTime = Mathf.Min(currentNormalizedTime + Time.deltaTime * extensionSpeedMultiplier3, ladderRotateAmountNormalized);
				if (currentNormalizedTime > 0.3f && ladderExtendAmountNormalized > 0.6f)
				{
					killTrigger.enabled = true;
				}
				ladderAudio.volume = Mathf.Min(ladderAudio.volume + Time.deltaTime * 1.75f, 1f);
				ladderRotateAnimator.SetFloat("rotationAmount", currentNormalizedTime);
				yield return null;
			}
			rotateAmount = ladderRotateAmountNormalized;
			ladderAudio.volume = 1f;
			ladderAudio.Stop();
			((Component)ladderAudio).transform.position = ((Component)moveableNode).transform.position;
			ladderAudio.PlayOneShot(hitWall, Mathf.Min(ladderRotateAmountNormalized + 0.3f, 1f));
			RoundManager.Instance.PlayAudibleNoise(((Component)ladderAudio).transform.position, 18f, 0.7f, 0, base.isInShipRoom, 0);
			if (isClimbable && ladderRotateAmountNormalized * 90f < minInteractableRotation)
			{
				ladderScript.interactable = true;
				interactCollider.enabled = true;
			}
			else
			{
				bridgeCollider.enabled = true;
			}
			killTrigger.enabled = false;
			if (hasHitRoof)
			{
				float newColliderScale = (100f - maxExtension) / 100f * 5.16f / 6f;
				((Component)interactCollider).transform.localScale = new Vector3(((Component)interactCollider).transform.localScale.x, newColliderScale, ((Component)interactCollider).transform.localScale.z);
				((Component)bridgeCollider).transform.localScale = new Vector3(((Component)bridgeCollider).transform.localScale.x, newColliderScale, ((Component)bridgeCollider).transform.localScale.z);
				((Component)interactCollider).transform.localPosition = new Vector3(((Component)interactCollider).transform.localPosition.x, 1f, ((Component)interactCollider).transform.localPosition.z);
				((Component)bridgeCollider).transform.localPosition = new Vector3(((Component)bridgeCollider).transform.localPosition.x, 1f, ((Component)bridgeCollider).transform.localPosition.z);
			}
			else
			{
				((Component)interactCollider).transform.localScale = new Vector3(((Component)interactCollider).transform.localScale.x, 5.15892f, ((Component)interactCollider).transform.localScale.z);
				((Component)bridgeCollider).transform.localScale = new Vector3(((Component)bridgeCollider).transform.localScale.x, 5.15892f, ((Component)bridgeCollider).transform.localScale.z);
				((Component)interactCollider).transform.localPosition = new Vector3(((Component)interactCollider).transform.localPosition.x, 3.8f, ((Component)interactCollider).transform.localPosition.z);
				((Component)bridgeCollider).transform.localPosition = new Vector3(((Component)bridgeCollider).transform.localPosition.x, 3.29f, ((Component)bridgeCollider).transform.localPosition.z);
			}
		}

		private float GetLadderExtensionDistance()
		{
			//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 (Physics.Raycast(((Component)baseNode).transform.position, Vector3.up, ref hit, maxExtension, layerMask, (QueryTriggerInteraction)1) && (base.isInShipRoom || base.isInFactory))
			{
				return ((RaycastHit)(ref hit)).distance;
			}
			return maxExtension;
		}

		private float GetLadderRotationDegrees(float startAt)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			int num = (int)Math.Ceiling(maxExtension / 10f * 10f);
			float num2 = maxExtension / (float)num;
			float num3 = 90f;
			RaycastHit val = default(RaycastHit);
			for (int i = 2; i < num; i++)
			{
				int num4 = 50;
				num4 += (int)(1.2f * (float)i);
				float num5 = 90f / (float)num4;
				float num6 = num2 * (float)i;
				((Component)moveableNode).transform.localPosition = new Vector3(0f, num6, 0f);
				baseNode.localEulerAngles = Vector3.zero;
				for (int j = 2; j < num4; j++)
				{
					Vector3 position = ((Component)moveableNode).transform.position;
					baseNode.localEulerAngles = new Vector3((float)(-j) * num5, 0f, 0f);
					Vector3 position2 = ((Component)moveableNode).transform.position;
					if (!Physics.Linecast(position, position2, ref val, layerMask, (QueryTriggerInteraction)1))
					{
						continue;
					}
					float num7 = ((float)j - 1.8f) * num5;
					if (num7 < num3)
					{
						LadderItemScript componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<LadderItemScript>();
						if ((Object)(object)componentInParent != (Object)null && ((Object)componentInParent).GetInstanceID() != ((Object)this).GetInstanceID())
						{
							linecastStart = position;
							linecastEnd = position2;
							hasFallenOnALadder = true;
						}
						else
						{
							hasFallenOnALadder = false;
						}
						num3 = num7;
					}
					break;
				}
				if (num3 < 9f)
				{
					break;
				}
			}
			return 0f - num3;
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
		}

		public override void EquipItem()
		{
			if (ladderAnimationCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(ladderAnimationCoroutine);
			}
			((GrabbableObject)this).EquipItem();
		}

		public override void DiscardItemFromEnemy()
		{
			((GrabbableObject)this).DiscardItemFromEnemy();
			ladderActivated = true;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0039: 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)
			isOnAnotherLadder = false;
			hasFallenOnALadder = false;
			isLeaningAgainstALadder = false;
			hasHitRoof = false;
			rotateAmount = -1f;
			linecastStart = Vector3.zero;
			linecastEnd = Vector3.zero;
			if (ladderAnimationCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(ladderAnimationCoroutine);
			}
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			ladderActivated = true;
			if (((NetworkBehaviour)this).IsOwner)
			{
				base.playerHeldBy.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
			}
		}

		public override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		public override string __getTypeName()
		{
			return "BigLadderItem";
		}
	}
}
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

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

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

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

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

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

	bool ICollection<T>.IsReadOnly => true;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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