using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using FubukiJester.Patches;
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: AssemblyTitle("FubukiJester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FubukiJester")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("293e7337-5cb3-4936-b577-fbee0bac2c14")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FubukiJester
{
[BepInPlugin("Athena.FubukiJester", "Fubuki Jester Mod", "1.0.2")]
public class FubukiJesterBase : BaseUnityPlugin
{
private const string modGUID = "Athena.FubukiJester";
private const string modName = "Fubuki Jester Mod";
private const string modVersion = "1.0.2";
private readonly Harmony harmony = new Harmony("Athena.FubukiJester");
private static FubukiJesterBase Instance;
internal ManualLogSource mls;
internal static List<AudioClip> SoundFX;
internal static List<Texture2D> fubukiMaterial;
internal static GameObject Visuals;
internal static AssetBundle Bundle;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Athena.FubukiJester");
mls.LogInfo((object)"Fubuki has awakened");
harmony.PatchAll(typeof(FubukiJesterBase));
harmony.PatchAll(typeof(FubukiPatch));
mls = ((BaseUnityPlugin)this).Logger;
SoundFX = new List<AudioClip>();
fubukiMaterial = new List<Texture2D>();
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("FubukiJester.dll".ToCharArray());
Bundle = AssetBundle.LoadFromFile(location + "fubuki");
if ((Object)(object)Bundle != (Object)null)
{
mls.LogInfo((object)"Succesfully loaded asset bundle");
SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
fubukiMaterial = Bundle.LoadAllAssets<Texture2D>().ToList();
}
}
}
}
namespace FubukiJester.Patches
{
[HarmonyPatch(typeof(JesterAI))]
internal class FubukiPatch : MonoBehaviour
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void OverrideAudio(JesterAI __instance)
{
__instance.popGoesTheWeaselTheme = FubukiJesterBase.SoundFX[1];
__instance.popUpSFX = FubukiJesterBase.SoundFX[0];
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void FubukiVisual(JesterAI __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance).transform.Find("MeshContainer");
object obj;
if (val == null)
{
obj = null;
}
else
{
Transform obj2 = val.Find("JackInTheBoxBody");
obj = ((obj2 != null) ? ((Component)obj2).GetComponent<SkinnedMeshRenderer>() : null);
}
SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)obj;
MaterialPropertyBlock val3 = new MaterialPropertyBlock();
((Renderer)val2).GetPropertyBlock(val3, 0);
val3.SetTexture("_BaseColorMap", (Texture)(object)FubukiJesterBase.fubukiMaterial[0]);
val3.SetVector("_BaseColorMap_ST", new Vector4(1f, 1f, 0f, 0f));
val3.SetTexture("_NormalMap", (Texture)(object)FubukiJesterBase.fubukiMaterial[0]);
((Renderer)val2).SetPropertyBlock(val3, 0);
Material val4 = null;
List<Material> list = ((Component)__instance).GetComponentsInChildren<Renderer>(true).SelectMany((Renderer x) => x.sharedMaterials).ToList();
foreach (Material item in list)
{
if (((Object)item).name.StartsWith("JesterTex"))
{
item.mainTexture = (Texture)(object)FubukiJesterBase.fubukiMaterial[0];
val4 = item;
}
}
}
}
}