Decompiled source of CustomEndless v1.0.23

OddsAndEnds.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MortarLib;
using Severon.OddsAndEnds;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OddsAndEnds")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OddsAndEnds")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c6ff218e-780c-48ad-be27-6f6a178b97dd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(DEN_Roach), "Start")]
public class RoachPatch
{
	public static List<Perk> perkList = new List<Perk>
	{
		new PerkBuilder("perk_roach_jump_buff", "Jump Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +5% jump height.").WithBuff("roach_jump_height", "addJump", 0.05f)
			.Build(),
		new PerkBuilder("perk_roach_reach_buff", "Reach Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +5% reach.").WithBuff("roach_reach", "addReach", 0.05f)
			.Build(),
		new PerkBuilder("perk_roach_gravity_buff", "Gravity Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives -5% gravity.").WithBuff("roach_gravity", "addGravity", -0.05f)
			.Build(),
		new PerkBuilder("perk_roach_climb_speed_buff", "Climb Speed Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +10% climb speed.").WithBuff("roach_climb_speed", "addClimb", 0.1f)
			.Build(),
		new PerkBuilder("perk_roach_recoil_buff", "Recoil Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +0.15 weapon recoil.").WithBuff("roach_weapon_recoil", "weaponRecoil", 0.15f)
			.Build(),
		new PerkBuilder("perk_roach_weapon_speed_buff", "Weapon Speed Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +5% weapon speed.").WithBuff("roach_weapon_speed", "weaponSpeedUp", 0.05f)
			.Build(),
		new PerkBuilder("perk_roach_stamina_buff", "Stamina Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +5% maximum stamina.").WithBuff("roach_stamina", "addStamina", 0.05f)
			.Build(),
		new PerkBuilder("perk_roach_inventory1", "Microscopic Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +3 inventory slots.").WithBuff("roach_inventory1", "addCapacity", 3f)
			.Build(),
		new PerkBuilder("perk_roach_inventory2", "Tiny Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +2 inventory slots.").WithBuff("roach_inventory2", "addCapacity", 2f)
			.Build(),
		new PerkBuilder("perk_roach_inventory3", "Small Roach").WithStacking(canStack: true, 1000).WithDescription("Each stack of this roach gives +1 inventory slot.").WithBuff("roach_inventory3", "addCapacity", 1f)
			.Build()
	};

	private static bool perksRegistered = false;

	public static void RegisterPerks()
	{
		if (perksRegistered)
		{
			return;
		}
		WKAssetDatabase baseAssetDatabase = CL_AssetManager.GetBaseAssetDatabase();
		if ((Object)(object)baseAssetDatabase == (Object)null)
		{
			return;
		}
		foreach (Perk perk in perkList)
		{
			if (!baseAssetDatabase.perkAssets.Contains(perk))
			{
				baseAssetDatabase.perkAssets.Add(perk);
			}
		}
		perksRegistered = true;
	}

	public static void Postfix(DEN_Roach __instance)
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: 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_00a2: 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)
		//IL_00b5: Expected O, but got Unknown
		if (Random.value > 0.25f || !EndlessConfiguration.CustomUIManager.GetToggleState("fun_boost_roaches"))
		{
			return;
		}
		CL_AssetManager.InitializeAssetManager();
		GameObject gameObject = ((Component)__instance).gameObject;
		Item_Object component = gameObject.GetComponent<Item_Object>();
		if (!((Object)(object)component == (Object)null))
		{
			RoachPatch.DuplicateComponent<Item_Object>(component, gameObject);
			Object.DestroyImmediate((Object)(object)component);
			component = gameObject.GetComponent<Item_Object>();
			ProcGen.SetTheFuckingColorOfThisMesh(((Component)__instance).gameObject, Color.blue);
			component.itemData = DuplicateItem(component.itemData);
			ItemExecutionModule_PerkAdder val = new ItemExecutionModule_PerkAdder
			{
				onEnterInventory = true,
				onPickupAndDrop = false,
				excludeInHand = false,
				GetPerks = new List<Perk>()
			};
			if (perkList != null && perkList.Count > 0)
			{
				Perk item = perkList[Random.Range(0, perkList.Count)];
				val.GetPerks.Add(item);
			}
			component.itemData.executionModules = new List<ItemExecutionModule> { (ItemExecutionModule)(object)val };
			component.itemData.prefabName = val.GetPerks[0].id;
			((Object)((Component)component).gameObject).name = component.itemData.prefabName;
			GameObject val2 = Object.Instantiate<GameObject>(((Component)component).gameObject);
			((Object)val2).name = component.itemData.prefabName;
			val2.SetActive(false);
			EndlessConfiguration.RegisterRuntimeObject(val2, cleanup: false);
			WishboneStuff.AddItemToBaseDatabase(val2);
			((ItemExecutionModule)val).Initialize(component.itemData);
		}
	}

	public static T DuplicateComponent<T>(T original, GameObject destination) where T : Component
	{
		T val = destination.AddComponent<T>();
		JsonUtility.FromJsonOverwrite(JsonUtility.ToJson((object)original), (object)val);
		return val;
	}

	public static Item DuplicateItem(Item original)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		Item val = new Item();
		JsonUtility.FromJsonOverwrite(JsonUtility.ToJson((object)original), (object)val);
		return val;
	}
}
public class BoostProcGen
{
	public class ItemDef
	{
		public string Id;

		public float Force;

		public bool IsGrounded;
	}

	public abstract class BoostPathNode
	{
		public BoostProcGen genRef;

		public virtual string Theme => (genRef != null) ? genRef.defaultTheme : "boost";

		public virtual float Weight => 1f;

		public virtual Vector3 Extents => new Vector3(0.5f, 0.5f, 0.5f);

		public abstract List<ItemDef> GenerateItems();

		public abstract Vector3 Spawn(BoostNodeData data, M_Level level);

		public virtual Vector3 GetExitPoint(BoostNodeData data)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return data.Position;
		}

		public static GameObject GetPrefab(string name, M_Level level = null)
		{
			return ProcGen.PathNode.GetPrefab(name, level);
		}

