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 ScrapMerging v1.0.4
ScrapMerging.dll
Decompiled 2 years agousing System; 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.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; 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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: AssemblyCompany("ScrapMerging")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.5.1.0")] [assembly: AssemblyInformationalVersion("1.5.1")] [assembly: AssemblyProduct("ScrapMerging")] [assembly: AssemblyTitle("ScrapMerging")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.1.0")] [module: UnverifiableCode] 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; } } } namespace ScrapMerging { [BepInPlugin("GiGaGon.ScrapMerging", "ScrapMerging", "1.0.4")] public class ScrapMerging : BaseUnityPlugin { public const string PluginGUID = "GiGaGon.ScrapMerging"; public const string PluginAuthor = "GiGaGon"; public const string PluginName = "ScrapMerging"; public const string PluginVersion = "1.0.4"; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown SharedComponents.ConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ScrapMerging.cfg"), true); SharedComponents.MergeDistance = SharedComponents.ConfigFile.Bind<float>("General", "Merge Distance", 1f, "Maximum distance at which scrap will merge."); SharedComponents.MergeInShip = SharedComponents.ConfigFile.Bind<bool>("General", "Merge In Ship", true, "If true, scrap will merge when dropped in the ship."); SharedComponents.MergeInFactory = SharedComponents.ConfigFile.Bind<bool>("General", "Merge In Factory", false, "If true, scrap will merge when dropped in the factory/mansion. Recommended to keep false for balance."); SharedComponents.MergeInOutdoors = SharedComponents.ConfigFile.Bind<bool>("General", "Merge In Outsides", false, "If true, scrap will merge when dropped outside the ship/factory/mansion. Recommended to keep false for balance."); SharedComponents.MergeOnlyAtCompany = SharedComponents.ConfigFile.Bind<bool>("General", "Merge Only At Company", false, "If true, scrap will only merge when at the company building."); SharedComponents.MergeScrapWeights = SharedComponents.ConfigFile.Bind<bool>("General", "Merge Scrap Weight", false, "If true, scrap weight will be merged in addition to value."); SharedComponents.ScrapPrefabs = new Dictionary<string, GrabbableObject>(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } } public static class SharedComponents { public static Dictionary<string, GrabbableObject> ScrapPrefabs { get; set; } public static ConfigFile ConfigFile { get; set; } public static ConfigEntry<float> MergeDistance { get; set; } public static ConfigEntry<bool> MergeInShip { get; set; } public static ConfigEntry<bool> MergeInFactory { get; set; } public static ConfigEntry<bool> MergeInOutdoors { get; set; } public static ConfigEntry<bool> MergeOnlyAtCompany { get; set; } public static ConfigEntry<bool> MergeScrapWeights { get; set; } public static string SanitizeString(string input) { return Regex.Replace(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(input.Replace("(Clone)", "")), "[^\\w]", "").Trim(); } } public static class PluginInfo { public const string PLUGIN_GUID = "ScrapMerging"; public const string PLUGIN_NAME = "ScrapMerging"; public const string PLUGIN_VERSION = "1.5.1"; } } namespace ScrapMerging.Patches { [HarmonyPatch(typeof(GrabbableObject))] public class GrabbableObjectPatches { [HarmonyPatch("OnHitGround")] [HarmonyPostfix] public static void MergeScrap(GrabbableObject __instance) { GrabbableObject __instance2 = __instance; if (!NetworkManager.Singleton.IsServer || __instance2 == null || !__instance2.itemProperties.isScrap || __instance2.isPocketed) { return; } SharedComponents.ConfigFile.Reload(); ConfigEntry<bool> val = default(ConfigEntry<bool>); if ((!SharedComponents.MergeInShip.Value && __instance2.isInShipRoom) || (!SharedComponents.MergeInFactory.Value && __instance2.isInFactory) || (!SharedComponents.MergeInOutdoors.Value && !__instance2.isInShipRoom && !__instance2.isInFactory) || !SharedComponents.ConfigFile.TryGetEntry<bool>("Enables", SharedComponents.SanitizeString(((Object)__instance2).name), ref val) || !val.Value || (SharedComponents.MergeOnlyAtCompany.Value && StartOfRound.Instance.currentLevel.sceneName != "CompanyBuilding")) { return; } GrabbableObject[] array = (from x in Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0) where x != null && !x.isPocketed && x.itemProperties.isScrap && x.isInShipRoom == __instance2.isInShipRoom && x.isInFactory == __instance2.isInFactory && ((Object)x).name == ((Object)__instance2).name select x).ToArray(); if (array.Length < 2) { return; } GrabbableObject[] array2 = array.Where((GrabbableObject x) => Vector3.Distance(((Component)x).transform.position, ((Component)__instance2).transform.position) < SharedComponents.MergeDistance.Value).ToArray(); if (array2.Length >= 2) { __instance2.SetScrapValue(array2.Select((GrabbableObject x) => x.scrapValue).Sum()); CollectionExtensions.Do<GrabbableObject>(array2.Where((GrabbableObject x) => ((Object)x).GetInstanceID() != ((Object)__instance2).GetInstanceID()), (Action<GrabbableObject>)delegate(GrabbableObject x) { ((NetworkBehaviour)x).NetworkObject.Despawn(true); }); } } } [HarmonyPatch(typeof(MenuManager))] public class MenuManagerPatches { public static string[] defaultFalseList = new string[8] { "DiyFlashbang", "GiftBox", "StopSign", "YieldSign", "RagdollGrabbableObject", "ShotgunItem", "Cat", "Laserpointer" }; [HarmonyPatch("Start")] [HarmonyPostfix] public static void GenerateConfig(MenuManager __instance) { if (SharedComponents.ConfigFile == null) { return; } SharedComponents.ConfigFile.Reload(); IEnumerable<GrabbableObject> enumerable = from GrabbableObject x in Resources.FindObjectsOfTypeAll(typeof(GrabbableObject)) where (Object)(object)x != (Object)null && (Object)(object)x.itemProperties != (Object)null && ((Object)x).name != null && x.itemProperties.isScrap select x; foreach (GrabbableObject item in enumerable) { SharedComponents.ScrapPrefabs.TryAdd(SharedComponents.SanitizeString(((Object)item).name), item); } foreach (GrabbableObject value in SharedComponents.ScrapPrefabs.Values) { SharedComponents.ConfigFile.Bind<bool>("Enables", SharedComponents.SanitizeString(((Object)value).name), !defaultFalseList.Contains(((Object)value).name), "If true, " + SharedComponents.SanitizeString(((Object)value).name) + "s will be merged."); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }