Decompiled source of RngFix v2.3.0

RngFix.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Cysharp.Threading.Tasks;
using HarmonyLib;
using LBoL.Base;
using LBoL.Base.Extensions;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Adventures;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Cards;
using LBoL.Core.Randoms;
using LBoL.Core.Stations;
using LBoL.Core.Units;
using LBoL.EntityLib.Adventures;
using LBoL.EntityLib.Adventures.FirstPlace;
using LBoL.EntityLib.Adventures.Stage2;
using LBoL.EntityLib.Adventures.Stage3;
using LBoL.EntityLib.Cards.Character.Cirno;
using LBoL.EntityLib.Cards.Character.Marisa;
using LBoL.EntityLib.Cards.Character.Reimu;
using LBoL.EntityLib.Cards.Enemy;
using LBoL.EntityLib.Cards.Neutral.Black;
using LBoL.EntityLib.Cards.Neutral.MultiColor;
using LBoL.EntityLib.Cards.Neutral.NoColor;
using LBoL.EntityLib.Cards.Neutral.TwoColor;
using LBoL.EntityLib.Cards.Others;
using LBoL.EntityLib.EnemyUnits.Character;
using LBoL.EntityLib.EnemyUnits.Normal;
using LBoL.EntityLib.EnemyUnits.Normal.Bats;
using LBoL.EntityLib.EnemyUnits.Normal.Guihuos;
using LBoL.EntityLib.EnemyUnits.Normal.Maoyus;
using LBoL.EntityLib.EnemyUnits.Normal.Ravens;
using LBoL.EntityLib.EnemyUnits.Normal.Yinyangyus;
using LBoL.EntityLib.EnemyUnits.Opponent;
using LBoL.EntityLib.Exhibits;
using LBoL.EntityLib.Exhibits.Adventure;
using LBoL.EntityLib.Exhibits.Common;
using LBoL.EntityLib.Exhibits.Shining;
using LBoL.EntityLib.JadeBoxes;
using LBoL.EntityLib.Stages.NormalStages;
using LBoL.EntityLib.StatusEffects.Cirno;
using LBoL.EntityLib.StatusEffects.Enemy;
using LBoL.EntityLib.StatusEffects.Enemy.Seija;
using LBoL.EntityLib.StatusEffects.Marisa;
using LBoL.EntityLib.StatusEffects.Neutral.TwoColor;
using LBoL.EntityLib.StatusEffects.Neutral.White;
using LBoL.EntityLib.StatusEffects.Sakuya;
using LBoL.Presentation;
using LBoL.Presentation.UI;
using LBoL.Presentation.UI.Panels;
using LBoLEntitySideloader;
using LBoLEntitySideloader.CustomHandlers;
using LBoLEntitySideloader.Entities;
using LBoLEntitySideloader.PersistentValues;
using LBoLEntitySideloader.PersistentValues.TypeConverters;
using LBoLEntitySideloader.ReflectionHelpers;
using LBoLEntitySideloader.Resource;
using Logging;
using RngFix.CustomRngs;
using RngFix.CustomRngs.Sampling;
using RngFix.CustomRngs.Sampling.Pads;
using RngFix.CustomRngs.Sampling.UniformPools;
using RngFix.Patches;
using RngFix.Patches.Battle;
using RngFix.Patches.Debug;
using UnityEngine;
using YamlDotNet.Serialization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("RngFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RngFix")]
[assembly: AssemblyTitle("RngFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RngFix
{
	[BepInPlugin("neo.lbol.fix.rngFix", "RngFix", "2.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		private class GrRestore_Patch
		{
			private static void Postfix(GameRunController __result)
			{
				log.LogDebug((object)"restoredeez");
				__result.CardValidDebugLevel = 0;
			}
		}

		private static readonly Harmony harmony = PInfo.harmony;

		internal static ManualLogSource log;

		internal static TemplateSequenceTable sequenceTable = new TemplateSequenceTable(0);

		internal static IResourceSource embeddedSource = (IResourceSource)new EmbeddedSource(Assembly.GetExecutingAssembly());

		internal static DirectorySource directorySource = new DirectorySource("neo.lbol.fix.rngFix", "");

		public static ConfigEntry<bool> ignoreFactorsTableConf;

		public static ConfigEntry<bool> doLoggingConf;

		private KeyboardShortcut debgugBind = new KeyboardShortcut((KeyCode)121, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 });

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			ignoreFactorsTableConf = ((BaseUnityPlugin)this).Config.Bind<bool>("Rng", "IgnoreFactorsTable", true, "Disables the mechanic where card chance of appearing as a card reward is decreased if an offered card is not picked. Setting this to true greatly increases card reward consistency.");
			doLoggingConf = ((BaseUnityPlugin)this).Config.Bind<bool>("Stats", "DoLogging", false, "Log various run stats (card, exhibits etc.) to <gameSaveDir>/RngFix");
			EntityManager.AddPostLoadAction((Action)delegate
			{
				Padding.ResetPadCache();
			}, (Assembly)null);
			EntityManager.RegisterSelf();
			harmony.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
			{
				WatermarkWrapper.ActivateWatermark();
			}
			((CustomGameRunSaveData)new RngSaveContainer()).RegisterSelf("neo.lbol.fix.rngFix");
			PickCardLog.RegisterOnCardsAdded();
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
			bool flag = false;
		}
	}
	public static class PInfo
	{
		public const string GUID = "neo.lbol.fix.rngFix";

		public const string Name = "RngFix";

		public const string version = "2.3.0";

		public static readonly Harmony harmony = new Harmony("neo.lbol.fix.rngFix");
	}
	internal class WatermarkWrapper
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ActivateWatermark()
		{
			API.ActivateWatermark();
		}
	}
}
namespace RngFix.Patches
{
	[HarmonyPatch(typeof(GameRunController), "BaseCardWeight")]
	internal class KillCardFactors_Patch
	{
		private static bool IgnoreFactorTable()
		{
			return !BepinexPlugin.ignoreFactorsTableConf.Value;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: 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_0034: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(GameRunController), "_cardRewardWeightFactors"))) }).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null)
			}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Pop, (object)null)
			})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(KillCardFactors_Patch), "IgnoreFactorTable", (Type[])null, (Type[])null))
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(GameRunController), "GetShopCards")]
	internal class GetShopCards_Patch
	{
		private static int IgnoreFactorTable()
		{
			return (!BepinexPlugin.ignoreFactorsTableConf.Value) ? 1 : 0;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.operand is MethodBase methodBase && methodBase.Name == "RollCards")).MatchBack(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				CodeMatch.op_Implicit(OpCodes.Ldc_I4_1),
				CodeMatch.op_Implicit(OpCodes.Ldc_I4_0),
				CodeMatch.op_Implicit(OpCodes.Ldc_I4_0)
			}).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GetShopCards_Patch), "IgnoreFactorTable", (Type[])null, (Type[])null)))
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	public class ShopFactor_Patch
	{
		public static ConditionalWeakTable<CardWeightTable, string> wt_cwt = new ConditionalWeakTable<CardWeightTable, string>();

		public const float constRareFactor = 0.93f;

		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(Stage), "GetShopNormalCards", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(Stage), "SupplyShopCard", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(Stage), "GetShopToolCards", (Type[])null, (Type[])null);
		}

		private static CardWeightTable ModCardWTable(CardWeightTable cwt, string cwtName)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			CardWeightTable val = cwt;
			if (BepinexPlugin.ignoreFactorsTableConf.Value)
			{
				RarityWeightTable rarityTable = cwt.RarityTable;
				val = new CardWeightTable(new RarityWeightTable(rarityTable.Common, rarityTable.Uncommon, rarityTable.Rare * 0.93f, rarityTable.Mythic), cwt.OwnerTable, cwt.CardTypeTable, cwt.IncludeOutsideKeyword);
			}
			wt_cwt.AddOrUpdate(val, cwtName);
			return val;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0003: 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_0076: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).Start();
			while (val.IsValid)
			{
				val = val.SearchForward((Func<CodeInstruction, bool>)((CodeInstruction ci) => (ci.opcode == OpCodes.Call || ci.opcode == OpCodes.Callvirt) && ci.operand is MethodBase methodBase && methodBase.Name.StartsWith("get_Shop") && methodBase.Name.EndsWith("Weight")));
				if (val.IsValid)
				{
					string name = (val.Instruction.operand as MethodBase).Name;
					val = val.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldstr, (object)name)
					}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ShopFactor_Patch), "ModCardWTable", (Type[])null, (Type[])null))
					});
				}
			}
			return val.LeaveJumpFix().InstructionEnumeration();
		}
	}
	public static class GenerateTools
	{
		public static Card[] GetTools(Stage stage, int count, RandomGen rng)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			GameRunController gameRun = ((GameEntity)stage).GameRun;
			Card[] array = gameRun.RollCards(rng, stage.ShopToolCardWeight, count, (ManaGroup?)gameRun.BaseMana, gameRun.RewardAndShopCardColorLimitFlag == 0, false, false, false, (Predicate<CardConfig>)null);
			Card[] array2 = array;
			foreach (Card val in array2)
			{
				gameRun.UpgradeNewDeckCardOnFlags(val);
			}
			return array;
		}
	}
	[HarmonyPatch(typeof(RingoEmp), "InitVariables")]
	internal class RingoEmp_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: 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_0035: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(Stage), "GetShopToolCards", (Type[])null, (Type[])null))) }).Set(OpCodes.Call, (object)AccessTools.Method(typeof(GenerateTools), "GetTools", (Type[])null, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(GameRunController), "AdventureRng"))
			})
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GrRngs), "Gr", (Type[])null, (Type[])null))
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class FixBook_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return ExtraAccess.InnerMoveNext(typeof(FixBook), "SpecialGain");
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: 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_0035: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(Stage), "GetShopToolCards", (Type[])null, (Type[])null))) }).Set(OpCodes.Call, (object)AccessTools.Method(typeof(GenerateTools), "GetTools", (Type[])null, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ExhibitsSelfRngs), "GetSelfRng", new Type[2]
				{
					typeof(GameRunController),
					typeof(Exhibit)
				}, (Type[])null))
			})
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldloc_1, (object)null)
				})
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GrRngs), "Gr", (Type[])null, (Type[])null))
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class Gongjuxiang_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(Gongjuxiang), "<OnAdded>b__0_0", (Type[])null, (Type[])null);
		}

		private static string ExId()
		{
			return "Gongjuxiang";
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: 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_0035: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(Stage), "GetShopToolCards", (Type[])null, (Type[])null))) }).Set(OpCodes.Call, (object)AccessTools.Method(typeof(GenerateTools), "GetTools", (Type[])null, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ExhibitsSelfRngs), "GetSelfRng", new Type[2]
				{
					typeof(GameRunController),
					typeof(string)
				}, (Type[])null))
			})
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Gongjuxiang_Patch), "ExId", (Type[])null, (Type[])null))
				})
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GrRngs), "Gr", (Type[])null, (Type[])null))
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	public static class Helpers
	{
		public static CodeMatcher LeaveJumpFix(this CodeMatcher matcher)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			matcher.Start();
			while (matcher.IsValid)
			{
				matcher.MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(OpCodes.Leave) }).Advance(1);
				if (matcher.IsInvalid)
				{
					break;
				}
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Nop, (object)null)
				});
			}
			return matcher;
		}

		public static CodeMatcher ReplaceRngGetter(this CodeMatcher matcher, string targetName, MethodInfo newCall, MethodInfo targetMethod = null)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			if (targetMethod == null)
			{
				targetMethod = AccessTools.PropertyGetter(typeof(GameRunController), targetName);
			}
			if (targetMethod == null)
			{
				throw new ArgumentException(string.Format("Could not find {0}.{1}", "GameRunController", targetMethod));
			}
			CodeMatch val = new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.operand as MethodInfo == targetMethod), (string)null);
			return matcher.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { val }).ThrowIfNotMatch(targetName + " getter not matched.", (CodeMatch[])(object)new CodeMatch[1] { val }).Set(OpCodes.Call, (object)newCall);
		}

		private static int RngGuardSingle(IEnumerable<EnemyUnit> alives)
		{
			return (alives.Count() <= 1) ? 1 : 0;
		}

		private static int RngGuardMany(IEnumerable<EnemyUnit> alives, int amount)
		{
			int num = alives.Count();
			return (amount >= num || amount <= 0) ? 1 : 0;
		}

		private static RandomGen FakeRng()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			return new RandomGen();
		}

		public static CodeMatcher RngAdvancementGuard(this CodeMatcher matcher, ILGenerator generator, CodeMatch searchBackMatch = null, bool many = false, CodeMatch[] amountMatch = null, bool searchForAmountMatchFirst = false)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Expected O, but got Unknown
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Expected O, but got Unknown
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Expected O, but got Unknown
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Expected O, but got Unknown
			string text = matcher.Instruction.operand?.ToString() ?? "";
			if (!text.Contains("SampleOrDefault") && !text.Contains("SampleManyOrAll") && !text.Contains("Sample") && !text.Contains("SampleMany"))
			{
				throw new ArgumentException("Matcher's position is not on sampling method");
			}
			if (searchBackMatch == null)
			{
				searchBackMatch = new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Callvirt && ci.operand as MethodInfo == AccessTools.PropertyGetter(typeof(EnemyGroup), "Alives")), (string)null);
			}
			Label label = generator.DefineLabel();
			Label label2 = generator.DefineLabel();
			matcher.AddLabels((IEnumerable<Label>)new Label[1] { label2 }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Br, (object)label2)
			});
			if (many)
			{
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldstr, (object)"deezdeeznuts")
				});
			}
			else
			{
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Helpers), "FakeRng", (Type[])null, (Type[])null)), new Label[1] { label }) });
			}
			matcher.Advance(-1);
			if (amountMatch != null && searchForAmountMatchFirst)
			{
				matcher.ThrowIfNotMatchBack($"{amountMatch} didn't match anything", amountMatch).MatchStartBackwards(amountMatch).Advance(-1);
			}
			matcher.ThrowIfNotMatchBack($"{searchBackMatch} didn't match anything", (CodeMatch[])(object)new CodeMatch[1] { searchBackMatch }).MatchEndBackwards((CodeMatch[])(object)new CodeMatch[1] { searchBackMatch }).Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Dup, (object)null)
				});
			List<CodeInstruction> list = new List<CodeInstruction>();
			if (many)
			{
				if (amountMatch == null)
				{
					list.Add(matcher.Instruction);
				}
				else
				{
					matcher.ThrowIfNotMatchForward($"AmountMatch@{matcher.Pos}: {amountMatch} didn't match anything", amountMatch).MatchEndForward(amountMatch);
					list.AddRange(matcher.InstructionsWithOffsets(-amountMatch.Length + 1, 0));
				}
				matcher.Advance(1);
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Helpers), "RngGuardMany", (Type[])null, (Type[])null))
				});
			}
			else
			{
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Helpers), "RngGuardSingle", (Type[])null, (Type[])null))
				});
			}
			matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Brtrue, (object)label)
			});
			foreach (var (val, num) in list.Select((CodeInstruction ci, int i) => (ci, i)))
			{
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { val.Clone() });
			}
			if (many)
			{
				matcher.ThrowIfNotMatchForward("SATORRI", (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => (ci.operand?.ToString() ?? "") == "deezdeeznuts"), (string)null)
				});
				matcher.MatchEndForward((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => (ci.operand?.ToString() ?? "") == "deezdeeznuts"), (string)null)
				});
				foreach (var item in list.Select((CodeInstruction ci, int i) => (ci, i)))
				{
					var (val2, _) = item;
					if (item.Item2 == 0)
					{
						matcher.SetInstruction(val2.Clone()).AddLabels((IEnumerable<Label>)new Label[1] { label }).Advance(1);
					}
					else
					{
						matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { val2.Clone() });
					}
				}
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Helpers), "FakeRng", (Type[])null, (Type[])null))
				});
			}
			return matcher;
		}

		public static bool IsActTransition(MapNode node)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			return (int)node.StationType == 7 || (int)node.StationType == 8 || (int)node.StationType == 3 || (int)node.StationType == 9;
		}

		public static bool GetOrCreateVal<K, V>(this Dictionary<K, V> dic, K key, Func<V> valInit, out V value)
		{
			if (dic.TryGetValue(key, out value))
			{
				return true;
			}
			value = valInit();
			dic[key] = value;
			return false;
		}

		public static int BitArrayToInt(int[] bitArray)
		{
			int num = 0;
			for (int i = 0; i < bitArray.Length; i++)
			{
				if (bitArray[i] == 1)
				{
					num |= 1 << i;
				}
			}
			return num;
		}

		public static int CountSetBits(ulong n)
		{
			int num = 0;
			while (n != 0)
			{
				n &= n - 1;
				num++;
			}
			return num;
		}
	}
	[HarmonyPatch]
	internal class Gr_InitRngs_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Constructor(typeof(GameRunController), new Type[1] { typeof(GameRunStartupParameters) }, false);
		}

		internal static void InitRngs(GameRunController gr)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			BepinexPlugin.log.LogDebug((object)"Initing GrRngs..");
			orCreate.persRngs.stageMasterRng = new StageMasterRng(gr.RootRng.NextULong());
			orCreate.persRngs.actMasterRng = new ActMasterRng(gr.RootRng.NextULong());
			orCreate.persRngs.gapInitRng = new RandomGen(gr.RootRng.NextULong());
			orCreate.persRngs.shopInitRng = new RandomGen(gr.RootRng.NextULong());
			orCreate.persRngs.rareExhibitQueueRng = new RandomGen(gr.RootRng.NextULong());
			orCreate.persRngs.qingeUpgradeQueueRng = new RandomGen(gr.RootRng.NextULong());
			orCreate.persRngs.fallbackInitRng = new RandomGen(gr.RootRng.NextULong());
			orCreate.ExhibitSelfRngs = new EntitySelfRngs<Exhibit>((Exhibit ex) => ((GameEntity)ex).Id, gr.RootRng.NextULong());
			orCreate.ExhibitSelfRngs.InitialiseRngs(Padding.AllExhibits.Select((Type ec) => ec?.Name));
			RandomGen val = new RandomGen(gr.RootRng.NextULong());
			orCreate.persRngs.cardUpgradeQueueRng = new RandomGen(val.NextULong());
			orCreate.persRngs.eliteCardRng = new RandomGen(val.NextULong());
			orCreate.persRngs.bossCardRng = new RandomGen(val.NextULong());
			orCreate.persRngs.adventureSelfRngs = new EntitySelfRngs<Adventure>((Adventure a) => a.Id, gr.RootRng.NextULong());
			orCreate.persRngs.adventureSelfRngs.InitialiseRngs(from ac in Padding.AllAdventurePadding()
				select ac?.Name);
			orCreate.persRngs.shopRngs = ShopRngs.Init(gr.RootRng.NextULong());
			orCreate.persRngs.extraCardRewardRng = new RandomGen(gr.RootRng.NextULong());
			orCreate.unusedRoot0 = new RandomGen(gr.RootRng.NextULong());
			GrRngs.wr_midConstructGr.SetTarget(gr);
		}

		private static void Postfix()
		{
			GrRngs.wr_midConstructGr.SetTarget(null);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: 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_0034: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertySetter(typeof(GameRunController), "RootRng"))) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null)
			})
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Gr_InitRngs_Patch), "InitRngs", (Type[])null, (Type[])null))
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(GameMaster), "BattleStationFlowFromEndSave")]
	internal class ReEnterAfterBattle_Patch
	{
		private static void Prefix(GameMaster __instance)
		{
			GameRunController currentGameRun = __instance.CurrentGameRun;
			GrRngs orCreate = GrRngs.GetOrCreate(currentGameRun);
			if (orCreate.NodeMaster == null)
			{
				orCreate.NodeMaster = new NodeMasterRng
				{
					rng = RandomGen.FromState(orCreate.persRngs.prevNodeMasterState)
				};
				orCreate.NodeMaster.Advance(currentGameRun);
			}
		}
	}
	[HarmonyPatch(typeof(GameRunController), "EnterStation")]
	internal class EnterStation_Patch
	{
		private static void Prefix(GameRunController __instance, Station station)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected I4, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Invalid comparison between Unknown and I4
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			GrRngs orCreate = GrRngs.GetOrCreate(__instance);
			MapNode visitingNode = __instance.CurrentMap.VisitingNode;
			RandomGen val = null;
			StationType stationType = visitingNode.StationType;
			StationType val2 = stationType;
			switch ((int)val2)
			{
			case 0:
				val = orCreate.persRngs.fallbackInitRng;
				BepinexPlugin.log.LogWarning((object)$"Node({visitingNode.X}, {visitingNode.Y}) station type is {(object)(StationType)0} using fallback rng.");
				break;
			case 1:
				val = orCreate.persRngs.battleInitRng;
				break;
			case 2:
				val = orCreate.persRngs.eliteInitRng;
				break;
			case 3:
				orCreate.persRngs.actMasterRng.Advance(__instance);
				val = orCreate.persRngs.transitionInitRng;
				break;
			case 4:
				val = orCreate.persRngs.gapInitRng;
				break;
			case 5:
				val = orCreate.persRngs.shopInitRng;
				break;
			case 6:
				orCreate.NodeMaster = null;
				break;
			case 7:
				orCreate.persRngs.stageMasterRng.Advance(__instance);
				orCreate.persRngs.actMasterRng.Advance(__instance);
				val = orCreate.persRngs.transitionInitRng;
				break;
			case 8:
				orCreate.persRngs.actMasterRng.Advance(__instance);
				val = orCreate.persRngs.transitionInitRng;
				break;
			case 9:
				orCreate.persRngs.actMasterRng.Advance(__instance);
				val = orCreate.persRngs.transitionInitRng;
				break;
			case 10:
				val = orCreate.persRngs.bossInitRng;
				break;
			case 11:
				val = orCreate.persRngs.fallbackInitRng;
				break;
			}
			if (val != null)
			{
				orCreate.NodeMaster = new NodeMasterRng(val.NextULong());
				orCreate.NodeMaster.Advance(__instance);
			}
			else if ((int)visitingNode.StationType != 6)
			{
				BepinexPlugin.log.LogError((object)$"NodeRngs were not assigned for station {visitingNode.StationType}");
			}
		}

		private static void Postfix(GameRunController __instance)
		{
			StatsLogger.LogGeneral(__instance);
			StatsLogger.LogVanillaRngs(__instance);
			StatsLogger.LogPersistentRngs(__instance);
		}
	}
	[HarmonyPatch(typeof(AdventureStation), "OnEnter")]
	internal class InitAdventureNode_Patch
	{
		private static void SetNodeMaster(Type aType, Stage stage)
		{
			BepinexPlugin.log.LogDebug((object)$"{stage}: {aType}");
			GameRunController gameRun = ((GameEntity)stage).GameRun;
			GrRngs orCreate = GrRngs.GetOrCreate(gameRun);
			ulong seed = orCreate.persRngs.adventureSelfRngs.GetRng(aType.Name).NextULong();
			orCreate.NodeMaster = new NodeMasterRng(seed);
			orCreate.NodeMaster.Advance(gameRun);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0003: 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_0035: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(Stage), "GetAdventure", (Type[])null, (Type[])null))) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Dup, (object)null)
			})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(AdventureStation), "Stage"))
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(InitAdventureNode_Patch), "SetNodeMaster", (Type[])null, (Type[])null))
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Overrider), "OnEnteredWithMode")]
	internal class DoremyPortal_Patch
	{
		private static void Prefix(Overrider __instance)
		{
			GameRunController gameRun = __instance._gameRun;
			GrRngs.AdvanceRngsOnJump(gameRun, gameRun.CurrentMap.BossNode);
		}
	}
	[HarmonyPatch(typeof(GameRunController), "RollNormalExhibit")]
	[HarmonyPriority(200)]
	internal class ExhibitRoll_Patch
	{
		private static bool Prefix(GameRunController __instance, ref Exhibit __result, RandomGen rng, ExhibitWeightTable weightTable, Func<Exhibit> fallback, Predicate<ExhibitConfig> filter)
		{
			GrRngs orCreate = GrRngs.GetOrCreate(__instance);
			orCreate.NormalExSampler.successAction = delegate(Exhibit ex)
			{
				__instance.ExhibitPool.Remove(((object)ex).GetType());
			};
			__result = orCreate.NormalExSampler.Roll(rng, (Type t) => weightTable.WeightFor(ExhibitConfig.FromId(t.Name)) * Library.WeightForExhibit(t, __instance), out var logInfo, (Type t) => filter == null || filter(ExhibitConfig.FromId(t.Name)), fallback);
			orCreate.NormalExSampler.successAction = null;
			StatsLogger.LogEx(__result, __instance, logInfo);
			return false;
		}
	}
	[HarmonyPatch(typeof(Stage), "GetAdventure")]
	[HarmonyPriority(200)]
	internal class AdventureRoll_Patch
	{
		private static bool Prefix(Stage __instance, ref Type __result)
		{
			GameRunController gr = ((GameEntity)__instance).GameRun;
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			AdventureInPool adventureInPool = orCreate.AdventureSampler.requirements.Find((ISlotRequirement<Type> r) => r is AdventureInPool) as AdventureInPool;
			Dictionary<Type, float> t2W = new Dictionary<Type, float>();
			CollectionExtensions.Do<RandomPoolEntry<Type>>((IEnumerable<RandomPoolEntry<Type>>)__instance.AdventurePool, (Action<RandomPoolEntry<Type>>)delegate(RandomPoolEntry<Type> e)
			{
				t2W.TryAdd(e.Elem, e.Weight);
			});
			adventureInPool.poolSet = new HashSet<Type>(t2W.Keys);
			orCreate.AdventureSampler.successAction = delegate(Type t)
			{
				__instance.AdventurePool.Remove(t, true);
			};
			__result = orCreate.AdventureSampler.Roll(GrRngs.GetAdventureQueueRng(gr), delegate(Type t)
			{
				float value = 0f;
				t2W.TryGetValue(t, out value);
				return value * Library.WeightForAdventure(t, gr);
			}, out var logInfo, null, () => typeof(FakeAdventure));
			StatsLogger.LogEvent(__result, gr, logInfo);
			return false;
		}
	}
	[HarmonyPatch(typeof(GameRunController), "RollCards", new Type[]
	{
		typeof(RandomGen),
		typeof(CardWeightTable),
		typeof(int),
		typeof(ManaGroup?),
		typeof(bool),
		typeof(bool),
		typeof(bool),
		typeof(bool),
		typeof(Predicate<CardConfig>)
	})]
	[HarmonyPriority(200)]
	internal class CardRoll_Patch
	{
		private static bool Prefix(GameRunController __instance, ref Card[] __result, RandomGen rng, CardWeightTable weightTable, int count, ManaGroup? manaLimit, bool colorLimit, bool applyFactors = false, bool battleRolling = false, bool ensureCount = false, [MaybeNull] Predicate<CardConfig> filter = null)
		{
			GrRngs orCreate = GrRngs.GetOrCreate(__instance);
			List<Card> rolledCards = new List<Card>();
			CardInPool cardInPool = orCreate.RewardCardSampler.requirements.Find((ISlotRequirement<Type> r) => r is CardInPool) as CardInPool;
			cardInPool.poolSet = new HashSet<Type>(((IEnumerable<RandomPoolEntry<Type>>)__instance.CreateValidCardsPool(weightTable, manaLimit, colorLimit, applyFactors, battleRolling, filter)).Select((RandomPoolEntry<Type> re) => re.Elem));
			HashSet<string> charExSet = new HashSet<string> { ((GameEntity)__instance.Player).Id };
			if (__instance.AllCharacterCardsFlag > 0)
			{
				foreach (PlayerUnitConfig item in PlayerUnitConfig.AllConfig())
				{
					charExSet.Add(item.Id);
				}
			}
			else
			{
				foreach (Exhibit exhibit in __instance.Player.Exhibits)
				{
					if (exhibit.OwnerId != null)
					{
						charExSet.Add(exhibit.OwnerId);
					}
				}
			}
			Func<Type, float> getW = delegate(Type t)
			{
				CardConfig val2 = CardConfig.FromId(t.Name);
				float num = weightTable.WeightFor(val2, ((GameEntity)__instance.Player).Id, (ISet<string>)charExSet);
				float num2 = __instance.BaseCardWeight(val2, false);
				return num * num2;
			};
			CsvLogger log = ((__instance.Battle == null) ? StatsLogger.GetCardLog(__instance) : StatsLogger.GetCardGenLog(__instance));
			for (int i = 0; i < count; i++)
			{
				ulong state = rng.State;
				SamplerLogInfo logInfo;
				Card val = orCreate.RewardCardSampler.Roll(rng, getW, out logInfo, (Type t) => rolledCards.All((Card c) => ((object)c).GetType() != t));
				if (val == null)
				{
					if (!ensureCount)
					{
						StatsLogger.LogCard(log, val, __instance, logInfo);
						break;
					}
					BepinexPlugin.log.LogWarning((object)"ENSURING COUNT ENSURING COUNT ENSURING COUNT");
					rng.State = state;
					val = orCreate.RewardCardSampler.Roll(rng, getW, out logInfo);
				}
				if (val != null)
				{
					rolledCards.Add(val);
				}
				StatsLogger.LogCard(log, val, __instance, logInfo);
			}
			__result = rolledCards.ToArray();
			return false;
		}
	}
}
namespace RngFix.Patches.Stages
{
	[HarmonyPatch(typeof(BambooForest), "GetEliteEnemies")]
	internal class BambooForest_EliteSample_Patch
	{
		private static string SampleFirstElite(UniqueRandomPool<string> _, RandomGen rng, BambooForest stage)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			UniqueRandomPool<string> val = new UniqueRandomPool<string>(((Stage)stage).EliteEnemyPool);
			RandomGen val2 = new RandomGen((ulong)rng.NextInt(0, int.MaxValue));
			string text = "Aya";
			if (val._entries.All((RandomPoolEntry<string> e) => e.Elem == "Aya") && ((IEnumerable<RandomPoolEntry<string>>)val._fallbackPool).All((RandomPoolEntry<string> e) => e.Elem == "Aya"))
			{
				return text;
			}
			while (text == "Aya")
			{
				text = val.Sample(val2);
			}
			return text;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Callvirt && ci.operand.ToString().Contains("Sample"))).SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(BambooForest_EliteSample_Patch), "SampleFirstElite", (Type[])null, (Type[])null))).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null)
			})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
}
namespace RngFix.Patches.RngGetters
{
	[HarmonyPatch(typeof(GameRunController), "GetRewardCards")]
	internal class CardReward_Patch
	{
		private static RandomGen SwitchCardRng(GameRunController gr)
		{
			StackFrame stackFrame = new StackFrame(2);
			string name = stackFrame.GetMethod().Name;
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			return (RandomGen)(name switch
			{
				"GetEnemyCardReward" => gr.CardRng, 
				"GetEliteEnemyCardReward" => gr.CardRng, 
				"GetBossCardReward" => GrRngs.GetBossCardRng(gr), 
				"GetDrinkTeaCardReward" => orCreate.ExhibitSelfRngs.GetRng("HuangyouJiqiren"), 
				_ => gr.CardRng, 
			});
		}

