using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.BoneMenu.Elements;
using MelonLoader;
using MelonLoader.Preferences;
using SLZ.Marrow.SceneStreaming;
using SLZ.Marrow.Utilities;
using SLZ.Rig;
using SuperHot;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SuperHot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SuperHot")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("945622a5-4786-4c52-87f3-624bc6542a09")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: MelonInfo(typeof(SuperHotMod), "SuperHot", "1.0.1", "Lakatrazz", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace SuperHot;
public class SuperHotMod : MelonMod
{
public const string Version = "1.0.1";
private const float VelocityMultiplier = 0.2f;
private const float VelocityPower = 4f;
private static bool _registeredPrefs = 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 MenuCategory BoneMenuCategory { 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;
_registeredPrefs = true;
}
public static void SetupBoneMenu()
{
//IL_0005: 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)
BoneMenuCategory = MenuManager.CreateCategory("SuperHot", Color.red);
BoneMenuEnabledElement = BoneMenuCategory.CreateBoolElement("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 (_registeredPrefs)
{
IsEnabled = MelonPrefEnabled.Value;
((GenericElement<bool>)(object)BoneMenuEnabledElement).SetValue(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_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
if ((int)SceneStreamer.Session.Status == 1 || Time.timeScale <= 0f || Time.timeSinceLevelLoad <= 3f || !IsEnabled || !Object.op_Implicit((Object)(object)Player.rigManager))
{
return;
}
if (Player.uiRig.popUpMenu.m_IsActivated)
{
if (!_wasUIOpen)
{
SetTimescale(1f);
}
_wasUIOpen = true;
}
else
{
_wasUIOpen = false;
ControllerRig controllerRig = Player.controllerRig;
float num = GetControllerVelocity(controllerRig.leftController) + GetControllerVelocity(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));
}
}