Decompiled source of FehuBows v420.0.4

plugin/__FEHU/FehuBows/FehuBows.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FehuBows")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FehuBows")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.0.5")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.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;
		}
	}
}
namespace FehuBows
{
	[BepInPlugin("com.jotunn.FehuBows", "FehuBows", "420.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal sealed class FehuBows : BaseUnityPlugin
	{
		internal const string PluginGuid = "com.jotunn.FehuBows";

		internal const string PluginName = "FehuBows";

		internal const string PluginVersion = "420.0.6";

		private static readonly string[] BowAssets = new string[7] { "assets/bossnbows/eikthyrbow.prefab", "assets/bossnbows/elderbow.prefab", "assets/bossnbows/bonemassbow.prefab", "assets/bossnbows/moderbow.prefab", "assets/bossnbows/yagluthbow.prefab", "assets/bossnbows/queenbow.prefab", "assets/bossnbows/faderbow.prefab" };

		private static readonly HashSet<string> RegisteredNames = new HashSet<string>(StringComparer.Ordinal);

		private static readonly Dictionary<string, string> DisplayNames = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
		{
			{ "eikthyrbow", "Eikthyr Bow" },
			{ "elderbow", "Elder Bow" },
			{ "bonemassbow", "Bonemass Bow" },
			{ "moderbow", "Moder Bow" },
			{ "yagluthbow", "Yagluth Bow" },
			{ "queenbow", "Queen Bow" },
			{ "faderbow", "Fader Bow" }
		};

		private ManualLogSource log;

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			AssetBundle val = FindSharedBowBundle();
			if ((Object)(object)val == (Object)null)
			{
				log.LogError((object)"[FehuBows] Shared bow asset bundle is unavailable; bows were not registered.");
				return;
			}
			string[] bowAssets = BowAssets;
			foreach (string assetPath in bowAssets)
			{
				RegisterBow(val, assetPath);
			}
			log.LogInfo((object)("[FehuBows] Lite registered " + RegisteredNames.Count + " bow prefabs."));
		}

		private static AssetBundle FindSharedBowBundle()
		{
			foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
			{
				if ((Object)(object)allLoadedAssetBundle != (Object)null && ((Object)allLoadedAssetBundle).name == "bossnbows")
				{
					return allLoadedAssetBundle;
				}
			}
			return null;
		}

		private void RegisterBow(AssetBundle bundle, string assetPath)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			GameObject val;
			try
			{
				val = bundle.LoadAsset<GameObject>(assetPath);
			}
			catch (Exception ex)
			{
				log.LogWarning((object)("[FehuBows] Could not read " + assetPath + ": " + ex.Message));
				return;
			}
			if ((Object)(object)val == (Object)null)
			{
				log.LogWarning((object)("[FehuBows] Missing bow prefab: " + assetPath));
				return;
			}
			ItemDrop component = val.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && DisplayNames.TryGetValue(((Object)val).name, out var value))
			{
				component.m_itemData.m_shared.m_name = value;
			}
			if (!RegisteredNames.Add(((Object)val).name))
			{
				return;
			}
			try
			{
				ItemManager.Instance.AddItem(new CustomItem(val, true));
			}
			catch (Exception ex2)
			{
				log.LogError((object)("[FehuBows] Failed to register " + ((Object)val).name + ": " + ex2.Message));
			}
		}
	}
}