Decompiled source of PEAK AIO v2.3.0

PEAK-AIO.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using HorizonBasedAmbientOcclusion.Universal;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using PEAK_AIO.API;
using PEAK_AIO.Patches;
using PEAK_AIO.TerrainGeneration;
using PEAK_AIO.UI;
using Peak;
using Photon.Pun;
using Photon.Realtime;
using PhotonCustomPropsUtils;
using Steamworks;
using TMPro;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Zorro.ControllerSupport;
using Zorro.Core;
using Zorro.Core.Serizalization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PEAK-AIO")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PEAK-AIO")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0e070e16-c355-4db0-804c-0510a5aa436e")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public static class AreaVoxeliser
{
	[BurstCompile]
	private struct BuildOverlapCommandsFirstPassJob : IJobParallelFor
	{
		[WriteOnly]
		public NativeArray<OverlapBoxCommand> commands;

		public int broadCellsX;

		public int broadCellsY;

		public int broadCellSize;

		public float spacing;

		public float3 offset;

		public QueryParameters query;

		public void Execute(int index)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			int num = index % broadCellsX;
			int num2 = index / broadCellsX;
			int num3 = num2 % broadCellsY;
			int num4 = num2 / broadCellsY;
			float num5 = (float)broadCellSize * spacing;
			float3 val = default(float3);
			((float3)(ref val))..ctor((float)num, (float)num3, (float)num4);
			float3 val2 = default(float3);
			((float3)(ref val2))..ctor(1f, 1f, 1f);
			float3 val3 = offset + val * num5 + val2 * (float)(((double)num5 - (double)spacing) * 0.5);
			commands[index] = new OverlapBoxCommand(float3.op_Implicit(val3), float3.op_Implicit(val2 * num5 * 0.5f), quaternion.op_Implicit(quaternion.identity), query);
		}
	}

	[BurstCompile]
	private struct ProcessFirstPassResultsJob : IJobParallelFor
	{
		[ReadOnly]
		public NativeArray<ColliderHit> results;

		[WriteOnly]
		public NativeArray<byte> activeBlocks;

		public void Execute(int index)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			ref NativeArray<byte> reference = ref activeBlocks;
			ColliderHit val = results[index];
			reference[index] = ((((ColliderHit)(ref val)).instanceID != 0) ? ((byte)1) : ((byte)0));
		}
	}

	[BurstCompile]
	private struct BuildOverlapCommandsSecondPassJob : IJobParallelFor
	{
		[WriteOnly]
		public NativeArray<OverlapBoxCommand> commands;

		[ReadOnly]
		public NativeArray<int> firstPassOccupiedIndexes;

		public int blocksX;

		public int blocksY;

		public int broadCellCoverage;

		public float spacing;

		public float3 offset;

		public QueryParameters query;

		public void Execute(int index)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			int num = firstPassOccupiedIndexes[index];
			int num2 = num % blocksX;
			int num3 = num / blocksX;
			int num4 = num3 % blocksY;
			int num5 = num3 / blocksY;
			int num6 = broadCellCoverage * broadCellCoverage * broadCellCoverage;
			float3 val = default(float3);
			((float3)(ref val))..ctor((float)num2, (float)num4, (float)num5);
			float3 val2 = default(float3);
			((float3)(ref val2))..ctor(1f, 1f, 1f);
			float3 val3 = default(float3);
			for (int i = 0; i < num6; i++)
			{
				int num7 = i % broadCellCoverage;
				int num8 = i / broadCellCoverage;
				int num9 = num8 % broadCellCoverage;
				int num10 = num8 / broadCellCoverage;
				((float3)(ref val3))..ctor((float)num7, (float)num9, (float)num10);
				float3 val4 = offset + (val * (float)broadCellCoverage + val3) * spacing;
				commands[index * num6 + i] = new OverlapBoxCommand(float3.op_Implicit(val4), float3.op_Implicit(val2 * spacing * 0.5f), quaternion.op_Implicit(quaternion.identity), query);
			}
		}
	}

	[BurstCompile]
	public struct FillOccupancyJob : IJobParallelFor
	{
		[ReadOnly]
		public NativeArray<int> firstPassOccupiedIndexes;

		[ReadOnly]
		public NativeArray<ColliderHit> results;

		[WriteOnly]
		public NativeArray<uint> occupancy;

		public int3 gridRes;

		public int broadCellsX;

		public int broadCellsY;

		public int broadCellCoverage;

		public int innerCellCount;

		public void Execute(int i)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			int num = firstPassOccupiedIndexes[i];
			int num2 = num % broadCellsX;
			int num3 = num / broadCellsX;
			int num4 = num3 % broadCellsY;
			int num5 = num3 / broadCellsY;
			for (int j = 0; j < innerCellCount; j++)
			{
				int num6 = j % broadCellCoverage;
				int num7 = j / broadCellCoverage;
				int num8 = num7 % broadCellCoverage;
				int num9 = num7 / broadCellCoverage;
				int num10 = num2 * broadCellCoverage + num6;
				int num11 = num4 * broadCellCoverage + num8;
				int num12 = num5 * broadCellCoverage + num9;
				if (num10 < gridRes.x && num11 < gridRes.y && num12 < gridRes.z)
				{
					int num13 = num10 + num11 * gridRes.x + num12 * gridRes.x * gridRes.y;
					ColliderHit val = results[i * innerCellCount + j];
					if (((ColliderHit)(ref val)).instanceID != 0)
					{
						occupancy[num13] = 1u;
					}
				}
			}
		}
	}

	public class TempLayerAssignment
	{
		public GameObject go;

		public int originalLayer;
	}

	private const int TempLayer = 19;

	private const int BatchSize = 128;

	private const int BroadCellCoverage = 4;

	public static List<TempLayerAssignment> tempLayerAssignments = new List<TempLayerAssignment>();

	private static NativeArray<OverlapBoxCommand> commands;

	private static NativeArray<ColliderHit> results;

	private static NativeArray<byte> activeCells;

	private static NativeArray<int> occupiedIndexes;

	public static NativeArray<uint> BuildOccupancyGrid()
	{
		//IL_0021: 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_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: 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_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03de: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0401: Unknown result type (might be due to invalid IL or missing references)
		//IL_0406: Unknown result type (might be due to invalid IL or missing references)
		//IL_0408: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0418: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: Unknown result type (might be due to invalid IL or missing references)
		//IL_041f: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Unknown result type (might be due to invalid IL or missing references)
		//IL_043c: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0454: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Unknown result type (might be due to invalid IL or missing references)
		//IL_0477: Unknown result type (might be due to invalid IL or missing references)
		//IL_047e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0483: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Unknown result type (might be due to invalid IL or missing references)
		//IL_048c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0493: Unknown result type (might be due to invalid IL or missing references)
		//IL_0494: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0512: Unknown result type (might be due to invalid IL or missing references)
		Type type = AccessTools.TypeByName("LightVolume");
		if (type == null)
		{
			Debug.LogError((object)"[AreaVoxeliser] LightVolume type not found!");
			return new NativeArray<uint>(0, (Allocator)4, (NativeArrayOptions)1);
		}
		object obj = AccessTools.Field(type, "instance")?.GetValue(null) ?? AccessTools.Property(type, "instance")?.GetValue(null);
		if (obj == null)
		{
			Debug.LogError((object)"[AreaVoxeliser] LightVolume instance is null!");
			return new NativeArray<uint>(0, (Allocator)4, (NativeArrayOptions)1);
		}
		object value = AccessTools.Field(type, "gridRes").GetValue(obj);
		int3 val2 = default(int3);
		if (value is uint3 val)
		{
			((int3)(ref val2))..ctor((int)val.x, (int)val.y, (int)val.z);
		}
		else if (value is int3 val3)
		{
			val2 = val3;
		}
		else
		{
			if (!(value is Vector3 val4))
			{
				throw new InvalidCastException("Unknown LightVolume.gridRes type: " + value?.GetType());
			}
			((int3)(ref val2))..ctor((int)val4.x, (int)val4.y, (int)val4.z);
		}
		float spacing = (float)AccessTools.Field(type, "raySpacing").GetValue(obj);
		float3 offset = float3.op_Implicit((Vector3)AccessTools.Field(type, "gridOffset").GetValue(obj));
		LayerMask val5 = (LayerMask)AccessTools.Field(type, "occluderMask").GetValue(obj);
		int num = val2.x * val2.y * val2.z;
		int num2 = Mathf.CeilToInt((float)(val2.x / 4));
		int num3 = Mathf.CeilToInt((float)(val2.y / 4));
		int num4 = Mathf.CeilToInt((float)(val2.z / 4));
		int num5 = num2 * num3 * num4;
		LayerMask val6 = LayerMask.op_Implicit(LayerMask.op_Implicit(val5) & -524289);
		MoveDoNotBakeToSeperateLayer();
		commands = new NativeArray<OverlapBoxCommand>(num5, (Allocator)3, (NativeArrayOptions)0);
		results = new NativeArray<ColliderHit>(num5, (Allocator)3, (NativeArrayOptions)1);
		activeCells = new NativeArray<byte>(num5, (Allocator)3, (NativeArrayOptions)1);
		QueryParameters query = new QueryParameters
		{
			layerMask = LayerMask.op_Implicit(val6),
			hitTriggers = (QueryTriggerInteraction)1
		};
		BuildOverlapCommandsFirstPassJob obj2 = new BuildOverlapCommandsFirstPassJob
		{
			commands = commands,
			broadCellsX = num2,
			broadCellsY = num3,
			broadCellSize = 4,
			spacing = spacing,
			offset = offset,
			query = query
		};
		JobHandle val7 = default(JobHandle);
		JobHandle val8 = IJobParallelForExtensions.Schedule<BuildOverlapCommandsFirstPassJob>(obj2, num5, 128, val7);
		JobHandle val9 = OverlapBoxCommand.ScheduleBatch(commands, results, 128, 1, val8);
		val7 = IJobParallelForExtensions.Schedule<ProcessFirstPassResultsJob>(new ProcessFirstPassResultsJob
		{
			results = results,
			activeBlocks = activeCells
		}, num5, 128, val9);
		((JobHandle)(ref val7)).Complete();
		int num6 = 0;
		for (int i = 0; i < num5; i++)
		{
			if (activeCells[i] > 0)
			{
				num6++;
			}
		}
		occupiedIndexes = new NativeArray<int>(num6, (Allocator)3, (NativeArrayOptions)1);
		int num7 = 0;
		for (int j = 0; j < num5; j++)
		{
			if (activeCells[j] > 0)
			{
				occupiedIndexes[num7++] = j;
			}
		}
		int num8 = num6;
		int num9 = 64;
		commands.Dispose();
		commands = new NativeArray<OverlapBoxCommand>(num8 * num9, (Allocator)3, (NativeArrayOptions)0);
		results.Dispose();
		results = new NativeArray<ColliderHit>(num8 * num9, (Allocator)3, (NativeArrayOptions)1);
		activeCells.Dispose();
		activeCells = new NativeArray<byte>(num8 * num9, (Allocator)3, (NativeArrayOptions)1);
		BuildOverlapCommandsSecondPassJob obj3 = new BuildOverlapCommandsSecondPassJob
		{
			commands = commands,
			firstPassOccupiedIndexes = occupiedIndexes,
			blocksX = num2,
			blocksY = num3,
			broadCellCoverage = 4,
			spacing = spacing,
			offset = offset,
			query = query
		};
		val7 = default(JobHandle);
		JobHandle val10 = IJobParallelForExtensions.Schedule<BuildOverlapCommandsSecondPassJob>(obj3, num8, 128, val7);
		JobHandle val11 = OverlapBoxCommand.ScheduleBatch(commands, results, 128, 1, val10);
		val7 = IJobParallelForExtensions.Schedule<ProcessFirstPassResultsJob>(new ProcessFirstPassResultsJob
		{
			results = results,
			activeBlocks = activeCells
		}, num8 * num9, 128, val11);
		((JobHandle)(ref val7)).Complete();
		NativeArray<uint> val12 = default(NativeArray<uint>);
		val12..ctor(num, (Allocator)4, (NativeArrayOptions)1);
		FillOccupancyJob obj4 = new FillOccupancyJob
		{
			firstPassOccupiedIndexes = occupiedIndexes,
			results = results,
			occupancy = val12,
			gridRes = val2,
			broadCellsX = num2,
			broadCellsY = num3,
			broadCellCoverage = 4,
			innerCellCount = num9
		};
		int length = occupiedIndexes.Length;
		val7 = default(JobHandle);
		val7 = IJobParallelForExtensions.Schedule<FillOccupancyJob>(obj4, length, 128, val7);
		((JobHandle)(ref val7)).Complete();
		commands.Dispose();
		results.Dispose();
		activeCells.Dispose();
		occupiedIndexes.Dispose();
		RestoreTempLayerAssignments();
		return val12;
	}

	private static void MoveDoNotBakeToSeperateLayer()
	{
		tempLayerAssignments.Clear();
		GameObject[] array = GameObject.FindGameObjectsWithTag("DoNotBake");
		for (int i = 0; i < array.Length; i++)
		{
			Collider[] componentsInChildren = array[i].GetComponentsInChildren<Collider>();
			for (int j = 0; j < componentsInChildren.Length; j++)
			{
				GameObject gameObject = ((Component)componentsInChildren[j]).gameObject;
				tempLayerAssignments.Add(new TempLayerAssignment
				{
					go = gameObject,
					originalLayer = gameObject.layer
				});
				gameObject.layer = 19;
			}
		}
	}

	private static void RestoreTempLayerAssignments()
	{
		foreach (TempLayerAssignment tempLayerAssignment in tempLayerAssignments)
		{
			if ((Object)(object)tempLayerAssignment.go != (Object)null)
			{
				tempLayerAssignment.go.layer = tempLayerAssignment.originalLayer;
			}
		}
		tempLayerAssignments.Clear();
	}
}
public static class ConfigManager
{
	public static ManualLogSource Logger;