		protected GameObject SpawnVoxelPlatform(Vector3 position, Quaternion rotation, Vector3Int size, GameObject cubePrefab, Transform parent, float scale = 1f)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0037: 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_00d2: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			string text = ((genRef != null) ? genRef.voxelPlatformName : "VoxelPlatform");
			GameObject val = new GameObject(text);
			val.transform.SetParent(parent);
			val.transform.position = position;
			val.transform.rotation = rotation;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((float)((Vector3Int)(ref size)).x * scale - 1f) * 0.5f, ((float)((Vector3Int)(ref size)).y * scale - 1f) * 0.5f, ((float)((Vector3Int)(ref size)).z * scale - 1f) * 0.5f);
			for (int i = 0; i < ((Vector3Int)(ref size)).x; i++)
			{
				for (int j = 0; j < ((Vector3Int)(ref size)).y; j++)
				{
					for (int k = 0; k < ((Vector3Int)(ref size)).z; k++)
					{
						GameObject val3 = Object.Instantiate<GameObject>(cubePrefab, val.transform);
						val3.transform.localPosition = new Vector3((float)i * scale, (float)j * scale, (float)k * scale) - val2;
						val3.transform.localRotation = Quaternion.identity;
					}
				}
			}
			return val;
		}
	}

	public class Platform3x3 : BoostPathNode
	{
		public override float Weight => 2f;

		public override Vector3 Extents => new Vector3(1.5f, 0.5f, 1.5f);

		public override List<ItemDef> GenerateItems()
		{
			List<ItemDef> list = new List<ItemDef>();
			int num = Random.Range(0, 5);
			for (int i = 0; i < num; i++)
			{
				if (genRef != null && genRef.itemDatabase.TryGetValue("Rebar", out var value))
				{
					list.Add(new ItemDef
					{
						Id = value.Id,
						Force = value.Force,
						IsGrounded = value.IsGrounded
					});
				}
			}
			return list;
		}

		public override Vector3 Spawn(BoostNodeData data, M_Level level)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0033: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = BoostPathNode.GetPrefab((genRef != null) ? genRef.cubePrefabName : "Cube", level);
			if ((Object)(object)prefab == (Object)null)
			{
				return data.Position;
			}
			GameObject val = SpawnVoxelPlatform(data.Position, data.Rotation, new Vector3Int(3, 1, 3), prefab, ((Component)level).transform);
			((Object)val).name = data.ParentName;
			float num = ((genRef != null) ? genRef.itemLocalOffsetMin : (-1f));
			Vector3 val3 = default(Vector3);
			foreach (ItemDef providedItem in data.ProvidedItems)
			{
				Item_Object cachedObject = EndlessConfiguration.GetCachedObject<Item_Object>(providedItem.Id);
				GameObject val2 = (((Object)(object)cachedObject != (Object)null) ? ((Component)cachedObject).gameObject : null);
				((Vector3)(ref val3))..ctor(Random.Range(num, 1f), 1f, Random.Range(num, 1f));
				Vector3 val4 = data.Position + data.Rotation * val3;
				if ((Object)(object)val2 != (Object)null)
				{
					GameObject val5 = Object.Instantiate<GameObject>(val2, val4, data.Rotation, val.transform);
					Rigidbody component = val5.GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null)
					{
						component.useGravity = false;
					}
				}
				else
				{
					WishboneStuff.SpawnWishbone(val4);
				}
			}
			return data.Position;
		}
	}

	public class Platform1x1 : BoostPathNode
	{
		public override float Weight => 1f;

		public override Vector3 Extents => new Vector3(0.5f, 0.5f, 0.5f);

		public override List<ItemDef> GenerateItems()
		{
			List<ItemDef> list = new List<ItemDef>();
			if (genRef != null && genRef.itemDatabase.TryGetValue("Wishbone", out var value))
			{
				list.Add(new ItemDef
				{
					Id = value.Id,
					Force = value.Force,
					IsGrounded = value.IsGrounded
				});
			}
			return list;
		}

		public override Vector3 Spawn(BoostNodeData data, M_Level level)
		{
			//IL_0027: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = BoostPathNode.GetPrefab("Cube", level);
			if ((Object)(object)prefab == (Object)null)
			{
				return data.Position;
			}
			GameObject val = SpawnVoxelPlatform(data.Position, data.Rotation, new Vector3Int(1, 1, 1), prefab, ((Component)level).transform);
			((Object)val).name = data.ParentName;
			float num = ((genRef != null) ? genRef.eggSpawnVerticalOffset : 1f);
			foreach (ItemDef providedItem in data.ProvidedItems)
			{
				Item_Object cachedObject = EndlessConfiguration.GetCachedObject<Item_Object>(providedItem.Id);
				GameObject val2 = (((Object)(object)cachedObject != (Object)null) ? ((Component)cachedObject).gameObject : null);
				Vector3 val3 = data.Position + data.Rotation * new Vector3(0f, num, 0f);
				if ((Object)(object)val2 != (Object)null)
				{
					GameObject val4 = Object.Instantiate<GameObject>(val2, val3, data.Rotation, val.transform);
					Rigidbody component = val4.GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null)
					{
						component.useGravity = false;
					}
				}
				else
				{
					WishboneStuff.SpawnWishbone(val3);
				}
			}
			return data.Position;
		}
	}

	public class BoostNodeData
	{
		public BoostPathNode NodeType;

		public Vector3 Position;

		public Quaternion Rotation;

		public List<ItemDef> ProvidedItems = new List<ItemDef>();

		public string ParentName = "BoostPlatform";

		public BoostNodeData PathPrev;

		public BoostNodeData PathNext;

		public Vector3 GetExitPoint()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return NodeType.GetExitPoint(this);
		}
	}

	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Func<Type, bool> <>9__33_0;

		public static Func<BoostPathNode, float> <>9__34_0;

		public static Func<ItemDef, float> <>9__36_0;

		public static Func<ItemDef, Guid> <>9__37_0;

		public static UnityAction <>9__39_0;

		internal bool <Init>b__33_0(Type t)
		{
			return typeof(BoostPathNode).IsAssignableFrom(t) && !t.IsAbstract;
		}

		internal float <GetRandomNode>b__34_0(BoostPathNode n)
		{
			return n.Weight;
		}

		internal float <ComputeLaunchSpeed>b__36_0(ItemDef i)
		{
			return i.Force;
		}

		internal Guid <RollExcludedItems>b__37_0(ItemDef x)
		{
			return Guid.NewGuid();
		}

		internal void <CreateWinButton>b__39_0()
		{
			CL_GameManager.gMan.Win();
		}
	}

	public int targetHeight = 400;

	public float baseJumpForce = 14f;

	public float gravity = 9.81f;

	public float playerMass = 1f;

	public float fixedDeltaTime = 0.02f;

	public int hardNodeCap = 400;

	public int maxItemsPerJump = 2;

	public int maxInventorySize = 10;

	public int minExcludedItems = 0;

	public int maxExcludedItems = 2;

	public int maxGroundedItemsPerJump = 2;

	public float startPosVerticalOffset = 1.5f;

	public float startPosForwardOffset = 9f;

	public float eggSpawnVerticalOffset = 1f;

	public float itemLocalOffsetMin = -1f;

	public float itemLocalOffsetMax = 1f;

	public float winButtonVerticalOffset = 2.5f;

	public float winButtonRotationDeg = 45f;

	public string unlitColorShader = "Unlit/Color";

	public string tagHandhold = "Handhold";

	public string cubePrefabName = "Cube";

	public string boostPlatformName = "BoostPlatform";

	public string defaultTheme = "boost";

	public string voxelPlatformName = "VoxelPlatform";

	public string activeTheme = "boost";

	public Dictionary<string, ItemDef> itemDatabase = new Dictionary<string, ItemDef>
	{
		{
			"Rebar",
			new ItemDef
			{
				Id = "Item_Rebar_Bone",
				Force = 12f,
				IsGrounded = false
			}
		},
		{
			"Wishbone",
			new ItemDef
			{
				Id = "Item_Wishbone",
				Force = 80f,
				IsGrounded = false
			}
		}
	};

	private static List<BoostPathNode> availableNodes = new List<BoostPathNode>();

	private static bool initialized = false;

	public void Init()
	{
		if (initialized)
		{
			return;
		}
		initialized = true;
		availableNodes.Clear();
		IEnumerable<Type> enumerable = from t in Assembly.GetExecutingAssembly().GetTypes()
			where typeof(BoostPathNode).IsAssignableFrom(t) && !t.IsAbstract
			select t;
		foreach (Type item in enumerable)
		{
			if (Activator.CreateInstance(item) is BoostPathNode boostPathNode)
			{
				boostPathNode.genRef = this;
				if (boostPathNode.Theme == activeTheme)
				{
					availableNodes.Add(boostPathNode);
				}
			}
		}
	}

	private BoostPathNode GetRandomNode()
	{
		float num = availableNodes.Sum((BoostPathNode n) => n.Weight);
		float num2 = Random.Range(0f, num);
		float num3 = 0f;
		foreach (BoostPathNode availableNode in availableNodes)
		{
			num3 += availableNode.Weight;
			if (num2 <= num3)
			{
				return availableNode;
			}
		}
		return availableNodes.Last();
	}

	public void Generate(M_Level level)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: 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_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: 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_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_039e: Unknown result type (might be due to invalid IL or missing references)
		if (!initialized)
		{
			Init();
		}
		if ((Object)(object)level == (Object)null || availableNodes.Count == 0 || gravity <= 0f || playerMass <= 0f)
		{
			return;
		}
		Vector3 val = ((Component)level).transform.position + Vector3.up * startPosVerticalOffset + Vector3.forward * startPosForwardOffset;
		float num = val.y + (float)targetHeight;
		List<BoostNodeData> list = new List<BoostNodeData>();
		List<ItemDef> list2 = new List<ItemDef>();
		BoostNodeData boostNodeData = new BoostNodeData
		{
			NodeType = GetRandomNode(),
			Position = val,
			Rotation = Quaternion.identity,
			ParentName = boostPlatformName
		};
		boostNodeData.ProvidedItems = boostNodeData.NodeType.GenerateItems();
		list.Add(boostNodeData);
		list2.AddRange(boostNodeData.ProvidedItems);
		float num2 = Random.Range(0f, 360f);
		Vector3 val2 = default(Vector3);
		while (list.Count < hardNodeCap && boostNodeData.Position.y < num)
		{
			List<ItemDef> excluded = RollExcludedItems(list2);
			List<ItemDef> list3 = SelectUsableItems(list2, excluded);
			float num3 = ComputeLaunchSpeed(list3);
			float num4 = num3 * num3 / (2f * gravity);
			float num5 = Random.Range(45f, 70f) * ((float)Math.PI / 180f);
			float num6 = num3 * Mathf.Cos(num5);
			float num7 = num3 * Mathf.Sin(num5);
			float num8 = Random.Range(0.55f, 0.85f) * num4;
			if (num8 < 1f)
			{
				num8 = 1f;
			}
			float num9 = num7 * num7 - 2f * gravity * num8;
			if (num9 < 0f)
			{
				num9 = 0f;
			}
			float num10 = (num7 + Mathf.Sqrt(num9)) / gravity;
			float num11 = num6 * num10;
			if (num11 < 3f)
			{
				num11 = 3f;
			}
			num2 += Random.Range(-30f, 30f);
			float num12 = num2 * ((float)Math.PI / 180f);
			((Vector3)(ref val2))..ctor(Mathf.Cos(num12) * num11, num8, Mathf.Sin(num12) * num11);
			Vector3 position = boostNodeData.GetExitPoint() + val2;
			BoostNodeData boostNodeData2 = new BoostNodeData
			{
				NodeType = GetRandomNode(),
				Position = position,
				Rotation = Quaternion.Euler(0f, num2, 0f),
				ParentName = boostPlatformName
			};
			boostNodeData2.ProvidedItems = boostNodeData2.NodeType.GenerateItems();
			foreach (ItemDef item in list3)
			{
				list2.Remove(item);
			}
			list2.AddRange(boostNodeData2.ProvidedItems);
			int num13 = Mathf.Max(0, maxInventorySize);
			if (list2.Count > num13)
			{
				list2.RemoveRange(0, list2.Count - num13);
			}
			boostNodeData.PathNext = boostNodeData2;
			boostNodeData2.PathPrev = boostNodeData;
			list.Add(boostNodeData2);
			boostNodeData = boostNodeData2;
		}
		foreach (BoostNodeData item2 in list)
		{
			item2.NodeType.Spawn(item2, level);
		}
		CreateWinButton(boostNodeData.Position, level);
	}

	private float ComputeLaunchSpeed(List<ItemDef> items)
	{
		float num = items.Sum((ItemDef i) => i.Force);
		float num2 = num / playerMass * fixedDeltaTime;
		return baseJumpForce + num2;
	}

	private List<ItemDef> RollExcludedItems(List<ItemDef> pool)
	{
		List<ItemDef> list = pool.OrderBy((ItemDef x) => Guid.NewGuid()).ToList();
		int count = Mathf.Min(Random.Range(minExcludedItems, maxExcludedItems), list.Count);
		return list.Take(count).ToList();
	}

	private List<ItemDef> SelectUsableItems(List<ItemDef> pool, List<ItemDef> excluded)
	{
		List<ItemDef> list = new List<ItemDef>();
		int num = 0;
		foreach (ItemDef item in pool)
		{
			if (list.Count >= maxItemsPerJump)
			{
				break;
			}
			if (excluded.Contains(item))
			{
				continue;
			}
			if (item.IsGrounded)
			{
				if (num >= maxGroundedItemsPerJump)
				{
					continue;
				}
				num++;
			}
			list.Add(item);
		}
		return list;
	}

	private void CreateWinButton(Vector3 position, M_Level level)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
		val.transform.SetParent(((Component)level).transform);
		val.transform.position = position + new Vector3(0f, winButtonVerticalOffset, 0f);
		val.transform.rotation = Quaternion.Euler(winButtonRotationDeg, 0f, winButtonRotationDeg);
		Material val2 = new Material(Shader.Find(unlitColorShader));
		val2.color = Color.white;
		((Renderer)val.GetComponent<MeshRenderer>()).material = val2;
		CL_Handhold val3 = val.AddComponent<CL_Handhold>();
		val3.activeEvent = new UnityEvent();
		UnityEvent activeEvent = val3.activeEvent;
		object obj = <>c.<>9__39_0;
		if (obj == null)
		{
			UnityAction val4 = delegate
			{
				CL_GameManager.gMan.Win();
			};
			<>c.<>9__39_0 = val4;
			obj = (object)val4;
		}
		activeEvent.AddListener((UnityAction)obj);
		ObjectTagger val5 = ((Component)val3).GetComponent<ObjectTagger>() ?? ((Component)val3).gameObject.AddComponent<ObjectTagger>();
		val5.AddTag(tagHandhold);
	}
}
public static class PlayerImpulseMonitor
{
	private const float SampleInterval = 5f;

	private const float MinUpwardVelocityThreshold = 1f;

	private static bool wasGrounded;

	private static Vector3 lastVelocity;

	private static Vector3 airborneStartPos;

	private static float airborneStartTime;

	private static float recordedLaunchSpeed;

	private static float elapsed;

	private static bool initialized;

	public static float LastRecordedLaunchSpeed => recordedLaunchSpeed;

	public static float LastActualHorizontalDist { get; private set; }

	public static float LastActualVerticalDist { get; private set; }

	public static float LastFlightTime { get; private set; }

	public static float ImpliedHorizontalVelocity { get; private set; }

	public static float ImpliedVerticalVelocity { get; private set; }

	public static void Reset()
	{
		recordedLaunchSpeed = 0f;
		LastActualHorizontalDist = 0f;
		LastActualVerticalDist = 0f;
		LastFlightTime = 0f;
		ImpliedHorizontalVelocity = 0f;
		ImpliedVerticalVelocity = 0f;
		initialized = false;
	}

