using System;
using System.Collections;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("my.pahsiv.MyMousyWig")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("my.pahsiv.MyMousyWig")]
[assembly: AssemblyTitle("MyMousyWig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace MyMousyWig
{
public class Patcher
{
private static readonly int SkinColor = Shader.PropertyToID("_SkinColor");
private static PlayerCustomizationDummy lastModifiedDummy;
public static bool CreateHatOption(Customization customization, string name, Texture2D icon)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
string name2 = name;
if (Array.Exists(customization.hats, (CustomizationOption hat) => ((Object)hat).name == name2))
{
return false;
}
CustomizationOption val = ScriptableObject.CreateInstance<CustomizationOption>();
val.color = Color.white;
((Object)val).name = name2;
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)
{
Customization component = ((Component)__instance).GetComponent<Customization>();
Texture2D icon = Plugin.assetBundle.LoadAsset<Texture2D>("Assets/Dummy1.png");
Texture2D icon2 = Plugin.assetBundle.LoadAsset<Texture2D>("Assets/Dummy2.png");
Texture2D icon3 = Plugin.assetBundle.LoadAsset<Texture2D>("Assets/Dummy3.png");
for (int i = 0; i < component.fits.Length; i++)
{
if (!component.fits[i].overrideHat)
{
continue;
}
while (component.hats.Length - 1 < component.fits[i].overrideHatIndex)
{
switch (i)
{
case 18:
CreateHatOption(component, $"Dummy#{component.hats.Length}", icon);
break;
case 19:
CreateHatOption(component, $"Dummy#{component.hats.Length}", icon2);
break;
default:
CreateHatOption(component, $"Dummy#{component.hats.Length}", icon3);
break;
}
}
}
for (int j = 0; j < Plugin.hats.Count; j++)
{
Plugin.HatEntry hatEntry = Plugin.hats[j];
CreateHatOption(component, hatEntry.Name, hatEntry.Icon);
}
}
[HarmonyPatch(typeof(CharacterCustomization), "Awake")]
[HarmonyPostfix]
public static void CharacterCustomizationAwakePostfix(CharacterCustomization __instance)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance.refs).transform.Find("Armature/Hip/Mid/AimJoint/Torso/Head/Hat");
List<Renderer> list = new List<Renderer>(__instance.refs.playerHats);
for (int i = 0; i < Plugin.hats.Count; i++)
{
GameObject val2 = Object.Instantiate<GameObject>(Plugin.hats[i].Prefab, val.position, val.rotation, val);
Plugin.SetLayerRecursively(val2.transform, ((Component)val).gameObject.layer);
Renderer componentInChildren = val2.GetComponentInChildren<Renderer>();
((Component)componentInChildren).gameObject.SetActive(false);
for (int j = 0; j < componentInChildren.materials.Length; j++)
{
componentInChildren.materials[j].shader = Shader.Find("W/Character");
}
__instance.refs.AllRenderers = CollectionExtensions.AddToArray<Renderer>(__instance.refs.AllRenderers, componentInChildren);
list.Add(componentInChildren);
}
__instance.refs.playerHats = list.ToArray();
}
[HarmonyPatch(typeof(PlayerCustomizationDummy), "UpdateDummy")]
[HarmonyPrefix]
public static void PlayerCustomizationDummyUpdateDummyPrefix(PlayerCustomizationDummy __instance)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)(object)lastModifiedDummy)
{
return;
}
lastModifiedDummy = __instance;
Transform val = ((Component)__instance.refs).transform.Find("Armature/Hip/Mid/AimJoint/Torso/Head/Hat");
List<Renderer> list = new List<Renderer>(__instance.refs.playerHats);
for (int i = 0; i < Plugin.hats.Count; i++)
{
GameObject val2 = Object.Instantiate<GameObject>(Plugin.hats[i].Prefab, val.position, val.rotation, val);
Plugin.SetLayerRecursively(val2.transform, ((Component)val).gameObject.layer);
Renderer componentInChildren = val2.GetComponentInChildren<Renderer>();
((Component)componentInChildren).gameObject.SetActive(false);
for (int j = 0; j < componentInChildren.materials.Length; j++)
{
componentInChildren.materials[j].shader = Shader.Find("W/Character");
}
list.Add(componentInChildren);
}
__instance.refs.playerHats = list.ToArray();
}
[HarmonyPatch(typeof(CharacterCustomization), "OnPlayerDataChange")]
[HarmonyPostfix]
public static void CharacterCustomizationOnPlayerDataChangePostFix(CharacterCustomization __instance, ref PersistentPlayerData playerData)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance.refs.PlayerRenderers[0] == (Object)null)
{
return;
}
int num = playerData.customizationData.currentSkin;
if (__instance.useDebugColor)
{
num = __instance.debugColorIndex;
}
Color color = Singleton<Customization>.Instance.skins[num].color;
for (int i = 0; i < __instance.refs.playerHats.Length; i++)
{
for (int j = 0; j < __instance.refs.playerHats[i].materials.Length; j++)
{
__instance.refs.playerHats[i].materials[j].SetColor(SkinColor, color);
}
}
}
[HarmonyPatch(typeof(PlayerCustomizationDummy), "SetPlayerColor")]
[HarmonyPostfix]
public static void PlayerCustomizationDummySetPlayerColorPostFix(PlayerCustomizationDummy __instance, ref int index)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
if (index > Singleton<Customization>.Instance.skins.Length)
{
return;
}
Color color = Singleton<Customization>.Instance.skins[index].color;
for (int i = 0; i < __instance.refs.playerHats.Length; i++)
{
for (int j = 0; j < __instance.refs.playerHats[i].materials.Length; j++)
{
__instance.refs.playerHats[i].materials[j].SetColor(SkinColor, color);
}
}
}
}
[BepInPlugin("my.pahsiv.MyMousyWig", "MyMousyWig", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
public struct HatEntry
{
public string Name;
public GameObject Prefab;
public Texture2D Icon;
public HatEntry(string name, GameObject prefab, Texture2D icon)
{
Name = name;
Prefab = prefab;
Icon = icon;
}
}
[CompilerGenerated]
private sealed class <LoadAssetBundleFromDisk>d__7 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private AssetBundleCreateRequest <createRequest>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAssetBundleFromDisk>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<createRequest>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string path = Path.Combine(directoryName, "ironmouse");
<createRequest>5__2 = AssetBundle.LoadFromMemoryAsync(File.ReadAllBytes(path));
<>2__current = <createRequest>5__2;
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
assetBundle = <createRequest>5__2.assetBundle;
hats = new List<HatEntry>();
hats.Add(LoadHat("ironmouse"));
hats.Add(LoadHat("ironmouseblack"));
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static AssetBundle assetBundle;
public static List<HatEntry> hats;
public const string Id = "my.pahsiv.MyMousyWig";
public static ManualLogSource Log { get; private set; }
public static string Name => "MyMousyWig";
public static string Version => "0.1.0";
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
((MonoBehaviour)this).StartCoroutine(LoadAssetBundleFromDisk());
Harmony val = new Harmony("my.pahsiv.MyMousyWig");
val.PatchAll(typeof(Patcher));
IEnumerable<MethodBase> patchedMethods = val.GetPatchedMethods();
Log.LogMessage((object)$"Total patched methods: {patchedMethods.Count()}");
foreach (MethodBase item in patchedMethods)
{
Log.LogMessage((object)("Patched: " + item.DeclaringType?.Name + "." + item.Name));
}
Log.LogMessage((object)(" Plugin " + Name + " " + Version + " is loaded!"));
}
[IteratorStateMachine(typeof(<LoadAssetBundleFromDisk>d__7))]
private static IEnumerator LoadAssetBundleFromDisk()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAssetBundleFromDisk>d__7(0);
}
public static void SetLayerRecursively(Transform transform, int layer)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
((Component)transform).gameObject.layer = layer;
foreach (Transform item in transform)
{
Transform transform2 = item;
SetLayerRecursively(transform2, layer);
}
}
public static HatEntry LoadHat(string hatName)
{
GameObject prefab = assetBundle.LoadAsset<GameObject>("Assets/" + hatName + ".prefab");
Texture2D icon = assetBundle.LoadAsset<Texture2D>("Assets/" + hatName + ".png");
return new HatEntry(hatName, prefab, icon);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}