Decompiled source of DevTools v1.0.1

DevTools.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[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("DevTools")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0583f826b06037719a051b7f3c93ffe95d6ceab3")]
[assembly: AssemblyProduct("DevTools")]
[assembly: AssemblyTitle("DevTools")]
[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 DevTools
{
	[BepInPlugin("com.valheimmods.devtools", "Dev Tools", "1.0.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		private static class TerminalInitPatch
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static ConsoleEvent <0>__SpawnSixtyItems;
			}

			private static bool _registered;

			private static void Postfix()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Expected O, but got Unknown
				if (!_registered)
				{
					object obj = <>O.<0>__SpawnSixtyItems;
					if (obj == null)
					{
						ConsoleEvent val = SpawnSixtyItems;
						<>O.<0>__SpawnSixtyItems = val;
						obj = (object)val;
					}
					new ConsoleCommand("spawn60", "Spawns one each of 60 different materials", (ConsoleEvent)obj, true, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
					_registered = true;
				}
			}

			private static void SpawnSixtyItems(ConsoleEventArgs args)
			{
				string[] itemPrefabs = ItemPrefabs;
				foreach (string text in itemPrefabs)
				{
					args.Context.TryRunCommand("spawn " + text + " 1", false, false);
				}
				args.Context.AddString("Spawned 60 different items near your character.");
			}
		}

		private const string PluginId = "com.valheimmods.devtools";

		private static readonly string[] ItemPrefabs = new string[60]
		{
			"Wood", "Stone", "Flint", "Resin", "LeatherScraps", "DeerHide", "Feathers", "Dandelion", "Honey", "BoneFragments",
			"GreydwarfEye", "FineWood", "RoundLog", "ElderBark", "Bronze", "Copper", "Tin", "Iron", "Silver", "BlackMetal",
			"Flametal", "YggdrasilWood", "Blackwood", "BlackMarble", "Grausten", "Coal", "SurtlingCore", "AncientSeed", "HardAntler", "DragonTear",
			"Crystal", "Obsidian", "FreezeGland", "WolfPelt", "WolfFang", "TrollHide", "Chitin", "SerpentScale", "Bloodbag", "Entrails",
			"Ooze", "Guck", "Root", "Tar", "LoxPelt", "Needle", "Barley", "Flax", "LinenThread", "IronNails",
			"BronzeNails", "Carapace", "Eitr", "Sap", "ScaleHide", "GemstoneBlue", "GemstoneGreen", "GemstoneRed", "Thunderstone", "Wisp"
		};

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_harmony = new Harmony("com.valheimmods.devtools");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Dev Tools loaded: spawn60 console command available.");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}