Decompiled source of DeezNuts v1.0.0

DeezNuts.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DeezNuts.Patch;
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: AssemblyCompany("DeezNuts")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DeezNuts")]
[assembly: AssemblyTitle("DeezNuts")]
[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 DeezNuts
{
	[BepInPlugin("com.fakemarsh.DeezNuts", "DeezNuts", "1.0.0")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony harmony = new Harmony("DeezNuts");

		public static ManualLogSource logger;

		public static GameObject deez_nuts_button;

		public static Item deez_nuts_item;

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			logger.LogInfo((object)"Plugin DeezNuts is loaded!");
			LoadButton();
			harmony.PatchAll(typeof(DeezPatches));
			harmony.PatchAll(typeof(NetworkPatches));
		}

		private void LoadButton()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "deeznuts");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			GameObject val2 = val.LoadAsset<GameObject>("Assets/DeezNuts/DeezNuts.prefab");
			deez_nuts_button = val2;
			deez_nuts_item = val.LoadAsset<Item>("Assets/DeezNuts/DeezNuts.asset");
			logger.LogInfo((object)("custom scrap item loaded into network: " + deez_nuts_item.itemName));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DeezNuts";

		public const string PLUGIN_NAME = "DeezNuts";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DeezNuts.Patch
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class DeezPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("Awake")]
		public static void DeezNutsButtonPatch(StartOfRound __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Plugin.logger.LogInfo((object)"inside button patch");
			SelectableLevel[] levels = __instance.levels;
			SelectableLevel[] array = levels;
			foreach (SelectableLevel val in array)
			{
				SpawnableItemWithRarity val2 = new SpawnableItemWithRarity();
				val2.spawnableItem = Plugin.deez_nuts_item;
				val2.rarity = 35;
				Plugin.logger.LogInfo((object)("Adding deez nuts button into moon " + ((Object)val).name));
				val.spawnableScrap.Add(val2);
				Plugin.logger.LogInfo((object)"\n\n");
			}
			if (!__instance.allItemsList.itemsList.Contains(Plugin.deez_nuts_item))
			{
				__instance.allItemsList.itemsList.Add(Plugin.deez_nuts_item);
			}
		}
	}
	internal class NetworkPatches
	{
		private static GameObject networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init(GameNetworkManager __instance)
		{
			Plugin.logger.LogInfo((object)"inside deez nuts network patcher");
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				Plugin.logger.LogInfo((object)"we are adding the deez nuts button to the network!");
				networkPrefab = Plugin.deez_nuts_button;
				((Component)__instance).GetComponent<NetworkManager>().PrefabHandler.AddNetworkPrefab(networkPrefab);
			}
		}
	}
}