	public static void Update(CharacterController controller)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: 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_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)controller == (Object)null)
		{
			return;
		}
		bool isGrounded = controller.isGrounded;
		Vector3 velocity = controller.velocity;
		Vector3 position = ((Component)controller).transform.position;
		if (!initialized)
		{
			wasGrounded = isGrounded;
			lastVelocity = velocity;
			initialized = true;
			return;
		}
		bool flag = wasGrounded && !isGrounded;
		bool flag2 = !wasGrounded && isGrounded;
		bool flag3 = !isGrounded && velocity.y - lastVelocity.y > 1f;
		if (flag)
		{
			airborneStartPos = position;
			airborneStartTime = Time.time;
		}
		if ((flag || flag3) && velocity.y > 0f)
		{
			recordedLaunchSpeed = ((Vector3)(ref velocity)).magnitude;
		}
		if (flag2)
		{
			LastFlightTime = Time.time - airborneStartTime;
			if (LastFlightTime > 0.05f)
			{
				Vector3 val = position;
				LastActualHorizontalDist = Vector2.Distance(new Vector2(airborneStartPos.x, airborneStartPos.z), new Vector2(val.x, val.z));
				LastActualVerticalDist = val.y - airborneStartPos.y;
				ImpliedHorizontalVelocity = LastActualHorizontalDist / LastFlightTime;
				ImpliedVerticalVelocity = (LastActualVerticalDist + 4.905f * LastFlightTime * LastFlightTime) / LastFlightTime;
			}
		}
		wasGrounded = isGrounded;
		lastVelocity = velocity;
		elapsed += Time.deltaTime;
		if (elapsed >= 5f)
		{
			elapsed -= 5f;
		}
	}
}
[HarmonyPatch(typeof(CharacterController), "Move")]
public static class ENT_Player_Update_Patch
{
	public static void Postfix(CharacterController __instance)
	{
		if (!((Object)(object)__instance == (Object)null))
		{
			PlayerImpulseMonitor.Update(__instance);
		}
	}
}
public class CollapsibleContainer : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
{
	[SerializeField]
	private bool startExpanded = true;

	private bool isExpanded;

	private RectTransform rectTransform;

	private void Awake()
	{
		rectTransform = ((Component)this).GetComponent<RectTransform>();
		isExpanded = startExpanded;
		UpdateVisibility();
	}

	public void OnPointerClick(PointerEventData eventData)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		RaycastResult pointerCurrentRaycast = eventData.pointerCurrentRaycast;
		if (!((Object)(object)((RaycastResult)(ref pointerCurrentRaycast)).gameObject != (Object)(object)((Component)this).gameObject))
		{
			Toggle();
		}
	}

	public void Toggle()
	{
		isExpanded = !isExpanded;
		UpdateVisibility();
		RebuildLayouts(rectTransform);
	}

	private void UpdateVisibility()
	{
		int childCount = ((Component)this).transform.childCount;
		if (childCount > 0)
		{
			((Component)((Component)this).transform.GetChild(0)).gameObject.SetActive(true);
		}
		for (int i = 1; i < childCount; i++)
		{
			((Component)((Component)this).transform.GetChild(i)).gameObject.SetActive(isExpanded);
		}
	}

	private void RebuildLayouts(RectTransform rect)
	{
		while ((Object)(object)rect != (Object)null)
		{
			LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
			Canvas.ForceUpdateCanvases();
			Transform parent = ((Transform)rect).parent;
			rect = (RectTransform)(object)((parent is RectTransform) ? parent : null);
		}
	}
}
public class WishboneStuff
{
	private static AssetBundle GetBundle(string bundleName)
	{
		string location = Assembly.GetExecutingAssembly().Location;
		string directoryName = Path.GetDirectoryName(location);
		if (string.IsNullOrEmpty(directoryName))
		{
			return null;
		}
		string text = Path.Combine(directoryName, bundleName);
		if (CustomLevelLoader._cachedBundles.TryGetValue(text, out var value) && (Object)(object)value != (Object)null)
		{
			return value;
		}
		foreach (KeyValuePair<string, AssetBundle> cachedBundle in CustomLevelLoader._cachedBundles)
		{
			if (cachedBundle.Key.EndsWith(bundleName, StringComparison.OrdinalIgnoreCase) && (Object)(object)cachedBundle.Value != (Object)null)
			{
				return cachedBundle.Value;
			}
		}
		AssetBundle frameworkBundle = GetFrameworkBundle(directoryName, bundleName);
		if ((Object)(object)frameworkBundle != (Object)null)
		{
			CustomLevelLoader._cachedBundles[text] = frameworkBundle;
			return frameworkBundle;
		}
		if (File.Exists(text))
		{
			try
			{
				AssetBundle val = AssetBundle.LoadFromFile(text);
				if ((Object)(object)val != (Object)null)
				{
					CustomLevelLoader._cachedBundles[text] = val;
					return val;
				}
			}
			catch
			{
			}
		}
		return null;
	}

	private static AssetBundle GetFrameworkBundle(string modFolder, string bundleName)
	{
		Type type = Type.GetType("Severon.GamemodeFramework.GamemodeFramework, GamemodeFramework", throwOnError: false);
		MethodInfo methodInfo = ((type == null) ? null : type.GetMethod("GetCachedAssetBundle", BindingFlags.Static | BindingFlags.Public, null, new Type[2]
		{
			typeof(string),
			typeof(string)
		}, null));
		try
		{
			return (AssetBundle)((methodInfo == null) ? null : /*isinst with value type is only supported in some contexts*/);
		}
		catch
		{
			return null;
		}
	}

	public static Item_Object SpawnWishbone(Vector3 position)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Expected O, but got Unknown
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Expected O, but got Unknown
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Expected O, but got Unknown
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Expected O, but got Unknown
		Item_Object cachedObject = EndlessConfiguration.GetCachedObject<Item_Object>("Item_Artifact_Remote");
		Item_Object cachedObject2 = EndlessConfiguration.GetCachedObject<Item_Object>("Item_Artifact_Translocator");
		if ((Object)(object)cachedObject == (Object)null || cachedObject.itemData == null || (Object)(object)cachedObject.itemData.handItemAsset == (Object)null)
		{
			return null;
		}
		Item_Object val = Object.Instantiate<Item_Object>(cachedObject, position, Quaternion.identity);
		GameObject prefab = ProcGen.PathNode.GetPrefab("Wishbone");
		if ((Object)(object)prefab != (Object)null)
		{
			MeshFilter componentInChildren = prefab.GetComponentInChildren<MeshFilter>();
			if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.sharedMesh != (Object)null)
			{
				Mesh val2 = Object.Instantiate<Mesh>(componentInChildren.sharedMesh);
				Vector3[] vertices = val2.vertices;
				Vector3 localScale = ((Component)componentInChildren).transform.localScale;
				for (int i = 0; i < vertices.Length; i++)
				{
					vertices[i] = Vector3.Scale(vertices[i], localScale);
				}
				val2.vertices = vertices;
				val2.RecalculateBounds();
				val2.RecalculateNormals();
				MeshFilter[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshFilter>(true);
				foreach (MeshFilter val3 in componentsInChildren)
				{
					val3.sharedMesh = val2;
				}
			}
		}
		if ((Object)(object)cachedObject != (Object)null && cachedObject.itemData != null && (Object)(object)cachedObject.itemData.handItemAsset != (Object)null)
		{
			HandItem handItemAsset = cachedObject.itemData.handItemAsset;
			GameObject val4 = new GameObject(((Object)((Component)handItemAsset).gameObject).name);
			val4.transform.localScale = ((Component)handItemAsset).transform.localScale;
			SpriteRenderer component = ((Component)handItemAsset).GetComponent<SpriteRenderer>();
			SpriteRenderer val5 = val4.AddComponent<SpriteRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				((Renderer)val5).sharedMaterial = ((Renderer)component).sharedMaterial;
				val5.sprite = component.sprite;
				val5.color = component.color;
				((Renderer)val5).sortingLayerID = ((Renderer)component).sortingLayerID;
				((Renderer)val5).sortingOrder = ((Renderer)component).sortingOrder;
			}
			val4.SetActive(false);
			EndlessConfiguration.RegisterRuntimeObject(val4, cleanup: false);
			ViewSway component2 = ((Component)handItemAsset).GetComponent<ViewSway>();
			ViewSway val6 = val4.AddComponent<ViewSway>();
			if ((Object)(object)component2 != (Object)null)
			{
				JsonUtility.FromJsonOverwrite(JsonUtility.ToJson((object)component2), (object)val6);
			}
			if (val6.parameters == null)
			{
				val6.parameters = new ViewSwayParameters();
			}
			HandItem_Wishbone handItem_Wishbone = val4.AddComponent<HandItem_Wishbone>();
			((HandItem)handItem_Wishbone).interactionModules = new List<Item_InteractionModule>();
			((HandItem)handItem_Wishbone).itemCosmetics = new List<Cosmetic_Item>();
			((HandItem)handItem_Wishbone).useStats = new List<string>();
			((HandItem)handItem_Wishbone).simpleUseModules = new List<SimpleModule>();
			((HandItem)handItem_Wishbone).firstGrabEvent = new UnityEvent();
			((HandItem)handItem_Wishbone).itemUseEvent = new UnityEvent();
			Hand_SpriteController[] componentsInChildren2 = val4.GetComponentsInChildren<Hand_SpriteController>(true);
			foreach (Hand_SpriteController val7 in componentsInChildren2)
			{
				val7.spriteName = "none";
				((Behaviour)val7).enabled = false;
			}
			SpriteRenderer[] componentsInChildren3 = val4.GetComponentsInChildren<SpriteRenderer>(true);
			foreach (SpriteRenderer val8 in componentsInChildren3)
			{
				((Renderer)val8).enabled = false;
			}
			SpriteRenderer val9 = null;
			SpriteRenderer val10 = null;
			if ((Object)(object)cachedObject2 != (Object)null && cachedObject2.itemData != null && (Object)(object)cachedObject2.itemData.handItemAsset != (Object)null)
			{
				SpriteRenderer[] componentsInChildren4 = ((Component)cachedObject2.itemData.handItemAsset).GetComponentsInChildren<SpriteRenderer>(true);
				foreach (SpriteRenderer val11 in componentsInChildren4)
				{
					if (!StringUtility.ContainsInsensitive(((Object)val11).name, "Sprite"))
					{
						continue;
					}
					GameObject val12 = Object.Instantiate<GameObject>(((Component)val11).gameObject);
					val12.transform.SetParent(val4.transform, false);
					val12.transform.Rotate(0f, 0f, 45f);
					val9 = val12.GetComponent<SpriteRenderer>();
					SpriteRenderer[] componentsInChildren5 = val12.GetComponentsInChildren<SpriteRenderer>(true);
					foreach (SpriteRenderer val13 in componentsInChildren5)
					{
						if (StringUtility.ContainsInsensitive(((Object)val13).name, "ItemFingers"))
						{
							val10 = val13;
						}
					}
					break;
				}
			}
			SpriteRenderer[] componentsInChildren6 = val4.GetComponentsInChildren<SpriteRenderer>(true);
			foreach (SpriteRenderer val14 in componentsInChildren6)
			{
				if (StringUtility.ContainsInsensitive(((Object)val14).name, "handle") || StringUtility.ContainsInsensitive(((Object)val14).name, "Fingers"))
				{
					((Renderer)val14).enabled = false;
				}
			}
			GameObject val15 = new GameObject("WishboneTarget");
			val15.transform.SetParent(val4.transform);
			SpriteRenderer val16 = val15.GetComponent<SpriteRenderer>();
			if ((Object)(object)val16 == (Object)null)
			{
				val16 = val15.AddComponent<SpriteRenderer>();
			}
			if ((Object)(object)component != (Object)null)
			{
				((Renderer)val16).sharedMaterial = ((Renderer)component).sharedMaterial;
			}
			handItem_Wishbone.targetRenderer = val16;
			if ((Object)(object)val10 != (Object)null)
			{
				((Renderer)handItem_Wishbone.targetRenderer).sortingLayerID = ((Renderer)val10).sortingLayerID;
			}
			((Renderer)handItem_Wishbone.targetRenderer).sortingOrder = 2;
			AssetBundle bundle = GetBundle("anywhere");
			if ((Object)(object)bundle != (Object)null)
			{
				handItem_Wishbone.spriteC1 = bundle.LoadAsset<Sprite>("WishC1");
				handItem_Wishbone.spriteC2 = bundle.LoadAsset<Sprite>("WishC2");
				handItem_Wishbone.spriteC3 = bundle.LoadAsset<Sprite>("WishC3");
			}
			val.itemData.handItemAsset = (HandItem)(object)val4.GetComponent<HandItem_Wishbone>();
		}
		val.itemData.SetItemAsset(val);
		val.itemData.prefabName = "Item_Wishbone";
		((Object)val).name = val.itemData.prefabName;
		((Object)((Component)val).gameObject).name = val.itemData.prefabName;
		((Object)val.itemData.handItemAsset).name = val.itemData.prefabName;
		GameObject val17 = Object.Instantiate<GameObject>(((Component)val).gameObject);
		((Object)val17).name = val.itemData.prefabName;
		val17.SetActive(false);
		EndlessConfiguration.RegisterRuntimeObject(val17, cleanup: false);
		AddItemToBaseDatabase(val17);
		((Component)val).gameObject.SetActive(true);
		return val;
	}

	public static void AddItemToBaseDatabase(GameObject itemPrefab)
	{
		WKAssetDatabase baseAssetDatabase = CL_AssetManager.GetBaseAssetDatabase();
		if ((Object)(object)baseAssetDatabase != (Object)null && (Object)(object)itemPrefab != (Object)null)
		{
			if (baseAssetDatabase.itemPrefabs == null)
			{
				baseAssetDatabase.itemPrefabs = new List<GameObject>();
			}
			bool flag = baseAssetDatabase.itemPrefabs.RemoveAll((GameObject prefab) => (Object)(object)prefab == (Object)null) > 0;
			bool flag2 = baseAssetDatabase.itemPrefabs.Exists((GameObject prefab) => (Object)(object)prefab != (Object)null && string.Equals(((Object)prefab).name, ((Object)itemPrefab).name, StringComparison.OrdinalIgnoreCase));
			if (!flag2)
			{
				baseAssetDatabase.itemPrefabs.Add(itemPrefab);
			}
			if (!flag2 || flag)
			{
				CL_AssetManager.RefreshDatabaseList();
			}
		}
	}
}
[HarmonyPatch(typeof(WKDatabaseHolder), "RefreshDictionary")]
public static class AssetDatabaseNullPrefabPatcher
{
	[HarmonyPrefix]
	public static void Prefix(WKDatabaseHolder __instance)
	{
		if (__instance != null && !((Object)(object)__instance.database == (Object)null))
		{
			if (__instance.database.itemPrefabs == null)
			{
				__instance.database.itemPrefabs = new List<GameObject>();
			}
			if (__instance.database.entityPrefabs == null)
			{
				__instance.database.entityPrefabs = new List<GameObject>();
			}
			__instance.database.itemPrefabs.RemoveAll((GameObject prefab) => (Object)(object)prefab == (Object)null);
			__instance.database.entityPrefabs.RemoveAll((GameObject prefab) => (Object)(object)prefab == (Object)null);
		}
	}
}
public class HandItem_Wishbone : HandItem
{
	private float holdTime;

