Decompiled source of ProcedualAnimation v1.0.3

Procudeal aimation.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using MelonLoader;
using ModThatIsNotMod.BoneMenu;
using ModThatIsNotMod.MonoBehaviours;
using Procudeal_aimation;
using PuppetMasta;
using StressLevelZero.AI;
using StressLevelZero.Props.Weapons;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
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(Main), "Procudeal aimation", "5.6.0", "Jeb", null)]
[assembly: MelonGame("Stress Level Zero", "BONEWORKS")]
[assembly: AssemblyTitle("Procudeal aimation")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Procudeal aimation")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e02c3ff9-db33-4862-8ec0-1d1790eb4fef")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ModThatIsNotMod.MonoBehaviours
{
	public class OriginalPuppetProperties : MonoBehaviour
	{
		public float damper;

		public float weight;

		public float animSpeed;

		public OriginalPuppetProperties(IntPtr ptr)
			: base(ptr)
		{
		}
	}
	public class AgonyLogic : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <ResetSequence>d__19 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public AgonyLogic <>4__this;

			private PuppetMaster <pm>5__1;

			private OriginalPuppetProperties <props>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<pm>5__1 = null;
				<props>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				<pm>5__1 = <>4__this._brain.puppetMaster;
				<props>5__2 = ((Component)<>4__this).GetComponent<OriginalPuppetProperties>();
				if ((Object)(object)<pm>5__1 == (Object)null || (Object)(object)<props>5__2 == (Object)null)
				{
					return false;
				}
				if ((Object)(object)<pm>5__1.targetAnimator != (Object)null)
				{
					((Behaviour)<pm>5__1.targetAnimator).enabled = true;
					<pm>5__1.targetAnimator.speed = 0f;
				}
				<pm>5__1.muscleDamper = <props>5__2.damper;
				<pm>5__1.muscleWeight = <props>5__2.weight;
				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 <Struggle>d__18 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public AgonyLogic <>4__this;

			private float <elapsed>5__1;

			private bool <isBicycle>5__2;

			private float <bicycleTimer>5__3;

			private bool <legToggle>5__4;

			private float <force>5__5;

			private float <anchorPower>5__6;

			private List<Rigidbody>.Enumerator <>s__7;

			private Rigidbody <hand>5__8;

			private List<Rigidbody>.Enumerator <>s__9;

			private Rigidbody <knee>5__10;

			private Vector3 <localPos>5__11;

			private Vector3 <idealLocalPos>5__12;

			private Vector3 <idealWorldPos>5__13;

			private Vector3 <pullDir>5__14;

			private int <activeIndex>5__15;

			private int <inactiveIndex>5__16;

			private Rigidbody <activeKnee>5__17;

			private Rigidbody <activeFoot>5__18;

			private Rigidbody <inactiveKnee>5__19;

			private Rigidbody <inactiveFoot>5__20;

			private Vector3 <localKneePos>5__21;

			private Vector3 <pushDir>5__22;

			private Vector3 <finalKick>5__23;

			private Vector3 <retractDir>5__24;

			private Vector3 <finalRetract>5__25;

			private List<Rigidbody>.Enumerator <>s__26;

			private Rigidbody <leg>5__27;

			private Vector3 <kickDir>5__28;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__7 = default(List<Rigidbody>.Enumerator);
				<hand>5__8 = null;
				<>s__9 = default(List<Rigidbody>.Enumerator);
				<knee>5__10 = null;
				<activeKnee>5__17 = null;
				<activeFoot>5__18 = null;
				<inactiveKnee>5__19 = null;
				<inactiveFoot>5__20 = null;
				<>s__26 = default(List<Rigidbody>.Enumerator);
				<leg>5__27 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Expected O, but got Unknown
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: 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_01c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cb: 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_01df: Unknown result type (might be due to invalid IL or missing references)
				//IL_0215: Unknown result type (might be due to invalid IL or missing references)
				//IL_0220: Unknown result type (might be due to invalid IL or missing references)
				//IL_0225: Unknown result type (might be due to invalid IL or missing references)
				//IL_022a: Unknown result type (might be due to invalid IL or missing references)
				//IL_022d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0238: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_033b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0340: Unknown result type (might be due to invalid IL or missing references)
				//IL_0357: Unknown result type (might be due to invalid IL or missing references)
				//IL_035c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0361: Unknown result type (might be due to invalid IL or missing references)
				//IL_0368: Unknown result type (might be due to invalid IL or missing references)
				//IL_0373: Unknown result type (might be due to invalid IL or missing references)
				//IL_0378: Unknown result type (might be due to invalid IL or missing references)
				//IL_037d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0380: Unknown result type (might be due to invalid IL or missing references)
				//IL_0385: Unknown result type (might be due to invalid IL or missing references)
				//IL_0391: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0907: Unknown result type (might be due to invalid IL or missing references)
				//IL_0911: Expected O, but got Unknown
				//IL_08ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_08fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_07de: Unknown result type (might be due to invalid IL or missing references)
				//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0807: Unknown result type (might be due to invalid IL or missing references)
				//IL_082d: Unknown result type (might be due to invalid IL or missing references)
				//IL_083d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0842: Unknown result type (might be due to invalid IL or missing references)
				//IL_0847: Unknown result type (might be due to invalid IL or missing references)
				//IL_084a: Unknown result type (might be due to invalid IL or missing references)
				//IL_084f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0854: Unknown result type (might be due to invalid IL or missing references)
				//IL_0859: Unknown result type (might be due to invalid IL or missing references)
				//IL_086a: Unknown result type (might be due to invalid IL or missing references)
				//IL_087b: Unknown result type (might be due to invalid IL or missing references)
				//IL_058b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0590: Unknown result type (might be due to invalid IL or missing references)
				//IL_0595: Unknown result type (might be due to invalid IL or missing references)
				//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_05db: Unknown result type (might be due to invalid IL or missing references)
				//IL_05de: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0603: Unknown result type (might be due to invalid IL or missing references)
				//IL_0614: Unknown result type (might be due to invalid IL or missing references)
				//IL_0625: Unknown result type (might be due to invalid IL or missing references)
				//IL_0650: Unknown result type (might be due to invalid IL or missing references)
				//IL_0661: Unknown result type (might be due to invalid IL or missing references)
				//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_06da: Unknown result type (might be due to invalid IL or missing references)
				//IL_06df: Unknown result type (might be due to invalid IL or missing references)
				//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0709: Unknown result type (might be due to invalid IL or missing references)
				//IL_072f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0740: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.RefreshBodyParts();
					if (<>4__this._isSmallEnemy)
					{
						<>4__this._isSuffering = false;
						return false;
					}
					<>2__current = (object)new WaitForFixedUpdate();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<elapsed>5__1 = 0f;
					<isBicycle>5__2 = Random.value > 0.85f;
					<bicycleTimer>5__3 = 0f;
					<legToggle>5__4 = true;
					goto IL_0922;
				case 2:
					<>1__state = -1;
					goto IL_0922;
				case 3:
					{
						<>1__state = -1;
						<>4__this._isSuffering = false;
						return false;
					}
					IL_0922:
					if (<>4__this._isSuffering && <elapsed>5__1 < Main.struggleTime)
					{
						<elapsed>5__1 += Time.fixedDeltaTime;
						<force>5__5 = Main.pullForce;
						Vector3 val;
						if ((Object)(object)<>4__this._chest != (Object)null && (Object)(object)<>4__this._pelvis != (Object)null)
						{
							Rigidbody chest = <>4__this._chest;
							val = <>4__this._pelvis.position - <>4__this._chest.position;
							chest.AddForce(((Vector3)(ref val)).normalized * (<force>5__5 * 1.2f), (ForceMode)0);
						}
						<>s__7 = <>4__this._limbs.GetEnumerator();
						try
						{
							while (<>s__7.MoveNext())
							{
								<hand>5__8 = <>s__7.Current;
								if (!((Object)(object)<hand>5__8 == (Object)null))
								{
									if ((Object)(object)<>4__this.lastHitBone != (Object)null)
									{
										Rigidbody obj = <hand>5__8;
										val = <>4__this.lastHitBone.position - <hand>5__8.position;
										obj.AddForce(((Vector3)(ref val)).normalized * (<force>5__5 * 1.5f), (ForceMode)0);
									}
									else if ((Object)(object)<>4__this._pelvis != (Object)null)
									{
										Rigidbody obj2 = <hand>5__8;
										val = <>4__this._pelvis.position - <hand>5__8.position;
										obj2.AddForce(((Vector3)(ref val)).normalized * <force>5__5, (ForceMode)0);
									}
									<hand>5__8 = null;
								}
							}
						}
						finally
						{
							((IDisposable)<>s__7).Dispose();
						}
						<>s__7 = default(List<Rigidbody>.Enumerator);
						<>s__9 = <>4__this._knees.GetEnumerator();
						try
						{
							while (<>s__9.MoveNext())
							{
								<knee>5__10 = <>s__9.Current;
								if (!((Object)(object)<knee>5__10 == (Object)null) && !((Object)(object)<>4__this._pelvis == (Object)null))
								{
									<localPos>5__11 = ((Component)<>4__this._pelvis).transform.InverseTransformPoint(<knee>5__10.position);
									if (Mathf.Abs(<localPos>5__11.x) > 0.05f)
									{
										<idealLocalPos>5__12 = new Vector3(0f, <localPos>5__11.y, <localPos>5__11.z);
										<idealWorldPos>5__13 = ((Component)<>4__this._pelvis).transform.TransformPoint(<idealLocalPos>5__12);
										val = <idealWorldPos>5__13 - <knee>5__10.position;
										<pullDir>5__14 = ((Vector3)(ref val)).normalized;
										<knee>5__10.AddForce(<pullDir>5__14 * (<force>5__5 * 0.6f), (ForceMode)0);
									}
									<knee>5__10 = null;
								}
							}
						}
						finally
						{
							((IDisposable)<>s__9).Dispose();
						}
						<>s__9 = default(List<Rigidbody>.Enumerator);
						if (<isBicycle>5__2)
						{
							<bicycleTimer>5__3 -= Time.fixedDeltaTime;
							if (<bicycleTimer>5__3 <= 0f)
							{
								<bicycleTimer>5__3 = Random.Range(0.15f, 0.3f);
								<legToggle>5__4 = !<legToggle>5__4;
								<activeIndex>5__15 = ((!<legToggle>5__4) ? 1 : 0);
								<inactiveIndex>5__16 = (<legToggle>5__4 ? 1 : 0);
								<activeKnee>5__17 = ((<>4__this._knees.Count > <activeIndex>5__15) ? <>4__this._knees[<activeIndex>5__15] : null);
								<activeFoot>5__18 = ((<>4__this._feet.Count > <activeIndex>5__15) ? <>4__this._feet[<activeIndex>5__15] : null);
								<inactiveKnee>5__19 = ((<>4__this._knees.Count > <inactiveIndex>5__16) ? <>4__this._knees[<inactiveIndex>5__16] : null);
								<inactiveFoot>5__20 = ((<>4__this._feet.Count > <inactiveIndex>5__16) ? <>4__this._feet[<inactiveIndex>5__16] : null);
								if ((Object)(object)<activeKnee>5__17 != (Object)null && (Object)(object)<>4__this._pelvis != (Object)null)
								{
									<localKneePos>5__21 = ((Component)<>4__this._pelvis).transform.InverseTransformPoint(<activeKnee>5__17.position);
									<localKneePos>5__21.x = 0f;
									val = ((Component)<>4__this._pelvis).transform.TransformPoint(<localKneePos>5__21) - <>4__this._pelvis.position;
									<pushDir>5__22 = ((Vector3)(ref val)).normalized;
									<finalKick>5__23 = Vector3.up * 0.4f + <pushDir>5__22;
									<activeKnee>5__17.AddForce(((Vector3)(ref <finalKick>5__23)).normalized * (<force>5__5 * 0.8f), (ForceMode)1);
									if ((Object)(object)<activeFoot>5__18 != (Object)null)
									{
										<activeFoot>5__18.AddForce(((Vector3)(ref <finalKick>5__23)).normalized * (<force>5__5 * 0.3f), (ForceMode)1);
									}
								}
								if ((Object)(object)<inactiveKnee>5__19 != (Object)null && (Object)(object)<>4__this._pelvis != (Object)null)
								{
									val = <>4__this._pelvis.position - <inactiveKnee>5__19.position;
									<retractDir>5__24 = ((Vector3)(ref val)).normalized;
									val = <retractDir>5__24 + Vector3.up * 0.2f;
									<finalRetract>5__25 = ((Vector3)(ref val)).normalized;
									<inactiveKnee>5__19.AddForce(<finalRetract>5__25 * (<force>5__5 * 0.6f), (ForceMode)1);
									if ((Object)(object)<inactiveFoot>5__20 != (Object)null)
									{
										<inactiveFoot>5__20.AddForce(<finalRetract>5__25 * (<force>5__5 * 0.2f), (ForceMode)1);
									}
								}
								<activeKnee>5__17 = null;
								<activeFoot>5__18 = null;
								<inactiveKnee>5__19 = null;
								<inactiveFoot>5__20 = null;
							}
						}
						else
						{
							<>s__26 = <>4__this._legs.GetEnumerator();
							try
							{
								while (<>s__26.MoveNext())
								{
									<leg>5__27 = <>s__26.Current;
									if (!((Object)(object)<leg>5__27 == (Object)null) && !((Object)(object)<>4__this._pelvis == (Object)null))
									{
										Rigidbody obj3 = <leg>5__27;
										val = <>4__this._pelvis.position - <leg>5__27.position;
										obj3.AddForce(((Vector3)(ref val)).normalized * (<force>5__5 * 0.8f), (ForceMode)0);
										if (Random.value > 0.98f)
										{
											val = <leg>5__27.position - <>4__this._pelvis.position;
											<kickDir>5__28 = ((Vector3)(ref val)).normalized + Random.onUnitSphere;
											<leg>5__27.AddForce(((Vector3)(ref <kickDir>5__28)).normalized * (<force>5__5 * 0.4f), (ForceMode)1);
										}
										<leg>5__27 = null;
									}
								}
							}
							finally
							{
								((IDisposable)<>s__26).Dispose();
							}
							<>s__26 = default(List<Rigidbody>.Enumerator);
						}
						<anchorPower>5__6 = 25f;
						if ((Object)(object)<>4__this._pelvis != (Object)null)
						{
							<>4__this._pelvis.AddForce(Vector3.down * <anchorPower>5__6, (ForceMode)0);
						}
						<>2__current = (object)new WaitForFixedUpdate();
						<>1__state = 2;
						return true;
					}
					<>2__current = <>4__this.ResetSequence();
					<>1__state = 3;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private AIBrain _brain;

		private List<Rigidbody> _limbs = new List<Rigidbody>();

		private List<Rigidbody> _legs = new List<Rigidbody>();

		private Rigidbody _pelvis;

		private Rigidbody _chest;

		private List<Rigidbody> _knees = new List<Rigidbody>();

		private List<Rigidbody> _feet = new List<Rigidbody>();

		public Rigidbody lastHitBone;

		private bool _isSuffering = false;

		private bool _isSmallEnemy = false;

		private string[] legKeywords = new string[6] { "foot", "calf", "thigh", "knee", "toe", "leg" };

		private string[] armKeywords = new string[5] { "hand", "arm", "shoulder", "wrist", "elbow" };

		private string[] coreKeywords = new string[3] { "chest", "spine", "neck" };

		private string[] pelvisKeywords = new string[3] { "pelvis", "hip", "root" };

		public AgonyLogic(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
			_brain = ((Component)this).GetComponent<AIBrain>();
		}

		public void ProcessHit()
		{
			if (!((Object)(object)_brain == (Object)null) && !_isSuffering)
			{
				_isSuffering = true;
				MelonCoroutines.Start(Struggle());
			}
		}

		private void RefreshBodyParts()
		{
			_isSmallEnemy = false;
			_limbs.Clear();
			_legs.Clear();
			_knees.Clear();
			_feet.Clear();
			PuppetMaster puppetMaster = _brain.puppetMaster;
			if ((Object)(object)puppetMaster == (Object)null || puppetMaster.muscles == null || ((Il2CppArrayBase<Muscle>)(object)puppetMaster.muscles).Count == 0)
			{
				return;
			}
			string text = ((Object)((Component)_brain).gameObject).name.ToLower();
			if (text.Contains("crab") || text.Contains("headcrab"))
			{
				_isSmallEnemy = true;
				return;
			}
			_pelvis = ((Il2CppArrayBase<Muscle>)(object)puppetMaster.muscles)[0].rigidbody;
			foreach (Muscle item in (Il2CppArrayBase<Muscle>)(object)puppetMaster.muscles)
			{
				if ((Object)(object)item.rigidbody == (Object)null)
				{
					continue;
				}
				string text2 = ((Object)item.rigidbody).name.ToLower();
				string[] array = pelvisKeywords;
				foreach (string value in array)
				{
					if (text2.Contains(value))
					{
						_pelvis = item.rigidbody;
						break;
					}
				}
				string[] array2 = coreKeywords;
				foreach (string value2 in array2)
				{
					if (text2.Contains(value2))
					{
						_chest = item.rigidbody;
						break;
					}
				}
				bool flag = false;
				string[] array3 = legKeywords;
				foreach (string value3 in array3)
				{
					if (text2.Contains(value3))
					{
						_legs.Add(item.rigidbody);
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					string[] array4 = armKeywords;
					foreach (string value4 in array4)
					{
						if (text2.Contains(value4))
						{
							_limbs.Add(item.rigidbody);
							break;
						}
					}
				}
				if (text2.Contains("calf") || text2.Contains("knee") || text2.Contains("lowerleg"))
				{
					_knees.Add(item.rigidbody);
				}
				if (text2.Contains("foot") || text2.Contains("toe"))
				{
					_feet.Add(item.rigidbody);
				}
			}
		}

		[IteratorStateMachine(typeof(<Struggle>d__18))]
		private IEnumerator Struggle()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Struggle>d__18(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<ResetSequence>d__19))]
		private IEnumerator ResetSequence()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ResetSequence>d__19(0)
			{
				<>4__this = this
			};
		}
	}
}
namespace Procudeal_aimation
{
	public class Main : MelonMod
	{
		[CompilerGenerated]
		private sealed class <OptimizedScanner>d__6 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Main <>4__this;

