Decompiled source of Kysen Capes v1.0.0

KysenBlackCape.dll

Decompiled 2 weeks 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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("KysenBlackCape")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("KG")]
[assembly: AssemblyProduct("KysenBlackCape")]
[assembly: AssemblyCopyright("Copyright © KG 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0D36C3F9-0662-4096-8BD7-E2CA8DBC8718")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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;
		}
	}
}
namespace KysenBlackCape
{
	[BepInPlugin("kg.kysenblackcape", "KysenBlackCape", "1.0.0")]
	public class KysenBlackCape : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		private static class ObjectDB_CopyOtherDB_Patch
		{
			private static void Prefix(ObjectDB __instance, ObjectDB other)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Expected O, but got Unknown
				if (Object.op_Implicit((Object)(object)Cape))
				{
					return;
				}
				GameObject val = new GameObject("KysenBlackCapeItemHolder")
				{
					hideFlags = (HideFlags)61
				};
				val.SetActive(false);
				Cape = Object.Instantiate<GameObject>(other.m_items.First((GameObject i) => ((Object)i).name == "CapeLox"), val.transform);
				ItemDrop component = Cape.GetComponent<ItemDrop>();
				((Object)Cape).name = "CapeKysen";
				component.m_itemData.m_shared = (SharedData)AccessTools.DeclaredMethod(typeof(object), "MemberwiseClone", (Type[])null, (Type[])null).Invoke(component.m_itemData.m_shared, null);
				component.m_itemData.m_shared.m_name = "Kysen's Black Cape";
				component.m_itemData.m_shared.m_description = "A dark cape once worn by the legendary Kysen.";
				AssetBundle assetBundle = GetAssetBundle("kysenblackcape");
				component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { assetBundle.LoadAsset<Sprite>("Cape_Kysen_Icon") };
				Texture2D val2 = assetBundle.LoadAsset<Texture2D>("Cape_Kysen_HD");
				IEnumerable<Renderer> enumerable = Cape.GetComponentsInChildren<MeshRenderer>(true).Cast<Renderer>().Concat((IEnumerable<Renderer>)(object)Cape.GetComponentsInChildren<SkinnedMeshRenderer>(true))
					.Cast<Renderer>();
				foreach (Renderer item in enumerable)
				{
					Material[] materials = item.materials;
					Material[] array = materials;
					foreach (Material val3 in array)
					{
						val3.SetTexture("_MainTex", (Texture)(object)val2);
					}
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static class ObjectDB_Awake_Patch
		{
			private static void Prefix(ObjectDB __instance)
			{
				if (Object.op_Implicit((Object)(object)Cape) && !__instance.m_items.Contains(Cape))
				{
					__instance.m_items.Add(Cape);
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class ZNetScene_Awake_Patch
		{
			private static bool Initialized;

			private static void Postfix(ZNetScene __instance)
			{
				__instance.m_namedPrefabs[StringExtensionMethods.GetStableHashCode(((Object)Cape).name)] = Cape;
			}
		}

		private const string GUID = "kg.kysenblackcape";

		private const string NAME = "KysenBlackCape";

		private const string VERSION = "1.0.0";

		private static GameObject Cape;

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("kg.kysenblackcape").PatchAll();
		}

		private static AssetBundle GetAssetBundle(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}
	}
}