Decompiled source of Public Gauntlet v2.7.1

RoRGauntlet.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DebugToolkit.Code;
using EntityStates.Drone.DroneJunk;
using EntityStates.LunarTeleporter;
using HG;
using HG.Reflection;
using HarmonyLib;
using IL.EntityStates.Drifter;
using IL.EntityStates.Drone.DroneJunk;
using IL.RoR2;
using IL.RoR2.Projectile;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;
using Mono.Collections.Generic;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using On.EntityStates.LunarTeleporter;
using On.RoR2;
using On.RoR2.Artifacts;
using On.RoR2.Items;
using On.RoR2.UI;
using On.RoR2.UI.MainMenu;
using ProperSave;
using ProperSave.Data;
using R2API;
using RoR2;
using RoR2.Artifacts;
using RoR2.ContentManagement;
using RoR2.PointOfInterest;
using RoR2.Projectile;
using RoR2.Stats;
using RoR2.UI;
using RoR2.UI.MainMenu;
using RoR2.UI.SkinControllers;
using RoRGauntlet;
using RoRGauntlet.Utilities;
using RoRGauntlet.Utilities.Extensions;
using RoRGauntlet.Web;
using RoRes;
using ScrollableLobbyUI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("DebugToolkit")]
[assembly: AssemblyCompany("RoRGauntlet")]
[assembly: AssemblyConfiguration("Public")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4cde0dc8116d7c4eabe64580f1373be1ba656fe0")]
[assembly: AssemblyProduct("RoRGauntlet")]
[assembly: AssemblyTitle("RoRGauntlet")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RoRes
{
	public sealed class AuthInfo
	{
		[JsonProperty("idToken")]
		public string IdToken { get; set; }

		[JsonProperty("refreshToken")]
		public string RefreshToken { get; set; }

		[JsonProperty("localId")]
		public string LocalId { get; set; }
	}
	public sealed class Loadout
	{
		[JsonProperty("id")]
		public long Id { get; set; }

		[JsonProperty("seed")]
		public ulong Seed { get; set; }

		[JsonProperty("survivor")]
		public string Survivor { get; set; }

		[JsonProperty("skills")]
		public List<long> Skills { get; set; }

		[JsonProperty("stages")]
		public List<string> Stages { get; set; }

		public override string ToString()
		{
			return JsonConvert.SerializeObject((object)this);
		}
	}
	public sealed class Member
	{
		[JsonProperty("team")]
		public long Id { get; set; }

		[JsonProperty("userId")]
		public string UserId { get; set; }
	}
	public sealed class Race
	{
		[JsonProperty("id")]
		public string Id { get; set; }

		[JsonProperty("lobbyCode")]
		public string LobbyCode { get; set; }

		[JsonProperty("password")]
		public string Password { get; set; }

		[JsonProperty("active")]
		public bool Active { get; set; }

		[JsonProperty("loadouts")]
		public List<Loadout> Loadouts { get; set; }

		[JsonProperty("members")]
		public List<Member> Members { get; set; }

		[JsonProperty("createTimestamp")]
		public long CreateTimestamp { get; set; }

		[JsonProperty("createUser")]
		public string CreateUser { get; set; }

		[JsonProperty("sanctioned")]
		public bool Sanctioned { get; set; }

		[JsonProperty("runSubmissions")]
		public List<RunSubmission> RunSubmissions { get; set; }

		public static Race FromJson(string json)
		{
			return JsonConvert.DeserializeObject<Race>(json, Converter.Settings);
		}

		public int GetCurrentLoadoutIndex(string userId)
		{
			if (RunSubmissions == null)
			{
				return 1;
			}
			List<RunSubmission> list = (from sub in RunSubmissions
				where sub != null && sub.UserId == userId
				orderby sub.LoadoutId
				select sub).ToList();
			if (list.Count() == 0)
			{
				return 1;
			}
			int num = 1;
			for (int i = 0; i < list.Count(); i++)
			{
				int loadoutId = list[i].LoadoutId;
				if (loadoutId > num)
				{
					return num;
				}
				if (i < list.Count - 1 && list[i + 1].LoadoutId - loadoutId > 1)
				{
					num = loadoutId + 1;
					break;
				}
				num++;
			}
			return num;
		}
	}
	public sealed class RunSubmission
	{
		[JsonProperty("loadoutId")]
		public int LoadoutId { get; set; }

		[JsonProperty("userId")]
		public string UserId { get; set; }

		[JsonProperty("runTime")]
		public long RunTime { get; set; }

		[JsonProperty("lazarusCount")]
		public long LazarusCount { get; set; }

		[JsonProperty("didConcede")]
		public bool DidConcede { get; set; }

		[JsonProperty("splitTimes")]
		public List<long> SplitTimes { get; set; }

		public static RunSubmission FromJson(string json)
		{
			return JsonConvert.DeserializeObject<RunSubmission>(json, Converter.Settings);
		}
	}
	public static class Serializer
	{
		public static string ToJson(this Race self)
		{
			return JsonConvert.SerializeObject((object)self, Converter.Settings);
		}

		public static string ToJson(this User self)
		{
			return JsonConvert.SerializeObject((object)self, Converter.Settings);
		}

		public static string ToJson(this RunSubmission self)
		{
			return JsonConvert.SerializeObject((object)self, Converter.Settings);
		}

		public static string ToJson(this AuthInfo self)
		{
			return JsonConvert.SerializeObject((object)self, Converter.Settings);
		}
	}
	internal static class Converter
	{
		public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
		{
			MetadataPropertyHandling = (MetadataPropertyHandling)2,
			DateParseHandling = (DateParseHandling)0,
			Converters = { (JsonConverter)new IsoDateTimeConverter
			{
				DateTimeStyles = DateTimeStyles.AssumeUniversal
			} }
		};
	}
	public sealed class User
	{
		[JsonProperty("id")]
		public string Id { get; set; }

		[JsonProperty("username")]
		public string Username { get; set; }

		[JsonProperty("pfp")]
		public Uri Pfp { get; set; }

		public static User FromJson(string json)
		{
			return JsonConvert.DeserializeObject<User>(json, Converter.Settings);
		}
	}
	public sealed class UserInfo
	{
		[JsonProperty("user")]
		public User User { get; set; }

		[JsonProperty("auth")]
		public AuthInfo Auth { get; set; }
	}
	public sealed class UserLoginResponse
	{
		[JsonProperty("id")]
		public string Id { get; set; }

		[JsonProperty("auth_id")]
		public string auth_id { get; set; }

		[JsonProperty("username")]
		public string Username { get; set; }

		[JsonProperty("pfp")]
		public Uri pfp { get; set; }

		[JsonProperty("twitch_handle")]
		public string twitchHandle { get; set; }

		[JsonProperty("youtube_handle")]
		public string youtubeHandle { get; set; }

		[JsonProperty("sanctioned_admin")]
		public bool sanctionedAdmin { get; set; }

		public static UserLoginResponse FromJson(string json)
		{
			return JsonConvert.DeserializeObject<UserLoginResponse>(json, Converter.Settings);
		}
	}
	internal sealed class RaceV2Api
	{
		private sealed class JoinLobbyRequest
		{
			public string Password { get; set; }

			public int Team { get; set; }
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnEnter <0>__onEnter;
		}

		[CompilerGenerated]
		private sealed class <GetRaceById>d__9<T> : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public long id;

			public RaceV2Api <>4__this;

			public Action<T> onDone;

			private UnityWebRequest <uwr>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<uwr>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Invalid comparison between Unknown and I4
				bool result2;
				try
				{
					int num = <>1__state;
					RaceV2Api raceV2Api = <>4__this;
					switch (num)
					{
					default:
						result2 = false;
						break;
					case 0:
					{
						<>1__state = -1;
						string endpoint = EnvironmentService.Instance.GetEnvironment().Endpoint;
						string text = $"{endpoint}/race?id={id}";
						<uwr>5__2 = UnityWebRequest.Get(text);
						<>1__state = -3;
						raceV2Api.AddHeaders(<uwr>5__2);
						<>2__current = <uwr>5__2.SendWebRequest();
						<>1__state = 1;
						result2 = true;
						break;
					}
					case 1:
					{
						<>1__state = -3;
						Result result = <uwr>5__2.result;
						if (result - 2 <= 1)
						{
							raceV2Api._log.LogError((object)("Error trying to fetch race data : " + <uwr>5__2.error));
						}
						else
						{
							raceV2Api._log.LogInfo((object)("Updated race data fetched : " + <uwr>5__2.downloadHandler.text));
							T obj = JsonConvert.DeserializeObject<T>(<uwr>5__2.downloadHandler.text, Converter.Settings);
							onDone(obj);
						}
						result2 = false;
						<>m__Finally1();
						break;
					}
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
				return result2;
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<uwr>5__2 != null)
				{
					((IDisposable)<uwr>5__2).Dispose();
				}
			}

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

		[CompilerGenerated]
		private sealed class <GetRaceData>d__10<T> : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string lobbyCode;

			public RaceV2Api <>4__this;

			public Action<T> onDone;

			private UnityWebRequest <uwr>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 2)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<uwr>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Invalid comparison between Unknown and I4
				try
				{
					int num = <>1__state;
					RaceV2Api raceV2Api = <>4__this;
					string text;
					switch (num)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						if (lobbyCode == null || lobbyCode.Length == 0)
						{
							raceV2Api._log.LogWarning((object)"Can't get race data from null or empty lobby code");
							<>2__current = null;
							<>1__state = 1;
							return true;
						}
						goto IL_006f;
					case 1:
						<>1__state = -1;
						goto IL_006f;
					case 2:
						{
							<>1__state = -3;
							Result result = <uwr>5__2.result;
							if (result - 2 <= 1)
							{
								raceV2Api._log.LogError((object)("Error trying to fetch race data : " + <uwr>5__2.error));
							}
							else
							{
								raceV2Api._log.LogInfo((object)("Updated race data fetched : " + <uwr>5__2.downloadHandler.text));
								T obj = JsonConvert.DeserializeObject<T>(<uwr>5__2.downloadHandler.text, Converter.Settings);
								onDone(obj);
							}
							<>m__Finally1();
							<uwr>5__2 = null;
							return false;
						}
						IL_006f:
						text = EnvironmentService.Instance.GetEnvironment().Endpoint + "/race/" + lobbyCode.ToUpper();
						<uwr>5__2 = UnityWebRequest.Get(text);
						<>1__state = -3;
						raceV2Api.AddHeaders(<uwr>5__2);
						<>2__current = <uwr>5__2.SendWebRequest();
						<>1__state = 2;
						return true;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<uwr>5__2 != null)
				{
					((IDisposable)<uwr>5__2).Dispose();
				}
			}

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

		[CompilerGenerated]
		private sealed class <InvokeGetUsersCurrentRace>d__17<Race> : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RaceV2Api <>4__this;

			public Action<Race, string> onDone;

			private UnityWebRequest <uwr>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<uwr>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//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_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Invalid comparison between Unknown and I4
				try
				{
					int num = <>1__state;
					RaceV2Api raceV2Api = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						string text = EnvironmentService.Instance.GetEnvironment().Endpoint + "/race/current";
						raceV2Api._log.LogDebug((object)("GetUsersCurrentRace endpoint " + text));
						Debug.Log((object)("GetUsersCurrentRace endpoint " + text));
						<uwr>5__2 = UnityWebRequest.Get(text);
						<>1__state = -3;
						raceV2Api.AddHeaders(<uwr>5__2);
						<>2__current = <uwr>5__2.SendWebRequest();
						<>1__state = 1;
						return true;
					}
					case 1:
					{
						<>1__state = -3;
						Result result = <uwr>5__2.result;
						if (result - 2 <= 1)
						{
							raceV2Api._log.LogError((object)("Error trying to fetch race data : " + <uwr>5__2.error));
						}
						else
						{
							raceV2Api._log.LogInfo((object)("Updated race data fetched : " + <uwr>5__2.downloadHandler.text));
							Race arg = JsonConvert.DeserializeObject<Race>(<uwr>5__2.downloadHandler.text, Converter.Settings);
							string requestHeader = <uwr>5__2.GetRequestHeader("Authorization");
							onDone(arg, requestHeader);
						}
						<>m__Finally1();
						<uwr>5__2 = null;
						return false;
					}
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<uwr>5__2 != null)
				{
					((IDisposable)<uwr>5__2).Dispose();
				}
			}

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

		[CompilerGenerated]
		private sealed class <InvokeSignIn>d__12<T> : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string username;

			public RaceV2Api <>4__this;

			public Action<T> onDone;

			private UnityWebRequest <uwr>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<uwr>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_009d: Invalid comparison between Unknown and I4
				try
				{
					int num = <>1__state;
					RaceV2Api raceV2Api = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						string text = EnvironmentService.Instance.GetEnvironment().Endpoint + "/user/" + username;
						<uwr>5__2 = UnityWebRequest.Post(text, (string)null);
						<>1__state = -3;
						raceV2Api.AddHeaders(<uwr>5__2);
						<>2__current = <uwr>5__2.SendWebRequest();
						<>1__state = 1;
						return true;
					}
					case 1:
					{
						<>1__state = -3;
						Result result = <uwr>5__2.result;
						if (result - 2 <= 1)
						{
							raceV2Api._log.LogError((object)("Error during login : " + <uwr>5__2.error));
						}
						else
						{
							raceV2Api._log.LogInfo((object)("Login success : " + <uwr>5__2.downloadHandler.text));
							T obj = JsonConvert.DeserializeObject<T>(<uwr>5__2.downloadHandler.text, Converter.Settings);
							onDone(obj);
						}
						<>m__Finally1();
						<uwr>5__2 = null;
						return false;
					}
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<uwr>5__2 != null)
				{
					((IDisposable)<uwr>5__2).Dispose();
				}
			}

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

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

			private object <>2__current;

			public RaceV2Api <>4__this;

			public RunSubmission runSubmission;

			private UnityWebRequest <uwr>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<uwr>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//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_00e9: 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_00ee: Invalid comparison between Unknown and I4
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					int num = <>1__state;
					RaceV2Api raceV2Api = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						string lobbyCode = LoadoutHandler.Instance.Race.LobbyCode;
						string text = EnvironmentService.Instance.GetEnvironment().Endpoint + "/race/" + lobbyCode + "/submitRun";
						raceV2Api._log.LogDebug((object)("Submit endpoint " + text));
						string text2 = JsonConvert.SerializeObject((object)runSubmission);
						raceV2Api._log.LogDebug((object)("post data : " + text2));
						<uwr>5__2 = UnityWebRequest.Put(text, text2);
						<>1__state = -3;
						raceV2Api.AddHeaders(<uwr>5__2);
						<>2__current = <uwr>5__2.SendWebRequest();
						<>1__state = 1;
						return true;
					}
					case 1:
					{
						<>1__state = -3;
						Result result = <uwr>5__2.result;
						if (result - 2 <= 1)
						{
							raceV2Api._log.LogError((object)("Error while submitting run : " + <uwr>5__2.error));
							raceV2Api._log.LogError((object)$"getError : {<uwr>5__2.GetError()}");
							foreach (KeyValuePair<string, string> responseHeader in <uwr>5__2.GetResponseHeaders())
							{
								raceV2Api._log.LogError((object)("Response header > " + responseHeader.Key + " : " + responseHeader.Value));
							}
						}
						else
						{
							raceV2Api._log.LogInfo((object)("Submit completed: " + <uwr>5__2.downloadHandler.text));
						}
						<>m__Finally1();
						<uwr>5__2 = null;
						return false;
					}
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<uwr>5__2 != null)
				{
					((IDisposable)<uwr>5__2).Dispose();
				}
			}

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

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

			private object <>2__current;

			public RaceV2Api <>4__this;

			public string lobbyCode;

			public string lobbyPassword;

			public int team;

			public Action<Race> onDone;

			private UnityWebRequest <uwr>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<uwr>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Invalid comparison between Unknown and I4
				bool result2;
				try
				{
					int num = <>1__state;
					RaceV2Api raceV2Api = <>4__this;
					switch (num)
					{
					default:
						result2 = false;
						break;
					case 0:
					{
						<>1__state = -1;
						raceV2Api._log.LogInfo((object)("JoinLobby(" + lobbyCode.ToUpper() + ")"));
						string text = EnvironmentService.Instance.GetEnvironment().Endpoint + "/race/" + lobbyCode + "/join";
						JoinLobbyRequest joinLobbyRequest = new JoinLobbyRequest
						{
							Password = lobbyPassword,
							Team = team
						};
						<uwr>5__2 = UnityWebRequest.Put(text, JsonConvert.SerializeObject((object)joinLobbyRequest));
						<>1__state = -3;
						raceV2Api.AddHeaders(<uwr>5__2);
						<>2__current = <uwr>5__2.SendWebRequest();
						<>1__state = 1;
						result2 = true;
						break;
					}
					case 1:
					{
						<>1__state = -3;
						Result result = <uwr>5__2.result;
						if (result - 2 <= 1)
						{
							raceV2Api._log.LogError((object)("Error while joining lobby : " + <uwr>5__2.error));
							Debug.Log((object)("Error while joining lobby : " + <uwr>5__2.error));
						}
						else
						{
							Race race = JsonConvert.DeserializeObject<Race>(<uwr>5__2.downloadHandler.text, Converter.Settings);
							LoadoutHandler.Instance.RegisterRace(race);
							Debug.Log((object)("Joined lobby '" + lobbyCode + "'"));
							onDone(race);
						}
						result2 = false;
						<>m__Finally1();
						break;
					}
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
				return result2;
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<uwr>5__2 != null)
				{
					((IDisposable)<uwr>5__2).Dispose();
				}
			}

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

		private readonly ManualLogSource _log = Logger.CreateLogSource("RoResV2Api");

		public static RaceV2Api Instance { get; } = new RaceV2Api();


		private void AddHeaders(UnityWebRequest uwr)
		{
			string apiKey = EnvironmentService.Instance.GetEnvironment().ApiKey;
			uwr.SetRequestHeader("x-api-key", apiKey);
			uwr.SetRequestHeader("Content-Type", "application/json");
			if (!string.IsNullOrEmpty(Main.instance.authorization))
			{
				uwr.SetRequestHeader("Authorization", Main.instance.authorization ?? "");
			}
		}

		public void SignIn(string username)
		{
			Debug.Log((object)("SignIn(" + username + ")"));
			((MonoBehaviour)Main.instance).StartCoroutine(InvokeSignIn(username, delegate(User u)
			{
				Debug.Log((object)("Received user Id : " + u.Id));
				Main.UserId.Value = u.Id;
			}));
		}

		public Task SignInWeb()
		{
			if (WebService.Instance.NegotiatedPort > 0)
			{
				TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
				string webUrl = EnvironmentService.Instance.GetEnvironment().WebUrl;
				Application.OpenURL($"{webUrl}/authorize?callback=http://localhost:{WebService.Instance.NegotiatedPort}/");
				WebService.Instance.SignedIn += delegate
				{
					tcs.TrySetResult(null);
				};
				return tcs.Task;
			}
			return Task.Run(async delegate
			{
				UserInfo userInfo = await InvokeSignInWeb();
				if (Debug.IsLoggingEnabled())
				{
					Debug.LogWarning((object)("Received user Id from web: " + userInfo.User.Id));
				}
				Debug.LogWarning((object)("Login successful: " + userInfo.User.Username));
				string authorization = Convert.ToBase64String(Encoding.UTF8.GetBytes(userInfo.Auth.ToJson())).Replace("=", "");
				Main.instance.authorization = authorization;
				Main.UserId.Value = userInfo.User.Id;
			});
		}

		[IteratorStateMachine(typeof(<JoinLobby>d__7))]
		public IEnumerator JoinLobby(string lobbyCode, string lobbyPassword, Action<Race> onDone, int team = 0)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <JoinLobby>d__7(0)
			{
				<>4__this = this,
				lobbyCode = lobbyCode,
				lobbyPassword = lobbyPassword,
				onDone = onDone,
				team = team
			};
		}

		public void AuditLobby(long id)
		{
			((MonoBehaviour)Main.instance).StartCoroutine(Instance.GetRaceById(id, delegate(Race race)
			{
				//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_0045: Expected O, but got Unknown
				//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)
				//IL_0065: Expected O, but got Unknown
				LoadoutHandler.Instance.RegisterRace(race);
				if (Object.op_Implicit((Object)(object)MainMenuController.instance))
				{
					Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0; \"", false);
				}
				else
				{
					object obj2 = <>O.<0>__onEnter;
					if (obj2 == null)
					{
						hook_OnEnter val2 = onEnter;
						<>O.<0>__onEnter = val2;
						obj2 = (object)val2;
					}
					BaseMainMenuScreen.OnEnter -= (hook_OnEnter)obj2;
					object obj3 = <>O.<0>__onEnter;
					if (obj3 == null)
					{
						hook_OnEnter val3 = onEnter;
						<>O.<0>__onEnter = val3;
						obj3 = (object)val3;
					}
					BaseMainMenuScreen.OnEnter += (hook_OnEnter)obj3;
					Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"disconnect; \"", false);
				}
				Debug.Log((object)$"Auditing lobby: {id}");
			}));
			static void onEnter(orig_OnEnter orig, BaseMainMenuScreen self, MainMenuController controller)
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Expected O, but got Unknown
				orig.Invoke(self, controller);
				Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0; \"", false);
				object obj = <>O.<0>__onEnter;
				if (obj == null)
				{
					hook_OnEnter val = onEnter;
					<>O.<0>__onEnter = val;
					obj = (object)val;
				}
				BaseMainMenuScreen.OnEnter -= (hook_OnEnter)obj;
			}
		}

		[IteratorStateMachine(typeof(<GetRaceById>d__9<>))]
		private IEnumerator GetRaceById<T>(long id, Action<T> onDone)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetRaceById>d__9<T>(0)
			{
				<>4__this = this,
				id = id,
				onDone = onDone
			};
		}

		[IteratorStateMachine(typeof(<GetRaceData>d__10<>))]
		public IEnumerator GetRaceData<T>(string lobbyCode, Action<T> onDone)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetRaceData>d__10<T>(0)
			{
				<>4__this = this,
				lobbyCode = lobbyCode,
				onDone = onDone
			};
		}

		public void SubmitRun(RunSubmission runSubmission)
		{
			_log.LogInfo((object)("SubmitRun(" + runSubmission.ToJson() + ")"));
			((MonoBehaviour)Main.instance).StartCoroutine(InvokeSubmitRun(runSubmission));
		}

		[IteratorStateMachine(typeof(<InvokeSignIn>d__12<>))]
		private IEnumerator InvokeSignIn<T>(string username, Action<T> onDone)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InvokeSignIn>d__12<T>(0)
			{
				<>4__this = this,
				username = username,
				onDone = onDone
			};
		}

		private async Task<UserInfo> InvokeSignInWeb()
		{
			using HttpListener listener = new HttpListener();
			bool flag = false;
			int i;
			for (i = 49152; i < 65536 && !flag; i++)
			{
				try
				{
					listener.Prefixes.Add($"http://*:{i}/");
					listener.Start();
					flag = true;
					if (Debug.IsLoggingEnabled())
					{
						Debug.Log((object)$"Listening for user on port {i}");
					}
				}
				catch (Exception ex)
				{
					listener.Prefixes.Clear();
					if (Debug.IsLoggingEnabled())
					{
						Debug.Log((object)$"Couldn't bind port: {i}. {ex.Message}");
					}
					continue;
				}
				break;
			}
			string webUrl = EnvironmentService.Instance.GetEnvironment().WebUrl;
			Application.OpenURL($"{webUrl}/authorize?callback=http://localhost:{i}/");
			string origin;
			if (flag)
			{
				Debug.Log((object)"Check for browser opening!");
				Debug.Log((object)$"If the browser doesn't open automatically you should open {webUrl}/authorize?callback=http://localhost:{i}/");
				HttpListenerContext httpListenerContext = await listener.GetContextAsync();
				origin = httpListenerContext.Request.Headers.Get("origin");
				if (httpListenerContext.Request.HttpMethod == HttpMethod.Options.Method)
				{
					addCorsHeaders(httpListenerContext.Response);
					httpListenerContext.Response.OutputStream.Close();
					httpListenerContext = await listener.GetContextAsync();
				}
				addCorsHeaders(httpListenerContext.Response);
				if (httpListenerContext.Request.HttpMethod == HttpMethod.Post.Method && httpListenerContext.Request.ContentType == "application/json")
				{
					using (StreamReader reader = new StreamReader(httpListenerContext.Request.InputStream, httpListenerContext.Request.ContentEncoding))
					{
						return JsonConvert.DeserializeObject<UserInfo>(await reader.ReadToEndAsync());
					}
				}
				Debug.Log((object)"Response was not Json");
			}
			else if (Debug.IsLoggingEnabled())
			{
				Debug.LogError((object)"Failed to start the server.");
			}
			return null;
			void addCorsHeaders(HttpListenerResponse response)
			{
				if (origin != null && (origin.EndsWith("riskofresources.com") || origin.EndsWith("localhost")))
				{
					response.AddHeader("Access-Control-Allow-Headers", "Authorization,Content-Type");
					response.AddHeader("Access-Control-Allow-Methods", "POST,OPTIONS");
					response.AddHeader("Access-Control-Allow-Origin", origin);
				}
			}
		}

		[IteratorStateMachine(typeof(<InvokeSubmitRun>d__15))]
		public IEnumerator InvokeSubmitRun(RunSubmission runSubmission)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InvokeSubmitRun>d__15(0)
			{
				<>4__this = this,
				runSubmission = runSubmission
			};
		}

		public void JoinCurrentRace(Action<Race> onDone)
		{
			((MonoBehaviour)Main.instance).StartCoroutine(InvokeGetUsersCurrentRace(delegate(Race race, string auth)
			{
				Main.instance.authorization = auth;
				LoadoutHandler.Instance.RegisterRace(race);
				Debug.Log((object)$"Race successfully received : {race}");
				Debug.Log((object)("Joined lobby '" + race.LobbyCode + "'"));
				onDone(race);
			}));
		}

		[IteratorStateMachine(typeof(<InvokeGetUsersCurrentRace>d__17<>))]
		private IEnumerator InvokeGetUsersCurrentRace<Race>(Action<Race, string> onDone)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InvokeGetUsersCurrentRace>d__17<Race>(0)
			{
				<>4__this = this,
				onDone = onDone
			};
		}
	}
	internal sealed class EnvironmentService
	{
		private readonly ManualLogSource _log = Logger.CreateLogSource("EnvironmentService");

		private readonly Dictionary<string, Environment> _environmentMap = new Dictionary<string, Environment>();

		public static EnvironmentService Instance { get; } = new EnvironmentService();


		private EnvironmentService()
		{
			Environment value = new Environment("http://example.com/endpoint", "not-a-real-api-key", "https://riskofresources.com");
			Environment value2 = new Environment("https://riskofresources.com/apply?dev=true", "Hey, you! Join the team at: riskofresources.com/apply", "https://dev.riskofresources.com");
			Environment value3 = new Environment("http://127.0.0.1:3000/", "We're always looking for more developers!", "http://localhost:3001");
			_environmentMap.Add("prd", value);
			_environmentMap.Add("dev", value2);
			_environmentMap.Add("dbg", value3);
		}

		public Environment GetEnvironment()
		{
			string value = Main.EnvironmentName.Value;
			try
			{
				return _environmentMap[value];
			}
			catch (KeyNotFoundException ex)
			{
				_log.LogError((object)ex.StackTrace);
				_log.LogError((object)("Environment '" + value + "' not found; returning first available"));
				return _environmentMap.Values.ToList().First();
			}
		}
	}
	internal sealed class Environment
	{
		public readonly string Endpoint;

		public readonly string ApiKey;

		public readonly string WebUrl;

		public Environment(string endpoint, string apiKey, string webUrl)
		{
			Endpoint = endpoint;
			ApiKey = apiKey;
			WebUrl = webUrl;
		}
	}
}
namespace RoRGauntlet
{
	public sealed class AntiCheat : MonoBehaviour
	{
		private Harmony _harmonyInstance;