	private bool isCharging;

	private UT_AudioClipHandler clipHandler;

	public int uses = 1;

	public Sprite spriteC1;

	public Sprite spriteC2;

	public Sprite spriteC3;

	public SpriteRenderer targetRenderer;

	public override void Initialize(Item i, Hand h)
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		if (base.interactionModules == null)
		{
			base.interactionModules = new List<Item_InteractionModule>();
		}
		if (base.itemCosmetics == null)
		{
			base.itemCosmetics = new List<Cosmetic_Item>();
		}
		if (base.useStats == null)
		{
			base.useStats = new List<string>();
		}
		if (base.simpleUseModules == null)
		{
			base.simpleUseModules = new List<SimpleModule>();
		}
		if (base.firstGrabEvent == null)
		{
			base.firstGrabEvent = new UnityEvent();
		}
		if (base.itemUseEvent == null)
		{
			base.itemUseEvent = new UnityEvent();
		}
		((HandItem)this).Initialize(i, h);
		base.anim = ((Component)this).GetComponent<Animator>();
		if ((Object)(object)clipHandler == (Object)null)
		{
			clipHandler = ((Component)this).GetComponent<UT_AudioClipHandler>();
		}
		StartCharging();
	}

	public override void OnEnable()
	{
		((HandItem)this).OnEnable();
		StartCharging();
	}

	public override void OnTryPocket()
	{
		((HandItem)this).OnTryPocket();
		ResetCharge();
	}

	public override void OnDrop()
	{
		((HandItem)this).OnDrop();
		ResetCharge();
	}

	private void StartCharging()
	{
		isCharging = true;
		holdTime = 0f;
		UpdateSprite(0);
	}

	private void ResetCharge()
	{
		isCharging = false;
		holdTime = 0f;
		if ((Object)(object)base.anim != (Object)null)
		{
			base.anim.SetInteger("Uses", 0);
		}
		UpdateSprite(0);
	}

	private void UpdateSprite(int chargeLevel)
	{
		if (!((Object)(object)targetRenderer == (Object)null))
		{
			switch (chargeLevel)
			{
			case 0:
				targetRenderer.sprite = spriteC1;
				break;
			case 1:
				targetRenderer.sprite = spriteC2;
				break;
			case 2:
				targetRenderer.sprite = spriteC3;
				break;
			}
		}
	}

	public override void LateUpdate()
	{
		((HandItem)this).LateUpdate();
		if (isCharging)
		{
			holdTime += Time.deltaTime;
			int num = Mathf.Clamp((int)holdTime, 0, 2);
			if ((Object)(object)base.anim != (Object)null)
			{
				base.anim.SetInteger("Uses", num + 1);
			}
			UpdateSprite(num);
		}
	}

	public override void Use()
	{
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: 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_00dc: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: 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_0253: Unknown result type (might be due to invalid IL or missing references)
		ENT_Player player = ENT_Player.GetPlayer();
		if (base.used || base.item == null || (Object)(object)base.item.inventory == (Object)null || ((Hand_Base)this).hand == null || (Object)(object)player == (Object)null || (Object)(object)player.cam == (Object)null)
		{
			return;
		}
		CL_Handhold cachedObject = EndlessConfiguration.GetCachedObject<CL_Handhold>("Item_Artifact_Remote_Handhold");
		if ((Object)(object)cachedObject == (Object)null)
		{
			Debug.LogWarning((object)"OddsAndEnds could not use the Wishbone: Item_Artifact_Remote_Handhold is unavailable.");
			return;
		}
		((HandItem)this).Use();
		base.used = true;
		int num = Mathf.Clamp((int)holdTime, 0, 2);
		CL_Handhold val = null;
		if ((Object)(object)cachedObject != (Object)null)
		{
			Transform transform = ((Component)ENT_Player.GetPlayer().cam).transform;
			Vector3 val2 = transform.position + transform.forward * 1f;
			Quaternion val3 = Quaternion.LookRotation(transform.forward);
			val = Object.Instantiate<CL_Handhold>(cachedObject, val2, val3);
			HandholdModule_JumpBoost val4 = (HandholdModule_JumpBoost)((val.modules == null) ? null : /*isinst with value type is only supported in some contexts*/);
			if (val4 != null && num == 2)
			{
				val4.boostInLookDir = 1f;
				val4.fovAdjust *= 5f;
				val4.doubleHandBoost = false;
				val4.jumpBoost *= 4f;
			}
			else if (val4 != null)
			{
				val4.boostInLookDir *= 1f;
				val4.fovAdjust *= (float)(num + 1);
				val4.jumpBoost *= (float)(num + 1);
			}
			UT_Timer component = ((Component)val).GetComponent<UT_Timer>();
			if ((Object)(object)component != (Object)null)
			{
				component.endEvent.Invoke();
				((Behaviour)component).enabled = false;
			}
			ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem ps in componentsInChildren)
			{
				ProcGen.SetTheFuckingColorOfThisParticleSystem(ps, Color.red / 5f * (float)(num + 1));
			}
			ProcGen.SetTheFuckingColorOfThisMesh(((Component)val).gameObject, Color.red / 5f * (float)(num + 1));
			val.dropOnInactive = false;
		}
		Hand hand = ((Hand_Base)this).hand;
		isCharging = false;
		((HandItem)this).RemoveItem();
		if ((Object)(object)val != (Object)null)
		{
			hand?.ForceGrabHandhold(((Component)val).transform);
		}
	}
}
public class EndlessSettings : MonoBehaviour
{
	[SerializeField]
	private MenuSettingsManager menuSettingsManager;

	[SerializeField]
	private Button panelButton;

	public string menuTag = "EndlessSettings";

	private readonly Dictionary<string, string> startingItemTitles = new Dictionary<string, string>
	{
		{ "item_timepiece", "Timepiece" },
		{ "item_translocator", "Translocator" },
		{ "item_evaglove", "EVA Glove" },
		{ "item_rapier", "Rapier" },
		{ "item_rebar_return", "Rho Spear" },
		{ "item_remote", "Remote" },
		{ "item_handgun_kit", "Handgun" },
		{ "item_flaregun_kit", "Flaregun" },
		{ "item_flashlight", "Flashlight" },
		{ "item_cryogun", "Cryogun" }
	};

