using System;
using System.Collections.Generic;
using System.Diagnostics;
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 PEAKLib.Core;
using UnityEngine;
[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("com.github.MiiMii1205.BebeilleHats")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("com.github.MiiMii1205.BebeilleHats")]
[assembly: AssemblyTitle("BebeilleHats")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 BebeilleHats
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.github.MiiMii1205.BebeilleHats", "BebeilleHats", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
private class Patcher
{
public static bool dummyPatched;
private static PlayerCustomizationDummy lastModifiedDummy;
public static bool CreateHatOption(Customization customization, string name, Texture2D icon)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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))
{
Log.LogWarning((object)("Trying to add " + name2 + " a second time."));
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);
Log.LogDebug((object)$"Added Hat Option {name2} in PassportManager @ {customization.hats.Length - 1}!");
return true;
}
[HarmonyPatch(typeof(PassportManager), "Awake")]
[HarmonyPostfix]
public static void PassportManagerAwakePostfix(PassportManager __instance)
{
Log.LogDebug((object)"Adding Hat_Bebeille...");
CreateHatOption(((Component)__instance).GetComponent<Customization>(), "Hat_Bebeille", customHatsIcons[0]);
CustomizationOption[] fits = ((Component)__instance).GetComponent<Customization>().fits;
foreach (CustomizationOption val in fits)
{
if (val.overrideHat)
{
val.overrideHatIndex += customHats.Count;
}
}
}
private static bool syncHats(CustomizationRefs dst, CustomizationRefs src = null)
{
if ((Object)(object)src == (Object)null)
{
Character localCharacter = Character.localCharacter;
CharacterCustomization val = default(CharacterCustomization);
if (!Object.op_Implicit((Object)(object)localCharacter) || !((Component)localCharacter).TryGetComponent<CharacterCustomization>(ref val))
{
Log.LogError((object)"CharacterCustomization component is missing.");
return false;
}
src = val.refs;
}
Renderer[] playerHats = src.playerHats;
Renderer[] playerHats2 = dst.playerHats;
if (playerHats.Length == playerHats2.Length)
{
return true;
}
Renderer val2 = playerHats2.FirstOrDefault();
if (!Object.op_Implicit((Object)(object)val2))
{
Log.LogError((object)"Cannot find renderer in dst");
return false;
}
int layer = ((Component)val2).gameObject.layer;
Transform val3 = ((Component)src).transform.Find("Armature/Hip/Mid/AimJoint/Torso/Head/Hat");
Transform val4 = ((Component)dst).transform.Find("Armature/Hip/Mid/AimJoint/Torso/Head/Hat");
List<Renderer> list = new List<Renderer>();
Renderer[] subArray = playerHats[..^2];
Renderer[] subArray2 = playerHats2[..^2];
for (int i = subArray2.Length; i < subArray.Length; i++)
{
Transform val5 = ((Component)subArray[i]).transform;
while ((Object)(object)val5.parent != (Object)(object)val3)
{
val5 = val5.parent;
}
GameObject val6 = Object.Instantiate<GameObject>(((Component)val5).gameObject, val4, false);
((Object)val6).name = ((Object)val5).name;
Renderer componentInChildren = val6.GetComponentInChildren<Renderer>(true);
((Component)componentInChildren).gameObject.layer = layer;
list.Add(componentInChildren);
}
Renderer[] subArray3 = dst.playerHats[^2..];
Renderer[] subArray4 = dst.playerHats[..^2];
dst.playerHats = CollectionExtensions.AddRangeToArray<Renderer>(CollectionExtensions.AddRangeToArray<Renderer>(subArray4, list.ToArray()), subArray3);
return true;
}
[HarmonyPatch(typeof(PeakHandler), "SetCosmetics")]
[HarmonyPrefix]
public static void PeakHandlerSetCosmeticsPrefix(PeakHandler __instance)
{
if (!syncHats(__instance.firstCutsceneScout))
{
Log.LogError((object)"Something went wrong [firstCutsceneScout]...");
}
for (int i = 0; i < __instance.cutsceneScoutRefs.Count(); i++)
{
if (!syncHats(__instance.cutsceneScoutRefs[i]))
{
Log.LogError((object)$"Something went wrong [cutsceneScoutRefs-{i}]...");
}
}
}
[HarmonyPatch(typeof(CharacterCustomization), "Awake")]
[HarmonyPostfix]
public static void CharacterCustomizationAwakePostfix(CharacterCustomization __instance)
{
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: 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");
for (int i = 0; i < customHats.Count; i++)
{
GameObject val2 = Object.Instantiate<GameObject>(customHats[i], val, true);
SetLayerRecursively(val2.transform, ((Component)val).gameObject.layer);
MeshRenderer component = val2.GetComponent<MeshRenderer>();
Material material = ((Renderer)component).material;
Shader shader = (((Renderer)component).sharedMaterial.shader = Shader.Find("W/Character"));
material.shader = shader;
Log.LogDebug((object)("Adding Hat " + ((Object)val2).name + "..."));
if (((Object)val2).name.Contains("Bebeille"))
{
val2.transform.localPosition = new Vector3(0f, 0.2280774f, 5.989897f);
Transform transform = val2.transform;
Quaternion val4 = new Quaternion(0f, 0f, -1f, 0f);
transform.localRotation = ((Quaternion)(ref val4)).normalized;
val2.transform.localScale = Vector3.one;
}
val2.SetActive(false);
Renderer[] subArray = __instance.refs.playerHats[^2..];
Renderer[] subArray2 = __instance.refs.playerHats[..^2];
__instance.refs.playerHats = CollectionExtensions.AddRangeToArray<Renderer>(CollectionExtensions.AddToArray<Renderer>(subArray2, (Renderer)(object)component), subArray);
Log.LogInfo((object)$"Inserted Hat {((Object)val2).name} @ {subArray2.Length + 1}!");
}
}
[HarmonyPatch(typeof(PlayerCustomizationDummy), "UpdateDummy")]
[HarmonyPrefix]
public static void PlayerCustomizationDummyUpdateDummyPrefix(PlayerCustomizationDummy __instance)
{
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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");
for (int i = 0; i < customHats.Count; i++)
{
GameObject val2 = Object.Instantiate<GameObject>(customHats[i], val, true);
SetLayerRecursively(val2.transform, ((Component)val).gameObject.layer);
MeshRenderer component = val2.GetComponent<MeshRenderer>();
Material material = ((Renderer)component).material;
Shader shader = (((Renderer)component).sharedMaterial.shader = Shader.Find("W/Character"));
material.shader = shader;
Log.LogDebug((object)("Adding Hat " + ((Object)val2).name + "..."));
if (((Object)val2).name.Contains("Bebeille"))
{
val2.transform.localPosition = new Vector3(0f, 0.2280774f, 5.989897f);
Transform transform = val2.transform;
Quaternion val4 = new Quaternion(0f, 0f, -1f, 0f);
transform.localRotation = ((Quaternion)(ref val4)).normalized;
val2.transform.localScale = Vector3.one;
}
val2.SetActive(false);
Renderer[] subArray = __instance.refs.playerHats[^2..];
Renderer[] subArray2 = __instance.refs.playerHats[..^2];
__instance.refs.playerHats = CollectionExtensions.AddRangeToArray<Renderer>(CollectionExtensions.AddToArray<Renderer>(subArray2, (Renderer)(object)component), subArray);
Log.LogInfo((object)$"Inserted Hat {((Object)val2).name} @ {subArray2.Length + 1}!");
}
}
}
public static List<GameObject> customHats;
public static List<Texture2D> customHatsIcons;
public const string Id = "com.github.MiiMii1205.BebeilleHats";
internal static ManualLogSource Log { get; private set; }
public static string Name => "BebeilleHats";
public static string Version => "1.0.2";
private 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 void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("com.github.MiiMii1205.BebeilleHats").PatchAll(typeof(Patcher));
Log = ((BaseUnityPlugin)this).Logger;
customHats = new List<GameObject>();
customHatsIcons = new List<Texture2D>();
BundleLoader.LoadBundleAndContentsWithName((BaseUnityPlugin)(object)this, "bebeilles.peakbundle", (Action<PeakBundle>)delegate(PeakBundle bundle)
{
customHats.Add(bundle.LoadAsset<GameObject>("BebeilleHat.prefab"));
customHatsIcons.Add(bundle.LoadAsset<Texture2D>("Hat_Icon_Bebeille.png"));
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
});
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}