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 KeySpawnConfig v1.0.0
Tomatobird.KeySpawnConfig.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Tomatobird.KeySpawnConfig")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ce2a1079511f2cc56594cc3d8732604613ef3d03")] [assembly: AssemblyProduct("KeySpawnConfig")] [assembly: AssemblyTitle("Tomatobird.KeySpawnConfig")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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 KeySpawnConfig { [BepInPlugin("Tomatobird.KeySpawnConfig", "KeySpawnConfig", "1.0.0")] public class KeySpawnConfig : BaseUnityPlugin { public static int keyAmount; public static int keysPerDoor; public static bool editKeyPrefab; public static bool keyIsScrap; public static bool keyIsConductiveMetal; public static int keyValue; public static float keyWeight; public static KeySpawnConfig Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Instance = this; keyAmount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Key Amount", -1, "Key spawn loop count override. (Always spawn this many keys.) Negative values skip this config.").Value; keysPerDoor = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Keys Per Door", -1, "How many keys should spawn per door? Does nothing if key spawn loop count is overridden. Negative values skip this config.").Value; editKeyPrefab = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Edit Key Prefab", false, "Should the Key Item Properties configuration be ?").Value; keyIsScrap = ((BaseUnityPlugin)this).Config.Bind<bool>("KeyItemProperties", "Scrap", false, "Is scrap that can be sold for profit.").Value; keyIsConductiveMetal = ((BaseUnityPlugin)this).Config.Bind<bool>("KeyItemProperties", "Conductive", true, "Conducts lightning.").Value; keyValue = ((BaseUnityPlugin)this).Config.Bind<int>("KeyItemProperties", "Value", 3, "Value of the key. Only does anything if key is a scrap item, unless you have a mod that can use the value anyway.").Value; keyWeight = ((BaseUnityPlugin)this).Config.Bind<float>("KeyItemProperties", "Weight", 1f, new ConfigDescription("How heavy should the key be? This is a multiplier to the player's current weight. For example, Large Axle weight is 1.15.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 999f), Array.Empty<object>())).Value; if (keyAmount > -1 || keysPerDoor > -1 || editKeyPrefab) { Patch(); } Logger.LogInfo((object)"Tomatobird.KeySpawnConfig v1.0.0 has loaded!"); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("Tomatobird.KeySpawnConfig"); } Logger.LogDebug((object)"Patching with RoundManagerPatch"); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Tomatobird.KeySpawnConfig"; public const string PLUGIN_NAME = "KeySpawnConfig"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace KeySpawnConfig.Patches { [HarmonyPatch(typeof(RoundManager))] public class RoundManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void EditKeyPrefab() { if (!KeySpawnConfig.editKeyPrefab) { return; } KeyItem component = RoundManager.Instance.keyPrefab.GetComponent<KeyItem>(); if ((Object)(object)component == (Object)null) { KeySpawnConfig.Logger.LogError((object)"Could not find KeyItem in RoundManager.Instance.keyPrefab. Key prefab configuration will not be applied."); return; } ((GrabbableObject)component).scrapValue = KeySpawnConfig.keyValue; ScanNodeProperties componentInChildren = ((Component)((Component)component).transform).GetComponentInChildren<ScanNodeProperties>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.subText = $"Value ${KeySpawnConfig.keyValue}"; } Item itemProperties = ((GrabbableObject)component).itemProperties; itemProperties.isScrap = KeySpawnConfig.keyIsScrap; itemProperties.isConductiveMetal = KeySpawnConfig.keyIsConductiveMetal; itemProperties.weight = KeySpawnConfig.keyWeight; } [HarmonyPatch("SetLockedDoors")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> SetLockedDoorsTranspiler(IEnumerable<CodeInstruction> instructions) { KeySpawnConfig.Logger.LogDebug((object)"Running SetLockedDoorsTranspiler"); int num = -1; List<CodeInstruction> list = new List<CodeInstruction>(instructions); if (KeySpawnConfig.keysPerDoor == 0 || KeySpawnConfig.keysPerDoor > 1) { for (int i = 80; i < list.Count; i++) { if (list[i - 2].opcode == OpCodes.Ldloc_3 && list[i - 1].opcode == OpCodes.Ldc_I4_1 && list[i].opcode == OpCodes.Add) { num = i - 1; break; } } if (num > -1) { list[num].opcode = OpCodes.Ldc_I4_S; list[num].operand = (sbyte)KeySpawnConfig.keysPerDoor; KeySpawnConfig.Logger.LogDebug((object)$"Correct codeinstructions were found and ldc.i4.1 was replaced with ldc.i4.s {KeySpawnConfig.keysPerDoor}."); } else { KeySpawnConfig.Logger.LogError((object)"ldloc.3 -> ldc.i4.1 -> add in RoundManager.SetLockedDoors not found. Did the game get updated?"); } } num = -1; if (KeySpawnConfig.keyAmount > -1) { for (int j = list.Count - 10; j < list.Count; j++) { if (list[j - 2].opcode == OpCodes.Ldloc_S && list[j - 1].opcode == OpCodes.Ldloc_3 && list[j].opcode == OpCodes.Blt) { num = j - 1; break; } } if (num > -1) { list[num].opcode = OpCodes.Ldc_I4_S; list[num].operand = (sbyte)KeySpawnConfig.keyAmount; KeySpawnConfig.Logger.LogDebug((object)$"Correct codeinstructions were found and ldloc_3 was replaced with ldc.i4.s {KeySpawnConfig.keyAmount}."); } else { KeySpawnConfig.Logger.LogError((object)"ldloc.s -> ldloc.3 -> blt.s in RoundManager.SetLockedDoors not found. Did the game get updated?"); } } return list.AsEnumerable(); } } }