Decompiled source of RngFix v1.1.0

RngFix.dll

Decompiled 15 hours 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 AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
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.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.Neutral.Black;
using LBoL.EntityLib.Exhibits.Adventure;
using LBoL.EntityLib.Exhibits.Common;
using LBoL.EntityLib.Exhibits.Shining;
using LBoL.EntityLib.Stages.NormalStages;
using LBoL.Presentation;
using LBoL.Presentation.UI;
using LBoL.Presentation.UI.Panels;
using LBoLEntitySideloader;
using LBoLEntitySideloader.CustomHandlers;
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.UniformPools;
using RngFix.Patches;
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", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		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;

		public static ConfigEntry<bool> disableManaBaseAffectedCardWeights;

		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;
			EntityManager.RegisterSelf();
			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", true, "Log various run stats (card, exhibits etc.) to <gameSaveDir>/RngFix");
			disableManaBaseAffectedCardWeights = ((BaseUnityPlugin)this).Config.Bind<bool>("Rng", "disableManaBaseAffectedCardWeights", false, "In vanilla, card weights are influenced by current mana. Roughly the more of a certain colour there is in the mana base the more likely cards of that colour are to appear. This disrupts seed consistency somewhat. But disabling this mechanic by default is potentially a big enough deviation from vanilla experience that an optional toggle is justified.");
			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 = "1.1.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))
				})
				.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)))
				.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.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))
				})
				.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))
				})
				.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))
				})
				.InstructionEnumeration();
		}
	}
	public static class Helpers
	{
		public static CodeMatcher ReplaceRngGetter(this CodeMatcher matcher, string targetName, MethodInfo newCall)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			MethodInfo targetGetter = AccessTools.PropertyGetter(typeof(GameRunController), targetName);
			if (targetGetter == null)
			{
				throw new ArgumentException(string.Format("Could not find {0}.{1}", "GameRunController", targetGetter));
			}
			CodeMatch val = new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.operand as MethodInfo == targetGetter), (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);
		}

		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;
		}
	}
	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))
				})
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class Gr_cctor_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return AccessTools.Constructor(typeof(GameRunController), new Type[1] { typeof(GameRunStartupParameters) }, false);
		}

		private static void InitRngs(GameRunController gr)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Expected O, but got Unknown
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Expected O, but got Unknown
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			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(from ec in ExhibitConfig.AllConfig()
				orderby ec.Order
				select ec.Id);
			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 AdventureConfig.AllConfig()
				orderby ac.No
				select ac.Id);
			orCreate.persRngs.shopRngs = ShopRngs.Init(gr.RootRng.NextULong());
			orCreate.persRngs.extraCardRewardRng = new RandomGen(gr.RootRng.NextULong());
			orCreate.unusedRoot0 = new RandomGen(gr.RootRng.NextULong());
		}

		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_cctor_Patch), "InitRngs", (Type[])null, (Type[])null))
				})
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(GameMaster), "BattleStationFlowFromEndSave")]
	internal class ReEnterAfterBattle_Patch
	{
		private static void Prefix(GameMaster __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			GameRunController currentGameRun = __instance.CurrentGameRun;
			GrRngs orCreate = GrRngs.GetOrCreate(currentGameRun);
			CardsEventArgs args = new CardsEventArgs();
			IEnumerable<Card> enumerable = from c in currentGameRun.Battle.EnumerateAllCards()
				where args.Cards.Any((Card ac) => ((GameEntity)ac).Id == ((GameEntity)c).Id)
				select c;
			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(Stage), "GetAdventure")]
	internal class InitAdventureNode_Patch
	{
		private static void Postfix(Stage __instance, Type __result)
		{
			GameRunController gameRun = ((GameEntity)__instance).GameRun;
			GrRngs orCreate = GrRngs.GetOrCreate(gameRun);
			ulong seed = orCreate.persRngs.adventureSelfRngs.GetRng(__result.Name).NextULong();
			orCreate.NodeMaster = new NodeMasterRng(seed);
			orCreate.NodeMaster.Advance(gameRun);
		}
	}
	[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);
			__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);
			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 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.CardSampler.requirements.Find((ISlotRequirement 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>(from e in __instance.Player.Exhibits
				where e.OwnerId != null
				select e.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;
			};
			for (int i = 0; i < count; i++)
			{
				ulong state = rng.State;
				SamplerLogInfo logInfo;
				Card val = orCreate.CardSampler.Roll(rng, getW, out logInfo, (Type t) => rolledCards.All((Card c) => ((object)c).GetType() != t));
				if (val == null)
				{
					if (!ensureCount)
					{
						StatsLogger.LogCard(val, __instance, logInfo);
						break;
					}
					BepinexPlugin.log.LogWarning((object)"ENSURING COUNT ENSURING COUNT ENSURING COUNT");
					rng.State = state;
					val = orCreate.CardSampler.Roll(rng, getW, out logInfo);
				}
				rolledCards.Add(val);
				StatsLogger.LogCard(val, __instance, logInfo);
			}
			__result = rolledCards.ToArray();
			return false;
		}
	}
}
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 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);
			for (int i = 0; i < 3; i++)
			{
				matcher = matcher.ReplaceRngGetter("CardRng", AccessTools.Method(typeof(CardReward_Patch), "SwitchCardRng", (Type[])null, (Type[])null));
			}
			matcher = matcher.ReplaceRngGetter("CardRng", AccessTools.Method(typeof(CardReward_Patch), "ExtraCardRewardRng", (Type[])null, (Type[])null));
			matcher = matcher.ReplaceRngGetter("CardRng", AccessTools.Method(typeof(GrRngs), "GetCardUpgradeQueueRng", (Type[])null, (Type[])null));
			return matcher.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)).InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(BattleController), "GenerateEnemyPoints")]
	internal class GenerateEnemyPoints_Patch
	{
		private static RandomGen GetLootGen(GameRunController gr)
		{
			return GrRngs.GetOrCreate(gr).battleLootRng;
		}

		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
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(GameRunController), "GameRunEventRng"))) }).Set(OpCodes.Call, (object)AccessTools.Method(typeof(GenerateEnemyPoints_Patch), "GetLootGen", (Type[])null, (Type[])null)).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 val = new CodeMatcher(instructions, (ILGenerator)null);
			while (true)
			{
				try
				{
					val = val.ReplaceRngGetter("GameRunEventRng", AccessTools.Method(typeof(GrRngs), "GetMoneyRewardRng", (Type[])null, (Type[])null));
				}
				catch (InvalidOperationException)
				{
					break;
				}
			}
			return val.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_0028: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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)
			}).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_0028: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ShopRng", AccessTools.Method(typeof(GrRngs), "GetShopExRng", (Type[])null, (Type[])null)).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_002a: 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)
				.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_0028: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", AccessTools.Method(typeof(GrRngs), "GetEliteQueueRng", (Type[])null, (Type[])null)).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_0028: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", AccessTools.Method(typeof(GrRngs), "GetAdventureQueueRng", (Type[])null, (Type[])null)).InstructionEnumeration();
		}
	}
}
namespace RngFix.Patches.Exhibits
{
	[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_0047: 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 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))
			}).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_0047: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			}).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_0047: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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)
				})
				.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)
			})
				.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_0026: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", AccessTools.PropertyGetter(typeof(GameRunController), "AdventureRng")).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_0026: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "RootRng", AccessTools.PropertyGetter(typeof(GameRunController), "AdventureRng")).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_0047: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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)
				})
				.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_0028: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ExhibitRng", AccessTools.Method(typeof(GetSpecialAdventureExhibit_Patch), "GetRng", (Type[])null, (Type[])null)).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_0026: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "StationRng", AccessTools.PropertyGetter(typeof(GameRunController), "AdventureRng")).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_0028: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ShopRng", AccessTools.Method(typeof(GrRngs), "GetTransitionRng", (Type[])null, (Type[])null)).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_0028: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "AdventureRng", AccessTools.Method(typeof(GrRngs), "GetTransitionRng", (Type[])null, (Type[])null)).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_0028: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "ExhibitRng", AccessTools.Method(typeof(GrRngs), "GetTransitionRng", (Type[])null, (Type[])null)).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)
			{
				StatsLogger.LogPickedCard(args.Cards.First(), args.Cards.Length, 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)
			return 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))
				})
				.InstructionEnumeration();
		}
	}
	public class StatsLogger
	{
		[HarmonyPatch(typeof(GameRunController), "Create")]
		[HarmonyPriority(300)]
		private class InitLog
		{
			private static void Postfix(GameRunController __result)
			{
				currentGrId = "";
				InitAndLogGrInfo(__result);
				InitLogs(__result);
			}
		}

		[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[11]
		{
			"ItemW", "WThreshold", "itemProb", "passThreshold", "probabilityFraction", "probabiltyMul", "MaxW", "rawMaxW", "TotalW", "wRollAttempts",
			"Rolls"
		};

		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, BepinexPlugin.disableManaBaseAffectedCardWeights.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 persistentRngsLog = GetPersistentRngsLog(gr);
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			foreach (KeyValuePair<string, FieldInfo> item in persistentRngsHead)
			{
				object value = item.Value.GetValue(orCreate.persRngs);
				ulong num = 0uL;
				if (value != null)
				{
					num = (ulong)mi_rngState.Invoke(value, Array.Empty<object>());
				}
				persistentRngsLog.SetValSafe(num, item.Key);
			}
			LogCommonAndFlush(persistentRngsLog, gr);
		}

		public static void LogCard(Card card, GameRunController gr, SamplerLogInfo li)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (BepinexPlugin.doLoggingConf.Value)
			{
				CsvLogger cardLog = GetCardLog(gr);
				GrRngs orCreate = GrRngs.GetOrCreate(gr);
				cardLog.SetValSafe((card != null) ? ((GameEntity)card).Name : null, "Card");
				cardLog.SetValSafe((card != null) ? new Rarity?(card.Config.Rarity) : null, "Rarity");
				if (card != null)
				{
					cardLog.SetValSafe(string.Join("", (card != null) ? card.Config.Colors : null), "Colors");
				}
				cardLog.SetValSafe(gr._cardRareWeightFactor, "RareFactorAfter");
				cardLog.SetValSafe(gr.CardRng.State, "CardRng");
				cardLog.SetValSafe(gr.ShopRng.State, "ShopRng");
				RandomGen cardUpgradeQueueRng = orCreate.persRngs.cardUpgradeQueueRng;
				cardLog.SetValSafe((cardUpgradeQueueRng != null) ? new ulong?(cardUpgradeQueueRng.State) : null, "UpgradeRng");
				LogRoll(cardLog, li);
				LogCommonAndFlush(cardLog, gr);
			}
		}

		public static void LogPickedCard(Card card, int amount, GameRunController gr)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (BepinexPlugin.doLoggingConf.Value)
			{
				CsvLogger pickedCardLog = GetPickedCardLog(gr);
				pickedCardLog.SetValSafe((card != null) ? ((GameEntity)card).Name : null, "AddedCard");
				pickedCardLog.SetValSafe(amount, "Amount");
				pickedCardLog.SetValSafe((card != null) ? new Rarity?(card.Config.Rarity) : null, "Rarity");
				if (card != null)
				{
					pickedCardLog.SetValSafe(string.Join("", (card != null) ? card.Config.Colors : null), "Colors");
				}
				LogCommonAndFlush(pickedCardLog, gr);
			}
		}

		public static void LogRoll(CsvLogger logger, SamplerLogInfo li)
		{
			if (BepinexPlugin.doLoggingConf.Value)
			{
				logger.SetValSafe(li.itemW, "ItemW");
				logger.SetValSafe(li.wThreshold, "WThreshold");
				logger.SetValSafe(li.itemProb, "itemProb");
				logger.SetValSafe(li.passThreshold, "passThreshold");
				logger.SetValSafe(li.probabilityFraction, "probabilityFraction");
				logger.SetValSafe(li.probabiltyMul, "probabiltyMul");
				logger.SetValSafe(li.totalW, "TotalW");
				logger.SetValSafe(li.maxW, "MaxW");
				logger.SetValSafe(li.rawMaxW, "rawMaxW");
				logger.SetValSafe(li.wRollAttempts, "wRollAttempts");
				logger.SetValSafe(li.rolls, "Rolls");
			}
		}

		public static void LogCommonAndFlush(CsvLogger logger, GameRunController gr, bool flush = true)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (!BepinexPlugin.doLoggingConf.Value)
			{
				return;
			}
			logger.SetValSafe(gr.CurrentMap.VisitingNode.StationType, "Station");
			logger.SetValSafe(gr.CurrentMap.VisitingNode.Act, "Act");
			logger.SetValSafe(((GameEntity)gr.CurrentStage).Id, "Stage");
			logger.SetValSafe(gr.CurrentMap.VisitingNode.X, "X");
			logger.SetValSafe(gr.CurrentMap.VisitingNode.Y, "Y");
			logger.SetCollumnToSanitize("Event", false);
			Station currentStation = gr.CurrentStation;
			AdventureStation val = (AdventureStation)(object)((currentStation is AdventureStation) ? currentStation : null);
			if (val != null)
			{
				Adventure adventure = val.Adventure;
				logger.SetValSafe("adventure:" + ((adventure != null) ? adventure.Title : null), "Event");
			}
			else
			{
				Station currentStation2 = gr.CurrentStation;
				BattleStation val2 = (BattleStation)(object)((currentStation2 is BattleStation) ? currentStation2 : null);
				if (val2 != null)
				{
					EnemyGroup enemyGroup = val2.EnemyGroup;
					logger.SetValSafe("battle:" + ((enemyGroup != null) ? enemyGroup.Id : null), "Event");
				}
				else
				{
					Station currentStation3 = gr.CurrentStation;
					EliteEnemyStation val3 = (EliteEnemyStation)(object)((currentStation3 is EliteEnemyStation) ? currentStation3 : null);
					if (val3 != null)
					{
						EnemyGroup enemyGroup2 = ((BattleStation)val3).EnemyGroup;
						logger.SetValSafe("elite:" + ((enemyGroup2 != null) ? enemyGroup2.Id : null), "Event");
					}
					else
					{
						Station currentStation4 = gr.CurrentStation;
						BossStation val4 = (BossStation)(object)((currentStation4 is BossStation) ? currentStation4 : null);
						if (val4 != null)
						{
							EnemyGroup enemyGroup3 = ((BattleStation)val4).EnemyGroup;
							logger.SetValSafe("boss:" + ((enemyGroup3 != null) ? enemyGroup3.Id : null), "Event");
						}
					}
				}
			}
			if (flush)
			{
				logger.FlushVals();
			}
		}

		private static CsvLogger GetLog(GameRunController gr, string prefix = "", string ext = ".csv", bool isEnabled = true)
		{
			string text = RandomGen.SeedToString(gr.RootSeed);
			string text2 = prefix + "_" + text;
			if (string.IsNullOrEmpty(currentGrId))
			{
				(CsvLogger, long) orCreateLog = CsvLogger.GetOrCreateLog(text2, (object)gr, ext, "RngFix", isEnabled);
				currentGrId = orCreateLog.Item2.ToString();
				return orCreateLog.Item1;
			}
			return CsvLogger.GetOrCreateLog(text2, currentGrId, ext, "RngFix", isEnabled);
		}

		public static CsvLogger GetCardLog(GameRunController gr, bool isEnabled = true)
		{
			return GetLog(gr, "cards", ".csv", isEnabled);
		}

		public static CsvLogger GetGeneralLog(GameRunController gr, bool isEnabled = true)
		{
			return GetLog(gr, "general", ".csv", isEnabled);
		}

		public static CsvLogger GetPickedCardLog(GameRunController gr, bool isEnabled = true)
		{
			return GetLog(gr, "pickedCards", ".csv", isEnabled);
		}

		public static CsvLogger GetExLog(GameRunController gr, bool isEnabled = true)
		{
			return GetLog(gr, "ex", ".csv", isEnabled);
		}

		public static CsvLogger GetEventLog(GameRunController gr, bool isEnabled = true)
		{
			return GetLog(gr, "event", ".csv", isEnabled);
		}

		public static CsvLogger GetVanillaRngsLog(GameRunController gr, bool isEnabled = true)
		{
			return GetLog(gr, "vanillaRngs", ".csv", isEnabled);
		}

		public static CsvLogger GetPersistentRngsLog(GameRunController gr, bool isEnabled = true)
		{
			return GetLog(gr, "persistentRngs", ".csv", isEnabled);
		}

		public static CsvLogger GetGrInfoLog(GameRunController gr, bool isEnabled = true)
		{
			return GetLog(gr, "grInfo", ".csv", isEnabled);
		}

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

		private static void InitLogs(GameRunController gr)
		{
			bool value = BepinexPlugin.doLoggingConf.Value;
			if (value)
			{
				GetCardLog(gr, value).SetHeader(cardsHeader.Concat(rollHead).Concat(commonHead));
				GetCardLog(gr).SetCollumnToSanitize("Card", true);
				GetCardLog(gr).LogHead();
				GetGeneralLog(gr, value).SetHeader(generalHead.Concat(commonHead));
				GetGeneralLog(gr).SetCollumnToSanitize("Exhibits", false);
				GetGeneralLog(gr).LogHead();
				GetPickedCardLog(gr, value).SetHeader(addedCardHead.Concat(commonHead));
				GetPickedCardLog(gr).SetCollumnToSanitize("AddedCard", true);
				GetPickedCardLog(gr).LogHead();
				GetExLog(gr, value).SetHeader(exHeader.Concat(rollHead).Concat(commonHead));
				GetExLog(gr).SetCollumnToSanitize("Exhibit", true);
				GetExLog(gr).LogHead();
				GetEventLog(gr, value).SetHeader(eventHead.Concat(rollHead).Concat(commonHead));
				GetEventLog(gr).LogHead();
				vanillaRngsHead.Clear();
				GetVanillaRngsLog(gr, value).SetHeader((from p in AccessTools.GetDeclaredProperties(typeof(GameRunController))
					where p.GetMethod?.Name.EndsWith("Rng") ?? false
					select p).Select(delegate(PropertyInfo p)
				{
					vanillaRngsHead.Add(new KeyValuePair<string, MethodInfo>(p.Name, p.GetMethod));
					return p.Name;
				}).Concat(commonHead));
				GetVanillaRngsLog(gr).LogHead();
				persistentRngsHead.Clear();
				GetPersistentRngsLog(gr, value).SetHeader((from f in AccessTools.GetDeclaredFields(typeof(GrRngs.PersRngs))
					where f.FieldType == typeof(RandomGen)
					select f).Select(delegate(FieldInfo f)
				{
					persistentRngsHead.Add(new KeyValuePair<string, FieldInfo>(f.Name, f));
					return f.Name;
				}).Concat(commonHead));
				GetPersistentRngsLog(gr).LogHead();
			}
		}
	}
	public static class CsvLoggerExt
	{
		public static void SetValSafe(this CsvLogger logger, object val, string valKey)
		{
			try
			{
				logger.SetVal(val, valKey, true);
			}
			catch (Exception ex)
			{
				BepinexPlugin.log.LogWarning((object)(logger.logFile + ":" + ex));
			}
		}
	}
}
namespace RngFix.Patches.Cards
{
	[HarmonyPatch(typeof(GameRunController), "BaseCardWeight")]
	internal class DisableManaBaseAffectedCardWeights_Patch
	{
		public static bool tempDebugDisable = true;

