Decompiled source of Brefasveinn Belt v0.1.0

FrizzQOL.BrefasveinnBelt.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("FrizzQOL.BrefasveinnBelt")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eca9f01bfd6bef7de943e1c0ec713334a909de4b")]
[assembly: AssemblyProduct("FrizzQOL.BrefasveinnBelt")]
[assembly: AssemblyTitle("FrizzQOL.BrefasveinnBelt")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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;
		}
	}
}
public static class BeltTeleport
{
	public const string PrefabName = "BrefasveinnBelt";

	public static bool AllowsTeleport(string equippedPrefabName, bool vanillaResult)
	{
		if (string.Equals(equippedPrefabName, "BrefasveinnBelt", StringComparison.Ordinal))
		{
			return true;
		}
		return vanillaResult;
	}
}
namespace BrefasveinnBelt
{
	internal static class BeltItem
	{
		public static void Register()
		{
			PrefabManager.OnVanillaPrefabsAvailable += AddClonedBelt;
		}

		private static void AddClonedBelt()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			try
			{
				if ((Object)(object)PrefabManager.Instance.GetPrefab("BeltStrength") == (Object)null)
				{
					Logger.LogError((object)"BeltStrength prefab missing. Bréfasveinn Belt was not registered.");
					return;
				}
				ItemConfig val = new ItemConfig();
				val.Name = "$item_brefasveinnbelt";
				val.Description = "$item_brefasveinnbelt_desc";
				val.CraftingStation = CraftingStations.Forge;
				val.AddRequirement("Iron", 10, 0);
				val.AddRequirement("DeerHide", 5, 0);
				val.AddRequirement("Silver", 3, 0);
				val.AddRequirement("SurtlingCore", 1, 0);
				CustomItem val2 = new CustomItem("BrefasveinnBelt", "BeltStrength", val);
				if ((Object)(object)val2.ItemDrop != (Object)null)
				{
					val2.ItemDrop.m_itemData.m_shared.m_equipStatusEffect = null;
				}
				ItemManager.Instance.AddItem(val2);
				Logger.LogInfo((object)"Registered Bréfasveinn Belt");
			}
			finally
			{
				PrefabManager.OnVanillaPrefabsAvailable -= AddClonedBelt;
			}
		}
	}
	[BepInPlugin("com.frizzqol.brefasveinnbelt", "FrizzQOL Bréfasveinn Belt", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.frizzqol.brefasveinnbelt";

		public const string PluginName = "FrizzQOL Bréfasveinn Belt";

		public const string PluginVersion = "0.1.0";

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			AddLocalizations();
			BeltItem.Register();
			_harmony = new Harmony("com.frizzqol.brefasveinnbelt");
			_harmony.PatchAll();
			Logger.LogInfo((object)"FrizzQOL Bréfasveinn Belt 0.1.0 loaded");
		}

		private static void AddLocalizations()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "item_brefasveinnbelt", "Bréfasveinn Belt" },
				{ "item_brefasveinnbelt_desc", "While worn, portals allow any items, including ores and metals." }
			});
		}
	}
	[HarmonyPatch(typeof(Humanoid), "IsTeleportable")]
	internal static class TeleportPatch
	{
		private static void Postfix(Humanoid __instance, ref bool __result)
		{
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Humanoid)val).m_utilityItem?.m_dropPrefab == (Object)null))
			{
				string prefabName = Utils.GetPrefabName(((Humanoid)val).m_utilityItem.m_dropPrefab);
				__result = BeltTeleport.AllowsTeleport(prefabName, __result);
			}
		}
	}
}