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 NoSeveredScrap v1.0.1
BepInEx/plugins/NoSeveredScrap.dll
Decompiled 7 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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("NoSeveredScrap")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NoSeveredScrap")] [assembly: AssemblyTitle("NoSeveredScrap")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 NoSeveredScrap { [BepInPlugin("NoSeveredScrap", "NoSeveredScrap", "1.0.1")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static readonly HashSet<string> Blocked = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Severed Hand", "Severed Foot", "Severed Heart", "Severed Ear", "Severed Tongue", "Severed Thigh", "Severed Bone", "Severed Bone Rib" }; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("NoSeveredScrap").PatchAll(); Log.LogInfo((object)"NoSeveredScrap carregado."); } internal static bool IsBlocked(SpawnableItemWithRarity s) { if ((Object)(object)s?.spawnableItem != (Object)null) { return Blocked.Contains(s.spawnableItem.itemName.Trim()); } return false; } internal static void Filter(SelectableLevel level) { if (level?.spawnableScrap != null && level.spawnableScrap.Any(IsBlocked)) { List<SpawnableItemWithRarity> list = level.spawnableScrap.Where((SpawnableItemWithRarity s) => !IsBlocked(s)).ToList(); if (list.Count == 0) { list = FallbackScrap(); } if (list.Count != 0) { int val = level.spawnableScrap.Count - list.Count; level.spawnableScrap = list; Log.LogInfo((object)$"{level.PlanetName}: itens de corpo removidos ({Math.Max(val, 0)})."); } } } private static List<SpawnableItemWithRarity> FallbackScrap() { List<Item> list = StartOfRound.Instance?.allItemsList?.itemsList; if (list == null) { return new List<SpawnableItemWithRarity>(); } return list.Where((Item i) => (Object)(object)i != (Object)null && i.isScrap && !Blocked.Contains(i.itemName.Trim())).Select((Func<Item, SpawnableItemWithRarity>)((Item i) => new SpawnableItemWithRarity(i, 10))).ToList(); } } [HarmonyPatch(typeof(StartOfRound), "Start")] internal static class StartOfRoundPatch { private static void Postfix(StartOfRound __instance) { if (__instance.levels != null) { SelectableLevel[] levels = __instance.levels; for (int i = 0; i < levels.Length; i++) { Plugin.Filter(levels[i]); } } } } [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] internal static class SpawnScrapPatch { private static void Prefix(RoundManager __instance) { SelectableLevel currentLevel = __instance.currentLevel; if (currentLevel?.spawnableScrap != null && currentLevel.spawnableScrap.Any(Plugin.IsBlocked)) { int increasedScrapSpawnRateIndex = __instance.increasedScrapSpawnRateIndex; SpawnableItemWithRarity val = ((increasedScrapSpawnRateIndex >= 0 && increasedScrapSpawnRateIndex < currentLevel.spawnableScrap.Count) ? currentLevel.spawnableScrap[increasedScrapSpawnRateIndex] : null); Plugin.Filter(currentLevel); __instance.increasedScrapSpawnRateIndex = ((val == null) ? (-1) : currentLevel.spawnableScrap.IndexOf(val)); } } } }