Decompiled source of Hexaback v1.0.2

Mods/HexaBack.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using HarmonyLib;
using HexaBack;
using Il2CppSLZ.Marrow;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
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(Core), "HexaBack", "1.0.0", "freakycheesy", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("HexaBack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c1d70bea404ed46b49d9980aa6778fea6466f2d4")]
[assembly: AssemblyProduct("HexaBack")]
[assembly: AssemblyTitle("HexaBack")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 HexaBack
{
	public class Core : MelonMod
	{
		[HarmonyPatch(typeof(PhysicsRig))]
		public static class ClimbPatch
		{
			[HarmonyPatch("CheckClimb")]
			[HarmonyPrefix]
			public static bool CheckDangle(PhysicsRig __instance, ref bool __result)
			{
				if (modEnabled.Value)
				{
					__result = false;
					return false;
				}
				return __result;
			}
		}

		public static Page page;

		public static MelonPreferences_Category category;

		public static MelonPreferences_Entry<bool> modEnabled;

		private const float jumpVelocityDivider = 1.5f;

		private const float gripMultiplier = 0.1f;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Initialized HexaBack.");
			CreatePrefs();
			CreateBoneMenu();
			Hooking.OnLevelLoaded += delegate
			{
				MakeHeptabodyHexabody(!modEnabled.Value);
			};
		}

		private static void CreatePrefs()
		{
			category = MelonPreferences.CreateCategory("Hexaback");
			category.SetFilePath("UserData/freakycheesy.cfg", true);
			modEnabled = category.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		}

		private void CreateBoneMenu()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			page = Page.Root.CreatePage("Hexaback", Color.green, 0, true);
			page.CreateBool("Toggle Mod", Color.green, modEnabled.Value, (Action<bool>)delegate(bool a)
			{
				modEnabled.Value = a;
				MakeHeptabodyHexabody(!modEnabled.Value);
				Save();
			});
		}

		private static void Save()
		{
			category.SaveToFile(true);
			MelonPreferences.Save();
		}

		public override void OnApplicationQuit()
		{
			MelonPreferences.Save();
			((MelonBase)this).OnApplicationQuit();
		}

		private static void MakeHeptabodyHexabody(bool revert)
		{
			PhysicsRig physicsRig = Player.PhysicsRig;
			Collider component = ((Component)((Rig)physicsRig).m_shoulderLf).GetComponent<Collider>();
			Collider component2 = ((Component)((Rig)physicsRig).m_shoulderRt).GetComponent<Collider>();
			Hand[] array = (Hand[])(object)new Hand[2] { physicsRig.leftHand, physicsRig.rightHand };
			component.isTrigger = !revert;
			component2.isTrigger = !revert;
			float jumpVelocity = ((Rig)physicsRig).manager.remapHeptaRig.jumpVelocity;
			((Rig)physicsRig).manager.remapHeptaRig.jumpVelocity = (revert ? (jumpVelocity * 1.5f) : (jumpVelocity / 1.5f));
			Hand[] array2 = array;
			foreach (Hand val in array2)
			{
				float gripMult = val.physHand.gripMult;
				gripMult = (revert ? (gripMult / 0.1f) : (gripMult * 0.1f));
				val.physHand.gripMult = gripMult;
			}
		}
	}
}