using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BackflipMod;
using Il2Cpp;
using Il2CppHexabodyVR.PlayerController;
using Il2CppHurricaneVR.Framework.Shared;
using MelonLoader;
using Microsoft.CodeAnalysis;
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(Core), "Backflip", "0.1.6", "coope", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Backflip")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Backflip")]
[assembly: AssemblyTitle("Backflip")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 BackflipMod
{
public class Core : MelonMod
{
private const float FlipDuration = 0.65f;
private const float StickDownThreshold = -0.65f;
private const float TuckDepth = 0.22f;
private const float JumpWindow = 0.45f;
private HexaBodyPlayer4 _body;
private HVRHexaBodyInputs _inputs;
private Transform _camera;
private Transform _cameraParent;
private Transform _pivot;
private float _nextScan;
private float _jumpWindowUntil;
private bool _needsRelease;
private bool _flipping;
private float _flipTime;
private float _lastAngle;
private float _lastDip;
public override void OnInitializeMelon()
{
((MelonBase)this).LoggerInstance.Msg("Backflip loaded");
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
_body = null;
_inputs = null;
_camera = null;
_cameraParent = null;
_pivot = null;
_jumpWindowUntil = 0f;
_needsRelease = false;
_flipping = false;
_nextScan = 0f;
}
public override void OnUpdate()
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Invalid comparison between Unknown and I4
if (_flipping)
{
return;
}
float unscaledTime = Time.unscaledTime;
if (unscaledTime >= _nextScan)
{
_nextScan = unscaledTime + 1f;
FindPlayer();
}
if (!((Object)(object)_body == (Object)null) && !((Object)(object)_inputs == (Object)null) && !((Object)(object)_camera == (Object)null))
{
float turnY = GetTurnY();
if (turnY > -0.3f)
{
_needsRelease = false;
}
if ((int)_body._legStatus == 1)
{
_jumpWindowUntil = unscaledTime + 0.45f;
}
if (!_needsRelease && !(unscaledTime > _jumpWindowUntil) && !(turnY > -0.65f))
{
StartFlip();
}
}
}
public override void OnLateUpdate()
{
if (!_flipping)
{
return;
}
if ((Object)(object)_camera == (Object)null || (Object)(object)_pivot == (Object)null)
{
StopFlip();
return;
}
_flipTime += Time.unscaledDeltaTime;
float num = _flipTime / 0.65f;
if (num >= 1f)
{
StopFlip();
return;
}
float num2 = 360f * num;
float num3 = Mathf.Sin(num * (float)Math.PI) * 0.22f;
ApplyFlip(num2 - _lastAngle, num3 - _lastDip);
_lastAngle = num2;
_lastDip = num3;
}
private void ApplyFlip(float dAngle, float dDip)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = _camera.position;
Quaternion rotation = _camera.rotation;
Quaternion val = Quaternion.Euler(0f - dAngle, 0f, 0f);
Quaternion val2 = rotation * val * Quaternion.Inverse(rotation);
_pivot.rotation = val2 * _pivot.rotation;
Vector3 val3 = Vector3.Scale(_camera.localPosition, _pivot.lossyScale);
_pivot.position = position - _pivot.rotation * val3 - Vector3.up * dDip;
}
private void StartFlip()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_002c: 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_004e: Unknown result type (might be due to invalid IL or missing references)
Transform parent = _camera.parent;
GameObject val = new GameObject("BackflipPivot");
val.transform.SetParent(parent, false);
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
val.transform.localScale = Vector3.one;
_cameraParent = parent;
_pivot = val.transform;
_camera.SetParent(_pivot, false);
_flipping = true;
_flipTime = 0f;
_lastAngle = 0f;
_lastDip = 0f;
_needsRelease = true;
}
private void StopFlip()
{
_flipping = false;
if ((Object)(object)_camera != (Object)null && (Object)(object)_cameraParent != (Object)null)
{
_camera.SetParent(_cameraParent, false);
}
if ((Object)(object)_pivot != (Object)null)
{
Object.Destroy((Object)(object)((Component)_pivot).gameObject);
}
_pivot = null;
}
private float GetTurnY()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
float num = ((HexaBodyInputsBase)_inputs).TurnAxis.y;
try
{
HVRController rightController = _inputs.RightController;
if ((Object)(object)rightController != (Object)null && rightController.Vive)
{
float y = rightController.TrackpadAxis.y;
if (y < num)
{
num = y;
}
}
}
catch
{
}
return num;
}
private void FindPlayer()
{
if ((Object)(object)_body == (Object)null)
{
_body = Object.FindObjectOfType<HexaBodyPlayer4>();
}
if ((Object)(object)_body == (Object)null)
{
return;
}
if ((Object)(object)_inputs == (Object)null)
{
_inputs = ((Component)_body).GetComponent<HVRHexaBodyInputs>();
if ((Object)(object)_inputs == (Object)null)
{
try
{
_inputs = PlayerStaticReferences.hexaInputs;
}
catch
{
_inputs = null;
}
}
}
if ((Object)(object)_camera == (Object)null)
{
_camera = _body.Camera;
}
}
}
}