Decompiled source of fiufkis Scrap Beta v2.0.0

fiufkiscrap.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
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("fiufkiscrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("fiufkiscrap")]
[assembly: AssemblyTitle("fiufkiscrap")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 fiufkiscrap
{
	public class fiufkiscrapconfig
	{
		public static ConfigEntry<bool> BookConfig { get; private set; }

		public static ConfigEntry<bool> BottleConfig { get; private set; }

		public static ConfigEntry<bool> CandleConfig { get; private set; }

		public static ConfigEntry<bool> PillowConfig { get; private set; }

		public static ConfigEntry<bool> CardboardBoxConfig { get; private set; }

		public static ConfigEntry<bool> CarTireConfig { get; private set; }

		public static ConfigEntry<bool> MonitorConfig { get; private set; }

		public static ConfigEntry<bool> DespairConfig { get; private set; }

		public static ConfigEntry<bool> VentCoverConfig { get; private set; }

		public static ConfigEntry<bool> KeyboardConfig { get; private set; }

		public static ConfigEntry<bool> MagnetConfig { get; private set; }

		public static ConfigEntry<bool> DeskLampConfig { get; private set; }

		public static ConfigEntry<bool> PottedPlantConfig { get; private set; }

		public fiufkiscrapconfig(ConfigFile configFile)
		{
			BookConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Book", true, "Disable spawning of the Book scrap.");
			BottleConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Bottle", true, "Disable spawning of the Bottle scrap.");
			BottleConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Bottle", true, "Disable spawning of the Bottle scrap.");
			CandleConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Candle", true, "Disable spawning of the Candle scrap.");
			PillowConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Pillow", true, "Disable spawning of the Pillow scrap.");
			CardboardBoxConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Cardboard Box", true, "Disable spawning of the Cardboard Box scrap.");
			CarTireConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Car Tire", true, "Disable spawning of the Car Tire scrap.");
			MonitorConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Monitor", true, "Disable spawning of the Monitor scrap.");
			VentCoverConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Vent Cover", true, "Disable spawning of the Vent Cover scrap.");
			KeyboardConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Keyboard", true, "Disable spawning of the Keyboard scrap.");
			MagnetConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Magnet", true, "Disable spawning of the Magnet scrap.");
			DeskLampConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Desk Lamp", true, "Disable spawning of the Desk Lamp scrap.");
			PottedPlantConfig = configFile.Bind<bool>("Regular Scraps", "Spawn Potted Plant", true, "Disable spawning of the Potted Plant scrap.");
			DespairConfig = configFile.Bind<bool>("Special Scraps", "Spawn Despair", true, "Disable spawning of the Despair scrap.");
			ClearUnusedEntries(configFile);
			plugin.Logger.LogInfo((object)"fiufki's Scrap config is loading.");
		}

		private void ClearUnusedEntries(ConfigFile configFile)
		{
			PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
			dictionary.Clear();
			configFile.Save();
		}
	}
	[BepInPlugin("com.fiufki.fiufkiscrap", "fiufki's Scrap", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.fiufki.fiufkiscrap";

		public const string PluginName = "fiufki's Scrap";

		public const string PluginVersion = "2.0.0";

		internal static ManualLogSource Logger;

		public static fiufkiscrapconfig ModConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			ModConfig = new fiufkiscrapconfig(((BaseUnityPlugin)this).Config);
			AssetBundleLoader.AddOnExtendedModLoadedListener((Action<ExtendedMod>)OnExtendedModRegistered, "fiufki", "fiufki's Scrap");
			AssetBundleLoader.AddOnLethalBundleLoadedListener((Action<AssetBundle>)OnLethalBundleLoaded, "fiufkiscrap.lethalbundle");
			InitializeNetworkBehaviours();
			Logger.LogInfo((object)"fiufki's Scrap is loaded.");
		}

		internal static void OnExtendedModRegistered(ExtendedMod extendedMod)
		{
			if ((Object)(object)extendedMod == (Object)null)
			{
				return;
			}
			foreach (ExtendedItem extendedItem in extendedMod.ExtendedItems)
			{
				if (GetConfigValueForItem(extendedItem.Item.itemName))
				{
					break;
				}
				extendedItem.LevelMatchingProperties = null;
				Logger.LogInfo((object)("Disabled spawning of the " + extendedItem.Item.itemName + " scrap."));
			}
		}

		internal static void OnLethalBundleLoaded(AssetBundle assetBundle)
		{
			if (!((Object)(object)assetBundle == (Object)null))
			{
			}
		}

		private static bool GetConfigValueForItem(string itemName)
		{
			switch (itemName)
			{
			case "Book":
				return fiufkiscrapconfig.BookConfig.Value;
			case "Bottle":
				return fiufkiscrapconfig.BottleConfig.Value;
			case "Candle":
				return fiufkiscrapconfig.CandleConfig.Value;
			case "Pillow":
				return fiufkiscrapconfig.PillowConfig.Value;
			case "Cardboard Box":
				return fiufkiscrapconfig.CardboardBoxConfig.Value;
			case "Car Tire":
				return fiufkiscrapconfig.CarTireConfig.Value;
			case "Monitor":
				return fiufkiscrapconfig.MonitorConfig.Value;
			case "Despair":
				return fiufkiscrapconfig.DespairConfig.Value;
			case "Vent Cover":
				return fiufkiscrapconfig.VentCoverConfig.Value;
			case "Keyboard":
				return fiufkiscrapconfig.KeyboardConfig.Value;
			case "Magnet":
				return fiufkiscrapconfig.MagnetConfig.Value;
			case "Desk Lamp":
				return fiufkiscrapconfig.DeskLampConfig.Value;
			case "Potted Plant":
				return fiufkiscrapconfig.PottedPlantConfig.Value;
			default:
				Logger.LogInfo((object)("No config found for " + itemName));
				return true;
			}
		}

		private void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}