Decompiled source of OnePunchMarrow v1.0.0

Mods/OnePunchMarrow.dll

Decompiled 3 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;
using BoneLib.BoneMenu;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.PuppetMasta;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using OnePunchMarrow;
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(OPMCore), "OnePunchMarrow", "1.0.0", "Zooks", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("OnePunchMarrow")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OnePunchMarrow")]
[assembly: AssemblyTitle("OnePunchMarrow")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace OnePunchMarrow
{
	public class OPMCore : MelonMod
	{
		[CompilerGenerated]
		private sealed class <DelayMenuBuilder>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public OPMCore <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(3.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					ModMenu.BuildRadialMenu();
					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();
			}
		}

		public static OPMCore Instance { get; private set; }

		public override void OnInitializeMelon()
		{
			Instance = this;
			ModSettings.InitializeSettings();
			MelonCoroutines.Start(DelayMenuBuilder());
		}

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

		public override void OnUpdate()
		{
			SafeAction.Execute(Chronos.UpdateHitstopLerp);
			SafeAction.Execute(VFX.UpdateSparks);
		}
	}
	internal static class SafeAction
	{
		public static void Execute(Action process)
		{
			try
			{
				process();
			}
			catch
			{
			}
		}
	}
	internal static class ModSettings
	{
		public static MelonPreferences_Category Storage;

		public static MelonPreferences_Entry<int> OutputTarget;

		public static MelonPreferences_Entry<float> KineticForce;

		public static MelonPreferences_Entry<float> AscendDrift;

		public static MelonPreferences_Entry<float> ImpactFloor;

		public static MelonPreferences_Entry<float> HitstopSpan;

		public static MelonPreferences_Entry<bool> ExecuteNeckSnaps;

		public static MelonPreferences_Entry<bool> UseTimeFreeze;

		public static MelonPreferences_Entry<bool> UseAudio;

		public static MelonPreferences_Entry<bool> UseVisuals;

		public static void InitializeSettings()
		{
			Storage = MelonPreferences.CreateCategory("OPMSettings_Main");
			OutputTarget = Storage.CreateEntry<int>("OutputTarget", 1, "Scope (0=Off 1=Fist 2=Any)", (string)null, false, false, (ValueValidator)null, (string)null);
			KineticForce = Storage.CreateEntry<float>("KineticForce", 50f, "Thrust Force", (string)null, false, false, (ValueValidator)null, (string)null);
			AscendDrift = Storage.CreateEntry<float>("AscendDrift", 0.35f, "Lift Pitch", (string)null, false, false, (ValueValidator)null, (string)null);
			ImpactFloor = Storage.CreateEntry<float>("ImpactFloor", 2.5f, "Velocity Barrier", (string)null, false, false, (ValueValidator)null, (string)null);
			ExecuteNeckSnaps = Storage.CreateEntry<bool>("ExecuteNeckSnaps", true, "Neck Breaks", (string)null, false, false, (ValueValidator)null, (string)null);
			UseTimeFreeze = Storage.CreateEntry<bool>("UseTimeFreeze", true, "Enable Hitstop", (string)null, false, false, (ValueValidator)null, (string)null);
			HitstopSpan = Storage.CreateEntry<float>("HitstopSpan", 0.1f, "Hitstop Duration", (string)null, false, false, (ValueValidator)null, (string)null);
			UseAudio = Storage.CreateEntry<bool>("UseAudio", true, "Trigger Audio", (string)null, false, false, (ValueValidator)null, (string)null);
			UseVisuals = Storage.CreateEntry<bool>("UseVisuals", false, "Visual Flares", (string)null, false, false, (ValueValidator)null, (string)null);
			Storage.SaveToFile(false);
		}
	}
	internal static class ModMenu
	{
		public enum ActionType
		{
			Off,
			Fists_Only,
			Any_Impact
		}

		public static void BuildRadialMenu()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			Page val = Page.Root.CreatePage("OnePunch Marrow", Color.red, 0, true);
			val.CreateEnum("Interaction Focus", Color.white, (Enum)(ActionType)ModSettings.OutputTarget.Value, (Action<Enum>)delegate(Enum statusSet)
			{
				ModSettings.OutputTarget.Value = (int)(ActionType)(object)statusSet;
				ModSettings.Storage.SaveToFile(false);
			});
			Page val2 = val.CreatePage("Physics Modification", Color.cyan, 0, true);
			val2.CreateFloat("Payload Propulsion", Color.white, ModSettings.KineticForce.Value, 5f, 1f, 300f, (Action<float>)delegate(float x)
			{
				ModSettings.KineticForce.Value = x;
				ModSettings.Storage.SaveToFile(false);
			});
			val2.CreateFloat("Lift Compensation", Color.white, ModSettings.AscendDrift.Value, 0.05f, 0f, 2f, (Action<float>)delegate(float x)
			{
				ModSettings.AscendDrift.Value = x;
				ModSettings.Storage.SaveToFile(false);
			});
			val2.CreateFloat("Activation Restrict", Color.white, ModSettings.ImpactFloor.Value, 0.5f, 0f, 15f, (Action<float>)delegate(float x)
			{
				ModSettings.ImpactFloor.Value = x;
				ModSettings.Storage.SaveToFile(false);
			});
			Page val3 = val.CreatePage("Structural Fractures", Color.red, 0, true);
			val3.CreateBool("Crunch Axis (Neck Snaps)", Color.white, ModSettings.ExecuteNeckSnaps.Value, (Action<bool>)delegate(bool b)
			{
				ModSettings.ExecuteNeckSnaps.Value = b;
				ModSettings.Storage.SaveToFile(false);
			});
			Page val4 = val.CreatePage("Visual Audial Sync", Color.green, 0, true);
			val4.CreateBool("Trigger Stasis Freeze", Color.white, ModSettings.UseTimeFreeze.Value, (Action<bool>)delegate(bool b)
			{
				ModSettings.UseTimeFreeze.Value = b;
				ModSettings.Storage.SaveToFile(false);
			});
			val4.CreateFloat("Stasis Pause Span", Color.white, ModSettings.HitstopSpan.Value, 0.05f, 0.05f, 1f, (Action<float>)delegate(float x)
			{
				ModSettings.HitstopSpan.Value = x;
				ModSettings.Storage.SaveToFile(false);
			});
			val4.CreateBool("Produce Thud Acoustics", Color.white, ModSettings.UseAudio.Value, (Action<bool>)delegate(bool b)
			{
				ModSettings.UseAudio.Value = b;
				ModSettings.Storage.SaveToFile(false);
			});
			val4.CreateBool("Graphic Environment Flares", Color.white, ModSettings.UseVisuals.Value, (Action<bool>)delegate(bool b)
			{
				ModSettings.UseVisuals.Value = b;
				ModSettings.Storage.SaveToFile(false);
			});
		}
	}
	internal static class PhysicsHandler
	{
		private static Dictionary<int, float> debounceLocks = new Dictionary<int, float>();

		public static void ProcessCollision(MuscleCollisionBroadcaster nodeBroadcaster, Collision dataPhys, GameObject inputObj)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			MuscleCollisionBroadcaster nodeBroadcaster2 = nodeBroadcaster;
			Collision dataPhys2 = dataPhys;
			if (ModSettings.OutputTarget.Value == 0 || !HierarchyLimits.IsLocalPlayer(inputObj))
			{
				return;
			}
			RigManager componentInParent = ((Component)nodeBroadcaster2).GetComponentInParent<RigManager>();
			if (((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent == (Object)(object)Player.RigManager) || (ModSettings.OutputTarget.Value == 1 && !HierarchyLimits.IsFist(inputObj)))
			{
				return;
			}
			Vector3 relativeVelocity = dataPhys2.relativeVelocity;
			if (((Vector3)(ref relativeVelocity)).magnitude < ModSettings.ImpactFloor.Value)
			{
				return;
			}
			int instanceID = ((Object)((Component)nodeBroadcaster2).gameObject).GetInstanceID();
			if ((!debounceLocks.TryGetValue(instanceID, out var value) || !(Time.time < value + 0.35f)) && dataPhys2.contactCount > 0)
			{
				ContactPoint contact = dataPhys2.GetContact(0);
				Vector3 contactPt = ((ContactPoint)(ref contact)).point;
				SafeAction.Execute(delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					ForceBoneDisconnects(nodeBroadcaster2, contactPt);
				});
				SafeAction.Execute(delegate
				{
					LaunchLocalNPC(nodeBroadcaster2, dataPhys2);
				});
				SafeAction.Execute(delegate
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					DeployEnvironmentalEffects(contactPt);
				});
				debounceLocks[instanceID] = Time.time;
			}
		}

		private static void LaunchLocalNPC(MuscleCollisionBroadcaster physLocalNode, Collision internalColLogic)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			Vector3 relativeVelocity = internalColLogic.relativeVelocity;
			ContactPoint contact = internalColLogic.GetContact(0);
			Vector3 val = -((ContactPoint)(ref contact)).normal;
			Vector3 val2 = ((((Vector3)(ref relativeVelocity)).sqrMagnitude < 5f) ? val : ((Vector3)(ref relativeVelocity)).normalized);
			Vector3 val3 = val2 + Vector3.up * ModSettings.AscendDrift.Value;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			float value = ModSettings.KineticForce.Value;
			if ((Object)(object)physLocalNode.puppetMaster != (Object)null)
			{
				physLocalNode.puppetMaster.state = (State)1;
				physLocalNode.puppetMaster.Kill();
				Rigidbody component = ((Component)physLocalNode).GetComponent<Rigidbody>();
				List<Rigidbody> list = new List<Rigidbody>();
				GatherChildRBs(((Component)physLocalNode.puppetMaster).transform, list);
				{
					foreach (Rigidbody item in list)
					{
						float num = (((Object)(object)item == (Object)(object)component) ? 1f : ((item.mass > 4f) ? 0.9f : 0.6f));
						item.AddForce(normalized * (value * num), (ForceMode)2);
					}
					return;
				}
			}
			Rigidbody component2 = ((Component)physLocalNode).GetComponent<Rigidbody>();
			if (component2 != null)
			{
				component2.AddForce(normalized * value, (ForceMode)2);
			}
		}

		private static void ForceBoneDisconnects(MuscleCollisionBroadcaster jointTgt, Vector3 xyzLocData)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			if (!ModSettings.ExecuteNeckSnaps.Value)
			{
				return;
			}
			string text = ((Object)((Component)jointTgt).gameObject).name.ToLower();
			if (!text.Contains("head") && !text.Contains("neck") && !text.Contains("jaw"))
			{
				return;
			}
			ConfigurableJoint component = ((Component)jointTgt).GetComponent<ConfigurableJoint>();
			if ((Object)(object)component != (Object)null)
			{
				if (!text.Contains("jaw"))
				{
					component.angularXMotion = (ConfigurableJointMotion)2;
					component.angularYMotion = (ConfigurableJointMotion)2;
					component.angularZMotion = (ConfigurableJointMotion)2;
				}
				JointDrive val = default(JointDrive);
				((JointDrive)(ref val)).positionSpring = 0f;
				((JointDrive)(ref val)).positionDamper = 0f;
				((JointDrive)(ref val)).maximumForce = 0f;
				JointDrive slerpDrive = (component.angularYZDrive = (component.angularXDrive = val));
				component.slerpDrive = slerpDrive;
			}
			if (!text.Contains("jaw"))
			{
				Rigidbody component2 = ((Component)jointTgt).GetComponent<Rigidbody>();
				if (component2 != null)
				{
					component2.AddRelativeTorque(new Vector3(Random.Range(-400f, 400f), 2200f, Random.Range(-400f, 400f)), (ForceMode)2);
				}
			}
			if (ModSettings.UseAudio.Value)
			{
				Acoustics.PlaySnapAudio(xyzLocData);
			}
		}

		private static void GatherChildRBs(Transform activeAnchorTree, List<Rigidbody> rbs)
		{
			Rigidbody component = ((Component)activeAnchorTree).GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				rbs.Add(component);
			}
			for (int i = 0; i < activeAnchorTree.childCount; i++)
			{
				GatherChildRBs(activeAnchorTree.GetChild(i), rbs);
			}
		}

		private static void DeployEnvironmentalEffects(Vector3 pointOfImpact)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (ModSettings.UseTimeFreeze.Value)
			{
				Chronos.InitFreezeLogic(ModSettings.HitstopSpan.Value);
			}
			if (ModSettings.UseAudio.Value)
			{
				Acoustics.PlayPunchAudio(pointOfImpact);
			}
			if (ModSettings.UseVisuals.Value)
			{
				VFX.EmitSpark(pointOfImpact);
			}
		}
	}
	internal static class HierarchyLimits
	{
		public static bool IsLocalPlayer(GameObject uHostObj)
		{
			return (Object)(object)Player.RigManager != (Object)null && (Object)(object)uHostObj != (Object)null && (Object)(object)uHostObj.GetComponentInParent<RigManager>() == (Object)(object)Player.RigManager;
		}

		public static bool IsFist(GameObject wristTargetObj)
		{
			return (Object)(object)wristTargetObj != (Object)null && ((Object)(object)wristTargetObj.GetComponentInParent<PhysHand>() != (Object)null || ((Object)wristTargetObj).name.ToLower().Contains("hand") || ((Object)wristTargetObj).name.ToLower().Contains("fist"));
		}
	}
	internal static class Chronos
	{
		private static bool statePaused = false;

		private static bool isRecoveryActive = false;

		private static float syncThresTime = 0f;

		private static float scaleOrigTs = 1f;

		private static float fxdTsOrig = 0.02f;

		public static void InitFreezeLogic(float reqDurTStep)
		{
			if (!statePaused)
			{
				scaleOrigTs = Time.timeScale;
				fxdTsOrig = Time.fixedDeltaTime;
				Time.timeScale = 0.035f;
				Time.fixedDeltaTime = fxdTsOrig * Time.timeScale;
				syncThresTime = Time.unscaledTime + reqDurTStep;
				statePaused = true;
				isRecoveryActive = false;
			}
		}

		public static void UpdateHitstopLerp()
		{
			if (!statePaused)
			{
				return;
			}
			if (!isRecoveryActive && Time.unscaledTime >= syncThresTime)
			{
				isRecoveryActive = true;
			}
			if (isRecoveryActive)
			{
				Time.timeScale = Mathf.Lerp(Time.timeScale, scaleOrigTs, Time.unscaledDeltaTime * 6f);
				Time.fixedDeltaTime = fxdTsOrig * Time.timeScale;
				if (Time.timeScale >= 0.95f * scaleOrigTs)
				{
					Time.timeScale = scaleOrigTs;
					Time.fixedDeltaTime = fxdTsOrig;
					statePaused = false;
					isRecoveryActive = false;
				}
			}
		}
	}
	internal static class VFX
	{
		private class SparkData
		{
			public GameObject obj;

			public float startTime;
		}

		private static List<SparkData> activeSparks = new List<SparkData>();

		private static Material cacheShaderMat;

		public static void EmitSpark(Vector3 pos)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cacheShaderMat == (Object)null)
			{
				cacheShaderMat = new Material(Shader.Find("Hidden/Internal-Colored"));
				((Object)cacheShaderMat).hideFlags = (HideFlags)61;
				cacheShaderMat.SetInt("_SrcBlend", 5);
				cacheShaderMat.SetInt("_DstBlend", 1);
				cacheShaderMat.SetInt("_Cull", 0);
				cacheShaderMat.SetInt("_ZWrite", 8);
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			val.transform.position = pos;
			if ((Object)(object)Camera.main != (Object)null)
			{
				val.transform.LookAt(((Component)Camera.main).transform);
			}
			Renderer component = val.GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				component.material = cacheShaderMat;
				component.material.color = new Color(1f, 0.7f, 0f, 1f);
			}
			activeSparks.Add(new SparkData
			{
				obj = val,
				startTime = Time.unscaledTime
			});
		}

		public static void UpdateSparks()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			for (int num = activeSparks.Count - 1; num >= 0; num--)
			{
				SparkData sparkData = activeSparks[num];
				if (sparkData == null || (Object)(object)sparkData.obj == (Object)null)
				{
					activeSparks.RemoveAt(num);
				}
				else
				{
					float num2 = (Time.unscaledTime - sparkData.startTime) / 0.25f;
					if (num2 >= 1f)
					{
						Object.Destroy((Object)(object)sparkData.obj);
						activeSparks.RemoveAt(num);
					}
					else
					{
						float num3 = Mathf.Lerp(0.1f, 2.8f, num2);
						sparkData.obj.transform.localScale = new Vector3(num3, num3, num3);
						Renderer component = sparkData.obj.GetComponent<Renderer>();
						if ((Object)(object)component != (Object)null && (Object)(object)component.material != (Object)null)
						{
							Color color = component.material.color;
							color.a = Mathf.Lerp(1f, 0f, num2);
							component.material.color = color;
						}
						if ((Object)(object)Camera.main != (Object)null)
						{
							sparkData.obj.transform.LookAt(((Component)Camera.main).transform);
						}
					}
				}
			}
		}
	}
	internal static class Acoustics
	{
		public static void PlayPunchAudio(Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GenerateProceduralAudio(pos, 22050, 55f, 18f, 0f, 1f, 1f, includeCrackle: false);
		}

		public static void PlaySnapAudio(Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GenerateProceduralAudio(pos, 13230, 750f, 200f, 55f, 1.6f, 1.2f, includeCrackle: true);
		}

		private static void GenerateProceduralAudio(Vector3 pos, int sampleRate, float frequency, float decayA, float decayB, float vol, float life, bool includeCrackle)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			GameObject val = new GameObject("OPM_AudioNode");
			val.transform.position = pos;
			GameObject val2 = val;
			AudioSource val3 = val2.AddComponent<AudioSource>();
			AudioClip val4 = AudioClip.Create("SynthClip", sampleRate / 2, 1, sampleRate, false);
			float[] array = new float[sampleRate / 2];
			for (int i = 0; i < array.Length; i++)
			{
				float num = (float)i / (float)sampleRate;
				if (!includeCrackle)
				{
					array[i] = Mathf.Sin(num * 2f * (float)Math.PI * frequency) * Mathf.Exp((0f - num) * decayA);
				}
				else
				{
					array[i] = (Random.value * 2f - 1f) * 0.9f * Mathf.Exp((0f - num) * decayB) + Mathf.Sin(num * 2f * (float)Math.PI * frequency) * 0.95f * Mathf.Exp((0f - num) * decayA);
				}
			}
			val4.SetData(Il2CppStructArray<float>.op_Implicit(array), 0);
			val3.clip = val4;
			val3.spatialBlend = 1f;
			val3.volume = vol;
			val3.pitch = Random.Range(0.85f, 1.25f);
			val3.ignoreListenerPause = true;
			val3.Play();
			Object.Destroy((Object)(object)val2, life);
		}
	}
	[HarmonyPatch(typeof(MuscleCollisionBroadcaster), "OnCollisionEnter")]
	internal class CollisionListenerRouter
	{
		private static void Postfix(MuscleCollisionBroadcaster __instance, Collision collision)
		{
			MuscleCollisionBroadcaster __instance2 = __instance;
			Collision collision2 = collision;
			if ((Object)(object)__instance2 != (Object)null && collision2 != null && (Object)(object)collision2.gameObject != (Object)null)
			{
				SafeAction.Execute(delegate
				{
					PhysicsHandler.ProcessCollision(__instance2, collision2, collision2.gameObject);
				});
			}
		}
	}
}