Decompiled source of ZetAspectHighlander v1.0.0

ZetAspectHighlander.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BransItems.Modules.ItemTiers;
using BransItems.Modules.ItemTiers.HighlanderTier;
using BransItems.Modules.Utils;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.ContentManagement;
using TPDespair.ZetAspects;
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("ZetAspectHighlander")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ZetAspectHighlander")]
[assembly: AssemblyTitle("ZetAspectHighlander")]
[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 ZetAspectHighlander
{
	[BepInPlugin("prodzpod.ZetAspectHighlander", "ZetAspectHighlander", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "prodzpod.ZetAspectHighlander";

		public const string PluginAuthor = "prodzpod";

		public const string PluginName = "ZetAspectHighlander";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource Log;

		public static PluginInfo pluginInfo;

		public static ConfigFile Config;

		public static ConfigEntry<bool> SpawnNaturally;

		public static Harmony Harmony;

		public static List<ItemIndex> Affixes = new List<ItemIndex>();

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			pluginInfo = ((BaseUnityPlugin)this).Info;
			Log = ((BaseUnityPlugin)this).Logger;
			Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "prodzpod.ZetAspectHighlander.cfg"), true);
			SpawnNaturally = Config.Bind<bool>("General", "Aspects drop naturally", false, "set this to make it like any other highlander");
			Harmony = new Harmony("prodzpod.ZetAspectHighlander");
			Harmony.PatchAll(typeof(ya));
			Harmony.PatchAll(typeof(yi));
			if (!SpawnNaturally.Value)
			{
				Harmony.PatchAll(typeof(ye));
			}
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Invalid comparison between Unknown and I4
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Invalid comparison between Unknown and I4
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				ItemDef[] itemDefs = ContentManager._itemDefs;
				foreach (ItemDef val in itemDefs)
				{
					if (((Object)val).name.StartsWith("ZetAspect") && ((int)val.tier == 4 || (int)val.tier == 2))
					{
						Log.LogInfo((object)("Fixing " + ((Object)val).name));
						val._itemTierDef = ((ItemTierBase)ItemTierBase<Highlander>.instance).itemTierDef;
						Affixes.Add(val.itemIndex);
					}
				}
			});
		}
	}
	[HarmonyPatch(typeof(ZetAspectsContent), "FinalizeAsync")]
	public class ya
	{
		public static void Prefix(ZetAspectsContent __instance)
		{
			foreach (ItemDef itemDef in ZetAspectsContent.itemDefs)
			{
				if ((Object)(object)itemDef._itemTierDef == (Object)(object)Catalog.BossItemTier || (Object)(object)itemDef._itemTierDef == (Object)(object)Catalog.RedItemTier)
				{
					itemDef._itemTierDef = ((ItemTierBase)ItemTierBase<Highlander>.instance).itemTierDef;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemHelpers), "PickupDefsWithTier")]
	public class ye
	{
		public static void Postfix(ItemTierDef itemTierDef, ref List<PickupDef> __result)
		{
			if ((Object)(object)itemTierDef == (Object)(object)((ItemTierBase)ItemTierBase<Highlander>.instance).itemTierDef)
			{
				__result = __result.Where((PickupDef x) => !Main.Affixes.Contains(x.itemIndex)).ToList();
			}
		}
	}
	[HarmonyPatch(typeof(Catalog), "SetItemState")]
	public class yi
	{
		public static void Postfix(ItemDef itemDef, bool shown)
		{
			if ((Object)(object)itemDef._itemTierDef == (Object)(object)Catalog.BossItemTier || (Object)(object)itemDef._itemTierDef == (Object)(object)Catalog.RedItemTier)
			{
				itemDef._itemTierDef = ((ItemTierBase)ItemTierBase<Highlander>.instance).itemTierDef;
			}
		}
	}
}