			private WaitForSeconds <waitTime>5__1;

			private Il2CppArrayBase<AIBrain> <allBrains>5__2;

			private IEnumerator<AIBrain> <>s__3;

			private AIBrain <brain>5__4;

			private PuppetMaster <pm>5__5;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<waitTime>5__1 = null;
				<allBrains>5__2 = null;
				<>s__3 = null;
				<brain>5__4 = null;
				<pm>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Invalid comparison between Unknown and I4
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<waitTime>5__1 = new WaitForSeconds(0.5f);
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (modEnabled)
				{
					<allBrains>5__2 = Resources.FindObjectsOfTypeAll<AIBrain>();
					<>s__3 = <allBrains>5__2.GetEnumerator();
					try
					{
						while (<>s__3.MoveNext())
						{
							<brain>5__4 = <>s__3.Current;
							if (!((Object)(object)<brain>5__4 == (Object)null))
							{
								if ((Object)(object)((Component)<brain>5__4).gameObject.GetComponent<AgonyLogic>() == (Object)null)
								{
									((Component)<brain>5__4).gameObject.AddComponent<AgonyLogic>();
								}
								<pm>5__5 = <brain>5__4.puppetMaster;
								if ((Object)(object)<pm>5__5 != (Object)null && (int)<pm>5__5.state != 1 && (Object)(object)<pm>5__5.targetAnimator != (Object)null && <pm>5__5.targetAnimator.speed == 0f)
								{
									((Behaviour)<pm>5__5.targetAnimator).enabled = true;
									<pm>5__5.targetAnimator.speed = 1f;
								}
								<pm>5__5 = null;
								<brain>5__4 = null;
							}
						}
					}
					finally
					{
						if (<>s__3 != null)
						{
							<>s__3.Dispose();
						}
					}
					<>s__3 = null;
					<allBrains>5__2 = null;
				}
				<>2__current = <waitTime>5__1;
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static bool modEnabled = true;

