Decompiled source of OnlyEggs v1.0.1

OnlyEggs.dll

Decompiled 4 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("EggsplosiveDay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds an Eggsplosive day to Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("EggsplosiveDay")]
[assembly: AssemblyTitle("EggsplosiveDay")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.1")]
namespace EggsplosiveDay
{
	[BepInPlugin("EggsplosiveDay", "EggsplosiveDay", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony = new Harmony("EggsplosiveDay");

		public static ManualLogSource Logger;

		public static ConfigEntry<int> Ammount;

		public static ConfigEntry<string> Item;

		public static ConfigEntry<bool> Debug;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			Logger = Logger.CreateLogSource("EggsplosiveDay");
			Logger.LogInfo((object)"        .-\"-.\r\n      .'=^=^='.\r\n     /=^=^=^=^=\\\r\n    :^= Eggs  =^;\r\n    |^   Day   ^|\r\n    :^=^=^=^=^=^:\r\n     \\=^=^=^=^=/\r\n      `.=^=^=.'\r\n        `~~~` \r\nPlugin EggsplosiveDay is loading.");
			Logger.LogInfo((object)"Loaded EggsplosiveDay. Patching.");
			Instance = this;
			Ammount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "chance", 20, "Default: 20\n(1 in 20) chance every day");
			Item = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Item", "Easter egg", "Default: Easter egg");
			Debug = ((BaseUnityPlugin)this).Config.Bind<bool>("DebugMode", "Debug", true, "Default: True");
			_harmony.PatchAll(typeof(Plugin));
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool Roll(ref SelectableLevel newLevel)
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			int num = Random.Range(1, 20);
			if (Debug.Value)
			{
				Logger.LogInfo((object)$"Rolled a {num} for OnlyEggs mod.");
				Logger.LogInfo((object)$"        .-\"-.\r\n      .'=^=^='.\r\n     /=^=^=^=^=\\\r\n    :^= {num} =^;\r\n    |^   Day   ^|\r\n    :^=^=^=^=^=^:\r\n     \\=^=^=^=^=/\r\n      `.=^=^=.'\r\n        `~~~` \r\nPlugin EggsplosiveDay is loading.");
			}
			if (num == 1)
			{
				if (Debug.Value)
				{
					Logger.LogInfo((object)"Roll is 1. Activating egg-only spawn modifications.");
				}
				bool flag = false;
				foreach (SpawnableItemWithRarity item in newLevel.spawnableScrap)
				{
					item.rarity = 0;
					if (item.spawnableItem.itemName == Item.Value)
					{
						item.rarity = 999;
						flag = true;
					}
				}
				if (!flag)
				{
					foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
					{
						if (items.itemName == Item.Value)
						{
							newLevel.spawnableScrap.Add(new SpawnableItemWithRarity
							{
								spawnableItem = items,
								rarity = 999
							});
						}
					}
				}
			}
			else if (Debug.Value)
			{
				Logger.LogInfo((object)"Roll did not meet condition (1). Skipping the modification.");
			}
			return true;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "EggsplosiveDay";

		public const string PLUGIN_NAME = "EggsplosiveDay";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute([In] int obj0)
		{
			Version = obj0;
		}
	}
}