		private static RandomGen ExtraCardRewardRng(GameRunController gr)
		{
			return GrRngs.GetOrCreate(gr).persRngs.extraCardRewardRng;
		}

		private static RandomGen UpgradeRng(GameRunController gr)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			RandomGen cardUpgradeQueueRng = GrRngs.GetOrCreate(gr).persRngs.cardUpgradeQueueRng;
			return new RandomGen(cardUpgradeQueueRng.NextULong());
		}

		private static float UpgradeFloat(RandomGen rng)
		{
			return rng.NextFloat(0f, 1f);
		}

		private static bool CheckRepeatRareBoss(bool repeat, bool boss)
		{
			return repeat && !boss;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Expected O, but got Unknown
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			val = val.MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(GameRunController), "_cardRewardDecreaseRepeatRare"))) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldarg_S, (object)6)
			})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(CardReward_Patch), "CheckRepeatRareBoss", (Type[])null, (Type[])null))
				});
			for (int i = 0; i < 3; i++)
			{
				val = val.ReplaceRngGetter("CardRng", AccessTools.Method(typeof(CardReward_Patch), "SwitchCardRng", (Type[])null, (Type[])null));
			}
			val = val.ReplaceRngGetter("CardRng", AccessTools.Method(typeof(CardReward_Patch), "ExtraCardRewardRng", (Type[])null, (Type[])null));
			LocalBuilder localBuilder = generator.DeclareLocal(typeof(RandomGen));
			LocalBuilder localBuilder2 = generator.DeclareLocal(typeof(float));
			val.MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(GameRunController), "CardRng"))) }).MatchEndBackwards((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldarg_0, (object)null)) }).RemoveInstructions(5)
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldloc, (object)localBuilder2.LocalIndex)
				})
				.MatchEndBackwards((CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null)
				})
				.Advance(-1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(CardReward_Patch), "UpgradeRng", (Type[])null, (Type[])null))
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Stloc, (object)localBuilder.LocalIndex)
				})
				.MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldloca_S, (object)null)) })
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldloc, (object)localBuilder.LocalIndex)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(CardReward_Patch), "UpgradeFloat", (Type[])null, (Type[])null))
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Stloc, (object)localBuilder2.LocalIndex)
				});
			return val.LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class RareExhibitRoll_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(MiyoiBartender), "InitVariables", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(YachieOppression), "InitVariables", (Type[])null, (Type[])null);
		}

		public static Exhibit RollExhibitInAdventure(Stage stage, ExhibitWeightTable weightTable, Predicate<ExhibitConfig> filter = null)
		{
			GameRunController gameRun = ((GameEntity)stage).GameRun;
			return gameRun.RollNormalExhibit(gameRun.AdventureRng, weightTable, (Func<Exhibit>)stage.GetSentinelExhibit, filter);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(Stage), "RollExhibitInAdventure", (Type[])null, (Type[])null))) }).Set(OpCodes.Call, (object)AccessTools.Method(typeof(RareExhibitRoll_Patch), "RollExhibitInAdventure", (Type[])null, (Type[])null)).LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class MoneyReward_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(BossStation), "GenerateRewards", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(Station), "GenerateEliteEnemyRewards", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(Station), "GenerateEnemyRewards", (Type[])null, (Type[])null);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			CodeMatcher matcher = new CodeMatcher(instructions, (ILGenerator)null);
			while (true)
			{
				try
				{
					matcher = matcher.ReplaceRngGetter("GameRunEventRng", AccessTools.Method(typeof(GrRngs), "GetMoneyRewardRng", (Type[])null, (Type[])null));
				}
				catch (InvalidOperationException)
				{
					break;
				}
			}
			return matcher.LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(GameRunController), "GetShopCards")]
	internal class GetShopCards_Patch
	{
		private static RandomGen ReplaceShopRng(GameRunController gr, CardWeightTable cwt)
		{
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			ShopRngs shopRngs = orCreate.persRngs.shopRngs;
			if (!ShopFactor_Patch.wt_cwt.TryGetValue(cwt, out var value))
			{
				BepinexPlugin.log.LogWarning((object)"No matching CardWeightTable found. Using fallback rng.");
				return shopRngs.fallbackRng;
			}
			if (!shopRngs.rngs.TryGetValue(value, out var value2))
			{
				BepinexPlugin.log.LogWarning((object)("No matching cwtName " + value + " in shop rngs. Using fallback rng"));
				return shopRngs.fallbackRng;
			}
			return value2;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ShopRng", AccessTools.Method(typeof(GetShopCards_Patch), "ReplaceShopRng", (Type[])null, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldarg_2, (object)null)
			}).LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Stage), "GetShopExhibit")]
	internal class GetShopExhibit_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ShopRng", AccessTools.Method(typeof(GrRngs), "GetShopExRng", (Type[])null, (Type[])null)).LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Stage), "GetEnemies")]
	internal class GetEnemies_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			MethodInfo newCall = AccessTools.Method(typeof(GrRngs), "GetEnemyActQueueRng", (Type[])null, (Type[])null);
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", newCall).ReplaceRngGetter("StationRng", newCall).ReplaceRngGetter("StationRng", newCall)
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class GetEliteEnemies_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(Stage), "GetEliteEnemies", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(BambooForest), "GetEliteEnemies", (Type[])null, (Type[])null);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", AccessTools.Method(typeof(GrRngs), "GetEliteQueueRng", (Type[])null, (Type[])null)).LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Stage), "GetAdventure")]
	internal class GetAdventure_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", AccessTools.Method(typeof(GrRngs), "GetAdventureQueueRng", (Type[])null, (Type[])null)).LeaveJumpFix().InstructionEnumeration();
		}
	}
}
namespace RngFix.Patches.Exhibits
{
	[HarmonyPatch(typeof(GameRunController), "RollShiningExhibit")]
	internal class RollShiningExhibit_Patch
	{
		public const float maxTotalWeight = 200f;

