using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BoneLib.BoneMenu; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.PuppetMasta; using InjuriesMod.Core; using InjuriesMod.Modules; using MelonLoader; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(ModClass), "Brain Injuries", "2.1.1", "PolskiAnt", "https://thunderstore.io/c/bonelab/p/PolskiAnt/BrainInjuries/")] [assembly: AssemblyTitle("Brain Injuries")] [assembly: AssemblyDescription("Adds a little realism to the game (PATCH 6)")] [assembly: MelonColor(255, 200, 30, 20)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("InjuriesMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("InjuriesMod")] [assembly: AssemblyVersion("1.0.0.0")] namespace InjuriesMod.Patches { [HarmonyPatch(typeof(SubBehaviourHealth), "TakeDamage")] public static class DamagePatch { private static readonly Random rnd = new Random(); public static void Prefix(SubBehaviourHealth __instance, int m, Attack attack) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Invalid comparison between Unknown and I4 //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Invalid comparison between Unknown and I4 //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Invalid comparison between Unknown and I4 //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Invalid comparison between Unknown and I4 //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Invalid comparison between Unknown and I4 //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Invalid comparison between Unknown and I4 if (__instance.muscles == null || m >= ((Il2CppArrayBase)(object)__instance.muscles).Count) { return; } PuppetMaster puppetMaster = ((SubBehaviourBase)__instance).behaviour.puppetMaster; if ((Object)(object)puppetMaster == (Object)null) { return; } if (DeathTracker.UnconsciousNPCs.Contains(((Il2CppObjectBase)puppetMaster).Pointer)) { float value; float num = (DeathTracker.UnconsciousStartTime.TryGetValue(((Il2CppObjectBase)puppetMaster).Pointer, out value) ? value : 0f); if (Time.time - num < 1f) { attack.damage = 0f; return; } float num2 = __instance.cur_hp - attack.damage; if (num2 <= 0f && !DeathTracker.AlreadyDead.Contains(((Il2CppObjectBase)puppetMaster).Pointer)) { puppetMaster.Kill(); } return; } StunGroup val = ((Il2CppArrayBase)(object)__instance.muscles)[m]; string text = ((object)(StunGroup)(ref val)).ToString(); if (!DeathTracker.PriorityDeathCause.ContainsKey(((Il2CppObjectBase)puppetMaster).Pointer)) { DeathTracker.LastHitBone[((Il2CppObjectBase)puppetMaster).Pointer] = ((text == "Head" && (int)attack.attackType != 2 && (int)attack.attackType != 1) ? "Unknown" : text); } if (text == "Head" && (int)attack.attackType == 2 && ModClass.HeadBluntResistEnabled) { attack.damage *= 0.7f; } if (text == "Head") { DeathTracker.LastAttackType[((Il2CppObjectBase)puppetMaster).Pointer] = attack.attackType; DeathTracker.LastAttackDamage[((Il2CppObjectBase)puppetMaster).Pointer] = attack.damage; if (attack.damage > 5f && ((int)attack.attackType == 2 || (int)attack.attackType == 1)) { DeathTracker.PriorityDeathCause[((Il2CppObjectBase)puppetMaster).Pointer] = "Head"; } if (attack.damage > 2f && attack.damage <= 5f && (int)attack.attackType == 2 && ModClass.UnconsciousEnabled && !DeathTracker.AlreadyDead.Contains(((Il2CppObjectBase)puppetMaster).Pointer) && !DeathTracker.UnconsciousNPCs.Contains(((Il2CppObjectBase)puppetMaster).Pointer) && rnd.Next(101) <= 75) { DeathTracker.UnconsciousNPCs.Add(((Il2CppObjectBase)puppetMaster).Pointer); DeathTracker.UnconsciousStartTime[((Il2CppObjectBase)puppetMaster).Pointer] = Time.time; MelonCoroutines.Start(ModuleD_Consciousness.Unconscious(puppetMaster)); } } if (text == "Spine" && ModClass.TorsoArmorEnabled) { attack.damage *= 0.5f; } } } [HarmonyPatch(typeof(PuppetMaster), "Kill", new Type[] { })] public static class DeathPatch { public static void Postfix(PuppetMaster __instance) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || DeathTracker.AlreadyDead.Contains(((Il2CppObjectBase)__instance).Pointer)) { return; } DeathTracker.AlreadyDead.Add(((Il2CppObjectBase)__instance).Pointer); string value; string value2; string text = (DeathTracker.PriorityDeathCause.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out value) ? value : ((!DeathTracker.LastHitBone.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out value2)) ? "Unknown" : value2)); if (!ModClass.BrainInjuriesEnabled) { text = "Disabled"; } if (DeathTracker.UnconsciousNPCs.Contains(((Il2CppObjectBase)__instance).Pointer)) { DeathTracker.ClearNPC(((Il2CppObjectBase)__instance).Pointer); ((MelonBase)ModClass.Instance).LoggerInstance.Msg("NPC died while unconscious."); return; } ((MelonBase)ModClass.Instance).LoggerInstance.Msg("NPC died | cause: " + text); if (!(text != "Head")) { AttackType value3; AttackType attackType = (AttackType)((!DeathTracker.LastAttackType.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out value3)) ? 64 : ((int)value3)); float value4; float damage = (DeathTracker.LastAttackDamage.TryGetValue(((Il2CppObjectBase)__instance).Pointer, out value4) ? value4 : 0f); MelonCoroutines.Start(ModuleA_Impact.HandleImpact(__instance, attackType, damage)); } } } [HarmonyPatch(typeof(PuppetMaster))] public static class PuppetMasterLifecyclePatches { [HarmonyPatch("OnDisable")] [HarmonyPrefix] public static void OnDisablePrefix(PuppetMaster __instance) { if ((Object)(object)__instance != (Object)null) { DeathTracker.ClearNPC(((Il2CppObjectBase)__instance).Pointer); } } [HarmonyPatch("OnDestroy")] [HarmonyPrefix] public static void OnDestroyPrefix(PuppetMaster __instance) { if ((Object)(object)__instance != (Object)null) { DeathTracker.ClearNPC(((Il2CppObjectBase)__instance).Pointer); } } } } namespace InjuriesMod.Modules { public static class ModuleA_Impact { public enum ImmediateReaction { TonicSpasm, Fencing, MuscleFailure, None, Hypotonia } [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; private float 5__1; private float 5__2; private float 5__3; private float 5__4; private Dictionary 5__5; private float 5__6; private float 5__7; private IEnumerator <>s__8; private Muscle 5__9; private string 5__10; private ConfigurableJoint 5__11; private bool 5__12; private Quaternion 5__13; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__5 = null; <>s__8 = null; 5__9 = null; 5__10 = null; 5__11 = null; <>1__state = -2; } private bool MoveNext() { //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_024b: 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) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 0.3f; 5__2 = 0.6f; 5__3 = 0.4f; 5__4 = 0f; 5__5 = PhysicsHelper.SaveMuscleWeights(puppet); break; case 1: <>1__state = -1; break; } if (5__4 < 5__1 + 5__2 + 5__3) { if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } 5__6 = PhysicsHelper.GetProgress(5__4, 5__1, 5__2, 5__3); 5__7 = PhysicsHelper.GetStrength(5__4, 5__1, 5__2, 5__3); <>s__8 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__8.MoveNext()) { 5__9 = <>s__8.Current; if (5__9 == null) { continue; } 5__10 = 5__9.name.ToLower(); 5__11 = ((Component)5__9.transform).GetComponent(); if ((Object)(object)5__11 == (Object)null) { continue; } 5__12 = 5__10.Contains("lf"); 5__13 = Quaternion.identity; if (5__10.Contains("elbow")) { 5__13 = (5__12 ? Quaternion.Euler(140f, 0f, 0f) : Quaternion.Euler(0f, 0f, 0f)); } else if (5__10.Contains("shoulder")) { 5__13 = (5__12 ? Quaternion.Euler(0f, 0f, 0f) : Quaternion.Euler(90f, 0f, -30f)); } else { if (!5__10.Contains("wrist")) { continue; } 5__13 = (5__12 ? Quaternion.Euler(60f, 0f, 0f) : Quaternion.Euler(-40f, 0f, 0f)); } 5__11.targetRotation = Quaternion.Slerp(Quaternion.identity, 5__13, 5__6); PhysicsHelper.SetJointDrive(5__11, 3000f * 5__7, 800f, 3000f); 5__9.props.muscleWeight = 5__7; 5__10 = null; 5__11 = null; 5__9 = null; } } finally { if (<>s__8 != null) { <>s__8.Dispose(); } } <>s__8 = null; 5__4 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } PhysicsHelper.RestoreAndResetJoints(puppet, 5__5); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; public AttackType attackType; public float damage; private float 5__1; private ImmediateReaction 5__2; private float 5__3; private float 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Invalid comparison between Unknown and I4 //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } 5__1 = 0f; 5__2 = ChooseImmediateReaction(attackType, damage); ((MelonBase)ModClass.Instance).LoggerInstance.Msg($"[ModuleA] Immediate: {5__2}"); if (!ModClass.BrainInjuriesEnabled) { 5__2 = ImmediateReaction.None; } <>2__current = MelonCoroutines.Start(RunImmediateReaction(puppet, 5__2)); <>1__state = 1; return true; case 1: <>1__state = -1; if (!ModClass.BrainInjuriesEnabled) { return false; } if (5__2 == ImmediateReaction.None && (int)attackType == 1) { 5__3 = 5f; if (DeathTracker.Rng.NextDouble() * 100.0 < (double)5__3) { ((MelonBase)ModClass.Instance).LoggerInstance.Msg($"Chance: {DeathTracker.Rng.NextDouble()}"); 5__4 = 7f + (float)DeathTracker.Rng.NextDouble() * 2f; <>2__current = (object)new WaitForSeconds(5__4); <>1__state = 2; return true; } } if (5__2 == ImmediateReaction.None || 5__2 == ImmediateReaction.MuscleFailure) { return false; } if (5__2 == ImmediateReaction.Fencing || 5__2 == ImmediateReaction.TonicSpasm) { 5__1 = 0.1f; } else { 5__1 = 1f; } <>2__current = (object)new WaitForSeconds(5__1); <>1__state = 4; return true; case 2: <>1__state = -1; if ((Object)(object)puppet != (Object)null && ((Il2CppObjectBase)puppet).Pointer != IntPtr.Zero) { <>2__current = MelonCoroutines.Start(Lazarus(puppet)); <>1__state = 3; return true; } goto IL_024a; case 3: <>1__state = -1; goto IL_024a; case 4: <>1__state = -1; <>2__current = MelonCoroutines.Start(ModuleB_Posturing.HandlePosturing(puppet, attackType, damage, 5__2)); <>1__state = 5; return true; case 5: { <>1__state = -1; return false; } IL_024a: return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; private float 5__1; private float 5__2; private float 5__3; private float 5__4; private Dictionary 5__5; private Quaternion 5__6; private Quaternion 5__7; private Quaternion 5__8; private Quaternion 5__9; private Quaternion 5__10; private Quaternion 5__11; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 0.4f; 5__2 = 0.2f; 5__3 = 0.3f; 5__4 = 0f; 5__5 = PhysicsHelper.SaveMuscleWeights(puppet); 5__6 = Quaternion.Euler(-90f, 0f, 0f); 5__7 = Quaternion.Euler(-85f, 0f, 0f); 5__8 = Quaternion.Euler(0f, 50f, 0f); 5__9 = Quaternion.Euler(90f, 0f, 0f); 5__10 = Quaternion.Euler(15f, 0f, 0f); 5__11 = Quaternion.Euler(10f, 0f, 0f); break; case 1: <>1__state = -1; break; } if (5__4 < 5__1 + 5__2 + 5__3) { if ((Object)(object)puppet == (Object)null) { return false; } PhysicsHelper.ApplyToSpine(puppet, PhysicsHelper.GetProgress(5__4, 5__1, 5__2, 5__3), PhysicsHelper.GetStrength(5__4, 5__1, 5__2, 5__3) * 1.3f, 5__6, 5__8, 5__7, 5__9); PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(5__4, 5__1, 5__2, 5__3), PhysicsHelper.GetStrength(5__4, 5__1, 5__2, 5__3) * 0.2f, Quaternion.identity, Quaternion.identity, Quaternion.identity, 5__10, 5__11, null, includeLegs: true, includeArms: false); 5__4 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } PhysicsHelper.RestoreAndResetJoints(puppet, 5__5); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; private float 5__1; private float 5__2; private float 5__3; private float 5__4; private Dictionary 5__5; private Quaternion 5__6; private Quaternion 5__7; private Quaternion 5__8; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 1f; 5__2 = 5f; 5__3 = 3f; 5__4 = 0f; 5__5 = PhysicsHelper.SaveMuscleWeights(puppet); 5__6 = Quaternion.Euler(130f, 0f, 0f); 5__7 = Quaternion.Euler(70f, 0f, 0f); 5__8 = Quaternion.Euler(40f, 0f, 20f); break; case 1: <>1__state = -1; break; } if (5__4 < 5__1 + 5__2 + 5__3) { if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(5__4, 5__1, 5__2, 5__3), PhysicsHelper.GetStrength(5__4, 5__1, 5__2, 5__3), 5__6, 5__7, 5__8, Quaternion.identity, Quaternion.identity, null, includeLegs: false); 5__4 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } PhysicsHelper.RestoreAndResetJoints(puppet, 5__5); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__9 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; private float 5__1; private float 5__2; private Dictionary 5__3; private Dictionary 5__4; private IEnumerator <>s__5; private Muscle 5__6; private ConfigurableJoint 5__7; private float 5__8; private IEnumerator <>s__9; private Muscle 5__10; private ConfigurableJoint 5__11; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__3 = null; 5__4 = null; <>s__5 = null; 5__6 = null; 5__7 = null; <>s__9 = null; 5__10 = null; 5__11 = null; <>1__state = -2; } private bool MoveNext() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 4f; 5__2 = 0f; 5__3 = PhysicsHelper.SaveMuscleWeights(puppet); 5__4 = new Dictionary(); <>s__5 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__5.MoveNext()) { 5__6 = <>s__5.Current; if (5__6 != null) { 5__3[5__6.name] = 5__6.props.muscleWeight; 5__7 = ((Component)5__6.transform).GetComponent(); if ((Object)(object)5__7 != (Object)null) { 5__4[5__6.name] = 5__7.slerpDrive; } 5__7 = null; 5__6 = null; } } } finally { if (<>s__5 != null) { <>s__5.Dispose(); } } <>s__5 = null; break; case 1: <>1__state = -1; break; } if (5__2 < 5__1) { if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } 5__8 = Mathf.Lerp(1f, 0f, 5__2 / 5__1); <>s__9 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__9.MoveNext()) { 5__10 = <>s__9.Current; if (5__10 != null) { 5__10.props.muscleWeight = 5__8 * 0.05f; 5__11 = ((Component)5__10.transform).GetComponent(); if (!((Object)(object)5__11 == (Object)null)) { PhysicsHelper.SetJointDrive(5__11, 100f * 5__8, 10f, 100f); 5__11 = null; 5__10 = null; } } } } finally { if (<>s__9 != null) { <>s__9.Dispose(); } } <>s__9 = null; 5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } PhysicsHelper.RestoreAndResetJoints(puppet, 5__3); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; public ImmediateReaction reaction; private ImmediateReaction <>s__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; ImmediateReaction immediateReaction = reaction; <>s__1 = immediateReaction; switch (<>s__1) { case ImmediateReaction.TonicSpasm: <>2__current = TonicSpasm(puppet); <>1__state = 1; return true; case ImmediateReaction.Fencing: <>2__current = Fencing(puppet); <>1__state = 2; return true; case ImmediateReaction.MuscleFailure: <>2__current = MuscleFailure(puppet); <>1__state = 3; return true; case ImmediateReaction.Hypotonia: <>2__current = Hypotonia(puppet); <>1__state = 4; return true; } break; } case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; case 3: <>1__state = -1; break; case 4: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; private float 5__1; private float 5__2; private float 5__3; private float 5__4; private Dictionary 5__5; private Quaternion 5__6; private Quaternion 5__7; private Quaternion 5__8; private Quaternion 5__9; private Quaternion 5__10; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 0.05f; 5__2 = 0.8f; 5__3 = 0.2f; 5__4 = 0f; 5__5 = PhysicsHelper.SaveMuscleWeights(puppet); 5__6 = Quaternion.Euler(-60f, 0f, 0f); 5__7 = Quaternion.Euler(-40f, 0f, 0f); 5__8 = Quaternion.Euler(-15f, 0f, -15f); 5__9 = Quaternion.Euler(15f, 0f, 0f); 5__10 = Quaternion.Euler(30f, 0f, 0f); break; case 1: <>1__state = -1; break; } if (5__4 < 5__1 + 5__2 + 5__3) { if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(5__4, 5__1, 5__2, 5__3), PhysicsHelper.GetStrength(5__4, 5__1, 5__2, 5__3) * 0.2f, 5__6, 5__7, 5__8, 5__9, 5__10); 5__4 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } PhysicsHelper.RestoreAndResetJoints(puppet, 5__5); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] public static IEnumerator HandleImpact(PuppetMaster puppet, AttackType attackType, float damage) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { puppet = puppet, attackType = attackType, damage = damage }; } private static ImmediateReaction ChooseImmediateReaction(AttackType attackType, float damage) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 if ((int)attackType == 1) { int[] baseWeights = new int[4] { 40, 10, 20, 30 }; return WeightedRandom(new ImmediateReaction[4] { ImmediateReaction.None, ImmediateReaction.MuscleFailure, ImmediateReaction.TonicSpasm, ImmediateReaction.Hypotonia }, baseWeights); } if ((int)attackType == 2) { if (damage >= 5f) { int[] baseWeights2 = new int[5] { 40, 30, 5, 15, 10 }; return WeightedRandom(new ImmediateReaction[5] { ImmediateReaction.TonicSpasm, ImmediateReaction.Fencing, ImmediateReaction.MuscleFailure, ImmediateReaction.None, ImmediateReaction.Hypotonia }, baseWeights2); } if (damage >= 2f) { int[] baseWeights3 = new int[5] { 20, 45, 10, 18, 7 }; return WeightedRandom(new ImmediateReaction[5] { ImmediateReaction.TonicSpasm, ImmediateReaction.Fencing, ImmediateReaction.MuscleFailure, ImmediateReaction.None, ImmediateReaction.Hypotonia }, baseWeights3); } int[] baseWeights4 = new int[5] { 10, 30, 20, 35, 5 }; return WeightedRandom(new ImmediateReaction[5] { ImmediateReaction.TonicSpasm, ImmediateReaction.Fencing, ImmediateReaction.MuscleFailure, ImmediateReaction.None, ImmediateReaction.Hypotonia }, baseWeights4); } int[] baseWeights5 = new int[4] { 30, 0, 60, 10 }; return WeightedRandom(new ImmediateReaction[4] { ImmediateReaction.MuscleFailure, ImmediateReaction.TonicSpasm, ImmediateReaction.None, ImmediateReaction.Hypotonia }, baseWeights5); } private static ImmediateReaction WeightedRandom(ImmediateReaction[] options, int[] baseWeights) { float num = 0f; float[] array = new float[options.Length]; for (int i = 0; i < options.Length; i++) { float multiplier = ModClass.GetMultiplier(ModClass.UserSettings[options[i]]); array[i] = (float)baseWeights[i] * multiplier; num += array[i]; } if (num <= 0f) { return ImmediateReaction.None; } double num2 = DeathTracker.Rng.NextDouble() * (double)num; float num3 = 0f; for (int j = 0; j < array.Length; j++) { num3 += array[j]; if (num2 < (double)num3) { return options[j]; } } return options[^1]; } [IteratorStateMachine(typeof(d__4))] private static IEnumerator RunImmediateReaction(PuppetMaster puppet, ImmediateReaction reaction) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { puppet = puppet, reaction = reaction }; } [IteratorStateMachine(typeof(d__5))] private static IEnumerator Hypotonia(PuppetMaster puppet) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { puppet = puppet }; } [IteratorStateMachine(typeof(d__6))] private static IEnumerator TonicSpasm(PuppetMaster puppet) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { puppet = puppet }; } [IteratorStateMachine(typeof(d__7))] private static IEnumerator Fencing(PuppetMaster puppet) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { puppet = puppet }; } [IteratorStateMachine(typeof(d__8))] private static IEnumerator Lazarus(PuppetMaster puppet) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { puppet = puppet }; } [IteratorStateMachine(typeof(d__9))] private static IEnumerator MuscleFailure(PuppetMaster puppet) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { puppet = puppet }; } } public static class ModuleB_Posturing { public enum PostureType { Decorticate, Decerebrate, Hemiplegic, None } [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; private float 5__1; private float 5__2; private float 5__3; private float 5__4; private Dictionary 5__5; private Quaternion 5__6; private Quaternion 5__7; private Quaternion 5__8; private Quaternion 5__9; private Quaternion 5__10; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__1 = 0.7f; 5__2 = 12f; 5__3 = 3f; 5__4 = 0f; 5__5 = PhysicsHelper.SaveMuscleWeights(puppet); 5__6 = Quaternion.Euler(-100f, 0f, 0f); 5__7 = Quaternion.Euler(-80f, 0f, 0f); 5__8 = Quaternion.Euler(-20f, 0f, -30f); 5__9 = Quaternion.Euler(20f, 0f, 0f); 5__10 = Quaternion.Euler(40f, 0f, 0f); break; case 2: <>1__state = -1; break; } if (5__4 < 5__1 + 5__2 + 5__3) { if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(5__4, 5__1, 5__2, 5__3), PhysicsHelper.GetStrength(5__4, 5__1, 5__2, 5__3), 5__6, 5__7, 5__8, 5__9, 5__10); 5__4 += Time.deltaTime; <>2__current = null; <>1__state = 2; return true; } PhysicsHelper.RestoreAndResetJoints(puppet, 5__5); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; private float 5__1; private float 5__2; private float 5__3; private float 5__4; private Dictionary 5__5; private Quaternion 5__6; private Quaternion 5__7; private Quaternion 5__8; private Quaternion 5__9; private Quaternion 5__10; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__1 = 1.5f; 5__2 = 10f; 5__3 = 2f; 5__4 = 0f; 5__5 = PhysicsHelper.SaveMuscleWeights(puppet); 5__6 = Quaternion.Euler(130f, 0f, 0f); 5__7 = Quaternion.Euler(70f, 0f, 0f); 5__8 = Quaternion.Euler(40f, 0f, 20f); 5__9 = Quaternion.Euler(-10f, 0f, 0f); 5__10 = Quaternion.Euler(-20f, 0f, 0f); break; case 2: <>1__state = -1; break; } if (5__4 < 5__1 + 5__2 + 5__3) { if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(5__4, 5__1, 5__2, 5__3), PhysicsHelper.GetStrength(5__4, 5__1, 5__2, 5__3), 5__6, 5__7, 5__8, 5__9, 5__10); 5__4 += Time.deltaTime; <>2__current = null; <>1__state = 2; return true; } PhysicsHelper.RestoreAndResetJoints(puppet, 5__5); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; public AttackType attackType; public float damage; public ModuleA_Impact.ImmediateReaction previousReaction; private float 5__1; private PostureType 5__2; private List 5__3; private float 5__4; private PostureType <>s__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: { <>1__state = -1; if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } if (1 == 0) { } float num = previousReaction switch { ModuleA_Impact.ImmediateReaction.Fencing => 75f, ModuleA_Impact.ImmediateReaction.TonicSpasm => 50f, ModuleA_Impact.ImmediateReaction.Hypotonia => 50f, _ => 0f, }; if (1 == 0) { } 5__1 = num; if (DeathTracker.Rng.NextDouble() * 100.0 > (double)5__1) { ((MelonBase)ModClass.Instance).LoggerInstance.Msg("[ModuleB] no posturing"); return false; } if (previousReaction == ModuleA_Impact.ImmediateReaction.MuscleFailure || previousReaction == ModuleA_Impact.ImmediateReaction.None) { return false; } if ((int)attackType == 2) { 5__4 = 20f; if (DeathTracker.Rng.NextDouble() * 100.0 < (double)5__4) { ModuleC_Seizures.Start(((Il2CppObjectBase)puppet).Pointer, 0.8f, Random.Range(5f, 10f)); } } 5__3 = new List(); if (previousReaction == ModuleA_Impact.ImmediateReaction.Fencing) { 5__3.Add(PostureType.Decorticate); 5__3.Add(PostureType.Hemiplegic); } else if (previousReaction == ModuleA_Impact.ImmediateReaction.TonicSpasm) { 5__3.Add(PostureType.Decerebrate); 5__3.Add(PostureType.Decorticate); } else { 5__3.Add(PostureType.Decerebrate); 5__3.Add(PostureType.Decorticate); 5__3.Add(PostureType.None); } 5__2 = WeightedRandomPosturing(5__3.ToArray()); ((MelonBase)ModClass.Instance).LoggerInstance.Msg($"[ModuleB] Posture: {5__2}"); PostureType postureType = 5__2; <>s__5 = postureType; switch (<>s__5) { case PostureType.Decorticate: <>2__current = Decorticate(puppet); <>1__state = 1; return true; case PostureType.Decerebrate: <>2__current = Decerebrate(puppet); <>1__state = 2; return true; case PostureType.Hemiplegic: <>2__current = Hemiplegic(puppet); <>1__state = 3; return true; case PostureType.None: return false; } break; } case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; case 3: <>1__state = -1; break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; private float 5__1; private float 5__2; private float 5__3; private float 5__4; private Dictionary 5__5; private Quaternion 5__6; private Quaternion 5__7; private Quaternion 5__8; private Quaternion 5__9; private Quaternion 5__10; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__1 = 1.5f; 5__2 = 10f; 5__3 = 2f; 5__4 = 0f; 5__5 = PhysicsHelper.SaveMuscleWeights(puppet); 5__6 = Quaternion.Euler(130f, 0f, 0f); 5__7 = Quaternion.Euler(70f, 0f, 0f); 5__8 = Quaternion.Euler(40f, 0f, 20f); 5__9 = Quaternion.Euler(-10f, 0f, 0f); 5__10 = Quaternion.Euler(-20f, 0f, 0f); break; case 2: <>1__state = -1; break; } if (5__4 < 5__1 + 5__2 + 5__3) { if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(5__4, 5__1, 5__2, 5__3), PhysicsHelper.GetStrength(5__4, 5__1, 5__2, 5__3), 5__6, 5__7, 5__8, 5__9, 5__10, "lf"); 5__4 += Time.deltaTime; <>2__current = null; <>1__state = 2; return true; } PhysicsHelper.RestoreAndResetJoints(puppet, 5__5); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] public static IEnumerator HandlePosturing(PuppetMaster puppet, AttackType attackType, float damage, ModuleA_Impact.ImmediateReaction previousReaction) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { puppet = puppet, attackType = attackType, damage = damage, previousReaction = previousReaction }; } private static PostureType WeightedRandomPosturing(PostureType[] options) { float num = 0f; float[] array = new float[options.Length]; for (int i = 0; i < options.Length; i++) { float multiplier = ModClass.GetMultiplier(ModClass.PosturingSettings[options[i]]); array[i] = 50f * multiplier; num += array[i]; } if (num <= 0f) { return PostureType.None; } double num2 = DeathTracker.Rng.NextDouble() * (double)num; float num3 = 0f; for (int j = 0; j < array.Length; j++) { num3 += array[j]; if (num2 < (double)num3) { return options[j]; } } return options[0]; } [IteratorStateMachine(typeof(d__3))] private static IEnumerator Decorticate(PuppetMaster puppet) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { puppet = puppet }; } [IteratorStateMachine(typeof(d__4))] private static IEnumerator Decerebrate(PuppetMaster puppet) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { puppet = puppet }; } [IteratorStateMachine(typeof(d__5))] private static IEnumerator Hemiplegic(PuppetMaster puppet) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { puppet = puppet }; } } internal class ModuleC_Seizures { public struct SeizureData { public float intensity; public float frequency; public float elapsed; public float duration; } private static readonly Dictionary _active = new Dictionary(); public static void Start(IntPtr ptr, float intensity, float duration) { if (ModClass.SeizuresEnabled) { _active[ptr] = new SeizureData { intensity = Mathf.Clamp01(intensity), frequency = Mathf.Lerp(3f, 8f, intensity) * 0.8f, elapsed = 0f, duration = duration }; ((MelonBase)ModClass.Instance).LoggerInstance.Msg($"[ModuleC] Seizure start | instensity: {intensity} | duration: {duration}"); } } public static void Tick(IntPtr ptr) { if (_active.TryGetValue(ptr, out var value)) { value.elapsed += Time.deltaTime; if (value.elapsed >= value.duration) { _active.Remove(ptr); MelonLogger.Msg("[ModuleC] Seizure ended"); } else { _active[ptr] = value; } } } public static void Stop(IntPtr ptr) { _active.Remove(ptr); } public static void Clear(IntPtr ptr) { _active.Remove(ptr); } public static bool IsActive(IntPtr ptr) { return _active.ContainsKey(ptr); } public static (float strengthMultiplier, float angleOffset) GetModifiers(IntPtr ptr, string muscleName) { if (!ModClass.SeizuresEnabled) { return (1f, 0f); } if (!_active.TryGetValue(ptr, out var value)) { return (1f, 0f); } float num = 1f - Mathf.Clamp01((value.elapsed - value.duration * 0.6f) / (value.duration * 0.4f)); float num2 = value.intensity * num; float num3 = (float)(muscleName.GetHashCode() % 100) * 0.063f; float item = 1f + num2 * 2f; float item2 = Mathf.Sin(value.elapsed * value.frequency * (float)Math.PI * 2f + num3) * 20f * num2; return (item, item2); } public static void ClearAll() { _active.Clear(); } } internal class ModuleD_Consciousness { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PuppetMaster puppet; public float duration; private IntPtr 5__1; private Transform 5__2; private BehaviourBaseNav 5__3; private AIBrain 5__4; private AIManager 5__5; private Animator 5__6; private Dictionary 5__7; private Dictionary 5__8; private float 5__9; private float 5__10; private IEnumerator <>s__11; private Muscle 5__12; private IEnumerator <>s__13; private Muscle 5__14; private IEnumerator <>s__15; private Muscle 5__16; private float 5__17; private float 5__18; private IEnumerator <>s__19; private Muscle 5__20; private float 5__21; private float 5__22; private float 5__23; private IEnumerator <>s__24; private Muscle 5__25; private float 5__26; private float 5__27; private IEnumerator <>s__28; private Muscle 5__29; private float 5__30; private float 5__31; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; 5__6 = null; 5__7 = null; 5__8 = null; <>s__11 = null; 5__12 = null; <>s__13 = null; 5__14 = null; <>s__15 = null; 5__16 = null; <>s__19 = null; 5__20 = null; <>s__24 = null; 5__25 = null; <>s__28 = null; 5__29 = null; <>1__state = -2; } private bool MoveNext() { //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Invalid comparison between Unknown and I4 //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } 5__1 = ((Il2CppObjectBase)puppet).Pointer; 5__2 = ((Component)puppet).transform.root; 5__3 = ((Component)5__2).GetComponentInChildren(); 5__4 = ((Component)5__2).GetComponentInChildren(); 5__5 = ((Component)5__2).GetComponentInChildren(); 5__6 = ((Component)5__2).GetComponentInChildren(); 5__7 = new Dictionary(); 5__8 = new Dictionary(); <>s__11 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__11.MoveNext()) { 5__12 = <>s__11.Current; 5__7[5__12.name] = 5__12._maxForce; 5__8[5__12.name] = 5__12.props.muscleWeight; 5__12 = null; } } finally { if (<>s__11 != null) { <>s__11.Dispose(); } } <>s__11 = null; <>s__13 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__13.MoveNext()) { 5__14 = <>s__13.Current; 5__14._maxForce = 5__7[5__14.name] * 0.08f; 5__14.props.muscleWeight = 5__8[5__14.name] * 0.08f; 5__14 = null; } } finally { if (<>s__13 != null) { <>s__13.Dispose(); } } <>s__13 = null; if ((Object)(object)5__6 != (Object)null) { ((Behaviour)5__6).enabled = false; } if ((Object)(object)5__4 != (Object)null && (Object)(object)5__4.behaviour != (Object)null) { 5__4.behaviour.mentalState = (MentalState)0; } ((MelonBase)ModClass.Instance).LoggerInstance.Msg("NPC unconcious!"); <>2__current = (object)new WaitForSeconds(duration); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { DeathTracker.UnconsciousNPCs.Remove(((Il2CppObjectBase)puppet).Pointer); DeathTracker.UnconsciousStartTime.Remove(((Il2CppObjectBase)puppet).Pointer); return false; } if (DeathTracker.AlreadyDead.Contains(((Il2CppObjectBase)puppet).Pointer)) { <>s__15 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__15.MoveNext()) { 5__16 = <>s__15.Current; if (5__7.TryGetValue(5__16.name, out 5__17)) { 5__16._maxForce = 5__17; } if (5__8.TryGetValue(5__16.name, out 5__18)) { 5__16.props.muscleWeight = 5__18; } 5__16 = null; } } finally { if (<>s__15 != null) { <>s__15.Dispose(); } } <>s__15 = null; DeathTracker.UnconsciousNPCs.Remove(((Il2CppObjectBase)puppet).Pointer); return false; } if ((int)puppet.state == 1) { DeathTracker.UnconsciousNPCs.Remove(((Il2CppObjectBase)puppet).Pointer); DeathTracker.UnconsciousStartTime.Remove(((Il2CppObjectBase)puppet).Pointer); return false; } <>s__19 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__19.MoveNext()) { 5__20 = <>s__19.Current; if (5__7.TryGetValue(5__20.name, out 5__21)) { 5__20._maxForce = 5__21; } if (5__8.TryGetValue(5__20.name, out 5__22)) { 5__20.props.muscleWeight = 5__22; } 5__20 = null; } } finally { if (<>s__19 != null) { <>s__19.Dispose(); } } <>s__19 = null; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; if ((Object)(object)5__6 != (Object)null) { ((Behaviour)5__6).enabled = true; } if ((Object)(object)5__4 != (Object)null) { ((Behaviour)5__4).enabled = true; } if ((Object)(object)5__3 != (Object)null) { 5__3.locoState = (LocoState)3; } 5__9 = 1f; 5__10 = 0f; break; case 3: <>1__state = -1; break; } if (5__10 < 5__9) { if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return false; } if (DeathTracker.AlreadyDead.Contains(((Il2CppObjectBase)puppet).Pointer)) { return false; } 5__23 = 5__10 / 5__9; <>s__24 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__24.MoveNext()) { 5__25 = <>s__24.Current; if (5__25 != null) { if (5__7.TryGetValue(5__25.name, out 5__26)) { 5__25._maxForce = Mathf.Lerp(0f, 5__26, 5__23); } if (5__8.TryGetValue(5__25.name, out 5__27)) { 5__25.props.muscleWeight = Mathf.Lerp(0f, 5__27, 5__23); } 5__25 = null; } } } finally { if (<>s__24 != null) { <>s__24.Dispose(); } } <>s__24 = null; 5__10 += Time.deltaTime; <>2__current = null; <>1__state = 3; return true; } <>s__28 = ((Il2CppArrayBase)(object)puppet.muscles).GetEnumerator(); try { while (<>s__28.MoveNext()) { 5__29 = <>s__28.Current; if (5__7.TryGetValue(5__29.name, out 5__30)) { 5__29._maxForce = 5__30; } if (5__8.TryGetValue(5__29.name, out 5__31)) { 5__29.props.muscleWeight = 5__31; } 5__29 = null; } } finally { if (<>s__28 != null) { <>s__28.Dispose(); } } <>s__28 = null; DeathTracker.UnconsciousNPCs.Remove(((Il2CppObjectBase)puppet).Pointer); DeathTracker.UnconsciousStartTime.Remove(((Il2CppObjectBase)puppet).Pointer); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] public static IEnumerator Unconscious(PuppetMaster puppet, float duration = 20f) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { puppet = puppet, duration = duration }; } } public static class PhysicsHelper { public static void SetJointDrive(ConfigurableJoint joint, float spring, float damper, float maxForce) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) JointDrive val = default(JointDrive); ((JointDrive)(ref val)).positionSpring = spring; ((JointDrive)(ref val)).positionDamper = damper; ((JointDrive)(ref val)).maximumForce = maxForce; JointDrive angularYZDrive = (joint.angularXDrive = (joint.slerpDrive = val)); joint.angularYZDrive = angularYZDrive; } public static void ApplyToSpine(PuppetMaster puppet, float progress, float strength, Quaternion spineRot, Quaternion headRot, Quaternion chestRot, Quaternion hipRot) { //IL_0054: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) foreach (Muscle item in (Il2CppArrayBase)(object)puppet.muscles) { if (item == null) { continue; } string text = item.name.ToLower(); ConfigurableJoint component = ((Component)item.transform).GetComponent(); if ((Object)(object)component == (Object)null) { continue; } Quaternion identity = Quaternion.identity; if (text.Contains("spine")) { identity = spineRot; } else if (text.Contains("chest")) { identity = chestRot; } else if (text.Contains("head")) { identity = headRot; } else { if (!text.Contains("hip")) { continue; } identity = hipRot; } component.targetRotation = Quaternion.Slerp(Quaternion.identity, identity, progress); SetJointDrive(component, 3000f * strength, 800f, 3000f); item.props.muscleWeight = strength; } } public static void ApplyToMuscles(PuppetMaster puppet, float progress, float strength, Quaternion elbowRot, Quaternion wristRot, Quaternion shoulderRot, Quaternion kneeRot, Quaternion ankleRot, string sideFilter = null, bool includeLegs = true, bool includeArms = true) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) ModuleC_Seizures.Tick(((Il2CppObjectBase)puppet).Pointer); foreach (Muscle item3 in (Il2CppArrayBase)(object)puppet.muscles) { if (item3 == null) { continue; } string text = item3.name.ToLower(); if (sideFilter != null && !text.Contains(sideFilter)) { continue; } ConfigurableJoint component = ((Component)item3.transform).GetComponent(); if ((Object)(object)component == (Object)null) { continue; } Quaternion identity = Quaternion.identity; bool flag = text.Contains("knee") || text.Contains("ankle") || text.Contains("hip"); bool flag2 = text.Contains("wrist") || text.Contains("shoulder") || text.Contains("elbow"); if ((flag && !includeLegs) || (flag2 && !includeArms)) { continue; } if (text.Contains("elbow")) { identity = elbowRot; } else if (text.Contains("wrist")) { identity = wristRot; } else if (text.Contains("shoulder")) { identity = shoulderRot; } else if (text.Contains("knee")) { identity = kneeRot; } else { if (!text.Contains("ankle")) { continue; } identity = ankleRot; } (float strengthMultiplier, float angleOffset) modifiers = ModuleC_Seizures.GetModifiers(((Il2CppObjectBase)puppet).Pointer, item3.name); float item = modifiers.strengthMultiplier; float item2 = modifiers.angleOffset; Quaternion val = Quaternion.Slerp(Quaternion.identity, identity, progress); val *= Quaternion.Euler(item2, 0f, 0f); component.targetRotation = val; SetJointDrive(component, 3000f * strength * item, 800f, 3000f); item3.props.muscleWeight = strength * item; } } public static float GetProgress(float e, float bs, float d, float rt) { return (e < bs) ? Mathf.Clamp01(e / bs) : 1f; } public static float GetStrength(float e, float bs, float d, float rt) { if (e < bs) { return Mathf.Clamp01(e / bs); } if (e < bs + d) { return 1f; } return 1f - Mathf.Clamp01((e - bs - d) / rt); } public static void RestoreAndResetJoints(PuppetMaster puppet, Dictionary originalWeights) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero) { return; } foreach (Muscle item in (Il2CppArrayBase)(object)puppet.muscles) { if (item != null) { if (originalWeights.TryGetValue(item.name, out var value)) { item.props.muscleWeight = value; } ConfigurableJoint component = ((Component)item.transform).GetComponent(); if (!((Object)(object)component == (Object)null)) { SetJointDrive(component, 0f, 0f, 0f); component.targetRotation = Quaternion.identity; } } } } public static Dictionary SaveMuscleWeights(PuppetMaster puppet) { Dictionary dictionary = new Dictionary(); foreach (Muscle item in (Il2CppArrayBase)(object)puppet.muscles) { if (item != null) { dictionary[item.name] = item.props.muscleWeight; } } return dictionary; } } } namespace InjuriesMod.Core { public static class DeathTracker { public static HashSet AlreadyDead = new HashSet(); public static HashSet UnconsciousNPCs = new HashSet(); public static Dictionary UnconsciousStartTime = new Dictionary(); public static Dictionary LastHitBone = new Dictionary(); public static Dictionary PriorityDeathCause = new Dictionary(); public static Dictionary LastAttackType = new Dictionary(); public static Dictionary LastAttackDamage = new Dictionary(); public static Random Rng = new Random(); public static void ClearNPC(IntPtr ptr) { if (!(ptr == IntPtr.Zero) && (AlreadyDead.Contains(ptr) || LastHitBone.ContainsKey(ptr) || UnconsciousNPCs.Contains(ptr) || LastAttackType.ContainsKey(ptr))) { ((MelonBase)ModClass.Instance).LoggerInstance.Msg($"Clearing NPC data (ptr: {ptr})"); ModuleC_Seizures.Clear(ptr); AlreadyDead.Remove(ptr); UnconsciousNPCs.Remove(ptr); UnconsciousStartTime.Remove(ptr); LastHitBone.Remove(ptr); PriorityDeathCause.Remove(ptr); LastAttackType.Remove(ptr); LastAttackDamage.Remove(ptr); } } public static void ClearAll() { AlreadyDead.Clear(); UnconsciousNPCs.Clear(); UnconsciousStartTime.Clear(); LastHitBone.Clear(); PriorityDeathCause.Clear(); LastAttackType.Clear(); LastAttackDamage.Clear(); } } public class ModClass : MelonMod { public enum FrequencyScale { None, Rare, Default, Common, Always } public static ModClass Instance; public static bool UnconsciousEnabled = false; public static bool BrainInjuriesEnabled = true; public static bool TorsoArmorEnabled = true; public static bool HeadBluntResistEnabled = true; public static bool SeizuresEnabled = true; public static Dictionary UserSettings = new Dictionary { { ModuleA_Impact.ImmediateReaction.Fencing, FrequencyScale.Default }, { ModuleA_Impact.ImmediateReaction.TonicSpasm, FrequencyScale.Default }, { ModuleA_Impact.ImmediateReaction.Hypotonia, FrequencyScale.Default }, { ModuleA_Impact.ImmediateReaction.None, FrequencyScale.Default }, { ModuleA_Impact.ImmediateReaction.MuscleFailure, FrequencyScale.Default } }; public static Dictionary PosturingSettings = new Dictionary { { ModuleB_Posturing.PostureType.Decorticate, FrequencyScale.Default }, { ModuleB_Posturing.PostureType.Decerebrate, FrequencyScale.Default }, { ModuleB_Posturing.PostureType.Hemiplegic, FrequencyScale.Default }, { ModuleB_Posturing.PostureType.None, FrequencyScale.Default } }; public override void OnInitializeMelon() { Harmony.CreateAndPatchAll(typeof(ModClass).Assembly, (string)null); SetupBoneMenu(); Instance = this; ((MelonBase)this).LoggerInstance.Msg("Mod loaded!"); } public static float GetMultiplier(FrequencyScale scale) { if (1 == 0) { } float result = scale switch { FrequencyScale.None => 0f, FrequencyScale.Rare => 0.5f, FrequencyScale.Default => 1f, FrequencyScale.Common => 2f, FrequencyScale.Always => 10f, _ => 1f, }; if (1 == 0) { } return result; } private static void SetupBoneMenu() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 0.988f, 0.729f); Color val3 = default(Color); ((Color)(ref val3))..ctor(1f, 0.25f, 0.25f); Page val4 = Page.Root.CreatePage("Brain Injuries", val3, 0, true); Page val5 = val4.CreatePage("GENERAL SETTINGS", val2, 0, true); val5.CreateBool("Knockouts / Unconscious", Color.cyan, false, (Action)delegate(bool v) { UnconsciousEnabled = v; }); val5.CreateBool("Brain Injuries", Color.yellow, true, (Action)delegate(bool v) { BrainInjuriesEnabled = v; }); val5.CreateBool("Seizures", Color.yellow, true, (Action)delegate(bool v) { SeizuresEnabled = v; if (!v) { ModuleC_Seizures.ClearAll(); } }); Page val6 = val4.CreatePage("DAMAGE RESISTANCE", val2, 0, true); val6.CreateBool("Reduced Torso Damage", Color.white, true, (Action)delegate(bool v) { TorsoArmorEnabled = v; }); val6.CreateBool("Reduced Blunt Head Damage", Color.white, true, (Action)delegate(bool v) { HeadBluntResistEnabled = v; }); Page val7 = val4.CreatePage("REACTION WEIGHTS", Color.yellow, 0, true); Page val8 = val7.CreatePage("IMMEDIATE REACTIONS", Color.white, 0, true); Page val9 = val7.CreatePage("POSTURING TYPES", Color.white, 0, true); foreach (ModuleA_Impact.ImmediateReaction reaction2 in UserSettings.Keys.ToList()) { val8.CreateEnum(reaction2.ToString(), Color.white, (Enum)UserSettings[reaction2], (Action)delegate(Enum val) { UserSettings[reaction2] = (FrequencyScale)(object)val; }); } foreach (ModuleB_Posturing.PostureType reaction in PosturingSettings.Keys.ToList()) { val9.CreateEnum(reaction.ToString(), Color.white, (Enum)PosturingSettings[reaction], (Action)delegate(Enum val) { PosturingSettings[reaction] = (FrequencyScale)(object)val; }); } val7.CreateFunction("RESTORE TO DEFAULT", Color.blue, (Action)delegate { foreach (ModuleA_Impact.ImmediateReaction item in UserSettings.Keys.ToList()) { UserSettings[item] = FrequencyScale.Default; } foreach (ModuleB_Posturing.PostureType item2 in PosturingSettings.Keys.ToList()) { PosturingSettings[item2] = FrequencyScale.Default; } MelonLogger.Msg("Restored settings (buttons will still show old values)"); }); } public override void OnSceneWasUnloaded(int buildIndex, string sceneName) { DeathTracker.ClearAll(); ((MelonBase)this).LoggerInstance.Msg("Scene cleared."); } } }