	public static ConfigEntry<bool> InfiniteStamina;

	public static ConfigEntry<bool> TeleportToPing;

	public static ConfigEntry<bool> FlyMod;

	public static ConfigEntry<float> FlySpeed;

	public static ConfigEntry<float> FlyAcceleration;

	public static ConfigEntry<bool> Fullbright;

	public static ConfigEntry<bool> EspToggle;

	public static ConfigEntry<bool> EspEnemies;

	public static ConfigEntry<bool> EspHazards;

	public static ConfigEntry<bool> EspLuggage;

	public static ConfigEntry<bool> DevTagToggle;

	public static ConfigEntry<bool> LockStatus;

	public static ConfigEntry<bool> NoWeight;

	public static ConfigEntry<bool> SpeedMod;

	public static ConfigEntry<bool> JumpMod;

	public static ConfigEntry<bool> NoFallDmg;

	public static ConfigEntry<bool> ClimbMod;

	public static ConfigEntry<bool> VineClimbMod;

	public static ConfigEntry<bool> RopeClimbMod;

	public static ConfigEntry<float> SpeedAmount;

	public static ConfigEntry<float> JumpAmount;

	public static ConfigEntry<float> ClimbAmount;

	public static ConfigEntry<float> VineClimbAmount;

	public static ConfigEntry<float> RopeClimbAmount;

	public static ConfigEntry<float> RechargeAmountSlot1;

	public static ConfigEntry<float> RechargeAmountSlot2;

	public static ConfigEntry<float> RechargeAmountSlot3;

	public static ConfigEntry<int> CustomMaxAscent;

	public static ConfigEntry<bool> DisableAscent13;

	public static void Init(ConfigFile config, ManualLogSource logger)
	{
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Expected O, but got Unknown
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Expected O, but got Unknown
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Expected O, but got Unknown
		Logger = logger;
		InfiniteStamina = config.Bind<bool>("Cheats", "InfiniteStamina", false, "Enable infinite stamina");
		TeleportToPing = config.Bind<bool>("Cheats", "TeleportToPing", false, "Automatically teleport to ping location");
		FlyMod = config.Bind<bool>("Cheats", "Fly Mod", false, "Enables fly mode when checked.");
		FlySpeed = config.Bind<float>("Cheats", "Fly Speed", 100f, "Speed used when flying.");
		FlyAcceleration = config.Bind<float>("Cheats", "Fly Acceleration", 300f, "Acceleration used when flying.");
		Fullbright = config.Bind<bool>("Cheats", "Fullbright", false, "Remove darkness and shadows");
		EspToggle = config.Bind<bool>("Cheats", "ESP", false, "Render nameplates through walls");
		EspEnemies = config.Bind<bool>("Cheats", "EspEnemies", false, "Render red boxes around enemies");
		EspHazards = config.Bind<bool>("Cheats", "EspHazards", false, "Render yellow boxes around hazards");
		EspLuggage = config.Bind<bool>("Cheats", "EspLuggage", false, "Render cyan boxes around luggage");
		DevTagToggle = config.Bind<bool>("Cheats", "DevTag", true, "Adds a Crown Dev Tag to your username");
		LockStatus = config.Bind<bool>("Afflictions", "LockStatus", false, (ConfigDescription)null);
		NoWeight = config.Bind<bool>("Afflictions", "NoWeight", false, (ConfigDescription)null);
		SpeedMod = config.Bind<bool>("Character", "SpeedMod", false, (ConfigDescription)null);
		JumpMod = config.Bind<bool>("Character", "JumpMod", false, (ConfigDescription)null);
		NoFallDmg = config.Bind<bool>("Character", "NoFallDmg", false, (ConfigDescription)null);
		ClimbMod = config.Bind<bool>("Character", "ClimbMod", false, (ConfigDescription)null);
		VineClimbMod = config.Bind<bool>("Character", "VineClimbMod", false, (ConfigDescription)null);
		RopeClimbMod = config.Bind<bool>("Character", "RopeClimbMod", false, (ConfigDescription)null);
		SpeedAmount = config.Bind<float>("Character", "SpeedAmount", 1f, (ConfigDescription)null);
		JumpAmount = config.Bind<float>("Character", "JumpAmount", 10f, (ConfigDescription)null);
		ClimbAmount = config.Bind<float>("Character", "ClimbAmount", 1f, (ConfigDescription)null);
		VineClimbAmount = config.Bind<float>("Character", "VineClimbAmount", 1f, (ConfigDescription)null);
		RopeClimbAmount = config.Bind<float>("Character", "RopeClimbAmount", 1f, (ConfigDescription)null);
		RechargeAmountSlot1 = config.Bind<float>("Inventory", "RechargeAmountSlot1", 100f, new ConfigDescription("Recharge amount for slot 1", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 999f), Array.Empty<object>()));
		RechargeAmountSlot2 = config.Bind<float>("Inventory", "RechargeAmountSlot2", 100f, new ConfigDescription("Recharge amount for slot 2", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 999f), Array.Empty<object>()));
		RechargeAmountSlot3 = config.Bind<float>("Inventory", "RechargeAmountSlot3", 100f, new ConfigDescription("Recharge amount for slot 3", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 999f), Array.Empty<object>()));
		CustomMaxAscent = config.Bind<int>("Ascents", "CustomMaxAscent", 0, "Tracks unlocks past the Steam limit.");
		DisableAscent13 = config.Bind<bool>("Ascents", "DisableAscent13", false, "Disables the Occult Statue gimmick.");
		Logger.LogInfo((object)"[PEAK AIO][ConfigManager] Config Loaded.");
	}
}
internal static class ConstantFields
{
	private static PropertyInfo infiniteStaminaProp;

	private static PropertyInfo statusLockProp;

	private static FieldInfo fallDamageTimeField;

	private static FieldInfo staminaField;

	private static FieldInfo movementModifierField;

	private static FieldInfo jumpGravityField;

	private static FieldInfo climbSpeedModField;

	private static FieldInfo vineClimbSpeedModField;

	private static FieldInfo ropeClimbSpeedModField;

	private static MethodInfo setStatusMethod;

	private static Array statusEnumValues;