	public static readonly (string Key, string Name, string BuffId)[] buffSettings = new(string, string, string)[83]
	{
		("buff_jump", "Jump Height", "addJump"),
		("buff_stamina", "Stamina", "addStamina"),
		("buff_stamina_regen", "Stamina Regen", "addStaminaRegen"),
		("buff_climb_speed", "Climb Speed", "addClimb"),
		("buff_reach", "Reach", "addReach"),
		("buff_armor", "Damage Resist", "damageResist"),
		("buff_vulnerability", "Damage Multiplier", "damageMult"),
		("buff_knockback_resist", "Knockback Resist", "knockbackResist"),
		("buff_weapon_speed", "Weapon Speed", "weaponSpeedUp"),
		("buff_weapon_slow", "Weapon Slow", "weaponSpeedDown"),
		("buff_weapon_recoil", "Weapon Recoil", "weaponRecoil"),
		("buff_time_slow", "Time Slow", "slowTime"),
		("buff_gravity", "Gravity", "addGravity"),
		("buff_inventory_space", "Inventory Space", "addCapacity"),
		("buff_air_control", "Air Control", "addAirControl"),
		("buff_left_hand_climb_speed", "Left Hand Climb Speed", "addClimb-hand-0"),
		("buff_right_hand_climb_speed", "Right Hand Climb Speed", "addClimb-hand-1"),
		("buff_left_hand_climbing_jump", "Left Hand Climbing Jump", "addClimbingJump-hand-0"),
		("buff_right_hand_climbing_jump", "Right Hand Climbing Jump", "addClimbingJump-hand-1"),
		("buff_temporary_climb_speed", "Temporary Climb Speed", "addClimbSpeed"),
		("buff_drag", "Drag", "addDrag"),
		("buff_extra_jumps", "Extra Jumps", "addExtraJumps"),
		("buff_field_of_view", "Field Of View", "addFOV"),
		("buff_freeze_resistance", "Freeze Resistance", "addFreezeResist"),
		("buff_grip_strength", "Grip Strength", "addGripStrength"),
		("buff_grounded_jump", "Grounded Jump", "addGroundedJump"),
		("buff_grounded_stamina_regen", "Grounded Stamina Regen", "addGroundedRegeneration"),
		("buff_grounded_speed", "Grounded Speed", "addGroundedSpeed"),
		("buff_hammer_damage", "Hammer Damage", "addHammer"),
		("buff_hang_speed", "Hang Speed", "addHangSpeed"),
		("buff_left_hand_hang_speed", "Left Hand Hang Speed", "addHangSpeed-hand-0"),
		("buff_right_hand_hang_speed", "Right Hand Hang Speed", "addHangSpeed-hand-1"),
		("buff_jump_boost", "Jump Boost", "addJumpBoost"),
		("buff_limp", "Limp", "addLimp"),
		("buff_piton_secure", "Piton Secure", "addPitonSecure"),
		("buff_player_scale", "Player Scale", "addPlayerScale"),
		("buff_player_width", "Player Width", "addPlayerWidth"),
		("buff_pocket_big_item_capacity", "Pocket Big Item Capacity", "addPocketBigItemCapacity"),
		("buff_pocket_capacity", "Pocket Capacity", "addPocketCapacity"),
		("buff_resting_friction", "Resting Friction", "addRestingFriction"),
		("buff_slow", "Slow", "addSlow"),
		("buff_speed", "Movement Speed", "addSpeed"),
		("buff_stamina_after_extra_jump", "Stamina After Extra Jump", "addStaminaAfterExtraJump"),
		("buff_stamina_after_jump", "Stamina After Jump", "addStaminaAfterJump"),
		("buff_stamina_after_jump_boost", "Stamina After Jump Boost", "addStaminaAfterJumpBoost"),
		("buff_still_grip_strength", "Still Grip Strength", "addStillGripStrength"),
		("buff_strike_damage", "Strike Damage", "addStrike"),
		("buff_throw_strength", "Throw Strength", "addThrow"),
		("buff_bloodied", "Bloodied", "bloodied"),
		("buff_boosted", "Boosted", "boosted"),
		("buff_duration_multiplier", "Buff Duration Multiplier", "buffTimeMult"),
		("buff_cryogenic_ammo", "Cryogenic Ammo", "addCryogenic"),
		("buff_freeze_counter", "Freeze Counter", "counter"),
		("buff_divide_capacity", "Inventory Capacity Multiplier", "divideCapacity"),
		("buff_divide_jump_strain", "Jump Strain Multiplier", "divideJumpStrain"),
		("buff_divide_stamina", "Stamina Multiplier", "divideStamina"),
		("buff_left_hand_divide_stamina", "Left Hand Stamina Multiplier", "divideStamina-hand-0"),
		("buff_right_hand_divide_stamina", "Right Hand Stamina Multiplier", "divideStamina-hand-1"),
		("buff_extra_jump_on_food", "Extra Jumps On Food", "extrajumponfood"),
		("buff_flight", "Flight", "flight"),
		("buff_force_crouch_grounded", "Force Crouch Grounded", "forceCrouchIfGrounded"),
		("buff_gooped", "Gooped", "gooped"),
		("buff_goop_time", "Goop Duration", "gooptime"),
		("buff_grab_anything", "Grab Anything", "grabAnything"),
		("buff_grip_resistance", "Grip Resistance", "gripResist"),
		("buff_leg_break", "Leg Break", "leg break"),
		("buff_left_arm_break", "Left Arm Break", "arm break (left)"),
		("buff_right_arm_break", "Right Arm Break", "arm break (right)"),
		("buff_bleed", "Bleed", "bleed"),
		("buff_burned", "Burned", "burned"),
		("buff_limit_grip_strength", "Grip Strength Limit", "limitGripStrength"),
		("buff_slow_mass", "Slow Mass", "massResist"),
		("buff_mass_slow", "Mass Slow", "massSlow"),
		("buff_mass_speed_multiplier", "Mass Speed Multiplier", "massSpeedMult"),
		("buff_poison_drop_hands", "Poison Drop Hands", "poisonDropHands"),
		("buff_poisoned", "Poisoned", "poisoned"),
		("buff_poison_stamina_damage", "Poison Stamina Damage", "poisonStaminaDamage"),
		("buff_poison_timer", "Poison Timer", "poisonTimer"),
		("buff_reduce_fall_damage_distance", "Fall Damage Distance", "reduceFallDamageDistance"),
		("buff_roided", "Roided", "roided"),
		("buff_slow_time_inventory", "Inventory Time Slow", "slowTimeInventory"),
		("buff_unbound", "Unbound", "unbound"),
		("buff_warming", "Warming", "warming")
	};

	private Dictionary<string, string> startingPerkTitles => (from p in CL_AssetManager.GetFullCombinedAssetDatabase().perkAssets
		where (Object)(object)p != (Object)null
		orderby p.title
		select p).ToDictionary((Perk p) => p.id, (Perk p) => p.title);

