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 Volks.VEPRBullpup;
[BepInPlugin("Volks.VEPRBullpup", "VEPRBullpup", "1.1.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class VEPRBullpupPlugin : 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(), "Volks.VEPRBullpup");
OtherLoader.RegisterDirectLoad(BasePath, "Volks.VEPRBullpup", "", "", "veprbullpups", "");
}
}
public class MagPush : FVRInteractiveObject
{
public enum Mode
{
Translation,
Rotation,
Folding
}
public enum Axis
{
X,
Y,
Z
}
public enum E_State
{
Open,
Mid,
Closed
}
public FVRFireArm FireArm;
public FVRFireArmReloadTriggerWell ReloadTriggerWell;
public Transform ObjectToMove;
public Transform Root;
public Mode MovementMode;
public Axis MovementAxis;
public float LowerLimit;
public float UpperLimit;
public bool SnapsToEndStops = true;
public float LimitWiggleRoom = 0.02f;
public AudioEvent CloseSounds;
public AudioEvent OpenSounds;
public AudioEvent BeginInteractionSounds;
public AudioEvent EndInteractionSounds;
private FVRFireArmMagazine magazine;
private bool isAttached = false;
private bool isLoaded = false;
private Vector3 _lastHandPos;
private float _currentPositionValue;
private Vector3 _origPos;
public E_State State;
private E_State _lastState;
public override void Start()
{
//IL_000e: 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)
((FVRInteractiveObject)this).Start();
_origPos = ObjectToMove.localPosition;
}
private void Update()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
if (!isAttached && (Object)(object)ReloadTriggerWell.FireArm.Magazine != (Object)null && Vector3.Distance(((Component)ReloadTriggerWell.FireArm.Magazine).transform.position, ObjectToMove.position) < 0.1f)
{
magazine = ReloadTriggerWell.FireArm.Magazine;
isAttached = true;
FireArm.PlayAudioEvent((FirearmAudioEventType)20, 1f);
FireArm.Magazine = null;
}
}
public override void BeginInteraction(FVRViveHand hand)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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)
((FVRInteractiveObject)this).BeginInteraction(hand);
_lastHandPos = ((HandInput)(ref hand.Input)).Pos;
SM.PlayGenericSound(BeginInteractionSounds, ObjectToMove.position);
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_0025: 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).UpdateInteraction(hand);
if (isAttached && !isLoaded)
{
Vector3 val = ((HandInput)(ref hand.Input)).Pos - _lastHandPos;
Vector3 vector = ObjectToMove.localPosition + val;
float num = vector.GetAxisValue(MovementAxis) - _origPos.GetAxisValue(MovementAxis);
_currentPositionValue = Mathf.Clamp(num, LowerLimit, UpperLimit);
if (SnapsToEndStops && Mathf.Abs(_currentPositionValue - LowerLimit) < LimitWiggleRoom)
{
_currentPositionValue = LowerLimit;
}
else if (SnapsToEndStops && Mathf.Abs(_currentPositionValue - UpperLimit) < LimitWiggleRoom)
{
_currentPositionValue = UpperLimit;
}
ObjectToMove.ModifyLocalPositionAxisValue(MovementAxis, _currentPositionValue);
_lastHandPos = ((HandInput)(ref hand.Input)).Pos;
float lerp = Mathf.InverseLerp(LowerLimit, UpperLimit, _currentPositionValue);
CheckSound(lerp);
if (Mathf.Abs(_currentPositionValue - UpperLimit) < LimitWiggleRoom)
{
isLoaded = true;
FireArm.PlayAudioEvent((FirearmAudioEventType)21, 1f);
FireArm.Magazine = magazine;
}
}
}
public override void EndInteraction(FVRViveHand hand)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).EndInteraction(hand);
SM.PlayGenericSound(EndInteractionSounds, ObjectToMove.position);
}
private void OnEnable()
{
FireArm.Magazine = null;
}
public bool IsFirearmReady()
{
return isLoaded && FireArm.IsLoaded();
}
public bool NeedsMagazinePush()
{
return isAttached && !isLoaded;
}
private void CheckSound(float lerp)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
if (lerp < LimitWiggleRoom)
{
State = E_State.Open;
}
else if (lerp > 1f - LimitWiggleRoom)
{
State = E_State.Closed;
}
else
{
State = E_State.Mid;
}
if (State == E_State.Open && _lastState != 0)
{
SM.PlayGenericSound(OpenSounds, ObjectToMove.position);
}
if (State == E_State.Closed && _lastState != E_State.Closed)
{
SM.PlayGenericSound(CloseSounds, ObjectToMove.position);
}
_lastState = State;
}
}
public static class TransformExtensions
{
public static float GetAxisValue(this Vector3 vector, MagPush.Axis axis)
{
return axis switch
{
MagPush.Axis.X => vector.x,
MagPush.Axis.Y => vector.y,
MagPush.Axis.Z => vector.z,
_ => 0f,
};
}
public static void ModifyLocalPositionAxisValue(this Transform transform, MagPush.Axis axis, float value)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
Vector3 localPosition = transform.localPosition;
switch (axis)
{
case MagPush.Axis.X:
localPosition.x = value;
break;
case MagPush.Axis.Y:
localPosition.y = value;
break;
case MagPush.Axis.Z:
localPosition.z = value;
break;
}
transform.localPosition = localPosition;
}
}