		private void OnEnable()
		{
			if (Chainloader.PluginInfos.ContainsKey("iHarbHD.DebugToolkit"))
			{
				_harmonyInstance = Harmony.CreateAndPatchAll(typeof(AntiCheat), (string)null);
			}
		}

		private void OnDisable()
		{
			Harmony harmonyInstance = _harmonyInstance;
			if (harmonyInstance != null)
			{
				harmonyInstance.UnpatchSelf();
			}
			_harmonyInstance = null;
		}

		[HarmonyPatch(typeof(MacroSystem), "Update")]
		[HarmonyPrefix]
		private static bool CheckForKeyDown()
		{
			return !(LoadoutHandler.Instance.Race?.Sanctioned ?? false);
		}
	}
	internal static class Assets
	{
		public static GameObject lazarusResurrectionEffect;

		public static List<Material> swappedMaterials = new List<Material>();

		public static void Initialize(string infoLocation)
		{
			try
			{
				PopulateAssets(infoLocation);
			}
			catch (Exception arg)
			{
				Debug.LogWarning((object)$"Failed to populate assets: {arg}");
			}
		}

		private static void PopulateAssets(string infoLocation)
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(infoLocation) ?? string.Empty, "riskofresourcesassets"));
			lazarusResurrectionEffect = val.LoadAsset<GameObject>("LazarusWingsRez");
			if (!ContentAddition.AddEffect(lazarusResurrectionEffect))
			{
				Log.Error("lazarusResurrectionEffect is not valid.", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\Assets.cs", "PopulateAssets", 35);
				return;
			}
			Material[] array = (from mat in val.LoadAllAssets<Material>()
				where ((Object)mat.shader).name.StartsWith("Stubbed")
				select mat).ToArray();
			foreach (Material val2 in array)
			{
				if (!((Object)val2.shader).name.StartsWith("Stubbed"))
				{
					Log.Warning($"The material {val2} is invalid.", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\Assets.cs", "PopulateAssets", 45);
					continue;
				}
				try
				{
					SwapShader(val2);
				}
				catch (Exception arg)
				{
					Log.Error($"Failed to swap shader of material {val2}: {arg}", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\Assets.cs", "PopulateAssets", 55);
				}
			}
		}

		private static void SwapShader(Material material)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			Shader shader = Addressables.LoadAssetAsync<Shader>((object)(((Object)material.shader).name.Substring("Stubbed".Length) + ".shader")).WaitForCompletion();
			material.shader = shader;
			if (((Object)material.shader).name.Contains("Cloud Remap"))
			{
				Material val = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Common/VFX/matLightningLongBlue.mat").WaitForCompletion();
				RuntimeCloudMaterialMapper runtimeCloudMaterialMapper = new RuntimeCloudMaterialMapper(material);
				material.CopyPropertiesFromMaterial(val);
				runtimeCloudMaterialMapper.SetMaterialValues(ref material);
			}
			swappedMaterials.Add(material);
		}
	}
	public sealed class BenthicBloomSeeding : MonoBehaviour
	{
		private delegate bool TryOverrideTransformedItemDelegate(ItemIndex itemToTransform, CharacterMaster master, ref ItemDef transformedItem);

		private BenthicBloomTransformationProvider _bloomTransformationProvider;

		private void OnEnable()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			RunHooks.OnRunPostStartGlobal += onRunPostStartGlobal;
			CharacterMaster.TryCloverVoidUpgrades += new Manipulator(CharacterMaster_TryCloverVoidUpgrades);
		}

		private void OnDisable()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			RunHooks.OnRunPostStartGlobal -= onRunPostStartGlobal;
			CharacterMaster.TryCloverVoidUpgrades -= new Manipulator(CharacterMaster_TryCloverVoidUpgrades);
		}

		private void onRunPostStartGlobal(Run run)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Xoroshiro128Plus val = new Xoroshiro128Plus(run.seed ^ 0x3EABE82DFA7uL);
			_bloomTransformationProvider = new BenthicBloomTransformationProvider(val.nextUlong, run);
		}

		private void CharacterMaster_TryCloverVoidUpgrades(ILContext il)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int transformableItemsLocalIndex = -1;
			ILCursor[] array = default(ILCursor[]);
			if (!val.TryFindNext(ref array, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<Inventory>(x, "itemAcquisitionOrder"),
				(Instruction x) => ILPatternMatchingExt.MatchNewobj<List<ItemIndex>>(x),
				(Instruction x) => x.MatchStloc(typeof(List<ItemIndex>), il, out transformableItemsLocalIndex)
			}))
			{
				Log.Error("Failed to find transformable items list local index", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\BenthicBloomSeeding.cs", "CharacterMaster_TryCloverVoidUpgrades", 49);
				return;
			}
			if (!val.TryFindNext(ref array, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, transformableItemsLocalIndex),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)typeof(List<ItemIndex>).GetProperty("Item").GetMethod)
			}))
			{
				Log.Error("Failed to find transformable items shuffle patch location", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\BenthicBloomSeeding.cs", "CharacterMaster_TryCloverVoidUpgrades", 57);
				return;
			}
			val.Goto(array[1].Next, (MoveType)2, false);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<ItemIndex, CharacterMaster, ItemIndex>>((Func<ItemIndex, CharacterMaster, ItemIndex>)getNextItemToTransform);
			VariableDefinition val2 = il.AddVariable<ItemIndex>();
			val.Emit(OpCodes.Dup);
			val.Emit(OpCodes.Stloc, val2);
			if (!val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)typeof(List<PickupIndex>).GetMethod("Sort", new Type[1] { typeof(Comparison<PickupIndex>) }))
			}))
			{
				Log.Error("Failed to find transform item selection location", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\BenthicBloomSeeding.cs", "CharacterMaster_TryCloverVoidUpgrades", 71);
				return;
			}
			int availableTransformedItemsLocalIndex = -1;
			ILCursor[] array2 = default(ILCursor[]);
			if (!val.TryFindPrev(ref array2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref availableTransformedItemsLocalIndex) && Extensions.Is((MemberReference)(object)((VariableReference)il.Body.Variables[availableTransformedItemsLocalIndex]).VariableType, (MemberInfo)typeof(List<PickupIndex>))
			}))
			{
				Log.Error("Failed to find available transformed items list local index", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\BenthicBloomSeeding.cs", "CharacterMaster_TryCloverVoidUpgrades", 79);
				return;
			}
			int transformedItemDefLocalIndex = -1;
			if (!val.TryFindNext(ref array2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref transformedItemDefLocalIndex) && Extensions.Is((MemberReference)(object)((VariableReference)il.Body.Variables[transformedItemDefLocalIndex]).VariableType, (MemberInfo)typeof(ItemDef))
			}))
			{
				Log.Error("Failed to find transformed item def local index", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\BenthicBloomSeeding.cs", "CharacterMaster_TryCloverVoidUpgrades", 87);
				return;
			}
			ILLabel afterSelectTransformedItemLabel = null;
			if (!val.TryGotoPrev((MoveType)1, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, availableTransformedItemsLocalIndex),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref afterSelectTransformedItemLabel)
			}))
			{
				Log.Error("Failed to find transformed item select patch location", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\BenthicBloomSeeding.cs", "CharacterMaster_TryCloverVoidUpgrades", 96);
				return;
			}
			val.Emit(OpCodes.Ldloc, val2);
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Ldloca, transformedItemDefLocalIndex);
			val.EmitDelegate<<>F{00000040}<ItemIndex, CharacterMaster, ItemDef, bool>>((<>F{00000040}<ItemIndex, CharacterMaster, ItemDef, bool>)tryOverrideTransformedItem);
			val.Emit(OpCodes.Brtrue, (object)afterSelectTransformedItemLabel);
		}

		private static bool shouldSeed(CharacterMaster master)
		{
			if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory))
			{
				return Object.op_Implicit((Object)(object)master.playerCharacterMasterController);
			}
			return false;
		}

		private ItemIndex getNextItemToTransform(ItemIndex itemToTransform, CharacterMaster master)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (shouldSeed(master) && _bloomTransformationProvider != null)
			{
				if (!_bloomTransformationProvider.TryGetNextItemToTake(master.inventory.itemAcquisitionOrder, out var nextItemToTake))
				{
					nextItemToTake = itemToTransform;
					foreach (ItemIndex item in master.inventory.itemAcquisitionOrder)
					{
						if (!_bloomTransformationProvider.IsValidItemToTake(item))
						{
							nextItemToTake = item;
							break;
						}
					}
				}
				itemToTransform = nextItemToTake;
			}
			return itemToTransform;
		}

		private bool tryOverrideTransformedItem(ItemIndex itemToTransform, CharacterMaster master, ref ItemDef transformedItem)
		{
			//IL_001a: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!shouldSeed(master))
			{
				return false;
			}
			if (_bloomTransformationProvider == null)
			{
				return false;
			}
			if (!_bloomTransformationProvider.TryGetNextTransformation(itemToTransform, out var transformation))
			{
				transformation = (ItemIndex)(-1);
			}
			transformedItem = ItemCatalog.GetItemDef(transformation);
			return true;
		}
	}
	public sealed class BenthicBloomTransformationProvider
	{
		private static ItemIndex[] _availableInputItems = Array.Empty<ItemIndex>();

		private readonly Dictionary<ItemTier, OrderedTransformationGenerator<ItemIndex>> _tierTransformationGenerators;

		private readonly OrderedTransformationGenerator<ItemIndex> _itemTakeOrderGenerator;

		[SystemInitializer(new Type[] { typeof(ItemCatalog) })]
		private static void Init()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			_availableInputItems = (from item in (IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs
				where Object.op_Implicit((Object)(object)item) && ((int)item.tier == 0 || (int)item.tier == 1)
				select item.itemIndex).ToArray();
		}

		public BenthicBloomTransformationProvider(ulong seed, Run run)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			Xoroshiro128Plus val = new Xoroshiro128Plus(seed);
			_itemTakeOrderGenerator = new OrderedTransformationGenerator<ItemIndex>(val.nextUlong, (IEnumerable<ItemIndex>)_availableInputItems);
			_tierTransformationGenerators = new Dictionary<ItemTier, OrderedTransformationGenerator<ItemIndex>>
			{
				{
					(ItemTier)0,
					new OrderedTransformationGenerator<ItemIndex>(val.nextUlong, dropListToItemIndices(run.availableTier2DropList))
				},
				{
					(ItemTier)1,
					new OrderedTransformationGenerator<ItemIndex>(val.nextUlong, dropListToItemIndices(run.availableTier3DropList))
				}
			};
			static IEnumerable<ItemIndex> dropListToItemIndices(IEnumerable<PickupIndex> pickupIndices)
			{
				return from pickupIndex in pickupIndices
					select (ItemIndex)(((??)PickupCatalog.GetPickupDef(pickupIndex)?.itemIndex) ?? (-1)) into i
					where (int)i != -1
					select i;
			}
		}

		public bool IsValidItemToTake(ItemIndex itemIndex)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return _itemTakeOrderGenerator.Contains(itemIndex);
		}

		public bool TryGetNextItemToTake(ICollection<ItemIndex> availableItems, out ItemIndex nextItemToTake)
		{
			if (!availableItems.Any(IsValidItemToTake))
			{
				nextItemToTake = (ItemIndex)(-1);
				return false;
			}
			return _itemTakeOrderGenerator.TryGetNextTransformation(availableItems.Contains, out nextItemToTake);
		}

		public bool TryGetNextTransformation(ItemIndex original, out ItemIndex transformation)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			ItemDef originalItemDef = ItemCatalog.GetItemDef(original);
			if (!Object.op_Implicit((Object)(object)originalItemDef))
			{
				transformation = (ItemIndex)(-1);
				return false;
			}
			if (!_tierTransformationGenerators.TryGetValue(originalItemDef.tier, out var value))
			{
				transformation = (ItemIndex)(-1);
				return false;
			}
			if (!value.TryGetNextTransformation(matchTags, out transformation))
			{
				return value.TryGetNextTransformation(out transformation);
			}
			return true;
			bool matchTags(ItemIndex itemIndex)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
				if (!Object.op_Implicit((Object)(object)itemDef))
				{
					return false;
				}
				bool num = originalItemDef.ContainsTag((ItemTag)1) && itemDef.ContainsTag((ItemTag)1);
				bool flag = originalItemDef.ContainsTag((ItemTag)2) && itemDef.ContainsTag((ItemTag)2);
				bool flag2 = originalItemDef.ContainsTag((ItemTag)3) && itemDef.ContainsTag((ItemTag)3);
				return num || flag || flag2;
			}
		}
	}
	public sealed class ConcedeService
	{
		private static void ShowConcedeNotAllowed(PauseScreenController pauseScreen)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			SimpleDialogBox obj = SimpleDialogBox.Create((MPEventSystem)null);
			obj.headerToken = new TokenParamsPair("No times submitted", Array.Empty<object>());
			string text = "You cannot concede as nobody has submitted a time yet";
			if (pauseScreen == null)
			{
				text += " Use info screen button (usually tab/select) to move cursor.";
			}
			obj.descriptionToken = new TokenParamsPair(text, Array.Empty<object>());
			obj.AddCancelButton("Cancel", Array.Empty<object>());
		}

		private static void ShowConcedeConfirmationDialog(PauseScreenController pauseScreen)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			SimpleDialogBox obj = SimpleDialogBox.Create((MPEventSystem)null);
			obj.headerToken = new TokenParamsPair("Are you sure?", Array.Empty<object>());
			string text = "Are you sure you want to concede this run?";
			if (pauseScreen == null)
			{
				text += " Use info screen button (usually tab/select) to move cursor.";
			}
			obj.descriptionToken = new TokenParamsPair(text, Array.Empty<object>());
			obj.AddActionButton((UnityAction)delegate
			{
				ActuallyConcedeGame(pauseScreen);
			}, "Yes", true, Array.Empty<object>());
			obj.AddCancelButton("Cancel", Array.Empty<object>());
		}

		private static void ActuallyConcedeGame(PauseScreenController pauseScreen)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)pauseScreen))
			{
				Object.Destroy((Object)(object)((Component)pauseScreen).gameObject);
			}
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				Main.ConcedeCheck = true;
				GameEndingDef val = ScriptableObject.CreateInstance<GameEndingDef>();
				val.isWin = false;
				val.showCredits = false;
				val.lunarCoinReward = 0u;
				RunReport.Generate(Run.instance, val);
				Run.CCRunEnd(default(ConCommandArgs));
				Main.ConcedeCheck = false;
			}
		}

		public void ConcedeGame(PauseScreenController pauseScreen)
		{
			string lobbyCode = LoadoutHandler.Instance.Race.LobbyCode;
			int currentLoadout = Main.CurrentLoadout.Value;
			((MonoBehaviour)Main.instance).StartCoroutine(RaceV2Api.Instance.GetRaceData(lobbyCode, delegate(Race race)
			{
				if (!race.Sanctioned)
				{
					ShowConcedeConfirmationDialog(pauseScreen);
				}
				else
				{
					List<RunSubmission> list = (from s in race.RunSubmissions ?? new List<RunSubmission>()
						where s != null
						where s.LoadoutId == currentLoadout
						select s).ToList();
					if (SimpleDialogBox.instancesList.Count <= 0)
					{
						if (list.Count > 0)
						{
							Log.Info("Found submission(s) from other player(s); concede is allowed", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\ConcedeService.cs", "ConcedeGame", 90);
							ShowConcedeConfirmationDialog(pauseScreen);
						}
						else
						{
							Log.Info("Can't concede when no other players have submitted their run", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\ConcedeService.cs", "ConcedeGame", 95);
							ShowConcedeNotAllowed(pauseScreen);
						}
					}
				}
			}));
		}
	}
	public sealed class ConcedeUI : MonoBehaviour
	{
		private readonly ConcedeService _concedeService = new ConcedeService();

		public void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			PauseScreenController.Awake += new hook_Awake(PauseScreenControllerOnAwake);
		}

		public void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			PauseScreenController.Awake -= new hook_Awake(PauseScreenControllerOnAwake);
		}

		private void PauseScreenControllerOnAwake(orig_Awake orig, PauseScreenController self)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			orig.Invoke(self);
			ButtonSkinController componentInChildren = ((Component)self).GetComponentInChildren<ButtonSkinController>();
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				Debug.LogWarning((object)"Failed to get button skin controller");
				return;
			}
			GameObject gameObject = ((Component)componentInChildren).gameObject;
			GameObject obj = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
			((Object)obj).name = "Concede Button";
			LanguageTextMeshController val = default(LanguageTextMeshController);
			if (obj.TryGetComponent<LanguageTextMeshController>(ref val))
			{
				val.token = "Concede Run";
			}
			HGButton val2 = default(HGButton);
			if (!obj.TryGetComponent<HGButton>(ref val2))
			{
				Debug.LogWarning((object)"Failed to setup concede button");
				Object.Destroy((Object)(object)gameObject);
				return;
			}
			((Button)val2).onClick = new ButtonClickedEvent();
			((UnityEvent)((Button)val2).onClick).AddListener((UnityAction)delegate
			{
				_concedeService.ConcedeGame(self);
			});
		}
	}
	public sealed class ConfigurablePillars : MonoBehaviour
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__OnMoonBatteryMissionControllerOnAwake;
		}

		private void OnEnable()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__OnMoonBatteryMissionControllerOnAwake;
			if (obj == null)
			{
				hook_Awake val = OnMoonBatteryMissionControllerOnAwake;
				<>O.<0>__OnMoonBatteryMissionControllerOnAwake = val;
				obj = (object)val;
			}
			MoonBatteryMissionController.Awake += (hook_Awake)obj;
		}

		private void OnDisable()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__OnMoonBatteryMissionControllerOnAwake;
			if (obj == null)
			{
				hook_Awake val = OnMoonBatteryMissionControllerOnAwake;
				<>O.<0>__OnMoonBatteryMissionControllerOnAwake = val;
				obj = (object)val;
			}
			MoonBatteryMissionController.Awake -= (hook_Awake)obj;
		}

		private static void OnMoonBatteryMissionControllerOnAwake(orig_Awake orig, MoonBatteryMissionController self)
		{
			orig.Invoke(self);
			self._numRequiredBatteries = Main.PillarNum.Value;
		}
	}
	internal static class DebugCommands
	{
		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void NextLoadout(ConCommandArgs args)
		{
			if (Main.CurrentLoadout.Value < LoadoutHandler.Instance.GetLoadouts().Count - 1)
			{
				ConfigEntry<int> currentLoadout = Main.CurrentLoadout;
				int value = currentLoadout.Value;
				currentLoadout.Value = value + 1;
			}
			Log.Info("Progressed to loadout " + Main.CurrentLoadout.Value, "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\Configuration\\DebugCommands.cs", "NextLoadout", 15);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SetLoadout(ConCommandArgs args)
		{
			Main.CurrentLoadout.Value = ((ConCommandArgs)(ref args)).GetArgInt(0);
			Debug.Log((object)$"Loadout number has been set to : {Main.CurrentLoadout.Value}");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SetDifficulty(ConCommandArgs args)
		{
			string argString = ((ConCommandArgs)(ref args)).GetArgString(0);
			string[] obj = new string[12]
			{
				"Eclipse8", "Eclipse7", "Eclipse6", "Eclipse5", "Eclipse4", "Eclipse3", "Eclipse2", "Eclipse1", "Hard", "Normal",
				"Easy", "Any"
			};
			bool flag = false;
			string[] array = obj;
			foreach (string text in array)
			{
				if (argString == text)
				{
					flag = true;
				}
			}
			if (flag)
			{
				Main.DifficultySelect.Value = argString;
				Log.Info("Set difficulty config to to " + argString, "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\Configuration\\DebugCommands.cs", "SetDifficulty", 45);
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void ListNameTokens(ConCommandArgs args)
		{
			Debug.Log((object)"Available Survivor Tokens");
			foreach (SurvivorDef allSurvivorDef in SurvivorCatalog.allSurvivorDefs)
			{
				Debug.Log((object)allSurvivorDef.displayNameToken);
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SubmitRun(ConCommandArgs args)
		{
			SubmitRun componentInChildren = ((Component)Main.instance).GetComponentInChildren<SubmitRun>(true);
			if (componentInChildren.RunSubmission != null)
			{
				RaceV2Api.Instance.SubmitRun(componentInChildren.RunSubmission);
			}
			else
			{
				Debug.LogWarning((object)"No run submission found");
			}
		}
	}
	internal static class SetupCommands
	{
		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SignIn(ConCommandArgs args)
		{
			LogEnv();
			RaceV2Api instance = RaceV2Api.Instance;
			string text = ((ConCommandArgs)(ref args)).TryGetArgString(0);
			if (string.IsNullOrEmpty(text))
			{
				instance.SignInWeb();
			}
			else
			{
				instance.SignIn(text);
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SetEnvironment(ConCommandArgs args)
		{
			LogEnv();
			string text = ((ConCommandArgs)(ref args)).GetArgString(0).ToLower();
			Main.EnvironmentName.Value = text;
			if (!text.Equals("prd") && !text.Equals("dev") && !text.Equals("dbg"))
			{
				Debug.LogError((object)"Invalid environment. Use 'prd' or 'dev'");
			}
			else
			{
				Debug.Log((object)("Environment set to : " + text));
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SetTeam(ConCommandArgs args)
		{
			LogEnv();
			int argInt = ((ConCommandArgs)(ref args)).GetArgInt(0);
			Log.Info($"Team number has been set to : {argInt}", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\Configuration\\SetupCommands.cs", "SetTeam", 48);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static async void JoinRace(ConCommandArgs args)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			LogEnv();
			RaceV2Api instance = RaceV2Api.Instance;
			string lobbyCode = ((ConCommandArgs)(ref args)).TryGetArgString(0);
			int? team = ((ConCommandArgs)(ref args)).TryGetArgInt(1);
			string password = ((ConCommandArgs)(ref args)).TryGetArgString(2);
			bool flag = string.IsNullOrEmpty(Main.UserId.Value) || string.IsNullOrEmpty(Main.instance.authorization);
			if (string.IsNullOrEmpty(lobbyCode))
			{
				if (flag)
				{
					Debug.Log((object)"Can't join active lobby without a user ID; please `sign_in` first");
					return;
				}
				Debug.Log((object)"Joining current race");
				instance.JoinCurrentRace(delegate(Race race)
				{
					LoadoutHandler.Instance.RegisterRace(race);
					Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0; \"", false);
				});
				return;
			}
			if (flag)
			{
				Debug.Log((object)"No user session: signing in first");
				await instance.SignInWeb();
			}
			((MonoBehaviour)Main.instance).StartCoroutine(instance.JoinLobby(lobbyCode, password, delegate(Race race)
			{
				LoadoutHandler.Instance.RegisterRace(race);
				Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0; \"", false);
			}, team.GetValueOrDefault(0)));
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void AuditRace(ConCommandArgs args)
		{
			RaceV2Api instance = RaceV2Api.Instance;
			ulong argULong = ((ConCommandArgs)(ref args)).GetArgULong(0);
			instance.AuditLobby((long)argULong);
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void SignOut(ConCommandArgs args)
		{
			Main.UserId.Value = "";
		}

		private static void LogEnv()
		{
			string value = Main.EnvironmentName.Value;
			Debug.Log((object)("Current environment : " + value));
		}
	}
	public sealed class ContainInArenaHandler : MonoBehaviour
	{
		private sealed class ContainInArena : MonoBehaviour
		{
			private const float MinHeight = 485f;

			private Vector3 _startPosition;

			private CharacterMotor _characterMotor;

			private void Awake()
			{
				//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)
				//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)
				_characterMotor = ((Component)this).gameObject.GetComponent<CharacterMotor>();
				if (!Object.op_Implicit((Object)(object)_characterMotor))
				{
					Log.Warning("No character motor so character won't TP back to arena", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\ContainInArenaHandler.cs", "Awake", 66);
					((Behaviour)this).enabled = false;
					return;
				}
				Scene activeScene = SceneManager.GetActiveScene();
				string name = ((Scene)(ref activeScene)).name;
				_startPosition = ((Component)this).gameObject.transform.position;
				((Behaviour)this).enabled = _startPosition.y > 450f && name == "moon2";
			}

			public void TeleportBack()
			{
				//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_0033: 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)
				Vector3 position = ((Component)this).gameObject.transform.position;
				((BaseCharacterController)_characterMotor).Motor.SetPosition(new Vector3(position.x, _startPosition.y + 7f, position.z), true);
			}

			private void FixedUpdate()
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				if (((Component)this).gameObject.transform.position.y < 485f)
				{
					TeleportBack();
				}
			}
		}

		public string key = "RoR2/Base/Brother/BrotherBody.prefab";

		private ContainInArena _containInArena;

		private AsyncOperationHandle<GameObject> _handle;

		private void Start()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			_handle = Addressables.LoadAssetAsync<GameObject>((object)key);
			_handle.Completed += OnLoadBody;
		}

		private void OnDisable()
		{
			Object.Destroy((Object)(object)_containInArena);
		}

		private void OnDestroy()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Addressables.Release<GameObject>(_handle);
		}

		private void OnEnable()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (_handle.IsValid() && (int)_handle.Status == 1)
			{
				OnLoadBody(_handle);
			}
		}

		private void OnLoadBody(AsyncOperationHandle<GameObject> obj)
		{
			CharacterBody val = default(CharacterBody);
			if (!obj.Result.TryGetComponent<CharacterBody>(ref val))
			{
				Log.Warning("No Character body", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\ContainInArenaHandler.cs", "OnLoadBody", 43);
			}
			else if (!((Behaviour)this).isActiveAndEnabled)
			{
				Log.Warning("ContainInArenaHandler not enabled!", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\ContainInArenaHandler.cs", "OnLoadBody", 48);
			}
			else
			{
				_containInArena = ((Component)val).gameObject.AddComponent<ContainInArena>();
			}
		}
	}
	public sealed class DLC2 : MonoBehaviour
	{
		private static Xoroshiro128Plus stage;

		private static Xoroshiro128Plus item;

		private event Action _onDisable;

		private void OnEnable()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			AddSceneToGroup("RoR2/Base/SceneGroups/sgStage2.asset", "RoR2/DLC2/lemuriantemple/lemuriantemple.asset");
			AddSceneToGroup("RoR2/Base/SceneGroups/sgStage3.asset", "RoR2/DLC2/habitat/habitat.asset");
			AddSceneToGroup("RoR2/Base/SceneGroups/loopSgStage3.asset", "RoR2/DLC2/habitatfall/habitatfall.asset");
			ChangeDestination("RoR2/DLC2/PortalColossus.prefab");
			ReplacePortals("RoR2/DLC2/ShrineHalcyonite.prefab", "RoR2/DLC2/iscColossusPortal.asset");
			Run.onRunStartGlobal += MarkFalseSonComplete;
			PurchaseInteraction.OnInteractionBegin += new Manipulator(ReplaceItemGenerator);
			PurchaseInteraction.OnInteractionBegin += new Manipulator(SeedSaleStarRoll);
			Run.GenerateStageRNG += new hook_GenerateStageRNG(OnGenerateStageRng);
			ChestBehavior.BaseItemDrop += new hook_BaseItemDrop(FixEdgeCase);
			HalcyoniteShrineInteractable.DrainConditionMet += new Manipulator(SkipHalcyonRoll);
			PickupPickerController.GenerateOptionsFromDropTablePlusForcedStorm += new Manipulator(GenerateAll);
			HalcyoniteShrineInteractable.Start += new hook_Start(OnHalcyoniteShrineInteractableOnStart);
		}

		private void OnDisable()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			try
			{
				this._onDisable?.Invoke();
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Failed to revert gauntlet changes for DLC2, things may be broken until restart: {arg}");
			}
			finally
			{
				this._onDisable = null;
			}
			Run.onRunStartGlobal -= MarkFalseSonComplete;
			PurchaseInteraction.OnInteractionBegin -= new Manipulator(ReplaceItemGenerator);
			PurchaseInteraction.OnInteractionBegin -= new Manipulator(SeedSaleStarRoll);
			Run.GenerateStageRNG -= new hook_GenerateStageRNG(OnGenerateStageRng);
			ChestBehavior.BaseItemDrop -= new hook_BaseItemDrop(FixEdgeCase);
			HalcyoniteShrineInteractable.DrainConditionMet -= new Manipulator(SkipHalcyonRoll);
			PickupPickerController.GenerateOptionsFromDropTablePlusForcedStorm -= new Manipulator(GenerateAll);
			HalcyoniteShrineInteractable.Start -= new hook_Start(OnHalcyoniteShrineInteractableOnStart);
		}

		private void OnHalcyoniteShrineInteractableOnStart(orig_Start orig, HalcyoniteShrineInteractable self)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			orig.Invoke(self);
			if (NetworkServer.active)
			{
				self.rng = new Xoroshiro128Plus(stage.nextUlong);
			}
		}

		private void OnGenerateStageRng(orig_GenerateStageRNG orig, Run self)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			orig.Invoke(self);
			stage = new Xoroshiro128Plus(self.spawnRng.nextUlong);
			item = new Xoroshiro128Plus(stage.nextUlong);
		}

		private void MarkFalseSonComplete(Run instance)
		{
			instance.SetEventFlag("FalseSonBossComplete");
		}

		private void ReplaceItemGenerator(ILContext context)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(context);
			VariableDefinition val2 = new VariableDefinition(context.Import(typeof(int)));
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchStfld<ChestBehavior>(i, "dropCount")
			});
			context.Method.Body.Variables.Add(val2);
			val.Emit(OpCodes.Stloc, val2);
			val.Emit(OpCodes.Dup);
			val.EmitDelegate<Action<ChestBehavior>>((Action<ChestBehavior>)delegate(ChestBehavior chest)
			{
				chest.rng = item;
			});
			val.Emit(OpCodes.Ldloc, val2);
		}

		private void SeedSaleStarRoll(ILContext context)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0054: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(context);
			VariableDefinition val2 = new VariableDefinition(context.Import(typeof(Xoroshiro128Plus)));
			val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdfld<PurchaseInteraction>(i, "saleStarCompatible")
			});
			val.Emit(OpCodes.Dup);
			val.EmitDelegate<Func<bool, Xoroshiro128Plus>>((Func<bool, Xoroshiro128Plus>)((bool compatible) => compatible ? new Xoroshiro128Plus(stage.nextUlong) : new Xoroshiro128Plus(0uL)));
			context.Method.Body.Variables.Add(val2);
			val.Emit(OpCodes.Stloc, val2);
			MethodInfo method = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => Util.CheckRoll(0f, (CharacterMaster)null)));
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCall(i, (MethodBase)method)
			}))
			{
				val.Remove();
				val.Emit(OpCodes.Ldloc, val2);
				val.Emit(OpCodes.Call, (MethodBase)((object)this).GetType().GetMethod("CheckRoll"));
			}
		}

		private void FixEdgeCase(orig_BaseItemDrop orig, ChestBehavior self)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (self.rng == item)
			{
				self.rng = new Xoroshiro128Plus(item);
				orig.Invoke(self);
				for (int i = 1; i < self.dropCount; i++)
				{
					item.Next();
				}
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void SkipHalcyonRoll(ILContext context)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_002c: 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_0044: 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_0089: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(context);
			FieldInfo field = typeof(HalcyoniteShrineInteractable).GetField("rng", BindingFlags.Instance | BindingFlags.NonPublic);
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchStfld(i, field)
			}))
			{
				val.Emit(OpCodes.Pop);
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldfld, field);
				ILCursor obj = val;
				int index = obj.Index + 1;
				obj.Index = index;
			}
			val = new ILCursor(context);
			field = typeof(Run).GetField("treasureRng");
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdfld(i, field)
			}))
			{
				ILCursor obj2 = val;
				int index = obj2.Index + 1;
				obj2.Index = index;
				val.Emit(OpCodes.Pop);
				val.EmitDelegate<Func<Xoroshiro128Plus>>((Func<Xoroshiro128Plus>)(() => new Xoroshiro128Plus(0uL)));
			}
		}

		private void GenerateAll(ILContext context)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			ParameterDefinition numOptionsParameter = ((IEnumerable<ParameterDefinition>)((MethodReference)context.Method).Parameters).FirstOrDefault((Func<ParameterDefinition, bool>)((ParameterDefinition p) => ((ParameterReference)p).Name == "numOptions"));
			if (numOptionsParameter == null)
			{
				Log.Error("Failed to find numOptions parameter", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\DLC2.cs", "GenerateAll", 186);
				return;
			}
			ILCursor val = new ILCursor(context);
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupDropTable>(i, "GenerateDistinctPickups")
			}))
			{
				ILCursor val2 = val.Clone();
				if (val2.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ((ParameterReference)numOptionsParameter).Index)
				}))
				{
					val2.EmitDelegate<Func<int, int>>((Func<int, int>)getNumOptionsToGenerate);
				}
				val.SearchTarget = (SearchTarget)1;
			}
			static int getNumOptionsToGenerate(int numOptions)
			{
				return Math.Max(5, numOptions);
			}
		}

		private async void AddSceneToGroup(string collection, string stage)
		{
			AsyncOperationHandle<SceneCollection> group = Addressables.LoadAssetAsync<SceneCollection>((object)collection);
			AsyncOperationHandle<SceneDef> scene = Addressables.LoadAssetAsync<SceneDef>((object)stage);
			await group.Task;
			await scene.Task;
			if (((Behaviour)this).isActiveAndEnabled)
			{
				SceneEntry[] original = group.Result._sceneEntries;
				ref SceneEntry[] sceneEntries = ref group.Result._sceneEntries;
				SceneEntry val = new SceneEntry
				{
					sceneDef = scene.Result
				};
				ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries, ref val);
				_onDisable += delegate
				{
					group.Result._sceneEntries = original;
				};
			}
		}

		private async void ChangeDestination(string portal)
		{
			AsyncOperationHandle<GameObject> prefab = Addressables.LoadAssetAsync<GameObject>((object)portal);
			await prefab.Task;
			if (((Behaviour)this).isActiveAndEnabled)
			{
				SceneExitController controller = prefab.Result.GetComponent<SceneExitController>();
				bool useRunNextStageScene = controller.useRunNextStageScene;
				bool isAlternatePath = controller.isAlternatePath;
				controller.useRunNextStageScene = true;
				controller.isAlternatePath = false;
				_onDisable += delegate
				{
					controller.useRunNextStageScene = useRunNextStageScene;
					controller.isAlternatePath = isAlternatePath;
				};
			}
		}

		private async void ReplacePortals(string parent, string replacement)
		{
			AsyncOperationHandle<GameObject> prefab = Addressables.LoadAssetAsync<GameObject>((object)parent);
			AsyncOperationHandle<InteractableSpawnCard> card = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)replacement);
			await prefab.Task;
			await card.Task;
			if (!((Behaviour)this).isActiveAndEnabled)
			{
				return;
			}
			PortalSpawner[] components = prefab.Result.GetComponents<PortalSpawner>();
			foreach (PortalSpawner portal in components)
			{
				string spawnMessageToken = portal.spawnMessageToken;
				portal.spawnMessageToken = "PORTAL_STORM_OPEN";
				string spawnPreviewMessageToken = portal.spawnPreviewMessageToken;
				portal.spawnPreviewMessageToken = "PORTAL_STORM_WILL_OPEN";
				InteractableSpawnCard portalSpawnCard = portal.portalSpawnCard;
				portal.portalSpawnCard = card.Result;
				string previewChildName = portal.previewChildName;
				portal.previewChildName = "StormPortalIndicator";
				string[] invalidStages = portal.invalidStages;
				portal.invalidStages = Array.Empty<string>();
				_onDisable += delegate
				{
					portal.spawnMessageToken = spawnMessageToken;
					portal.spawnPreviewMessageToken = spawnPreviewMessageToken;
					portal.portalSpawnCard = portalSpawnCard;
					portal.previewChildName = previewChildName;
					portal.invalidStages = invalidStages;
				};
			}
		}

		public static bool CheckRoll(float percent, CharacterMaster master, Xoroshiro128Plus generator)
		{
			if (!(percent >= 100f))
			{
				if (percent <= 0f)
				{
					return false;
				}
				return CheckForLuck(percent, master, generator.nextNormalizedFloat * 100f);
			}
			return true;
		}

		public static bool CheckForLuck(float percent, CharacterMaster master, float roll)
		{
			float num = (Object.op_Implicit((Object)(object)master) ? Mathf.Ceil(master.luck) : 0f);
			float num2 = percent / 100f;
			if (!(num > 0f))
			{
				if (num < 0f)
				{
					num2 = Mathf.Pow(num2, 1f - num);
				}
			}
			else
			{
				num2 = 1f - Mathf.Pow(1f - num2, 1f + num);
			}
			if (roll < num2 * 100f)
			{
				if (roll >= percent)
				{
					GameObject bodyObject = master.GetBodyObject();
					CharacterBody val = default(CharacterBody);
					if (Object.op_Implicit((Object)(object)bodyObject) && bodyObject.TryGetComponent<CharacterBody>(ref val))
					{
						val.wasLucky = true;
					}
				}
				return true;
			}
			return false;
		}
	}
	public sealed class DLC3 : MonoBehaviour
	{
		private sealed class TeleporterAccessCodesLockController : MonoBehaviour
		{
			private TeleporterInteraction _teleporterInteraction;

			private void Awake()
			{
				_teleporterInteraction = ((Component)this).GetComponent<TeleporterInteraction>();
			}

			private void FixedUpdate()
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Invalid comparison between Unknown and I4
				if (NetworkServer.active)
				{
					_teleporterInteraction.locked = InstanceTracker.Any<SolusPathPortalTracker>() || ((int)TeleporterInteraction.instance.activationState <= 1 && !TeleporterInteraction.instance.isAccessingCodes);
				}
			}
		}

		private sealed class SolusHeartOfferingBodyController : MonoBehaviour
		{
			private CharacterBody _body;

			private void Awake()
			{
				_body = ((Component)this).GetComponent<CharacterBody>();
			}

			private void OnEnable()
			{
				_body.AddBuff(Buffs.Intangible);
			}

			private void OnDisable()
			{
				_body.RemoveBuff(Buffs.Intangible);
			}
		}

		private sealed class EyePortalLockController : MonoBehaviour
		{
			private GenericInteraction _interaction;

			[SystemInitializer(new Type[]
			{
				typeof(CraftableCatalog),
				typeof(PickupCatalog)
			})]
			private static void Init()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/EyePortal/EyePortal.prefab");
				val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Invalid comparison between Unknown and I4
					if (!handle.IsValid() || (int)handle.Status != 1 || !Object.op_Implicit((Object)(object)handle.Result))
					{
						Log.Error(string.Format("Failed to load eye portal prefab: {0}", handle.IsValid() ? ((object)handle.OperationException) : ((object)"invalid handle")), "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\DLC3.cs", "Init", 666);
					}
					else
					{
						UnityObjectExtensions.EnsureComponent<EyePortalLockController>(handle.Result);
					}
				};
			}

			private void Awake()
			{
				_interaction = ((Component)this).GetComponent<GenericInteraction>();
			}

			private void OnEnable()
			{
				Inventory.onInventoryChangedGlobal += onInventoryChangedGlobal;
				((UnityEvent<Interactor>)(object)_interaction.onActivation).AddListener((UnityAction<Interactor>)onInteract);
				refreshInteractability();
			}

			private void OnDisable()
			{
				Inventory.onInventoryChangedGlobal -= onInventoryChangedGlobal;
				((UnityEvent<Interactor>)(object)_interaction.onActivation).RemoveListener((UnityAction<Interactor>)onInteract);
			}

			private void onInventoryChangedGlobal(Inventory inventory)
			{
				CharacterMaster val = default(CharacterMaster);
				if (((Component)inventory).TryGetComponent<CharacterMaster>(ref val) && Object.op_Implicit((Object)(object)val.playerCharacterMasterController))
				{
					refreshInteractability();
				}
			}

			private void refreshInteractability()
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				bool flag = false;
				if (CraftableCatalog.resultToRecipeSearchTable.TryGetValue(PickupCatalog.FindPickupIndex(Items.MasterCore.itemIndex), out var value))
				{
					foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
					{
						if (!instance.isConnected)
						{
							continue;
						}
						CharacterMaster master = instance.master;
						if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory))
						{
							continue;
						}
						foreach (RecipeEntry item in value)
						{
							if (item.ValidateSelection(master.inventory))
							{
								flag = true;
								break;
							}
						}
						if (flag)
						{
							break;
						}
					}
				}
				_interaction.Networkinteractability = (Interactability)((!flag) ? 1 : 2);
			}

			private void onInteract(Interactor interactor)
			{
				((Behaviour)this).enabled = false;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Func<PickupIndex, bool> <0>__pickupIsValidTempItemFallback;

			public static Manipulator <1>__AccessCodesMissionController_OnStartServer;

			public static OrderedPickupTransmutationProvider.AllowPickupTransmutationDelegate <2>__allowTransmuteTemporaryItem;

			public static Func<Xoroshiro128Plus, Xoroshiro128Plus> <3>__getSalvageRng;

			public static Func<Xoroshiro128Plus, Xoroshiro128Plus> <4>__getItemRng;

			public static Func<int, int, int, TinkerProjectile, int> <5>__getRandomDebuffIndex;

			public static <>F{00000010}<MonoBehaviour, UniquePickup?, bool> <6>__tryGetSeededReroll;

			public static Func<PickupIndex, UniquePickup, PickupIndex> <7>__seededReroll;

			public static Func<Xoroshiro128Plus, Xoroshiro128Plus> <8>__overrideRng;
		}

		private static SceneIndex _solusWebSceneIndex = (SceneIndex)(-1);

		private static SceneIndex _computationalExchangeSceneIndex = (SceneIndex)(-1);

		private static Func<PickupIndex, bool> _pickupIsValidTempItemFunc;

		private static DLC3 _instance;

		private Xoroshiro128Plus _drifterItemRng;

		private Xoroshiro128Plus _drifterProjectileRng;

		private Xoroshiro128Plus _drifterTinkerRngGenerator;

		private Xoroshiro128Plus _junkDroneRng;

		private Xoroshiro128Plus _solusHeartBossRngGenerator;

		private OrderedPickupTransmutationProvider _temporaryItemRollTransmutationProvider;

		private ulong _tinkerInteractableBaseRerollSeed;

		private readonly Dictionary<int, OrderedDropTableTransmutationProvider> _interactableTinkerRerollProviders = new Dictionary<int, OrderedDropTableTransmutationProvider>();

		private OrderedPickupTransmutationProvider _pickupPickerTinkerRerollProvider;

		private SolusHeartOfferingBodyController _solusHeartOfferingBodyPrefabController;

		public static bool UseDLC3Path => Main.UseDLC3Path.Value;

		public static DLC3 Instance => _instance;

		[SystemInitializer(new Type[] { typeof(SceneCatalog) })]
		private static void Init()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			_solusWebSceneIndex = SceneCatalog.FindSceneIndex("solusweb");
			if ((int)_solusWebSceneIndex == -1)
			{
				Log.Error("Failed to find solus web scene index", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\DLC3.cs", "Init", 39);
			}
			_computationalExchangeSceneIndex = SceneCatalog.FindSceneIndex("computationalexchange");
			if ((int)_computationalExchangeSceneIndex == -1)
			{
				Log.Error("Failed to find computational exchange scene index", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\DLC3.cs", "Init", 45);
			}
			MethodInfo methodInfo = typeof(Util).GetMethods(BindingFlags.Static | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name.StartsWith("<RollTemporaryItemFromItemIndex>g__PickupIsNonBlacklistedItem|") && m.ReturnType == typeof(bool) && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(PickupIndex));
			if (methodInfo != null)
			{
				try
				{
					_pickupIsValidTempItemFunc = Extensions.CreateDelegate<Func<PickupIndex, bool>>((MethodBase)methodInfo);
				}
				catch (Exception data)
				{
					Log.Error_NoCallerPrefix(data);
				}
			}
			else
			{
				Log.Error("Failed to find PickupIsNonBlacklistedItem local function", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\DLC3.cs", "Init", 62);
			}
			if (_pickupIsValidTempItemFunc == null)
			{
				Log.Warning("Failed to get temporary pickup validator method, using fallback", "C:\\Users\\Erin\\Desktop\\Modding\\GauntletMod\\Gauntlet\\src\\DLC3.cs", "Init", 67);
				_pickupIsValidTempItemFunc = pickupIsValidTempItemFallback;
			}
			static bool pickupIsValidTempItemFallback(PickupIndex pickupIndex)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
				if (pickupDef == null)
				{
					return false;
				}
				ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
				if (!Object.op_Implicit((Object)(object)itemDef))
				{
					return false;
				}
				if (itemDef.DoesNotContainTag((ItemTag)33) && itemDef.DoesNotContainTag((ItemTag)10) && itemDef.DoesNotContainTag((ItemTag)9))
				{
					return itemDef.ContainsTag((ItemTag)31);
				}
				return false;
			}
		}

		private void OnEnable()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_00f2: Expected O, but got Unknown
			SingletonHelper.Assign<DLC3>(ref _instance, this);
			RunHooks.OnRunPostStartGlobal += onRunPostStartGlobal;
			Stage.onStageStartGlobal += onStageStartGlobal;
			Salvage.OnEnter += new Manipulator(Salvage_OnEnter);
			DrifterCleanupController.InitRng += new hook_InitRng(DrifterCleanupController_InitRng);
			Surprise.DropTempItemServer += new Manipulator(Surprise_DropTempItemServer);
			TinkerProjectile.ManageMonster += new Manipulator(TinkerProjectile_ManageMonster);
			BossGroup.Awake += new hook_Awake(BossGroup_Awake);
			Util.RollTemporaryItemFromItemIndex += new hook_RollTemporaryItemFromItemIndex(Util_RollTemporaryItemFromItemIndex);
			ShopTerminalBehavior.RerollPickup += new Manipulator(SeededTinkerRerollInteractablePatch);
			PickupDistributorBehavior.RerollPickup += new Manipulator(SeededTinkerRerollInteractablePatch);
			PickupPickerController.RerollCurrentOptions += new Manipulator(PickupPickerController_RerollCurrentOptions);
			CraftingController.CanTakePickupAfterUseByIngredientSlots += new hook_CanTakePickupAfterUseByIngredientSlots(CraftingController_CanTakePickupAfterUseByIngredientSlots);
			object obj = <>O.<1>__AccessCodesMissionController_OnStartServer;
			if (obj == null)
			{
				Manipulator val = AccessCodesMissionController_OnStartServer;
				<>O.<1>__AccessCodesMissionController_OnStartServer = val;
				obj = (object)val;
			}
			AccessCodesMissionController.OnStartServer += (Manipulator)obj;
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/SolusHeart/SolusHeartBody_Offering.prefab").WaitForCompletion();
			if (Object.op_Implicit((Object)(object)val2))
			{
				_solusHeartOfferingBodyPrefabController = UnityObjectExtensions.EnsureComponent<SolusHeartOfferingBodyController>(val2);
			}
		}

		private void OnDisable()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_00dc: 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_00e7: Expected O, but got Unknown
			RunHooks.OnRunPostStartGlobal -= onRunPostStartGlobal;
			Stage.onStageStartGlobal -= onStageStartGlobal;
			Salvage.OnEnter -= new Manipulator(Salvage_OnEnter);
			DrifterCleanupController.InitRng -= new hook_InitRng(DrifterCleanupController_InitRng);
			Surprise.DropTempItemServer -= new Manipulator(Surprise_DropTempItemServer);
			TinkerProjectile.ManageMonster -= new Manipulator(TinkerProjectile_ManageMonster);
			BossGroup.Awake -= new hook_Awake(BossGroup_Awake);
			Util.RollTemporaryItemFromItemIndex -= new hook_RollTemporaryItemFromItemIndex(Util_RollTemporaryItemFromItemIndex);
			ShopTerminalBehavior.RerollPickup -= new Manipulator(SeededTinkerRerollInteractablePatch);
			PickupDistributorBehavior.RerollPickup -= new Manipulator(SeededTinkerRerollInteractablePatch);
			PickupPickerController.RerollCurrentOptions -= new Manipulator(PickupPickerController_RerollCurrentOptions);
			CraftingController.CanTakePickupAfterUseByIngredientSlots -= new hook_CanTakePickupAfterUseByIngredientSlots(CraftingController_CanTakePickupAfterUseByIngredientSlots);
			object obj = <>O.<1>__AccessCodesMissionController_OnStartServer;
			if (obj == null)
			{
				Manipulator val = AccessCodesMissionController_OnStartServer;
				<>O.<1>__AccessCodesMissionController_OnStartServer = val;
				obj = (object)val;
			}
			AccessCodesMissionController.OnStartServer -= (Manipulator)obj;
			if (Object.op_Implicit((Object)(object)_solusHeartOfferingBodyPrefabController))
			{
				Object.Destroy((Object)(object)_solusHeartOfferingBodyPrefabController);
				_solusHeartOfferingBodyPrefabController = null;
			}
			SingletonHelper.Unassign<DLC3>(ref _instance, this);
		}

		public Xoroshiro128Plus GetNextTinkerProjectileRng()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (_drifterTinkerRngGenerator == null)
			{
				return null;
			}
			return new Xoroshiro128Plus(_drifterTinkerRngGenerator.nextUlong);
		}

		private void onRunPostStartGlobal(Run run)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got