Decompiled source of BrainInjuries v2.0.0

Mods/InjuriesMod.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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.0.0", "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<StunGroup>)(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<StunGroup>)(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 <Fencing>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			private float <bs>5__1;

			private float <d>5__2;

			private float <rt>5__3;

			private float <e>5__4;

			private Dictionary<string, float> <originalWeights>5__5;

			private float <progress>5__6;

			private float <strength>5__7;

			private IEnumerator<Muscle> <>s__8;

			private Muscle <muscle>5__9;

			private string <name>5__10;

			private ConfigurableJoint <joint>5__11;

			private bool <isLeft>5__12;

			private Quaternion <target>5__13;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Fencing>d__7(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<originalWeights>5__5 = null;
				<>s__8 = null;
				<muscle>5__9 = null;
				<name>5__10 = null;
				<joint>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;
					<bs>5__1 = 0.3f;
					<d>5__2 = 0.6f;
					<rt>5__3 = 0.4f;
					<e>5__4 = 0f;
					<originalWeights>5__5 = PhysicsHelper.SaveMuscleWeights(puppet);
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<e>5__4 < <bs>5__1 + <d>5__2 + <rt>5__3)
				{
					if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero)
					{
						return false;
					}
					<progress>5__6 = PhysicsHelper.GetProgress(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3);
					<strength>5__7 = PhysicsHelper.GetStrength(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3);
					<>s__8 = ((Il2CppArrayBase<Muscle>)(object)puppet.muscles).GetEnumerator();
					try
					{
						while (<>s__8.MoveNext())
						{
							<muscle>5__9 = <>s__8.Current;
							if (<muscle>5__9 == null)
							{
								continue;
							}
							<name>5__10 = <muscle>5__9.name.ToLower();
							<joint>5__11 = ((Component)<muscle>5__9.transform).GetComponent<ConfigurableJoint>();
							if ((Object)(object)<joint>5__11 == (Object)null)
							{
								continue;
							}
							<isLeft>5__12 = <name>5__10.Contains("lf");
							<target>5__13 = Quaternion.identity;
							if (<name>5__10.Contains("elbow"))
							{
								<target>5__13 = (<isLeft>5__12 ? Quaternion.Euler(140f, 0f, 0f) : Quaternion.Euler(0f, 0f, 0f));
							}
							else if (<name>5__10.Contains("shoulder"))
							{
								<target>5__13 = (<isLeft>5__12 ? Quaternion.Euler(0f, 0f, 0f) : Quaternion.Euler(90f, 0f, -30f));
							}
							else
							{
								if (!<name>5__10.Contains("wrist"))
								{
									continue;
								}
								<target>5__13 = (<isLeft>5__12 ? Quaternion.Euler(60f, 0f, 0f) : Quaternion.Euler(-40f, 0f, 0f));
							}
							<joint>5__11.targetRotation = Quaternion.Slerp(Quaternion.identity, <target>5__13, <progress>5__6);
							PhysicsHelper.SetJointDrive(<joint>5__11, 3000f * <strength>5__7, 800f, 3000f);
							<muscle>5__9.props.muscleWeight = <strength>5__7;
							<name>5__10 = null;
							<joint>5__11 = null;
							<muscle>5__9 = null;
						}
					}
					finally
					{
						if (<>s__8 != null)
						{
							<>s__8.Dispose();
						}
					}
					<>s__8 = null;
					<e>5__4 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				PhysicsHelper.RestoreAndResetJoints(puppet, <originalWeights>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 <HandleImpact>d__0 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			public AttackType attackType;

			public float damage;

			private float <waitTime>5__1;

			private ImmediateReaction <immediateReaction>5__2;

			private float <lazarusChance>5__3;

			private float <delay>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <HandleImpact>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;
					}
					<waitTime>5__1 = 0f;
					<immediateReaction>5__2 = ChooseImmediateReaction(attackType, damage);
					((MelonBase)ModClass.Instance).LoggerInstance.Msg($"[ModuleA] Immediate: {<immediateReaction>5__2}");
					if (!ModClass.BrainInjuriesEnabled)
					{
						<immediateReaction>5__2 = ImmediateReaction.None;
					}
					<>2__current = MelonCoroutines.Start(RunImmediateReaction(puppet, <immediateReaction>5__2));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!ModClass.BrainInjuriesEnabled)
					{
						return false;
					}
					if (<immediateReaction>5__2 == ImmediateReaction.None && (int)attackType == 1)
					{
						<lazarusChance>5__3 = 5f;
						if (DeathTracker.Rng.NextDouble() * 100.0 < (double)<lazarusChance>5__3)
						{
							((MelonBase)ModClass.Instance).LoggerInstance.Msg($"Chance: {DeathTracker.Rng.NextDouble()}");
							<delay>5__4 = 7f + (float)DeathTracker.Rng.NextDouble() * 2f;
							<>2__current = (object)new WaitForSeconds(<delay>5__4);
							<>1__state = 2;
							return true;
						}
					}
					if (<immediateReaction>5__2 == ImmediateReaction.None || <immediateReaction>5__2 == ImmediateReaction.MuscleFailure)
					{
						return false;
					}
					if (<immediateReaction>5__2 == ImmediateReaction.Fencing || <immediateReaction>5__2 == ImmediateReaction.TonicSpasm)
					{
						<waitTime>5__1 = 0.1f;
					}
					else
					{
						<waitTime>5__1 = 1f;
					}
					<>2__current = (object)new WaitForSeconds(<waitTime>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, <immediateReaction>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 <Hypotonia>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			private float <bs>5__1;

			private float <d>5__2;

			private float <rt>5__3;

			private float <e>5__4;

			private Dictionary<string, float> <originalWeights>5__5;

			private Quaternion <spineRot>5__6;

			private Quaternion <chestRot>5__7;

			private Quaternion <headRot>5__8;

			private Quaternion <hipRot>5__9;

			private Quaternion <kneeRot>5__10;

			private Quaternion <ankleRot>5__11;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Hypotonia>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<originalWeights>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;
					<bs>5__1 = 0.4f;
					<d>5__2 = 0.2f;
					<rt>5__3 = 0.3f;
					<e>5__4 = 0f;
					<originalWeights>5__5 = PhysicsHelper.SaveMuscleWeights(puppet);
					<spineRot>5__6 = Quaternion.Euler(-90f, 0f, 0f);
					<chestRot>5__7 = Quaternion.Euler(-85f, 0f, 0f);
					<headRot>5__8 = Quaternion.Euler(0f, 50f, 0f);
					<hipRot>5__9 = Quaternion.Euler(90f, 0f, 0f);
					<kneeRot>5__10 = Quaternion.Euler(15f, 0f, 0f);
					<ankleRot>5__11 = Quaternion.Euler(10f, 0f, 0f);
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<e>5__4 < <bs>5__1 + <d>5__2 + <rt>5__3)
				{
					if ((Object)(object)puppet == (Object)null)
					{
						return false;
					}
					PhysicsHelper.ApplyToSpine(puppet, PhysicsHelper.GetProgress(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), PhysicsHelper.GetStrength(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3) * 1.3f, <spineRot>5__6, <headRot>5__8, <chestRot>5__7, <hipRot>5__9);
					PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), PhysicsHelper.GetStrength(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3) * 0.2f, Quaternion.identity, Quaternion.identity, Quaternion.identity, <kneeRot>5__10, <ankleRot>5__11, null, includeLegs: true, includeArms: false);
					<e>5__4 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				PhysicsHelper.RestoreAndResetJoints(puppet, <originalWeights>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 <Lazarus>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			private float <bs>5__1;

			private float <d>5__2;

			private float <rt>5__3;

			private float <e>5__4;

			private Dictionary<string, float> <originalWeights>5__5;

			private Quaternion <elbowRot>5__6;

			private Quaternion <wristRot>5__7;

			private Quaternion <shoulderRot>5__8;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Lazarus>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<originalWeights>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;
					<bs>5__1 = 1f;
					<d>5__2 = 5f;
					<rt>5__3 = 3f;
					<e>5__4 = 0f;
					<originalWeights>5__5 = PhysicsHelper.SaveMuscleWeights(puppet);
					<elbowRot>5__6 = Quaternion.Euler(130f, 0f, 0f);
					<wristRot>5__7 = Quaternion.Euler(70f, 0f, 0f);
					<shoulderRot>5__8 = Quaternion.Euler(40f, 0f, 20f);
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<e>5__4 < <bs>5__1 + <d>5__2 + <rt>5__3)
				{
					if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero)
					{
						return false;
					}
					PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), PhysicsHelper.GetStrength(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), <elbowRot>5__6, <wristRot>5__7, <shoulderRot>5__8, Quaternion.identity, Quaternion.identity, null, includeLegs: false);
					<e>5__4 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				PhysicsHelper.RestoreAndResetJoints(puppet, <originalWeights>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 <MuscleFailure>d__9 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			private float <duration>5__1;

			private float <elapsed>5__2;

			private Dictionary<string, float> <originalWeights>5__3;

			private Dictionary<string, JointDrive> <originalDrives>5__4;

			private IEnumerator<Muscle> <>s__5;

			private Muscle <m>5__6;

			private ConfigurableJoint <j>5__7;

			private float <strength>5__8;

			private IEnumerator<Muscle> <>s__9;

			private Muscle <muscle>5__10;

			private ConfigurableJoint <joint>5__11;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <MuscleFailure>d__9(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<originalWeights>5__3 = null;
				<originalDrives>5__4 = null;
				<>s__5 = null;
				<m>5__6 = null;
				<j>5__7 = null;
				<>s__9 = null;
				<muscle>5__10 = null;
				<joint>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;
					<duration>5__1 = 4f;
					<elapsed>5__2 = 0f;
					<originalWeights>5__3 = PhysicsHelper.SaveMuscleWeights(puppet);
					<originalDrives>5__4 = new Dictionary<string, JointDrive>();
					<>s__5 = ((Il2CppArrayBase<Muscle>)(object)puppet.muscles).GetEnumerator();
					try
					{
						while (<>s__5.MoveNext())
						{
							<m>5__6 = <>s__5.Current;
							if (<m>5__6 != null)
							{
								<originalWeights>5__3[<m>5__6.name] = <m>5__6.props.muscleWeight;
								<j>5__7 = ((Component)<m>5__6.transform).GetComponent<ConfigurableJoint>();
								if ((Object)(object)<j>5__7 != (Object)null)
								{
									<originalDrives>5__4[<m>5__6.name] = <j>5__7.slerpDrive;
								}
								<j>5__7 = null;
								<m>5__6 = null;
							}
						}
					}
					finally
					{
						if (<>s__5 != null)
						{
							<>s__5.Dispose();
						}
					}
					<>s__5 = null;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<elapsed>5__2 < <duration>5__1)
				{
					if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero)
					{
						return false;
					}
					<strength>5__8 = Mathf.Lerp(1f, 0f, <elapsed>5__2 / <duration>5__1);
					<>s__9 = ((Il2CppArrayBase<Muscle>)(object)puppet.muscles).GetEnumerator();
					try
					{
						while (<>s__9.MoveNext())
						{
							<muscle>5__10 = <>s__9.Current;
							if (<muscle>5__10 != null)
							{
								<muscle>5__10.props.muscleWeight = <strength>5__8 * 0.05f;
								<joint>5__11 = ((Component)<muscle>5__10.transform).GetComponent<ConfigurableJoint>();
								if (!((Object)(object)<joint>5__11 == (Object)null))
								{
									PhysicsHelper.SetJointDrive(<joint>5__11, 100f * <strength>5__8, 10f, 100f);
									<joint>5__11 = null;
									<muscle>5__10 = null;
								}
							}
						}
					}
					finally
					{
						if (<>s__9 != null)
						{
							<>s__9.Dispose();
						}
					}
					<>s__9 = null;
					<elapsed>5__2 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				PhysicsHelper.RestoreAndResetJoints(puppet, <originalWeights>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 <RunImmediateReaction>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			public ImmediateReaction reaction;

			private ImmediateReaction <>s__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <RunImmediateReaction>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 <TonicSpasm>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			private float <bs>5__1;

			private float <d>5__2;

			private float <rt>5__3;

			private float <e>5__4;

			private Dictionary<string, float> <originalWeights>5__5;

			private Quaternion <elbowRot>5__6;

			private Quaternion <wristRot>5__7;

			private Quaternion <shoulderRot>5__8;

			private Quaternion <kneeRot>5__9;

			private Quaternion <ankleRot>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TonicSpasm>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<originalWeights>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;
					<bs>5__1 = 0.05f;
					<d>5__2 = 0.8f;
					<rt>5__3 = 0.2f;
					<e>5__4 = 0f;
					<originalWeights>5__5 = PhysicsHelper.SaveMuscleWeights(puppet);
					<elbowRot>5__6 = Quaternion.Euler(-60f, 0f, 0f);
					<wristRot>5__7 = Quaternion.Euler(-40f, 0f, 0f);
					<shoulderRot>5__8 = Quaternion.Euler(-15f, 0f, -15f);
					<kneeRot>5__9 = Quaternion.Euler(15f, 0f, 0f);
					<ankleRot>5__10 = Quaternion.Euler(30f, 0f, 0f);
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<e>5__4 < <bs>5__1 + <d>5__2 + <rt>5__3)
				{
					if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero)
					{
						return false;
					}
					PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), PhysicsHelper.GetStrength(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3) * 0.2f, <elbowRot>5__6, <wristRot>5__7, <shoulderRot>5__8, <kneeRot>5__9, <ankleRot>5__10);
					<e>5__4 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				PhysicsHelper.RestoreAndResetJoints(puppet, <originalWeights>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(<HandleImpact>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 <HandleImpact>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[] weights = new int[4] { 40, 10, 20, 30 };
				return WeightedRandom(new ImmediateReaction[4]
				{
					ImmediateReaction.None,
					ImmediateReaction.MuscleFailure,
					ImmediateReaction.TonicSpasm,
					ImmediateReaction.Hypotonia
				}, weights);
			}
			if ((int)attackType == 2)
			{
				if (damage >= 5f)
				{
					int[] weights2 = new int[5] { 40, 30, 5, 15, 10 };
					return WeightedRandom(new ImmediateReaction[5]
					{
						ImmediateReaction.TonicSpasm,
						ImmediateReaction.Fencing,
						ImmediateReaction.MuscleFailure,
						ImmediateReaction.None,
						ImmediateReaction.Hypotonia
					}, weights2);
				}
				if (damage >= 2f)
				{
					int[] weights3 = new int[5] { 20, 45, 10, 18, 7 };
					return WeightedRandom(new ImmediateReaction[5]
					{
						ImmediateReaction.TonicSpasm,
						ImmediateReaction.Fencing,
						ImmediateReaction.MuscleFailure,
						ImmediateReaction.None,
						ImmediateReaction.Hypotonia
					}, weights3);
				}
				int[] weights4 = new int[5] { 10, 30, 20, 35, 5 };
				return WeightedRandom(new ImmediateReaction[5]
				{
					ImmediateReaction.TonicSpasm,
					ImmediateReaction.Fencing,
					ImmediateReaction.MuscleFailure,
					ImmediateReaction.None,
					ImmediateReaction.Hypotonia
				}, weights4);
			}
			int[] weights5 = new int[4] { 30, 0, 60, 10 };
			return WeightedRandom(new ImmediateReaction[4]
			{
				ImmediateReaction.MuscleFailure,
				ImmediateReaction.TonicSpasm,
				ImmediateReaction.None,
				ImmediateReaction.Hypotonia
			}, weights5);
		}

		private static ImmediateReaction WeightedRandom(ImmediateReaction[] options, int[] weights)
		{
			int num = 0;
			foreach (int num2 in weights)
			{
				num += num2;
			}
			int num3 = DeathTracker.Rng.Next(num);
			int num4 = 0;
			for (int j = 0; j < weights.Length; j++)
			{
				num4 += weights[j];
				if (num3 < num4)
				{
					return options[j];
				}
			}
			return options[^1];
		}

		[IteratorStateMachine(typeof(<RunImmediateReaction>d__4))]
		private static IEnumerator RunImmediateReaction(PuppetMaster puppet, ImmediateReaction reaction)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RunImmediateReaction>d__4(0)
			{
				puppet = puppet,
				reaction = reaction
			};
		}

		[IteratorStateMachine(typeof(<Hypotonia>d__5))]
		private static IEnumerator Hypotonia(PuppetMaster puppet)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Hypotonia>d__5(0)
			{
				puppet = puppet
			};
		}

		[IteratorStateMachine(typeof(<TonicSpasm>d__6))]
		private static IEnumerator TonicSpasm(PuppetMaster puppet)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TonicSpasm>d__6(0)
			{
				puppet = puppet
			};
		}

		[IteratorStateMachine(typeof(<Fencing>d__7))]
		private static IEnumerator Fencing(PuppetMaster puppet)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Fencing>d__7(0)
			{
				puppet = puppet
			};
		}

		[IteratorStateMachine(typeof(<Lazarus>d__8))]
		private static IEnumerator Lazarus(PuppetMaster puppet)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Lazarus>d__8(0)
			{
				puppet = puppet
			};
		}

		[IteratorStateMachine(typeof(<MuscleFailure>d__9))]
		private static IEnumerator MuscleFailure(PuppetMaster puppet)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <MuscleFailure>d__9(0)
			{
				puppet = puppet
			};
		}
	}
	public static class ModuleB_Posturing
	{
		private enum PostureType
		{
			Decorticate,
			Decerebrate,
			Hemiplegic,
			None
		}

		[CompilerGenerated]
		private sealed class <Decerebrate>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			private float <bs>5__1;

			private float <d>5__2;

			private float <rt>5__3;

			private float <e>5__4;

			private Dictionary<string, float> <originalWeights>5__5;

			private Quaternion <elbowRot>5__6;

			private Quaternion <wristRot>5__7;

			private Quaternion <shoulderRot>5__8;

			private Quaternion <kneeRot>5__9;

			private Quaternion <ankleRot>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Decerebrate>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<originalWeights>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;
					<bs>5__1 = 0.5f;
					<d>5__2 = 12f;
					<rt>5__3 = 3f;
					<e>5__4 = 0f;
					<originalWeights>5__5 = PhysicsHelper.SaveMuscleWeights(puppet);
					<elbowRot>5__6 = Quaternion.Euler(-100f, 0f, 0f);
					<wristRot>5__7 = Quaternion.Euler(-80f, 0f, 0f);
					<shoulderRot>5__8 = Quaternion.Euler(-20f, 0f, -30f);
					<kneeRot>5__9 = Quaternion.Euler(20f, 0f, 0f);
					<ankleRot>5__10 = Quaternion.Euler(40f, 0f, 0f);
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (<e>5__4 < <bs>5__1 + <d>5__2 + <rt>5__3)
				{
					if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero)
					{
						return false;
					}
					PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), PhysicsHelper.GetStrength(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), <elbowRot>5__6, <wristRot>5__7, <shoulderRot>5__8, <kneeRot>5__9, <ankleRot>5__10);
					<e>5__4 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				PhysicsHelper.RestoreAndResetJoints(puppet, <originalWeights>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 <Decorticate>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			private float <bs>5__1;

			private float <d>5__2;

			private float <rt>5__3;

			private float <e>5__4;

			private Dictionary<string, float> <originalWeights>5__5;

			private Quaternion <elbowRot>5__6;

			private Quaternion <wristRot>5__7;

			private Quaternion <shoulderRot>5__8;

			private Quaternion <kneeRot>5__9;

			private Quaternion <ankleRot>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Decorticate>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<originalWeights>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;
					<bs>5__1 = 1f;
					<d>5__2 = 10f;
					<rt>5__3 = 2f;
					<e>5__4 = 0f;
					<originalWeights>5__5 = PhysicsHelper.SaveMuscleWeights(puppet);
					<elbowRot>5__6 = Quaternion.Euler(130f, 0f, 0f);
					<wristRot>5__7 = Quaternion.Euler(70f, 0f, 0f);
					<shoulderRot>5__8 = Quaternion.Euler(40f, 0f, 20f);
					<kneeRot>5__9 = Quaternion.Euler(-10f, 0f, 0f);
					<ankleRot>5__10 = Quaternion.Euler(-20f, 0f, 0f);
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (<e>5__4 < <bs>5__1 + <d>5__2 + <rt>5__3)
				{
					if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero)
					{
						return false;
					}
					PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), PhysicsHelper.GetStrength(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), <elbowRot>5__6, <wristRot>5__7, <shoulderRot>5__8, <kneeRot>5__9, <ankleRot>5__10);
					<e>5__4 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				PhysicsHelper.RestoreAndResetJoints(puppet, <originalWeights>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 <HandlePosturing>d__0 : IEnumerator<object>, 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 <postureChance>5__1;

			private PostureType <posture>5__2;

			private PostureType <>s__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <HandlePosturing>d__0(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;
					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, 
						_ => 0f, 
					};
					if (1 == 0)
					{
					}
					<postureChance>5__1 = num;
					if (DeathTracker.Rng.NextDouble() * 100.0 > (double)<postureChance>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 (previousReaction == ModuleA_Impact.ImmediateReaction.Fencing)
					{
						<posture>5__2 = ((DeathTracker.Rng.Next(2) != 0) ? PostureType.Hemiplegic : PostureType.Decorticate);
					}
					else
					{
						<posture>5__2 = ((DeathTracker.Rng.Next(2) == 0) ? PostureType.Decerebrate : PostureType.Decorticate);
					}
					((MelonBase)ModClass.Instance).LoggerInstance.Msg($"[ModuleB] Posture: {<posture>5__2}");
					PostureType postureType = <posture>5__2;
					<>s__3 = postureType;
					switch (<>s__3)
					{
					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 <Hemiplegic>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			private float <bs>5__1;

			private float <d>5__2;

			private float <rt>5__3;

			private float <e>5__4;

			private Dictionary<string, float> <originalWeights>5__5;

			private Quaternion <elbowRot>5__6;

			private Quaternion <wristRot>5__7;

			private Quaternion <shoulderRot>5__8;

			private Quaternion <kneeRot>5__9;

			private Quaternion <ankleRot>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Hemiplegic>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<originalWeights>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;
					<bs>5__1 = 1.5f;
					<d>5__2 = 10f;
					<rt>5__3 = 2f;
					<e>5__4 = 0f;
					<originalWeights>5__5 = PhysicsHelper.SaveMuscleWeights(puppet);
					<elbowRot>5__6 = Quaternion.Euler(130f, 0f, 0f);
					<wristRot>5__7 = Quaternion.Euler(70f, 0f, 0f);
					<shoulderRot>5__8 = Quaternion.Euler(40f, 0f, 20f);
					<kneeRot>5__9 = Quaternion.Euler(-10f, 0f, 0f);
					<ankleRot>5__10 = Quaternion.Euler(-20f, 0f, 0f);
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (<e>5__4 < <bs>5__1 + <d>5__2 + <rt>5__3)
				{
					if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero)
					{
						return false;
					}
					PhysicsHelper.ApplyToMuscles(puppet, PhysicsHelper.GetProgress(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), PhysicsHelper.GetStrength(<e>5__4, <bs>5__1, <d>5__2, <rt>5__3), <elbowRot>5__6, <wristRot>5__7, <shoulderRot>5__8, <kneeRot>5__9, <ankleRot>5__10, "lf");
					<e>5__4 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				PhysicsHelper.RestoreAndResetJoints(puppet, <originalWeights>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(<HandlePosturing>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 <HandlePosturing>d__0(0)
			{
				puppet = puppet,
				attackType = attackType,
				damage = damage,
				previousReaction = previousReaction
			};
		}

		[IteratorStateMachine(typeof(<Decorticate>d__2))]
		private static IEnumerator Decorticate(PuppetMaster puppet)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Decorticate>d__2(0)
			{
				puppet = puppet
			};
		}

		[IteratorStateMachine(typeof(<Decerebrate>d__3))]
		private static IEnumerator Decerebrate(PuppetMaster puppet)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Decerebrate>d__3(0)
			{
				puppet = puppet
			};
		}

		[IteratorStateMachine(typeof(<Hemiplegic>d__4))]
		private static IEnumerator Hemiplegic(PuppetMaster puppet)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Hemiplegic>d__4(0)
			{
				puppet = puppet
			};
		}
	}
	internal class ModuleD_Consciousness
	{
		[CompilerGenerated]
		private sealed class <Unconscious>d__0 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PuppetMaster puppet;

			public float duration;

			private IntPtr <ptr>5__1;

			private Transform <npcRoot>5__2;

			private BehaviourBaseNav <behaviour>5__3;

			private AIBrain <brain>5__4;

			private AIManager <manager>5__5;

			private Animator <animator>5__6;

			private Dictionary<string, float> <originalMaxForce>5__7;

			private Dictionary<string, float> <originalMuscleWeight>5__8;

			private float <recoverTime>5__9;

			private float <elapsed>5__10;

			private IEnumerator<Muscle> <>s__11;

			private Muscle <m>5__12;

			private IEnumerator<Muscle> <>s__13;

			private Muscle <m>5__14;

			private IEnumerator<Muscle> <>s__15;

			private Muscle <m>5__16;

			private float <force>5__17;

			private float <weight>5__18;

			private IEnumerator<Muscle> <>s__19;

			private Muscle <m>5__20;

			private float <force>5__21;

			private float <weight>5__22;

			private float <t>5__23;

			private IEnumerator<Muscle> <>s__24;

			private Muscle <m>5__25;

			private float <targetForce>5__26;

			private float <targetWeight>5__27;

			private IEnumerator<Muscle> <>s__28;

			private Muscle <m>5__29;

			private float <force>5__30;

			private float <weight>5__31;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Unconscious>d__0(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<npcRoot>5__2 = null;
				<behaviour>5__3 = null;
				<brain>5__4 = null;
				<manager>5__5 = null;
				<animator>5__6 = null;
				<originalMaxForce>5__7 = null;
				<originalMuscleWeight>5__8 = null;
				<>s__11 = null;
				<m>5__12 = null;
				<>s__13 = null;
				<m>5__14 = null;
				<>s__15 = null;
				<m>5__16 = null;
				<>s__19 = null;
				<m>5__20 = null;
				<>s__24 = null;
				<m>5__25 = null;
				<>s__28 = null;
				<m>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;
					}
					<ptr>5__1 = ((Il2CppObjectBase)puppet).Pointer;
					<npcRoot>5__2 = ((Component)puppet).transform.root;
					<behaviour>5__3 = ((Component)<npcRoot>5__2).GetComponentInChildren<BehaviourBaseNav>();
					<brain>5__4 = ((Component)<npcRoot>5__2).GetComponentInChildren<AIBrain>();
					<manager>5__5 = ((Component)<npcRoot>5__2).GetComponentInChildren<AIManager>();
					<animator>5__6 = ((Component)<npcRoot>5__2).GetComponentInChildren<Animator>();
					<originalMaxForce>5__7 = new Dictionary<string, float>();
					<originalMuscleWeight>5__8 = new Dictionary<string, float>();
					<>s__11 = ((Il2CppArrayBase<Muscle>)(object)puppet.muscles).GetEnumerator();
					try
					{
						while (<>s__11.MoveNext())
						{
							<m>5__12 = <>s__11.Current;
							<originalMaxForce>5__7[<m>5__12.name] = <m>5__12._maxForce;
							<originalMuscleWeight>5__8[<m>5__12.name] = <m>5__12.props.muscleWeight;
							<m>5__12 = null;
						}
					}
					finally
					{
						if (<>s__11 != null)
						{
							<>s__11.Dispose();
						}
					}
					<>s__11 = null;
					<>s__13 = ((Il2CppArrayBase<Muscle>)(object)puppet.muscles).GetEnumerator();
					try
					{
						while (<>s__13.MoveNext())
						{
							<m>5__14 = <>s__13.Current;
							<m>5__14._maxForce = <originalMaxForce>5__7[<m>5__14.name] * 0.08f;
							<m>5__14.props.muscleWeight = <originalMuscleWeight>5__8[<m>5__14.name] * 0.08f;
							<m>5__14 = null;
						}
					}
					finally
					{
						if (<>s__13 != null)
						{
							<>s__13.Dispose();
						}
					}
					<>s__13 = null;
					if ((Object)(object)<animator>5__6 != (Object)null)
					{
						((Behaviour)<animator>5__6).enabled = false;
					}
					if ((Object)(object)<brain>5__4 != (Object)null && (Object)(object)<brain>5__4.behaviour != (Object)null)
					{
						<brain>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<Muscle>)(object)puppet.muscles).GetEnumerator();
						try
						{
							while (<>s__15.MoveNext())
							{
								<m>5__16 = <>s__15.Current;
								if (<originalMaxForce>5__7.TryGetValue(<m>5__16.name, out <force>5__17))
								{
									<m>5__16._maxForce = <force>5__17;
								}
								if (<originalMuscleWeight>5__8.TryGetValue(<m>5__16.name, out <weight>5__18))
								{
									<m>5__16.props.muscleWeight = <weight>5__18;
								}
								<m>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<Muscle>)(object)puppet.muscles).GetEnumerator();
					try
					{
						while (<>s__19.MoveNext())
						{
							<m>5__20 = <>s__19.Current;
							if (<originalMaxForce>5__7.TryGetValue(<m>5__20.name, out <force>5__21))
							{
								<m>5__20._maxForce = <force>5__21;
							}
							if (<originalMuscleWeight>5__8.TryGetValue(<m>5__20.name, out <weight>5__22))
							{
								<m>5__20.props.muscleWeight = <weight>5__22;
							}
							<m>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)<animator>5__6 != (Object)null)
					{
						((Behaviour)<animator>5__6).enabled = true;
					}
					if ((Object)(object)<brain>5__4 != (Object)null)
					{
						((Behaviour)<brain>5__4).enabled = true;
					}
					if ((Object)(object)<behaviour>5__3 != (Object)null)
					{
						<behaviour>5__3.locoState = (LocoState)3;
					}
					<recoverTime>5__9 = 1f;
					<elapsed>5__10 = 0f;
					break;
				case 3:
					<>1__state = -1;
					break;
				}
				if (<elapsed>5__10 < <recoverTime>5__9)
				{
					if ((Object)(object)puppet == (Object)null || ((Il2CppObjectBase)puppet).Pointer == IntPtr.Zero)
					{
						return false;
					}
					if (DeathTracker.AlreadyDead.Contains(((Il2CppObjectBase)puppet).Pointer))
					{
						return false;
					}
					<t>5__23 = <elapsed>5__10 / <recoverTime>5__9;
					<>s__24 = ((Il2CppArrayBase<Muscle>)(object)puppet.muscles).GetEnumerator();
					try
					{
						while (<>s__24.MoveNext())
						{
							<m>5__25 = <>s__24.Current;
							if (<m>5__25 != null)
							{
								if (<originalMaxForce>5__7.TryGetValue(<m>5__25.name, out <targetForce>5__26))
								{
									<m>5__25._maxForce = Mathf.Lerp(0f, <targetForce>5__26, <t>5__23);
								}
								if (<originalMuscleWeight>5__8.TryGetValue(<m>5__25.name, out <targetWeight>5__27))
								{
									<m>5__25.props.muscleWeight = Mathf.Lerp(0f, <targetWeight>5__27, <t>5__23);
								}
								<m>5__25 = null;
							}
						}
					}
					finally
					{
						if (<>s__24 != null)
						{
							<>s__24.Dispose();
						}
					}
					<>s__24 = null;
					<elapsed>5__10 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 3;
					return true;
				}
				<>s__28 = ((Il2CppArrayBase<Muscle>)(object)puppet.muscles).GetEnumerator();
				try
				{
					while (<>s__28.MoveNext())
					{
						<m>5__29 = <>s__28.Current;
						if (<originalMaxForce>5__7.TryGetValue(<m>5__29.name, out <force>5__30))
						{
							<m>5__29._maxForce = <force>5__30;
						}
						if (<originalMuscleWeight>5__8.TryGetValue(<m>5__29.name, out <weight>5__31))
						{
							<m>5__29.props.muscleWeight = <weight>5__31;
						}
						<m>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(<Unconscious>d__0))]
		public static IEnumerator Unconscious(PuppetMaster puppet, float duration = 20f)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Unconscious>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<Muscle>)(object)puppet.muscles)
			{
				if (item == null)
				{
					continue;
				}
				string text = item.name.ToLower();
				ConfigurableJoint component = ((Component)item.transform).GetComponent<ConfigurableJoint>();
				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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			foreach (Muscle item in (Il2CppArrayBase<Muscle>)(object)puppet.muscles)
			{
				if (item == null)
				{
					continue;
				}
				string text = item.name.ToLower();
				if (sideFilter != null && !text.Contains(sideFilter))
				{
					continue;
				}
				ConfigurableJoint component = ((Component)item.transform).GetComponent<ConfigurableJoint>();
				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;
				}
				component.targetRotation = Quaternion.Slerp(Quaternion.identity, identity, progress);
				SetJointDrive(component, 3000f * strength, 800f, 3000f);
				item.props.muscleWeight = strength;
			}
		}

		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<string, float> 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<Muscle>)(object)puppet.muscles)
			{
				if (item != null)
				{
					if (originalWeights.TryGetValue(item.name, out var value))
					{
						item.props.muscleWeight = value;
					}
					ConfigurableJoint component = ((Component)item.transform).GetComponent<ConfigurableJoint>();
					if (!((Object)(object)component == (Object)null))
					{
						SetJointDrive(component, 0f, 0f, 0f);
						component.targetRotation = Quaternion.identity;
					}
				}
			}
		}

		public static Dictionary<string, float> SaveMuscleWeights(PuppetMaster puppet)
		{
			Dictionary<string, float> dictionary = new Dictionary<string, float>();
			foreach (Muscle item in (Il2CppArrayBase<Muscle>)(object)puppet.muscles)
			{
				if (item != null)
				{
					dictionary[item.name] = item.props.muscleWeight;
				}
			}
			return dictionary;
		}
	}
}
namespace InjuriesMod.Core
{
	public static class DeathTracker
	{
		public static HashSet<IntPtr> AlreadyDead = new HashSet<IntPtr>();

