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 KeepUnlocks v1.0.5
KeepUnlocks.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KeepUnlocks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Saves certain unlockables when the run resets. Configurable to keep suits, furniture, and/or ship upgrades.")] [assembly: AssemblyFileVersion("1.0.5.0")] [assembly: AssemblyInformationalVersion("1.0.5+0a6be0120f0d53a6d166bbb53c175e7a77e269bf")] [assembly: AssemblyProduct("KeepUnlocks")] [assembly: AssemblyTitle("KeepUnlocks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace KeepUnlocks { internal class KeepThis { private static List<int> unlocks = new List<int>(); internal static void FindItemsToKeep() { unlocks.Clear(); for (int i = 0; i < StartOfRound.Instance.unlockablesList.unlockables.Count; i++) { if (StartOfRound.Instance.unlockablesList.unlockables[i].hasBeenUnlockedByPlayer) { KeepThisItem(i); } } } private static void KeepThisItem(int id) { if (unlocks.Contains(id)) { return; } UnlockableItem val = StartOfRound.Instance.unlockablesList.unlockables[id]; if (val.unlockableType == 0) { if (Plugin.configKeepSuits.Value) { unlocks.Add(id); } } else if (IsShipUpgrade(val)) { if (Plugin.configKeepUpgrades.Value) { unlocks.Add(id); } } else if (Plugin.configKeepFurniture.Value) { unlocks.Add(id); } } internal static IEnumerator RepopulateShipWithUnlocks() { int num = TimeOfDay.Instance.quotaVariables.startingCredits; Terminal val = Object.FindAnyObjectByType<Terminal>(); if ((Object)(object)val != (Object)null) { num = val.groupCredits; } foreach (int unlock in unlocks) { StartOfRound.Instance.BuyShipUnlockableServerRpc(unlock, num); } if (!Plugin.configAutoStore.Value) { yield break; } yield return (object)new WaitForSeconds(2f); PlaceableShipObject[] array = Object.FindObjectsByType<PlaceableShipObject>((FindObjectsSortMode)0); foreach (PlaceableShipObject val2 in array) { if (unlocks.Contains(val2.unlockableID) && StartOfRound.Instance.unlockablesList.unlockables[val2.unlockableID].canBeStored && !IsShipUpgrade(StartOfRound.Instance.unlockablesList.unlockables[val2.unlockableID])) { if (!StartOfRound.Instance.unlockablesList.unlockables[val2.unlockableID].spawnPrefab) { val2.parentObject.disableObject = true; Debug.Log((object)"DISABLE OBJECT F"); } ShipBuildModeManager.Instance.StoreObjectServerRpc(NetworkObjectReference.op_Implicit(((Component)val2.parentObject).GetComponent<NetworkObject>()), (int)GameNetworkManager.Instance.localPlayerController.playerClientId); } } } private static bool IsShipUpgrade(UnlockableItem item) { if (!(item.unlockableName == "Teleporter") && !(item.unlockableName == "Signal translator") && !(item.unlockableName == "Loud horn") && !(item.unlockableName == "Inverse Teleporter")) { return item.unlockableName == "Bodycam"; } return true; } } internal static class LobbyCompatibility { internal static void Init() { PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.keepunlocks", Version.Parse("1.0.5"), (CompatibilityLevel)1, (VersionStrictness)0); } } [BepInPlugin("butterystancakes.lethalcompany.keepunlocks", "Keep Unlocks", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.keepunlocks"; internal const string PLUGIN_NAME = "Keep Unlocks"; internal const string PLUGIN_VERSION = "1.0.5"; public static ConfigEntry<bool> configKeepSuits; public static ConfigEntry<bool> configKeepFurniture; public static ConfigEntry<bool> configKeepUpgrades; public static ConfigEntry<bool> configAutoStore; private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility"; private void Awake() { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility")) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected"); LobbyCompatibility.Init(); } configKeepSuits = ((BaseUnityPlugin)this).Config.Bind<bool>("Cosmetic", "KeepSuits", true, "Retain player suits? (Green suit, Hazard suit, Pajama suit, Purple Suit, Bee Suit, Bunny Suit)"); configKeepFurniture = ((BaseUnityPlugin)this).Config.Bind<bool>("Cosmetic", "KeepFurniture", false, "Retain misc. furniture? (Television, Shower, etc.)"); configKeepUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "KeepUpgrades", false, "Retain ship upgrades? (Loud horn, Signal translator, Teleporter, Inverse Teleporter)"); configAutoStore = ((BaseUnityPlugin)this).Config.Bind<bool>("Miscellaneous", "AutoStore", true, "Automatically place furniture into storage."); ((BaseUnityPlugin)this).Config.Bind<bool>("Experimental", "AutoStore", false, "Legacy setting, moved to \"Miscellaneous\" section"); ((BaseUnityPlugin)this).Config.Remove(((BaseUnityPlugin)this).Config["Experimental", "AutoStore"].Definition); ((BaseUnityPlugin)this).Config.Save(); new Harmony("butterystancakes.lethalcompany.keepunlocks").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Keep Unlocks v1.0.5 loaded"); } } public static class PluginInfo { public const string PLUGIN_GUID = "KeepUnlocks"; public const string PLUGIN_NAME = "KeepUnlocks"; public const string PLUGIN_VERSION = "1.0.5"; } } namespace KeepUnlocks.Patches { [HarmonyPatch] internal class KeepUnlocksPatches { [HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")] [HarmonyPrefix] private static void PreResetSavedGameValues(GameNetworkManager __instance) { if (__instance.isHostingGame && !StartOfRound.Instance.isChallengeFile) { KeepThis.FindItemsToKeep(); } } [HarmonyPatch(typeof(StartOfRound), "ResetShip")] [HarmonyPostfix] private static void PostResetShip(StartOfRound __instance) { if (((NetworkBehaviour)__instance).IsServer && !__instance.isChallengeFile) { ((MonoBehaviour)__instance).StartCoroutine(KeepThis.RepopulateShipWithUnlocks()); } } } }