		private static Type ConsistentExSample(RepeatableRandomPool<Type> pool, RandomGen rng, GameRunController gr)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			RandomGen val = new RandomGen(rng.NextULong());
			RepeatableRandomPool<Type> val2 = new RepeatableRandomPool<Type>(pool);
			float num = pool._entries.Sum((RandomPoolEntry<Type> e) => e.Weight);
			if (200f > num)
			{
				val2.Add((Type)null, 200f - num);
			}
			else
			{
				BepinexPlugin.log.LogWarning((object)$"Total shining exhibit weight {num} exceed {200f}");
			}
			Type type = null;
			int num2 = 0;
			int num3 = 1000000;
			while (type == null && num2 < num3)
			{
				type = val2.Sample(val);
				num2++;
			}
			if (type == null)
			{
				type = pool.Sample(val);
				BepinexPlugin.log.LogWarning((object)$"Shinning exhibit not sampled in {num2} rolls. Using fallback.");
			}
			return type;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).SearchForward((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Callvirt && ci.operand is MethodBase methodBase && methodBase.Name == "Sample")).ThrowIfInvalid("").SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RollShiningExhibit_Patch), "ConsistentExSample", (Type[])null, (Type[])null)))
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null)
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class LightBulb_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return ExtraAccess.InnerMoveNext(typeof(GapOptionsPanel), "GetRareCardRunner");
		}

		private static string LightBulbId()
		{
			return "ShanliangDengpao";
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "AdventureRng", AccessTools.Method(typeof(ExhibitsSelfRngs), "GetSelfRng", new Type[2]
			{
				typeof(GameRunController),
				typeof(string)
			}, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LightBulb_Patch), "LightBulbId", (Type[])null, (Type[])null))
			}).LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class MagicGuideBook_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return ExtraAccess.InnerMoveNext(typeof(Modaoshu), "SpecialGain");
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "CardRng", AccessTools.Method(typeof(ExhibitsSelfRngs), "GetSelfRng", new Type[2]
			{
				typeof(GameRunController),
				typeof(Exhibit)
			}, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null)
			}).LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class FragmentsOfTheWorld_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return ExtraAccess.InnerMoveNext(typeof(ShijieSuipian), "SpecialGain");
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "GameRunEventRng", AccessTools.Method(typeof(ExhibitsSelfRngs), "GetSelfRng", new Type[2]
			{
				typeof(GameRunController),
				typeof(Exhibit)
			}, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null)
			}).ReplaceRngGetter("GameRunEventRng", AccessTools.Method(typeof(ExhibitsSelfRngs), "GetSelfRng", new Type[2]
			{
				typeof(GameRunController),
				typeof(Exhibit)
			}, (Type[])null))
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldloc_1, (object)null)
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class UpgradeRandomCards_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(Chaidao), "OnGain", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(Jiaobu), "OnGain", (Type[])null, (Type[])null);
			yield return AccessTools.Method(typeof(QipaiYouhua), "OnGain", (Type[])null, (Type[])null);
		}

		public static void UpgradeRandomCards(GameRunController gr, int amount = 1, CardType? type = null, Exhibit exhibit = null)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (amount <= 0)
			{
				throw new InvalidOperationException("DEEZNUTS");
			}
			List<Card> list = new List<Card>();
			foreach (Card item in gr._baseDeck)
			{
				if (!item.CanUpgradeAndPositive)
				{
					continue;
				}
				if (type.HasValue)
				{
					if (item.CardType == type.Value)
					{
						list.Add(item);
					}
				}
				else
				{
					list.Add(item);
				}
			}
			Card[] array = CollectionsExtensions.SampleManyOrAll<Card>((IEnumerable<Card>)list, amount, GrRngs.GetOrCreate(gr).ExhibitSelfRngs.GetRng(exhibit));
			gr.UpgradeDeckCards((IEnumerable<Card>)array, false);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameRunController), "UpgradeRandomCards", (Type[])null, (Type[])null))) }).Set(OpCodes.Call, (object)AccessTools.Method(typeof(UpgradeRandomCards_Patch), "UpgradeRandomCards", (Type[])null, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null)
			})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
}
namespace RngFix.Patches.Events
{
	[HarmonyPatch(typeof(GameRunController), "GetOpponentCandidates")]
	internal class GameRunController_GetOpponentCandidates_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", AccessTools.PropertyGetter(typeof(GameRunController), "AdventureRng")).LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class GameMaster_SelectStationFlow_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return ExtraAccess.InnerMoveNext(typeof(GameMaster), "SelectStationFlow");
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "RootRng", AccessTools.PropertyGetter(typeof(GameRunController), "AdventureRng")).LeaveJumpFix().InstructionEnumeration();
		}
	}
	public class DancersRng
	{
		public RandomGen optionRng;

		public RandomGen toolRng;

		public RandomGen exhibitRng;

		public RandomGen abilityRng;
	}
	[HarmonyPatch(typeof(BackgroundDancers))]
	internal class DancersInit_Patch
	{
		private static ConditionalWeakTable<BackgroundDancers, DancersRng> table = new ConditionalWeakTable<BackgroundDancers, DancersRng>();

		public static DancersRng GerOrCreateRng(Adventure adventure)
		{
			BackgroundDancers val = (BackgroundDancers)(object)((adventure is BackgroundDancers) ? adventure : null);
			if (val != null)
			{
				return table.GetOrCreateValue(val);
			}
			return null;
		}

		public static RandomGen GetOptionRng(BackgroundDancers bd)
		{
			return GerOrCreateRng((Adventure)(object)bd).optionRng;
		}

		public static RandomGen GetToolRng(BackgroundDancers bd)
		{
			return GerOrCreateRng((Adventure)(object)bd).toolRng;
		}

		public static RandomGen GetExhibitRng(BackgroundDancers bd)
		{
			return GerOrCreateRng((Adventure)(object)bd).exhibitRng;
		}

		public static RandomGen GetAbilityRng(BackgroundDancers bd)
		{
			return GerOrCreateRng((Adventure)(object)bd).abilityRng;
		}

		[HarmonyPatch("InitVariables")]
		[HarmonyPrefix]
		private static void InitPrefix(BackgroundDancers __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			DancersRng dancersRng = GerOrCreateRng((Adventure)(object)__instance);
			GameRunController gameRun = ((Adventure)__instance).GameRun;
			dancersRng.optionRng = new RandomGen(gameRun.AdventureRng.NextULong());
			dancersRng.toolRng = new RandomGen(gameRun.AdventureRng.NextULong());
			dancersRng.exhibitRng = new RandomGen(gameRun.AdventureRng.NextULong());
			dancersRng.abilityRng = new RandomGen(gameRun.AdventureRng.NextULong());
		}
	}
	[HarmonyPatch]
	internal class DancersRollSelect_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Method(typeof(BackgroundDancers), "RollOptions", (Type[])null, (Type[])null);
			yield return ExtraAccess.InnerMoveNext(typeof(BackgroundDancers), "SelectOption");
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			OpCode opCode = ((__originalMethod.Name == "MoveNext") ? OpCodes.Ldloc_1 : OpCodes.Ldarg_0);
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "AdventureRng", AccessTools.Method(typeof(DancersInit_Patch), "GetOptionRng", (Type[])null, (Type[])null)).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(opCode, (object)null)
			}).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Pop, (object)null)
			})
				.ReplaceRngGetter("AdventureRng", AccessTools.Method(typeof(DancersInit_Patch), "GetToolRng", (Type[])null, (Type[])null))
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(opCode, (object)null)
				})
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Pop, (object)null)
				})
				.ReplaceRngGetter("AdventureRng", AccessTools.Method(typeof(DancersInit_Patch), "GetAbilityRng", (Type[])null, (Type[])null))
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(opCode, (object)null)
				})
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Pop, (object)null)
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Stage), "GetSpecialAdventureExhibit")]
	internal class GetSpecialAdventureExhibit_Patch
	{
		private static RandomGen GetRng(GameRunController gr)
		{
			try
			{
				VnPanel panel = UiManager.GetPanel<VnPanel>();
				Adventure currentAdventure = panel._currentAdventure;
				RandomGen val = DancersInit_Patch.GerOrCreateRng(currentAdventure)?.exhibitRng;
				if (val != null)
				{
					return val;
				}
			}
			catch (InvalidOperationException)
			{
			}
			return gr.ExhibitRng;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ExhibitRng", AccessTools.Method(typeof(GetSpecialAdventureExhibit_Patch), "GetRng", (Type[])null, (Type[])null)).LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(MiyoiBartender), "InitVariables")]
	internal class MiyoiBartender_InitVariables_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", AccessTools.PropertyGetter(typeof(GameRunController), "AdventureRng")).LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(RinnosukeTrade), "GetExhibitPrice")]
	internal class RinnosukeTrade_GetExhibitPrice_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ShopRng", AccessTools.Method(typeof(GrRngs), "GetTransitionRng", (Type[])null, (Type[])null)).LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(SumirekoGathering), "InitVariables")]
	internal class SumirekoGathering_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "AdventureRng", AccessTools.Method(typeof(GrRngs), "GetTransitionRng", (Type[])null, (Type[])null)).LeaveJumpFix().InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Stage), "GetSupplyExhibit")]
	internal class GetSupplyExhibit_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ExhibitRng", AccessTools.Method(typeof(GrRngs), "GetTransitionRng", (Type[])null, (Type[])null)).LeaveJumpFix().InstructionEnumeration();
		}
	}
	internal class Yachie
	{
	}
}
namespace RngFix.Patches.Debug
{
	internal class PickCardLog
	{
		public static void RegisterOnCardsAdded()
		{
			CHandlerManager.RegisterGameEventHandler<CardsEventArgs>((EventProvider<CardsEventArgs, GameRunController>)((GameRunController gr) => gr.DeckCardsAdded), (GameEventHandler<CardsEventArgs>)delegate(CardsEventArgs args)
			{
				CollectionExtensions.Do<IGrouping<string, Card>>(from c in args.Cards
					group c by ((c != null) ? ((GameEntity)c).Id : null) ?? "null", (Action<IGrouping<string, Card>>)delegate(IGrouping<string, Card> cg)
				{
					StatsLogger.LogPickedCard(cg.FirstOrDefault(), cg.Count(), StatsLogger.Gr());
				});
			}, (GameEventPriority)10);
		}
	}
	internal class RngGetDebug_Patch
	{
		private static MethodInfo adventureRng = AccessTools.PropertyGetter(typeof(GameRunController), "AdventureRng");

