Decompiled source of ProcedualAnimation v1.0.1

Procudeal aimation.dll

Decompiled 13 hours 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 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.5.3", "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__16 : 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__16(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__15 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public AgonyLogic <>4__this;

			private PuppetMaster <pm>5__1;

			private float <elapsed>5__2;

			private float <force>5__3;

			private List<Rigidbody>.Enumerator <>s__4;

			private Rigidbody <rb>5__5;

			private List<Rigidbody>.Enumerator <>s__6;

			private Rigidbody <leg>5__7;

			private Vector3 <kickDir>5__8;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<pm>5__1 = null;
				<>s__4 = default(List<Rigidbody>.Enumerator);
				<rb>5__5 = null;
				<>s__6 = default(List<Rigidbody>.Enumerator);
				<leg>5__7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Expected O, but got Unknown
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0390: Unknown result type (might be due to invalid IL or missing references)
				//IL_039a: Expected O, but got Unknown
				//IL_0379: Unknown result type (might be due to invalid IL or missing references)
				//IL_0383: Unknown result type (might be due to invalid IL or missing references)
				//IL_0274: Unknown result type (might be due to invalid IL or missing references)
				//IL_027f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0284: Unknown result type (might be due to invalid IL or missing references)
				//IL_0289: Unknown result type (might be due to invalid IL or missing references)
				//IL_028c: Unknown result type (might be due to invalid IL or missing references)
				//IL_029d: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ea: 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_0300: Unknown result type (might be due to invalid IL or missing references)
				//IL_0311: 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();
					<pm>5__1 = <>4__this._brain.puppetMaster;
					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__2 = 0f;
					goto IL_03ab;
				case 2:
					<>1__state = -1;
					goto IL_03ab;
				case 3:
					{
						<>1__state = -1;
						<>4__this._isSuffering = false;
						return false;
					}
					IL_03ab:
					if (<>4__this._isSuffering && <elapsed>5__2 < Main.struggleTime)
					{
						<elapsed>5__2 += Time.fixedDeltaTime;
						<force>5__3 = 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__3 * 1.2f), (ForceMode)0);
						}
						<>s__4 = <>4__this._limbs.GetEnumerator();
						try
						{
							while (<>s__4.MoveNext())
							{
								<rb>5__5 = <>s__4.Current;
								if ((Object)(object)<rb>5__5 != (Object)null && (Object)(object)<>4__this._pelvis != (Object)null)
								{
									Rigidbody obj = <rb>5__5;
									val = <>4__this._pelvis.position - <rb>5__5.position;
									obj.AddForce(((Vector3)(ref val)).normalized * <force>5__3, (ForceMode)0);
								}
								<rb>5__5 = null;
							}
						}
						finally
						{
							((IDisposable)<>s__4).Dispose();
						}
						<>s__4 = default(List<Rigidbody>.Enumerator);
						<>s__6 = <>4__this._legs.GetEnumerator();
						try
						{
							while (<>s__6.MoveNext())
							{
								<leg>5__7 = <>s__6.Current;
								if (!((Object)(object)<leg>5__7 == (Object)null) && !((Object)(object)<>4__this._pelvis == (Object)null))
								{
									Rigidbody obj2 = <leg>5__7;
									val = <>4__this._pelvis.position - <leg>5__7.position;
									obj2.AddForce(((Vector3)(ref val)).normalized * (<force>5__3 * 0.8f), (ForceMode)0);
									if (Random.value > 0.98f)
									{
										val = <leg>5__7.position - <>4__this._pelvis.position;
										<kickDir>5__8 = ((Vector3)(ref val)).normalized + Random.onUnitSphere;
										<leg>5__7.AddForce(((Vector3)(ref <kickDir>5__8)).normalized * (<force>5__3 * 0.4f), (ForceMode)1);
									}
									<leg>5__7 = null;
								}
							}
						}
						finally
						{
							((IDisposable)<>s__6).Dispose();
						}
						<>s__6 = default(List<Rigidbody>.Enumerator);
						if ((Object)(object)<>4__this._pelvis != (Object)null)
						{
							<>4__this._pelvis.AddForce(Vector3.down * 20f, (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 bool _isSuffering = 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[4] { "chest", "spine", "neck", "head" };

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

		private bool _isSmallEnemy = false;

		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();
			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)
				{
					continue;
				}
				string[] array4 = armKeywords;
				foreach (string value4 in array4)
				{
					if (text2.Contains(value4))
					{
						_limbs.Add(item.rigidbody);
						break;
					}
				}
			}
		}

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

		[IteratorStateMachine(typeof(<ResetSequence>d__16))]
		private IEnumerator ResetSequence()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ResetSequence>d__16(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 NOT animation becuase it got a idiot typo IS ACTIVE!!!!!! wow i cant belive it wowwwwwwwww");
			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(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();
			}
		}
	}
}