Decompiled source of PovRtdPortalOre v1.1.0

PovRtdPortalOre.dll

Decompiled 2 weeks 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 Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.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 OblitusEs.PovRtdPortalOre
{
	[BepInPlugin("OblitusEs.PovRtdPortalOre", "PovRtdPortalOre", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "OblitusEs.PovRtdPortalOre";

		public const string Name = "PovRtdPortalOre";

		public const string Version = "1.1.0";

		private const string PortalOreType = "PassiveTree.Conveniences+PortalOre";

		private static readonly string[][] Bosses = new string[8][]
		{
			new string[3] { "Eikthyr", "defeated_eikthyr", "" },
			new string[3] { "The Elder", "defeated_gdking", "Item_GoldOre_RtD, Item_CelestialBronzeBar_RtD" },
			new string[3] { "Bonemass", "defeated_bonemass", "Item_BrightsteelBar_RtD" },
			new string[3] { "Moder", "defeated_dragon", "Item_OrichalcumOre_RtD, Item_MoonironOre_RtD, Item_QuicksilverBar_RtD" },
			new string[3] { "Yagluth", "defeated_goblinking", "Item_BloodironOre_RtD, Item_NetheriteBar_RtD" },
			new string[3] { "The Queen", "defeated_queen", "FelmetalOre_RtD, FelmetalBar_RtD" },
			new string[3] { "Fader", "defeated_fader", "FroMetalOre_RtD, FroMetalBar_RtD" },
			new string[3] { "Frozen King", "defeated_frozenking", "" }
		};

		private void Awake()
		{
			List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
			string[][] bosses = Bosses;
			foreach (string[] array in bosses)
			{
				ConfigEntry<string> val = ((BaseUnityPlugin)this).Config.Bind<string>(array[0], "Items", array[2], "Ores and bars (item prefab names, separated by commas) that may go through portals once " + array[0] + " has been defeated. Move a name to another boss's section to change when it unlocks. Requires Path of Valheiman's Ore Portals passive. Leave empty for none.");
				list.Add(new KeyValuePair<string, string>(array[1], val.Value));
			}
			Type type = AccessTools_TypeByName("PassiveTree.Conveniences+PortalOre");
			if (type == null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Path of Valheiman is not installed (or its layout changed) - nothing to do.");
				return;
			}
			if (!(type.GetField("Boss", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) is Dictionary<string, string> dictionary))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"PortalOre.Boss dictionary not found - PoV may have changed. No items added.");
				return;
			}
			int num = 0;
			int num2 = 0;
			foreach (KeyValuePair<string, string> item in list)
			{
				string[] array2 = (item.Value ?? "").Split(new char[3] { ',', ';', '\n' }, StringSplitOptions.RemoveEmptyEntries);
				foreach (string text in array2)
				{
					string text2 = text.Trim();
					if (text2.Length != 0)
					{
						if (dictionary.ContainsKey(text2))
						{
							num2++;
							continue;
						}
						dictionary[text2] = item.Key;
						num++;
					}
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Added {num} item(s) to PoV's Ore Portals list ({num2} already present).");
		}

		private static Type AccessTools_TypeByName(string name)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				Type type = null;
				try
				{
					type = assembly.GetType(name, throwOnError: false);
				}
				catch
				{
				}
				if (type != null)
				{
					return type;
				}
			}
			return null;
		}
	}
}