using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
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: AssemblyTitle("FreddyBracken")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FreddyBracken")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2ed810b2-476e-4150-b015-645ee4681b3d")]
[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 FreddyBracken
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "FreddyBracken";
public const string PLUGIN_NAME = "FreddyBracken";
public const string PLUGIN_VERSION = "1.0.2";
}
[BepInPlugin("FreddyBracken", "FreddyBracken", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
public static GameObject Visuals;
public static AudioClip NeckCrackAudio;
public static AudioClip AngeredAudio;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin FreddyBracken is loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "freddy.bundle");
AssetBundle val = AssetBundle.LoadFromFile(text);
Visuals = val.LoadAsset<GameObject>("assets/prefabs/freddy.prefab");
NeckCrackAudio = val.LoadAsset<AudioClip>("assets/prefabs/freddycrackneck.wav");
AngeredAudio = val.LoadAsset<AudioClip>("assets/prefabs/freddyangered.wav");
Renderer[] componentsInChildren = Visuals.GetComponentsInChildren<Renderer>(true);
foreach (Renderer val2 in componentsInChildren)
{
((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
}
}
}
}
namespace FreddyBracken.Patches
{
[HarmonyPatch(typeof(FlowermanAI), "Start")]
internal class FlowermanPatch
{
private static void Postfix(FlowermanAI __instance)
{
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Plugin.Visuals == (Object)null)
{
return;
}
Transform val = ((Component)__instance).transform.Find("FlowermanModel");
object obj;
if (val == null)
{
obj = null;
}
else
{
Transform obj2 = val.Find("LOD1");
obj = ((obj2 != null) ? ((Component)obj2).GetComponent<SkinnedMeshRenderer>() : null);
}
SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)obj;
object obj3;
if (val == null)
{
obj3 = null;
}
else
{
Transform obj4 = val.Find("AnimContainer");
obj3 = ((obj4 != null) ? obj4.Find("metarig") : null);
}
Transform val3 = (Transform)obj3;
if (!((Object)(object)val2 == (Object)null) && ((Renderer)val2).enabled)
{
((Renderer)val2).enabled = false;
Renderer[] componentsInChildren = ((Component)val3).gameObject.GetComponentsInChildren<Renderer>();
foreach (Renderer val4 in componentsInChildren)
{
val4.enabled = false;
}
GameObject val5 = Object.Instantiate<GameObject>(Plugin.Visuals);
val5.transform.SetParent(val);
val5.transform.localPosition = Vector3.zero;
val5.transform.localRotation = Quaternion.identity;
val5.transform.localScale = Vector3.one;
Transform val6 = val5.transform.Find("Container/Body_Geo");
Transform val7 = val5.transform.Find("Container/metarig");
val7.SetParent(val3.parent, true);
((Component)val7).transform.localScale = ((Component)val3).transform.localScale;
((Component)val7).transform.localRotation = ((Component)val3).transform.localRotation;
((Component)val7).transform.localPosition = ((Component)val3).transform.localPosition;
SkinnedMeshRenderer component = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
component.rootBone = val7;
((Object)val3).name = "old-metarig";
__instance.crackNeckSFX = Plugin.NeckCrackAudio;
__instance.creatureAngerVoice.clip = Plugin.AngeredAudio;
}
}
}
}