Decompiled source of FlappyLab v1.1.1

Mods/FlappyLab.dll

Decompiled 2 months 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 BoneLib.Notifications;
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.1.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+f16fd200d7b7b05d50cb200173fab53403b04eae")]
[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 = 50f;

		private static bool _preferencesSetup = false;

		public static bool isEnabled { get; private set; }

		public static MelonPreferences_Category MelonPrefCategory { get; private set; }

		public static MelonPreferences_Entry<bool> MelonPrefEnabled { 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 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);
			FlightStrengthSetting = MelonPrefCategory.CreateEntry<float>("FlightStrength", flightStrength, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			isEnabled = MelonPrefEnabled.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_00a6: 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);
			strengthElement = mainPage.CreateFloat("Flight Strength", Color.cyan, flightStrength, 1f, 0f, 100f, (Action<float>)OnSetFlightStrength);
			resetElement = mainPage.CreateFunction("Reset Preferences", Color.red, (Action)OnResetPreferences);
		}

		private static void OnSetEnabled(bool value)
		{
			isEnabled = value;
			MelonPrefEnabled.Value = isEnabled;
			MelonPrefCategory.SaveToFile(false);
		}

		public override void OnPreferencesLoaded()
		{
			if (_preferencesSetup)
			{
				isEnabled = MelonPrefEnabled.Value;
				flightStrength = FlightStrengthSetting.Value;
				enabledElement.Value = isEnabled;
				strengthElement.Value = flightStrength;
			}
		}

		private static void OnResetPreferences()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003b: 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)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0067: Expected O, but got Unknown
			flightStrength = 50f;
			strengthElement.Value = flightStrength;
			MelonPrefCategory.SaveToFile(true);
			Notifier.Send(new Notification
			{
				PopupLength = 4f,
				Type = (NotificationType)0,
				ShowTitleOnPopup = true,
				Title = NotificationText.op_Implicit("FlappyLab"),
				Message = NotificationText.op_Implicit("Preferences have been reset.")
			});
		}

		private static void OnSetFlightStrength(float value)
		{
			flightStrength = value;
			FlightStrengthSetting.Value = flightStrength;
			MelonPrefCategory.SaveToFile(false);
		}

		public override void OnFixedUpdate()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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)
			if (!Player.HandsExist || !isEnabled)
			{
				return;
			}
			PhysicsRig physicsRig = Player.PhysicsRig;
			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));
				}
			}
		}
	}
}