		private static int CheckOption(int colourCount)
		{
			if (BepinexPlugin.disableManaBaseAffectedCardWeights.Value || tempDebugDisable)
			{
				return 0;
			}
			return colourCount;
		}

		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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).End().MatchEndBackwards((CodeMatch[])(object)new CodeMatch[4]
			{
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(CardConfig), "Colors"))),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(IReadOnlyCollection<ManaColor>), "Count"))),
				CodeMatch.op_Implicit(OpCodes.Stloc_S),
				CodeMatch.op_Implicit(OpCodes.Ldloc_S)
			}).Advance(-1)
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(DisableManaBaseAffectedCardWeights_Patch), "CheckOption", (Type[])null, (Type[])null))
				})
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class QingeUpgrade_Patch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return ExtraAccess.InnerMoveNext(typeof(QingeUpgrade), "OnEnemyDied");
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			return Helpers.ReplaceRngGetter(new CodeMatcher(instructions, (ILGenerator)null), "GameRunEventRng", AccessTools.Method(typeof(GrRngs), "GetQingeUpgradeQueueRng", (Type[])null, (Type[])null)).InstructionEnumeration();
		}
	}
}
namespace RngFix.CustomRngs
{
	public class EntitySelfRngs<T>
	{
		public RandomGen rootRng;

