Decompiled source of FlappyLab v1.0.1

Mods/FlappyLab.dll

Decompiled a day 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 FlappyLab;
using Il2CppSLZ.Marrow;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "FlappyLab", "1.0.0", "Cirket", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FlappyLab")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FlappyLab")]
[assembly: AssemblyTitle("FlappyLab")]
[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]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 FlappyLab
{
	public class Core : MelonMod
	{
		public static float flightStrength = 40f;

		public static bool _preferencesSetup = false;

		public static bool isEnabled { get; private set; }

		public static bool basicMode { get; private set; }

		public static MelonPreferences_Category MelonPrefCategory { get; private set; }

		public static MelonPreferences_Entry<bool> MelonPrefEnabled { get; private set; }

		public static MelonPreferences_Entry<bool> MelonPrefBasic { get; private set; }

		public static MelonPreferences_Entry<float> FlightStrengthSetting { get; private set; }

		public static Page mainPage { get; private set; }

		public static BoolElement enabledElement { get; private set; }

		public static BoolElement basicElement { get; private set; }

		public static FloatElement strengthElement { get; private set; }

		public static FunctionElement resetElement { get; private set; }

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("FlappyLab Initialized.");
			SetupMelonPrefs();
			SetupBoneMenu();
		}

		public static void SetupMelonPrefs()
		{
			MelonPrefCategory = MelonPreferences.CreateCategory("FlappyLab");
			MelonPrefEnabled = MelonPrefCategory.CreateEntry<bool>("isEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MelonPrefBasic = MelonPrefCategory.CreateEntry<bool>("basicMode", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			FlightStrengthSetting = MelonPrefCategory.CreateEntry<float>("FlightStrength", 20f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			isEnabled = MelonPrefEnabled.Value;
			basicMode = MelonPrefBasic.Value;
			flightStrength = FlightStrengthSetting.Value;
			_preferencesSetup = true;
		}

		public static void SetupBoneMenu()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			mainPage = Page.Root.CreatePage("FlappyLab", Color.cyan, 0, true);
			enabledElement = mainPage.CreateBool("Enabled", Color.white, isEnabled, (Action<bool>)OnSetEnabled);
			basicElement = mainPage.CreateBool("Basic Mode", Color.white, basicMode, (Action<bool>)OnSetBasic);
			strengthElement = mainPage.CreateFloat("Flight Strength", Color.cyan, 20f, 1f, 0f, 100f, (Action<float>)OnSetFlightStrength);
			resetElement = mainPage.CreateFunction("Reset Preferences", Color.red, (Action)OnResetPreferences);
		}

		private static void OnSetEnabled(bool value)
		{
			isEnabled = value;
		}

		private static void OnSetBasic(bool value)
		{
			basicMode = value;
		}

		private static void OnResetPreferences()
		{
			flightStrength = 40f;
			strengthElement.Value = flightStrength;
		}

		private static void OnSetFlightStrength(float value)
		{
			flightStrength = value;
		}

		public override void OnFixedUpdate()
		{
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			if (!Player.HandsExist || !isEnabled)
			{
				return;
			}
			PhysicsRig physicsRig = Player.PhysicsRig;
			if (!basicMode)
			{
				BaseController[] array = (BaseController[])(object)new BaseController[2]
				{
					Player.LeftController,
					Player.RightController
				};
				Vector3 val3 = default(Vector3);
				foreach (BaseController val in array)
				{
					Vector3 localVelocity = val._localVelocity;
					Rigidbody pelvisRb = physicsRig.torso._pelvisRb;
					Vector3 val2 = pelvisRb.mass * flightStrength * localVelocity;
					((Vector3)(ref val3))..ctor(val2.x, Mathf.Clamp(val2.y, val2.y, 0f), val2.z);
					if ((Object)(object)val == (Object)(object)Player.LeftController)
					{
						pelvisRb.AddForce(Vector3.Project(-val3, -((Component)val).transform.right));
					}
					else
					{
						pelvisRb.AddForce(Vector3.Project(-val3, ((Component)val).transform.right));
					}
				}
			}
			else
			{
				Hand[] array2 = (Hand[])(object)new Hand[2] { physicsRig.leftHand, physicsRig.rightHand };
				for (int i = 0; i < array2.Length; i++)
				{
					float y = array2[i].rb.velocity.y;
					float num = Mathf.Abs(Mathf.Clamp(y, y, 0f));
					Rigidbody pelvisRb2 = physicsRig.torso._pelvisRb;
					float num2 = pelvisRb2.mass * flightStrength * num;
					pelvisRb2.AddForce(new Vector3(0f, num2, 0f));
				}
			}
		}
	}
}