Decompiled source of TestAccountCore v1.12.0

TestAccountCore.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Extras;
using LethalLib.Modules;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using MonoMod.Utils;
using TestAccountCore.Dependencies;
using TestAccountCore.Dependencies.Compatibility;
using TestAccountCore.Loaders;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Serialization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[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.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("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[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.12.0.0")]
[assembly: AssemblyInformationalVersion("1.12.0+9eebeedfc00b2943eddf9820157e92d33aa16961")]
[assembly: AssemblyProduct("TestAccountCore")]
[assembly: AssemblyTitle("TestAccount666.TestAccountCore")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.12.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[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]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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)new StringBuilder("Asset bundle '" + assetBundleName + "' not found at " + text + ".").Append(" ").Append("Check if the asset bundle is in the same directory as the plugin.").ToString());
				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);
			}
		}

		public static void LoadItems(ConfigFile? configFile)
		{
			if (_assets != null && configFile != null)
			{
				ItemWithDefaultWeight[] source = _assets.LoadAllAssets<ItemWithDefaultWeight>();
				IEnumerable<ItemWithDefaultWeight> source2 = source.OfType<ItemWithDefaultWeight>();
				List<ItemWithDefaultWeight> itemsWithDefaultWeight = source2.ToList();
				ScrapLoader.RegisterAllScrap(itemsWithDefaultWeight, configFile);
			}
		}

		public static void LoadHazards(ConfigFile? configFile)
		{
			if (_assets != null && configFile != null)
			{
				MapHazardWithDefaultWeight[] source = _assets.LoadAllAssets<MapHazardWithDefaultWeight>();
				IEnumerable<MapHazardWithDefaultWeight> source2 = source.OfType<MapHazardWithDefaultWeight>();
				List<MapHazardWithDefaultWeight> hazardsWithDefaultWeight = source2.ToList();
				HazardLoader.RegisterAllHazards(hazardsWithDefaultWeight, configFile);
			}
		}

		public static void LoadUnlockables(ConfigFile? configFile)
		{
			if (_assets != null && configFile != null)
			{
				UnlockableWithPrice[] source = _assets.LoadAllAssets<UnlockableWithPrice>();
				IEnumerable<UnlockableWithPrice> source2 = source.OfType<UnlockableWithPrice>();
				List<UnlockableWithPrice> unlockablesWithPrice = source2.ToList();
				UnlockableLoader.RegisterAllUnlockables(unlockablesWithPrice, configFile);
			}
		}

		public static void LoadShopItems(ConfigFile? configFile)
		{
			if (_assets != null && configFile != null)
			{
				ShopItemWithDefaultPrice[] source = _assets.LoadAllAssets<ShopItemWithDefaultPrice>();
				IEnumerable<ShopItemWithDefaultPrice> source2 = source.OfType<ShopItemWithDefaultPrice>();
				List<ShopItemWithDefaultPrice> itemsWithDefaultPrice = source2.ToList();
				ShopItemLoader.RegisterAllShopItems(itemsWithDefaultPrice, configFile);
			}
		}
	}
	public abstract class CustomScript : ScriptableObject
	{
		public abstract void Initialize(ConfigFile? configFile);
	}
	[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>();

		public bool isRegistered;
	}
	public enum LevelTypes
	{
		ALL,
		VANILLA,
		MODDED,
		UNKNOWN
	}
	public static class VanillaLevelMatcher
	{
		public static readonly List<string> VanillaLevels = new List<string>(13)
		{
			"EXPERIMENTATION", "ASSURANCE", "VOW", "GORDION", "MARCH", "ADAMANCE", "REND", "DINE", "OFFENSE", "TITAN",
			"ARTIFICE", "LIQUIDATION", "EMBRION"
		};

		public static bool IsVanilla(string level)
		{
			return VanillaLevels.Contains(level.ToUpper());
		}
	}
	public static class LevelTypeMatcher
	{
		public static LevelTypes FromString(string levelType)
		{
			if ("all".StartsWith(levelType.ToLower()))
			{
				return LevelTypes.ALL;
			}
			if ("vanilla".StartsWith(levelType.ToLower()))
			{
				return LevelTypes.VANILLA;
			}
			return "modded".StartsWith(levelType.ToLower()) ? LevelTypes.MODDED : LevelTypes.UNKNOWN;
		}
	}
	public static class LinqExtensions
	{
		public static bool None<TSource>(this IEnumerable<TSource> source)
		{
			return !source.Any();
		}
	}
	[HarmonyPatch]
	public static class MapHazardRegistry
	{
		public static readonly Dictionary<SpawnableMapObject, Func<SelectableLevel, AnimationCurve>> RegisteredHazards = new Dictionary<SpawnableMapObject, Func<SelectableLevel, AnimationCurve>>();

		public static readonly HashSet<GameObject> HazardPrefabs = new HashSet<GameObject>();

		[HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")]
		[HarmonyPrefix]
		public static void FillRandomMapObjects()
		{
			RandomMapObject[] array = Object.FindObjectsByType<RandomMapObject>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			SpawnableMapObject[] spawnableMapObjects = RoundManager.Instance.currentLevel.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				if (HazardPrefabs.Contains(val.prefabToSpawn))
				{
					RandomMapObject[] array2 = array;
					foreach (RandomMapObject val2 in array2)
					{
						val2.spawnablePrefabs.Add(val.prefabToSpawn);
					}
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		public static void RegisterHazards()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			HazardPrefabs.Clear();
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			SelectableLevel[] array = levels;
			foreach (SelectableLevel val in array)
			{
				SpawnableMapObject[] spawnableMapObjects = val.spawnableMapObjects;
				List<SpawnableMapObject> list = new List<SpawnableMapObject>(spawnableMapObjects.Length);
				list.AddRange(spawnableMapObjects);
				List<SpawnableMapObject> list2 = list;
				foreach (var (val3, func2) in RegisteredHazards)
				{
					HazardPrefabs.Add(val3.prefabToSpawn);
					SpawnableMapObject item = new SpawnableMapObject
					{
						prefabToSpawn = val3.prefabToSpawn,
						spawnFacingWall = val3.spawnFacingWall,
						spawnWithBackToWall = val3.spawnWithBackToWall,
						spawnFacingAwayFromWall = val3.spawnFacingAwayFromWall,
						spawnWithBackFlushAgainstWall = val3.spawnWithBackFlushAgainstWall,
						disallowSpawningNearEntrances = val3.disallowSpawningNearEntrances,
						requireDistanceBetweenSpawns = val3.requireDistanceBetweenSpawns,
						numberToSpawn = func2(val)
					};
					list2.Add(item);
				}
				val.spawnableMapObjects = list2.ToArray();
			}
		}
	}
	[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()
		{
			TestAccountCore.Logger.LogDebug((object)"Starting WaitAndSync");
			yield return (object)new WaitForSeconds(1f);
			TestAccountCore.Logger.LogDebug((object)"After wait");
			SetRendererServerRpc();
			TestAccountCore.Logger.LogDebug((object)"RPC called");
			yield return (object)new WaitForEndOfFrame();
			TestAccountCore.Logger.LogDebug((object)"End of frame");
			if (synced)
			{
				TestAccountCore.Logger.LogDebug((object)"Already synced, breaking out.");
				yield break;
			}
			TestAccountCore.Logger.LogDebug((object)"Not yet synced, retrying...");
			yield return WaitAndSync();
		}
	}
	public static class Netcode
	{
		public static void ExecuteNetcodePatcher(Assembly assembly)
		{
			Type[] types = assembly.GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[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;
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("TestAccount666.TestAccountCore", "TestAccountCore", "1.12.0")]
	public class TestAccountCore : BaseUnityPlugin
	{
		internal static Harmony? harmony;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			if (harmony == null)
			{
				harmony = new Harmony("TestAccount666.TestAccountCore");
			}
			harmony.PatchAll(typeof(MapHazardRegistry));
			if (DependencyChecker.IsLobbyCompatibilityInstalled())
			{
				Logger.LogInfo((object)"Found LobbyCompatibility Mod, initializing support :)");
				LobbyCompatibilitySupport.Initialize();
			}
			Logger.LogInfo((object)"TestAccount666.TestAccountCore v1.12.0 has loaded!");
		}
	}
	public static class UnixTime
	{
		public static long GetCurrentTime()
		{
			return (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
		}
	}
	[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;
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TestAccount666.TestAccountCore";

		public const string PLUGIN_NAME = "TestAccountCore";

		public const string PLUGIN_VERSION = "1.12.0";
	}
}
namespace TestAccountCore.Loaders
{
	public static class HazardLoader
	{
		private static readonly Lazy<Regex> _NumberPattern = new Lazy<Regex>(() => new Regex("\\d* ", RegexOptions.Compiled));

		internal static void RegisterAllHazards(List<MapHazardWithDefaultWeight> hazardsWithDefaultWeight, ConfigFile? configFile)
		{
			ConfigFile configFile2 = configFile;
			if (configFile2 != null)
			{
				hazardsWithDefaultWeight.ForEach(delegate(MapHazardWithDefaultWeight hazard)
				{
					RegisterHazard(hazard, configFile2);
				});
			}
		}

		private static void RegisterHazard(MapHazardWithDefaultWeight hazard, ConfigFile? configFile)
		{
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Expected O, but got Unknown
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Expected O, but got Unknown
			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!");
			}
			ConfigEntry<bool> val = configFile.Bind<bool>(hazard.hazardName ?? "", "1. Enabled", true, "If false, " + hazard.hazardName + " will not be registered.");
			if (!val.Value)
			{
				return;
			}
			TestAccountCore.Logger.LogInfo((object)("Registering hazard " + hazard.hazardName + "..."));
			if (string.IsNullOrWhiteSpace(hazard.spawnCurve))
			{
				TestAccountCore.Logger.LogWarning((object)("Hazard " + hazard.hazardName + " is still using spawn amount! This is no longer supported!"));
				return;
			}
			string text = "Vanilla - " + hazard.spawnCurve + " ; Modded - " + hazard.spawnCurve;
			string text2 = configFile.Bind<string>(hazard.hazardName ?? "", "2. Spawn Curve", text, "The spawn curve for " + hazard.hazardName + ". First number is between 0 and 1. The second one is the max amount.").Value;
			if (!text2.Contains("-"))
			{
				TestAccountCore.Logger.LogWarning((object)("Looks like you didn't specify any moons for " + hazard.hazardName + "! Defaulting to 'All'! A valid example: '" + text + "'"));
				text2 = "All - " + text2;
			}
			text2 = text2.Replace(" ", "");
			Dictionary<string, AnimationCurve> levelSpawnCurveDictionary = new Dictionary<string, AnimationCurve>();
			if (!FillLevelSpawnCurveList(text, text2, levelSpawnCurveDictionary))
			{
				TestAccountCore.Logger.LogWarning((object)("Failed to register hazard " + hazard.hazardName + "!"));
				return;
			}
			AnimationCurve noSpawnAnimationCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, 0f),
				new Keyframe(1f, 0f)
			});
			AnimationCurve allLevelSpawnCurve;
			bool hasAll = levelSpawnCurveDictionary.TryGetValue("ALL", out allLevelSpawnCurve);
			AnimationCurve vanillaLevelSpawnCurve;
			bool hasVanilla = levelSpawnCurveDictionary.TryGetValue("VANILLA", out vanillaLevelSpawnCurve);
			AnimationCurve moddedLevelSpawnCurve;
			bool hasModded = levelSpawnCurveDictionary.TryGetValue("MODDED", out moddedLevelSpawnCurve);
			MapHazardRegistry.RegisteredHazards[new SpawnableMapObject
			{
				prefabToSpawn = hazard.spawnableMapObject,
				spawnFacingWall = hazard.spawnFacingWall,
				spawnWithBackToWall = hazard.spawnWithBackToWall,
				spawnFacingAwayFromWall = hazard.spawnFacingAwayFromWall,
				spawnWithBackFlushAgainstWall = hazard.spawnWithBackFlushAgainstWall,
				disallowSpawningNearEntrances = hazard.disallowSpawningNearEntrances,
				requireDistanceBetweenSpawns = hazard.requireDistanceBetweenSpawns
			}] = delegate(SelectableLevel level)
			{
				string text3 = _NumberPattern.Value.Replace(level.PlanetName, "").ToLower();
				AnimationCurve val2 = noSpawnAnimationCurve;
				if (hasAll)
				{
					val2 = allLevelSpawnCurve;
				}
				bool flag = VanillaLevelMatcher.IsVanilla(text3);
				if (hasVanilla && flag)
				{
					val2 = vanillaLevelSpawnCurve;
				}
				if (hasModded && !flag)
				{
					val2 = moddedLevelSpawnCurve;
				}
				foreach (var (text5, val4) in levelSpawnCurveDictionary)
				{
					if (text3.StartsWith(text5.ToLower()))
					{
						val2 = val4;
						break;
					}
				}
				if (val2 == null)
				{
					val2 = noSpawnAnimationCurve;
				}
				return val2;
			};
			NetworkPrefabs.RegisterNetworkPrefab(hazard.spawnableMapObject);
			hazard.isRegistered = true;
			TestAccountCore.Logger.LogInfo((object)("Fully registered hazard " + hazard.hazardName + "!"));
		}

		private static bool FillLevelSpawnCurveList(string defaultCurve, string spawnCurveString, Dictionary<string, AnimationCurve> levelSpawnCurveDictionary)
		{
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			string[] array = spawnCurveString.Split(";", StringSplitOptions.RemoveEmptyEntries);
			if (array.Length < 1)
			{
				try
				{
					throw new InvalidDataException("'" + spawnCurveString + "' is invalid! Valid Example: '" + defaultCurve + "'");
				}
				catch (Exception ex)
				{
					TestAccountCore.Logger.LogError((object)("Map Hazard spawn curve is not correctly configured: " + ex.Message));
					Extensions.LogDetailed(ex, (string)null);
					return false;
				}
			}
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split("-", StringSplitOptions.RemoveEmptyEntries);
				if (array3.Length <= 1)
				{
					try
					{
						throw new InvalidDataException("'" + spawnCurveString + "' is invalid! Point: " + text);
					}
					catch (Exception ex2)
					{
						TestAccountCore.Logger.LogError((object)("Map Hazard spawn curve is not correctly configured: " + ex2.Message));
						Extensions.LogDetailed(ex2, (string)null);
						return false;
					}
				}
				string text2 = array3[0];
				string spawnCurveString2 = array3[1];
				List<Keyframe> list = new List<Keyframe>();
				if (!ReadSpawnCurveString(spawnCurveString2, list))
				{
					return false;
				}
				LevelTypes levelTypes = LevelTypeMatcher.FromString(text2);
				if (1 == 0)
				{
				}
				string text3 = levelTypes switch
				{
					LevelTypes.ALL => "ALL", 
					LevelTypes.VANILLA => "VANILLA", 
					LevelTypes.MODDED => "MODDED", 
					_ => text2, 
				};
				if (1 == 0)
				{
				}
				text2 = text3;
				AnimationCurve value = new AnimationCurve(list.ToArray());
				levelSpawnCurveDictionary[text2] = value;
			}
			return true;
		}

		private static bool ReadSpawnCurveString(string spawnCurveString, List<Keyframe> keyFrames)
		{
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			string[] array = spawnCurveString.Split(",", StringSplitOptions.RemoveEmptyEntries);
			foreach (string text in array)
			{
				string[] array2 = text.Split(':', StringSplitOptions.RemoveEmptyEntries);
				if (array2.Length <= 1)
				{
					try
					{
						throw new InvalidDataException("'" + spawnCurveString + "' is invalid! Point: " + text);
					}
					catch (Exception ex)
					{
						TestAccountCore.Logger.LogError((object)("Map Hazard spawn curve is not correctly configured: " + ex.Message));
						Extensions.LogDetailed(ex, (string)null);
						return false;
					}
				}
				if (!float.TryParse(array2[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					try
					{
						throw new InvalidDataException("'" + spawnCurveString + "' is invalid! Point: " + text + " (Could not parse time '" + array2[0] + "' as float)");
					}
					catch (Exception ex2)
					{
						TestAccountCore.Logger.LogError((object)("Map Hazard spawn curve is not correctly configured: " + ex2.Message));
						Extensions.LogDetailed(ex2, (string)null);
						return false;
					}
				}
				if (!int.TryParse(array2[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2))
				{
					try
					{
						throw new InvalidDataException("'" + spawnCurveString + "' is invalid! Point: " + text + " (Could not parse amount '" + array2[1] + "' as int)");
					}
					catch (Exception ex3)
					{
						TestAccountCore.Logger.LogError((object)("Map Hazard spawn curve is not correctly configured: " + ex3.Message));
						Extensions.LogDetailed(ex3, (string)null);
						return false;
					}
				}
				keyFrames.Add(new Keyframe(result, (float)result2));
			}
			return true;
		}
	}
	public static class ScrapLoader
	{
		internal static void RegisterAllScrap(List<ItemWithDefaultWeight> itemsWithDefaultWeight, ConfigFile? configFile)
		{
			ConfigFile configFile2 = configFile;
			if (configFile2 != null)
			{
				itemsWithDefaultWeight.ForEach(delegate(ItemWithDefaultWeight item)
				{
					RegisterScrap(item, configFile2);
				});
			}
		}

		private static void RegisterScrap(ItemWithDefaultWeight item, ConfigFile? configFile)
		{
			if (configFile == null)
			{
				return;
			}
			if (item.item == null)
			{
				throw new NullReferenceException("ItemProperties cannot be null!");
			}
			ConfigEntry<bool> val = configFile.Bind<bool>(item.item.itemName ?? "", "1. Enabled", true, "If false, " + item.item.itemName + " will not be registered. This is different from a spawn weight of 0!");
			if (!val.Value)
			{
				return;
			}
			TestAccountCore.Logger.LogInfo((object)("Registering item " + item.item.itemName + "..."));
			ConfigEntry<int> val2 = configFile.Bind<int>(item.item.itemName ?? "", "2. Maximum Value", item.item.maxValue, "Defines the maximum scrap value for " + item.item.itemName + ".");
			ConfigEntry<int> val3 = configFile.Bind<int>(item.item.itemName ?? "", "3. Minimum Value", item.item.minValue, "Defines the minimum scrap value for " + item.item.itemName + ".");
			ConfigEntry<string> val4 = configFile.Bind<string>(item.item.itemName ?? "", "4. Moon Spawn Weight", $"Vanilla:{item.defaultWeight}, Modded:{item.defaultWeight}", $"Defines the spawn weight per moon. e.g. Assurance:{item.defaultWeight}");
			item.item.maxValue = val2.Value;
			item.item.minValue = val3.Value;
			ConfigEntry<bool> val5 = configFile.Bind<bool>(item.item.itemName ?? "", "5. Is Conductive", item.item.isConductiveMetal, "If set to true, will make the item conductive. Conductive defines, if the item attracts lightning");
			item.item.isConductiveMetal = val5.Value;
			(Dictionary<LevelTypes, int>, Dictionary<string, int>) tuple = val4.Value.ParseConfig(item.item.itemName);
			foreach (GameObject connectedNetworkPrefab in item.connectedNetworkPrefabs)
			{
				NetworkPrefabs.RegisterNetworkPrefab(connectedNetworkPrefab);
			}
			NetworkPrefabs.RegisterNetworkPrefab(item.item.spawnPrefab);
			Items.RegisterScrap(item.item, tuple.Item1, tuple.Item2);
			item.isRegistered = true;
			TestAccountCore.Logger.LogInfo((object)("Fully registered item " + item.item.itemName + "!"));
		}

		private static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ParseConfig(this string configMoonRarity, string itemName)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from configEntry in configMoonRarity.Split(',')
				select configEntry.Trim())
			{
				if (string.IsNullOrWhiteSpace(item))
				{
					continue;
				}
				string[] array = item.Split(':');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (int.TryParse(array[1], out var result))
				{
					if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
					{
						dictionary[result2] = result;
						TestAccountCore.Logger.LogInfo((object)$"Registered {itemName}'s weight for level type {result2} to {result}");
					}
					else
					{
						dictionary2[text] = result;
						TestAccountCore.Logger.LogInfo((object)$"Registered {itemName}'s weight for custom level type {text} to {result}");
					}
				}
			}
			return (dictionary, dictionary2);
		}
	}
	public static class ShopItemLoader
	{
		internal static void RegisterAllShopItems(List<ShopItemWithDefaultPrice> itemsWithDefaultPrice, ConfigFile? configFile)
		{
			ConfigFile configFile2 = configFile;
			if (configFile2 != null)
			{
				itemsWithDefaultPrice.ForEach(delegate(ShopItemWithDefaultPrice item)
				{
					RegisterShopItem(item, configFile2);
				});
			}
		}

		private static void RegisterShopItem(ShopItemWithDefaultPrice item, ConfigFile? configFile)
		{
			if (configFile == null)
			{
				return;
			}
			if (item.item == null)
			{
				throw new NullReferenceException("ItemProperties cannot be null!");
			}
			ConfigEntry<bool> val = configFile.Bind<bool>(item.item.itemName ?? "", "1. Enabled", true, "If false, " + item.item.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 " + item.item.itemName + "..."));
			ConfigEntry<int> val2 = configFile.Bind<int>(item.item.itemName ?? "", "2. Price", item.defaultPrice, "How much " + item.item.itemName + " costs to buy!");
			ConfigEntry<bool> val3 = configFile.Bind<bool>(item.item.itemName ?? "", "3. Is Conductive", item.item.isConductiveMetal, "If set to true, will make the item conductive. Conductive defines, if the item attracts lightning");
			item.item.isConductiveMetal = val3.Value;
			foreach (GameObject connectedNetworkPrefab in item.connectedNetworkPrefabs)
			{
				NetworkPrefabs.RegisterNetworkPrefab(connectedNetworkPrefab);
			}
			NetworkPrefabs.RegisterNetworkPrefab(item.item.spawnPrefab);
			Items.RegisterShopItem(item.item, val2.Value);
			item.isRegistered = true;
			TestAccountCore.Logger.LogInfo((object)("Fully registered shop item " + item.item.itemName + "!"));
		}
	}
	public static class UnlockableLoader
	{
		internal static void RegisterAllUnlockables(List<UnlockableWithPrice> unlockablesWithPrice, ConfigFile? configFile)
		{
			ConfigFile configFile2 = configFile;
			if (configFile2 != null)
			{
				unlockablesWithPrice.ForEach(delegate(UnlockableWithPrice unlockable)
				{
					RegisterUnlockable(unlockable, configFile2);
				});
			}
		}

		private static void RegisterUnlockable(UnlockableWithPrice unlockable, ConfigFile? configFile)
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			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!");
			}
			ConfigEntry<bool> val = configFile.Bind<bool>(unlockable.unlockableName ?? "", "1. Enabled", true, "If false, " + unlockable.unlockableName + " will not be registered.");
			if (val.Value)
			{
				TestAccountCore.Logger.LogInfo((object)("Registering unlockable " + unlockable.unlockableName + "..."));
				ConfigEntry<bool> val2 = configFile.Bind<bool>(unlockable.unlockableName ?? "", "2. Always unlocked", false, "If true, " + unlockable.unlockableName + " will always be unlocked. Otherwise you need to unlock it.");
				ConfigEntry<int> val3 = configFile.Bind<int>(unlockable.unlockableName ?? "", "3. Price", unlockable.price, new ConfigDescription("Price to unlock " + unlockable.unlockableName + ". Obviously doesn't matter, if 'Always Unlocked' is true.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>()));
				ScriptableObject obj = ScriptableObject.CreateInstance(typeof(UnlockableItemDef));
				UnlockableItemDef val4 = (UnlockableItemDef)(object)((obj is UnlockableItemDef) ? obj : null);
				if (val4 == null)
				{
					throw new NullReferenceException("(" + unlockable.unlockableName + ") Could not create unlockable item!");
				}
				val4.storeType = unlockable.storeType;
				val4.unlockable = new UnlockableItem
				{
					unlockableName = unlockable.unlockableName,
					alreadyUnlocked = val2.Value,
					inStorage = false,
					alwaysInStock = true,
					canBeStored = true,
					maxNumber = 1,
					unlockableType = 1,
					hasBeenUnlockedByPlayer = val2.Value,
					spawnPrefab = true,
					prefabObject = unlockable.spawnPrefab,
					luckValue = unlockable.luckValue
				};
				Unlockables.RegisterUnlockable(val4, val3.Value, unlockable.storeType);
				NetworkPrefabs.RegisterNetworkPrefab(unlockable.spawnPrefab);
				unlockable.isRegistered = true;
				TestAccountCore.Logger.LogInfo((object)("Fully registered unlockable " + unlockable.unlockableName + "!"));
			}
		}
	}
}
namespace TestAccountCore.Dependencies
{
	public static class DependencyChecker
	{
		public static bool IsLobbyCompatibilityInstalled()
		{
			return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Contains("LobbyCompatibility"));
		}
	}
	public static class LobbyCompatibilitySupport
	{
		internal static void Initialize()
		{
			Initialize("TestAccount666.TestAccountCore", new string("1.12.0"), CompatibilityLevel.ClientOnly, VersionStrictness.Minor);
		}

		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)
		{
		}
	}
}