Decompiled source of PowerThrow v1.0.1

Mods/PowerThrow.dll

Decompiled 2 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 HarmonyLib;
using Il2CppFemur;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using PowerThrow;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "PowerThrow", "1.0.1", "TheUltimateNuke", null)]
[assembly: MelonGame("Boneloaf", "Gang Beasts")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PowerThrow")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+78c9811dba6df59097566be1bdb3dc8aaa514b24")]
[assembly: AssemblyProduct("PowerThrow")]
[assembly: AssemblyTitle("PowerThrow")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PowerThrow
{
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPatch(typeof(ControlHandeler_Human), "PunchGrab")]
		[HarmonyPrefix]
		private static void Prefix(ControlHandeler_Human __instance, Arm arm)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if ((__instance.IsThisArmJustUp((Arm)1) || __instance.IsThisArmJustUp((Arm)0)) && !(__instance.armActionTimer <= 0.2f) && ((ControlHandeler)__instance).onGround && !((Object)(object)__instance.grabRigidbody == (Object)null))
			{
				MelonCoroutines.Start(Mod.WaitForArmRelease(__instance, arm));
			}
		}
	}
	public class Mod : MelonMod
	{
		[CompilerGenerated]
		private sealed class <WaitForArmRelease>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ControlHandeler_Human __instance;

			public Arm arm;

			private Rigidbody <rb>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0068: 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_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Invalid comparison between Unknown and I4
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<rb>5__2 = __instance.grabRigidbody;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)__instance.grabJoint != (Object)null)
				{
					<rb>5__2 = __instance.grabRigidbody;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				bool isRagdoll = false;
				Arm val = arm;
				if ((int)val != 0)
				{
					if ((int)val == 1)
					{
						isRagdoll = ((ControlHandeler)__instance).actor.bodyHandeler.rightGrabInteractable.partOfRagdoll;
					}
				}
				else
				{
					isRagdoll = ((ControlHandeler)__instance).actor.bodyHandeler.leftGrabInteractable.partOfRagdoll;
				}
				ApplyThrowImpulse(<rb>5__2, isRagdoll);
				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();
			}
		}

		private static readonly MelonPreferences_Category _preferencesCategory = MelonPreferences.CreateCategory("PowerThrow", "PowerThrow");

		private static readonly MelonPreferences_Entry<float> _throwForcePref = _preferencesCategory.CreateEntry<float>("ThrowForce", 800f, "Throw Force", (string)null, false, false, (ValueValidator)null, (string)null);

		public static Instance Logger => Melon<Mod>.Logger;

		public static float ThrowForce
		{
			get
			{
				return _throwForcePref.Value;
			}
			set
			{
				_throwForcePref.Value = value;
			}
		}

		[IteratorStateMachine(typeof(<WaitForArmRelease>d__7))]
		internal static IEnumerator WaitForArmRelease(ControlHandeler_Human __instance, Arm arm)
		{
			//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 <WaitForArmRelease>d__7(0)
			{
				__instance = __instance,
				arm = arm
			};
		}

		private static void ApplyThrowImpulse(Rigidbody rb, bool isRagdoll)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			rb.AddForce(rb.velocity * ThrowForce * (isRagdoll ? 80f : 1f), (ForceMode)2);
		}

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg(ConsoleColor.Green, "Mod PowerThrow initialized!");
		}
	}
	internal static class MyModInfo
	{
		public const string Author = "TheUltimateNuke";

		public const string Name = "PowerThrow";

		public const string Version = "1.0.1";
	}
}