using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
using MoonBending;
using RumbleModdingAPI;
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(MoonProgram), "MoonBending", "1.0.4", "DefinitelyNotEnder", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: AssemblyTitle("MoonBending")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoonBending")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("27593270-059E-4017-BC8C-3D843C14A2A0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoonBending;
public class ContinuousRotation
{
private const float rotationSpeed = 115f;
}
public class ButtonState
{
public bool IsPressed { get; private set; }
public bool WasPressed { get; private set; }
public bool Pressed => IsPressed && !WasPressed;
public bool Released => !IsPressed && WasPressed;
public void UpdateState(bool currentState)
{
WasPressed = IsPressed;
IsPressed = currentState;
}
}
public static class Gravity
{
public static readonly Vector3 Moon = new Vector3(0f, -1.625f, 0f);
public static readonly Vector3 Light = new Vector3(0f, -0.5f, 0f);
public static readonly Vector3 Zero = new Vector3(0f, 0f, 0f);
public static readonly Vector3 Normal = new Vector3(0f, -9.81f, 0f);
}
public static class RumbleLayers
{
public static readonly int Moveable = 14;
public static readonly int Spawnable = 9;
public static readonly int Environment = 10;
}
public class MoonProgram : MelonMod
{
private string currentScene = "Loader";
private bool isActive;
private bool hasRefs;
private GameObject playerGo;
private Transform playerHead;
private PlayerManager playerManager;
private Rigidbody playerRb;
private Transform playerVROrigin;
private PlayerResetSystem resetSystem;
private ThrusterLocomotion thrust;
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
currentScene = sceneName;
if (isActive)
{
CleanupMod();
}
}
private void GetPlayerReferences()
{
try
{
if (!((Object)(object)playerGo != (Object)null))
{
playerManager = Singleton<PlayerManager>.instance;
playerGo = ((Component)playerManager.localPlayer.Controller).gameObject;
resetSystem = playerGo.GetComponentInChildren<PlayerResetSystem>();
playerVROrigin = playerGo.transform.Find("VR");
playerRb = ((Component)playerVROrigin).GetComponent<Rigidbody>();
playerHead = playerGo.transform.Find("VR/Headset Offset/Headset");
hasRefs = true;
}
}
catch
{
}
}
private void CleanupMod()
{
try
{
MelonLogger.Msg("Disabling Moon Program...");
GetPlayerReferences();
if (!hasRefs)
{
return;
}
foreach (Rigidbody componentsInChild in playerGo.GetComponentsInChildren<Rigidbody>())
{
componentsInChild.useGravity = true;
}
resetSystem.useAirborneReset = true;
resetSystem.useSceneBoundariesReset = true;
thrust = null;
isActive = false;
}
catch
{
MelonLogger.Msg("Unable to disable mod.");
}
}
private void SetupMod()
{
MelonLogger.Msg("Enabling Moon Program...");
bool flag = Players.IsHost();
if (currentScene == "Gym" || (flag && currentScene == "Park"))
{
GetPlayerReferences();
if (!hasRefs)
{
return;
}
if (thrust == null)
{
thrust = new ThrusterLocomotion(playerRb, playerHead);
}
foreach (Rigidbody componentsInChild in playerGo.GetComponentsInChildren<Rigidbody>())
{
componentsInChild.useGravity = false;
}
resetSystem.useAirborneReset = false;
resetSystem.useSceneBoundariesReset = false;
isActive = true;
}
else
{
MelonLogger.Msg("Unable to enable Moon Program - Not in a valid scene or not the host");
}
}
public override void OnUpdate()
{
if (Input.GetKeyDown((KeyCode)103))
{
if (isActive)
{
CleanupMod();
}
else
{
SetupMod();
}
}
}
public override void OnFixedUpdate()
{
if (isActive)
{
thrust?.HandleThrusterLocomotion();
}
}
}
public class ThrusterLocomotion
{
private const float InputThreshold = 0.5f;
private const float BreakThreshold = 3.5f;
private const float ThrustSpeed = 128f;
private const float BoostSpeed = 256f;
private const float MaxThrustVelocity = 4f;
private const float MaxBoostVelocity = 8f;
private readonly ButtonState boostState = new ButtonState();
private readonly ButtonState breakState = new ButtonState();
private readonly Rigidbody playerRb;
private readonly Transform playerHead;
private readonly Transform vectorLeft;
private readonly Transform vectorRight;
public ThrusterLocomotion(Rigidbody rb, Transform head)
{
playerRb = rb;
playerHead = head;
GameObject gameObject = ((Component)Managers.GetPlayerManager().localPlayer.Controller).gameObject;
vectorLeft = ((Component)gameObject.transform.Find("VR/Left Controller/IkTarget")).transform;
vectorRight = ((Component)gameObject.transform.Find("VR/Right Controller/IkTarget")).transform;
}
private void ThrustAtVector(Transform thrustVector, float speed = 128f)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_0025: 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)
Vector3 val = thrustVector.up * speed * Time.fixedDeltaTime;
float num = Vector3.Dot(playerRb.velocity, ((Vector3)(ref val)).normalized);
if (num < 4f)
{
playerRb.AddForce(val, (ForceMode)1);
}
}
private void HandleThrust()
{
if (LeftController.GetTrigger() > 0.5f && (Object)(object)vectorLeft != (Object)null)
{
ThrustAtVector(vectorLeft);
}
if (RightController.GetTrigger() > 0.5f && (Object)(object)vectorRight != (Object)null)
{
ThrustAtVector(vectorRight);
}
}
private void HandleBoost()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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)
boostState.UpdateState(RightController.GetSecondary() > 0.5f);
if (boostState.Pressed)
{
Vector3 val = playerHead.forward * 256f;
float num = Vector3.Dot(playerRb.velocity, ((Vector3)(ref val)).normalized);
if (num < 8f)
{
playerRb.AddForce(val, (ForceMode)1);
}
}
}
private void HandleBreak()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0061: 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)
breakState.UpdateState(LeftController.GetSecondary() > 0.5f);
if (breakState.Pressed)
{
Vector3 velocity = playerRb.velocity * 0.5f;
if (((Vector3)(ref velocity)).magnitude < 3.5f)
{
velocity = Vector3.zero;
}
playerRb.velocity = velocity;
}
}
public void HandleThrusterLocomotion()
{
HandleThrust();
HandleBreak();
HandleBoost();
}
}