Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TestAccountCore v1.18.0
TestAccountCore.dll
Decompiled a week agousing 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 Dawn; using DunGen; 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.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("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.18.0.0")] [assembly: AssemblyInformationalVersion("1.18.0+63c060ea112fe072a804c7ff245318a34d384de0")] [assembly: AssemblyProduct("TestAccountCore")] [assembly: AssemblyTitle("TestAccount666.TestAccountCore")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.18.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) { LoadItemsAndReturn(configFile); } public static List<ItemWithDefaultWeight> LoadItemsAndReturn(ConfigFile? configFile) { if (_assets == null || configFile == null) { return new List<ItemWithDefaultWeight>(); } ItemWithDefaultWeight[] source = _assets.LoadAllAssets<ItemWithDefaultWeight>(); IEnumerable<ItemWithDefaultWeight> source2 = source.OfType<ItemWithDefaultWeight>(); List<ItemWithDefaultWeight> list = source2.ToList(); ScrapLoader.RegisterAllScrap(list, configFile); return list; } public static void LoadHazards(ConfigFile? configFile) { LoadHazardsAndReturn(configFile); } public static List<MapHazardWithDefaultWeight> LoadHazardsAndReturn(ConfigFile? configFile) { if (_assets == null || configFile == null) { return new List<MapHazardWithDefaultWeight>(); } MapHazardWithDefaultWeight[] source = _assets.LoadAllAssets<MapHazardWithDefaultWeight>(); IEnumerable<MapHazardWithDefaultWeight> source2 = source.OfType<MapHazardWithDefaultWeight>(); List<MapHazardWithDefaultWeight> list = source2.ToList(); HazardLoader.RegisterAllHazards(list, configFile); return list; } public static void LoadUnlockables(ConfigFile? configFile) { LoadUnlockablesAndReturn(configFile); } public static List<UnlockableWithPrice> LoadUnlockablesAndReturn(ConfigFile? configFile) { if (_assets == null || configFile == null) { return new List<UnlockableWithPrice>(); } UnlockableWithPrice[] source = _assets.LoadAllAssets<UnlockableWithPrice>(); IEnumerable<UnlockableWithPrice> source2 = source.OfType<UnlockableWithPrice>(); List<UnlockableWithPrice> list = source2.ToList(); UnlockableLoader.RegisterAllUnlockables(list, configFile); return list; } public static void LoadShopItems(ConfigFile? configFile) { LoadShopItemsAndReturn(configFile); } public static List<ShopItemWithDefaultPrice> LoadShopItemsAndReturn(ConfigFile? configFile) { if (_assets == null || configFile == null) { return new List<ShopItemWithDefaultPrice>(); } ShopItemWithDefaultPrice[] source = _assets.LoadAllAssets<ShopItemWithDefaultPrice>(); IEnumerable<ShopItemWithDefaultPrice> source2 = source.OfType<ShopItemWithDefaultPrice>(); List<ShopItemWithDefaultPrice> list = source2.ToList(); ShopItemLoader.RegisterAllShopItems(list, configFile); return list; } public static void LoadEnemies(ConfigFile? configFile) { LoadEnemiesAndReturn(configFile); } public static List<EnemyWithDefaultWeight> LoadEnemiesAndReturn(ConfigFile? configFile) { if (_assets == null || configFile == null) { return new List<EnemyWithDefaultWeight>(); } EnemyWithDefaultWeight[] source = _assets.LoadAllAssets<EnemyWithDefaultWeight>(); IEnumerable<EnemyWithDefaultWeight> source2 = source.OfType<EnemyWithDefaultWeight>(); List<EnemyWithDefaultWeight> list = source2.ToList(); EnemyLoader.RegisterAllEnemies(list, configFile); return list; } public static void LoadHallwayHazards(ConfigFile? configFile) { LoadHallwayHazardsAndReturn(configFile); } public static List<HallwayHazardWithDefaultWeight> LoadHallwayHazardsAndReturn(ConfigFile? configFile) { if (_assets == null || configFile == null) { return new List<HallwayHazardWithDefaultWeight>(); } HallwayHazardWithDefaultWeight[] source = _assets.LoadAllAssets<HallwayHazardWithDefaultWeight>(); IEnumerable<HallwayHazardWithDefaultWeight> source2 = source.OfType<HallwayHazardWithDefaultWeight>(); List<HallwayHazardWithDefaultWeight> list = source2.ToList(); HallwayHazardLoader.RegisterAllHazards(list, configFile); return list; } public static void UnloadBundle(bool unloadAllLoadedObjects = false) { AssetBundle? assets = _assets; if (assets != null) { assets.Unload(unloadAllLoadedObjects); } } } public static class ConfigParser { public static Dictionary<string, int> ParseConfig(this string configMoonRarity, string itemName) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); configMoonRarity = configMoonRarity.ToLower().Replace("modded:", "custom:"); 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) { string text = array[0]; if (!int.TryParse(array[1], out var result)) { TestAccountCore.Logger.LogWarning((object)("Invalid spawn weight for " + text + ": " + item)); continue; } dictionary[text] = result; TestAccountCore.Logger.LogInfo((object)$"Registered {itemName}'s weight for custom level type {text} to {result}"); } } return dictionary; } } 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 = null; [SerializeField] [Tooltip("The terminal keyword.")] [Space(10f)] public TerminalKeyword keyWord = null; [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 readonly struct RegisteredHazard { public HallwayHazardWithDefaultWeight Hazard { get; } public Dictionary<string, int> SpawnWeights { get; } public RegisteredHazard(HallwayHazardWithDefaultWeight hazard, Dictionary<string, int> spawnWeights) { Hazard = hazard; SpawnWeights = spawnWeights; } public int GetWeight(string level) { NamespacedKey val = NamespacedKey.ForceParse(level, true); if (!(val is NamespacedKey<DawnMoonInfo> val2)) { TestAccountCore.Logger.LogWarning((object)$"(Hazard: {Hazard.hazardName}) Couldn't find weight for key {val}! Is it a moon?"); return -1; } int num = -1; foreach (var (text2, num3) in SpawnWeights) { if (level.ToLower().Contains(text2)) { return num3; } switch (text2) { case "custom": if (!((NamespacedKey)val2).IsModded()) { continue; } break; case "modded": if (!((NamespacedKey)val2).IsModded()) { continue; } break; case "vanilla": if (!((NamespacedKey)val2).IsVanilla()) { continue; } break; case "all": break; default: continue; } num = num3; } if (num != -1) { return num; } TestAccountCore.Logger.LogWarning((object)$"(Hazard: {Hazard.hazardName}) Couldn't find weight for key {val2}!"); return 0; } } private static readonly List<RegisteredHazard> _REGISTERED_HAZARDS = new List<RegisteredHazard>(); public static void RegisterHazard(HallwayHazardWithDefaultWeight hazard, Dictionary<string, int> spawnWeights) { _REGISTERED_HAZARDS.Add(new RegisteredHazard(hazard, spawnWeights)); } [HarmonyPatch] [HarmonyPrefix] public static void InjectHazards(Doorway a, Doorway b) { AddHazardsForDoorway(a, 0.05f); AddHazardsForDoorway(b, 0.07f); } private static void AddHazardsForDoorway(Doorway doorway, float multiplier) { if ((Object)(object)doorway == (Object)null || doorway.ConnectorPrefabWeights == null) { return; } List<GameObjectWeight> connectorPrefabWeights = doorway.ConnectorPrefabWeights; int matchCount = connectorPrefabWeights.Count((GameObjectWeight weight) => (Object)(object)weight?.GameObject != (Object)null && ((Object)weight.GameObject).name == "BigDoorSpawn"); TestAccountCore.Logger.LogDebug((object)$"Hazard injection: {matchCount} matches, {_REGISTERED_HAZARDS.Count} hazards"); if (matchCount != 0) { List<GameObjectWeight> list = new List<GameObjectWeight>(matchCount * _REGISTERED_HAZARDS.Count); list.AddRange(from <>h__TransparentIdentifier0 in _REGISTERED_HAZARDS.Select(delegate(RegisteredHazard hazard) { RegisteredHazard registeredHazard = hazard; return new { hazard = hazard, weight = registeredHazard.GetWeight(RoundManager.Instance.currentLevel.PlanetName) }; }) from repeat in Enumerable.Repeat<GameObjectWeight>(new GameObjectWeight { Weight = multiplier * (float)<>h__TransparentIdentifier0.weight, GameObject = <>h__TransparentIdentifier0.hazard.Hazard.spawnHazardPrefab }, matchCount) select repeat); connectorPrefabWeights.AddRange(list); } } } [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 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; } if ("modded".StartsWith(levelType.ToLower())) { return LevelTypes.MODDED; } return "custom".StartsWith(levelType.ToLower()) ? LevelTypes.MODDED : LevelTypes.UNKNOWN; } } 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 { [CompilerGenerated] private sealed class <WaitAndSync>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MaterialVariants <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitAndSync>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; TestAccountCore.Logger.LogDebug((object)"Starting WaitAndSync"); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; TestAccountCore.Logger.LogDebug((object)"After wait"); <>4__this.SetRendererServerRpc(); TestAccountCore.Logger.LogDebug((object)"RPC called"); <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 2; return true; case 2: <>1__state = -1; TestAccountCore.Logger.LogDebug((object)"End of frame"); if (<>4__this.synced) { TestAccountCore.Logger.LogDebug((object)"Already synced, breaking out."); return false; } TestAccountCore.Logger.LogDebug((object)"Not yet synced, retrying..."); <>2__current = <>4__this.WaitAndSync(); <>1__state = 3; return true; case 3: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [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]; } } } [IteratorStateMachine(typeof(<WaitAndSync>d__10))] private IEnumerator WaitAndSync() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitAndSync>d__10(0) { <>4__this = this }; } } 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 List<UnlockableItem> AllUnlockedItems = new List<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.18.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"); } try { harmony.PatchAll(typeof(VersionChecker)); } catch (Exception ex) { Logger.LogError((object)"Failed to patch VersionChecker!"); Extensions.LogDetailed(ex, (string)null); } if (DependencyChecker.IsDawnLibInstalled()) { 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.18.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; } [HarmonyPatch(typeof(MenuManager))] public static class VersionChecker { [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public MenuManager manager; internal bool <WaitForVersionToExist>b__0() { TextMeshProUGUI versionNumberText = manager.versionNumberText; return versionNumberText != null && ((TMP_Text)versionNumberText).text != null; } } [CompilerGenerated] private sealed class <WaitForVersionToExist>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MenuManager manager; private <>c__DisplayClass1_0 <>8__1; private string <version>5__2; private string <split>5__3; private int <versionNumber>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForVersionToExist>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <version>5__2 = null; <split>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass1_0(); <>8__1.manager = manager; <>2__current = (object)new WaitUntil((Func<bool>)delegate { TextMeshProUGUI versionNumberText = <>8__1.manager.versionNumberText; return versionNumberText != null && ((TMP_Text)versionNumberText).text != null; }); <>1__state = 1; return true; case 1: <>1__state = -1; <version>5__2 = ((TMP_Text)<>8__1.manager.versionNumberText).text; if (Utility.IsNullOrWhiteSpace(<version>5__2)) { TestAccountCore.Logger.LogError((object)"Failed to check version! Version String null?!"); return false; } <split>5__3 = <version>5__2.Split(' ').First(); if (<split>5__3.StartsWith("v", StringComparison.InvariantCultureIgnoreCase)) { string text = <split>5__3; <split>5__3 = text.Substring(1, text.Length - 1); } if (!int.TryParse(<split>5__3, out <versionNumber>5__4)) { TestAccountCore.Logger.LogError((object)("Failed to check version! Couldn't parse '" + <version>5__2 + "' (" + <split>5__3 + ") to int!")); return false; } if (<versionNumber>5__4 < 80) { TestAccountCore.Logger.LogWarning((object)"TestAccountCore requires version v80 or higher! Please update Lethal Company!"); return false; } TestAccountCore.Logger.LogInfo((object)$"TestAccountCore is running on version v{<versionNumber>5__4}!"); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPatch("Start")] [HarmonyPostfix] public static void CheckVersion(MenuManager __instance) { try { ((MonoBehaviour)__instance).StartCoroutine(WaitForVersionToExist(__instance)); } catch (Exception ex) { TestAccountCore.Logger.LogError((object)"Failed to check version!"); Extensions.LogDetailed(ex, (string)null); } } [IteratorStateMachine(typeof(<WaitForVersionToExist>d__1))] public static IEnumerator WaitForVersionToExist(MenuManager manager) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForVersionToExist>d__1(0) { manager = manager }; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TestAccount666.TestAccountCore"; public const string PLUGIN_NAME = "TestAccountCore"; public const string PLUGIN_VERSION = "1.18.0"; } } namespace TestAccountCore.Loaders { public static class EnemyLoader { internal static void RegisterAllEnemies(List<EnemyWithDefaultWeight> enemiesWithDefaultWeight, ConfigFile? configFile) { ConfigFile configFile2 = configFile; if (configFile2 != null) { enemiesWithDefaultWeight.ForEach(delegate(EnemyWithDefaultWeight enemy) { RegisterEnemy(enemy, configFile2); }); } } private static void RegisterEnemy(EnemyWithDefaultWeight enemy, ConfigFile? configFile) { EnemyWithDefaultWeight enemy2 = enemy; if (configFile == null) { return; } if (enemy2.enemyType == null) { throw new NullReferenceException("EnemyType cannot be null!"); } string enemyName = enemy2.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> val2 = configFile.Bind<string>(text, "2. Moon Spawn Weight", $"Vanilla:{enemy2.defaultWeight}, Modded:{enemy2.defaultWeight}", $"Defines the spawn weight per moon. e.g. Assurance:{enemy2.defaultWeight}"); Dictionary<string, int> spawnRateByCustomLevelType = val2.Value.ParseConfig(enemyName); NamespacedKey<DawnEnemyInfo> val3 = NamespacedKey<DawnEnemyInfo>.From("testaccountcore", "enemy" + enemyName.ToLower()); DawnLib.DefineEnemy(val3, enemy2.enemyType, (Action<EnemyInfoBuilder>)delegate(EnemyInfoBuilder enemyBuilder) { enemyBuilder.CreateBestiaryNode(enemy2.infoNode.displayText).CreateNameKeyword(enemy2.keyWord.word); enemyBuilder.DefineInside((Action<EnemyLocationBuilder>)delegate(EnemyLocationBuilder insideBuilder) { insideBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)SetWeights); }); }); DawnLib.RegisterNetworkPrefab(enemy2.enemyType.enemyPrefab); enemy2.connectedNetworkPrefabs.ForEach((Action<GameObject>)DawnLib.RegisterNetworkPrefab); enemy2.isRegistered = true; TestAccountCore.Logger.LogInfo((object)("Fully registered enemy " + enemyName + "!")); void SetWeights(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder) { foreach (var (text3, num2) in spawnRateByCustomLevelType) { if (text3 != null) { if (text3.Equals("all")) { weightBuilder.SetGlobalWeight(num2); } else { NamespacedKey val4 = NamespacedKey.ForceParse(text3, true); if (val4 == null) { TestAccountCore.Logger.LogError((object)("Could not parse key " + text3 + " for enemy " + enemyName)); } else if (!(val4 is NamespacedKey<DawnMoonInfo> val5)) { weightBuilder.AddTagWeight(val4, num2); } else { weightBuilder.AddWeight(val5, num2); } } } } weightBuilder.Build(); } } } public static class HallwayHazardLoader { internal static void RegisterAllHazards(List<HallwayHazardWithDefaultWeight> hazardsWithDefaultWeight, ConfigFile? configFile) { ConfigFile configFile2 = configFile; if (configFile2 != null) { hazardsWithDefaultWeight.ForEach(delegate(HallwayHazardWithDefaultWeight item) { RegisterHazard(item, configFile2); }); } } private static void RegisterHazard(HallwayHazardWithDefaultWeight hazard, ConfigFile? configFile) { if (configFile == null) { return; } if (hazard.hazardName == null) { TestAccountCore.Logger.LogError((object)$"Hallway Hazard name cannot be null! ({hazard})"); return; } if (hazard.hazardPrefab == null) { TestAccountCore.Logger.LogError((object)("Hallway Hazard " + hazard.hazardName + " has no prefab!")); return; } if (hazard.spawnHazardPrefab == null) { TestAccountCore.Logger.LogError((object)("Hallway Hazard " + hazard.hazardName + " has no spawn prefab!")); return; } string text = hazard.hazardName + " - Hallway Hazard"; ConfigEntry<bool> val = configFile.Bind<bool>(text, "1. Enabled", true, "If false, " + hazard.hazardName + " will not be registered. This is different from a spawn weight of 0!"); if (val.Value) { TestAccountCore.Logger.LogInfo((object)("Registering hallway hazard " + hazard.hazardName + "...")); ConfigEntry<string> val2 = configFile.Bind<string>(text, "2. Moon Spawn Weight", $"Vanilla:{hazard.defaultWeight}, Modded:{hazard.defaultWeight}", $"Defines the spawn weight per moon. e.g. Assurance:{hazard.defaultWeight}"); Dictionary<string, int> spawnWeights = val2.Value.ParseConfig(hazard.hazardName); DawnLib.RegisterNetworkPrefab(hazard.hazardPrefab); HallwayHazardRegistry.RegisterHazard(hazard, spawnWeights); hazard.isRegistered = true; TestAccountCore.Logger.LogInfo((object)("Fully registered hallway hazard " + hazard.hazardName + "!")); } } } 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) { MapHazardWithDefaultWeight hazard2 = hazard; if (configFile == null) { return; } if (hazard2.hazardName == null) { throw new NullReferenceException("Map Hazard name cannot be null!"); } if (hazard2.spawnableMapObject == null) { throw new NullReferenceException("(" + hazard2.hazardName + ") Map Hazard cannot be null!"); } string text = hazard2.hazardName + " - Hazard"; ConfigEntry<bool> val = configFile.Bind<bool>(text, "1. Enabled", true, "If false, " + hazard2.hazardName + " will not be registered."); if (!val.Value) { return; } TestAccountCore.Logger.LogInfo((object)("Registering hazard " + hazard2.hazardName + "...")); if (string.IsNullOrWhiteSpace(hazard2.spawnCurve)) { TestAccountCore.Logger.LogWarning((object)("Hazard " + hazard2.hazardName + " is still using spawn amount! This is no longer supported!")); return; } string text2 = "Vanilla - " + hazard2.spawnCurve + " ; Modded - " + hazard2.spawnCurve; string value = configFile.Bind<string>(text, "2. Spawn Curve", text2, "The spawn curve for " + hazard2.hazardName + ". First number is between 0 and 1. The second one is the max amount.").Value; value = value.ToUpper().Replace("MODDED:", "CUSTOM:"); if (!value.Contains("-")) { TestAccountCore.Logger.LogWarning((object)("Looks like you didn't specify any moons for " + hazard2.hazardName + "! Defaulting to 'All'! A valid example: '" + text2 + "'")); value = "All - " + value; } value = value.Replace(" ", ""); Dictionary<string, AnimationCurve> levelSpawnCurveDictionary = new Dictionary<string, AnimationCurve>(); if (!FillLevelSpawnCurveList(text2, value, levelSpawnCurveDictionary)) { TestAccountCore.Logger.LogWarning((object)("Failed to register hazard " + hazard2.hazardName + "!")); return; } NamespacedKey<DawnMapObjectInfo> val2 = NamespacedKey<DawnMapObjectInfo>.From("testaccountcore", "hazard" + hazard2.hazardName.ToLower()); DawnLib.DefineMapObject(val2, hazard2.spawnableMapObject, (Action<MapObjectInfoBuilder>)delegate(MapObjectInfoBuilder infoBuilder) { infoBuilder.DefineInside((Action<InsideBuilder>)delegate(InsideBuilder insideBuilder) { insideBuilder.OverrideDisallowSpawningNearEntrances(hazard2.disallowSpawningNearEntrances); insideBuilder.OverrideRequireDistanceBetweenSpawns(hazard2.requireDistanceBetweenSpawns); insideBuilder.OverrideSpawnFacingAwayFromWall(hazard2.spawnFacingAwayFromWall); insideBuilder.OverrideSpawnFacingWall(hazard2.spawnFacingWall); insideBuilder.OverrideSpawnWithBackFlushAgainstWall(hazard2.spawnWithBackFlushAgainstWall); insideBuilder.OverrideSpawnWithBackToWall(hazard2.spawnWithBackToWall); insideBuilder.SetWeights((Action<CurveTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(CurveTableBuilder<DawnMoonInfo, SpawnWeightContext> curveBuilder) { foreach (var (text4, val4) in levelSpawnCurveDictionary) { if (text4 != null) { if (text4.Equals("ALL")) { curveBuilder.SetGlobalCurve(val4); } else { NamespacedKey val5 = NamespacedKey.ForceParse(text4, true); if (val5 == null) { TestAccountCore.Logger.LogError((object)("Could not parse key " + text4 + " for hazard " + hazard2.hazardName)); } else if (!(val5 is NamespacedKey<DawnMoonInfo> val6)) { curveBuilder.AddTagCurve(val5, val4); } else { curveBuilder.AddCurve(val6, val4); } } } } }); }); }); DawnLib.RegisterNetworkPrefab(hazard2.spawnableMapObject); hazard2.isRegistered = true; TestAccountCore.Logger.LogInfo((object)("Fully registered hazard " + hazard2.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 => "CUSTOM", _ => 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!"); } 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> val4 = configFile.Bind<string>(text, "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>(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 = val5.Value; Dictionary<string, int> spawnRateByCustomLevelType = val4.Value.ParseConfig(itemName); NamespacedKey<DawnItemInfo> val6 = NamespacedKey<DawnItemInfo>.From("testaccountcore", "scrap" + itemName.ToLower()); DawnLib.DefineItem(val6, item.item, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder builder) { builder.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrapBuilder) { scrapBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)SetWeights); }); }); for (int i = 0; i < item.alternativeItems.Count; i++) { Item val7 = item.alternativeItems[i]; NamespacedKey<DawnItemInfo> val8 = NamespacedKey<DawnItemInfo>.From("testaccountcore", "scrap" + val7.itemName.ToLower() + i); DawnLib.DefineItem(val8, val7, (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 + "!")); void SetWeights(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weightBuilder) { foreach (var (text3, num2) in spawnRateByCustomLevelType) { if (text3 != null) { if (text3.Equals("all")) { weightBuilder.SetGlobalWeight(num2); } else { NamespacedKey val9 = NamespacedKey.ForceParse(text3, true); if (val9 == null) { TestAccountCore.Logger.LogError((object)("Could not parse key " + text3 + " for scrap " + itemName)); } else if (!(val9 is NamespacedKey<DawnMoonInfo> val10)) { weightBuilder.AddTagWeight(val9, num2); } else { weightBuilder.AddWeight(val10, num2); } } } } weightBuilder.Build(); } } } 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!"); } string text = item.item.itemName + " - Shop"; ConfigEntry<bool> val = configFile.Bind<bool>(text, "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> price = configFile.Bind<int>(text, "2. Price", item.defaultPrice, "How much " + item.item.itemName + " costs to buy!"); ConfigEntry<bool> val2 = configFile.Bind<bool>(item.item.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" + item.item.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 " + 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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 text = unlockable.unlockableName + " - Unlockable"; ConfigEntry<bool> val = configFile.Bind<bool>(text, "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>(text, "2. Always unlocked", false, "If true, " + unlockable.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 " + unlockable.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 = unlockable.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" + 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 " + unlockable.unlockableName + "!")); } } } } namespace TestAccountCore.KotlinSharp.Extensions { public static class KotlinStyleExtensions { 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) { return (T?)(predicate(self) ? ((object)self) : ((object)default(T))); } public static T? TakeUnless<T>(this T self, Func<T, bool> predicate) { return (T?)(predicate(self) ? ((object)default(T)) : ((object)self)); } public static T Random<T>(this IList<T> array, Random? random = null) { if (random == null) { random = new Random(); } return array[random.Next(array.Count)]; } public static bool InRange<T>(this T value, T min, T max) where T : IComparable<T> { return value.CompareTo(min) >= 0 && value.CompareTo(max) <= 0; } 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 Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Contains("LobbyCompatibility")); } public static bool IsLethalLibInstalled() { return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.ToLowerInvariant().Contains("lethallib")); } public static bool IsDawnLibInstalled() { return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.ToLowerInvariant().Contains("dawnlib")); } } public static class LobbyCompatibilitySupport { internal static void Initialize() { Initialize("TestAccount666.TestAccountCore", new string("1.18.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) { } } }