	private void Awake()
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Expected O, but got Unknown
		if ((Object)(object)menuSettingsManager == (Object)null)
		{
			menuSettingsManager = ((Component)((Component)this).transform.parent.parent).GetComponentInChildren<MenuSettingsManager>();
		}
		if ((Object)(object)panelButton == (Object)null)
		{
			panelButton = ((Component)this).GetComponent<Button>();
		}
		if ((Object)(object)panelButton != (Object)null)
		{
			((UnityEvent)panelButton.onClick).AddListener(new UnityAction(OnPanelClicked));
		}
		RegisterAllSettings();
	}

	public void RegisterAllSettings()
	{
		if ((Object)(object)menuSettingsManager == (Object)null)
		{
			return;
		}
		menuSettingsManager.Register(menuTag, "Use Default Transitions And Breakrooms", "use_default_transitions_and_breakrooms", SettingType.Bool, "false");
		foreach (KeyValuePair<string, string> startingItemTitle in startingItemTitles)
		{
			menuSettingsManager.Register(menuTag, startingItemTitle.Value, startingItemTitle.Key, SettingType.Integer, "0", "STARTING ITEMS");
		}
		foreach (KeyValuePair<string, string> startingPerkTitle in startingPerkTitles)
		{
			menuSettingsManager.Register(menuTag, startingPerkTitle.Value, startingPerkTitle.Key, SettingType.Integer, "0", "STARTING PERKS");
		}
		(string, string, string)[] array = buffSettings;
		for (int i = 0; i < array.Length; i++)
		{
			(string, string, string) tuple = array[i];
			menuSettingsManager.Register(menuTag, tuple.Item2, tuple.Item1, SettingType.Float, "0", "BUFFS");
		}
		menuSettingsManager.Register(menuTag, "Mass Scaling Mult", "mass_speed_mult", SettingType.Float, "1", "MASS");
		menuSettingsManager.Register(menuTag, "Mass Starting Speed", "mass_start_speed", SettingType.Float, "1", "MASS");
		menuSettingsManager.Register(menuTag, "Mass Acceleration Mult", "mass_accel_mult", SettingType.Float, "1", "MASS");
		menuSettingsManager.Register(menuTag, "Rubberband Mult", "mass_rubberband_mult", SettingType.Float, "1", "MASS");
		menuSettingsManager.Register(menuTag, "Enable Rubberband", "mass_rubberband_enabled", SettingType.Bool, "true", "MASS");
		menuSettingsManager.Register(menuTag, "Perk Every X", "breakroom_perk_machine_every", SettingType.Integer, "1", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Perk After X", "breakroom_perk_machine_after", SettingType.Integer, "0", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Experimental Every X", "breakroom_experimental_machine_every", SettingType.Integer, "0", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Experimental After X", "breakroom_experimental_machine_after", SettingType.Integer, "0", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "ATM Every X", "breakroom_atm_every", SettingType.Integer, "1", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "ATM After X", "breakroom_atm_after", SettingType.Integer, "0", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Vender Every X", "breakroom_vending_every", SettingType.Integer, "1", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Vender After X", "breakroom_vending_after", SettingType.Integer, "0", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Vender T2 Every X", "breakroom_vending_t2_every", SettingType.Integer, "1", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Vender T2 After X", "breakroom_vending_t2_after", SettingType.Integer, "0", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Recycler Every X", "breakroom_recycler_every", SettingType.Integer, "1", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Recycler After X", "breakroom_recycler_after", SettingType.Integer, "0", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Cryo Refueler Every X", "breakroom_cryo_refueler_every", SettingType.Integer, "1", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Cryo Refueler After X", "breakroom_cryo_refueler_after", SettingType.Integer, "0", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Monolith Every X", "breakroom_rho_monolith_every", SettingType.Integer, "3", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Monolith After X", "breakroom_rho_monolith_after", SettingType.Integer, "3", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Bazaar Every X", "breakroom_manhole_hatch_every", SettingType.Integer, "3", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Bazaar After X", "breakroom_manhole_hatch_after", SettingType.Integer, "5", "BREAKROOMS");
		menuSettingsManager.Register(menuTag, "Campaign Or Challenge Win", "campaign_or_challenge_win", SettingType.Bool, "false", "WIN CONDITION");
		menuSettingsManager.Register(menuTag, "Cycles Condition", "cycles_win_enabled", SettingType.Bool, "false", "WIN CONDITION");
		menuSettingsManager.Register(menuTag, "Win After X Cycles", "cycles_win_amount", SettingType.Integer, "1", "WIN CONDITION");
		menuSettingsManager.Register(menuTag, "Height Condition", "height_win_enabled", SettingType.Bool, "false", "WIN CONDITION");
		menuSettingsManager.Register(menuTag, "Win After Climbing X", "height_win_amount", SettingType.Float, "1000", "WIN CONDITION");
		menuSettingsManager.Register(menuTag, "Always Snowing", "fun_always_snowing", SettingType.Bool, "false", "FUN");
		menuSettingsManager.Register(menuTag, "Consumah", "fun_consumah", SettingType.Bool, "false", "FUN");
		menuSettingsManager.Register(menuTag, "Trinket Roaches", "fun_boost_roaches", SettingType.Bool, "false", "FUN");
		menuSettingsManager.Register(menuTag, "All Perks Stack Linearly", "fun_limitless_perks", SettingType.Bool, "false", "FUN");
		menuSettingsManager.Register(menuTag, "Buffs/Debuffs Never End", "fun_limitless_buffs", SettingType.Bool, "false", "FUN");
		menuSettingsManager.Register(menuTag, "Unseen Tuocs", "fun_unseen_amount", SettingType.Integer, "0", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Unseen Cimim", "fun_cimim_amount", SettingType.Integer, "0", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "4d Unseen", "always_see_unseen", SettingType.Bool, "true", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Has Eye", "unseen_has_eye", SettingType.Bool, "true", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Eye Size", "unseen_eye_size", SettingType.Float, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "General Size", "unseen_general_size", SettingType.Float, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Use Buttons", "unseen_buttons", SettingType.Bool, "true", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Use Items", "unseen_use_items", SettingType.Bool, "true", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Grab Items", "unseen_grab_items", SettingType.Bool, "true", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Quirks", "unseen_quirks", SettingType.Bool, "true", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Crouch Copy", "unseen_crouch", SettingType.Bool, "true", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Leg Length", "unseen_leg_length", SettingType.Float, "14", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Min Leg Segments", "unseen_leg_seg_min", SettingType.Integer, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Max Leg Segments", "unseen_leg_seg_max", SettingType.Integer, "5", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Leg Min", "unseen_leg_min", SettingType.Integer, "5", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Leg Max", "unseen_leg_max", SettingType.Integer, "12", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Leg Start", "unseen_leg_start", SettingType.Integer, "8", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Leg Form Wait Min", "unseen_leg_form_min", SettingType.Float, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Leg Form Wait Max", "unseen_leg_form_max", SettingType.Float, "5", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Step Time", "unseen_step_time", SettingType.Float, "0.1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Step Gap", "unseen_step_gap", SettingType.Float, "0.28", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Step Count", "unseen_step_count", SettingType.Integer, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tap Time", "unseen_tap_time", SettingType.Float, "0.1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tap Gap", "unseen_tap_gap", SettingType.Float, "0.1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tap Dmg", "unseen_tap_dmg", SettingType.Float, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Prop Dmg", "unseen_prop_dmg", SettingType.Float, "0.3", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Move Cap", "unseen_move_cap", SettingType.Float, "28", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Force Per Leg", "unseen_force_per_leg", SettingType.Float, "6", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Patrol Speed", "unseen_patrol_spd", SettingType.Float, "22", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Catch Speed", "unseen_catch_spd", SettingType.Float, "28", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Attack Spweed", "unseen_attack_spd", SettingType.Float, "12", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Grab Chance", "unseen_grab_rate", SettingType.Float, "0.8", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Throw Speed", "unseen_throw_spd", SettingType.Float, "8", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Carry Time", "unseen_carry_time", SettingType.Float, "4", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Carry Speed Mult", "unseen_carry_spd", SettingType.Float, "0.25", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Give Chnce", "unseen_give_rate", SettingType.Float, "0.5", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Button Chance", "unseen_button_rate", SettingType.Float, "0.35", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Friend Use Chance", "unseen_friend_use", SettingType.Float, "0.35", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Hostile Use Chance", "unseen_hostile_use", SettingType.Float, "0.7", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Quirk Min", "unseen_quirk_min", SettingType.Integer, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Quirk Max", "unseen_quirk_max", SettingType.Integer, "3", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Quirk Chance", "unseen_quirk_rate", SettingType.Float, "0.65", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Quirk Min Time", "unseen_quirk_min_time", SettingType.Float, "18", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Quirk Max Time", "unseen_quirk_max_time", SettingType.Float, "42", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Shadow Size", "unseen_shadow_size", SettingType.Integer, "64", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Shadow Frames", "unseen_shadow_frames", SettingType.Integer, "13", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Core Size", "unseen_core_size", SettingType.Float, "0.5", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tendril Min", "unseen_tendril_min", SettingType.Integer, "20", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tendril Max", "unseen_tendril_max", SettingType.Integer, "32", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tendril Min Len", "unseen_tendril_min_len", SettingType.Float, "0.48", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tendril Max Len", "unseen_tendril_max_len", SettingType.Float, "3.05", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tendril Thickness", "unseen_tendril_thick", SettingType.Float, "7.5", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Tendril Curving", "unseen_tendril_curve", SettingType.Float, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Smoothing Passes", "unseen_cell_passes", SettingType.Integer, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Edge Fade (px)", "unseen_edge_fade", SettingType.Float, "1", "ARACHNOPHOBIA");
		menuSettingsManager.Register(menuTag, "Leg Roll Chance", "unseen_leg_roll", SettingType.Float, "0.35", "ARACHNOPHOBIA");
	}

	public void OnPanelClicked()
	{
		if ((Object)(object)menuSettingsManager != (Object)null)
		{
			menuSettingsManager.LoadMenu(menuTag);
		}
	}
}
public class HoverDetector : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
	[SerializeField]
	private float fadeDuration = 0.15f;

	[SerializeField]
	private float toggleFadeDuration = 0.1f;

	[SerializeField]
	private Color enabledColor = Color.green;

	[SerializeField]
	private float rotationDuration = 0.16f;

	[SerializeField]
	private AnimationCurve rotationCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
	{
		new Keyframe(0f, 0f),
		new Keyframe(0.65f, 1.15f),
		new Keyframe(1f, 1f)
	});

	public bool toggled;

	private Image targetImage;

	private Image buttonImage;

	private Color disabledColor;

	private Quaternion originalImageRotation;

	private Coroutine currentFadeCoroutine;

	private Coroutine rotationCoroutine;

	private bool imageHovered;

	private UISettingsManager settingsManager;

	public string settingsTag = "default_bool";

	private void Awake()
	{
		//IL_0019: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		if (((Component)this).TryGetComponent<Image>(ref buttonImage))
		{
			disabledColor = ((Graphic)buttonImage).color;
		}
		Transform val = ((Component)this).transform.Find("Image");
		if ((Object)(object)val != (Object)null && ((Component)val).TryGetComponent<Image>(ref targetImage))
		{
			originalImageRotation = ((Component)targetImage).transform.localRotation;
			SetImageAlpha(0f);
		}
		settingsManager = UISettingsManager.instance;
	}

	private void UpdateSettingState(bool isEnabled)
	{
		if ((Object)(object)settingsManager != (Object)null)
		{
			settingsManager.SetBool(settingsTag, isEnabled);
		}
	}

	public void OnPointerEnter(PointerEventData eventData)
	{
		StartFade(1f);
		StartRotation(hovering: true);
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		StartFade(0f);
		StartRotation(hovering: false);
	}

	private void StartRotation(bool hovering)
	{
		if (!((Object)(object)targetImage == (Object)null))
		{
			if (rotationCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(rotationCoroutine);
			}
			rotationCoroutine = ((MonoBehaviour)this).StartCoroutine(RotateImage(hovering));
		}
	}

	private IEnumerator RotateImage(bool hovering)
	{
		Quaternion startRotation = ((Component)targetImage).transform.localRotation;
		Quaternion endRotation = (hovering ? (originalImageRotation * Quaternion.Euler(0f, 0f, 45f)) : originalImageRotation);
		float elapsed = 0f;
		while (elapsed < rotationDuration)
		{
			elapsed += Time.unscaledDeltaTime;
			float t = rotationCurve.Evaluate(Mathf.Clamp01(elapsed / rotationDuration));
			((Component)targetImage).transform.localRotation = Quaternion.SlerpUnclamped(startRotation, endRotation, t);
			yield return null;
		}
		((Component)targetImage).transform.localRotation = endRotation;
	}

	private void StartFade(float targetAlpha)
	{
		if (!((Object)(object)targetImage == (Object)null))
		{
			if (currentFadeCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(currentFadeCoroutine);
			}
			currentFadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeRoutine(targetAlpha));
		}
	}

	private IEnumerator FadeRoutine(float targetAlpha)
	{
		float startAlpha = ((Graphic)targetImage).color.a;
		float elapsed = 0f;
		while (elapsed < fadeDuration)
		{
			elapsed += Time.deltaTime;
			SetImageAlpha(Mathf.Lerp(startAlpha, targetAlpha, elapsed / fadeDuration));
			yield return null;
		}
		SetImageAlpha(targetAlpha);
	}

	private IEnumerator ToggleFadeRoutine(Color targetColor)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)buttonImage == (Object)null))
		{
			Color startColor = ((Graphic)buttonImage).color;
			float elapsed = 0f;
			while (elapsed < toggleFadeDuration)
			{
				elapsed += Time.deltaTime;
				((Graphic)buttonImage).color = Color.Lerp(startColor, targetColor, elapsed / toggleFadeDuration);
				yield return null;
			}
			((Graphic)buttonImage).color = targetColor;
		}
	}

	private void SetImageAlpha(float alpha)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		Color color = ((Graphic)targetImage).color;
		color.a = alpha;
		((Graphic)targetImage).color = color;
	}
}
public static class CustomLevelLoader
{
	public static readonly Dictionary<string, AssetBundle> _cachedBundles = new Dictionary<string, AssetBundle>(StringComparer.OrdinalIgnoreCase);

	public static bool Override;

	private static Shader overrideShader;

	private static readonly Dictionary<Material, Shader> originalShaders = new Dictionary<Material, Shader>();

	private static readonly HashSet<M_Level> customLevels = new HashSet<M_Level>();