		[YamlIgnore]
		public Func<T, string> GetId;

		public Dictionary<string, RandomGen> rngs = new Dictionary<string, RandomGen>();

		public EntitySelfRngs()
		{
		}

		public EntitySelfRngs(Func<T, string> GetId)
			: this()
		{
			this.GetId = GetId;
		}

		public EntitySelfRngs(Func<T, string> GetId, ulong rootSeed)
			: this(GetId)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			rootRng = new RandomGen(rootSeed);
		}

		public void InitialiseRngs(IEnumerable<string> initOrder)
		{
			CollectionExtensions.Do<string>(initOrder, (Action<string>)delegate(string id)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				rngs.TryAdd(id, new RandomGen(rootRng.NextULong()));
			});
		}

		public RandomGen GetRng(T entity)
		{
			return GetRng(GetId(entity));
		}

		public RandomGen GetRng(string id)
		{
			if (!rngs.TryGetValue(id, out var value))
			{
				throw new ArgumentException("Rng with id " + id + " not found.");
			}
			return value;
		}
	}
	internal static class ExhibitsSelfRngs
	{
		internal static string GetId(Exhibit ex)
		{
			return ((GameEntity)ex).Id;
		}

		internal static RandomGen GetSelfRng(GameRunController gr, Exhibit entity)
		{
			return GrRngs.GetOrCreate(gr).ExhibitSelfRngs.GetRng(entity);
		}

		internal static RandomGen GetSelfRng(GameRunController gr, string id)
		{
			return GrRngs.GetOrCreate(gr).ExhibitSelfRngs.GetRng(id);
		}
	}
	internal static class AdventureSelfRngs
	{
		internal static string GetId(Adventure adv)
		{
			return adv.Id;
		}
	}
	public class GrRngs
	{
		public class PersRngs
		{
			public StageMasterRng stageMasterRng;

			public ActMasterRng actMasterRng;

			public ulong prevNodeMasterState;

			public RandomGen enemyActQueueRng;

			public RandomGen battleInitRng;

			public RandomGen eliteQueueRng;

			public ulong adventureQueueSeed;

			public RandomGen bossInitRng;

			public RandomGen eliteInitRng;

			public RandomGen transitionInitRng;

			public RandomGen gapInitRng;

			public RandomGen shopInitRng;

			public RandomGen rareExhibitQueueRng;

			public RandomGen qingeUpgradeQueueRng;

			public RandomGen cardUpgradeQueueRng;

			public RandomGen extraCardRewardRng;

			public RandomGen eliteCardRng;

			public RandomGen bossCardRng;

			public RandomGen fallbackInitRng;

			public EntitySelfRngs<Exhibit> exhibitSelfRngs;

			public EntitySelfRngs<Adventure> adventureSelfRngs;

			public ShopRngs shopRngs;
		}

		private static ConditionalWeakTable<GameRunController, GrRngs> table = new ConditionalWeakTable<GameRunController, GrRngs>();

		public PersRngs persRngs = new PersRngs();

		private NodeMasterRng nodeMaster;

		public RandomGen transitionRng;

		public RandomGen battleLootRng;

		public RandomGen bossCardRewardRng;

		public RandomGen moneyRewardRng;

		public RandomGen unusedNode0;

		public RandomGen unusedNode1;

		public RandomGen unusedNode2;

		public RandomGen unusedNode3;

		public RandomGen unusedNode4;

		public RandomGen unusedRoot0;

		private Lazy<AbstractSlotSampler<Exhibit>> normalExSampler = new Lazy<AbstractSlotSampler<Exhibit>>(() => new EqualWSlotSampler<Exhibit>(new List<ISlotRequirement>
		{
			new ExInPool(),
			new ExHasManaColour()
		}, delegate(Type t)
		{
			Exhibit val2 = Library.CreateExhibit(t);
			Gr().ExhibitPool.Remove(((object)val2).GetType());
			return val2;
		}, null, null, Padding.ExPadding()));

		private Lazy<AbstractSlotSampler<Card>> cardSampler = new Lazy<AbstractSlotSampler<Card>>(() => new EqualWSlotSampler<Card>(new List<ISlotRequirement>
		{
			new CardInPool()
		}, delegate(Type t)
		{
			Card val = Library.CreateCard(t);
			((GameEntity)val).GameRun = Gr();
			return val;
		}, null, delegate
		{
			BepinexPlugin.log.LogDebug((object)"deeznuts");
		}, Padding.CardPadding()));

		private Lazy<AbstractSlotSampler<Type>> adventureSampler = new Lazy<AbstractSlotSampler<Type>>(() => new EqualWSlotSampler<Type>(new List<ISlotRequirement>
		{
			new AdventureInPool(),
			new AdventureNOTinHistory()
		}, (Type t) => t, null, null, Padding.AdventurePadding()));

		public AbstractSlotSampler<Exhibit> NormalExSampler => normalExSampler.Value;

		public AbstractSlotSampler<Card> CardSampler => cardSampler.Value;

		public AbstractSlotSampler<Type> AdventureSampler => adventureSampler.Value;

		public NodeMasterRng NodeMaster
		{
			get
			{
				return nodeMaster;
			}
			set
			{
				nodeMaster = value;
			}
		}

		public EntitySelfRngs<Exhibit> ExhibitSelfRngs
		{
			get
			{
				return persRngs.exhibitSelfRngs;
			}
			set
			{
				persRngs.exhibitSelfRngs = value;
			}
		}

		public static RandomGen GetEnemyActQueueRng(GameRunController gr)
		{
			return GetOrCreate(gr).persRngs.enemyActQueueRng;
		}

		public static RandomGen GetEliteQueueRng(GameRunController gr)
		{
			return GetOrCreate(gr).persRngs.eliteQueueRng;
		}

		public static RandomGen GetAdventureQueueRng(GameRunController gr)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			return new RandomGen(GetOrCreate(gr).persRngs.adventureQueueSeed);
		}

		public static RandomGen GetQingeUpgradeQueueRng(GameRunController gr)
		{
			return GetOrCreate(gr).persRngs.qingeUpgradeQueueRng;
		}

		public static RandomGen GetCardUpgradeQueueRng(GameRunController gr)
		{
			return GetOrCreate(gr).persRngs.cardUpgradeQueueRng;
		}

		public static RandomGen GetEliteCardRng(GameRunController gr)
		{
			return GetOrCreate(gr).persRngs.eliteCardRng;
		}

		public static RandomGen GetTransitionRng(GameRunController gr)
		{
			return GetOrCreate(gr).transitionRng;
		}

		public static RandomGen GetMoneyRewardRng(GameRunController gr)
		{
			return GetOrCreate(gr).moneyRewardRng;
		}

		public static RandomGen GetShopExRng(GameRunController gr)
		{
			return GetOrCreate(gr).persRngs.shopRngs.exRng;
		}

		public static RandomGen GetBossCardRng(GameRunController gr)
		{
			return GetOrCreate(gr).persRngs.bossCardRng;
		}

		public void AdvaceNodeMaster(GameRunController gr)
		{
			NodeMaster.Advance(gr);
		}

		public static void AdvanceRngsOnJump(GameRunController gr, MapNode jumpToNode, bool suppressWarning = false)
		{
			MapNode visitingNode = gr.CurrentMap.VisitingNode;
			if (jumpToNode.X < visitingNode.X)
			{
				if (!suppressWarning)
				{
					BepinexPlugin.log.LogWarning((object)"Jumping to a previous level or act. Rngs cannot be reversed, seed consistency will be lost.");
				}
				return;
			}
			GrRngs orCreate = GetOrCreate(gr);
			int num = jumpToNode.Act - visitingNode.Act - (Helpers.IsActTransition(jumpToNode) ? 1 : 0);
			orCreate.persRngs.actMasterRng.AdvanceSteps(gr, num);
			for (int i = 0; i < num; i++)
			{
				orCreate.persRngs.transitionInitRng.NextULong();
			}
		}

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

		public static GrRngs GetOrCreate(GameRunController gr)
		{
			return table.GetOrCreateValue(gr);
		}
	}
	public abstract class MasterRng
	{
		public RandomGen rng;

		public MasterRng()
		{
		}

		public MasterRng(ulong seed)
			: this()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			rng = new RandomGen(seed);
		}

		public abstract void Advance(GameRunController gr);

		public void AdvanceSteps(GameRunController gr, int steps)
		{
			for (int i = 0; i < steps; i++)
			{
				Advance(gr);
			}
		}
	}
	public class StageMasterRng : MasterRng
	{
		public StageMasterRng()
		{
		}

		public StageMasterRng(ulong seed)
			: base(seed)
		{
		}

		public override void Advance(GameRunController gr)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			orCreate.persRngs.eliteQueueRng = new RandomGen(rng.NextULong());
			orCreate.persRngs.adventureQueueSeed = rng.NextULong();
			orCreate.persRngs.eliteInitRng = new RandomGen(rng.NextULong());
			orCreate.persRngs.bossInitRng = new RandomGen(rng.NextULong());
			rng.NextULong();
			orCreate.persRngs.transitionInitRng = new RandomGen(rng.NextULong());
		}
	}
	public class ActMasterRng : MasterRng
	{
		public ActMasterRng()
		{
		}

		public ActMasterRng(ulong seed)
			: base(seed)
		{
		}

		public override void Advance(GameRunController gr)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			orCreate.persRngs.enemyActQueueRng = new RandomGen(rng.NextULong());
			orCreate.persRngs.battleInitRng = new RandomGen(rng.NextULong());
		}
	}
	public class NodeMasterRng : MasterRng
	{
		public NodeMasterRng()
		{
		}

		public NodeMasterRng(ulong seed)
			: base(seed)
		{
		}

		public override void Advance(GameRunController gr)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			GrRngs orCreate = GrRngs.GetOrCreate(gr);
			orCreate.persRngs.prevNodeMasterState = rng.State;
			gr.GameRunEventRng = new RandomGen(rng.NextULong());
			gr.BattleRng = new RandomGen(rng.NextULong());
			gr.BattleCardRng = new RandomGen(rng.NextULong());
			gr.ShuffleRng = new RandomGen(rng.NextULong());
			gr.EnemyMoveRng = new RandomGen(rng.NextULong());
			gr.EnemyBattleRng = new RandomGen(rng.NextULong());
			orCreate.battleLootRng = new RandomGen(rng.NextULong());
			gr.AdventureRng = new RandomGen(rng.NextULong());
			orCreate.transitionRng = new RandomGen(rng.NextULong());
			orCreate.bossCardRewardRng = new RandomGen(rng.NextULong());
			orCreate.moneyRewardRng = new RandomGen(rng.NextULong());
			orCreate.unusedNode0 = new RandomGen(rng.NextULong());
			orCreate.unusedNode1 = new RandomGen(rng.NextULong());
			orCreate.unusedNode2 = new RandomGen(rng.NextULong());
			orCreate.unusedNode3 = new RandomGen(rng.NextULong());
			orCreate.unusedNode4 = new RandomGen(rng.NextULong());
		}
	}
	public class RngSaveContainer : CustomGameRunSaveData
	{
		public GrRngs.PersRngs persRngs;

		public string currentGrId;

		public override void Restore(GameRunController gameRun)
		{
			GrRngs orCreate = GrRngs.GetOrCreate(gameRun);
			orCreate.persRngs = persRngs;
			orCreate.persRngs.exhibitSelfRngs.GetId = (Exhibit ex) => ((GameEntity)ex).Id;
			orCreate.persRngs.adventureSelfRngs.GetId = (Adventure adv) => adv.Id;
			StatsLogger.currentGrId = currentGrId;
		}

		public override void Save(GameRunController gameRun)
		{
			GrRngs orCreate = GrRngs.GetOrCreate(gameRun);
			persRngs = orCreate.persRngs;
			currentGrId = StatsLogger.currentGrId;
		}

		public override IEnumerable<IYamlTypeConverter> TypeConverters()
		{
			yield return (IYamlTypeConverter)new RandomGenTypeConverter();
		}
	}
	public class ShopRngs
	{
		public Dictionary<string, RandomGen> rngs = new Dictionary<string, RandomGen>();

		public RandomGen exRng;

		public RandomGen fallbackRng;

		public static ShopRngs Init(ulong seed)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			ShopRngs shopRngs = new ShopRngs();
			RandomGen initRng = new RandomGen(seed);
			shopRngs.exRng = new RandomGen((ulong)initRng.Next());
			shopRngs.fallbackRng = new RandomGen((ulong)initRng.Next());
			CollectionExtensions.Do<string>((IEnumerable<string>)(from pi in AccessTools.GetDeclaredProperties(typeof(Stage))
				where pi.GetMethod != null && pi.GetMethod.ReturnType == typeof(CardWeightTable) && pi.GetMethod.Name.StartsWith("get_Shop") && pi.GetMethod.Name.EndsWith("Weight")
				select pi.GetMethod.Name).OrderBy<string, string>((string s) => s, StringComparer.Ordinal), (Action<string>)delegate(string s)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				shopRngs.rngs.Add(s, new RandomGen((ulong)initRng.Next()));
			});
			return shopRngs;
		}
	}
}
namespace RngFix.CustomRngs.Sampling
{
	public abstract class AbstractSlotSampler<T>
	{
		public List<ISlotRequirement> requirements = new List<ISlotRequirement>();

