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 Maximum Cope v1.0.2
Maximum_Cope.dll
Decompiled 2 years agousing 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 EntityStates; using IL.EntityStates; using IL.EntityStates.GoldGat; using Maximum_Cope.TimeTrackers; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.EntityStates; using On.RoR2; using On.RoR2.CharacterAI; using RoR2; using RoR2.CharacterAI; 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("Maximum_Cope")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+07443701fbc472daf663d7e7586ac1ae877ce243")] [assembly: AssemblyProduct("Maximum_Cope")] [assembly: AssemblyTitle("Maximum_Cope")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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; } } } namespace Maximum_Cope { [BepInPlugin("com.Moffein.MaximumCope", "Maximum Cope", "1.0.0")] public class MaximumCopePlugin : BaseUnityPlugin { private void Awake() { EntityStateTimeTracker.Init(); BaseAITimeTracker.Init(); HealthComponentTimeTracker.Init(); GenericSkillTimeTracker.Init(); EntityStateMachineTimeTracker.Init(); } } } namespace Maximum_Cope.TimeTrackers { public static class BaseAITimeTracker { public static Dictionary<BaseAI, float> lastUpdateDict = new Dictionary<BaseAI, float>(); internal static void Init() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown Stage.onStageStartGlobal += ClearNullEntries; BaseAI.Awake += new hook_Awake(BaseAI_Awake); BaseAI.OnDestroy += new hook_OnDestroy(BaseAI_OnDestroy); BaseAI.ManagedFixedUpdate += new hook_ManagedFixedUpdate(BaseAI_ManagedFixedUpdate); } private static void BaseAI_ManagedFixedUpdate(orig_ManagedFixedUpdate orig, BaseAI self, float deltaTime) { if (lastUpdateDict.TryGetValue(self, out var value)) { deltaTime = Time.time - value; lastUpdateDict[self] = Time.time; } orig.Invoke(self, deltaTime); } private static void ClearNullEntries(Stage obj) { lastUpdateDict = lastUpdateDict.Where<KeyValuePair<BaseAI, float>>(delegate(KeyValuePair<BaseAI, float> kv) { KeyValuePair<BaseAI, float> keyValuePair = kv; return (Object)(object)keyValuePair.Key != (Object)null; }).ToDictionary((KeyValuePair<BaseAI, float> kv) => kv.Key, (KeyValuePair<BaseAI, float> kv) => kv.Value); } private static void BaseAI_Awake(orig_Awake orig, BaseAI self) { lastUpdateDict.Add(self, Time.time); orig.Invoke(self); } private static void BaseAI_OnDestroy(orig_OnDestroy orig, BaseAI self) { orig.Invoke(self); lastUpdateDict.Remove(self); } } public static class EntityStateMachineTimeTracker { public static Dictionary<EntityStateMachine, float> lastUpdateDict = new Dictionary<EntityStateMachine, float>(); internal static void Init() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown EntityStateMachine.ManagedFixedUpdate += new hook_ManagedFixedUpdate(EntityStateMachine_ManagedFixedUpdate); Stage.onStageStartGlobal += ClearNullEntries; EntityStateMachine.Awake += new hook_Awake(EntityStateMachine_Awake); EntityStateMachine.OnDestroy += new hook_OnDestroy(EntityStateMachine_OnDestroy); } private static void EntityStateMachine_ManagedFixedUpdate(orig_ManagedFixedUpdate orig, EntityStateMachine self, float deltaTime) { if (lastUpdateDict.TryGetValue(self, out var value)) { deltaTime = Time.time - value; lastUpdateDict[self] = Time.time; } orig.Invoke(self, deltaTime); } private static void ClearNullEntries(Stage obj) { lastUpdateDict = lastUpdateDict.Where<KeyValuePair<EntityStateMachine, float>>(delegate(KeyValuePair<EntityStateMachine, float> kv) { KeyValuePair<EntityStateMachine, float> keyValuePair = kv; return (Object)(object)keyValuePair.Key != (Object)null; }).ToDictionary((KeyValuePair<EntityStateMachine, float> kv) => kv.Key, (KeyValuePair<EntityStateMachine, float> kv) => kv.Value); } private static void EntityStateMachine_Awake(orig_Awake orig, EntityStateMachine self) { lastUpdateDict.Add(self, Time.time); orig.Invoke(self); } private static void EntityStateMachine_OnDestroy(orig_OnDestroy orig, EntityStateMachine self) { orig.Invoke(self); lastUpdateDict.Remove(self); } } public static class EntityStateTimeTracker { public static Dictionary<EntityState, float> lastUpdateDict = new Dictionary<EntityState, float>(); public static Dictionary<EntityState, float> lastFixedUpdateDict = new Dictionary<EntityState, float>(); private const float frameTimeDefault = 1f / 60f; internal static void Init() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown EntityState.GetDeltaTime += new hook_GetDeltaTime(EntityState_GetDeltaTime); EntityState.FixedUpdate += new hook_FixedUpdate(EntityState_FixedUpdate); EntityState.Update += new hook_Update(EntityState_Update); Stage.onStageStartGlobal += ClearNullEntries; EntityState.OnEnter += new hook_OnEnter(EntityState_OnEnter); EntityState.OnExit += new hook_OnExit(EntityState_OnExit); BaseCharacterMain.UpdateAnimationParameters += new Manipulator(BaseCharacterMain_UpdateAnimationParameters); GoldGatFire.Update += new Manipulator(ConvertToDeltaTime); GoldGatIdle.Update += new Manipulator(ConvertToDeltaTime); } private static void BaseCharacterMain_UpdateAnimationParameters(ILContext il) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) bool flag = true; ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(EntityState), "GetDeltaTime") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<float, EntityState, float>>((Func<float, EntityState, float>)delegate(float deltaTime, EntityState self) { if (lastUpdateDict.TryGetValue(self, out var value4)) { float num4 = Time.time - value4; if (num4 > 0f) { deltaTime = num4; } } return deltaTime; }); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(Time), "get_deltaTime") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<float, EntityState, float>>((Func<float, EntityState, float>)delegate(float deltaTime, EntityState self) { if (lastUpdateDict.TryGetValue(self, out var value3)) { float num3 = Time.time - value3; if (num3 > 0f) { deltaTime = num3; } } return deltaTime; }); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(Time), "get_deltaTime") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<float, EntityState, float>>((Func<float, EntityState, float>)delegate(float deltaTime, EntityState self) { if (lastUpdateDict.TryGetValue(self, out var value2)) { float num2 = Time.time - value2; if (num2 > 0f) { deltaTime = num2; } } return deltaTime; }); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(Time), "get_deltaTime") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<float, EntityState, float>>((Func<float, EntityState, float>)delegate(float deltaTime, EntityState self) { if (lastUpdateDict.TryGetValue(self, out var value)) { float num = Time.time - value; if (num > 0f) { deltaTime = num; } } return deltaTime; }); flag = false; } } } } if (flag) { Debug.LogError((object)"Maximum Cope: Failed to IL Hook BaseCharacterMain_UpdateAnimationParameters"); } } private static void ConvertToDeltaTime(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(EntityState), "GetDeltaTime") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<float, EntityState, float>>((Func<float, EntityState, float>)delegate(float deltaTime, EntityState self) { if (lastUpdateDict.TryGetValue(self, out var value)) { float num = Time.time - value; if (num > 0f) { deltaTime = num; } } return deltaTime; }); } else { Debug.LogError((object)"Maximum Cope: Failed to IL Hook ConvertToDeltaTime"); } } private static float EntityState_GetDeltaTime(orig_GetDeltaTime orig, EntityState self) { if (lastFixedUpdateDict.TryGetValue(self, out var value)) { float num = Time.time - value; if (num <= 0f) { num = 1f / 60f; } } return orig.Invoke(self); } private static void EntityState_FixedUpdate(orig_FixedUpdate orig, EntityState self) { float num = Time.fixedDeltaTime; if (lastFixedUpdateDict.TryGetValue(self, out var value)) { num = Time.time - value; lastFixedUpdateDict[self] = Time.time; } self.fixedAge += num; } private static void EntityState_Update(orig_Update orig, EntityState self) { float num = Time.deltaTime; if (lastUpdateDict.TryGetValue(self, out var value)) { num = Time.time - value; lastUpdateDict[self] = Time.time; } self.age += num; } private static void ClearNullEntries(Stage obj) { lastUpdateDict = lastUpdateDict.Where<KeyValuePair<EntityState, float>>(delegate(KeyValuePair<EntityState, float> kv) { KeyValuePair<EntityState, float> keyValuePair2 = kv; return keyValuePair2.Key != null; }).ToDictionary((KeyValuePair<EntityState, float> kv) => kv.Key, (KeyValuePair<EntityState, float> kv) => kv.Value); lastFixedUpdateDict = lastFixedUpdateDict.Where<KeyValuePair<EntityState, float>>(delegate(KeyValuePair<EntityState, float> kv) { KeyValuePair<EntityState, float> keyValuePair = kv; return keyValuePair.Key != null; }).ToDictionary((KeyValuePair<EntityState, float> kv) => kv.Key, (KeyValuePair<EntityState, float> kv) => kv.Value); } private static void EntityState_OnExit(orig_OnExit orig, EntityState self) { orig.Invoke(self); lastUpdateDict.Remove(self); lastFixedUpdateDict.Remove(self); } private static void EntityState_OnEnter(orig_OnEnter orig, EntityState self) { lastUpdateDict.Add(self, Time.time); lastFixedUpdateDict.Add(self, Time.time); orig.Invoke(self); } } public static class GenericSkillTimeTracker { public static Dictionary<GenericSkill, float> lastUpdateDict = new Dictionary<GenericSkill, float>(); internal static void Init() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GenericSkill.ManagedFixedUpdate += new hook_ManagedFixedUpdate(GenericSkill_ManagedFixedUpdate); GenericSkill.Awake += new hook_Awake(GenericSkill_Awake); GenericSkill.OnDestroy += new hook_OnDestroy(GenericSkill_OnDestroy); Stage.onStageStartGlobal += ClearNullEntries; } private static void GenericSkill_ManagedFixedUpdate(orig_ManagedFixedUpdate orig, GenericSkill self, float deltaTime) { if (lastUpdateDict.TryGetValue(self, out var value)) { deltaTime = Time.time - value; lastUpdateDict[self] = Time.time; } orig.Invoke(self, deltaTime); } private static void ClearNullEntries(Stage obj) { lastUpdateDict = lastUpdateDict.Where<KeyValuePair<GenericSkill, float>>(delegate(KeyValuePair<GenericSkill, float> kv) { KeyValuePair<GenericSkill, float> keyValuePair = kv; return (Object)(object)keyValuePair.Key != (Object)null; }).ToDictionary((KeyValuePair<GenericSkill, float> kv) => kv.Key, (KeyValuePair<GenericSkill, float> kv) => kv.Value); } private static void GenericSkill_Awake(orig_Awake orig, GenericSkill self) { lastUpdateDict.Add(self, Time.time); orig.Invoke(self); } private static void GenericSkill_OnDestroy(orig_OnDestroy orig, GenericSkill self) { orig.Invoke(self); lastUpdateDict.Remove(self); } } public static class HealthComponentTimeTracker { public static Dictionary<HealthComponent, float> lastUpdateDict = new Dictionary<HealthComponent, float>(); internal static void Init() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown HealthComponent.ManagedFixedUpdate += new hook_ManagedFixedUpdate(HealthComponent_ManagedFixedUpdate); HealthComponent.Awake += new hook_Awake(HealthComponent_Awake); HealthComponent.OnDestroy += new hook_OnDestroy(HealthComponent_OnDestroy); Stage.onStageStartGlobal += ClearNullEntries; } private static void HealthComponent_ManagedFixedUpdate(orig_ManagedFixedUpdate orig, HealthComponent self, float deltaTime) { if (lastUpdateDict.TryGetValue(self, out var value)) { deltaTime = Time.time - value; lastUpdateDict[self] = Time.time; } orig.Invoke(self, deltaTime); } private static void ClearNullEntries(Stage obj) { lastUpdateDict = lastUpdateDict.Where<KeyValuePair<HealthComponent, float>>(delegate(KeyValuePair<HealthComponent, float> kv) { KeyValuePair<HealthComponent, float> keyValuePair = kv; return (Object)(object)keyValuePair.Key != (Object)null; }).ToDictionary((KeyValuePair<HealthComponent, float> kv) => kv.Key, (KeyValuePair<HealthComponent, float> kv) => kv.Value); } private static void HealthComponent_Awake(orig_Awake orig, HealthComponent self) { lastUpdateDict.Add(self, Time.time); orig.Invoke(self); } private static void HealthComponent_OnDestroy(orig_OnDestroy orig, HealthComponent self) { orig.Invoke(self); lastUpdateDict.Remove(self); } } } namespace R2API.Utils { [AttributeUsage(AttributeTargets.Assembly)] public class ManualNetworkRegistrationAttribute : Attribute { } }