		public static float pullForce = 35f;

		public static float struggleTime = 8f;

		private bool _isScannerRunning = false;

		public override void OnApplicationStart()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			MelonLogger.Msg(ConsoleColor.Cyan, "the proceudal ANIMAtion IS ACTIVE - Now with Raycast Precision!");
			ClassInjector.RegisterTypeInIl2Cpp<AgonyLogic>();
			ClassInjector.RegisterTypeInIl2Cpp<OriginalPuppetProperties>();
			Harmony val = new Harmony("com.jeb.proceduralanimation");
			val.PatchAll();
			SetupMenu();
		}

		public override void OnSceneWasInitialized(int buildIndex, string sceneName)
		{
			if (!_isScannerRunning)
			{
				_isScannerRunning = true;
				MelonCoroutines.Start(OptimizedScanner());
			}
		}

		[IteratorStateMachine(typeof(<OptimizedScanner>d__6))]
		private IEnumerator OptimizedScanner()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <OptimizedScanner>d__6(0)
			{
				<>4__this = this
			};
		}

		private void SetupMenu()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			MenuCategory val = MenuManager.CreateCategory("Procudeal aimation", Color.red);
			val.CreateBoolElement("Mod Active", Color.white, true, (Action<bool>)delegate(bool v)
			{
				modEnabled = v;
			});
			val.CreateFloatElement("Force", Color.red, 35f, (Action<float>)delegate(float v)
			{
				pullForce = v;
			}, 5f, -2.1474836E+09f, 2.1474836E+09f, false);
			val.CreateFloatElement("Duration", Color.white, 8f, (Action<float>)delegate(float v)
			{
				struggleTime = v;
			}, 1f, -2.1474836E+09f, 2.1474836E+09f, false);
		}
	}
	[HarmonyPatch(typeof(Gun), "OnFire", new Type[] { })]
	public class GunFirePatch
	{
		[HarmonyPostfix]
		public static void Postfix(Gun __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.modEnabled || (Object)(object)__instance.firePointTransform == (Object)null)
			{
				return;
			}
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(__instance.firePointTransform.position, __instance.firePointTransform.forward);
			RaycastHit val2 = default(RaycastHit);
			if (!Physics.Raycast(val, ref val2, 500f))
			{
				return;
			}
			AIBrain componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<AIBrain>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				AgonyLogic component = ((Component)componentInParent).GetComponent<AgonyLogic>();
				if ((Object)(object)component != (Object)null)
				{
					component.lastHitBone = ((Component)((RaycastHit)(ref val2)).collider).GetComponent<Rigidbody>();
				}
			}
		}
	}
	[HarmonyPatch(typeof(PuppetMaster), "Kill", new Type[] { })]
	public class PuppetMasterKillPatch
	{
		[HarmonyPrefix]
		public static void Prefix(PuppetMaster __instance)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.modEnabled)
			{
				return;
			}
			AIBrain componentInParent = ((Component)__instance).GetComponentInParent<AIBrain>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return;
			}
			OriginalPuppetProperties component = ((Component)componentInParent).GetComponent<OriginalPuppetProperties>();
			if ((Object)(object)component == (Object)null)
			{
				component = ((Component)componentInParent).gameObject.AddComponent<OriginalPuppetProperties>();
				component.damper = __instance.muscleDamper;
				component.weight = __instance.muscleWeight;
				if ((Object)(object)__instance.targetAnimator != (Object)null)
				{
					component.animSpeed = __instance.targetAnimator.speed;
				}
			}
			if ((Object)(object)__instance.targetAnimator != (Object)null)
			{
				((Behaviour)__instance.targetAnimator).enabled = false;
			}
			__instance.stateSettings = new StateSettings(0f, 0f, 0f, 0f, false, false);
			__instance.muscleDamper = 0f;
			__instance.muscleWeight = 5f;
			AgonyLogic component2 = ((Component)componentInParent).GetComponent<AgonyLogic>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.ProcessHit();
			}
		}
	}
}