	public static LevelAssetHolder LoadRoom(string bundlePath, string assetName, string levelName)
	{
		Type type = Type.GetType("Severon.GamemodeFramework.GamemodeFramework, GamemodeFramework", throwOnError: false);
		MethodInfo methodInfo = ((type == null) ? null : type.GetMethod("LoadLevel", BindingFlags.Static | BindingFlags.Public, null, new Type[4]
		{
			typeof(string),
			typeof(string),
			typeof(string),
			typeof(string)
		}, null));
		if (methodInfo != null)
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			LevelAssetHolder val;
			try
			{
				object? obj = methodInfo.Invoke(null, new object[4] { directoryName, bundlePath, assetName, levelName });
				val = (LevelAssetHolder)((obj is LevelAssetHolder) ? obj : null);
			}
			catch (TargetInvocationException ex)
			{
				Debug.LogWarning((object)(ex.InnerException ?? ex));
				return LoadRoomFallback(bundlePath, assetName, levelName);
			}
			if (val == null || (Object)(object)val.level == (Object)null)
			{
				return LoadRoomFallback(bundlePath, assetName, levelName);
			}
			RegisterCustomLevel(val.level);
			CL_Lamp[] componentsInChildren = ((Component)val.level).gameObject.GetComponentsInChildren<CL_Lamp>(true);
			foreach (CL_Lamp val2 in componentsInChildren)
			{
				val2.range *= 2f;
				val2.SetAngle(359f);
				val2.bypassLightmap = 1f;
				val2.lampActive = true;
			}
			return val;
		}
		return LoadRoomFallback(bundlePath, assetName, levelName);
	}

	private static LevelAssetHolder LoadRoomFallback(string bundlePath, string assetName, string levelName)
	{
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Expected O, but got Unknown
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		if (string.IsNullOrEmpty(directoryName))
		{
			return null;
		}
		string text = Path.Combine(directoryName, bundlePath);
		AssetBundle value = null;
		if (!_cachedBundles.TryGetValue(text, out value) || (Object)(object)value == (Object)null)
		{
			if (!File.Exists(text))
			{
				return null;
			}
			try
			{
				value = AssetBundle.LoadFromFile(text);
			}
			catch
			{
				return null;
			}
			if ((Object)(object)value == (Object)null)
			{
				return null;
			}
			_cachedBundles[text] = value;
		}
		GameObject val = value.LoadAsset<GameObject>(assetName);
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		GameObject val2 = Object.Instantiate<GameObject>(val);
		EndlessConfiguration.RegisterRuntimeObject(val2, cleanup: false);
		((Object)val2).name = levelName;
		M_Level val3 = val2.GetComponent<M_Level>();
		if ((Object)(object)val3 == (Object)null)
		{
			val3 = val2.AddComponent<M_Level>();
		}
		Transform val4 = FindRecursiveContains(val2.transform, "entrance");
		Transform val5 = FindRecursiveContains(val2.transform, "exit");
		if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null)
		{
			Object.Destroy((Object)(object)val2);
			return null;
		}
		Transform[] componentsInChildren = val2.GetComponentsInChildren<Transform>(true);
		foreach (Transform val6 in componentsInChildren)
		{
			if (((Object)val6).name.IndexOf("handhold", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				ObjectTagger val7 = ((Component)val6).GetComponent<ObjectTagger>();
				if ((Object)(object)val7 == (Object)null)
				{
					val7 = ((Component)val6).gameObject.AddComponent<ObjectTagger>();
				}
				val7.AddTag("Handhold");
			}
			if ((Object)(object)((Component)val6).GetComponent<Light>() != (Object)null && (Object)(object)((Component)val6).GetComponent<CL_Lamp>() == (Object)null)
			{
				((Component)val6).gameObject.AddComponent<CL_Lamp>();
			}
		}
		CL_Lamp[] componentsInChildren2 = val2.GetComponentsInChildren<CL_Lamp>(true);
		foreach (CL_Lamp val8 in componentsInChildren2)
		{
			Light component = ((Component)val8).gameObject.GetComponent<Light>();
			if (!((Object)(object)component == (Object)null))
			{
				val8.SetColor(component.color);
				val8.range = component.range * 2f;
				val8.SetAngle(360f);
				val8.bypassLightmap = 1f;
				val8.lampActive = true;
				if (val8.isEffector && !CL_Lamp.effectorLamps.Contains(val8))
				{
					CL_Lamp.effectorLamps.Add(val8);
				}
				if ((Object)(object)FXManager.fxMan != (Object)null)
				{
					FXManager.fxMan.AddLamp(val8);
				}
			}
		}
		val3.levelName = levelName;
		val3.levelEntrance = val4;
		val3.levelExit = val5;
		val3.isLODGap = false;
		val3.spawnPosition = val4;
		val3.customBounds = true;
		val3.levelBounds = (Bounds)((levelName == "To_Duct") ? CalculateDuctBounds(val3) : new Bounds(Vector3.zero, new Vector3(5f, 5f, 5f)));
		val3.CalculateBounds();
		val3.canFlip = false;
		val3.showInLevelList = true;
		val3.allowEvents = true;
		val3.spawnSettings = new SpawnSettings
		{
			spawnChance = 1f
		};
		RegisterCustomLevel(val3);
		LevelAssetHolder newHolderFromLevel;
		try
		{
			newHolderFromLevel = LevelAssetHolder.GetNewHolderFromLevel(val3);
		}
		catch
		{
			Object.Destroy((Object)(object)val2);
			return null;
		}
		val2.SetActive(false);
		return newHolderFromLevel;
	}

	private static Transform FindRecursiveContains(Transform root, string substring)
	{
		Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			if (((Object)val).name.IndexOf(substring, StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return val;
			}
		}
		return null;
	}

	private static Bounds CalculateDuctBounds(M_Level level)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = ((Component)level).transform;
		Bounds result = default(Bounds);
		((Bounds)(ref result))..ctor(transform.InverseTransformPoint(level.levelEntrance.position), Vector3.zero);
		((Bounds)(ref result)).Encapsulate(transform.InverseTransformPoint(level.levelExit.position));
		MeshFilter[] componentsInChildren = ((Component)transform).GetComponentsInChildren<MeshFilter>(true);
		foreach (MeshFilter val in componentsInChildren)
		{
			if ((Object)(object)val.sharedMesh == (Object)null)
			{
				continue;
			}
			Bounds bounds = val.sharedMesh.bounds;
			Matrix4x4 val2 = transform.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix;
			Vector3 min = ((Bounds)(ref bounds)).min;
			Vector3 max = ((Bounds)(ref bounds)).max;
			for (int j = 0; j < 2; j++)
			{
				for (int k = 0; k < 2; k++)
				{
					for (int l = 0; l < 2; l++)
					{
						((Bounds)(ref result)).Encapsulate(((Matrix4x4)(ref val2)).MultiplyPoint3x4(new Vector3((j == 0) ? min.x : max.x, (k == 0) ? min.y : max.y, (l == 0) ? min.z : max.z)));
					}
				}
			}
		}
		((Bounds)(ref result)).Expand(2f);
		return result;
	}

	public static void ClearCache()
	{
		foreach (AssetBundle value in _cachedBundles.Values)
		{
			if ((Object)(object)value != (Object)null)
			{
				value.Unload(false);
			}
		}
		_cachedBundles.Clear();
	}

	private static void RegisterCustomLevel(M_Level level)
	{
		if ((Object)(object)level != (Object)null)
		{
			customLevels.Add(level);
		}
	}

	internal static IEnumerable<M_Level> GetCustomLevels()
	{
		customLevels.RemoveWhere((M_Level level) => (Object)(object)level == (Object)null);
		return customLevels;
	}
}
public enum SettingType
{
	Integer,
	Float,
	Bool
}
public class MenuSettingsManager : MonoBehaviour
{
	private class SettingData
	{
		public string menuTag;

		public string displayName;

		public string settingTag;

		public SettingType settingType;

		public string defaultValue;

		public string dropdownName;
	}

	private GameObject templateFloat;

	private GameObject templateInteger;

	private GameObject templateBool;

	private GameObject templateDropdown;

	private UISettingsManager settingsManager;

	private Transform contentContainer;

	private List<SettingData> registeredSettings = new List<SettingData>();

	private List<GameObject> activeInstances = new List<GameObject>();

	private string activeMenuTag;

	private Transform controls;

	private static readonly Dictionary<string, bool> boolDefaults = new Dictionary<string, bool>();

	private static readonly Dictionary<string, int> intDefaults = new Dictionary<string, int>();

	private static readonly Dictionary<string, float> floatDefaults = new Dictionary<string, float>();

	private void Awake()
	{
		Transform parent = ((Component)this).transform.parent;
		settingsManager = ((parent != null) ? ((Component)parent).GetComponent<UISettingsManager>() : null);
		Transform obj = ((Component)this).transform.Find("TemplateFloat");
		templateFloat = ((obj != null) ? ((Component)obj).gameObject : null);
		Transform obj2 = ((Component)this).transform.Find("TemplateInteger");
		templateInteger = ((obj2 != null) ? ((Component)obj2).gameObject : null);
		Transform obj3 = ((Component)this).transform.Find("TemplateBool");
		templateBool = ((obj3 != null) ? ((Component)obj3).gameObject : null);
		Transform obj4 = ((Component)this).transform.Find("TemplateDropdown");
		templateDropdown = ((obj4 != null) ? ((Component)obj4).gameObject : null);
		SetupContentContainer();
	}

