Decompiled source of TestAccountCore DawnLib Experimental v1.19.0

TestAccountCore.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dawn;
using DunGen;
using Dusk;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using MonoMod.Utils;
using TMPro;
using TestAccountCore.Dependencies;
using TestAccountCore.Dependencies.Compatibility;
using TestAccountCore.KotlinSharp.Extensions;
using TestAccountCore.Loaders;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Serialization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")]
[assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")]
[assembly: IgnoresAccessChecksTo("Unity.XR.Management")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")]
[assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TestAccount666.TestAccountCore")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod with some common methods I use in my mods")]
[assembly: AssemblyFileVersion("1.19.0.0")]
[assembly: AssemblyInformationalVersion("1.19.0+47c7765c1ac022bd357fbb64cc405553e1cca418")]
[assembly: AssemblyProduct("TestAccountCore")]
[assembly: AssemblyTitle("TestAccount666.TestAccountCore")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.19.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TestAccountCore
{
	public static class AssetLoader
	{
		private static AssetBundle? _assets;

		public static void LoadBundle(Assembly assembly, string assetBundleName)
		{
			string directoryName = Path.GetDirectoryName(assembly.Location);
			if (directoryName == null)
			{
				TestAccountCore.Logger.LogError((object)("Failed to determine assembly '" + assembly.FullName + "' location."));
				return;
			}
			string text = Path.Combine(directoryName, assetBundleName);
			if (!File.Exists(text))
			{
				TestAccountCore.Logger.LogFatal((object)("Asset bundle '" + assetBundleName + "' not found at " + text + ". Check if the asset bundle is in the same directory as the plugin."));
				return;
			}
			try
			{
				_assets = AssetBundle.LoadFromFile(text);
			}
			catch (Exception ex)
			{
				TestAccountCore.Logger.LogError((object)("Failed to load asset bundle '" + assetBundleName + "' for assembly " + assembly.FullName + ": " + ex.Message));
			}
		}

		public static void LoadCustomScripts(ConfigFile? configFile)
		{
			if (_assets == null || configFile == null)
			{
				return;
			}
			CustomScript[] source = _assets.LoadAllAssets<CustomScript>();
			IEnumerable<CustomScript> enumerable = source.OfType<CustomScript>();
			foreach (CustomScript item in enumerable)
			{
				item.Initialize(configFile);
			}
		}

		private static List<T> LoadAssetsAndRegister<T>(ConfigFile? configFile, Action<List<T>, ConfigFile?> registerAction, bool checkDawnLib = true) where T : Object
		{
			if (_assets == null || configFile == null)
			{
				return new List<T>();
			}
			if (checkDawnLib && !DependencyChecker.IsDawnLibInstalled())
			{
				StackTrace stackTrace = new StackTrace(3, fNeedFileInfo: true);
				StackFrame stackFrame = stackTrace.GetFrames()?.FirstOrDefault();
				string text = stackFrame?.GetFileName();
				object obj;
				if (stackFrame == null)
				{
					obj = null;
				}
				else
				{
					MethodBase? method = stackFrame.GetMethod();
					obj = (((object)method != null) ? GeneralExtensions.FullDescription(method) : null);
				}
				string text2 = (string)obj;
				TestAccountCore.Logger.LogError((object)("DawnLib is not installed, but is required to load custom content!\nOffending Mod: " + text + " (Via " + text2 + ")"));
				return new List<T>();
			}
			List<T> list = _assets.LoadAllAssets<T>().OfType<T>().ToList();
			registerAction(list, configFile);
			return list;
		}

		public static void LoadItems(ConfigFile? configFile)
		{
			LoadItemsAndReturn(configFile);
		}

		public static List<ItemWithDefaultWeight> LoadItemsAndReturn(ConfigFile? configFile)
		{
			return LoadAssetsAndRegister<ItemWithDefaultWeight>(configFile, (Action<List<ItemWithDefaultWeight>, ConfigFile?>)ScrapLoader.RegisterAllScrap, checkDawnLib: true);
		}

		public static void LoadHazards(ConfigFile? configFile)
		{
			LoadHazardsAndReturn(configFile);
		}

		public static List<MapHazardWithDefaultWeight> LoadHazardsAndReturn(ConfigFile? configFile)
		{
			return LoadAssetsAndRegister<MapHazardWithDefaultWeight>(configFile, (Action<List<MapHazardWithDefaultWeight>, ConfigFile?>)HazardLoader.RegisterAllHazards, checkDawnLib: true);
		}

		public static void LoadUnlockables(ConfigFile? configFile)
		{
			LoadUnlockablesAndReturn(configFile);
		}

		public static List<UnlockableWithPrice> LoadUnlockablesAndReturn(ConfigFile? configFile)
		{
			return LoadAssetsAndRegister<UnlockableWithPrice>(configFile, (Action<List<UnlockableWithPrice>, ConfigFile?>)UnlockableLoader.RegisterAllUnlockables, checkDawnLib: true);
		}

		public static void LoadShopItems(ConfigFile? configFile)
		{
			LoadShopItemsAndReturn(configFile);
		}

		public static List<ShopItemWithDefaultPrice> LoadShopItemsAndReturn(ConfigFile? configFile)
		{
			return LoadAssetsAndRegister<ShopItemWithDefaultPrice>(configFile, (Action<List<ShopItemWithDefaultPrice>, ConfigFile?>)ShopItemLoader.RegisterAllShopItems, checkDawnLib: true);
		}

		public static void LoadEnemies(ConfigFile? configFile)
		{
			LoadEnemiesAndReturn(configFile);
		}

		public static List<EnemyWithDefaultWeight> LoadEnemiesAndReturn(ConfigFile? configFile)
		{
			return LoadAssetsAndRegister<EnemyWithDefaultWeight>(configFile, (Action<List<EnemyWithDefaultWeight>, ConfigFile?>)EnemyLoader.RegisterAllEnemies, checkDawnLib: true);
		}

		public static void LoadHallwayHazards(ConfigFile? configFile)
		{
			LoadHallwayHazardsAndReturn(configFile);
		}

		public static List<HallwayHazardWithDefaultWeight> LoadHallwayHazardsAndReturn(ConfigFile? configFile)
		{
			return LoadAssetsAndRegister<HallwayHazardWithDefaultWeight>(configFile, (Action<List<HallwayHazardWithDefaultWeight>, ConfigFile?>)HallwayHazardLoader.RegisterAllHazards, checkDawnLib: true);
		}

		public static void UnloadBundle(bool unloadAllLoadedObjects = false)
		{
			AssetBundle? assets = _assets;
			if (assets != null)
			{
				assets.Unload(unloadAllLoadedObjects);
			}
		}
	}
	public abstract class CustomScript : ScriptableObject
	{
		public abstract void Initialize(ConfigFile? configFile);
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/EnemyWithDefaultWeight", order = 1)]
	public class EnemyWithDefaultWeight : ScriptableObject
	{
		[SerializeField]
		[Tooltip("The enemy type to register.")]
		[Space(10f)]
		public EnemyType? enemyType;

		[SerializeField]
		[Tooltip("The default spawn weight.")]
		[Space(10f)]
		public int defaultWeight;

		[SerializeField]
		[Tooltip("The terminal info node.")]
		[Space(10f)]
		public TerminalNode infoNode;

		[SerializeField]
		[Tooltip("The terminal keyword.")]
		[Space(10f)]
		public TerminalKeyword keyWord;

		[SerializeField]
		[Tooltip("All network prefabs that are connected to this enemy.")]
		[Space(5f)]
		public List<GameObject> connectedNetworkPrefabs = new List<GameObject>();

		public bool isRegistered;
	}
	[HarmonyPatch(typeof(Dungeon), "SpawnDoorPrefab")]
	public static class HallwayHazardRegistry
	{
		private class _registeredHazard
		{
			private readonly MathOperation[] _addSubtract;

			public HallwayHazardWithDefaultWeight Hazard { get; }

			public HashSet<ResolvedNamespacedWeight<DawnMoonInfo>> MoonWeightModifiers { get; private set; }

			public HashSet<ResolvedNamespacedWeight<DawnDungeonInfo>> InteriorWeightModifiers { get; private set; }

			public _registeredHazard(HallwayHazardWithDefaultWeight hazard, ConfigEntry<string> moonSpawnWeights, ConfigEntry<string>? interiorSpawnWeights)
			{
				<moonSpawnWeights>P = moonSpawnWeights;
				<interiorSpawnWeights>P = interiorSpawnWeights;
				Hazard = hazard;
				MoonWeightModifiers = new HashSet<ResolvedNamespacedWeight<DawnMoonInfo>>();
				InteriorWeightModifiers = new HashSet<ResolvedNamespacedWeight<DawnDungeonInfo>>();
				_addSubtract = (MathOperation[])(object)new MathOperation[2]
				{
					default(MathOperation),
					(MathOperation)1
				};
				base..ctor();
			}

			internal void BindResolvers()
			{
				LethalContent.Moons.AfterTaggingWithContext += MoonsOnOnFreezeWithContext;
				LethalContent.Dungeons.AfterTaggingWithContext += DungeonsOnOnFreezeWithContext;
			}

			private void DungeonsOnOnFreezeWithContext(NamespacedKeyResolver<DawnDungeonInfo> resolver)
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				if (<interiorSpawnWeights>P?.Value == null)
				{
					return;
				}
				HashSet<ResolvedNamespacedWeight<DawnDungeonInfo>> hashSet = new HashSet<ResolvedNamespacedWeight<DawnDungeonInfo>>();
				foreach (ResolvedNamespacedWeight<DawnDungeonInfo> item in NamespacedKeyResolverWeightExtensions.ResolveWeights<DawnDungeonInfo>(resolver, (IEnumerable<UnresolvedNamespacedWeight>)UnresolvedNamespacedWeight.ConvertManyFromString(<interiorSpawnWeights>P.Value)))
				{
					hashSet.Add(item);
				}
				InteriorWeightModifiers = hashSet;
			}

			private void MoonsOnOnFreezeWithContext(NamespacedKeyResolver<DawnMoonInfo> resolver)
			{
				//IL_0026: 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_002d: Unknown result type (might be due to invalid IL or missing references)
				HashSet<ResolvedNamespacedWeight<DawnMoonInfo>> hashSet = new HashSet<ResolvedNamespacedWeight<DawnMoonInfo>>();
				foreach (ResolvedNamespacedWeight<DawnMoonInfo> item in NamespacedKeyResolverWeightExtensions.ResolveWeights<DawnMoonInfo>(resolver, (IEnumerable<UnresolvedNamespacedWeight>)UnresolvedNamespacedWeight.ConvertManyFromString(<moonSpawnWeights>P.Value)))
				{
					hashSet.Add(item);
				}
				MoonWeightModifiers = hashSet;
			}

			private float ApplyModifiers<T>(float currentWeight, IEnumerable<ResolvedNamespacedWeight<T>> modifiers, T targetKey) where T : ITaggable, INamespaced
			{
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Invalid comparison between Unknown and I4
				ResolvedNamespacedWeight<T>[] source = modifiers.Where<ResolvedNamespacedWeight<T>>((ResolvedNamespacedWeight<T> weight) => (NamespacedKey)(object)weight.Key == ((INamespaced)targetKey).Key || ((ITaggable)targetKey/*cast due to .constrained prefix*/).HasTag((NamespacedKey)(object)weight.Key)).ToArray();
				IEnumerable<ResolvedNamespacedWeight<T>> enumerable = source.Where((ResolvedNamespacedWeight<T> weight) => _addSubtract.Contains(weight.Operation));
				IEnumerable<ResolvedNamespacedWeight<T>> enumerable2 = source.Where((ResolvedNamespacedWeight<T> weight) => !_addSubtract.Contains(weight.Operation));
				foreach (ResolvedNamespacedWeight<T> item in enumerable)
				{
					currentWeight = (((int)item.Operation != 0) ? (currentWeight - item.Value) : (currentWeight + item.Value));
				}
				foreach (ResolvedNamespacedWeight<T> item2 in enumerable2)
				{
					currentWeight = (((int)item2.Operation != 3) ? (currentWeight * item2.Value) : (currentWeight / item2.Value));
				}
				return currentWeight;
			}

			public float GetWeight(DawnMoonInfo level, DawnDungeonInfo dungeon)
			{
				float currentWeight = ApplyModifiers<DawnMoonInfo>(0f, (IEnumerable<ResolvedNamespacedWeight<DawnMoonInfo>>)MoonWeightModifiers, level);
				currentWeight = ApplyModifiers<DawnDungeonInfo>(currentWeight, (IEnumerable<ResolvedNamespacedWeight<DawnDungeonInfo>>)InteriorWeightModifiers, dungeon);
				return Math.Max(currentWeight, 0f);
			}

			public static void BindResolvers(_registeredHazard it)
			{
				it.BindResolvers();
			}
		}

		private static readonly List<_registeredHazard> _REGISTERED_HAZARDS = new List<_registeredHazard>();

		private static ManualLogSource Logger => TestAccountCore.Logger;

		public static void RegisterHazard(HallwayHazardWithDefaultWeight hazard, ConfigEntry<string> moonWeights, ConfigEntry<string> interiorWeights)
		{
			_REGISTERED_HAZARDS.Add(new _registeredHazard(hazard, moonWeights, interiorWeights).Also(_registeredHazard.BindResolvers));
		}

		[HarmonyPatch]
		[HarmonyPrefix]
		public static void InjectHazards(Dungeon __instance, Doorway a, Doorway b)
		{
			AddHazardsForDoorway(a, 0.05f, __instance);
			AddHazardsForDoorway(b, 0.07f, __instance);
		}

		private static void AddHazardsForDoorway(Doorway doorway, float multiplier, Dungeon dungeon)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			if ((Object)(object)doorway == (Object)null || doorway.ConnectorPrefabWeights == null)
			{
				return;
			}
			List<GameObjectWeight> connectorPrefabWeights = doorway.ConnectorPrefabWeights;
			int num = connectorPrefabWeights.Count((GameObjectWeight val) => val != null && Object.op_Implicit((Object)(object)val.GameObject) && ((Object)val.GameObject).name == "BigDoorSpawn");
			if (num == 0)
			{
				return;
			}
			DawnMoonInfo level = SelectableLevelExtensions[RoundManager.Instance.currentLevel];
			DawnDungeonInfo dungeon2 = DungeonFlowExtensions[dungeon.DungeonFlow];
			foreach (_registeredHazard rEGISTERED_HAZARD in _REGISTERED_HAZARDS)
			{
				float weight = rEGISTERED_HAZARD.GetWeight(level, dungeon2);
				float weight2 = multiplier * weight;
				GameObject spawnHazardPrefab = rEGISTERED_HAZARD.Hazard.spawnHazardPrefab;
				for (int num2 = 0; num2 < num; num2++)
				{
					connectorPrefabWeights.Add(new GameObjectWeight
					{
						Weight = weight2,
						GameObject = spawnHazardPrefab
					});
				}
			}
		}
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/HallwayHazardWithDefaultWeight", order = 1)]
	public class HallwayHazardWithDefaultWeight : ScriptableObject
	{
		[SerializeField]
		[Tooltip("The hazard prefab to spawn.")]
		[Space(10f)]
		public GameObject? hazardPrefab;

		[SerializeField]
		[Tooltip("The spawn prefab used to spawn the hazard.")]
		[Space(10f)]
		public GameObject? spawnHazardPrefab;

		[SerializeField]
		[Tooltip("The hazard name.")]
		[Space(10f)]
		public string? hazardName;

		[SerializeField]
		[Tooltip("The default spawn weight of this hazard.")]
		[Space(5f)]
		public int defaultWeight;

		[SerializeField]
		[Tooltip("All network prefabs that are connected to this hazard.")]
		[Space(5f)]
		public List<GameObject> connectedNetworkPrefabs = new List<GameObject>();

		public bool isRegistered;
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/ItemWithDefaultWeight", order = 1)]
	public class ItemWithDefaultWeight : ScriptableObject
	{
		[SerializeField]
		[Tooltip("The item properties.")]
		[Space(10f)]
		public Item? item;

		[SerializeField]
		[Tooltip("The default spawn weight of this item.")]
		[Space(5f)]
		public int defaultWeight;

		[SerializeField]
		[Tooltip("All network prefabs that are connected to this item.")]
		[Space(5f)]
		public List<GameObject> connectedNetworkPrefabs = new List<GameObject>();

		[SerializeField]
		[Tooltip("Alternative item properties, which are registered without any spawn weight.")]
		[Space(10f)]
		public List<Item> alternativeItems = new List<Item>();

		public bool isRegistered;
	}
	public static class LinqExtensions
	{
		public static bool None<TSource>(this IEnumerable<TSource> source)
		{
			return !source.Any();
		}
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/MapHazardWithDefaultWeight", order = 1)]
	public class MapHazardWithDefaultWeight : ScriptableObject
	{
		[SerializeField]
		[Tooltip("The hazard to spawn.")]
		[Space(10f)]
		public GameObject? spawnableMapObject;

		[SerializeField]
		[Tooltip("The amount to spawn.")]
		[Space(10f)]
		[Obsolete]
		public int amount;

		[SerializeField]
		[Tooltip("The amount to spawn.")]
		[Space(10f)]
		public string? spawnCurve;

		[SerializeField]
		[Tooltip("The hazard name.")]
		[Space(10f)]
		public string? hazardName;

		[SerializeField]
		[Space(10f)]
		public bool spawnFacingAwayFromWall;

		[SerializeField]
		[Space(10f)]
		public bool spawnFacingWall;

		[SerializeField]
		[Space(10f)]
		public bool spawnWithBackToWall;

		[SerializeField]
		[Space(10f)]
		public bool spawnWithBackFlushAgainstWall;

		[SerializeField]
		[Space(10f)]
		public bool requireDistanceBetweenSpawns;

		[SerializeField]
		[Space(10f)]
		public bool disallowSpawningNearEntrances;

		public bool isRegistered;
	}
	[AddComponentMenu("TestAccount666/TestAccountCore/Material Variants")]
	public class MaterialVariants : NetworkBehaviour
	{
		[Tooltip("The variants of the scrap.")]
		public Material[] materialVariants;

		[Space(5f)]
		[Tooltip("The mesh renderers to change the material of. This will use the first material in the array.")]
		public MeshRenderer[] meshRenderers;

		[FormerlySerializedAs("ChangeScanNodeText")]
		[Space(5f)]
		public bool changeScanNodeText;

		[Tooltip("The text to change to when the material is changed.")]
		public string[] scanNodeText;

		[Space(5f)]
		[Tooltip("The scan node properties to change the text of.")]
		public ScanNodeProperties scanNodeProperties;

		[Space(5f)]
		[Tooltip("The currently saved material variant.")]
		public int savedMaterialVariant = -1;

		public bool synced;

		public override void OnNetworkSpawn()
		{
			((MonoBehaviour)this).StartCoroutine(WaitAndSync());
		}

		[ServerRpc(RequireOwnership = false)]
		private void SetRendererServerRpc()
		{
			savedMaterialVariant = ((savedMaterialVariant != -1) ? Math.Clamp(savedMaterialVariant, 0, materialVariants.Length - 1) : Random.Range(0, materialVariants.Length));
			SetRendererClientRpc(savedMaterialVariant);
		}

		[ClientRpc]
		private void SetRendererClientRpc(int materialVariant)
		{
			synced = true;
			MeshRenderer[] array = meshRenderers;
			foreach (MeshRenderer val in array)
			{
				((Renderer)val).material = materialVariants[materialVariant];
				if (changeScanNodeText)
				{
					scanNodeProperties.headerText = scanNodeText[materialVariant];
				}
			}
		}

		private IEnumerator WaitAndSync()
		{
			while (true)
			{
				yield return (object)new WaitForSeconds(1f);
				SetRendererServerRpc();
				yield return (object)new WaitForEndOfFrame();
				if (synced)
				{
					break;
				}
				TestAccountCore.Logger.LogDebug((object)"Not yet synced, retrying...");
			}
			TestAccountCore.Logger.LogDebug((object)"Already synced, breaking out.");
		}
	}
	public static class Netcode
	{
		public static void ExecuteNetcodePatcher(Assembly assembly)
		{
			List<Type> list = new List<Type>();
			try
			{
				list.AddRange(assembly.GetTypes());
			}
			catch (ReflectionTypeLoadException ex)
			{
				list.AddRange(ex.Types.Where((Type t) => t != null));
			}
			foreach (Type item in list)
			{
				try
				{
					MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					MethodInfo[] array = methods;
					foreach (MethodInfo methodInfo in array)
					{
						object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
						if (customAttributes.Length != 0)
						{
							methodInfo.Invoke(null, null);
						}
					}
				}
				catch (Exception)
				{
				}
			}
		}
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/ShopItemWithDefaultPrice", order = 1)]
	public class ShopItemWithDefaultPrice : ScriptableObject
	{
		[SerializeField]
		[Tooltip("The item properties.")]
		[Space(10f)]
		public Item? item;

		[SerializeField]
		[Tooltip("The default price of this item.")]
		[Space(5f)]
		public int defaultPrice;

		[SerializeField]
		[Tooltip("All network prefabs that are connected to this item.")]
		[Space(5f)]
		public List<GameObject> connectedNetworkPrefabs = new List<GameObject>();

		public bool isRegistered;
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public static class SpawnTheUnlockablesGodDammit
	{
		public static HashSet<UnlockableItem> AllUnlockedItems = new HashSet<UnlockableItem>();

		[HarmonyPatch("LoadUnlockables")]
		[HarmonyPrefix]
		public static void SpawnFuckingUnlockables()
		{
			DoYourWorst();
		}

		[HarmonyPatch("ResetShipFurniture")]
		[HarmonyPostfix]
		public static void RespawnTheGodDamnUnlockables()
		{
			DoYourWorst();
		}

		private static void DoYourWorst()
		{
			StartOfRound instance = StartOfRound.Instance;
			if (!Object.op_Implicit((Object)(object)instance) || (!((NetworkBehaviour)instance).IsHost && !((NetworkBehaviour)instance).IsServer))
			{
				return;
			}
			List<UnlockableItem> unlockables = instance.unlockablesList.unlockables;
			for (int i = 0; i < unlockables.Count; i++)
			{
				UnlockableItem val = unlockables[i];
				if (AllUnlockedItems.Contains(val) && !val.hasBeenUnlockedByPlayer && !val.alreadyUnlocked && !instance.SpawnedShipUnlockables.ContainsKey(i))
				{
					instance.SpawnUnlockable(i, false);
					val.hasBeenUnlockedByPlayer = true;
				}
			}
		}
	}
	public enum StoreType
	{
		None,
		ShipUpgrade,
		Decor
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("TestAccount666.TestAccountCore", "TestAccountCore", "1.19.0")]
	public class TestAccountCore : BaseUnityPlugin
	{
		internal static Harmony? harmony;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			if (harmony == null)
			{
				harmony = new Harmony("TestAccount666.TestAccountCore");
			}
			try
			{
				harmony.PatchAll(typeof(VersionChecker));
			}
			catch (Exception ex)
			{
				Logger.LogError((object)"Failed to patch VersionChecker!");
				Extensions.LogDetailed(ex, (string)null);
			}
			if (DependencyChecker.IsDawnLibInstalled())
			{
				string text = DependencyChecker.GetDawnLibVersion()[0].ToString();
				if (!int.TryParse(text, out var result) || result < 1)
				{
					Logger.LogError((object)("Detected DawnLib, but found an invalid version! (Expected experimental 1.x.x or higher! Got: " + text + ")"));
					return;
				}
				harmony.PatchAll(typeof(HallwayHazardRegistry));
				harmony.PatchAll(typeof(SpawnTheUnlockablesGodDammit));
			}
			if (DependencyChecker.IsLobbyCompatibilityInstalled())
			{
				Logger.LogInfo((object)"Found LobbyCompatibility Mod, initializing support :)");
				LobbyCompatibilitySupport.Initialize();
			}
			Logger.LogInfo((object)"TestAccount666.TestAccountCore v1.19.0 has loaded!");
		}
	}
	public static class UnixTime
	{
		public static long GetCurrentTime()
		{
			return DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
		}
	}
	[CreateAssetMenu(menuName = "ScriptableObjects/UnlockableWithPrice", order = 1)]
	public class UnlockableWithPrice : ScriptableObject
	{
		[SerializeField]
		[Tooltip("The unlockable type.")]
		[Space(10f)]
		public StoreType storeType;

		[SerializeField]
		[Tooltip("The unlockable name.")]
		[Space(10f)]
		public string? unlockableName;

		[SerializeField]
		[Tooltip("The unlockable price.")]
		[Space(10f)]
		public int price;

		[SerializeField]
		[Tooltip("The luck value for this unlockable.")]
		[Space(10f)]
		public float luckValue;

		[SerializeField]
		[Tooltip("The unlockable prefab.")]
		[Space(10f)]
		public GameObject? spawnPrefab;

		public bool isRegistered;
	}
	[HarmonyPatch(typeof(MenuManager))]
	public static class VersionChecker
	{
		private static ManualLogSource Logger => TestAccountCore.Logger;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void CheckVersion(MenuManager __instance)
		{
			try
			{
				((MonoBehaviour)__instance).StartCoroutine(WaitForVersionToExist(__instance));
			}
			catch (Exception ex)
			{
				Logger.LogError((object)"Failed to check version!");
				Extensions.LogDetailed(ex, (string)null);
			}
		}

		public static IEnumerator WaitForVersionToExist(MenuManager manager)
		{
			yield return (object)new WaitUntil((Func<bool>)delegate
			{
				TextMeshProUGUI versionNumberText = manager.versionNumberText;
				return versionNumberText != null && ((TMP_Text)versionNumberText).text != null;
			});
			string text = ((TMP_Text)manager.versionNumberText).text;
			int versionNumber;
			if (Utility.IsNullOrWhiteSpace(text))
			{
				Logger.LogError((object)"Failed to check version! Version String null?!");
			}
			else if (TryExtractVersionNumber(text, out versionNumber))
			{
				ValidateVersionRequirement(versionNumber);
			}
		}

		private static bool TryExtractVersionNumber(string rawVersion, out int versionNumber)
		{
			versionNumber = -1;
			int num = rawVersion.IndexOf(' ');
			string text = ((num >= 0) ? rawVersion.Substring(0, num) : rawVersion).Trim();
			if (text.StartsWith("v", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring(1);
			}
			if (int.TryParse(text, out versionNumber))
			{
				return true;
			}
			Logger.LogError((object)("Failed to check version! Couldn't parse '" + rawVersion + "' (" + text + ") to int!"));
			return false;
		}

		private static void ValidateVersionRequirement(int versionNumber)
		{
			if (versionNumber < 80)
			{
				Logger.LogWarning((object)$"TestAccountCore requires version v80 or higher! Please update Lethal Company! (Detected v{versionNumber})");
			}
			else
			{
				Logger.LogInfo((object)$"TestAccountCore is running on version v{versionNumber}!");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TestAccount666.TestAccountCore";

		public const string PLUGIN_NAME = "TestAccountCore";

		public const string PLUGIN_VERSION = "1.19.0";
	}
}
namespace TestAccountCore.Loaders
{
	public static class EnemyLoader
	{
		internal static void RegisterAllEnemies(List<EnemyWithDefaultWeight> enemiesWithDefaultWeight, ConfigFile? configFile)
		{
			if (configFile != null)
			{
				enemiesWithDefaultWeight.ForEach(delegate(EnemyWithDefaultWeight enemy)
				{
					RegisterEnemy(enemy, configFile);
				});
			}
		}

		private static void RegisterEnemy(EnemyWithDefaultWeight enemy, ConfigFile? configFile)
		{
			if (configFile == null)
			{
				return;
			}
			if (enemy.enemyType == null)
			{
				throw new NullReferenceException("EnemyType cannot be null!");
			}
			string enemyName = enemy.enemyType.enemyName;
			string text = enemyName + " - Enemy";
			ConfigEntry<bool> val = configFile.Bind<bool>(text, "1. Enabled", true, "If false, " + enemyName + " will not be registered. This is different from a spawn weight of 0!");
			if (!val.Value)
			{
				return;
			}
			TestAccountCore.Logger.LogInfo((object)("Registering enemy " + enemyName + "..."));
			ConfigEntry<string> configMoonRarity = configFile.Bind<string>(text, "2. Moon Spawn Weight", $"vanilla=+{enemy.defaultWeight}, custom=+{enemy.defaultWeight}", $"Defines the spawn weight per moon. e.g. Assurance:{enemy.defaultWeight}");
			ConfigEntry<string> configInteriorRarity = configFile.Bind<string>(text, "3. Interior Spawn Weight", "vanilla=+0, custom=+0", "Defines the spawn weight per interior.");
			NamespacedKey<DawnEnemyInfo> val2 = NamespacedKey<DawnEnemyInfo>.From("testaccountcore", "enemy" + enemyName.ToLower());
			DawnLib.DefineEnemy(val2, enemy.enemyType, (Action<EnemyInfoBuilder>)delegate(EnemyInfoBuilder enemyBuilder)
			{
				enemyBuilder.CreateBestiaryNode(enemy.infoNode.displayText).CreateNameKeyword(enemy.keyWord.word);
				enemyBuilder.DefineInside((Action<EnemyLocationBuilder>)delegate(EnemyLocationBuilder insideBuilder)
				{
					insideBuilder.SetWeights((Action<WeightProfile<int>>)delegate(WeightProfile<int> profile)
					{
						//IL_0020: Unknown result type (might be due to invalid IL or missing references)
						//IL_002a: Expected O, but got Unknown
						//IL_0025: Unknown result type (might be due to invalid IL or missing references)
						//IL_004b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0055: Expected O, but got Unknown
						//IL_0050: Unknown result type (might be due to invalid IL or missing references)
						profile.AddSource((IWeightModifierSource<int>)new MoonIntWeightSource((Func<IEnumerable<UnresolvedNamespacedWeight>>)(() => UnresolvedNamespacedWeight.ConvertManyFromString(configMoonRarity.Value))));
						profile.AddSource((IWeightModifierSource<int>)new DungeonIntWeightSource((Func<IEnumerable<UnresolvedNamespacedWeight>>)(() => UnresolvedNamespacedWeight.ConvertManyFromString(configInteriorRarity.Value))));
					});
				});
			});
			DawnLib.RegisterNetworkPrefab(enemy.enemyType.enemyPrefab);
			enemy.connectedNetworkPrefabs.ForEach((Action<GameObject>)DawnLib.RegisterNetworkPrefab);
			enemy.isRegistered = true;
			TestAccountCore.Logger.LogInfo((object)("Fully registered enemy " + enemyName + "!"));
		}
	}
	public static class HallwayHazardLoader
	{
		internal static void RegisterAllHazards(List<HallwayHazardWithDefaultWeight> hazardsWithDefaultWeight, ConfigFile? configFile)
		{
			if (configFile != null)
			{
				hazardsWithDefaultWeight.ForEach(delegate(HallwayHazardWithDefaultWeight hazard)
				{
					RegisterHazard(hazard, configFile);
				});
			}
		}

		private static void RegisterHazard(HallwayHazardWithDefaultWeight hazard, ConfigFile? configFile)
		{
			if (configFile != null)
			{
				if (hazard.hazardName == null)
				{
					throw new NullReferenceException("Hallway Hazard name cannot be null!");
				}
				if (hazard.hazardPrefab == null)
				{
					throw new NullReferenceException("Hallway Hazard " + hazard.hazardName + " has no prefab!");
				}
				if (hazard.spawnHazardPrefab == null)
				{
					throw new NullReferenceException("Hallway Hazard " + hazard.hazardName + " has no spawn prefab!");
				}
				string hazardName = hazard.hazardName;
				string text = hazardName + " - Hallway Hazard";
				ConfigEntry<bool> val = configFile.Bind<bool>(text, "1. Enabled", true, "If false, " + hazardName + " will not be registered. This is different from a spawn weight of 0!");
				if (val.Value)
				{
					TestAccountCore.Logger.LogInfo((object)("Registering hallway hazard " + hazardName + "..."));
					ConfigEntry<string> moonWeights = configFile.Bind<string>(text, "2. Moon Spawn Weight", $"vanilla=+{hazard.defaultWeight}, custom=+{hazard.defaultWeight}", $"Defines the spawn weight per moon. e.g. Assurance:{hazard.defaultWeight}");
					ConfigEntry<string> interiorWeights = configFile.Bind<string>(text, "2. Interior Spawn Weight", "vanilla=+0, custom=+0", "Defines the spawn weight per interior.");
					DawnLib.RegisterNetworkPrefab(hazard.hazardPrefab);
					hazard.connectedNetworkPrefabs.ForEach((Action<GameObject>)DawnLib.RegisterNetworkPrefab);
					HallwayHazardRegistry.RegisterHazard(hazard, moonWeights, interiorWeights);
					hazard.isRegistered = true;
					TestAccountCore.Logger.LogInfo((object)("Fully registered hallway hazard " + hazardName + "!"));
				}
			}
		}
	}
	public static class HazardLoader
	{
		internal static void RegisterAllHazards(List<MapHazardWithDefaultWeight> hazardsWithDefaultWeight, ConfigFile? configFile)
		{
			if (configFile != null)
			{
				hazardsWithDefaultWeight.ForEach(delegate(MapHazardWithDefaultWeight hazard)
				{
					RegisterHazard(hazard, configFile);
				});
			}
		}

		private static void RegisterHazard(MapHazardWithDefaultWeight hazard, ConfigFile? configFile)
		{
			if (configFile == null)
			{
				return;
			}
			if (hazard.hazardName == null)
			{
				throw new NullReferenceException("Map Hazard name cannot be null!");
			}
			if (hazard.spawnableMapObject == null)
			{
				throw new NullReferenceException("(" + hazard.hazardName + ") Map Hazard cannot be null!");
			}
			string hazardName = hazard.hazardName;
			string text = hazardName + " - Hazard";
			ConfigEntry<bool> val = configFile.Bind<bool>(text, "1. Enabled", true, "If false, " + hazardName + " will not be registered.");
			if (!val.Value)
			{
				return;
			}
			TestAccountCore.Logger.LogInfo((object)("Registering hazard " + hazardName + "..."));
			if (string.IsNullOrWhiteSpace(hazard.spawnCurve))
			{
				TestAccountCore.Logger.LogWarning((object)("Hazard " + hazardName + " is still using spawn amount! This is no longer supported!"));
				return;
			}
			hazard.spawnCurve = hazard.spawnCurve.Replace(",", ";").Replace(":", ",");
			string text2 = "vanilla - " + hazard.spawnCurve + " | custom - " + hazard.spawnCurve;
			ConfigEntry<string> moonSpawnCurve = configFile.Bind<string>(text, "2. Moon Spawn Curve", text2, "The moon spawn curve for " + hazardName + ". First number is between 0 and 1. The second one is the max amount.");
			ConfigEntry<string> interiorSpawnCurve = configFile.Bind<string>(text, "3. Interior Spawn Curve", text2, "The interior spawn curve for " + hazardName + ". First number is between 0 and 1. The second one is the max amount.");
			NamespacedKey<DawnMapObjectInfo> val2 = NamespacedKey<DawnMapObjectInfo>.From("testaccountcore", "hazard" + hazardName.ToLower());
			DawnLib.DefineMapObject(val2, hazard.spawnableMapObject, (Action<MapObjectInfoBuilder>)delegate(MapObjectInfoBuilder infoBuilder)
			{
				infoBuilder.DefineInside((Action<InsideBuilder>)delegate(InsideBuilder insideBuilder)
				{
					insideBuilder.OverrideDisallowSpawningNearEntrances(hazard.disallowSpawningNearEntrances);
					insideBuilder.OverrideRequireDistanceBetweenSpawns(hazard.requireDistanceBetweenSpawns);
					insideBuilder.OverrideSpawnFacingAwayFromWall(hazard.spawnFacingAwayFromWall);
					insideBuilder.OverrideSpawnFacingWall(hazard.spawnFacingWall);
					insideBuilder.OverrideSpawnWithBackFlushAgainstWall(hazard.spawnWithBackFlushAgainstWall);
					insideBuilder.OverrideSpawnWithBackToWall(hazard.spawnWithBackToWall);
					insideBuilder.SetWeights((Action<WeightProfile<AnimationCurve>>)delegate(WeightProfile<AnimationCurve?> profile)
					{
						//IL_005e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0068: Expected O, but got Unknown
						//IL_0063: Unknown result type (might be due to invalid IL or missing references)
						profile.AddSource((IWeightModifierSource<AnimationCurve>)new MapObjectSpawnMechanics((Func<string>)(() => moonSpawnCurve.Value), (Func<string>)(() => interiorSpawnCurve.Value), (Func<bool>)(() => false)));
					});
				});
			});
			DawnLib.RegisterNetworkPrefab(hazard.spawnableMapObject);
			hazard.isRegistered = true;
			TestAccountCore.Logger.LogInfo((object)("Fully registered hazard " + hazardName + "!"));
		}
	}
	public static class ScrapLoader
	{
		internal static void RegisterAllScrap(List<ItemWithDefaultWeight> itemsWithDefaultWeight, ConfigFile? configFile)
		{
			if (configFile != null)
			{
				itemsWithDefaultWeight.ForEach(delegate(ItemWithDefaultWeight item)
				{
					RegisterScrap(item, configFile);
				});
			}
		}

		private static void RegisterScrap(ItemWithDefaultWeight item, ConfigFile? configFile)
		{
			if (configFile == null)
			{
				return;
			}
			if (item.item == null)
			{
				throw new NullReferenceException("ItemProperties cannot be null!");
			}
			string itemName = item.item.itemName;
			string text = itemName + " - Scrap";
			ConfigEntry<bool> val = configFile.Bind<bool>(text, "1. Enabled", true, "If false, " + itemName + " will not be registered. This is different from a spawn weight of 0!");
			if (!val.Value)
			{
				return;
			}
			TestAccountCore.Logger.LogInfo((object)("Registering item " + itemName + "..."));
			ConfigEntry<int> val2 = configFile.Bind<int>(text, "2. Maximum Value", item.item.maxValue, "Defines the maximum scrap value for " + itemName + ".");
			ConfigEntry<int> val3 = configFile.Bind<int>(text, "3. Minimum Value", item.item.minValue, "Defines the minimum scrap value for " + itemName + ".");
			ConfigEntry<string> configMoonRarity = configFile.Bind<string>(text, "4. Moon Spawn Weight", $"vanilla=+{item.defaultWeight}, custom=+{item.defaultWeight}", $"Defines the spawn weight per moon. e.g. Assurance:{item.defaultWeight}");
			ConfigEntry<string> configInteriorRarity = configFile.Bind<string>(text, "5. Interior Spawn Weight", "vanilla=+0, custom=+0", "Defines the spawn weight per interior.");
			item.item.maxValue = val2.Value;
			item.item.minValue = val3.Value;
			ConfigEntry<bool> val4 = configFile.Bind<bool>(itemName + " - General", "1. Is Conductive", item.item.isConductiveMetal, "If set to true, will make the item conductive. Conductive defines, if the item attracts lightning");
			item.item.isConductiveMetal = val4.Value;
			NamespacedKey<DawnItemInfo> val5 = NamespacedKey<DawnItemInfo>.From("testaccountcore", "scrap" + itemName.ToLower());
			DawnLib.DefineItem(val5, item.item, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
			{
				builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder)
				{
					scrapBuilder.SetWeights((Action<WeightProfile<int>>)delegate(WeightProfile<int> profile)
					{
						//IL_0020: Unknown result type (might be due to invalid IL or missing references)
						//IL_002a: Expected O, but got Unknown
						//IL_0025: Unknown result type (might be due to invalid IL or missing references)
						//IL_004b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0055: Expected O, but got Unknown
						//IL_0050: Unknown result type (might be due to invalid IL or missing references)
						profile.AddSource((IWeightModifierSource<int>)new MoonIntWeightSource((Func<IEnumerable<UnresolvedNamespacedWeight>>)(() => UnresolvedNamespacedWeight.ConvertManyFromString(configMoonRarity.Value))));
						profile.AddSource((IWeightModifierSource<int>)new DungeonIntWeightSource((Func<IEnumerable<UnresolvedNamespacedWeight>>)(() => UnresolvedNamespacedWeight.ConvertManyFromString(configInteriorRarity.Value))));
					});
				});
			});
			for (int num = 0; num < item.alternativeItems.Count; num++)
			{
				Item val6 = item.alternativeItems[num];
				NamespacedKey<DawnItemInfo> val7 = NamespacedKey<DawnItemInfo>.From("testaccountcore", "scrap" + val6.itemName.ToLower() + num);
				DawnLib.DefineItem(val7, val6, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder)
				{
					builder.DefineScrap((Action<ScrapBuilder>)delegate
					{
					});
				});
			}
			DawnLib.RegisterNetworkPrefab(item.item.spawnPrefab);
			item.connectedNetworkPrefabs.ForEach((Action<GameObject>)DawnLib.RegisterNetworkPrefab);
			item.isRegistered = true;
			TestAccountCore.Logger.LogInfo((object)("Fully registered item " + itemName + "!"));
		}
	}
	public static class ShopItemLoader
	{
		internal static void RegisterAllShopItems(List<ShopItemWithDefaultPrice> itemsWithDefaultPrice, ConfigFile? configFile)
		{
			if (configFile != null)
			{
				itemsWithDefaultPrice.ForEach(delegate(ShopItemWithDefaultPrice item)
				{
					RegisterShopItem(item, configFile);
				});
			}
		}

		private static void RegisterShopItem(ShopItemWithDefaultPrice item, ConfigFile? configFile)
		{
			if (configFile == null)
			{
				return;
			}
			if (item.item == null)
			{
				throw new NullReferenceException("ItemProperties cannot be null!");
			}
			string itemName = item.item.itemName;
			string text = itemName + " - Shop";
			ConfigEntry<bool> val = configFile.Bind<bool>(text, "1. Enabled", true, "If false, " + itemName + " will not be registered. This is different from a spawn weight of 0!");
			if (!val.Value)
			{
				return;
			}
			TestAccountCore.Logger.LogInfo((object)("Registering shop item " + itemName + "..."));
			ConfigEntry<int> price = configFile.Bind<int>(text, "2. Price", item.defaultPrice, "How much " + itemName + " costs to buy!");
			ConfigEntry<bool> val2 = configFile.Bind<bool>(itemName + " - General", "1. Is Conductive", item.item.isConductiveMetal, "If set to true, will make the item conductive. Conductive defines, if the item attracts lightning");
			item.item.isConductiveMetal = val2.Value;
			NamespacedKey<DawnItemInfo> val3 = NamespacedKey<DawnItemInfo>.From("testaccountcore", "shop" + itemName.ToLower());
			DawnLib.DefineItem(val3, item.item, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder itemBuilder)
			{
				itemBuilder.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder builder)
				{
					builder.OverrideCost(price.Value);
				});
			});
			DawnLib.RegisterNetworkPrefab(item.item.spawnPrefab);
			item.connectedNetworkPrefabs.ForEach((Action<GameObject>)DawnLib.RegisterNetworkPrefab);
			item.isRegistered = true;
			TestAccountCore.Logger.LogInfo((object)("Fully registered shop item " + itemName + "!"));
		}
	}
	public static class UnlockableLoader
	{
		internal static void RegisterAllUnlockables(List<UnlockableWithPrice> unlockablesWithPrice, ConfigFile? configFile)
		{
			if (configFile != null)
			{
				unlockablesWithPrice.ForEach(delegate(UnlockableWithPrice unlockable)
				{
					RegisterUnlockable(unlockable, configFile);
				});
			}
		}

		private static void RegisterUnlockable(UnlockableWithPrice unlockable, ConfigFile? configFile)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			if (configFile == null)
			{
				return;
			}
			if (unlockable.unlockableName == null)
			{
				throw new NullReferenceException("Unlockable unlockableName cannot be null!");
			}
			if (unlockable.spawnPrefab == null)
			{
				throw new NullReferenceException("(" + unlockable.unlockableName + ") Spawn Prefab cannot be null!");
			}
			string unlockableName = unlockable.unlockableName;
			string text = unlockableName + " - Unlockable";
			ConfigEntry<bool> val = configFile.Bind<bool>(text, "1. Enabled", true, "If false, " + unlockableName + " will not be registered.");
			if (val.Value)
			{
				TestAccountCore.Logger.LogInfo((object)("Registering unlockable " + unlockableName + "..."));
				ConfigEntry<bool> val2 = configFile.Bind<bool>(text, "2. Always unlocked", false, "If true, " + unlockableName + " will always be unlocked. Otherwise you need to unlock it.");
				ConfigEntry<int> price = configFile.Bind<int>(text, "3. Price", unlockable.price, new ConfigDescription("Price to unlock " + unlockableName + ". Obviously doesn't matter, if 'Always Unlocked' is true.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>()));
				UnlockableItem val3 = new UnlockableItem
				{
					unlockableName = unlockableName,
					alreadyUnlocked = false,
					inStorage = false,
					alwaysInStock = true,
					canBeStored = true,
					IsPlaceable = true,
					maxNumber = 1,
					unlockableType = 1,
					spawnPrefab = true,
					prefabObject = unlockable.spawnPrefab,
					luckValue = unlockable.luckValue
				};
				NamespacedKey<DawnUnlockableItemInfo> val4 = NamespacedKey<DawnUnlockableItemInfo>.From("testaccountcore", "unlockable" + unlockableName.ToLower());
				DawnLib.DefineUnlockable(val4, val3, (Action<UnlockableInfoBuilder>)delegate(UnlockableInfoBuilder unlockableBuilder)
				{
					unlockableBuilder.SetCost(price.Value);
					unlockableBuilder.DefinePlaceableObject((Action<PlaceableObjectBuilder>)delegate
					{
					});
				});
				DawnLib.RegisterNetworkPrefab(unlockable.spawnPrefab);
				if (val2.Value)
				{
					SpawnTheUnlockablesGodDammit.AllUnlockedItems.Add(val3);
				}
				unlockable.isRegistered = true;
				TestAccountCore.Logger.LogInfo((object)("Fully registered unlockable " + unlockableName + "!"));
			}
		}
	}
}
namespace TestAccountCore.KotlinSharp.Extensions
{
	public static class KotlinStyleExtensions
	{
		[CompilerGenerated]
		private static Random <InternalRandom>k__BackingField;

		private static Random InternalRandom => <InternalRandom>k__BackingField ?? (<InternalRandom>k__BackingField = new Random());

		public static T Also<T>(this T self, Action<T> action)
		{
			action(self);
			return self;
		}

		public static T2 Let<T, T2>(this T self, Func<T, T2> action)
		{
			return action(self);
		}

		public static T? TakeIf<T>(this T self, Func<T, bool> predicate)
		{
			if (!predicate(self))
			{
				return default(T);
			}
			return self;
		}

		public static T? TakeUnless<T>(this T self, Func<T, bool> predicate)
		{
			if (!predicate(self))
			{
				return self;
			}
			return default(T);
		}

		public static T Random<T>(this IList<T> array, Random? random = null)
		{
			if (random == null)
			{
				random = InternalRandom;
			}
			return array[random.Next(array.Count)];
		}

		public static bool InRange<T>(this T value, T min, T max) where T : IComparable<T>
		{
			if (value.CompareTo(min) >= 0)
			{
				return value.CompareTo(max) <= 0;
			}
			return false;
		}

		public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
		{
			if (enumerable == null)
			{
				throw new ArgumentNullException("enumerable");
			}
			if (action == null)
			{
				throw new ArgumentNullException("action");
			}
			foreach (T item in enumerable)
			{
				action(item);
			}
		}

		public static bool IsEmpty<T>(this List<T> list)
		{
			return list.Count == 0;
		}

		public static bool IsNotEmpty<T>(this List<T> list)
		{
			return list.Count != 0;
		}
	}
	public static class UsefulExtensions
	{
		public static void Times(this int times, Action action)
		{
			for (int i = 0; i < times; i++)
			{
				action();
			}
		}
	}
}
namespace TestAccountCore.Dependencies
{
	public static class DependencyChecker
	{
		public static bool IsLobbyCompatibilityInstalled()
		{
			return IsInstalled("LobbyCompatibility");
		}

		public static bool IsLethalLibInstalled()
		{
			return IsInstalled("LethalLib");
		}

		public static bool IsDawnLibInstalled()
		{
			return IsInstalled("DawnLib");
		}

		internal static string GetDawnLibVersion()
		{
			return Chainloader.PluginInfos.Values.First((PluginInfo metadata) => metadata.Metadata.GUID.Contains("DawnLib", StringComparison.OrdinalIgnoreCase)).Metadata.Version.ToString();
		}

		private static bool IsInstalled(string id)
		{
			return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Contains(id, StringComparison.OrdinalIgnoreCase));
		}
	}
	public static class LobbyCompatibilitySupport
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void Initialize()
		{
			Initialize("TestAccount666.TestAccountCore", new string("1.19.0".AsSpan()), CompatibilityLevel.ClientOnly, VersionStrictness.Minor);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void Initialize(string pluginGuid, string pluginVersion, CompatibilityLevel compatibilityLevel, VersionStrictness versionStrictness)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			PluginHelper.RegisterPlugin(pluginGuid, new Version(pluginVersion), compatibilityLevel.Convert(), versionStrictness.Convert());
		}
	}
}
namespace TestAccountCore.Dependencies.Compatibility
{
	public enum CompatibilityLevel
	{
		ClientOnly,
		ServerOnly,
		Everyone,
		ClientOptional
	}
	internal static class Converter
	{
		internal static VersionStrictness Convert(this VersionStrictness versionStrictness)
		{
			return (VersionStrictness)versionStrictness;
		}

		internal static CompatibilityLevel Convert(this CompatibilityLevel versionStrictness)
		{
			return (CompatibilityLevel)versionStrictness;
		}
	}
	public enum VersionStrictness
	{
		None,
		Major,
		Minor,
		Patch
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}