Decompiled source of OopsAllItems v1.1.0

OopsAllItems.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[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("OopsAllItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OopsAllItems")]
[assembly: AssemblyTitle("OopsAllItems")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OopsAllItems
{
	[BepInPlugin("OopsAllItems", "OopsAllItems", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string DUCK_ITEM_NAME = "Rubber Ducky";

		private static List<SpawnableItemWithRarity> storedScrapList = new List<SpawnableItemWithRarity>();

		private Harmony _harmony = new Harmony("OopsAllItems");

		public static ManualLogSource Logger;

		private void Awake()
		{
			Logger = Logger.CreateLogSource("OopsAllItems");
			Logger.LogInfo((object)"Plugin OopsAllItems is loading.");
			Logger.LogInfo((object)"Loaded OopsAllItems. Patching.");
			_harmony.PatchAll(typeof(Plugin));
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPrefix]
		private static bool OopsAllItems(RoundManager __instance)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			storedScrapList.Clear();
			storedScrapList.AddRange(__instance.currentLevel.spawnableScrap);
			if (!__instance.currentLevel.spawnableScrap.Any((SpawnableItemWithRarity a) => a.spawnableItem.itemName == "Rubber Ducky"))
			{
				foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
				{
					if (items.itemName == "Rubber Ducky")
					{
						SpawnableItemWithRarity val = new SpawnableItemWithRarity();
						val.spawnableItem = items;
						val.rarity = 1;
						__instance.currentLevel.spawnableScrap.Add(val);
					}
				}
			}
			int index = __instance.AnomalyRandom.Next(0, __instance.currentLevel.spawnableScrap.Count);
			SpawnableItemWithRarity item = __instance.currentLevel.spawnableScrap[index];
			__instance.currentLevel.spawnableScrap.Clear();
			__instance.currentLevel.spawnableScrap.Add(item);
			return true;
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPostfix]
		private static void OopsAllItemsReload(RoundManager __instance)
		{
			__instance.currentLevel.spawnableScrap.Clear();
			__instance.currentLevel.spawnableScrap.AddRange(storedScrapList);
			storedScrapList.Clear();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "OopsAllItems";

		public const string PLUGIN_NAME = "OopsAllItems";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}