Decompiled source of CustomHats v1.0.0

MoreHats.dll

Decompiled 4 days ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
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("MoreHats")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("MoreHats")]
[assembly: AssemblyTitle("MoreSkins")]
[assembly: AssemblyVersion("0.1.0.0")]
namespace MoreHats;

[BepInPlugin("radsi.hats", "custom hats", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private class Patcher
	{
		public static bool dummyPatched;

		public static bool CreateHatOption(Customization customization, string name, Texture2D icon)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (Array.Exists(customization.hats, (CustomizationOption hat) => ((Object)hat).name == name))
			{
				return false;
			}
			CustomizationOption val = ScriptableObject.CreateInstance<CustomizationOption>();
			val.color = Color.white;
			((Object)val).name = name;
			val.texture = (Texture)(object)icon;
			val.type = (Type)50;
			val.requiredAchievement = (ACHIEVEMENTTYPE)0;
			customization.hats = CollectionExtensions.AddToArray<CustomizationOption>(customization.hats, val);
			return true;
		}

		[HarmonyPatch(typeof(PassportManager), "Awake")]
		[HarmonyPostfix]
		public static void PassportManagerAwakePostfix(PassportManager __instance)
		{
			CreateHatOption(((Component)__instance).GetComponent<Customization>(), "Hat_GhostMask", customHatsIcons[0]);
			CreateHatOption(((Component)__instance).GetComponent<Customization>(), "Hat_CreeperHat", customHatsIcons[1]);
			CreateHatOption(((Component)__instance).GetComponent<Customization>(), "Hat_Wat", customHatsIcons[2]);
		}

		[HarmonyPatch(typeof(CharacterCustomization), "Awake")]
		[HarmonyPostfix]
		public static void CharacterCustomizationAwakePostfix(CharacterCustomization __instance)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			Transform child = ((Component)__instance).transform.GetChild(0).GetChild(0).GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(0)
				.GetChild(1)
				.GetChild(1);
			for (int i = 0; i < customHats.Count; i++)
			{
				GameObject val = Object.Instantiate<GameObject>(customHats[i]);
				((Renderer)val.GetComponent<MeshRenderer>()).material.shader = Shader.Find("W/Character");
				val.transform.SetParent(child);
				if (((Object)val).name.Contains("creeper"))
				{
					val.transform.localPosition = new Vector3(0f, 0.5f, 8f);
					val.transform.localScale = new Vector3(3f, 3f, 3f);
					val.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
				}
				else if (((Object)val).name.Contains("ghost"))
				{
					val.transform.localPosition = new Vector3(0f, -1f, 5.6f);
					val.transform.localScale = new Vector3(50f, 50f, 50f);
					val.transform.localRotation = Quaternion.Euler(0f, 0f, 90f);
				}
				else
				{
					val.transform.localPosition = new Vector3(0f, 0f, 6.5f);
					val.transform.localScale = new Vector3(3f, 3f, 3f);
					val.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
				}
				val.SetActive(false);
				__instance.refs.playerHats = CollectionExtensions.AddToArray<Renderer>(__instance.refs.playerHats, (Renderer)(object)val.GetComponent<MeshRenderer>());
			}
		}
	}

	public static AssetBundle assetBundle;

	public static List<GameObject> customHats;

	public static List<Texture2D> customHatsIcons;

	public void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("radsi.hats").PatchAll(typeof(Patcher));
		assetBundle = AssetBundle.LoadFromMemory(Resource1.hats);
		customHats = new List<GameObject>();
		customHatsIcons = new List<Texture2D>();
		customHats.Add(assetBundle.LoadAsset<GameObject>("assets/ghost.prefab"));
		customHats.Add(assetBundle.LoadAsset<GameObject>("assets/creeper.prefab"));
		customHats.Add(assetBundle.LoadAsset<GameObject>("assets/wat.prefab"));
		customHatsIcons.Add(assetBundle.LoadAsset<Texture2D>("assets/ghosticon.png"));
		customHatsIcons.Add(assetBundle.LoadAsset<Texture2D>("assets/creepericon.png"));
		customHatsIcons.Add(assetBundle.LoadAsset<Texture2D>("assets/nagawat.png"));
	}
}
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resource1
{
	private static ResourceManager resourceMan;

	private static CultureInfo resourceCulture;

	[EditorBrowsable(EditorBrowsableState.Advanced)]
	internal static ResourceManager ResourceManager
	{
		get
		{
			if (resourceMan == null)
			{
				ResourceManager resourceManager = new ResourceManager("MoreHats.Resource1", typeof(Resource1).Assembly);
				resourceMan = resourceManager;
			}
			return resourceMan;
		}
	}

	[EditorBrowsable(EditorBrowsableState.Advanced)]
	internal static CultureInfo Culture
	{
		get
		{
			return resourceCulture;
		}
		set
		{
			resourceCulture = value;
		}
	}

	internal static byte[] hats
	{
		get
		{
			object @object = ResourceManager.GetObject("hats", resourceCulture);
			return (byte[])@object;
		}
	}

	internal Resource1()
	{
	}
}