using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ForceBoost;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Core.ScriptableObjects;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
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), "ForceBoost", "1.0.0", "geom2543", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ForceBoost")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ForceBoost")]
[assembly: AssemblyTitle("ForceBoost")]
[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 ForceBoost
{
public class Core : MelonMod
{
private MelonPreferences_Category _cat;
private MelonPreferences_Entry<bool> _enabled;
private MelonPreferences_Entry<float> _force;
private MelonPreferences_Entry<float> _speed;
private MelonPreferences_Entry<bool> _verbose;
private readonly Dictionary<IntPtr, (float accel, float speed, float slerp)> _written = new Dictionary<IntPtr, (float, float, float)>();
private readonly Dictionary<IntPtr, float> _writtenTime = new Dictionary<IntPtr, float>();
private float _timer;
public override void OnInitializeMelon()
{
_cat = MelonPreferences.CreateCategory("ForceBoost");
_enabled = _cat.CreateEntry<bool>("Enabled", true, "Enabled", (string)null, false, false, (ValueValidator)null, (string)null);
_force = _cat.CreateEntry<float>("ForceMultiplier", 10f, "Force x", "Multiplies the force-pull acceleration force (and the force that turns the item into your hand)", false, false, (ValueValidator)null, (string)null);
_speed = _cat.CreateEntry<float>("SpeedMultiplier", 3f, "Speed x", "Multiplies the top speed items fly to your hand at (gravity-glove style: flight time is divided by it)", false, false, (ValueValidator)null, (string)null);
_verbose = _cat.CreateEntry<bool>("Verbose", true, "Verbose log", (string)null, false, false, (ValueValidator)null, (string)null);
((MelonBase)this).LoggerInstance.Msg($"Loaded. Force pull x{_force.Value}, speed x{_speed.Value}.");
}
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
_timer = 0.5f;
}
public override void OnUpdate()
{
if (!_enabled.Value)
{
return;
}
_timer -= Time.unscaledDeltaTime;
if (_timer > 0f)
{
return;
}
_timer = 2f;
try
{
Apply();
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("Apply: " + ex.Message);
_timer = 10f;
}
}
private void Apply()
{
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Max(0f, _force.Value);
float num2 = Mathf.Max(0.01f, _speed.Value);
foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<HVRForcePullSettings>()))
{
HVRForcePullSettings val = ((item != null) ? ((Il2CppObjectBase)item).TryCast<HVRForcePullSettings>() : null);
if (!((Object)(object)val == (Object)null) && (!_written.TryGetValue(((Il2CppObjectBase)val).Pointer, out (float, float, float) value) || !Mathf.Approximately(value.Item1, val.MaxAccelerationForce) || !Mathf.Approximately(value.Item2, val.MaxSpeed) || !Mathf.Approximately(value.Item3, val.SlerpMaxForce)))
{
float maxAccelerationForce = val.MaxAccelerationForce;
float maxSpeed = val.MaxSpeed;
float slerpMaxForce = val.SlerpMaxForce;
val.MaxAccelerationForce = maxAccelerationForce * num;
val.MaxSpeed = maxSpeed * num2;
if (!float.IsInfinity(slerpMaxForce) && slerpMaxForce < 1E+30f)
{
val.SlerpMaxForce = slerpMaxForce * num;
}
_written[((Il2CppObjectBase)val).Pointer] = (val.MaxAccelerationForce, val.MaxSpeed, val.SlerpMaxForce);
if (_verbose.Value)
{
((MelonBase)this).LoggerInstance.Msg($"'{((Object)val).name}': accel {maxAccelerationForce:F0} -> {val.MaxAccelerationForce:F0}, speed {maxSpeed:F1} -> {val.MaxSpeed:F1}, turn force {slerpMaxForce:F0} -> {val.SlerpMaxForce:F0}");
}
}
}
foreach (Object item2 in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<HVRForceGrabber>()))
{
HVRForceGrabber val2 = ((item2 != null) ? ((Il2CppObjectBase)item2).TryCast<HVRForceGrabber>() : null);
if (!((Object)(object)val2 == (Object)null) && (!_writtenTime.TryGetValue(((Il2CppObjectBase)val2).Pointer, out var value2) || !Mathf.Approximately(value2, val2.ForceTime)))
{
float forceTime = val2.ForceTime;
if (forceTime > 0f)
{
val2.ForceTime = forceTime / num2;
}
_writtenTime[((Il2CppObjectBase)val2).Pointer] = val2.ForceTime;
if (_verbose.Value)
{
((MelonBase)this).LoggerInstance.Msg($"Grabber '{((Object)val2).name}' style {val2.GrabStyle}: glove flight time {forceTime:F2} -> {val2.ForceTime:F2}");
}
}
}
}
}
}