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 CodeRebirth.src.Content.Enemies; using EasyTextEffects.Editor.MyBoxCopy.Extensions; using GameNetcodeStuff; using LethalNetworkAPI; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On.GameNetcodeStuff; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; [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: IgnoresAccessChecksTo("CodeRebirth")] [assembly: AssemblyCompany("pseudopulse.VengefulMonarch")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+2681534e804ebd3b1af126b800ee846af49561e0")] [assembly: AssemblyProduct("VengefulMonarch")] [assembly: AssemblyTitle("pseudopulse.VengefulMonarch")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 VengefulMonarch { [BepInPlugin("pseudopulse.VengefulMonarch", "VengefulMonarch", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class VengefulMonarch : BaseUnityPlugin { public delegate PlayerControllerB? orig_GetClosestPlayerToMonarch(Monarch self, out float dist); [CompilerGenerated] private static class <>O { public static Manipulator <0>__DoAIIntervalMethodModifier; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action, CutieFlyAI, int, PlayerControllerB, bool, int> <>9__12_0; public static Action, Monarch> <>9__12_1; public static Action <>9__12_7; public static Action, Monarch> <>9__12_2; public static Action, Monarch> <>9__12_3; public static hook_KillPlayer <>9__12_4; public static Func <>9__12_8; public static Func <>9__12_9; public static Func <>9__12_12; public static Func <>9__12_11; public static Manipulator <>9__12_5; public static UnityAction <>9__12_6; internal void b__12_0(Action orig, CutieFlyAI self, int force, PlayerControllerB player, bool sfx, int hitID) { orig(self, force, player, sfx, hitID); if (!CutieflyKillers.Contains(player)) { CutieflyKillers.Add(player); UpdateMonarchList(); } } internal void b__12_1(Action orig, Monarch self) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown orig(self); List list = ((EnemyAI)self).enemyBehaviourStates.ToList(); list.Add(new EnemyBehaviourState { name = "Flee", playOneShotSFX = false, playOneShotVoice = false }); ((EnemyAI)self).enemyBehaviourStates = list.ToArray(); } internal void b__12_2(Action orig, Monarch self) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) bool flag = true; if ((Object)(object)((EnemyAI)self).targetPlayer != (Object)null && !CutieflyKillers.Contains(((EnemyAI)self).targetPlayer)) { ((EnemyAI)self).targetPlayer = null; } if (!self.isAttacking && CutieflyKillers.Count <= 0 && ((EnemyAI)self).currentBehaviourStateIndex != ((EnemyAI)self).enemyBehaviourStates.Length - 1) { ((EnemyAI)self).SwitchToBehaviourServerRpc(((EnemyAI)self).enemyBehaviourStates.Length - 1); MyCollections.ForEach((IEnumerable)self._cachedColliders, (Action)delegate(Collider x) { if (Object.op_Implicit((Object)(object)x) && !(x is CharacterController)) { x.enabled = false; } }); ((EnemyAI)self).agent.autoTraverseOffMeshLink = true; flag = false; } if (!self.isAttacking && ((EnemyAI)self).currentBehaviourStateIndex == ((EnemyAI)self).enemyBehaviourStates.Length - 1) { ((EnemyAI)self).creatureAnimator.SetBool(Monarch.IsFlyingAnimation, true); ((Behaviour)((EnemyAI)self).agent).enabled = false; ((EnemyAI)self).agent.updatePosition = false; ((EnemyAI)self).agent.updateRotation = false; ((EnemyAI)self).agent.updateUpAxis = false; if (((Component)self).transform.position.y > 200f && !((EnemyAI)self).isEnemyDead) { ((Component)((EnemyAI)self).creatureAnimator).gameObject.SetActive(false); ((EnemyAI)self).KillEnemy(true); } flag = false; } if (flag) { orig(self); } else { DoAIIntervalCaller((EnemyAI)(object)self); } } internal void b__12_7(Collider x) { if (Object.op_Implicit((Object)(object)x) && !(x is CharacterController)) { x.enabled = false; } } internal void b__12_3(Action orig, Monarch self) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) orig(self); if (((NetworkBehaviour)self).IsServer && ((EnemyAI)self).currentBehaviourStateIndex == ((EnemyAI)self).enemyBehaviourStates.Length - 1 && !self.isAttacking) { ((Component)self).transform.position = ((Component)self).transform.position + Vector3.up * 15f * Time.deltaTime; } } internal void b__12_4(orig_KillPlayer orig, PlayerControllerB self, Vector3 vel, bool spawnBody, CauseOfDeath source, int anim, Vector3 pos, bool drop) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, vel, spawnBody, source, anim, pos, drop); if (CutieflyKillers.Contains(self)) { CutieflyKillers.Remove(self); UpdateMonarchList(); } } internal void b__12_5(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass12_0 CS$<>8__locals0 = new <>c__DisplayClass12_0(); ILCursor val = new ILCursor(il); CS$<>8__locals0.loc = -1; MethodReference val3 = default(MethodReference); FieldReference val2 = default(FieldReference); val.TryGotoNext((MoveType)2, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val3), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val2), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref CS$<>8__locals0.loc) }); val.EmitDelegate>((Func)(() => CutieflyKillers.Where((PlayerControllerB x) => (Object)(object)x != (Object)null).ToArray())); val.Emit(OpCodes.Stloc, CS$<>8__locals0.loc); } internal bool b__12_8(Instruction x) { MethodReference val = default(MethodReference); return ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val); } internal bool b__12_9(Instruction x) { FieldReference val = default(FieldReference); return ILPatternMatchingExt.MatchLdfld(x, ref val); } internal PlayerControllerB[] b__12_11() { return CutieflyKillers.Where((PlayerControllerB x) => (Object)(object)x != (Object)null).ToArray(); } internal bool b__12_12(PlayerControllerB x) { return (Object)(object)x != (Object)null; } internal void b__12_6(Scene o, Scene n) { CutieflyKillers.Clear(); } } [CompilerGenerated] private sealed class <>c__DisplayClass12_0 { public int loc; internal bool b__10(Instruction x) { return ILPatternMatchingExt.MatchStloc(x, ref loc); } } public static List CutieflyKillers = new List(); public static BindingFlags FLAGS = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public static LNetworkMessage SyncMonarchList; public static VengefulMonarch Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; private void Awake() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Action action = ClientReceivedMessage; SyncMonarchList = LNetworkMessage.Connect("VMSyncMonarchList", (Action)ServerReceivedMessage, action, (Action)null); new Hook((MethodBase)typeof(CutieFlyAI).GetMethod("HitEnemy", FLAGS), (Delegate)(Action, CutieFlyAI, int, PlayerControllerB, bool, int>)delegate(Action orig, CutieFlyAI self, int force, PlayerControllerB player, bool sfx, int hitID) { orig(self, force, player, sfx, hitID); if (!CutieflyKillers.Contains(player)) { CutieflyKillers.Add(player); UpdateMonarchList(); } }); new Hook((MethodBase)typeof(Monarch).GetMethod("Awake", FLAGS), (Delegate)(Action, Monarch>)delegate(Action orig, Monarch self) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown orig(self); List list = ((EnemyAI)self).enemyBehaviourStates.ToList(); list.Add(new EnemyBehaviourState { name = "Flee", playOneShotSFX = false, playOneShotVoice = false }); ((EnemyAI)self).enemyBehaviourStates = list.ToArray(); }); new Hook((MethodBase)typeof(Monarch).GetMethod("DoAIInterval", FLAGS), (Delegate)(Action, Monarch>)delegate(Action orig, Monarch self) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) bool flag = true; if ((Object)(object)((EnemyAI)self).targetPlayer != (Object)null && !CutieflyKillers.Contains(((EnemyAI)self).targetPlayer)) { ((EnemyAI)self).targetPlayer = null; } if (!self.isAttacking && CutieflyKillers.Count <= 0 && ((EnemyAI)self).currentBehaviourStateIndex != ((EnemyAI)self).enemyBehaviourStates.Length - 1) { ((EnemyAI)self).SwitchToBehaviourServerRpc(((EnemyAI)self).enemyBehaviourStates.Length - 1); MyCollections.ForEach((IEnumerable)self._cachedColliders, (Action)delegate(Collider x) { if (Object.op_Implicit((Object)(object)x) && !(x is CharacterController)) { x.enabled = false; } }); ((EnemyAI)self).agent.autoTraverseOffMeshLink = true; flag = false; } if (!self.isAttacking && ((EnemyAI)self).currentBehaviourStateIndex == ((EnemyAI)self).enemyBehaviourStates.Length - 1) { ((EnemyAI)self).creatureAnimator.SetBool(Monarch.IsFlyingAnimation, true); ((Behaviour)((EnemyAI)self).agent).enabled = false; ((EnemyAI)self).agent.updatePosition = false; ((EnemyAI)self).agent.updateRotation = false; ((EnemyAI)self).agent.updateUpAxis = false; if (((Component)self).transform.position.y > 200f && !((EnemyAI)self).isEnemyDead) { ((Component)((EnemyAI)self).creatureAnimator).gameObject.SetActive(false); ((EnemyAI)self).KillEnemy(true); } flag = false; } if (flag) { orig(self); } else { DoAIIntervalCaller((EnemyAI)(object)self); } }); new Hook((MethodBase)typeof(Monarch).GetMethod("Update", FLAGS), (Delegate)(Action, Monarch>)delegate(Action orig, Monarch self) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) orig(self); if (((NetworkBehaviour)self).IsServer && ((EnemyAI)self).currentBehaviourStateIndex == ((EnemyAI)self).enemyBehaviourStates.Length - 1 && !self.isAttacking) { ((Component)self).transform.position = ((Component)self).transform.position + Vector3.up * 15f * Time.deltaTime; } }); object obj = <>c.<>9__12_4; if (obj == null) { hook_KillPlayer val = delegate(orig_KillPlayer orig, PlayerControllerB self, Vector3 vel, bool spawnBody, CauseOfDeath source, int anim, Vector3 pos, bool drop) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, vel, spawnBody, source, anim, pos, drop); if (CutieflyKillers.Contains(self)) { CutieflyKillers.Remove(self); UpdateMonarchList(); } }; <>c.<>9__12_4 = val; obj = (object)val; } PlayerControllerB.KillPlayer += (hook_KillPlayer)obj; MethodInfo? method = typeof(Monarch).GetMethod("GetClosestPlayerToMonarch", FLAGS); object obj2 = <>c.<>9__12_5; if (obj2 == null) { Manipulator val2 = delegate(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) ILCursor val4 = new ILCursor(il); int loc = -1; MethodReference val6 = default(MethodReference); FieldReference val5 = default(FieldReference); val4.TryGotoNext((MoveType)2, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val6), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val5), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc) }); val4.EmitDelegate>((Func)(() => CutieflyKillers.Where((PlayerControllerB x) => (Object)(object)x != (Object)null).ToArray())); val4.Emit(OpCodes.Stloc, loc); }; <>c.<>9__12_5 = val2; obj2 = (object)val2; } new ILHook((MethodBase)method, (Manipulator)obj2); MethodInfo? method2 = typeof(VengefulMonarch).GetMethod("DoAIIntervalCaller", FLAGS); object obj3 = <>O.<0>__DoAIIntervalMethodModifier; if (obj3 == null) { Manipulator val3 = DoAIIntervalMethodModifier; <>O.<0>__DoAIIntervalMethodModifier = val3; obj3 = (object)val3; } new ILHook((MethodBase)method2, (Manipulator)obj3); SceneManager.activeSceneChanged += delegate { CutieflyKillers.Clear(); }; } private void ServerReceivedMessage(int[] arg1, ulong arg2) { UpdateMonarchListInternal(arg1); } private void ClientReceivedMessage(int[] obj) { UpdateMonarchListInternal(obj); } private static void UpdateMonarchList() { List list = new List(); foreach (PlayerControllerB cutieflyKiller in CutieflyKillers) { list.Add((int)cutieflyKiller.playerClientId); } SyncMonarchList.SendOtherClients(list.ToArray()); if (Object.op_Implicit((Object)(object)NetworkManager.Singleton) && !NetworkManager.Singleton.IsServer) { SyncMonarchList.SendServer(list.ToArray()); } } private static void UpdateMonarchListInternal(int[] ids) { if (!Object.op_Implicit((Object)(object)StartOfRound.Instance)) { return; } CutieflyKillers.Clear(); foreach (int num in ids) { if (num < StartOfRound.Instance.allPlayerScripts.Length) { CutieflyKillers.Add(StartOfRound.Instance.allPlayerScripts[num]); } } } private static void DoAIIntervalCaller(EnemyAI self) { } private static void DoAIIntervalMethodModifier(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Call, (MethodBase)typeof(EnemyAI).GetMethod("DoAIInterval", FLAGS)); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "pseudopulse.VengefulMonarch"; public const string PLUGIN_NAME = "VengefulMonarch"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }