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 SafeSoloScrap v2.1.0
SafeSoloScrap.dll
Decompiled a day 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; [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("SafeSoloScrap")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Lets you keep some scrap on the ship after dying in singleplayer, for a more casual solo-friendly experience.")] [assembly: AssemblyFileVersion("2.1.0.0")] [assembly: AssemblyInformationalVersion("2.1.0+9642e8b8e06de591b759cc86a2e9fa3a10c82d9d")] [assembly: AssemblyProduct("SafeSoloScrap")] [assembly: AssemblyTitle("SafeSoloScrap")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SafeSoloScrap { internal static class LobbyCompatibility { internal static void Init() { PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.safesoloscrap", Version.Parse("2.1.0"), (CompatibilityLevel)1, (VersionStrictness)0); } } [BepInPlugin("butterystancakes.lethalcompany.safesoloscrap", "Safe Solo Scrap", "2.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.safesoloscrap"; internal const string PLUGIN_NAME = "Safe Solo Scrap"; internal const string PLUGIN_VERSION = "2.1.0"; public static ConfigEntry<int> configMaxPlayers; private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility"; internal static ManualLogSource Logger; private void Awake() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility")) { Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected"); LobbyCompatibility.Init(); } configMaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "MaxPlayers", 1, new ConfigDescription("How many players are allowed in the lobby before vanilla death penalty takes over?", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), Array.Empty<object>())); ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "KeepTwoHanded", false, "Legacy setting, doesn't work"); ((BaseUnityPlugin)this).Config.Remove(((BaseUnityPlugin)this).Config["Gameplay", "KeepTwoHanded"].Definition); ((BaseUnityPlugin)this).Config.Save(); new Harmony("butterystancakes.lethalcompany.safesoloscrap").PatchAll(); Logger.LogInfo((object)"Safe Solo Scrap v2.1.0 loaded"); } } public static class ScrapSafe { private static readonly string[] drillPieces = new string[1] { "LungApparatus" }; public static bool IsItemLost(GrabbableObject grabObj) { if (grabObj.itemProperties.isScrap) { if (StartOfRound.Instance.connectedPlayersAmount <= Plugin.configMaxPlayers.Value - 1) { return !grabObj.scrapPersistedThroughRounds; } return true; } return false; } } public static class PluginInfo { public const string PLUGIN_GUID = "SafeSoloScrap"; public const string PLUGIN_NAME = "SafeSoloScrap"; public const string PLUGIN_VERSION = "2.1.0"; } } namespace SafeSoloScrap.Patches { [HarmonyPatch] internal class SafeSoloScrapPatches { [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> RoundManager_Trans_DespawnPropsAtEndOfRound(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = instructions.ToList(); FieldInfo fieldInfo = AccessTools.Field(typeof(Item), "isScrap"); for (int i = 2; i < list.Count; i++) { if (list[i].opcode == OpCodes.Brfalse && list[i - 1].opcode == OpCodes.Ldfld && (FieldInfo)list[i - 1].operand == fieldInfo) { list[i - 1].opcode = OpCodes.Call; list[i - 1].operand = AccessTools.Method(typeof(ScrapSafe), "IsItemLost", (Type[])null, (Type[])null); list.RemoveAt(i - 2); Plugin.Logger.LogDebug((object)"Transpiler (Penalty): Redirect scrap check to custom function"); return list; } } Plugin.Logger.LogError((object)"Penalty transpiler failed"); return list; } } }