using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; 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("PeterHead")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PeterHead")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("bad7520b-d6ab-49ba-9521-27aba032cdc5")] [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 PeterHead { [BepInPlugin("KadenBiel.PeterHead", "PeterHead", "1.0.2")] public class PeterHeadBase : BaseUnityPlugin { private const string modGUID = "KadenBiel.PeterHead"; private const string modName = "PeterHead"; private const string modVersion = "1.0.2"; private readonly Harmony harmony = new Harmony("KadenBiel.PeterHead"); private static PeterHeadBase Instance; public static ManualLogSource mls; public static AssetBundle PeterAssets; public static GameObject PeterPrefab; public static AudioClip Walk; public static AudioClip Hit; public static AudioClip Laugh0; public static AudioClip Laugh1; public static AudioClip Laugh2; public static string modDir; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } modDir = ((BaseUnityPlugin)this).Info.Location; mls = Logger.CreateLogSource("KadenBiel.PeterHead"); LoadAssets(); mls.LogInfo((object)"PeterHead is awake"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } private static void LoadAssets() { try { PeterAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(modDir), "peterhead")); } catch (Exception ex) { mls.LogError((object)("AssetBundle failed to load -- " + ex.Message)); return; } try { PeterPrefab = PeterAssets.LoadAsset("PeterHead.prefab"); Walk = PeterAssets.LoadAsset("PeterWalk.ogg"); Hit = PeterAssets.LoadAsset("PeterKill.ogg"); Laugh0 = PeterAssets.LoadAsset("PeterLaugh.ogg"); Laugh1 = PeterAssets.LoadAsset("PeterLaugh0.ogg"); Laugh2 = PeterAssets.LoadAsset("PeterLaugh1.ogg"); mls.LogInfo((object)"Peter Assets Loaded"); } catch (Exception ex2) { mls.LogError((object)("Failed to load assets -- " + ex2.Message)); } } } } namespace PeterHead.Patchers { [HarmonyPatch] internal class CoilPatch { [HarmonyPatch(typeof(SpringManAI), "Update")] [HarmonyPostfix] private static void addController(SpringManAI __instance) { if ((Object)(object)((Component)__instance).gameObject.GetComponent() == (Object)null) { PeterHeadBase.mls.LogInfo((object)"Instantiating Peter"); ((Component)__instance).gameObject.AddComponent(); } } } internal class PeterController : MonoBehaviour { private static GameObject Peter; private SpringManAI SpringAI { get; set; } private Vector3 prevPosition { get; set; } private void LoadAudio() { SpringAI.springNoises = (AudioClip[])(object)new AudioClip[3] { PeterHeadBase.Laugh0, PeterHeadBase.Laugh1, PeterHeadBase.Laugh2 }; PeterHeadBase.mls.LogInfo((object)"Audio Replaced"); } private void HideSpringModel() { try { PeterHeadBase.mls.LogInfo((object)"Attempting to find spring man mesh"); for (int i = 0; i < ((Component)SpringAI).transform.childCount - 1; i++) { PeterHeadBase.mls.LogInfo((object)("Index: " + i + " Name: " + ((Object)((Component)SpringAI).transform.GetChild(i)).name)); } Renderer[] componentsInChildren = ((Component)((Component)SpringAI).transform.Find("SpringManModel")).GetComponentsInChildren(); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].enabled = false; } PeterHeadBase.mls.LogInfo((object)"Spring Man Hidden"); } catch (Exception ex) { PeterHeadBase.mls.LogError((object)("Failed to find Spring Man Model: " + ex.Message)); } } private void EnablePeter() { try { MeshRenderer[] componentsInChildren = Peter.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).enabled = true; } PeterHeadBase.mls.LogInfo((object)"Peter Enabled"); } catch (Exception ex) { PeterHeadBase.mls.LogError((object)("Failed to find Peter Model: " + ex.Message)); } } private void Start() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) PeterHeadBase.mls.LogInfo((object)"Peter Started"); SpringAI = ((Component)this).GetComponent(); Peter = Object.Instantiate(PeterHeadBase.PeterPrefab, ((Component)SpringAI).transform.position, Quaternion.identity, ((Component)SpringAI).transform); LoadAudio(); HideSpringModel(); EnablePeter(); } private void Update() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (((EnemyAI)SpringAI).movingTowardsTargetPlayer && !((EnemyAI)SpringAI).creatureSFX.isPlaying) { ((EnemyAI)SpringAI).creatureSFX.clip = PeterHeadBase.Hit; ((EnemyAI)SpringAI).creatureSFX.Play(); } if (((EnemyAI)SpringAI).creatureSFX.isPlaying && prevPosition == ((Component)this).transform.position) { ((EnemyAI)SpringAI).creatureSFX.Stop(); } prevPosition = ((Component)this).transform.position; } } }