		protected Func<Type, T> initAction;

		public Action<T> successAction = null;

		public Action failureAction = null;

		public Action<SamplerLogInfo, Type> debugAction = null;

		public AbstractSlotSampler(List<ISlotRequirement> requirements, Func<Type, T> initAction, Action<T> successAction, Action failureAction)
		{
			this.requirements = requirements;
			this.initAction = initAction;
			this.successAction = successAction;
			this.failureAction = failureAction;
		}

		public abstract T Roll(RandomGen rng, Func<Type, float> getW, out SamplerLogInfo logInfo, Predicate<Type> filter = null, Func<T> fallback = null);
	}
	public class SamplerLogInfo
	{
		public float totalW;

		public float maxW;

		public float rawMaxW;

		public uint rolls;

		public float wThreshold;

		public float itemW;

		public uint wRollAttempts;

		public float itemProb;

		public float passThreshold;

		public float probabilityFraction;

		public float probabiltyMul;

		public override string ToString()
		{
			return $"ItemW:{itemW};WThreshold:{wThreshold};MaxW:{maxW};itemProb:{itemProb};passThreshold:{passThreshold};probabilityFraction:{probabilityFraction};probabiltyMul:{probabiltyMul};rawMaxW:{rawMaxW};TotalW:{totalW};wRollAttempts:{wRollAttempts};";
		}
	}
	public class EqualWSlotSampler<T> : AbstractSlotSampler<T>
	{
		private RepeatableUniformRandomPool<Type> constantPotentialPool;

		public ProbFactionRange factionRange = new ProbFactionRange(new float[9] { 1.6f, 2f, 4f, 5f, 6f, 7f, 10f, 20f, 100f });

		public uint maxItemRolls = 400000u;

		public float probabiltyMul = 0.381966f;

		public uint extraRolls = 0u;

		public EqualWSlotSampler(List<ISlotRequirement> requirements, Func<Type, T> initAction, Action<T> successAction, Action failureAction, IEnumerable<Type> potentialPool)
			: base(requirements, initAction, successAction, failureAction)
		{
			constantPotentialPool = new RepeatableUniformRandomPool<Type>();
			BuildPool(potentialPool);
		}

		public void BuildPool(IEnumerable<Type> potentialPool)
		{
			constantPotentialPool.Ad

Logging.dll

Decompiled 15 hours 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.persistentDataPath, (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)
		{
		}
	}
}