		private static IEnumerable<MethodBase> TargetMethods()
		{
			return from pi in typeof(GameRunController).GetProperties()
				where pi.Name.EndsWith("Rng")
				select pi.GetMethod;
		}

		private static void Postfix(MethodBase __originalMethod, RandomGen __result)
		{
			if (__originalMethod.Name.StartsWith("get_Adventure"))
			{
				BepinexPlugin.log.LogDebug((object)$"adventureRng state: {((__result != null) ? new ulong?(__result.State) : null)}");
			}
			if (__originalMethod.Name.StartsWith("get_CardRng"))
			{
			}
			if (!__originalMethod.Name.StartsWith("get_DebutRng"))
			{
			}
		}
	}
	internal class rollDeez_patch
	{
		private static void Prefix()
		{
			BepinexPlugin.log.LogDebug((object)"rolling Deez");
		}
	}
	[HarmonyPatch(typeof(Debut), "InitVariables")]
	internal class debutdeez_Patch
	{
		private static void nuts(RandomGen rng)
		{
			BepinexPlugin.log.LogDebug((object)$"true debutRng state: {rng.State}");
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			return Helpers.LeaveJumpFix(new CodeMatcher(instructions, (ILGenerator)null)).InstructionEnumeration();
		}
	}
	internal class naz_Patch
	{
		private static void Prefix(int resultIndex)
		{
			BepinexPlugin.log.LogDebug((object)$"rez: {resultIndex}");
			StackTrace stackTrace = new StackTrace();
			BepinexPlugin.log.LogDebug((object)"---------------");
			StackFrame[] frames = stackTrace.GetFrames();
			foreach (StackFrame stackFrame in frames)
			{
				BepinexPlugin.log.LogDebug((object)(stackFrame.GetMethod().DeclaringType.FullName + "::" + stackFrame.GetMethod().Name));
			}
			BepinexPlugin.log.LogDebug((object)"---------------");
		}
	}
	internal class VnPanel_Patch
	{
		private static void Prefix(string command, RuntimeCommandHandler extraCommandHandler)
		{
			BepinexPlugin.log.LogDebug((object)$"{command}, {extraCommandHandler}");
		}
	}
	internal class RandomGenNext_Patch
	{
		private static bool CheckSt(StackTrace st)
		{
			return st.GetFrames().FirstOrDefault((StackFrame st) => st.GetMethod().Name.Contains("RollCards")) != null;
		}

