Decompiled source of TerrasScrap v1.0.2

TerrasScrap.dll

Decompiled 3 days 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 HarmonyLib;
using LethalLevelLoader;
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("TerrasScrap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A small collection of vanilla styled scrap.")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+e01cea7a61e58729b4695f7a34df66cf1ac416f8")]
[assembly: AssemblyProduct("TerrasScrap")]
[assembly: AssemblyTitle("Terra's Scrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 TerrasScrap
{
	[BepInPlugin("terraformer9x.TerrasScrap", "Terra's Scrap", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private const string pluginGUID = "terraformer9x.TerrasScrap";

		private const string pluginName = "Terra's Scrap";

		private const string pluginVersion = "1.0.2";

		private readonly Harmony harmony = new Harmony("terraformer9x.TerrasScrap");

		public static Plugin Instance;

		private void Awake()
		{
			if (Instance == null)
			{
				Instance = this;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Terra's Scrap 1.0.2  is loaded!");
			harmony.PatchAll(typeof(StartOfRoundPatch));
		}

		public static void Log(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}

		public static void LogError(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogError((object)msg);
		}

		public static void LogDebug(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogDebug((object)msg);
		}
	}
	internal class StartOfRoundPatch
	{
		private static bool executed;

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void StartOfRoundPostfix(ref StartOfRound __instance)
		{
			if (executed)
			{
				return;
			}
			executed = true;
			Dictionary<string, List<ItemGroup>> dictionary = new Dictionary<string, List<ItemGroup>>();
			ItemGroup[] array = Resources.FindObjectsOfTypeAll<ItemGroup>();
			foreach (ItemGroup val in array)
			{
				if (!dictionary.ContainsKey(((Object)val).name))
				{
					List<ItemGroup> value = new List<ItemGroup>(1) { val };
					dictionary.Add(((Object)val).name, value);
				}
				else
				{
					dictionary[((Object)val).name].Add(val);
				}
			}
			List<ExtendedItem> list = PatchedContent.ExtendedItems.Where((ExtendedItem x) => ((ExtendedContent)x).ModName == "Terra's Scrap").ToList();
			Dictionary<string, Item> dictionary2 = new Dictionary<string, Item>();
			foreach (ExtendedItem item in list)
			{
				if ((Object)(object)item.Item != (Object)null && !dictionary2.ContainsKey(((Object)item.Item).name) && !dictionary2.ContainsValue(item.Item))
				{
					dictionary2.Add(((Object)item.Item).name, item.Item);
				}
			}
			dictionary2["TrafficCone"].spawnPositionTypes.AddRange(dictionary["GeneralItemClass"]);
			dictionary2["Tuba"].spawnPositionTypes.AddRange(dictionary["GeneralItemClass"]);
			dictionary2["WineBottle"].spawnPositionTypes.AddRange(dictionary["TabletopItems"]);
			dictionary2["Fan"].spawnPositionTypes.AddRange(dictionary["GeneralItemClass"]);
			dictionary2["Fan"].spawnPositionTypes.AddRange(dictionary["TabletopItems"]);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TerrasScrap";

		public const string PLUGIN_NAME = "TerrasScrap";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}