using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.SceneStreaming;
using Il2CppSLZ.Marrow.Utilities;
using MelonLoader;
using MelonLoader.Preferences;
using SuperHot;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SuperHot")]
[assembly: MelonInfo(typeof(SuperHotMod), "SuperHot", "1.1.0", "Lakatrazz", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace SuperHot;
public class SuperHotMod : MelonMod
{
public const string Version = "1.1.0";
private const float VelocityMultiplier = 0.2f;
private const float VelocityPower = 4f;
private static bool _preferencesSetup = false;
private static float _lastTime = 1f;
private static float _springVelocity;
private static bool _wasUIOpen = false;
public static SuperHotMod Instance { get; private set; }
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 Page MainPage { get; private set; }
public static BoolElement BoneMenuEnabledElement { get; private set; }
public override void OnInitializeMelon()
{
Instance = this;
SetupMelonPrefs();
SetupBoneMenu();
}
public static void SetupMelonPrefs()
{
MelonPrefCategory = MelonPreferences.CreateCategory("SuperHot");
MelonPrefEnabled = MelonPrefCategory.CreateEntry<bool>("IsEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
IsEnabled = MelonPrefEnabled.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)
MainPage = Page.Root.CreatePage("SuperHot", Color.red, 0, true);
BoneMenuEnabledElement = MainPage.CreateBool("Mod Toggle", Color.yellow, IsEnabled, (Action<bool>)OnSetEnabled);
}
public static void OnSetEnabled(bool value)
{
IsEnabled = value;
MelonPrefEnabled.Value = value;
MelonPrefCategory.SaveToFile(false);
if (!IsEnabled)
{
SetTimescale(1f);
}
}
public override void OnPreferencesLoaded()
{
if (_preferencesSetup)
{
IsEnabled = MelonPrefEnabled.Value;
BoneMenuEnabledElement.Value = IsEnabled;
}
}
private static void SetTimescale(float value)
{
if (!(value <= 0f))
{
Time.timeScale = value;
if (IsEnabled)
{
float refreshRate = MarrowGame.xr.Display.GetRefreshRate();
Time.fixedDeltaTime = Mathf.Clamp(value, 0.05f, 1f) / refreshRate;
}
}
}
public override void OnUpdate()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (!IsEnabled || (int)SceneStreamer.Session.Status == 1 || Time.timeScale <= 0f || Time.timeSinceLevelLoad <= 3f || (Object)(object)Player.RigManager == (Object)null)
{
return;
}
if (UIRig.Instance.popUpMenu.m_IsActivated)
{
if (!_wasUIOpen)
{
SetTimescale(1f);
}
_wasUIOpen = true;
}
else
{
_wasUIOpen = false;
OpenControllerRig controllerRig = Player.ControllerRig;
float num = GetControllerVelocity(((ControllerRig)controllerRig).leftController) + GetControllerVelocity(((ControllerRig)controllerRig).rightController);
Vector3 pelvisVelocity = Player.PhysicsRig.pelvisVelocity;
float num2 = Mathf.Clamp(Mathf.Pow(num + ((Vector3)(ref pelvisVelocity)).magnitude * 0.2f, 4f), 0.0001f, 1f);
SetTimescale(_lastTime = Mathf.SmoothDamp(_lastTime, num2, ref _springVelocity, 0.25f, 10f, Time.unscaledDeltaTime));
}
}
private static float GetControllerVelocity(BaseController controller)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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)
Vector3 relativeVelocityInWorld = controller.GetRelativeVelocityInWorld();
float num = ((Vector3)(ref relativeVelocityInWorld)).magnitude * 0.2f;
Vector2 thumbStickAxis = controller.GetThumbStickAxis();
return num + (Mathf.Abs(thumbStickAxis.x) + Mathf.Abs(thumbStickAxis.y));
}
}