Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FreddyEnemy Patch v1.0.0
FreddyEnemy_Patch.dll
Decompiled 16 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using FreddyEnemy.AI; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FreddyEnemy_Patch")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FreddyEnemy_Patch")] [assembly: AssemblyTitle("FreddyEnemy_Patch")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } } namespace FreddyEnemy_Patch { [BepInPlugin("erv.FreddyEnemy_Patch", "FreddyEnemy Patch", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("erv.FreddyEnemy_Patch"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying surgical patch for FreddyEnemy mod..."); MethodInfo[] array = new MethodInfo[2] { AccessTools.Method(typeof(EnemyFreddy), "Update", (Type[])null, (Type[])null), AccessTools.Method(typeof(EnemyFreddyAnim), "Update", (Type[])null, (Type[])null) }; MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { if (methodInfo != null) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo); if (patchInfo != null && (patchInfo.Prefixes.Count > 0 || patchInfo.Postfixes.Count > 0 || patchInfo.Transpilers.Count > 0)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Found a potentially conflicting patch on: " + methodInfo.Name + ". Removing it...")); val.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)0, (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully removed conflicting patch."); } } } val.PatchAll(typeof(Plugin)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Surgical patch for FreddyEnemy has been successfully applied!"); } [HarmonyPatch(typeof(EnemyFreddy), "Update")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> AttackUpdateTranspiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(EnemyFreddy), "HandleAttack", (Type[])null, (Type[])null); MethodInfo operand = AccessTools.Method(typeof(Plugin), "CustomHandleAttack", (Type[])null, (Type[])null); for (int i = 0; i < list.Count; i++) { if ((list[i].opcode == OpCodes.Call || list[i].opcode == OpCodes.Callvirt) && list[i].operand is MethodInfo methodInfo2 && methodInfo2 == methodInfo) { list[i].opcode = OpCodes.Call; list[i].operand = operand; break; } } return list; } public static void CustomHandleAttack(EnemyFreddy instance) { //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) Traverse val = Traverse.Create((object)instance); if (val.Field("_stateImpulse").FieldExists() ? val.Field("_stateImpulse").GetValue<bool>() : val.Field("stateImpulse").GetValue<bool>()) { val.Field("attackImpulse").SetValue((object)true); Enemy val2 = (val.Field("_enemy").FieldExists() ? val.Field("_enemy").GetValue<Enemy>() : val.Field("enemy").GetValue<Enemy>()); if ((Object)(object)val2 != (Object)null) { Traverse.Create((object)val2).Field("StuckCount").SetValue((object)0); Traverse.Create((object)val2).Property("StuckCount", (object[])null).SetValue((object)0); } PhotonView val3 = (val.Field("_photonView").FieldExists() ? val.Field("_photonView").GetValue<PhotonView>() : val.Field("photonView").GetValue<PhotonView>()); if (GameManager.Multiplayer() && (Object)(object)val3 != (Object)null) { val3.RPC("AttackImpulseRPC", (RpcTarget)1, Array.Empty<object>()); } PlayerAvatar val4 = (val.Field("_target").FieldExists() ? val.Field("_target").GetValue<PlayerAvatar>() : val.Field("target").GetValue<PlayerAvatar>()); if ((Object)(object)val4 != (Object)null && (Object)(object)val4.playerHealth != (Object)null) { int num = (((Object)(object)val2 != (Object)null) ? SemiFunc.EnemyGetIndex(val2) : 0); val4.playerHealth.HurtOther(50, ((Component)val4).transform.position, false, num, false); } if (SemiFunc.IsMultiplayer() && (Object)(object)val3 != (Object)null) { Vector3 val5 = (((Object)(object)val4 != (Object)null) ? ((Component)val4).transform.position : ((Component)instance).transform.position); val3.RPC("ActivateHurtColliderRPC", (RpcTarget)0, new object[1] { val5 }); } } } [HarmonyPatch(typeof(EnemyFreddyAnim), "Update")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> AnimUpdateTranspiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(EnemyFreddyAnim), "SfxStunnedLoop", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(EnemyFreddyAnim), "SfxHaywireLoop", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(EnemyFreddyAnim), "SfxCloakedLoop", (Type[])null, (Type[])null); MethodInfo operand = AccessTools.Method(typeof(Plugin), "CustomSfxStunnedLoop", (Type[])null, (Type[])null); MethodInfo operand2 = AccessTools.Method(typeof(Plugin), "CustomSfxHaywireLoop", (Type[])null, (Type[])null); MethodInfo operand3 = AccessTools.Method(typeof(Plugin), "CustomSfxCloakedLoop", (Type[])null, (Type[])null); for (int i = 0; i < list.Count; i++) { if ((list[i].opcode == OpCodes.Call || list[i].opcode == OpCodes.Callvirt) && list[i].operand is MethodInfo methodInfo4) { if (methodInfo4 == methodInfo) { list[i].opcode = OpCodes.Call; list[i].operand = operand; } else if (methodInfo4 == methodInfo2) { list[i].opcode = OpCodes.Call; list[i].operand = operand2; } else if (methodInfo4 == methodInfo3) { list[i].opcode = OpCodes.Call; list[i].operand = operand3; } } } return list; } public static void CustomSfxStunnedLoop(EnemyFreddyAnim instance) { Traverse val = Traverse.Create((object)instance); Sound val2 = (val.Field("_sfxStunnedLoop").FieldExists() ? val.Field("_sfxStunnedLoop").GetValue<Sound>() : val.Field("sfxStunnedLoop").GetValue<Sound>()); bool flag = (val.Field("_stunned").FieldExists() ? val.Field("_stunned").GetValue<bool>() : val.Field("stunned").GetValue<bool>()); if (val2 != null) { val2.PlayLoop(flag, 5f, 5f, 1f, 1f); } } public static void CustomSfxHaywireLoop(EnemyFreddyAnim instance) { Traverse val = Traverse.Create((object)instance); Sound val2 = (val.Field("_sfxHaywireLoop").FieldExists() ? val.Field("_sfxHaywireLoop").GetValue<Sound>() : val.Field("sfxHaywireLoop").GetValue<Sound>()); bool flag = (val.Field("_haywiring").FieldExists() ? val.Field("_haywiring").GetValue<bool>() : val.Field("haywiring").GetValue<bool>()); if (val2 != null) { val2.PlayLoop(flag, 5f, 5f, 1f, 1f); } } public static void CustomSfxCloakedLoop(EnemyFreddyAnim instance) { Traverse val = Traverse.Create((object)instance); Sound val2 = (val.Field("_sfxCloakedLoop").FieldExists() ? val.Field("_sfxCloakedLoop").GetValue<Sound>() : val.Field("sfxCloakedLoop").GetValue<Sound>()); bool flag = (val.Field("_cloaked").FieldExists() ? val.Field("_cloaked").GetValue<bool>() : val.Field("cloaked").GetValue<bool>()); if (val2 != null) { val2.PlayLoop(flag, 5f, 5f, 1f, 1f); } } } }