		private static void Prefix(RandomGen __instance)
		{
			StackTrace st = new StackTrace();
			if (CheckSt(st))
			{
				BepinexPlugin.log.LogDebug((object)$"before{__instance.State}---------------");
			}
		}

		private static void Postfix(RandomGen __instance)
		{
			StackTrace stackTrace = new StackTrace();
			if (CheckSt(stackTrace))
			{
				StackFrame[] frames = stackTrace.GetFrames();
				foreach (StackFrame stackFrame in frames)
				{
					BepinexPlugin.log.LogDebug((object)(stackFrame.GetMethod().DeclaringType.FullName + "::" + stackFrame.GetMethod().Name));
				}
				BepinexPlugin.log.LogDebug((object)$"after{__instance.State}---------------");
			}
		}
	}
	internal class Up_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return typeof(UniqueRandomPool<>).MakeGenericType(typeof(Card)).GetMethod("Sample", new Type[1] { typeof(Func<float, float, float>) });
		}

		private static GameRunController Gr()
		{
			GameMaster instance = Singleton<GameMaster>.Instance;
			return (instance != null) ? instance.CurrentGameRun : null;
		}

		private static bool CheckSt()
		{
			StackTrace stackTrace = new StackTrace();
			return stackTrace.GetFrames().FirstOrDefault((StackFrame st) => st.GetMethod().Name.StartsWith("RollCards")) != null;
		}

		private static void W1(float w)
		{
			if (CheckSt())
			{
				ManualLogSource log = BepinexPlugin.log;
				GameRunController obj = Gr();
				ulong? obj2;
				if (obj == null)
				{
					obj2 = null;
				}
				else
				{
					RandomGen cardRng = obj.CardRng;
					obj2 = ((cardRng != null) ? new ulong?(cardRng.State) : null);
				}
				log.LogDebug((object)$"state before: {obj2}");
				BepinexPlugin.log.LogDebug((object)$"total weights: {w}");
			}
		}

		private static void W2(float w)
		{
			if (CheckSt())
			{
				BepinexPlugin.log.LogDebug((object)$"rolled weight: {w}");
				ManualLogSource log = BepinexPlugin.log;
				GameRunController obj = Gr();
				ulong? obj2;
				if (obj == null)
				{
					obj2 = null;
				}
				else
				{
					RandomGen cardRng = obj.CardRng;
					obj2 = ((cardRng != null) ? new ulong?(cardRng.State) : null);
				}
				log.LogDebug((object)$"state after: {obj2}");
			}
		}

		private static void PrintCard(object o, string s)
		{
			if (o is Type type && type.IsSubclassOf(typeof(Card)))
			{
				BepinexPlugin.log.LogDebug((object)(s + type.Name));
				BepinexPlugin.log.LogDebug((object)"-----");
			}
		}

		private static void PrintDefault(object o)
		{
			PrintCard(o, "(Default roll) ");
		}

		private static void PrintCond(object o)
		{
			PrintCard(o, "(Conditional roll) ");
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Stloc_0, (object)null)) }).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Dup, (object)null)
			}).Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Up_Patch), "W1", (Type[])null, (Type[])null))
				})
				.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Stloc_1, (object)null)) })
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Dup, (object)null)
				})
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Up_Patch), "W2", (Type[])null, (Type[])null))
				})
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ret, (object)null)) })
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Dup, (object)null)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Up_Patch), "PrintDefault", (Type[])null, (Type[])null))
				})
				.Advance(1)
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ret, (object)null)) })
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Dup, (object)null)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Up_Patch), "PrintCond", (Type[])null, (Type[])null))
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	internal class NormalizeWeights_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return typeof(UniqueRandomPool<>).MakeGenericType(typeof(Card)).GetMethod("Sample", new Type[1] { typeof(Func<float, float, float>) });
		}

		private static float DivideItemWeight(float w, float totalW)
		{
			return w / totalW;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[2]
			{
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldc_R4, (object)0f)),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldloc_0, (object)null))
			}).Set(OpCodes.Ldc_R4, (object)1f).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(RandomPoolEntry<Card>), "Weight"))) })
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldloc_0, (object)null)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(NormalizeWeights_Patch), "DivideItemWeight", (Type[])null, (Type[])null))
				})
				.Advance(1)
				.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(RandomPoolEntry<Card>), "Weight"))) })
				.Advance(1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldloc_0, (object)null)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(NormalizeWeights_Patch), "DivideItemWeight", (Type[])null, (Type[])null))
				})
				.LeaveJumpFix()
				.InstructionEnumeration();
		}
	}
	public class RngGetDebugCardDef : CardTemplate
	{
		public class RngGetDebugCard : Card
		{
			private ManaGroup suspendCost;

			private bool shouldSuspend;

			public ManaGroup SuspendCost => suspendCost;

			public bool ShouldSuspend
			{
				get
				{
					return shouldSuspend;
				}
				set
				{
					shouldSuspend = value;
				}
			}

			public ManaGroup NaturalCost
			{
				get
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
					//IL_0039: Unknown result type (might be due to invalid IL or missing references)
					//IL_003f: 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_004a: Unknown result type (might be due to invalid IL or missing references)
					//IL_004f: 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)
					//IL_0058: Unknown result type (might be due to invalid IL or missing references)
					//IL_005d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_0035: Unknown result type (might be due to invalid IL or missing references)
					//IL_0069: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0066: Unknown result type (might be due to invalid IL or missing references)
					//IL_006f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0084: Unknown result type (might be due to invalid IL or missing references)
					//IL_008a: Invalid comparison between Unknown and I4
					//IL_00af: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
					//IL_0096: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
					if (((Card)this).IsXCost)
					{
						return ((Card)this).BaseCost;
					}
					if (((Card)this).FreeCost || ((Card)this).Summoned)
					{
						return ManaGroup.Empty;
					}
					ManaGroup val = ((Card)this).TurnCost + ((Card)this).AdditionalCost + ((Card)this).AuraCost;
					ManaGroup corrected = ((ManaGroup)(ref val)).Corrected;
					corrected = (((Card)this).IsPurified ? ManaGroupExtensions.Purified(corrected) : corrected);
					BattleController battle = ((Card)this).Battle;
					if (battle != null && battle.ManaFreezeLevel > 0 && (int)((Card)this).Zone == 2)
					{
						return corrected + ManaGroup.Anys(((Card)this).Battle.ManaFreezeLevel);
					}
					return corrected;
				}
			}

			public override ManaGroup ForceCost => SuspendCost;

			public override bool IsForceCost
			{
				get
				{
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					if (((Card)this).Battle != null)
					{
						ManaGroup battleMana = ((Card)this).Battle.BattleMana;
						if (!((ManaGroup)(ref battleMana)).CanAfford(NaturalCost))
						{
							ShouldSuspend = true;
							((GameEntity)this).NotifyChanged();
							return true;
						}
					}
					ShouldSuspend = false;
					((GameEntity)this).NotifyChanged();
					return false;
				}
			}

			protected override void OnEnterBattle(BattleController battle)
			{
				((Card)this).OnEnterBattle(battle);
			}

			private UniTask<RandomGen> AsyncRng()
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				return UniTask.RunOnThreadPool<RandomGen>((Func<RandomGen>)(() => ((GameEntity)this).GameRun.BattleRng), true, default(CancellationToken));
			}

			protected override IEnumerable<BattleAction> Actions(UnitSelector selector, ManaGroup consumingMana, Interaction precondition)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				BepinexPlugin.log.LogDebug((object)$"suspend deez: {ShouldSuspend}");
				yield break;
			}

			public RngGetDebugCard()
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				ManaGroup val = default(ManaGroup);
				((ManaGroup)(ref val)).Any = 1;
				((ManaGroup)(ref val)).Black = 1;
				suspendCost = val;
				shouldSuspend = false;
				((Card)this)..ctor();
			}
		}

		public override IdContainer GetId()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IdContainer.op_Implicit("RngGetDebugCard");
		}

		public override CardImages LoadCardImages()
		{
			return null;
		}

		public override LocalizationOption LoadLocalization()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			return (LocalizationOption)new DirectLocalization(new Dictionary<string, object>
			{
				{ "Name", "deez" },
				{ "Description", "Sus:{ShouldSuspend} ({SuspendCost})\nNat:{NaturalCost}\nActual:{Cost}" }
			}, (Locale)0, (Locale)0, false);
		}

		public override CardConfig MakeConfig()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			string[][] array = new string[0][];
			TargetType? val = (TargetType)4;
			List<ManaColor> obj = new List<ManaColor> { (ManaColor)4 };
			ManaGroup val2 = default(ManaGroup);
			((ManaGroup)(ref val2)).Any = 2;
			((ManaGroup)(ref val2)).Black = 2;
			return new CardConfig(0, "", 10, true, array, "", "", 0, false, true, true, false, true, (Rarity)0, (CardType)3, val, (IReadOnlyList<ManaColor>)obj, false, val2, (ManaGroup?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (ManaGroup?)null, (ManaGroup?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (Keyword)0, (Keyword)0, false, (Keyword)0, (Keyword)0, (IReadOnlyList<string>)new List<string>(), (IReadOnlyList<string>)new List<string>(), (IReadOnlyList<string>)new List<string>(), (IReadOnlyList<string>)new List<string>(), (string)null, "", "", false, (string)null, (IReadOnlyList<string>)new List<string>());
		}

		public static RandomGen StaticRng()
		{
			GameRunController obj = GrRngs.Gr();
			return (obj != null) ? obj.BattleRng : null;
		}
	}
	public class StatsLogger
	{
		[HarmonyPatch]
		private class InitLog
		{
			[HarmonyPatch(typeof(GameRunController), "Create")]
			[HarmonyPostfix]
			private static void Postfix(GameRunController __result)
			{
				currentGrId = "";
				InitAndLogGrInfo(__result);
			}

			private static void EarlyInit(GameRunController gr)
			{
				InitLogs(gr);
			}

			[HarmonyPatch(/*Could not decode attribute arguments.*/)]
			[HarmonyPriority(300)]
			[HarmonyTranspiler]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Expected O, but got Unknown
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Expected O, but got Unknown
				return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Gr_InitRngs_Patch), "InitRngs", (Type[])null, (Type[])null))) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null)
				})
					.Insert((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(InitLog), "EarlyInit", (Type[])null, (Type[])null))
					})
					.LeaveJumpFix()
					.InstructionEnumeration();
			}
		}

		[HarmonyPatch(typeof(GameRunController), "Restore")]
		[HarmonyPriority(300)]
		private class RestoreLogs
		{
			private static void Postfix(GameRunController __result)
			{
				InitLogs(__result);
			}
		}

		public static string[] generalHead = new string[3] { "ManaBase", "Char", "Exhibits" };

		public static string[] cardsHeader = new string[7] { "Card", "Rarity", "Colors", "RareFactorAfter", "CardRng", "ShopRng", "UpgradeRng" };

		public static string[] addedCardHead = new string[4] { "AddedCard", "Amount", "Rarity", "Colors" };

		public static List<KeyValuePair<string, MethodInfo>> vanillaRngsHead = new List<KeyValuePair<string, MethodInfo>>();

		public static List<KeyValuePair<string, FieldInfo>> persistentRngsHead = new List<KeyValuePair<string, FieldInfo>>();

		public static string[] exHeader = new string[6] { "Exhibit", "Rarity", "Pool", "ExRng", "ShopRng", "AdvRng" };

		public static string[] eventHead = new string[2] { "Adventure", "AdvInitRng" };

		public static string[] grInfoHead = new string[5] { "GameVersion", "CardValidDebugLevel", "Jadeboxes", "rngFixOptions", "Mods" };

		public static string[] rollHead = new string[12]
		{
			"ItemW", "WThreshold", "itemProb", "passThreshold", "probabilityFraction", "probabiltyMul", "MaxW", "rawMaxW", "TotalW", "wRollAttempts",
			"Rolls", "fractionWarning"
		};

		public static string[] commonHead = new string[6] { "Station", "Event", "Stage", "Act", "X", "Y" };

		private static MethodInfo mi_rngState = AccessTools.PropertyGetter(typeof(RandomGen), "State");

		public static string currentGrId = "";

		public static void InitAndLogGrInfo(GameRunController gr)
		{
			if (BepinexPlugin.doLoggingConf.Value)
			{
				CsvLogger grInfoLog = GetGrInfoLog(gr);
				grInfoLog.SetHeader((IEnumerable<string>)grInfoHead);
				grInfoLog.LogHead();
				grInfoLog.SetValSafe(VersionInfo.Current.Version, "GameVersion");
				grInfoLog.SetValSafe(gr.CardValidDebugLevel, "CardValidDebugLevel");
				grInfoLog.SetValSafe(string.Join(";", gr.JadeBoxes.Select((JadeBox jb) => ((GameEntity)jb).Name)), "Jadeboxes");
				grInfoLog.SetValSafe(string.Join("|", BepinexPlugin.ignoreFactorsTableConf.Value, BepinexPlugin.doLoggingConf.Value), "rngFixOptions");
				grInfoLog.SetValSafe(string.Join(";", Chainloader.PluginInfos.Values.Select((PluginInfo pi) => $"{pi.Metadata.GUID}|{pi.Metadata.Version}")), "Mods");
				grInfoLog.FlushVals();
			}
		}

		public static void LogGeneral(GameRunController gr)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (BepinexPlugin.doLoggingConf.Value)
			{
				CsvLogger generalLog = GetGeneralLog(gr);
				generalLog.SetValSafe(gr.BaseMana, "ManaBase");
				generalLog.SetValSafe(((GameEntity)gr.Player).Name, "Char");
				generalLog.SetValSafe(string.Join("|", gr.Player.Exhibits), "Exhibits");
				LogCommonAndFlush(generalLog, gr);
			}
		}

		public static void LogEvent(Type adv, GameRunController gr, SamplerLogInfo li)
		{
			if (BepinexPlugin.doLoggingConf.Value)
			{
				CsvLogger eventLog = GetEventLog(gr);
				GrRngs orCreate = GrRngs.GetOrCreate(gr);
				eventLog.SetValSafe(adv.Name, "Adventure");
				eventLog.SetValSafe(orCreate.persRngs.adventureSelfRngs.GetRng(adv.Name).State, "AdvInitRng");
				LogRoll(eventLog, li);
				LogCommonAndFlush(eventLog, gr);
			}
		}

		public static void LogEx(Exhibit ex, GameRunController gr, SamplerLogInfo li)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (BepinexPlugin.doLoggingConf.Value)
			{
				CsvLogger exLog = GetExLog(gr);
				GrRngs orCreate = GrRngs.GetOrCreate(gr);
				exLog.SetValSafe((ex != null) ? ((GameEntity)ex).Name : null, "Exhibit");
				exLog.SetValSafe((ex != null) ? new Rarity?(ex.Config.Rarity) : null, "Rarity");
				exLog.SetValSafe((ex != null) ? new AppearanceType?(ex.Config.Appearance) : null, "Pool");
				exLog.SetValSafe(gr.ExhibitRng.State, "ExRng");
				exLog.SetValSafe(gr.ShopRng.State, "ShopRng");
				exLog.SetValSafe(gr.AdventureRng.State, "AdvRng");
				LogRoll(exLog, li);
				LogCommonAndFlush(exLog, gr);
			}
		}

		public static void LogVanillaRngs(GameRunController gr)
		{
			if (!BepinexPlugin.doLoggingConf.Value)
			{
				return;
			}
			CsvLogger vanillaRngsLog = GetVanillaRngsLog(gr);
			foreach (KeyValuePair<string, MethodInfo> item in vanillaRngsHead)
			{
				object obj = item.Value.Invoke(gr, Array.Empty<object>());
				ulong num = 0uL;
				if (obj != null)
				{
					num = (ulong)mi_rngState.Invoke(obj, Array.Empty<object>());
				}
				vanillaRngsLog.SetValSafe(num, item.Key);
			}
			LogCommonAndFlush(vanillaRngsLog, gr);
		}

		public static void LogPersistentRngs(GameRunController gr)
		{
			if (!BepinexPlugin.doLoggingConf.Value)
			{
				return;
			}
			CsvLogger per

Logging.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("Logging")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Logging")]
[assembly: AssemblyTitle("Logging")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Logging
{
	public sealed class CsvLogger : IDisposable
	{
		private static readonly Dictionary<string, CsvLogger> loggers = new Dictionary<string, CsvLogger>();

		private static readonly string SessionFolder = $"_{DateTime.Now:yyyy-MM-dd_HH.mm.ss}";

		private static ObjectIDGenerator objectAssociations = new ObjectIDGenerator();

		private static int assCount = 0;

		private readonly FileStream _fileStream;

		private readonly StreamWriter _streamWriter;

		private readonly object lockObj = new object();

		private bool isEnabled = true;

		public readonly string logFile;

		public readonly string subFolder;

		public readonly string fileDir;

		private List<string> header = new List<string>();

		private Dictionary<string, string> values = new Dictionary<string, string>();

		private Dictionary<string, bool> valsToSanitize = new Dictionary<string, bool>();

		private string emptyValue = "N/A";

		public static int AssCount => assCount;

		public IReadOnlyList<string> Header => header;

		public IReadOnlyDictionary<string, string> Values => values;

		public IReadOnlyDictionary<string, bool> ValsToSanitize => valsToSanitize;

		public string EmptyValue
		{
			get
			{
				return emptyValue;
			}
			set
			{
				CollectionExtensions.Do<string>(values.Keys.Where((string k) => values[k] == emptyValue), (Action<string>)delegate(string k)
				{
					values[k] = value;
				});
				emptyValue = value;
			}
		}

		public bool IsEnabled
		{
			get
			{
				return isEnabled;
			}
			set
			{
				isEnabled = value;
			}
		}

		public CsvLogger(string logFile, string ext = ".csv", string subFolder = "", bool isEnabled = true)
		{
			this.logFile = logFile + ext;
			this.subFolder = subFolder;
			fileDir = Path.Join((ReadOnlySpan<char>)Application.dataPath, (ReadOnlySpan<char>)"..");
			fileDir = Path.Join((ReadOnlySpan<char>)fileDir, (ReadOnlySpan<char>)subFolder, (ReadOnlySpan<char>)SessionFolder);
			Directory.CreateDirectory(fileDir);
			string path = Path.Join((ReadOnlySpan<char>)fileDir, (ReadOnlySpan<char>)this.logFile);
			_fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
			_streamWriter = new StreamWriter(_fileStream);
			this.subFolder = subFolder;
			this.isEnabled = isEnabled;
		}

		public static CsvLogger GetOrCreateLog(string logFile, string id, string ext = ".csv", string subFolder = "", bool isEnabled = true)
		{
			string key = logFile + id;
			if (!loggers.TryGetValue(key, out var value))
			{
				value = new CsvLogger(logFile + "_" + assCount, ext, subFolder, isEnabled);
				loggers[key] = value;
			}
			return value;
		}

		public static (CsvLogger, long) GetOrCreateLog(string logFile, object ass, string ext = ".csv", string subFolder = "", bool isEnabled = true)
		{
			bool firstTime;
			long id = objectAssociations.GetId(ass, out firstTime);
			if (firstTime)
			{
				assCount++;
			}
			CsvLogger orCreateLog = GetOrCreateLog(logFile, id.ToString(), ext, subFolder, isEnabled);
			return (orCreateLog, id);
		}

		public void AddHeaderVal(string valKey)
		{
			if (valKey != null && !values.ContainsKey(valKey))
			{
				header.Add(valKey);
				values.Add(valKey, emptyValue);
			}
		}

		public void SetHeader(IEnumerable<string> collumns)
		{
			header.Clear();
			values.Clear();
			CollectionExtensions.Do<string>(collumns, (Action<string>)delegate(string c)
			{
				AddHeaderVal(c);
			});
		}

		public void LogHead()
		{
			Log(header);
		}

		public bool SetVal(object val, string valKey, bool doThrow = true)
		{
			if (!isEnabled)
			{
				return false;
			}
			if (values.ContainsKey(valKey))
			{
				values[valKey] = val?.ToString() ?? "null";
				return true;
			}
			if (doThrow)
			{
				throw new ArgumentException("CsvLogger " + logFile + " doesn't have column " + valKey);
			}
			return false;
		}

		public bool SetVals(IEnumerable<KeyValuePair<string, string>> valsNKeys)
		{
			return valsNKeys.Select((KeyValuePair<string, string> kv) => SetVal(kv.Value, kv.Key)).Any();
		}

		public bool HasVals()
		{
			return values.Values.Any((string v) => v != emptyValue);
		}

		public void FlushVals()
		{
			string[] array = new string[header.Count];
			int num = 0;
			foreach (string item in header)
			{
				string text = values[item];
				if (valsToSanitize.TryGetValue(item, out var value))
				{
					text = SanitizeVal(text, value);
				}
				array[num] = text;
				values[item] = emptyValue;
				num++;
			}
			Log(array);
		}

		public bool SetCollumnToSanitize(string key, bool conditional = true)
		{
			if (!values.ContainsKey(key))
			{
				return false;
			}
			if (!valsToSanitize.TryAdd(key, conditional))
			{
				valsToSanitize[key] = conditional;
			}
			return true;
		}

		public static string SanitizeVal(string val, bool conditional)
		{
			bool flag = true;
			if (conditional)
			{
				flag = val.Contains(",");
			}
			return flag ? ("\"" + val + "\"") : val;
		}

		public void Log(IEnumerable<object> values)
		{
			Log(string.Join(", ", values));
		}

		public void Log(string message)
		{
			if (!IsEnabled)
			{
				return;
			}
			lock (lockObj)
			{
				_streamWriter.WriteLine(message);
				_streamWriter.Flush();
			}
		}

		public void Dispose()
		{
			lock (lockObj)
			{
				_streamWriter?.Dispose();
				_fileStream?.Dispose();
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}