	public static PropertyInfo GetInfiniteStaminaProperty()
	{
		if (infiniteStaminaProp == null)
		{
			infiniteStaminaProp = typeof(Character).GetProperty("infiniteStam", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return infiniteStaminaProp;
	}

	public static PropertyInfo GetStatusLockProperty()
	{
		if (statusLockProp == null)
		{
			statusLockProp = typeof(Character).GetProperty("statusesLocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return statusLockProp;
	}

	public static FieldInfo GetFallDamageTimeField()
	{
		if (fallDamageTimeField == null)
		{
			fallDamageTimeField = typeof(CharacterMovement).GetField("fallDamageTime", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return fallDamageTimeField;
	}

	public static FieldInfo GetStaminaField()
	{
		if (staminaField == null)
		{
			staminaField = typeof(CharacterData).GetField("_stam", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return staminaField;
	}

	public static FieldInfo GetMovementModifierField()
	{
		if (movementModifierField == null)
		{
			movementModifierField = typeof(CharacterMovement).GetField("movementModifier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return movementModifierField;
	}

	public static FieldInfo GetJumpGravityField()
	{
		if (jumpGravityField == null)
		{
			jumpGravityField = typeof(CharacterMovement).GetField("jumpGravity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return jumpGravityField;
	}

	public static FieldInfo GetClimbSpeedModField()
	{
		if (climbSpeedModField == null)
		{
			climbSpeedModField = typeof(CharacterClimbing).GetField("climbSpeedMod", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return climbSpeedModField;
	}

	public static FieldInfo GetVineClimbSpeedModField()
	{
		if (vineClimbSpeedModField == null)
		{
			vineClimbSpeedModField = typeof(CharacterVineClimbing).GetField("climbSpeedMod", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return vineClimbSpeedModField;
	}

	public static FieldInfo GetRopeClimbSpeedModField()
	{
		if (ropeClimbSpeedModField == null)
		{
			ropeClimbSpeedModField = typeof(CharacterRopeHandling).GetField("climbSpeedMod", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return ropeClimbSpeedModField;
	}

	public static MethodInfo GetSetStatusMethod()
	{
		if (setStatusMethod == null)
		{
			setStatusMethod = typeof(CharacterAfflictions).GetMethod("SetStatus", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		return setStatusMethod;
	}

	public static Array GetStatusEnumValues()
	{
		if (statusEnumValues == null)
		{
			statusEnumValues = Enum.GetValues(typeof(STATUSTYPE));
		}
		return statusEnumValues;
	}

	public static void RefreshAll()
	{
		infiniteStaminaProp = null;
		statusLockProp = null;
		fallDamageTimeField = null;
		staminaField = null;
		movementModifierField = null;
		jumpGravityField = null;
		climbSpeedModField = null;
		vineClimbSpeedModField = null;
		ropeClimbSpeedModField = null;
		setStatusMethod = null;
		statusEnumValues = null;
	}
}
public class EventComponent : MonoBehaviour
{
	private void Update()
	{
		CharacterMovement movementComponent = GameHelpers.GetMovementComponent();
		if ((Object)(object)movementComponent != (Object)null)
		{
			if (ConfigManager.SpeedMod.Value)
			{
				ConstantFields.GetMovementModifierField()?.SetValue(movementComponent, ConfigManager.SpeedAmount.Value);
			}
			if (ConfigManager.JumpMod.Value)
			{
				ConstantFields.GetJumpGravityField()?.SetValue(movementComponent, ConfigManager.JumpAmount.Value);
				if (ConfigManager.NoFallDmg.Value)
				{
					ConstantFields.GetFallDamageTimeField()?.SetValue(movementComponent, 999f);
				}
			}
		}
		Character characterComponent = GameHelpers.GetCharacterComponent();
		if ((Object)(object)characterComponent != (Object)null)
		{
			if (ConfigManager.InfiniteStamina.Value)
			{
				ConstantFields.GetInfiniteStaminaProperty()?.SetValue(characterComponent, true);
			}
			if (ConfigManager.LockStatus.Value)
			{
				ConstantFields.GetStatusLockProperty()?.SetValue(characterComponent, true);
			}
		}
		CharacterClimbing climbingComponent = GameHelpers.GetClimbingComponent();
		if ((Object)(object)climbingComponent != (Object)null && ConfigManager.ClimbMod.Value)
		{
			ConstantFields.GetClimbSpeedModField()?.SetValue(climbingComponent, ConfigManager.ClimbAmount.Value);
		}
		CharacterVineClimbing vineClimbComponent = GameHelpers.GetVineClimbComponent();
		if ((Object)(object)vineClimbComponent != (Object)null && ConfigManager.VineClimbMod.Value)
		{
			ConstantFields.GetVineClimbSpeedModField()?.SetValue(vineClimbComponent, ConfigManager.VineClimbAmount.Value);
		}
		CharacterRopeHandling ropeClimbComponent = GameHelpers.GetRopeClimbComponent();
		if ((Object)(object)ropeClimbComponent != (Object)null && ConfigManager.RopeClimbMod.Value)
		{
			ConstantFields.GetRopeClimbSpeedModField()?.SetValue(ropeClimbComponent, ConfigManager.RopeClimbAmount.Value);
		}
	}
}
internal static class GameHelpers
{
	private static Character character;

	private static CharacterData characterData;

	private static CharacterMovement movementComponent;

	private static CharacterAfflictions afflictionsComponent;

	private static CharacterClimbing climbingComponent;

	private static CharacterVineClimbing vineClimbingComponent;

	private static CharacterRopeHandling ropeClimbingComponent;

	public static Character GetCharacterComponent()
	{
		if ((Object)(object)character == (Object)null)
		{
			character = Character.localCharacter;
		}
		return character;
	}

	public static CharacterData GetCharacterData()
	{
		if ((Object)(object)characterData == (Object)null)
		{
			characterData = Object.FindFirstObjectByType<CharacterData>();
		}
		return characterData;
	}

	public static CharacterMovement GetMovementComponent()
	{
		Character characterComponent = GetCharacterComponent();
		if ((Object)(object)characterComponent == (Object)null)
		{
			return null;
		}
		if ((Object)(object)movementComponent == (Object)null)
		{
			movementComponent = ((Component)characterComponent).GetComponent<CharacterMovement>();
		}
		return movementComponent;
	}

	public static CharacterAfflictions GetAfflictionsComponent()
	{
		Character characterComponent = GetCharacterComponent();
		if ((Object)(object)characterComponent == (Object)null)
		{
			return null;
		}
		if ((Object)(object)afflictionsComponent == (Object)null)
		{
			afflictionsComponent = ((Component)characterComponent).GetComponent<CharacterAfflictions>();
		}
		return afflictionsComponent;
	}

	public static CharacterClimbing GetClimbingComponent()
	{
		Character characterComponent = GetCharacterComponent();
		if ((Object)(object)characterComponent == (Object)null)
		{
			return null;
		}
		if ((Object)(object)climbingComponent == (Object)null)
		{
			climbingComponent = ((Component)characterComponent).GetComponent<CharacterClimbing>();
		}
		return climbingComponent;
	}

	public static CharacterVineClimbing GetVineClimbComponent()
	{
		Character characterComponent = GetCharacterComponent();
		if ((Object)(object)characterComponent == (Object)null)
		{
			return null;
		}
		if ((Object)(object)vineClimbingComponent == (Object)null)
		{
			vineClimbingComponent = ((Component)characterComponent).GetComponent<CharacterVineClimbing>();
		}
		return vineClimbingComponent;
	}

	public static CharacterRopeHandling GetRopeClimbComponent()
	{
		Character characterComponent = GetCharacterComponent();
		if ((Object)(object)characterComponent == (Object)null)
		{
			return null;
		}
		if ((Object)(object)ropeClimbingComponent == (Object)null)
		{
			ropeClimbingComponent = ((Component)characterComponent).GetComponent<CharacterRopeHandling>();
		}
		return ropeClimbingComponent;
	}

	public static void Refresh()
	{
		character = null;
		characterData = null;
		movementComponent = null;
		afflictionsComponent = null;
		climbingComponent = null;
		vineClimbingComponent = null;
		ropeClimbingComponent = null;
	}
}
public static class Globals
{
	public static bool anyAfflictionEnabled;

	public static Character character;

	public static CharacterData characterData;

	public static FieldInfo staminaField;

	public static PropertyInfo infiniteStamProp;

	public static FieldInfo sinceFallSlideField;

	public static FieldInfo sinceGroundedField;

	public static object movementComp;

	public static FieldInfo movementModifierField;

	public static FieldInfo jumpGravityField;

	public static FieldInfo fallDamageTimeField;

	public static object characterClimb;

	public static FieldInfo climbSpeedModifierField;

	public static object characterVineClimb;

	public static FieldInfo vineClimbSpeedModifierField;

	public static object characterRopeHandling;

	public static FieldInfo ropeClimbSpeedModifierField;

	public static object afflictionsObj;

	public static MethodInfo setStatusMethod;

	public static object weightEnumValue;

	public static object poisonEnumValue;

	public static object hotEnumValue;

	public static object coldEnumValue;

	public static object curseEnumValue;

	public static object injuryEnumValue;

	public static object drowsyEnumValue;

	public static object hungerEnumValue;

	public static List<Item> items = new List<Item>();

	public static List<string> itemNames = new List<string>();

	public static int[] selectedItems = new int[3] { -1, -1, -1 };

	public static string[] itemDisplayNames = new string[3] { "None", "None", "None" };

	public static string[] itemSearchBuffers = new string[3];

	public static Player playerObj;

	public static List<Character> allPlayers = new List<Character>();

	public static List<string> playerNames = new List<string>();

	public static int selectedPlayer = -1;

	public static bool excludeSelfFromAllActions = true;

	public static bool teleportToPingEnabled = false;

	public static float teleportX = 0f;

	public static float teleportY = 0f;

	public static float teleportZ = 0f;

	public static int selectedLuggageIndex = -1;

	public static List<string> luggageLabels = new List<string>();

	public static List<Luggage> luggageObject = new List<Luggage>();

	public static List<Luggage> allOpenedLuggage = new List<Luggage>();
}
[HarmonyPatch(typeof(PointPinger), "ReceivePoint_Rpc")]
public class PointPingPatch
{
	private static void Postfix(Vector3 point, Vector3 hitNormal, PointPinger __instance)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (ConfigManager.TeleportToPing.Value)
			{
				Character character = __instance.character;
				object obj;
				if (character == null)
				{
					obj = null;
				}
				else
				{
					PhotonView photonView = ((MonoBehaviourPun)character).photonView;
					obj = ((photonView != null) ? photonView.Owner : null);
				}
				Player val = (Player)obj;
				if (val != null && val == PhotonNetwork.LocalPlayer && (Object)(object)Character.localCharacter != (Object)null && !Character.localCharacter.data.dead)
				{
					Utilities.WarpSelf(point + Vector3.up, poof: true);
					ConfigManager.Logger.LogInfo((object)"[Patch] Teleported to ping!");
				}
			}
		}
		catch (Exception ex)
		{
			ConfigManager.Logger.LogError((object)("[Patch] Exception: " + ex));
		}
	}
}
[HarmonyPatch(typeof(Character), "Update")]
public class FlyPatch
{
	private static bool isFlying = false;

	private static Vector3 flyVelocity = Vector3.zero;

	public static bool IsFlying => isFlying;

	public static void SetFlying(bool enable)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		isFlying = enable;
		flyVelocity = Vector3.zero;
	}

	private static void Postfix(Character __instance)
	{
		//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_0082: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: 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_00b5: 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_0022: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: 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_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		if (!__instance.IsLocal)
		{
			return;
		}
		if (!ConfigManager.FlyMod.Value)
		{
			if (isFlying)
			{
				isFlying = false;
				flyVelocity = Vector3.zero;
			}
			return;
		}
		if (!isFlying)
		{
			isFlying = true;
		}
		__instance.data.isGrounded = true;
		__instance.data.sinceGrounded = 0f;
		__instance.data.sinceJump = 0f;
		Vector3 val = Vector2.op_Implicit(__instance.input.movementInput);
		Vector3 normalized = ((Vector3)(ref __instance.data.lookDirection_Flat)).normalized;
		Vector3 val2 = Vector3.Cross(Vector3.up, normalized);
		Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
		Vector3 val3 = normalized * val.y + normalized2 * val.x;
		if (__instance.input.jumpIsPressed)
		{
			val3 += Vector3.up;
		}
		if (__instance.input.crouchIsPressed)
		{
			val3 += Vector3.down;
		}
		float value = ConfigManager.FlySpeed.Value;
		float value2 = ConfigManager.FlyAcceleration.Value;
		flyVelocity = Vector3.Lerp(flyVelocity, ((Vector3)(ref val3)).normalized * value, Time.deltaTime * value2);
		foreach (Bodypart part in __instance.refs.ragdoll.partList)
		{
			if ((Object)(object)((part != null) ? part.Rig : null) != (Object)null)
			{
				part.Rig.linearVelocity = flyVelocity;
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")]
public class Patch_UpdateWeight
{
	private static void Postfix(CharacterAfflictions __instance)
	{
		if (ConfigManager.NoWeight.Value)
		{
			__instance.SetStatus((STATUSTYPE)7, 0f, true);
		}
	}
}
public class LightVolume_Fullbright_Patch
{
	private static Texture3D whiteTex;

	public static void Postfix(object __instance)
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		if (ConfigManager.Fullbright == null || !ConfigManager.Fullbright.Value)
		{
			return;
		}
		if ((Object)(object)whiteTex == (Object)null)
		{
			whiteTex = new Texture3D(2, 2, 2, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[8];
			for (int i = 0; i < 8; i++)
			{
				array[i] = Color.white;
			}
			whiteTex.SetPixels(array);
			whiteTex.Apply();
		}
		Shader.SetGlobalTexture("_LightMap", (Texture)(object)whiteTex);
		Shader.SetGlobalColor("_SkyColor", Color.white);
	}
}
public static class Utilities
{
	public static ManualLogSource Logger;

	private static MethodInfo _warpPlayer;

	public static bool hasInitializedLuggageList;

	public static void WarpSelf(Vector3 pos, bool poof)
	{
		//IL_0047: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		Character localCharacter = Character.localCharacter;
		if ((Object)(object)localCharacter == (Object)null || (Object)(object)((MonoBehaviourPun)localCharacter).photonView == (Object)null)
		{
			return;
		}
		if (!PhotonNetwork.InRoom || PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient)
		{
			((MonoBehaviourPun)localCharacter).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { pos, poof });
			return;
		}
		if (_warpPlayer == null)
		{
			_warpPlayer = typeof(Character).GetMethod("WarpPlayer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2]
			{
				typeof(Vector3),
				typeof(bool)
			}, null);
		}
		if (_warpPlayer != null)
		{
			_warpPlayer.Invoke(localCharacter, new object[2] { pos, poof });
		}
		else
		{
			((MonoBehaviourPun)localCharacter).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { pos, poof });
		}
	}

	private static bool RequireHost(string what)
	{
		if (!PhotonNetwork.InRoom || PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient)
		{
			return true;
		}
		ManualLogSource logger = Logger;
		if (logger != null)
		{
			logger.LogWarning((object)("[Lobby] " + what + ": only the host can do this since PEAK 3.1."));
		}
		return false;
	}

	public static void GetPlayer()
	{
		if ((Object)(object)Globals.playerObj == (Object)null)
		{
			Globals.playerObj = Player.localPlayer;
		}
	}

	public static void UpdateItems()
	{
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		Globals.items.Clear();
		Globals.itemNames.Clear();
		for (int i = 0; i < 3; i++)
		{
			Globals.selectedItems[i] = -1;
		}
		Dictionary<string, Item> dictionary = new Dictionary<string, Item>(StringComparer.OrdinalIgnoreCase);
		try
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			if ((Object)(object)instance != (Object)null && instance.itemLookup != null)
			{
				foreach (KeyValuePair<ushort, Item> item in instance.itemLookup)
				{
					if ((Object)(object)item.Value != (Object)null && !dictionary.ContainsKey(((Object)((Component)item.Value).gameObject).name))
					{
						dictionary[((Object)((Component)item.Value).gameObject).name] = item.Value;
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogWarning((object)("[Inventory] ItemDatabase read failed: " + ex.Message));
			}
		}
		if (dictionary.Count == 0)
		{
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(Item));
			foreach (Object obj in array)
			{
				Item val = (Item)(object)((obj is Item) ? obj : null);
				if (!((Object)(object)val != (Object)null))
				{
					continue;
				}
				Scene scene = ((Component)val).gameObject.scene;
				if (((Scene)(ref scene)).handle == SceneHandle.op_Implicit(0))
				{
					scene = ((Component)val).gameObject.scene;
					if (string.IsNullOrEmpty(((Scene)(ref scene)).name) && !dictionary.ContainsKey(((Object)((Component)val).gameObject).name))
					{
						dictionary[((Object)((Component)val).gameObject).name] = val;
					}
				}
			}
		}
		foreach (KeyValuePair<string, Item> item2 in dictionary.OrderBy<KeyValuePair<string, Item>, string>((KeyValuePair<string, Item> k) => k.Key, StringComparer.OrdinalIgnoreCase))
		{
			Globals.items.Add(item2.Value);
			Globals.itemNames.Add(item2.Key);
		}
	}

	public static void AssignInventoryItem(int slot, int itemIndex)
	{
		if (itemIndex >= 0 && itemIndex < Globals.items.Count)
		{
			AssignInventoryPrefab(slot, Globals.items[itemIndex]);
		}
	}

	public static void AssignInventoryPrefab(int slot, Item prefab)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected O, but got Unknown
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		GetPlayer();
		if (!((Object)(object)Globals.playerObj == (Object)null) && !((Object)(object)prefab == (Object)null) && Globals.playerObj.itemSlots != null && Globals.playerObj.itemSlots.Length > slot)
		{
			ItemSlot obj = Globals.playerObj.itemSlots[slot];
			ItemInstanceData val = new ItemInstanceData(Guid.NewGuid());
			ItemInstanceDataHandler.AddInstanceData(val);
			obj.SetItem(prefab, val);
			byte[] array = IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(Globals.playerObj.itemSlots, Globals.playerObj.backpackSlot, Globals.playerObj.tempFullSlot));
			((MonoBehaviourPun)Globals.playerObj).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2] { array, true });
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogInfo((object)$"[Inventory] Assigned {((Object)((Component)prefab).gameObject).name} to slot {slot}");
			}
		}
	}

	public static void RechargeInventorySlot(int slot, float rechargeValue)
	{
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Invalid comparison between Unknown and I4
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Invalid comparison between Unknown and I4
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Invalid comparison between Unknown and I4
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Invalid comparison between Unknown and I4
		GetPlayer();
		if ((Object)(object)Globals.playerObj == (Object)null)
		{
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogError((object)"[PEAK AIO] Player is null during inventory operation");
			}
		}
		else
		{
			if (!((Object)(object)Globals.playerObj != (Object)null) || Globals.playerObj.itemSlots == null || Globals.playerObj.itemSlots.Length <= slot)
			{
				return;
			}
			ItemSlot val = Globals.playerObj.itemSlots[slot];
			if (((val == null) ? null : val.data?.data) != null)
			{
				foreach (KeyValuePair<DataEntryKey, DataEntryValue> datum in val.data.data)
				{
					if ((int)datum.Key == 12)
					{
						DataEntryValue value = datum.Value;
						IntItemData val2 = (IntItemData)(object)((value is IntItemData) ? value : null);
						if (val2 != null)
						{
							val2.Value = (int)rechargeValue;
							continue;
						}
					}
					if ((int)datum.Key == 10)
					{
						DataEntryValue value2 = datum.Value;
						FloatItemData val3 = (FloatItemData)(object)((value2 is FloatItemData) ? value2 : null);
						if (val3 != null)
						{
							val3.Value = rechargeValue;
							continue;
						}
					}
					if ((int)datum.Key == 11)
					{
						DataEntryValue value3 = datum.Value;
						FloatItemData val4 = (FloatItemData)(object)((value3 is FloatItemData) ? value3 : null);
						if (val4 != null)
						{
							val4.Value = rechargeValue;
							continue;
						}
					}
					if ((int)datum.Key == 2)
					{
						DataEntryValue value4 = datum.Value;
						OptionableIntItemData val5 = (OptionableIntItemData)(object)((value4 is OptionableIntItemData) ? value4 : null);
						if (val5 != null)
						{
							val5.Value = (int)rechargeValue;
						}
					}
				}
			}
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogInfo((object)$"[Inventory] Recharged slot {slot} to {rechargeValue}");
			}
		}
	}

	public static void RefreshPlayerList()
	{
		try
		{
			Globals.allPlayers.Clear();
			Globals.playerNames.Clear();
			Globals.selectedPlayer = -1;
			if (Character.AllCharacters != null)
			{
				foreach (Character allCharacter in Character.AllCharacters)
				{
					if ((Object)(object)allCharacter != (Object)null && (Object)(object)((Component)allCharacter).gameObject != (Object)null)
					{
						Globals.allPlayers.Add(allCharacter);
						Globals.playerNames.Add(string.IsNullOrEmpty(allCharacter.characterName) ? "Unknown" : allCharacter.characterName);
					}
				}
			}
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogInfo((object)$"[PlayerList] Found {Globals.allPlayers.Count} active players.");
			}
		}
		catch (Exception arg)
		{
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)$"[PlayerList] Error: {arg}");
			}
		}
	}

	private static bool IsTargetValid(int index)
	{
		if (index < 0 || index >= Globals.allPlayers.Count)
		{
			return false;
		}
		Character val = Globals.allPlayers[index];
		if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null || (Object)(object)((MonoBehaviourPun)val).photonView == (Object)null)
		{
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogWarning((object)"[Lobby] Stale player reference detected. Auto-refreshing list.");
			}
			RefreshPlayerList();
			return false;
		}
		return true;
	}

	public static void ReviveAllPlayers()
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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)
		RefreshPlayerList();
		foreach (Character allPlayer in Globals.allPlayers)
		{
			if (!((Object)(object)((MonoBehaviourPun)allPlayer).photonView == (Object)null))
			{
				Vector3 val = (((Object)(object)allPlayer.Ghost != (Object)null) ? ((Component)allPlayer.Ghost).transform.position : allPlayer.Head);
				((MonoBehaviourPun)allPlayer).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3]
				{
					val + new Vector3(0f, 4f, 0f),
					false,
					-1
				});
			}
		}
		ManualLogSource logger = Logger;
		if (logger != null)
		{
			logger.LogInfo((object)"[Lobby] Revive All triggered.");
		}
	}

	public static void KillAllPlayers()
	{
		if (!RequireHost("Kill All"))
		{
			return;
		}
		RefreshPlayerList();
		foreach (Character allPlayer in Globals.allPlayers)
		{
			if (!((Object)(object)((MonoBehaviourPun)allPlayer).photonView == (Object)null) && (!Globals.excludeSelfFromAllActions || !allPlayer.IsLocal))
			{
				((MonoBehaviourPun)allPlayer).photonView.RPC("RPCA_Die", (RpcTarget)0, Array.Empty<object>());
			}
		}
		ManualLogSource logger = Logger;
		if (logger != null)
		{
			logger.LogInfo((object)$"[Lobby] Kill All triggered. ExcludeSelf: {Globals.excludeSelfFromAllActions}");
		}
	}

	public static void WarpAllPlayersToMe()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		if (!RequireHost("Warp All To Me"))
		{
			return;
		}
		RefreshPlayerList();
		if ((Object)(object)Character.localCharacter == (Object)null)
		{
			return;
		}
		Vector3 val = Character.localCharacter.Head + new Vector3(0f, 4f, 0f);
		foreach (Character allPlayer in Globals.allPlayers)
		{
			if (!((Object)(object)((MonoBehaviourPun)allPlayer).photonView == (Object)null) && !allPlayer.IsLocal)
			{
				((MonoBehaviourPun)allPlayer).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val, true });
			}
		}
		ManualLogSource logger = Logger;
		if (logger != null)
		{
			logger.LogInfo((object)"[Lobby] Warp All To Me triggered.");
		}
	}

	public static void ReviveSelectedPlayer()
	{
		//IL_003f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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)
		if (!IsTargetValid(Globals.selectedPlayer))
		{
			return;
		}
		try
		{
			Character val = Globals.allPlayers[Globals.selectedPlayer];
			Vector3 val2 = (((Object)(object)val.Ghost != (Object)null) ? ((Component)val.Ghost).transform.position : val.Head);
			((MonoBehaviourPun)val).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3]
			{
				val2 + new Vector3(0f, 4f, 0f),
				false,
				-1
			});
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogInfo((object)("[Lobby] Revive requested for " + val.characterName));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)ex);
			}
		}
	}

	public static void KillSelectedPlayer()
	{
		if (!RequireHost("Kill player") || !IsTargetValid(Globals.selectedPlayer))
		{
			return;
		}
		try
		{
			Character val = Globals.allPlayers[Globals.selectedPlayer];
			((MonoBehaviourPun)val).photonView.RPC("RPCA_Die", (RpcTarget)0, Array.Empty<object>());
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogInfo((object)("[Lobby] Kill requested for " + val.characterName));
			}
		}
		catch (Exception ex)
		{
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)ex);
			}
		}
	}

	public static void WarpToSelectedPlayer()
	{
		//IL_001f: 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_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		if (!IsTargetValid(Globals.selectedPlayer))
		{
			return;
		}
		try
		{
			Character val = Globals.allPlayers[Globals.selectedPlayer];
			Vector3 pos = val.Head + new Vector3(0f, 4f, 0f);
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)((localCharacter != null) ? ((MonoBehaviourPun)localCharacter).photonView : null) != (Object)null)
			{
				WarpSelf(pos, poof: true);
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)("[Lobby] Warping local player to " + val.characterName));
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)ex);
			}
		}
	}

	public static void WarpSelectedPlayerToMe()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		if (!RequireHost("Bring player") || !IsTargetValid(Globals.selectedPlayer))
		{
			return;
		}
		try
		{
			Character val = Globals.allPlayers[Globals.selectedPlayer];
			if (!((Object)(object)Character.localCharacter == (Object)null))
			{
				Vector3 val2 = Character.localCharacter.Head + new Vector3(0f, 4f, 0f);
				((MonoBehaviourPun)val).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val2, true });
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)("[Lobby] Warping " + val.characterName + " to local player"));
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)ex);
			}
		}
	}

	public static void ApplyDeveloperTag()
	{
		string text = "\ud83d\udc51 [DEV] ";
		if (PhotonNetwork.LocalPlayer != null)
		{
			string nickName = PhotonNetwork.LocalPlayer.NickName;
			if (!string.IsNullOrEmpty(nickName) && !nickName.StartsWith(text))
			{
				PhotonNetwork.LocalPlayer.NickName = text + nickName;
			}
		}
		if (!((Object)(object)Character.localCharacter != (Object)null))
		{
			return;
		}
		string characterName = Character.localCharacter.characterName;
		if (string.IsNullOrEmpty(characterName) || characterName.StartsWith(text))
		{
			return;
		}
		string value = text + characterName;
		PropertyInfo property = typeof(Character).GetProperty("characterName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (property != null && property.CanWrite)
		{
			property.SetValue(Character.localCharacter, value);
			return;
		}
		FieldInfo field = typeof(Character).GetField("<characterName>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);
		if (field != null)
		{
			field.SetValue(Character.localCharacter, value);
			return;
		}
		FieldInfo fieldInfo = typeof(Character).GetField("_characterName", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(Character).GetField("m_characterName", BindingFlags.Instance | BindingFlags.NonPublic);
		if (fieldInfo != null)
		{
			fieldInfo.SetValue(Character.localCharacter, value);
		}
	}

	public static void SpawnTestDummy()
	{
		//IL_0034: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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)
		if (!PhotonNetwork.IsMasterClient)
		{
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogWarning((object)"[Dummy] You must be the Host to spawn the dummy.");
			}
		}
		else
		{
			if ((Object)(object)Character.localCharacter == (Object)null)
			{
				return;
			}
			Vector3 val = ((Component)Character.localCharacter).transform.position + ((Component)Character.localCharacter).transform.forward * 3f;
			GameObject val2 = PhotonNetwork.InstantiateRoomObject("Character_Scoutmaster", val, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val2 != (Object)null)
			{
				Scoutmaster component = val2.GetComponent<Scoutmaster>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				ManualLogSource logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)"[Dummy] Spawned static test dummy.");
				}
			}
		}
	}

	public static void ProcessWorldCheats()
	{
	}

	public static void TeleportToCoords(float x, float y, float z)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead)
			{
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					logger.LogWarning((object)"[Teleport] Local character is null or dead. Aborting teleport.");
				}
			}
			else if (!((Object)(object)((MonoBehaviourPun)localCharacter).photonView == (Object)null))
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(x, y, z);
				WarpSelf(val, poof: true);
				ManualLogSource logger2 = Logger;
				if (logger2 != null)
				{
					logger2.LogInfo((object)$"[Teleport] Teleported to {val}");
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource logger3 = Logger;
			if (logger3 != null)
			{
				logger3.LogError((object)("[Teleport] Exception: " + ex));
			}
		}
	}

	public static void EnsureLuggageListInitialized()
	{
		if (!hasInitializedLuggageList)
		{
			hasInitializedLuggageList = true;
			RefreshLuggageList();
		}
	}

	public static void RefreshLuggageList()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		Globals.luggageLabels.Clear();
		Globals.luggageObject.Clear();
		Globals.selectedLuggageIndex = -1;
		if ((Object)(object)Character.localCharacter == (Object)null)
		{
			return;
		}
		List<(Luggage, float)> list = new List<(Luggage, float)>();
		foreach (Luggage item3 in Luggage.ALL_LUGGAGE)
		{
			if (!((Object)(object)item3 == (Object)null))
			{
				float num = Vector3.Distance(Character.localCharacter.Head, item3.Center());
				if (num <= 300f)
				{
					list.Add((item3, num));
				}
			}
		}
		list.Sort(((Luggage lug, float distance) a, (Luggage lug, float distance) b) => a.distance.CompareTo(b.distance));
		foreach (var item4 in list)
		{
			Luggage item = item4.Item1;
			float item2 = item4.Item2;
			string arg = item.displayName ?? "Unnamed";
			Globals.luggageLabels.Add($"{arg} [{item2:F1}m]");
			Globals.luggageObject.Add(item);
		}
		ManualLogSource logger = Logger;
		if (logger != null)
		{
			logger.LogInfo((object)$"[Luggage] Refreshed. Found {Globals.luggageLabels.Count} nearby.");
		}
	}

	public static void OpenAllNearbyLuggage()
	{
		int num = 0;
		for (int i = 0; i < Globals.luggageObject.Count; i++)
		{
			Luggage val = Globals.luggageObject[i];
			if (!((Object)(object)val == (Object)null))
			{
				PhotonView component = ((Component)val).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null)
				{
					component.RPC("OpenLuggageRPC", (RpcTarget)0, new object[1] { true });
					num++;
				}
			}
		}
		ManualLogSource logger = Logger;
		if (logger != null)
		{
			logger.LogInfo((object)$"[Luggage] Requested open for {num} nearby containers.");
		}
	}

	public static void OpenLuggage(int index)
	{
		if (index < 0 || index >= Globals.luggageObject.Count)
		{
			return;
		}
		Luggage val = Globals.luggageObject[index];
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		try
		{
			PhotonView component = ((Component)val).GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null)
			{
				component.RPC("OpenLuggageRPC", (RpcTarget)0, new object[1] { true });
				ManualLogSource logger = Logger;
				if (logger != null)
				{
					logger.LogInfo((object)("[Luggage] Sent OpenLuggageRPC for: " + val.displayName));
				}
			}
		}
		catch (Exception arg)
		{
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogError((object)$"[Luggage] Open failed: {arg}");
			}
		}
	}

	public static async void SpawnScoutmasterForPlayer(int playerIndex)
	{
		if (!PhotonNetwork.IsMasterClient)
		{
			ManualLogSource logger = Logger;
			if (logger != null)
			{
				logger.LogWarning((object)"[Scoutmaster] Only the MasterClient can spawn the Scoutmaster.");
			}
			return;
		}
		if (playerIndex < 0 || playerIndex >= Character.AllCharacters.Count)
		{
			ManualLogSource logger2 = Logger;
			if (logger2 != null)
			{
				logger2.LogWarning((object)"[Scoutmaster] Invalid player index.");
			}
			return;
		}
		Character targetCharacter = Character.AllCharacters[playerIndex];
		if ((Object)(object)targetCharacter == (Object)null)
		{
			return;
		}
		Vector3 val = ((Component)targetCharacter).transform.position + new Vector3(Random.Range(-10f, 10f), 25f, Random.Range(-10f, 10f));
		Vector3 down = Vector3.down;
		RaycastHit val2 = default(RaycastHit);
		if (Physics.Raycast(val, down, ref val2, 100f, -1))
		{
			Vector3 val3 = ((RaycastHit)(ref val2)).point + Vector3.up * 1f;
			Quaternion identity = Quaternion.identity;
			GameObject scoutObj = PhotonNetwork.InstantiateRoomObject("Character_Scoutmaster", val3, identity, (byte)0, (object[])null);
			Character component = scoutObj.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.data.spawnPoint = ((Component)component).transform;
			}
			await Task.Delay(100);
			Scoutmaster component2 = scoutObj.GetComponent<Scoutmaster>();
			if (!((Object)(object)component2 != (Object)null))
			{
				return;
			}
			try
			{
				MethodInfo method = typeof(Scoutmaster).GetMethod("SetCurrentTarget", BindingFlags.Instance | BindingFlags.NonPublic);
				if (method != null)
				{
					method.Invoke(component2, new object[2] { targetCharacter, 15f });
					ManualLogSource logger3 = Logger;
					if (logger3 != null)
					{
						logger3.LogInfo((object)("[Scoutmaster] Target set to " + targetCharacter.characterName));
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger4 = Logger;
				if (logger4 != null)
				{
					logger4.LogError((object)("[Scoutmaster] Reflection error: " + ex));
				}
			}
		}
		else
		{
			ManualLogSource logger5 = Logger;
			if (logger5 != null)
			{
				logger5.LogWarning((object)"[Scoutmaster] No valid ground to spawn.");
			}
		}
	}
}
namespace PEAK_AIO
{
	public class AscentGimmick
	{
		public AscentStruct _ascentData;

