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.2", "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 = Vector3.zero;
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()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
MelonLogger.Msg("Disabling Moon Program...");
GetPlayerReferences();
Physics.gravity = Gravity.Normal;
resetSystem.useAirborneReset = true;
resetSystem.useSceneBoundariesReset = true;
thrust = null;
isActive = false;
}
private void SetupMod()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
MelonLogger.Msg("Enabling Moon Program...");
bool flag = Players.IsHost();
if (currentScene == "Gym" || (currentScene == "Park" && flag))
{
GetPlayerReferences();
if (hasRefs)
{
if (thrust == null)
{
thrust = new ThrusterLocomotion(playerRb, playerHead);
}
Physics.gravity = Gravity.Moon;
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 = 100f;
private const float boostSpeed = 200f;
private const float maxThrustVelocity = 3f;
private const float maxBoostVelocity = 6f;
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 = 100f)
{
//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 < 3f)
{
playerRb.AddForce(val, (ForceMode)1);
}
}
private void HandleThrust()
{
if (LeftController.GetTrigger() > 0.5f)
{
ThrustAtVector(vectorLeft);
}
if (RightController.GetTrigger() > 0.5f)
{
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 * 200f;
float num = Vector3.Dot(playerRb.velocity, ((Vector3)(ref val)).normalized);
if (num < 6f)
{
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();
}
}