		public static HashSet<IntPtr> UnconsciousNPCs = new HashSet<IntPtr>();

		public static Dictionary<IntPtr, float> UnconsciousStartTime = new Dictionary<IntPtr, float>();

		public static Dictionary<IntPtr, string> LastHitBone = new Dictionary<IntPtr, string>();

		public static Dictionary<IntPtr, string> PriorityDeathCause = new Dictionary<IntPtr, string>();

		public static Dictionary<IntPtr, AttackType> LastAttackType = new Dictionary<IntPtr, AttackType>();

		public static Dictionary<IntPtr, float> LastAttackDamage = new Dictionary<IntPtr, float>();

		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})");
				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 static ModClass Instance;

		public static bool UnconsciousEnabled = true;

		public static bool BrainInjuriesEnabled = true;

		public static bool TorsoArmorEnabled = true;

		public static bool HeadBluntResistEnabled = true;

		public override void OnInitializeMelon()
		{
			Harmony.CreateAndPatchAll(typeof(ModClass).Assembly, (string)null);
			SetupBoneMenu();
			Instance = this;
			((MelonBase)this).LoggerInstance.Msg("Mod loaded!");
		}

		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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			Color val = default(Color);
			((Color)(ref val))..ctor(1f, 0.988f, 0.729f);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(1f, 0.25f, 0.25f);
			Page val3 = Page.Root.CreatePage("Brain Injuries", val2, 0, true);
			Page val4 = val3.CreatePage("GENERAL SETTINGS", val, 0, true);
			val4.CreateBool("Knockouts / Unconscious", Color.cyan, true, (Action<bool>)delegate(bool v)
			{
				UnconsciousEnabled = v;
			});
			val4.CreateBool("Brain Injuries", Color.yellow, true, (Action<bool>)delegate(bool v)
			{
				BrainInjuriesEnabled = v;
			});
			Page val5 = val3.CreatePage("DAMAGE RESISTANCE", val, 0, true);
			val5.CreateBool("Reduced Torso Damage", Color.white, true, (Action<bool>)delegate(bool v)
			{
				TorsoArmorEnabled = v;
			});
			val5.CreateBool("Reduced Blunt Head Damage", Color.white, true, (Action<bool>)delegate(bool v)
			{
				HeadBluntResistEnabled = v;
			});
		}

		public override void OnSceneWasUnloaded(int buildIndex, string sceneName)
		{
			DeathTracker.ClearAll();
			((MelonBase)this).LoggerInstance.Msg("Scene cleared.");
		}
	}
}