		public bool active;

		public virtual string GetTitle()
		{
			return "";
		}

		public virtual string GetDescription()
		{
			return "";
		}

		public virtual Color GetColor()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return Color.red;
		}

		public virtual string GetTitleReward()
		{
			return "";
		}

		public virtual void CharacterPassedOut(Character character)
		{
		}

		public virtual void OnLavaExisted(Lava lava)
		{
		}

		public virtual void OnFogInitNewSphere(OrbFogHandler __instance)
		{
		}

		public virtual void OnCharacterFall(Character character)
		{
		}

		public virtual void RespawnChestExisted(Spawner chest)
		{
		}

		public virtual void OnFinishCooking(ItemCooking itemCooking)
		{
		}

		public virtual void SpawnerSpawnItems(Spawner spawner, ref List<Transform> spawnSpots)
		{
		}

		public virtual void OnGrabbedCharacter(Character thisCharacter)
		{
		}

		public virtual void OnUpdateNormalStatuses(Character character)
		{
		}

		public virtual void Update()
		{
		}

		public virtual float AfflictionMultiplier(CharacterAfflictions afflictions, STATUSTYPE statusType, float amount)
		{
			return 0f;
		}
	}
	public static class AscentGimmickHandler
	{
		internal static readonly List<AscentGimmick> gimmicks = new List<AscentGimmick>();

		private static readonly List<AscentInstanceData> pendingDatas = new List<AscentInstanceData>();

		private static bool HasInitialized = false;

		internal static int BaseAscents { get; private set; } = -1;

		internal static void MarkGimmicksAsActive(int ascentIndex)
		{
			int num = 0;
			foreach (AscentInstanceData ascent in SingletonAsset<AscentData>.Instance.ascents)
			{
				AscentGimmick gimmickByData = GetGimmickByData(ascent);
				if (num <= ascentIndex && gimmickByData != null)
				{
					gimmickByData.active = true;
					Plugin.Logger.LogWarning((object)("enabled gimmick " + gimmickByData.GetType().Name + " [" + gimmickByData.GetTitle() + "]!"));
				}
				num++;
			}
		}

		public static AscentGimmick GetGimmickByData(AscentInstanceData data)
		{
			foreach (AscentGimmick gimmick in gimmicks)
			{
				if (gimmick._ascentData.data == data)
				{
					return gimmick;
				}
			}
			return null;
		}

		internal static void DisableGimmicks()
		{
			foreach (AscentGimmick gimmick in gimmicks)
			{
				gimmick.active = false;
			}
		}

		internal static int GetBaseAscentCount()
		{
			if (BaseAscents == -1)
			{
				BaseAscents = SingletonAsset<AscentData>.Instance.ascents.Count;
			}
			return BaseAscents;
		}

		internal static void Initialize()
		{
			if (HasInitialized)
			{
				Plugin.Logger.LogError((object)"already initialized");
				return;
			}
			HasInitialized = true;
			AscentData instance = SingletonAsset<AscentData>.Instance;
			List<AscentInstanceData> ascents = instance.ascents;
			List<AscentInstanceData> list = new List<AscentInstanceData>();
			Plugin.Logger.LogInfo((object)$"initializing with ({pendingDatas.Count} custom) and ({ascents.Count} base)");
			foreach (AscentInstanceData item in ascents)
			{
				HotLoadAscentInstanceData(list, item);
			}
			foreach (AscentInstanceData pendingData in pendingDatas)
			{
				HotLoadAscentInstanceData(list, pendingData);
			}
			instance.ascents = list;
		}

		private static void HotLoadAscentInstanceData(List<AscentInstanceData> targetList, AscentInstanceData data)
		{
			if (data.titleReward == "")
			{
				data.titleReward = data.title + " Conqueror";
			}
			if ((Object)(object)data.sashSprite == (Object)null && (Object)(object)SingletonAsset<AscentData>.Instance != (Object)null && SingletonAsset<AscentData>.Instance.ascents != null && SingletonAsset<AscentData>.Instance.ascents.Count > 0)
			{
				data.sashSprite = SingletonAsset<AscentData>.Instance.ascents[0].sashSprite;
			}
			targetList.Add(data);
		}

		public static void RegisterAscent<T>() where T : AscentGimmick
		{
			//IL_000b: 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)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			AscentGimmick ascentGimmick = Activator.CreateInstance<T>();
			AscentInstanceData val = new AscentInstanceData
			{
				title = ascentGimmick.GetTitle(),
				description = ascentGimmick.GetDescription(),
				titleReward = ascentGimmick.GetTitleReward(),
				color = ascentGimmick.GetColor()
			};
			ascentGimmick._ascentData = new AscentStruct
			{
				data = val,
				order = 9 + (gimmicks.Count + 1)
			};
			gimmicks.Add(ascentGimmick);
			if (HasInitialized)
			{
				HotLoadAscentInstanceData(SingletonAsset<AscentData>.Instance.ascents, val);
				Plugin.Logger.LogInfo((object)("Hot loaded " + val.title + "!"));
				return;
			}
			pendingDatas.Add(val);
			Plugin.Logger.LogInfo((object)("Queued " + val.title));
			AddIdentityTranslation(ascentGimmick.GetTitle(), ascentGimmick.GetTitle());
			AddIdentityTranslation("DESC_" + ascentGimmick.GetTitle(), ascentGimmick.GetDescription());
			static void AddIdentityTranslation(string key, string text)
			{
				if (string.IsNullOrWhiteSpace(key))
				{
					throw new NotImplementedException($"translation was empty?? {typeof(T)}");
				}
				LocalizedText.mainTable.Add(key.ToUpperInvariant(), Enumerable.Repeat(text.ToUpperInvariant(), 14).ToList());
			}
		}
	}
	public struct AscentStruct
	{
		public AscentInstanceData data;

		public int order;
	}
	public class AfflictionGimmick : AscentGimmick
	{
		public override string GetTitle()
		{
			return "Ascent 10";
		}

		public override string GetDescription()
		{
			return "You're more vulnerable to everything but Injuries, Hunger and Weight.";
		}

		public override float AfflictionMultiplier(CharacterAfflictions affliction, STATUSTYPE statusType, float amount)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Invalid comparison between Unknown and I4
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			if ((int)statusType == 0 || (int)statusType == 1 || (int)statusType == 7 || !affliction.character.IsLocal || (CharacterPatches.UpdateNormalStatuses.InUpdateNormalStatuses && (int)statusType == 2))
			{
				return 0f;
			}
			if ((int)statusType == 6 || (int)statusType == 5)
			{
				return 1f;
			}
			return 2f;
		}
	}
	public class BingBongGimmick : AscentGimmick
	{
		private static float SinceLastShake;

		public override string GetDescription()
		{
			return "Bing Bong calls upon an evil force if not given attention.";
		}

		public override string GetTitle()
		{
			return "Chaos 4";
		}

		public override void Update()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			float deltaTime = Time.deltaTime;
			SinceLastShake += deltaTime;
			Item heldBingBongItem = BingBongPatches.heldBingBongItem;
			if ((Object)(object)heldBingBongItem != (Object)null && (int)heldBingBongItem.itemState == 1)
			{
				BingBongMechanics.BingBongUnheldFor = 0f;
			}
			else
			{
				BingBongMechanics.BingBongUnheldFor += deltaTime;
			}
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (allCharacter.IsLocal)
				{
					if (allCharacter.data.passedOutOnTheBeach > 0f)
					{
						BingBongMechanics.BingBongUnheldFor = 0f;
						break;
					}
					if (BingBongMechanics.BingBongUnheldFor > 10f && BingBongMechanics.BingBongUnheldFor <= 15f && SinceLastShake > 0f)
					{
						SinceLastShake = 0f;
						GamefeelHandler.instance.AddPerlinShake(0.7f, 0.15f, 15f);
					}
					if (BingBongMechanics.BingBongUnheldFor >= 15f)
					{
						allCharacter.refs.afflictions.AddStatus((STATUSTYPE)4, 0.05f * Time.deltaTime, false, true, true, false);
						break;
					}
				}
			}
		}
	}
	public class CampfireGimmick : AscentGimmick
	{
		public override string GetDescription()
		{
			return "Campfires are extremely hot.";
		}

		public override string GetTitle()
		{
			return "Chaos 2";
		}

		public override void OnFinishCooking(ItemCooking itemCooking)
		{
			itemCooking.wreckWhenCooked = true;
		}
	}
	public class SkeletonGimmick : AscentGimmick
	{
		public override string GetDescription()
		{
			return "Going unconscious is instant death.";
		}

		public override string GetTitle()
		{
			return "Chaos 1";
		}

		public override void CharacterPassedOut(Character character)
		{
			if (character.IsLocal)
			{
				((object)character).GetType().GetMethod("DieInstantly", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(character, Array.Empty<object>());
			}
		}
	}
	public class SunHotGimmick : AscentGimmick
	{
		public override string GetDescription()
		{
			return "The sun is very hot, don't get a heatstroke.";
		}

		public override string GetTitle()
		{
			return "Chaos 3";
		}

		public override void OnUpdateNormalStatuses(Character character)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			if (!character.IsLocal || DayNightManager.instance.isDay < 0.5f)
			{
				return;
			}
			MountainProgressHandler instance = Singleton<MountainProgressHandler>.Instance;
			if (!((Object)(object)instance == (Object)null) && instance.maxProgressPointReached < 3)
			{
				Vector3 val = -((Component)RenderSettings.sun).transform.forward;
				RaycastHit val2 = HelperFunctions.LineCheck(character.Center, character.Center + val * 1000f, (LayerType)5, 0f, (QueryTriggerInteraction)1);
				if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).transform) || !(((Object)((Component)((RaycastHit)(ref val2)).transform).gameObject).name != "EdgeWall"))
				{
					character.refs.afflictions.AddStatus((STATUSTYPE)8, 0.0025f * Time.deltaTime, false, true, true, false);
				}
			}
		}
	}
	public class FallDamageGimmick : AscentGimmick
	{
		public override string GetTitle()
		{
			return "Ascent 9";
		}

		public override string GetDescription()
		{
			return "Butter Fingers.";
		}

		public override void OnCharacterFall(Character character)
		{
			if (character.IsLocal)
			{
				((object)Character.localCharacter.refs.items).GetType().GetMethod("DropAllItems", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(Character.localCharacter.refs.items, new object[1] { true });
			}
		}
	}
	public class HelpingIsBadGimmick : AscentGimmick
	{
		public override string GetTitle()
		{
			return "Ascent 12";
		}

		public override string GetDescription()
		{
			return "Helping makes you drowsy.";
		}

		public override void OnGrabbedCharacter(Character character)
		{
			character.refs.afflictions.AddStatus((STATUSTYPE)6, 0.05f, false, true, true, false);
		}
	}
	public class LuggageGimmick : AscentGimmick
	{
		public override string GetTitle()
		{
			return "Ascent 11";
		}

		public override string GetDescription()
		{
			return "Big Luggage's have a chance to only contain one item.";
		}

		public override void SpawnerSpawnItems(Spawner spawner, ref List<Transform> spawnSpots)
		{
			if (((Object)((Component)spawner).gameObject).name == "LuggageBig" && Random.Range(0, 2) == 0)
			{
				List<Transform> list = new List<Transform>();
				list.Add(spawnSpots[0]);
				spawnSpots = list;
			}
		}
	}
	public class OccultStatueGimmick : AscentGimmick
	{
		private List<Spawner> despawnQueue;

		private readonly object despawnQueue_lockObj = new object();

		public override string GetTitle()
		{
			return "Ascent 13";
		}

		public override string GetDescription()
		{
			return "No more Revive Statues.";
		}

		public override void RespawnChestExisted(Spawner chest)
		{
			if (Plugin.ascent13Disabler.Value)
			{
				return;
			}
			lock (despawnQueue_lockObj)
			{
				if (despawnQueue == null)
				{
					despawnQueue = new List<Spawner>();
					((MonoBehaviour)Plugin.Instance).StartCoroutine(DespawnStatusDelayed());
				}
				despawnQueue.Add(chest);
			}
		}

		private IEnumerator DespawnStatusDelayed()
		{
			yield return (object)new WaitForSeconds(45f);
			lock (despawnQueue_lockObj)
			{
				if (despawnQueue == null)
				{
					yield break;
				}
				foreach (Spawner item in despawnQueue)
				{
					((Component)item).gameObject.SetActive(false);
				}
				despawnQueue = null;
			}
		}
	}
	public class FogGimmick : AscentGimmick
	{
		private HashSet<int> patchedFogs = new HashSet<int>();

		public override string GetDescription()
		{
			return "The fog starts earlier and moves faster.";
		}

		public override string GetTitle()
		{
			return "Chaos 5";
		}

		public override void OnFogInitNewSphere(OrbFogHandler fog)
		{
			fog.currentStartForward = 0f;
			fog.currentStartHeight = 0f;
			if (!patchedFogs.Contains(((Object)fog).GetInstanceID()))
			{
				fog.speed *= 2f;
				fog.maxWaitTime /= 10f;
				patchedFogs.Add(((Object)fog).GetInstanceID());
				ConfigManager.Logger.LogWarning((object)$"Fog {((Object)fog).GetInstanceID()} safely accelerated!");
			}
		}
	}
	[Serializable]
	public class BiomeData
	{
		public BiomeType biomeType;

		public List<string> variants = new List<string>();

		public VariantSelectionType variantSelectionType;
	}
	public static class BiomeDatabase
	{
		public static List<SectionData> Sections = new List<SectionData>
		{
			new SectionData
			{
				sectionName = "Biome_1",
				biomes = new Dictionary<BiomeType, BiomeData> { [(BiomeType)0] = new BiomeData
				{
					variants = new List<string> { "Default", "SnakeBeach", "RedBeach", "BlueBeach", "JellyHell", "BlackSand" },
					variantSelectionType = VariantSelectionType.BiomeVariant
				} }
			},
			new SectionData
			{
				sectionName = "Biome_2",
				biomes = new Dictionary<BiomeType, BiomeData>
				{
					[(BiomeType)1] = new BiomeData
					{
						variants = new List<string> { "Default", "Lava", "Pillars", "Thorny", "Bombs", "Ivy", "SkyJungle" },
						variantSelectionType = VariantSelectionType.BiomeVariant
					},
					[(BiomeType)7] = new BiomeData
					{
						variants = new List<string> { "Default", "Cave Mania", "Deep Water", "Deep Woods", "Clearcut" },
						variantSelectionType = VariantSelectionType.VariantObject
					}
				}
			},
			new SectionData
			{
				sectionName = "Biome_3",
				biomes = new Dictionary<BiomeType, BiomeData>
				{
					[(BiomeType)2] = new BiomeData
					{
						variants = new List<string> { "Default", "Lava", "Spiky", "GeyserHell" },
						variantSelectionType = VariantSelectionType.BiomeVariant
					},
					[(BiomeType)6] = new BiomeData
					{
						variants = new List<string> { "NoVariant", "ScorpionsHell", "CacusHell", "CactusForest", "DynamiteHell", "TumblerHell" },
						variantSelectionType = VariantSelectionType.VariantObject
					}
				}
			},
			new SectionData
			{
				sectionName = "Biome_4",
				biomes = new Dictionary<BiomeType, BiomeData>
				{
					[(BiomeType)3] = new BiomeData
					{
						variants = new List<string>(),
						variantSelectionType = VariantSelectionType.VariantObject
					},
					[(BiomeType)8] = new BiomeData
					{
						variants = new List<string>(),
						variantSelectionType = VariantSelectionType.VariantObject
					}
				}
			}
		};
	}
	[Serializable]
	public class MapSettings
	{
		public bool enableRandomiser;

		public int seed;

		public bool autoRandomSeed;

		public bool fullyRandom;

		public List<SectionSettings> sectionSettings = new List<SectionSettings>();

		public static MapSettings CreateDefaultMapSettings()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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)
			List<SectionSettings> list = new List<SectionSettings>();
			foreach (SectionData section in BiomeDatabase.Sections)
			{
				if (section.biomes.Count != 0)
				{
					BiomeType key = section.biomes.FirstOrDefault().Key;
					string selectedVariant = ((section.biomes[key].variants.Count > 0) ? section.biomes[key].variants[0] : "");
					list.Add(new SectionSettings
					{
						overrideEnabled = true,
						sectionName = section.sectionName,
						selectedBiomeType = key,
						selectedVariant = selectedVariant
					});
				}
			}
			return new MapSettings
			{
				seed = 42,
				autoRandomSeed = false,
				fullyRandom = false,
				sectionSettings = list
			};
		}
	}
	[BepInPlugin("com.sukaira.peakaio", "PEAK AIO", "2.3.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		internal static Plugin Instance;

		internal static Harmony _harmony;

		public static List<int> viewIDsToSend;

		public static List<PhotonView>? viewsRequiringIDs;

		public static List<int> receivedViewIDs;

		public static bool awaitingViewIDs = false;

		public AssetBundle seedPickerUIBundle;

		public const int MAX_SEED_VALUE = 999999999;

		public MapSettings mapSettings;

		public MapSettings roomMapSettings;

		private RandomiserUIManager uiManager;

		internal PhotonScopedManager photonManager;

		internal GameObject uidocObject;

		public AssetBundle visibilityComputeBundle;

		internal static readonly string SavePath = Path.Combine(Application.persistentDataPath, "TerrainRandomiser", "MapSettings.json");

		public static ConfigEntry<bool> EnableLightMapBaking;

		public static bool loadingQuickSave;

		public static bool hasQuickSave;

		internal static ConfigEntry<int> ascentsUnlocked;

		internal static ConfigEntry<bool> ascent13Disabler;

		private List<BadgeData> unlockedBadges = new List<BadgeData>();

		private List<BadgeData> lockedBadges = new List<BadgeData>();

		private static bool Initted = false;

		public static int masterSeed => Instance.roomMapSettings.seed;

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("com.sukaira.peakaio");
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			EnableLightMapBaking = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableLightMapBaking", true, "Generates a lightmap which is used for certain game mechanics. Disable this if the game crashes.");
			try
			{
				seedPickerUIBundle = AssetBundle.LoadFromMemory(Resource1.terrainrandomiser);
				visibilityComputeBundle = AssetBundle.LoadFromMemory(Resource1.visibilitycompute);
				LightMapBaker.computeShader = visibilityComputeBundle.LoadAsset<ComputeShader>("SkyVisibilityDDA");
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"Failed to load AssetBundles: {arg}");
			}
			LoadMapSettings();
			if (mapSettings == null)
			{
				mapSettings = MapSettings.CreateDefaultMapSettings();
			}
			AddPhotonManager();
			((Component)this).gameObject.AddComponent<EventComponent>();
			ConfigManager.Init(((BaseUnityPlugin)this).Config, Logger);
			Utilities.Logger = Logger;
			AioEsp.Init(((BaseUnityPlugin)this).Config);
			InfiniteItems.Init(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.AddComponent<AioEsp>();
			((Component)this).gameObject.AddComponent<AioMenu>();
			Fullbright.Init(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.AddComponent<Fullbright>();
			Globals.itemSearchBuffers = new string[3] { "", "", "" };
			ascentsUnlocked = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxAscent", 0, "");
			ascent13Disabler = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Ascent 13 Disabler", false, "Disables ascent 13.");
			try
			{
				AscentGimmickHandler.GetBaseAscentCount();
				AscentGimmickHandler.RegisterAscent<FallDamageGimmick>();
				AscentGimmickHandler.RegisterAscent<AfflictionGimmick>();
				AscentGimmickHandler.RegisterAscent<LuggageGimmick>();
				AscentGimmickHandler.RegisterAscent<HelpingIsBadGimmick>();
				AscentGimmickHandler.RegisterAscent<OccultStatueGimmick>();
				AscentGimmickHandler.RegisterAscent<SkeletonGimmick>();
				AscentGimmickHandler.RegisterAscent<CampfireGimmick>();
				AscentGimmickHandler.RegisterAscent<SunHotGimmick>();
				AscentGimmickHandler.RegisterAscent<BingBongGimmick>();
				AscentGimmickHandler.RegisterAscent<FogGimmick>();
				AscentGimmickHandler.Initialize();
				Logger.LogInfo((object)"Ascents Injected successfully into Engine!");
			}
			catch (Exception arg2)
			{
				Logger.LogError((object)$"Ascents array injection failed: {arg2}");
			}
			try
			{
				_harmony.PatchAll();
				Logger.LogInfo((object)"Harmony Patches Applied successfully.");
			}
			catch (Exception arg3)
			{
				Logger.LogError((object)$"Harmony Patching Failed: {arg3}");
			}
			Logger.LogInfo((object)"Plugin com.sukaira.peakaio is loaded!");
			if (Chainloader.PluginInfos.ContainsKey("com.sukaira.peakaio"))
			{
				Chainloader.PluginInfos.Remove("com.sukaira.peakaio");
				Logger.LogWarning((object)"PEAK AIO has scrubbed itself from the Chainloader registry.");
			}
		}

		internal static void Init()
		{
			if (Initted)
			{
				return;
			}
			Initted = true;
			int num = default(int);
			if (Singleton<AchievementManager>.Instance.GetSteamStatInt((STEAMSTATTYPE)13, ref num))
			{
				if (num > AscentGimmickHandler.BaseAscents)
				{
					Singleton<AchievementManager>.Instance.SetSteamStat((STEAMSTATTYPE)13, AscentGimmickHandler.BaseAscents);
				}
				ascentsUnlocked.Value = ((ascentsUnlocked.Value < num) ? num : ascentsUnlocked.Value);
			}
			Logger.LogInfo((object)"Initted");
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
			if ((Object)(object)seedPickerUIBundle != (Object)null)
			{
				if ((Object)(object)uidocObject != (Object)null)
				{
					uidocObject.GetComponent<UIDocument>().rootVisualElement.Clear();
					Object.Destroy((Object)(object)uidocObject);
				}
				seedPickerUIBundle.Unload(true);
				seedPickerUIBundle = null;
			}
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)277) && (Object)(object)AioMenu.Instance != (Object)null)
			{
				AioMenu.Instance.Toggle();
			}
			InfiniteItems.Tick();
			Utilities.ProcessWorldCheats();
			if (ConfigManager.DevTagToggle != null && ConfigManager.DevTagToggle.Value)
			{
				Utilities.ApplyDeveloperTag();
			}
			GUIManagerPatches.Grasp.SinceLastGrab += Time.deltaTime;
			foreach (AscentGimmick gimmick in AscentGimmickHandler.gimmicks)
			{
				if (gimmick.active)
				{
					gimmick.Update();
				}
			}
		}

		private void LateUpdate()
		{
			InfiniteItems.LateTick();
		}

		private void AddPhotonManager()
		{
			photonManager = PhotonCustomPropsUtilsPlugin.GetManager("com.snosz.terrainrandomiser");
			photonManager.RegisterOnJoinedRoom((Action<Player>)delegate
			{
				if (PhotonNetwork.IsMasterClient)
				{
					photonManager.SetRoomProperty("roomMapSettings", (object)JsonConvert.SerializeObject((object)mapSettings, (Formatting)0));
				}
			});
			photonManager.RegisterRoomProperty<string>("roomMapSettings", (RoomEventType)2, (Action<string>)delegate(string value)
			{
				roomMapSettings = JsonConvert.DeserializeObject<MapSettings>(value);
			});
			photonManager.RegisterRoomProperty<int[]>("propViews", (RoomEventType)2, (Action<int[]>)delegate(int[] val)
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					if (receivedViewIDs == null)
					{
						receivedViewIDs = new List<int>();
					}
					else
					{
						receivedViewIDs.Clear();
					}
					receivedViewIDs = val.ToList();
					if (awaitingViewIDs)
					{
						Instance.UpdateRequiredViewIDs();
					}
				}
			});
		}

		public void UpdateRequiredViewIDs()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				return;
			}
			if (viewsRequiringIDs == null || receivedViewIDs == null)
			{
				Debug.LogError((object)"[TerrainRandomiser] Required lists did not initialize or have already been resolved.");
				return;
			}
			if (viewsRequiringIDs.Count > receivedViewIDs.Count)
			{
				Debug.LogError((object)"[TerrainRandomiser] ID Count mismatch! Map will be out of sync!");
				return;
			}
			for (int i = 0; i < viewsRequiringIDs.Count; i++)
			{
				if ((Object)(object)viewsRequiringIDs[i] != (Object)null && (Object)(object)((Component)viewsRequiringIDs[i]).gameObject != (Object)null)
				{
					viewsRequiringIDs[i].ViewID = receivedViewIDs[i];
				}
				else
				{
					Debug.LogError((object)$"Null or destroyed PhotonView at index {i}");
				}
			}
			Debug.LogError((object)$"[TerrainRandomiser] Updated receivedViewIDs with {receivedViewIDs.Count} IDs");
			receivedViewIDs.Clear();
			viewsRequiringIDs.Clear();
			viewsRequiringIDs = null;
			awaitingViewIDs = false;
		}

		internal void CreateUI(BoardingPass bpInstance)
		{
			if (!((Object)(object)seedPickerUIBundle == (Object)null))
			{
				GameObject val =