using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace BitWizrd.HuntWinterRose
{
[BepInPlugin("BitWizrd.HuntWinterRose", "HuntWinterRose", "1.0.1")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class HuntWinterRosePlugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "BitWizrd.HuntWinterRose");
OtherLoader.RegisterDirectLoad(BasePath, "BitWizrd.HuntWinterRose", "", "winter rose", "", "");
}
}
}
namespace BitWizrd.Vetterli
{
public class VetterliLifter : MonoBehaviour
{
[Header("References")]
public BoltActionRifle rifle;
public Transform lifterTransform;
public FVRFireArmMagazine magazine;
[Header("Positions")]
public Vector3 downPosition;
public Vector3 upPosition;
[Header("Animation")]
public float liftSpeed = 5f;
public float lowerSpeed = 3f;
private bool _isLifted = false;
private bool _isLifting = false;
private bool _isLowering = false;
private float _lerpProgress = 0f;
private BoltActionHandleState _lastBoltState;
private float _lastBoltLerp;
private bool _magazineProxyState = false;
private void Start()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rifle == (Object)null)
{
rifle = ((Component)this).GetComponentInParent<BoltActionRifle>();
}
if ((Object)(object)lifterTransform == (Object)null)
{
Debug.LogError((object)"VetterliLifter: No lifter transform assigned!");
((Behaviour)this).enabled = false;
return;
}
lifterTransform.localPosition = downPosition;
if ((Object)(object)magazine != (Object)null)
{
_magazineProxyState = false;
magazine.HideAllProxies = false;
magazine.UpdateBulletDisplay();
}
}
private void Update()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Invalid comparison between Unknown and I4
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Invalid comparison between Unknown and I4
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rifle == (Object)null || (Object)(object)lifterTransform == (Object)null)
{
return;
}
bool flag = _lastBoltState != rifle.CurBoltHandleState;
bool flag2 = Mathf.Abs(_lastBoltLerp - rifle.BoltLerp) > 0.001f;
_lastBoltState = rifle.CurBoltHandleState;
_lastBoltLerp = rifle.BoltLerp;
if ((Object)(object)magazine != (Object)null)
{
bool flag3 = (((int)rifle.CurBoltHandleState != 1 || !(rifle.BoltLerp < 0.99f)) && ((int)rifle.CurBoltHandleState != 0 || !(rifle.BoltLerp < 0.99f))) || _isLowering;
if (flag3 != _magazineProxyState)
{
_magazineProxyState = flag3;
magazine.HideAllProxies = !flag3;
magazine.UpdateBulletDisplay();
}
}
if (flag || flag2)
{
if ((int)rifle.CurBoltHandleState == 2 && rifle.BoltLerp > 0.95f && !_isLifted && !_isLifting)
{
_isLifting = true;
_isLowering = false;
_isLifted = false;
_lerpProgress = 0f;
}
else if ((int)rifle.CurBoltHandleState == 0 && rifle.BoltLerp < 0.05f && _isLifted && !_isLowering)
{
_isLowering = true;
_isLifting = false;
_isLifted = false;
_lerpProgress = 0f;
}
}
if (_isLifting && _lerpProgress < 1f)
{
_lerpProgress += Time.deltaTime * liftSpeed;
float num = Mathf.Clamp01(_lerpProgress);
lifterTransform.localPosition = Vector3.Lerp(downPosition, upPosition, num);
if (num >= 1f)
{
_isLifted = true;
_isLifting = false;
}
}
else if (!_isLifting && _isLifted && _lerpProgress < 1f)
{
_lerpProgress += Time.deltaTime * lowerSpeed;
float num2 = Mathf.Clamp01(_lerpProgress);
lifterTransform.localPosition = Vector3.Lerp(upPosition, downPosition, num2);
if (num2 >= 1f)
{
_isLifted = false;
}
}
else if (!_isLifting && !_isLifted)
{
lifterTransform.localPosition = downPosition;
}
else if (_isLifted && !_isLifting)
{
lifterTransform.localPosition = upPosition;
}
}
}
}