	private void SetupContentContainer()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((Component)this).transform.Find("Content");
		if ((Object)(object)val != (Object)null)
		{
			contentContainer = val;
		}
		else
		{
			GameObject val2 = new GameObject("Content", new Type[1] { typeof(RectTransform) });
			contentContainer = val2.transform;
			contentContainer.SetParent(((Component)this).transform, false);
			RectTransform component = ((Component)contentContainer).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = new Vector2(0f, component.sizeDelta.y);
			VerticalLayoutGroup component2 = ((Component)this).GetComponent<VerticalLayoutGroup>();
			if ((Object)(object)component2 != (Object)null)
			{
				VerticalLayoutGroup val3 = val2.AddComponent<VerticalLayoutGroup>();
				((LayoutGroup)val3).padding = ((LayoutGroup)component2).padding;
				((HorizontalOrVerticalLayoutGroup)val3).spacing = ((HorizontalOrVerticalLayoutGroup)component2).spacing;
				((LayoutGroup)val3).childAlignment = ((LayoutGroup)component2).childAlignment;
				((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = ((HorizontalOrVerticalLayoutGroup)component2).childControlWidth;
				((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = ((HorizontalOrVerticalLayoutGroup)component2).childControlHeight;
				((HorizontalOrVerticalLayoutGroup)val3).childScaleWidth = ((HorizontalOrVerticalLayoutGroup)component2).childScaleWidth;
				((HorizontalOrVerticalLayoutGroup)val3).childScaleHeight = ((HorizontalOrVerticalLayoutGroup)component2).childScaleHeight;
				((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = ((HorizontalOrVerticalLayoutGroup)component2).childForceExpandWidth;
				((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = ((HorizontalOrVerticalLayoutGroup)component2).childForceExpandHeight;
				((HorizontalOrVerticalLayoutGroup)val3).reverseArrangement = ((HorizontalOrVerticalLayoutGroup)component2).reverseArrangement;
				ContentSizeFitter val4 = val2.AddComponent<ContentSizeFitter>();
				val4.verticalFit = (FitMode)2;
			}
		}
		ScrollRect val5 = default(ScrollRect);
		if (((Component)this).TryGetComponent<ScrollRect>(ref val5))
		{
			val5.content = ((Component)contentContainer).GetComponent<RectTransform>();
			val5.viewport = ((Component)this).GetComponent<RectTransform>();
		}
		if ((Object)(object)((Component)this).GetComponent<RectMask2D>() == (Object)null && (Object)(object)((Component)this).GetComponent<Mask>() == (Object)null)
		{
			((Component)this).gameObject.AddComponent<RectMask2D>();
		}
	}

	public void Register(string menuTag, string displayName, string settingTag, SettingType settingType, string defaultValue, string dropdownName = "")
	{
		registeredSettings.Add(new SettingData
		{
			menuTag = menuTag,
			displayName = displayName,
			settingTag = settingTag,
			settingType = settingType,
			defaultValue = defaultValue,
			dropdownName = dropdownName
		});
		if (settingType == SettingType.Bool && bool.TryParse(defaultValue, out var result))
		{
			boolDefaults[settingTag] = result;
		}
		if (settingType == SettingType.Integer && int.TryParse(defaultValue, out var result2))
		{
			intDefaults[settingTag] = result2;
		}
		if (settingType == SettingType.Float && float.TryParse(defaultValue, out var result3))
		{
			floatDefaults[settingTag] = result3;
		}
		UISettingsManager uISettingsManager = (((Object)(object)settingsManager != (Object)null) ? settingsManager : UISettingsManager.instance);
		if (!((Object)(object)uISettingsManager == (Object)null))
		{
			if (settingType == SettingType.Integer && int.TryParse(defaultValue, out var result4) && !uISettingsManager.HasInt(settingTag))
			{
				uISettingsManager.SetInt(settingTag, EndlessConfiguration.CustomUIManager.SettingCounts.TryGetValue(settingTag, out var value) ? value : result4);
			}
			if (settingType == SettingType.Float && float.TryParse(defaultValue, out var result5) && !uISettingsManager.HasFloat(settingTag))
			{
				uISettingsManager.SetFloat(settingTag, EndlessConfiguration.CustomUIManager.SettingFloats.TryGetValue(settingTag, out var value2) ? value2 : result5);
			}
			if (settingType == SettingType.Bool && bool.TryParse(defaultValue, out var result6) && !uISettingsManager.HasBool(settingTag))
			{
				uISettingsManager.SetBool(settingTag, EndlessConfiguration.CustomUIManager.SettingToggles.TryGetValue(settingTag, out var value3) ? value3 : result6);
			}
		}
	}

	public void ResetConfiguredSettings(string excludedTag)
	{
		UISettingsManager uISettingsManager = (((Object)(object)settingsManager != (Object)null) ? settingsManager : UISettingsManager.instance);
		if ((Object)(object)uISettingsManager == (Object)null)
		{
			return;
		}
		for (int i = 0; i < registeredSettings.Count; i++)
		{
			SettingData settingData = registeredSettings[i];
			if (!string.Equals(settingData.settingTag, excludedTag, StringComparison.OrdinalIgnoreCase))
			{
				if (settingData.settingType == SettingType.Bool && bool.TryParse(settingData.defaultValue, out var result))
				{
					uISettingsManager.SetBool(settingData.settingTag, result);
					EndlessConfiguration.CustomUIManager.SettingToggles[settingData.settingTag] = result;
				}
				if (settingData.settingType == SettingType.Integer && int.TryParse(settingData.defaultValue, out var result2))
				{
					uISettingsManager.SetInt(settingData.settingTag, result2);
					EndlessConfiguration.CustomUIManager.SettingCounts[settingData.settingTag] = result2;
				}
				if (settingData.settingType == SettingType.Float && float.TryParse(settingData.defaultValue, out var result3))
				{
					uISettingsManager.SetFloat(settingData.settingTag, result3);
					EndlessConfiguration.CustomUIManager.SettingFloats[settingData.settingTag] = result3;
				}
			}
		}
	}

	public Transform BeginCustomMenu(string menuTag)
	{
		if ((Object)(object)contentContainer == (Object)null)
		{
			SetupContentContainer();
		}
		if (string.Equals(activeMenuTag, menuTag, StringComparison.OrdinalIgnoreCase))
		{
			ClearMenu();
			return null;
		}
		for (int i = 0; i < activeInstances.Count; i++)
		{
			if ((Object)(object)activeInstances[i] != (Object)null)
			{
				Object.Destroy((Object)(object)activeInstances[i]);
			}
		}
		activeInstances.Clear();
		activeMenuTag = menuTag;
		Transform val = GetControls();
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(false);
		}
		return contentContainer;
	}

	public GameObject CreateIntegerInstance(Transform parent)
	{
		if ((Object)(object)templateInteger == (Object)null || (Object)(object)parent == (Object)null)
		{
			return null;
		}
		GameObject val = Object.Instantiate<GameObject>(templateInteger, parent);
		activeInstances.Add(val);
		return val;
	}

	public void LoadBalancedMenu(string menuTag, string requirements)
	{
		if (string.Equals(activeMenuTag, menuTag, StringComparison.OrdinalIgnoreCase))
		{
			ClearMenu();
			return;
		}
		LoadMenu(menuTag);
		if ((Object)(object)contentContainer == (Object)null)
		{
			return;
		}
		Transform val = GetControls();
		if (!((Object)(object)val == (Object)null))
		{
			GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, contentContainer);
			((Object)val2).name = "Requirements";
			float num = 50f;
			TMP_Text[] componentsInChildren = val2.GetComponentsInChildren<TMP_Text>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].text = requirements;
				componentsInChildren[i].overflowMode = (TextOverflowModes)0;
				num = Mathf.Max(num, componentsInChildren[i].preferredHeight + 12f);
			}
			Text[] componentsInChildren2 = val2.GetComponentsInChildren<Text>(true);
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				componentsInChildren2[j].text = requirements;
				componentsInChildren2[j].horizontalOverflow = (HorizontalWrapMode)1;
				componentsInChildren2[j].verticalOverflow = (VerticalWrapMode)1;
				num = Mathf.Max(num, componentsInChildren2[j].preferredHeight + 12f);
			}
			LayoutElement val3 = val2.GetComponent<LayoutElement>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val2.AddComponent<LayoutElement>();
			}
			val3.minHeight = num;
			val3.preferredHeight = num;
			val2.SetActive(true);
			val2.transform.SetAsFirstSibling();
			Transform obj = contentContainer;
			LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((obj is RectTransform) ? obj : null));
			activeInstances.Add(val2);
		}
	}

	private Transform GetControls()
	{
		if ((Object)(object)controls != (Object)null)
		{
			return controls;
		}
		Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>(true);
		if ((Object)(object)componentInParent == (Object)null)
		{
			return null;
		}
		Transform[] componentsInChildren = ((Component)componentInParent).GetComponentsInChildren<Transform>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			if (string.Equals(((Object)componentsInChildren[i]).name, "Controls", StringComparison.OrdinalIgnoreCase))
			{
				return controls = componentsInChildren[i];
			}
		}
		return null;
	}

	private void ClearMenu()
	{
		for (int i = 0; i < activeInstances.Count; i++)
		{
			if ((Object)(object)activeInstances[i] != (Object)null)
			{
				Object.Destroy((Object)(object)activeInstances[i]);
			}
		}
		activeInstances.Clear();
		activeMenuTag = null;
		Transform val = GetControls();
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(true);
		}
	}

	public static bool IsDefaultBool(string settingTag, bool value)
	{
		bool value2;
		return boolDefaults.TryGetValue(settingTag, out value2) && value == value2;
	}

	public static bool IsDefaultInt(string settingTag, int value)
	{
		int value2;
		return intDefaults.TryGetValue(settingTag, out value2) && value == value2;
	}

	public static bool IsDefaultFloat(string settingTag, float value)
	{
		float value2;
		return floatDefaults.TryGetValue(settingTag, out value2) && value == value2;
	}

	public void LoadMenu(string menuTag, int slot = -1)
	{
		if ((Object)(object)contentContainer == (Object)null)
		{
			SetupContentContainer();
		}
		if (string.Equals(activeMenuTag, menuTag, StringComparison.OrdinalIgnoreCase))
		{
			ClearMenu();
			return;
		}
		for (int i = 0; i < activeInstances.Count; i++)
		{
			if ((Object)(object)activeInstances[i] != (Object)null)
			{
				Object.Destroy((Object)(object)activeInstances[i]);
			}
		}
		activeInstances.Clear();
		activeMenuTag = menuTag;
		Transform val = GetControls();
		if ((Object)(object)val != (Object)null)
		{
			((Component)val).gameObject.SetActive(false);
		}
		Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
		TMP_Text val4 = default(TMP_Text);
		Text val5 = default(Text);
		foreach (SettingData registeredSetting in registeredSettings)
		{
			if (registeredSetting.menuTag != menuTag)
			{
				continue;
			}
			bool active = true;
			Transform value = contentContainer;
			if (!string.IsNullOrEmpty(registeredSetting.dropdownName))
			{
				active = false;
				if (!dictionary.TryGetValue(registeredSetting.dropdownName, out value) && (Object)(object)templateDropdown != (Object)null)
				{
					GameObject val2 = Object.Instantiate<GameObject>(templateDropdown, contentContainer);
					((Object)val2).name = registeredSetting.dropdownName;
					Transform val3 = val2.transform.Find("Title");
					if ((Object)(object)val3 != (Object)null)
					{
						if (((Component)val3).TryGetComponent<TMP_Text>(ref val4))
						{
							val4.text = registeredSetting.dropdownName;
						}
						else if (((Component)val3).TryGetComponent<Text>(ref val5))
						{
							val5.text = registeredSetting.dropdownName;
						}
					}
					val2.SetActive(true);
					dictionary[registeredSetting.dropdownName] = val2.transform;
					value = val2.transform;
					activeInstances.Add(val2);
				}
			}
			GameObject val6 = null;
			switch (registeredSetting.settingType)
			{
			case SettingType.Integer:
				val6 = templateInteger;
				break;
			case SettingType.Float:
				val6 = templateFloat;
				break;
			case SettingType.Bool:
				val6 = templateBool;
				break;
			}
			if (!((Object)(object)val6 != (Object)null))
			{
				continue;
			}
			GameObject val7 = Object.Instantiate<GameObject>(val6, value);
			MonoBehaviour val8 = null;
			object value2 = null;
			string text = registeredSetting.settingTag;
			if (slot != -1)
			{
				string text2 = text;
				string text3 = registeredSetting.menuTag.ToLower() + "_";
				if (text2.StartsWith(text3, StringComparison.OrdinalIgnoreCase))
				{
					text2 = text2.Substring(text3.Length);
				}
				text = $"slot_{slot}_{text2}";
			}
			if (registeredSetting.settingType == SettingType.Integer)
			{
				val8 = (MonoBehaviour)(object)val7.GetComponent<TemplateInteger>();
				int result;
				int num = (int.TryParse(registeredSetting.defaultValue, out result) ? result : 0);
				value2 = (((Object)(object)settingsManager != (Object)null) ? settingsManager.GetInt(text, num) : num);
			}
			else if (registeredSetting.settingType == SettingType.Float)
			{
				val8 = (MonoBehaviour)(object)val7.GetComponent<TemplateFloat>();
				float result2;
				float num2 = (float.TryParse(registeredSetting.defaultValue, out result2) ? result2 : 0f);
				value2 = (((Object)(object)settingsManager != (Object)null) ? settingsManager.GetFloat(text, num2) : num2);
			}
			else if (registeredSetting.settingType == SettingType.Bool)
			{
				val8 = (MonoBehaviour)(object)val7.GetComponent<TemplateBool>();
				bool result3;
				bool flag = bool.TryParse(registeredSetting.defaultValue, out result3) && result3;
				value2 = (((Object)(object)settingsManager != (Object)null) ? settingsManager.GetBool(text, f