using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using FistVR;
using H3VRUtils;
using H3VRUtils.UniqueCode;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("PotatoesSoup")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PotatoesSoup")]
[assembly: AssemblyTitle("PotatoesSoup")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace PotatoesSoup
{
public class Akimbo
{
[HarmonyPatch(typeof(Handgun), "UpdateInteraction")]
[HarmonyPrefix]
public static bool Handgun_UpdateInteraction_AkimboReloading(Handgun __instance, ref FVRViveHand hand)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.Akimbo_IsEnabled.Value || (Object)(object)((FVRFireArm)__instance).Magazine != (Object)null || (Object)(object)((FVRFireArm)__instance).MagazineMountPos == (Object)null)
{
return true;
}
FVRQuickBeltSlot val = null;
Transform val2 = ((!((Object)(object)__instance.ReloadTriggerWell == (Object)null)) ? __instance.ReloadTriggerWell.transform : ((Component)hand.PoseOverride).transform);
for (int i = 0; i < GM.CurrentPlayerBody.QBSlots_Internal.Count; i++)
{
if (GM.CurrentPlayerBody.QBSlots_Internal[i].IsPointInsideMe(val2.position))
{
val = GM.CurrentPlayerBody.QBSlots_Internal[i];
break;
}
}
if ((Object)(object)val == (Object)null || (Object)(object)val.CurObject == (Object)null || !(val.CurObject is FVRFireArmMagazine))
{
return true;
}
FVRPhysicalObject curObject = val.CurObject;
FVRFireArmMagazine val3 = (FVRFireArmMagazine)(object)((curObject is FVRFireArmMagazine) ? curObject : null);
if (val3.MagazineType != ((FVRFireArm)__instance).MagazineType)
{
return true;
}
if (BepInExPlugin.AkimboOneHand_IsEnabled.Value || (Object)(object)hand.OtherHand.CurrentInteractable != (Object)null)
{
FVRFireArmMagazine val4;
if (((FVRPhysicalObject)val3).m_isSpawnLock)
{
val4 = Object.Instantiate<GameObject>(((AnvilAsset)((FVRPhysicalObject)val3).ObjectWrapper).GetGameObject(), ((FVRInteractiveObject)val3).Transform.position, ((FVRInteractiveObject)val3).Transform.rotation).GetComponent<FVRFireArmMagazine>();
for (int j = 0; j < Mathf.Min(val3.LoadedRounds.Length, val4.LoadedRounds.Length); j++)
{
if (val3.LoadedRounds[j] != null && (Object)(object)val3.LoadedRounds[j].LR_Mesh != (Object)null)
{
val4.LoadedRounds[j].LR_Class = val3.LoadedRounds[j].LR_Class;
val4.LoadedRounds[j].LR_Mesh = val3.LoadedRounds[j].LR_Mesh;
val4.LoadedRounds[j].LR_Material = val3.LoadedRounds[j].LR_Material;
val4.LoadedRounds[j].LR_ObjectWrapper = val3.LoadedRounds[j].LR_ObjectWrapper;
}
}
val4.m_numRounds = val3.m_numRounds;
val4.UpdateBulletDisplay();
}
else
{
val4 = val3;
((FVRPhysicalObject)val3).ClearQuickbeltState();
}
val4.Load((FVRFireArm)(object)__instance);
}
return true;
}
[HarmonyPatch(typeof(ClosedBoltWeapon), "UpdateInteraction")]
[HarmonyPrefix]
public static bool ClosedBoltWeapon_UpdateInteraction_AkimboReloading(ClosedBoltWeapon __instance, ref FVRViveHand hand)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.AkimboAllWeapons_IsEnabled.Value)
{
return true;
}
if (!BepInExPlugin.Akimbo_IsEnabled.Value || (Object)(object)((FVRFireArm)__instance).Magazine != (Object)null || (Object)(object)((FVRFireArm)__instance).MagazineMountPos == (Object)null)
{
return true;
}
FVRQuickBeltSlot val = null;
Transform transform = ((Component)((FVRFireArm)__instance).MagazineMountPos).transform;
if ((Object)(object)transform == (Object)null)
{
return true;
}
for (int i = 0; i < GM.CurrentPlayerBody.QBSlots_Internal.Count; i++)
{
if (GM.CurrentPlayerBody.QBSlots_Internal[i].IsPointInsideMe(transform.position))
{
val = GM.CurrentPlayerBody.QBSlots_Internal[i];
break;
}
}
if ((Object)(object)val == (Object)null || (Object)(object)val.CurObject == (Object)null || !(val.CurObject is FVRFireArmMagazine))
{
return true;
}
FVRPhysicalObject curObject = val.CurObject;
FVRFireArmMagazine val2 = (FVRFireArmMagazine)(object)((curObject is FVRFireArmMagazine) ? curObject : null);
if (val2.MagazineType != ((FVRFireArm)__instance).MagazineType)
{
return true;
}
if (BepInExPlugin.AkimboOneHand_IsEnabled.Value || (Object)(object)hand.OtherHand.CurrentInteractable != (Object)null)
{
FVRFireArmMagazine val3;
if (((FVRPhysicalObject)val2).m_isSpawnLock)
{
val3 = Object.Instantiate<GameObject>(((AnvilAsset)((FVRPhysicalObject)val2).ObjectWrapper).GetGameObject(), ((FVRInteractiveObject)val2).Transform.position, ((FVRInteractiveObject)val2).Transform.rotation).GetComponent<FVRFireArmMagazine>();
for (int j = 0; j < Mathf.Min(val2.LoadedRounds.Length, val3.LoadedRounds.Length); j++)
{
if (val2.LoadedRounds[j] != null && (Object)(object)val2.LoadedRounds[j].LR_Mesh != (Object)null)
{
val3.LoadedRounds[j].LR_Class = val2.LoadedRounds[j].LR_Class;
val3.LoadedRounds[j].LR_Mesh = val2.LoadedRounds[j].LR_Mesh;
val3.LoadedRounds[j].LR_Material = val2.LoadedRounds[j].LR_Material;
val3.LoadedRounds[j].LR_ObjectWrapper = val2.LoadedRounds[j].LR_ObjectWrapper;
}
}
val3.m_numRounds = val2.m_numRounds;
val3.UpdateBulletDisplay();
}
else
{
val3 = val2;
((FVRPhysicalObject)val2).ClearQuickbeltState();
}
val3.Load((FVRFireArm)(object)__instance);
}
return true;
}
[HarmonyPatch(typeof(OpenBoltReceiver), "UpdateInteraction")]
[HarmonyPrefix]
public static bool OpenBoltReceiver_UpdateInteraction_AkimboReloading(OpenBoltReceiver __instance, ref FVRViveHand hand)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.AkimboAllWeapons_IsEnabled.Value)
{
return true;
}
if (!BepInExPlugin.Akimbo_IsEnabled.Value || (Object)(object)((FVRFireArm)__instance).Magazine != (Object)null || (Object)(object)((FVRFireArm)__instance).MagazineMountPos == (Object)null)
{
return true;
}
FVRQuickBeltSlot val = null;
Transform transform = ((Component)((FVRFireArm)__instance).MagazineMountPos).transform;
if ((Object)(object)transform == (Object)null)
{
return true;
}
for (int i = 0; i < GM.CurrentPlayerBody.QBSlots_Internal.Count; i++)
{
if (GM.CurrentPlayerBody.QBSlots_Internal[i].IsPointInsideMe(transform.position))
{
val = GM.CurrentPlayerBody.QBSlots_Internal[i];
break;
}
}
if ((Object)(object)val == (Object)null || (Object)(object)val.CurObject == (Object)null || !(val.CurObject is FVRFireArmMagazine))
{
return true;
}
FVRPhysicalObject curObject = val.CurObject;
FVRFireArmMagazine val2 = (FVRFireArmMagazine)(object)((curObject is FVRFireArmMagazine) ? curObject : null);
if (val2.MagazineType != ((FVRFireArm)__instance).MagazineType)
{
return true;
}
if (BepInExPlugin.AkimboOneHand_IsEnabled.Value || (Object)(object)hand.OtherHand.CurrentInteractable != (Object)null)
{
FVRFireArmMagazine val3;
if (((FVRPhysicalObject)val2).m_isSpawnLock)
{
val3 = Object.Instantiate<GameObject>(((AnvilAsset)((FVRPhysicalObject)val2).ObjectWrapper).GetGameObject(), ((FVRInteractiveObject)val2).Transform.position, ((FVRInteractiveObject)val2).Transform.rotation).GetComponent<FVRFireArmMagazine>();
for (int j = 0; j < Mathf.Min(val2.LoadedRounds.Length, val3.LoadedRounds.Length); j++)
{
if (val2.LoadedRounds[j] != null && (Object)(object)val2.LoadedRounds[j].LR_Mesh != (Object)null)
{
val3.LoadedRounds[j].LR_Class = val2.LoadedRounds[j].LR_Class;
val3.LoadedRounds[j].LR_Mesh = val2.LoadedRounds[j].LR_Mesh;
val3.LoadedRounds[j].LR_Material = val2.LoadedRounds[j].LR_Material;
val3.LoadedRounds[j].LR_ObjectWrapper = val2.LoadedRounds[j].LR_ObjectWrapper;
}
}
val3.m_numRounds = val2.m_numRounds;
val3.UpdateBulletDisplay();
}
else
{
val3 = val2;
((FVRPhysicalObject)val2).ClearQuickbeltState();
}
val3.Load((FVRFireArm)(object)__instance);
}
return true;
}
[HarmonyPatch(typeof(Revolver), "UpdateInteraction")]
[HarmonyPrefix]
public static bool Revolver_UpdateInteraction_AkimboReloading(Revolver __instance, ref FVRViveHand hand)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.Akimbo_IsEnabled.Value || __instance.isCylinderArmLocked)
{
return true;
}
FVRQuickBeltSlot val = null;
RevolverCylinder cylinder = __instance.Cylinder;
for (int i = 0; i < GM.CurrentPlayerBody.QBSlots_Internal.Count; i++)
{
if (GM.CurrentPlayerBody.QBSlots_Internal[i].IsPointInsideMe(((Component)cylinder).transform.position))
{
val = GM.CurrentPlayerBody.QBSlots_Internal[i];
break;
}
}
bool flag = true;
FVRFireArmChamber[] chambers = __instance.Chambers;
for (int j = 0; j < chambers.Length; j++)
{
if (!chambers[j].IsFull)
{
flag = false;
break;
}
}
Speedloader val2 = default(Speedloader);
int num;
if (!((Object)(object)val == (Object)null) && !((Object)(object)val.CurObject == (Object)null))
{
FVRPhysicalObject curObject = val.CurObject;
val2 = (Speedloader)(object)((curObject is Speedloader) ? curObject : null);
if (val2 != null)
{
num = ((!__instance.Cylinder.CanAccept()) ? 1 : 0);
goto IL_00d8;
}
}
num = 1;
goto IL_00d8;
IL_00d8:
if (((uint)num | (flag ? 1u : 0u)) != 0)
{
return true;
}
if (val2.Chambers[0].Type != ((FVRFireArm)__instance).RoundType)
{
return true;
}
if (BepInExPlugin.AkimboOneHand_IsEnabled.Value || (Object)(object)hand.OtherHand.CurrentInteractable != (Object)null)
{
Speedloader val3;
if (((FVRPhysicalObject)val2).m_isSpawnLock)
{
val3 = Object.Instantiate<GameObject>(((AnvilAsset)((FVRPhysicalObject)val2).ObjectWrapper).GetGameObject(), ((FVRInteractiveObject)val2).Transform.position, ((FVRInteractiveObject)val2).Transform.rotation).GetComponent<Speedloader>();
for (int k = 0; k < val2.Chambers.Count; k++)
{
if (val2.Chambers[k].IsLoaded)
{
val3.Chambers[k].Load(val2.Chambers[k].LoadedClass, false);
}
else
{
val3.Chambers[k].Unload();
}
}
}
else
{
val3 = val2;
((FVRPhysicalObject)val2).ClearQuickbeltState();
}
__instance.Cylinder.LoadFromSpeedLoader(val3);
if (val3.InjectsOnInsertion)
{
Object.Destroy((Object)(object)((Component)val3).gameObject);
}
}
return true;
}
}
public class BaseGamePatch : MonoBehaviour
{
[HarmonyPatch(typeof(LaserPointer), "FVRUpdate")]
[HarmonyPostfix]
public static void LaserPointerPatch_Update_FixScale(LaserPointer __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
float num = Vector3.Distance(((Component)ManagerSingleton<GM>.Instance.m_currentPlayerBody.Head).transform.position, __instance.BeamHitPoint.transform.position);
float num2 = Mathf.Lerp(0.01f, 0.2f, num * 0.01f);
__instance.BeamHitPoint.transform.localScale = new Vector3(num2, num2, num2);
}
[HarmonyPatch(typeof(FVRFireArm), "FireMuzzleSmoke", new Type[] { typeof(int) })]
[HarmonyPrefix]
public static bool FVRFireArm_FireMuzzleSmoke_FixOOB(FVRFireArm __instance, ref int i)
{
if (__instance.m_muzzleSystems.Count < i)
{
return false;
}
return true;
}
[HarmonyPatch(typeof(FVRPhysicalObject), "Awake")]
[HarmonyPrefix]
public static bool FVRFireArm_Awake_FixScaling(FVRPhysicalObject __instance)
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance.ObjectWrapper == (Object)null)
{
return true;
}
if (__instance.ObjectWrapper.ItemID == "MadsenLAR" || __instance.ObjectWrapper.ItemID == "MagazineMadsenLAR30rnd" || __instance.ObjectWrapper.ItemID == "MagazineMadsenLAR20rnd" || __instance.ObjectWrapper.ItemID == "MagazineMadsenLAR10rnd")
{
((Component)__instance).transform.localScale = new Vector3(0.88f, 0.88f, 0.88f);
}
if (__instance.ObjectWrapper.ItemID == "PanzerSchreck54")
{
((Component)__instance).transform.localScale = new Vector3(0.95f, 0.95f, 1f);
}
return true;
}
[HarmonyPatch(typeof(FVRPhysicalObject), "Awake")]
[HarmonyPrefix]
public static bool FVRFireArm_Awake_AddMagDump(FVRPhysicalObject __instance)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance.ObjectWrapper == (Object)null)
{
return true;
}
if (__instance.ObjectWrapper.ItemID == "M1912" || __instance.ObjectWrapper.ItemID == "M1912P16")
{
DumpInternalMag obj = ((Component)__instance).gameObject.AddComponent<DumpInternalMag>();
obj.presstoejectbutton = (TouchpadDirType)2;
obj.handgun = (Handgun)(object)((__instance is Handgun) ? __instance : null);
}
return true;
}
[HarmonyPatch(typeof(ClosedBoltWeapon), "Awake")]
[HarmonyPrefix]
public static bool ClosedBoltWeapon_Awake_LessSensitiveDualStage(ClosedBoltWeapon __instance)
{
if (!BepInExPlugin.DualStageAlt_IsEnabled.Value)
{
return true;
}
if ((Object)(object)((FVRPhysicalObject)__instance).ObjectWrapper == (Object)null || !__instance.UsesDualStageFullAuto)
{
return true;
}
__instance.TriggerDualStageThreshold = 1.1f;
return true;
}
[HarmonyPatch(typeof(ClosedBoltWeapon), "UpdateInputAndAnimate")]
[HarmonyPostfix]
public static void ClosedBoltWeapon_UpdateInputAndAnimate_DualStageFire(ClosedBoltWeapon __instance, ref FVRViveHand hand)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Invalid comparison between Unknown and I4
if (!__instance.UsesDualStageFullAuto || !BepInExPlugin.DualStageAlt_IsEnabled.Value)
{
return;
}
FireSelectorModeType modeType = __instance.FireSelector_Modes[__instance.m_fireSelectorMode].ModeType;
if ((int)modeType != 0 && ((FVRInteractiveObject)__instance).m_hasTriggeredUpSinceBegin && (int)__instance.Bolt.CurPos == 0 && (int)modeType == 3 && hand.Input.TriggerPressed)
{
__instance.DropHammer();
__instance.m_hasTriggerReset = false;
if (__instance.m_CamBurst > 0)
{
__instance.m_CamBurst--;
}
}
}
[HarmonyPatch(typeof(BreakActionWeapon), "FVRFixedUpdate")]
[HarmonyPrefix]
public static bool BreakActionWeapon_FVRFixedUpdate_PrefixFixLatching(BreakActionWeapon __instance)
{
__instance.m_latchRot *= 2f;
return true;
}
[HarmonyPatch(typeof(BreakActionWeapon), "FVRFixedUpdate")]
[HarmonyPostfix]
public static void BreakActionWeapon_FVRFixedUpdate_PostfixFixLatching(BreakActionWeapon __instance)
{
__instance.m_latchRot *= 0.5f;
}
[HarmonyPatch(typeof(FVRFireArmRound), "Awake")]
[HarmonyPatch(typeof(FVRFireArmRound), "Fire")]
[HarmonyPostfix]
public static void FVRFireArmRound_Awake_Bounce(FVRFireArmRound __instance)
{
if (!__instance.m_isSpent || !BepInExPlugin.BulletBounce_IsEnabled.Value)
{
return;
}
Collider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Collider>();
foreach (Collider val in componentsInChildren)
{
if (!val.isTrigger)
{
val.material = BepInExPlugin.Bounce;
}
}
}
[HarmonyPatch(typeof(FVRFireArmChamber), "EjectRound", new Type[]
{
typeof(Vector3),
typeof(Vector3),
typeof(Vector3),
typeof(bool)
})]
[HarmonyPatch(typeof(FVRFireArmChamber), "EjectRound", new Type[]
{
typeof(Vector3),
typeof(Vector3),
typeof(Vector3),
typeof(Vector3),
typeof(Quaternion),
typeof(bool)
})]
[HarmonyPrefix]
public static bool BoltActionRifle_AdaptiveEjectSpeed(FVRFireArmChamber __instance, ref Vector3 EjectionVelocity, ref Vector3 EjectionAngularVelocity)
{
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.AdaptiveEjectSpeed_IsEnabled.Value)
{
return true;
}
float value = 1f;
if (__instance.Firearm is BoltActionRifle)
{
FVRFireArm firearm = __instance.Firearm;
BoltActionRifle val = (BoltActionRifle)(object)((firearm is BoltActionRifle) ? firearm : null);
if ((Object)(object)((FVRInteractiveObject)val.BoltHandle).m_hand != (Object)null)
{
value = ((Vector3)(ref ((FVRInteractiveObject)val.BoltHandle).m_hand.Input.VelLinearWorld)).magnitude / 2f;
}
}
else if (__instance.Firearm is ClosedBoltWeapon)
{
FVRFireArm firearm2 = __instance.Firearm;
ClosedBoltWeapon val2 = (ClosedBoltWeapon)(object)((firearm2 is ClosedBoltWeapon) ? firearm2 : null);
if (!val2.HasHandle && (Object)(object)((FVRInteractiveObject)val2.Bolt).m_hand != (Object)null)
{
value = ((Vector3)(ref ((FVRInteractiveObject)val2.Bolt).m_hand.Input.VelLinearWorld)).magnitude / 3f;
}
else if (val2.HasHandle && (Object)(object)((FVRInteractiveObject)val2.Handle).m_hand != (Object)null)
{
value = ((Vector3)(ref ((FVRInteractiveObject)val2.Handle).m_hand.Input.VelLinearWorld)).magnitude / 3f;
}
}
else if (__instance.Firearm is Handgun)
{
FVRFireArm firearm3 = __instance.Firearm;
Handgun val3 = (Handgun)(object)((firearm3 is Handgun) ? firearm3 : null);
if ((Object)(object)((FVRInteractiveObject)val3.Slide).m_hand != (Object)null)
{
value = ((Vector3)(ref ((FVRInteractiveObject)val3.Slide).m_hand.Input.VelLinearWorld)).magnitude / 2f;
}
}
else if (__instance.Firearm is OpenBoltReceiver)
{
FVRFireArm firearm4 = __instance.Firearm;
OpenBoltReceiver val4 = (OpenBoltReceiver)(object)((firearm4 is OpenBoltReceiver) ? firearm4 : null);
if ((Object)(object)((FVRInteractiveObject)val4.Bolt).m_hand != (Object)null)
{
value = ((Vector3)(ref ((FVRInteractiveObject)val4.Bolt).m_hand.Input.VelLinearWorld)).magnitude / 3f;
}
}
else if (__instance.Firearm is TubeFedShotgun)
{
FVRFireArm firearm5 = __instance.Firearm;
TubeFedShotgun val5 = (TubeFedShotgun)(object)((firearm5 is TubeFedShotgun) ? firearm5 : null);
if ((Object)(object)((FVRInteractiveObject)val5.Bolt).m_hand != (Object)null)
{
value = ((Vector3)(ref ((FVRInteractiveObject)val5.Bolt).m_hand.Input.VelLinearWorld)).magnitude / 3f;
}
else if (val5.HasHandle && (Object)(object)((FVRInteractiveObject)val5.Handle).m_hand != (Object)null)
{
value = ((Vector3)(ref ((FVRInteractiveObject)val5.Handle).m_hand.Input.VelLinearWorld)).magnitude / 3f;
}
}
value = Math.Max(Math.Min(Math.Abs(value), 1f), 0.2f);
EjectionVelocity *= value;
EjectionAngularVelocity *= value;
return true;
}
[HarmonyPatch(typeof(BoltActionRifle), "Awake")]
[HarmonyPostfix]
public static void BoltActionRifle_Awake_CorrectLoading(BoltActionRifle __instance)
{
if (BepInExPlugin.CorrectLoading_IsEnabled.Value && (Object)(object)((FVRFireArm)__instance).Magazine != (Object)null)
{
__instance.Chamber.IsManuallyChamberable = false;
}
}
}
[BepInPlugin("dll.potatoes1286.soup", "Potatoes' Soup", "7.2.1")]
[BepInProcess("h3vr.exe")]
public class BepInExPlugin : BaseUnityPlugin
{
public const string SETTING_OTHER_NAME = "Other";
public static ConfigEntry<bool> EasyAttaching_IsEnabled;
public static ConfigEntry<bool> AccurateQBSlots_IsEnabled;
public static ConfigEntry<bool> BetterStabilization_IsEnabled;
public static ConfigEntry<bool> AntonBoltLock_IsEnabled;
public static ConfigEntry<bool> VerboseLogging_IsEnabled;
public static ConfigEntry<bool> Akimbo_IsEnabled;
public static ConfigEntry<bool> DualStageAlt_IsEnabled;
public static ConfigEntry<bool> BulletBounce_IsEnabled;
public static ConfigEntry<float> BulletBounce_Bounciness;
public static ConfigEntry<bool> AdaptiveEjectSpeed_IsEnabled;
public static ConfigEntry<bool> CorrectLoading_IsEnabled;
public const string SETTING_QG_NAME = "Quick Grabbing";
public static ConfigEntry<bool> QuickGrabbing_IsEnabled;
public static ConfigEntry<bool> QuickGrabbing_DisableWhenRunning;
public static ConfigEntry<bool> QuickGrabbing_RegrabBolt;
public static ConfigEntry<bool> QuickGrabbing_GrabFores;
public static ConfigEntry<bool> QuickGrabbing_GrabPistolSlides;
public static ConfigEntry<bool> QuickGrabbing_GrabRopes;
public static ConfigEntry<bool> QuickGrabbing_GrabBolts;
public static ConfigEntry<bool> QuickGrabbing_GrabMags;
public static ConfigEntry<bool> QuickGrabbing_GrabGrenade;
public static ConfigEntry<float> QuickGrabbing_GrabGrenadeRange;
public static ConfigEntry<bool> QuickGrabbing_GrabSosigWeapon;
public static ConfigEntry<bool> QuickGrabbing_GrabBullets;
public static ConfigEntry<bool> QuickGrabbing_FastClip;
public const string SETTING_QUESTIONABLE_NAME = "Questionable Settings";
public static ConfigEntry<bool> AkimboOneHand_IsEnabled;
public static ConfigEntry<bool> AkimboAllWeapons_IsEnabled;
public const string SETTING_CS_NAME = "Clear Stabilization";
public static ConfigEntry<bool> ClearStab_IsEnabled;
public static ConfigEntry<float> ClearStab_Treshhold;
public static PhysicMaterial Bounce = new PhysicMaterial();
private void SetConfig_Other()
{
EasyAttaching_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Easy Attaching", true, "Enables Easy Attaching");
BetterStabilization_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Better Stabilization", true, "Allows two hand stabilization, even if other hand is holding an item.");
AntonBoltLock_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Antons Bolt Lock", false, "Enables Anton's bolt lock that applies to guns like the SKS and M1 Garand.");
VerboseLogging_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Verbose Logging", false, "Add more spam to your console for debugging.");
Akimbo_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Akimbo", true, "Enables Akimbo-style reloading.");
DualStageAlt_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Less-Sensitive Dual Stage Trigger", true, "Makes dual stage triggers (e.g AUG) to have a less sensitive auto trigger which requires full depression of the trigger, allowing easier single-shots.");
BulletBounce_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Enable Bullet Bounce", true, "Empty bullets now bounce.");
BulletBounce_Bounciness = ((BaseUnityPlugin)this).Config.Bind<float>("Other", "Bullet Bounciness", 0.5f, "From 0-1 (requires restart.)");
AdaptiveEjectSpeed_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Adaptive Eject Speed", true, "Bullets eject faster when you rack the bolt faster.");
CorrectLoading_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Correct Bolt Action Loading", true, "Disables +1 loading of bolt action rifles, because YOU CAN'T DO THAT IRL.");
}
private void SetConfig_QuickGrabbing()
{
QuickGrabbing_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Is Enabled", true, "Enables Quick Grabbing");
QuickGrabbing_DisableWhenRunning = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Disable When Running", true, "When true, Quick Grab will be disabled when running in Armswinger to prevent accidental grabs.");
QuickGrabbing_RegrabBolt = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Re-grabbing Gun When Quick Grabbing Bolt (Bolt Action Only)", false, "When true, if you close the bolt on a bolt action after quick-grabbing it, you will automatically regrab the gun.");
QuickGrabbing_GrabFores = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Grabbing Foregrips", false, "Allows Quick Grabbing to apply to foregrips");
QuickGrabbing_GrabPistolSlides = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Grabbing Pistol Slides", true, "Allows Quick Grabbing to apply to pistol slides");
QuickGrabbing_GrabRopes = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Grabbing Ropes", true, "Allows Quick Grabbing to apply to ropes");
QuickGrabbing_GrabBolts = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Grabbing Weapon Bolts", true, "Allows Quick Grabbing to apply to weapon bolts/handles");
QuickGrabbing_GrabMags = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Grabbing Magazines and Speedloaders", true, "Allows Quick Grabbing to apply to weapon mags/speedloaders");
QuickGrabbing_GrabGrenade = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Grabbing Grenades", true, "Allows Quick Grabbing to apply to grenades");
QuickGrabbing_GrabGrenadeRange = ((BaseUnityPlugin)this).Config.Bind<float>("Quick Grabbing", "Expanded Grenade Grab Range", 0.3f, "Expands range to grab grenades, making it easier to grab grenades mid-air (Radius in metres)");
QuickGrabbing_GrabSosigWeapon = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Grabbing Sosig guns", true, "Allows Quick Grabbing to apply to sosig guns");
QuickGrabbing_GrabBullets = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Grabbing Bullets", true, "Allows Quick Grabbing to apply to bullets");
QuickGrabbing_FastClip = ((BaseUnityPlugin)this).Config.Bind<bool>("Quick Grabbing", "Enable Fast Clip", true, "If true, will automatically let go of clips when magazine full.");
}
private void SetConfig_Questionable()
{
AkimboOneHand_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Questionable Settings", "Enable Akimbo When Second Hand Free", false, "Enables Akimbo-style reloading even if your second hand is unoccupied");
AkimboAllWeapons_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Questionable Settings", "Enable Akimbo Reloading With All Weapons", false, "Enables Akimbo-style reloading even if you only are holding what definitely is NOT a pistol.");
}
private void SetConfig_ClearStab()
{
ClearStab_IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Clear Stabilization", "Is Enabled", true, "Hides your offhand if you're stabilizing a gun with it.");
ClearStab_Treshhold = ((BaseUnityPlugin)this).Config.Bind<float>("Clear Stabilization", "Treshhold", 0.09f, "Distance, in metres, you must be from the hand holding the gun to activate clear stabilization.");
}
public void SetConfigs()
{
SetConfig_Other();
SetConfig_QuickGrabbing();
SetConfig_ClearStab();
SetConfig_Questionable();
}
public void Start()
{
SetConfigs();
LogAndPatch(typeof(DecockingRevolver));
LogAndPatch(typeof(BaseGamePatch));
LogAndPatch(typeof(BoltBrace));
LogAndPatch(typeof(BoltBrace_PlayerHeadLock));
LogAndPatch(typeof(ThumbBullet));
LogAndPatch(typeof(BoltActionRifleDecocking));
LogAndPatch(typeof(ClearStabilization));
LogAndPatch(typeof(BetterPanels));
LogAndPatch(typeof(EasyAttaching));
LogAndPatch(typeof(ExtractorHit));
LogAndPatch(typeof(QuickGrabbing));
LogAndPatch(typeof(SingleActionCCing));
LogAndPatch(typeof(BetterStabilization));
LogAndPatch(typeof(Akimbo));
Bounce.bounciness = BulletBounce_Bounciness.Value;
Bounce.bounceCombine = (PhysicMaterialCombine)3;
}
public void LogAndPatch(Type type)
{
if (VerboseLogging_IsEnabled.Value)
{
Debug.Log((object)("V-Soup: Patching " + type.FullName + "!"));
}
Harmony.CreateAndPatchAll(type, (string)null);
}
}
internal static class PluginInfo
{
internal const string NAME = "Potatoes' Soup";
internal const string GUID = "dll.potatoes1286.soup";
internal const string VERSION = "7.2.1";
}
public class BetterPanels : MonoBehaviour
{
[HarmonyPatch(typeof(FVRWristMenu), "SpawnOptionsPanel")]
[HarmonyPrefix]
public static bool LockPanelOnSpawn_Patch(FVRWristMenu __instance)
{
//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)
if ((Object)(object)GM.CurrentOptionsPanel == (Object)null)
{
(GM.CurrentOptionsPanel = Object.Instantiate<GameObject>(__instance.OptionsPanelPrefab, Vector3.zero, Quaternion.identity)).GetComponent<FVRPhysicalObject>().SetIsKinematicLocked(true);
}
return true;
}
}
public class BetterQBslots : MonoBehaviour
{
[HarmonyPatch(typeof(FVRQuickBeltSlot), "MoveContentsInstant")]
[HarmonyPatch(typeof(FVRQuickBeltSlot), "MoveContents")]
[HarmonyPatch(typeof(FVRQuickBeltSlot), "MoveContentsCheap")]
[HarmonyPrefix]
public static bool QBRemoveCode_Patch(FVRQuickBeltSlot __instance, ref Vector3 dir)
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if (BepInExPlugin.AccurateQBSlots_IsEnabled.Value && __instance.m_isKeepingTrackWithHead)
{
return false;
}
if ((Object)(object)__instance.CurObject != (Object)null)
{
if (((FVRInteractiveObject)__instance.CurObject).IsHeld)
{
return false;
}
FVRInteractiveObject val = null;
if (__instance.CurObject is ClosedBoltWeapon)
{
FVRPhysicalObject curObject = __instance.CurObject;
val = (FVRInteractiveObject)(object)((ClosedBoltWeapon)((curObject is ClosedBoltWeapon) ? curObject : null)).Bolt;
}
if (__instance.CurObject is BoltActionRifle)
{
FVRPhysicalObject curObject2 = __instance.CurObject;
val = (FVRInteractiveObject)(object)((BoltActionRifle)((curObject2 is BoltActionRifle) ? curObject2 : null)).BoltHandle;
}
if (__instance.CurObject is Handgun)
{
FVRPhysicalObject curObject3 = __instance.CurObject;
val = (FVRInteractiveObject)(object)((Handgun)((curObject3 is Handgun) ? curObject3 : null)).Slide;
}
if ((Object)(object)val != (Object)null && val.IsHeld)
{
return false;
}
((Component)__instance.CurObject).transform.position = ((Component)__instance.CurObject).transform.position + dir;
__instance.CurObject.RootRigidbody.velocity = Vector3.zero;
}
return false;
}
[HarmonyPatch(typeof(FVRQuickBeltSlot), "FixedUpdate")]
[HarmonyPrefix]
public static bool QBfuPatch(FVRQuickBeltSlot __instance)
{
if (BepInExPlugin.AccurateQBSlots_IsEnabled.Value && __instance.m_isKeepingTrackWithHead)
{
return false;
}
return true;
}
[HarmonyPatch(typeof(FVRQuickBeltSlot), "Update")]
[HarmonyPostfix]
public static void QBMoveContentsPatch(FVRQuickBeltSlot __instance)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.AccurateQBSlots_IsEnabled.Value || !__instance.m_isKeepingTrackWithHead || !((Object)(object)__instance.CurObject != (Object)null) || ((FVRInteractiveObject)__instance.CurObject).IsHeld)
{
return;
}
if (__instance.IsPlayer && __instance.CurObject.DoesQuickbeltSlotFollowHead && (int)__instance.Shape == 0)
{
if (__instance.CurObject.DoesQuickbeltSlotFollowHead)
{
Vector3 val = Vector3.ProjectOnPlane(((Component)GM.CurrentPlayerBody.Head).transform.forward, ((Component)__instance).transform.right);
__instance.PoseOverride.rotation = Quaternion.LookRotation(val, ((Component)GM.CurrentPlayerBody.Head).transform.up);
}
else
{
__instance.PoseOverride.localRotation = Quaternion.identity;
}
}
if (!((FVRInteractiveObject)__instance.CurObject).IsHeld)
{
FVRInteractiveObject val2 = null;
if (__instance.CurObject is ClosedBoltWeapon)
{
FVRPhysicalObject curObject = __instance.CurObject;
val2 = (FVRInteractiveObject)(object)((ClosedBoltWeapon)((curObject is ClosedBoltWeapon) ? curObject : null)).Bolt;
}
if (__instance.CurObject is BoltActionRifle)
{
FVRPhysicalObject curObject2 = __instance.CurObject;
val2 = (FVRInteractiveObject)(object)((BoltActionRifle)((curObject2 is BoltActionRifle) ? curObject2 : null)).BoltHandle;
}
if (__instance.CurObject is Handgun)
{
FVRPhysicalObject curObject3 = __instance.CurObject;
val2 = (FVRInteractiveObject)(object)((Handgun)((curObject3 is Handgun) ? curObject3 : null)).Slide;
}
if (!((Object)(object)val2 != (Object)null) || !val2.IsHeld)
{
((Component)__instance.CurObject).transform.position = ((Component)__instance.PoseOverride).transform.position;
((Component)__instance.CurObject).transform.rotation = ((Component)__instance.PoseOverride).transform.rotation;
}
}
}
}
public class BetterStabilization : MonoBehaviour
{
[HarmonyPatch(typeof(FVRFireArm), "IsTwoHandStabilized")]
[HarmonyPrefix]
public static bool FVRFireArm_IsTwoHandStabilized_Patch(FVRFireArm __instance, ref bool __result)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.BetterStabilization_IsEnabled.Value)
{
return true;
}
__result = false;
if ((Object)(object)((FVRInteractiveObject)__instance).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)__instance).m_hand.OtherHand != (Object)null && Vector3.Distance(((FVRInteractiveObject)__instance).m_hand.PalmTransform.position, ((FVRInteractiveObject)__instance).m_hand.OtherHand.PalmTransform.position) < 0.15f)
{
__result = true;
}
return false;
}
}
public class BoltActionRifleDecocking : MonoBehaviour
{
[HarmonyPatch(typeof(BoltActionRifle), "UpdateInteraction")]
[HarmonyPrefix]
public static bool BoltActionRifle_Cocking_Patch(BoltActionRifle __instance, ref FVRViveHand hand)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if (__instance.RequiresHammerUncockedToToggleFireSelector && (int)__instance.FireSelector_Modes[__instance.m_fireSelectorMode].ModeType == 0)
{
return true;
}
if (!__instance.IsHammerCocked && Vector2.Angle(((FVRInteractiveObject)__instance).m_hand.Input.TouchpadAxes, Vector2.up) <= 45f && ((FVRInteractiveObject)__instance).m_hand.Input.TouchpadDown && ((Vector2)(ref ((FVRInteractiveObject)__instance).m_hand.Input.TouchpadAxes)).magnitude > 0.2f)
{
__instance.CockHammer();
((FVRFireArm)__instance).PlayAudioEvent((FirearmAudioEventType)11, 1f);
}
return true;
}
[HarmonyPatch(typeof(BoltActionRifle), "Fire")]
[HarmonyPrefix]
public static bool BoltActionRifle_Decocking_Patch(BoltActionRifle __instance)
{
//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)
if (((FVRInteractiveObject)__instance).IsHeld && Vector2.Angle(((FVRInteractiveObject)__instance).m_hand.Input.TouchpadAxes, Vector2.up) <= 45f && ((FVRInteractiveObject)__instance).m_hand.Input.TouchpadPressed && ((Vector2)(ref ((FVRInteractiveObject)__instance).m_hand.Input.TouchpadAxes)).magnitude > 0.2f)
{
return false;
}
return true;
}
}
public class BoltBrace : MonoBehaviour
{
[HarmonyPatch(typeof(ClosedBoltWeapon), "FVRUpdate")]
[HarmonyPrefix]
public static bool BoltBrace_ClosedBolt_Patch(ClosedBoltWeapon __instance)
{
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Invalid comparison between Unknown and I4
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
if ((Object)(object)((Component)__instance).transform.parent != (Object)(object)((Component)BoltBrace_PlayerHeadLock.Instance).transform)
{
if (!((FVRInteractiveObject)__instance).IsHeld && !((FVRPhysicalObject)__instance).IsAltHeld && ((int)__instance.Bolt.CurPos == 4 || (__instance.Bolt.UsesAKSafetyLock && Mathf.Abs(__instance.Bolt.m_boltZ_current - __instance.Bolt.m_boltZ_safetylock) < 0.001f)) && ((FVRInteractiveObject)__instance.Bolt).IsHeld && !((FVRPhysicalObject)__instance).IsKinematicLocked && ((FVRFireArm)__instance).IsShoulderStabilized() && (Object)(object)((FVRPhysicalObject)__instance).Bipod == (Object)null)
{
((FVRPhysicalObject)__instance).SetIsKinematicLocked(true);
((Component)__instance).transform.parent = ((Component)BoltBrace_PlayerHeadLock.Instance).transform;
((Component)__instance).gameObject.AddComponent(typeof(BoltBrace_UnKinematicLock));
}
}
else if (((FVRInteractiveObject)__instance).IsHeld || ((FVRPhysicalObject)__instance).IsAltHeld || ((int)__instance.Bolt.CurPos != 4 && (!__instance.Bolt.UsesAKSafetyLock || !(Mathf.Abs(__instance.Bolt.m_boltZ_current - __instance.Bolt.m_boltZ_safetylock) < 0.001f))) || !((FVRInteractiveObject)__instance.Bolt).IsHeld)
{
((Component)__instance).transform.parent = null;
((FVRPhysicalObject)__instance).SetIsKinematicLocked(false);
}
return true;
}
[HarmonyPatch(typeof(Handgun), "FVRUpdate")]
[HarmonyPrefix]
public static bool BoltBrace_Handgun_Patch(Handgun __instance)
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Invalid comparison between Unknown and I4
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
if ((Object)(object)((Component)__instance).transform.parent != (Object)(object)((Component)BoltBrace_PlayerHeadLock.Instance).transform)
{
if (!((FVRInteractiveObject)__instance).IsHeld && !((FVRPhysicalObject)__instance).IsAltHeld && (int)__instance.Slide.CurPos == 4 && ((FVRInteractiveObject)__instance.Slide).IsHeld && !((FVRPhysicalObject)__instance).IsKinematicLocked && ((FVRFireArm)__instance).IsShoulderStabilized() && (Object)(object)((FVRPhysicalObject)__instance).Bipod == (Object)null)
{
((FVRPhysicalObject)__instance).SetIsKinematicLocked(true);
((Component)__instance).transform.parent = ((Component)BoltBrace_PlayerHeadLock.Instance).transform;
((Component)__instance).gameObject.AddComponent(typeof(BoltBrace_UnKinematicLock));
}
}
else if (((FVRInteractiveObject)__instance).IsHeld || ((FVRPhysicalObject)__instance).IsAltHeld || (int)__instance.Slide.CurPos != 4 || !((FVRInteractiveObject)__instance.Slide).IsHeld)
{
((Component)__instance).transform.parent = null;
((FVRPhysicalObject)__instance).SetIsKinematicLocked(false);
}
return true;
}
[HarmonyPatch(typeof(BoltActionRifle), "FVRFixedUpdate")]
[HarmonyPrefix]
public static bool BoltBrace_BoltAction_Patch(BoltActionRifle __instance)
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Invalid comparison between Unknown and I4
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Invalid comparison between Unknown and I4
if ((Object)(object)((Component)__instance).transform.parent != (Object)(object)((Component)BoltBrace_PlayerHeadLock.Instance).transform)
{
if (!((FVRInteractiveObject)__instance).IsHeld && !((FVRPhysicalObject)__instance).IsAltHeld && (int)__instance.CurBoltHandleState == 2 && ((FVRInteractiveObject)__instance.BoltHandle).IsHeld && !((FVRPhysicalObject)__instance).IsKinematicLocked && ((FVRFireArm)__instance).IsShoulderStabilized() && (Object)(object)((FVRPhysicalObject)__instance).Bipod == (Object)null)
{
((FVRPhysicalObject)__instance).SetIsKinematicLocked(true);
((Component)__instance).transform.parent = ((Component)BoltBrace_PlayerHeadLock.Instance).transform;
((Component)__instance).gameObject.AddComponent(typeof(BoltBrace_UnKinematicLock));
}
}
else if (((FVRInteractiveObject)__instance).IsHeld || ((FVRPhysicalObject)__instance).IsAltHeld || (int)__instance.CurBoltHandleState != 2 || !((FVRInteractiveObject)__instance.BoltHandle).IsHeld)
{
((Component)__instance).transform.parent = null;
((FVRPhysicalObject)__instance).SetIsKinematicLocked(false);
}
return true;
}
[HarmonyPatch(typeof(FVRFireArm), "EjectClip")]
[HarmonyPrefix]
public static bool BoltBrace_BoltAction_Patch_Fix(FVRFireArm __instance)
{
if (__instance is BoltActionRifle && (Object)(object)((Component)__instance).transform.parent == (Object)(object)((Component)BoltBrace_PlayerHeadLock.Instance).transform)
{
return false;
}
return true;
}
[HarmonyPatch(typeof(PhysicalMagazineReleaseLatch), "FixedUpdate")]
[HarmonyPostfix]
public static void BoltBrace_PhysicalMagazineReleaseLatch_FixKick(PhysicalMagazineReleaseLatch __instance)
{
if (((FVRPhysicalObject)__instance.FireArm).IsKinematicLocked && (Object)(object)__instance.FireArm.Magazine != (Object)null && __instance.timeSinceLastCollision < 0.03f && __instance.Joint.angle < __instance.Threshold * 0.25f)
{
__instance.FireArm.EjectMag(true);
}
}
}
public class BoltBrace_PlayerHeadLock : MonoBehaviour
{
public static BoltBrace_PlayerHeadLock Instance;
private Transform transform1 = ((Component)GM.CurrentPlayerBody.Head).transform;
public void Update()
{
//IL_000d: 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)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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)
Transform transform = ((Component)this).transform;
transform.position = transform1.position;
transform.rotation = transform1.rotation;
Vector3 localEulerAngles = transform.localEulerAngles;
localEulerAngles.x = 0f;
localEulerAngles.z = 0f;
transform.localEulerAngles = localEulerAngles;
}
[HarmonyPatch(typeof(FVRPlayerBody), "Start")]
[HarmonyPrefix]
public static bool SpawnPHL(FVRPlayerBody __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
Instance = new GameObject().AddComponent<BoltBrace_PlayerHeadLock>();
return true;
}
}
public class BoltBrace_UnKinematicLock : MonoBehaviour
{
private FVRPhysicalObject physobj;
private FVRInteractiveObject bolt;
public void Start()
{
physobj = ((Component)this).GetComponent<FVRPhysicalObject>();
if (physobj is ClosedBoltWeapon)
{
ref FVRInteractiveObject reference = ref bolt;
FVRPhysicalObject obj = physobj;
reference = (FVRInteractiveObject)(object)((ClosedBoltWeapon)((obj is ClosedBoltWeapon) ? obj : null)).Bolt;
}
if (physobj is BoltActionRifle)
{
ref FVRInteractiveObject reference2 = ref bolt;
FVRPhysicalObject obj2 = physobj;
reference2 = (FVRInteractiveObject)(object)((BoltActionRifle)((obj2 is BoltActionRifle) ? obj2 : null)).BoltHandle;
}
if (physobj is Handgun)
{
ref FVRInteractiveObject reference3 = ref bolt;
FVRPhysicalObject obj3 = physobj;
reference3 = (FVRInteractiveObject)(object)((Handgun)((obj3 is Handgun) ? obj3 : null)).Slide;
}
}
public void Update()
{
if (!((FVRInteractiveObject)physobj).IsHeld && !physobj.IsAltHeld && !bolt.IsHeld && physobj.TimeSinceInQuickbelt != 0f)
{
physobj.SetIsKinematicLocked(false);
Object.Destroy((Object)(object)this);
}
}
}
public class ClearStabilization : MonoBehaviour
{
[HarmonyPatch(typeof(FVRFireArm), "IsTwoHandStabilized")]
[HarmonyPrefix]
public static bool ClearStabilization_Patch(FVRFireArm __instance)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.ClearStab_IsEnabled.Value || !GM.Options.QuickbeltOptions.HideControllerGeoWhenObjectHeld)
{
return true;
}
if ((Object)(object)((FVRInteractiveObject)__instance).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)__instance).m_hand.OtherHand != (Object)null && ((Object)(object)((FVRInteractiveObject)__instance).m_hand.OtherHand.CurrentInteractable == (Object)null || ((FVRInteractiveObject)__instance).m_hand.OtherHand.CurrentInteractable is Flashlight || ((FVRInteractiveObject)__instance).m_hand.OtherHand.CurrentInteractable is FVRFireArmMagazine))
{
float num = Vector3.Distance(((FVRInteractiveObject)__instance).m_hand.PalmTransform.position, ((FVRInteractiveObject)__instance).m_hand.OtherHand.PalmTransform.position);
if (num < BepInExPlugin.ClearStab_Treshhold.Value)
{
((FVRInteractiveObject)__instance).m_hand.OtherHand.Display_Controller.SetActive(false);
}
else if (num < BepInExPlugin.ClearStab_Treshhold.Value + 0.06f)
{
ReDisplayViveHand(ref ((FVRInteractiveObject)__instance).m_hand.OtherHand);
}
}
return true;
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
public static bool ClearStabilization_ResetOtherHand_Patch(FVRViveHand __instance)
{
ReDisplayViveHand(ref __instance.OtherHand);
return true;
}
public static void ReDisplayViveHand(ref FVRViveHand hand)
{
if ((Object)(object)hand.m_currentInteractable == (Object)null)
{
if (!hand.Display_InteractionSphere.activeSelf)
{
hand.Display_InteractionSphere.SetActive(true);
}
if (!hand.Display_InteractionSphere_Palm.activeSelf)
{
hand.Display_InteractionSphere_Palm.SetActive(true);
}
}
else
{
if (hand.Display_InteractionSphere.activeSelf)
{
hand.Display_InteractionSphere.SetActive(false);
}
if (hand.Display_InteractionSphere_Palm.activeSelf)
{
hand.Display_InteractionSphere_Palm.SetActive(false);
}
}
if (GM.Options.QuickbeltOptions.HideControllerGeoWhenObjectHeld)
{
if ((Object)(object)hand.m_currentInteractable == (Object)null)
{
if (!hand.Display_Controller.activeSelf)
{
hand.Display_Controller.SetActive(true);
}
}
else if (hand.Display_Controller.activeSelf)
{
hand.Display_Controller.SetActive(false);
}
}
else if (!hand.Display_Controller.activeSelf)
{
hand.Display_Controller.SetActive(true);
}
}
}
public class DecockingRevolver : MonoBehaviour
{
[HarmonyPatch(typeof(Revolver), "Fire")]
[HarmonyPrefix]
public static bool DecockRevolver(Revolver __instance)
{
if (__instance.DoesFiringRecock)
{
__instance.m_shouldRecock = true;
}
if (__instance.CanManuallyCockHammer && (Object)(object)((FVRInteractiveObject)__instance).m_hand != (Object)null)
{
bool flag = false;
if (((FVRInteractiveObject)__instance).m_hand.IsInStreamlinedMode ? ((FVRInteractiveObject)__instance).m_hand.Input.AXButtonPressed : ((FVRInteractiveObject)__instance).m_hand.Input.TouchpadPressed)
{
__instance.Chambers[__instance.CurChamber].IsSpent = false;
__instance.Chambers[__instance.CurChamber].UpdateProxyDisplay();
__instance.m_shouldRecock = false;
return false;
}
}
return true;
}
[HarmonyPatch(typeof(Revolver), "UpdateTriggerHammer")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> DecockRevolver_UpdateTriggerHammerPatch(IEnumerable<CodeInstruction> instructions)
{
int num = -1;
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count && i + 4 < list.Count - 1; i++)
{
if (list[i].opcode == OpCodes.Ldarg_0 && list[i + 1].opcode == OpCodes.Ldfld && list[i + 2].opcode == OpCodes.Ldflda && list[i + 3].opcode == OpCodes.Ldfld && list[i + 4].opcode == OpCodes.Brtrue)
{
num = i;
}
}
if (num > -1)
{
for (int j = 0; j < 5; j++)
{
list[num + j].opcode = OpCodes.Nop;
}
}
return list.AsEnumerable();
}
[HarmonyPatch(typeof(Revolver), "UpdateTriggerHammer")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> RemoveFiringRecock_UpdateTriggerHammer_Patch(IEnumerable<CodeInstruction> instructions)
{
int num = -1;
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count && i + 5 < list.Count - 1; i++)
{
if (list[i].opcode == OpCodes.Ldarg_0 && list[i + 1].opcode == OpCodes.Ldfld && list[i + 2].opcode == OpCodes.Brfalse && list[i + 3].opcode == OpCodes.Ldarg_0 && list[i + 4].opcode == OpCodes.Ldc_I4_1 && list[i + 5].opcode == OpCodes.Stfld)
{
num = i;
}
}
if (num > -1)
{
for (int j = 0; j < 6; j++)
{
list[num + j].opcode = OpCodes.Nop;
}
}
return list.AsEnumerable();
}
}
public class EasyAttaching : MonoBehaviour
{
[HarmonyPatch(typeof(FVRPhysicalObject), "FVRFixedUpdate")]
[HarmonyPostfix]
public static void EasyAttach_Patch(FVRPhysicalObject __instance)
{
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
if (!BepInExPlugin.EasyAttaching_IsEnabled.Value || !(__instance is FVRFireArmAttachment))
{
return;
}
FVRFireArmAttachment val = (FVRFireArmAttachment)(object)((__instance is FVRFireArmAttachment) ? __instance : null);
if (!((FVRInteractiveObject)__instance).IsHeld || !((Object)(object)((FVRInteractiveObject)__instance).m_hand.OtherHand.CurrentInteractable != (Object)null))
{
return;
}
FVRInteractiveObject currentInteractable = ((FVRInteractiveObject)__instance).m_hand.OtherHand.CurrentInteractable;
FVRPhysicalObject val2 = (FVRPhysicalObject)(object)((currentInteractable is FVRPhysicalObject) ? currentInteractable : null);
if ((Object)(object)val2 == (Object)null)
{
return;
}
bool flag = false;
foreach (FVRFireArmAttachmentMount attachmentMount in val2.AttachmentMounts)
{
if ((Object)(object)attachmentMount == (Object)null)
{
Debug.LogError((object)(((Object)val2.ObjectWrapper).name + " has a missing attachment mount field. What? --Soup"));
}
else if (Vector3.Distance(((Component)attachmentMount).transform.position, ((Component)val.Sensor).transform.position) <= 0.15f)
{
flag = true;
}
}
Collider[] colliders;
if (flag)
{
colliders = ((FVRInteractiveObject)__instance).m_colliders;
foreach (Collider val3 in colliders)
{
if ((Object)(object)val3 != (Object)null && !val3.isTrigger && ((Component)val3).gameObject.layer == LayerMask.NameToLayer("Default"))
{
((Component)val3).gameObject.layer = LayerMask.NameToLayer("NoCol");
}
}
return;
}
colliders = ((FVRInteractiveObject)__instance).m_colliders;
foreach (Collider val4 in colliders)
{
if ((Object)(object)val4 != (Object)null && !val4.isTrigger && ((Component)val4).gameObject.layer == LayerMask.NameToLayer("NoCol"))
{
((Component)val4).gameObject.layer = LayerMask.NameToLayer("Default");
}
}
}
}
public class ExtractorHit
{
[HarmonyPatch(typeof(RevolverEjector), "FVRUpdate")]
[HarmonyPostfix]
public static void RevolverEjector_FVRUpdate_HitEjector(RevolverEjector __instance)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
if (!((FVRInteractiveObject)__instance.Magnum).IsHeld || __instance.Magnum.m_isCylinderArmLocked)
{
return;
}
FVRViveHand otherHand = ((FVRInteractiveObject)__instance.Magnum).m_hand.OtherHand;
if (otherHand.CurrentInteractable is Speedloader && !((Speedloader)/*isinst with value type is only supported in some contexts*/).Chambers.Any((SpeedloaderChamber x) => x.IsLoaded))
{
return;
}
float num = Vector3.Distance(((Component)__instance).transform.position, ((HandInput)(ref otherHand.Input)).Pos);
float num2 = Vector3.Distance(((Component)__instance).transform.position, ((HandInput)(ref otherHand.Input)).PalmPos);
float num3 = Vector3.Dot(-((Component)__instance).transform.forward, ((Vector3)(ref otherHand.Input.VelLinearWorld)).normalized);
if ((num < 0.035f || num2 < 0.035f) && num3 > 0.4f && ((Vector3)(ref otherHand.Input.VelLinearWorld)).magnitude > 1f)
{
__instance.ELerp = 1f;
if ((Object)(object)__instance.Ejector != (Object)null)
{
__instance.Ejector.localPosition = __instance.RearPos;
}
if ((Object)(object)__instance.Ejector2 != (Object)null)
{
__instance.Ejector2.localPosition = __instance.RearPos2;
}
__instance.Magnum.EjectChambers();
}
}
[HarmonyPatch(typeof(FVRInteractiveObject), "FVRUpdate")]
[HarmonyPostfix]
public static void SingleActionEjectorRod_FVRUpdate_HitEjector(FVRInteractiveObject __instance)
{
//IL_0039: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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)
if (!(__instance is SingleActionEjectorRod))
{
return;
}
SingleActionEjectorRod val = (SingleActionEjectorRod)(object)((__instance is SingleActionEjectorRod) ? __instance : null);
if (((FVRInteractiveObject)val.Revolver).IsHeld)
{
FVRViveHand otherHand = ((FVRInteractiveObject)val.Revolver).m_hand.OtherHand;
float num = Vector3.Distance(((Component)val).transform.position, ((HandInput)(ref otherHand.Input)).Pos);
float num2 = Vector3.Distance(((Component)val).transform.position, ((HandInput)(ref otherHand.Input)).PalmPos);
float num3 = Vector3.Dot(-((Component)val).transform.forward, ((Vector3)(ref otherHand.Input.VelLinearWorld)).normalized);
if ((num < 0.035f || num2 < 0.035f) && num3 > 0.4f && ((Vector3)(ref otherHand.Input.VelLinearWorld)).magnitude > 1f)
{
val.Revolver.EjectPrevCylinder();
}
}
}
}
public class QuickerClip : MonoBehaviour
{
public static float clipejectdist = 0.12f;
[HarmonyPatch(typeof(FVRInteractiveObject), "UpdateInteraction")]
[HarmonyPrefix]
public static bool RemoveClipCorrectly(FVRInteractiveObject __instance, ref FVRViveHand hand)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (__instance is FVRFireArmClip)
{
FVRFireArmClip val = (FVRFireArmClip)(object)((__instance is FVRFireArmClip) ? __instance : null);
float num = Vector3.Distance(((Component)val).transform.position, ((Component)hand).transform.position);
Debug.Log((object)num);
if (num >= clipejectdist)
{
Debug.Log((object)"Let me go!");
hand.ForceSetInteractable((FVRInteractiveObject)null);
val.Release();
hand.ForceSetInteractable(__instance);
}
}
return true;
}
}
public class QuickGrabbing : MonoBehaviour
{
[HarmonyPatch(typeof(FVRInteractiveObject), "Poke")]
[HarmonyPostfix]
public static void QuickGrabbingPatch(FVRInteractiveObject __instance, ref FVRViveHand hand)
{
if (BepInExPlugin.QuickGrabbing_IsEnabled.Value && !((Object)(object)hand.m_currentHoveredQuickbeltSlot != (Object)null) && ((__instance is ClosedBolt && BepInExPlugin.QuickGrabbing_GrabBolts.Value) || (__instance is ClosedBoltHandle && BepInExPlugin.QuickGrabbing_GrabBolts.Value) || (__instance is OpenBoltReceiverBolt && BepInExPlugin.QuickGrabbing_GrabBolts.Value) || (__instance is OpenBoltChargingHandle && BepInExPlugin.QuickGrabbing_GrabBolts.Value) || (__instance is BoltActionRifle_Handle && BepInExPlugin.QuickGrabbing_GrabBolts.Value) || (__instance is TubeFedShotgunBolt && BepInExPlugin.QuickGrabbing_GrabBolts.Value) || (__instance is FVRFireArmMagazine && BepInExPlugin.QuickGrabbing_GrabMags.Value) || (__instance is Speedloader && BepInExPlugin.QuickGrabbing_GrabMags.Value) || (__instance is FVRFireArmClipInterface && BepInExPlugin.QuickGrabbing_FastClip.Value) || (__instance is HandgunSlide && BepInExPlugin.QuickGrabbing_GrabPistolSlides.Value) || (__instance is FVRHandGrabPoint && BepInExPlugin.QuickGrabbing_GrabRopes.Value) || (__instance is PinnedGrenade && BepInExPlugin.QuickGrabbing_GrabGrenade.Value) || (__instance is FVRCappedGrenade && BepInExPlugin.QuickGrabbing_GrabGrenade.Value) || (__instance is SosigWeaponPlayerInterface && BepInExPlugin.QuickGrabbing_GrabSosigWeapon.Value) || (__instance is TubeFedShotgunHandle && BepInExPlugin.QuickGrabbing_GrabFores.Value) || (__instance is FVRAlternateGrip && BepInExPlugin.QuickGrabbing_GrabFores.Value) || (__instance is FVRFireArmGrip && BepInExPlugin.QuickGrabbing_GrabFores.Value) || (__instance is RPG7Foregrip && BepInExPlugin.QuickGrabbing_GrabFores.Value) || (__instance is AttachableForegrip && BepInExPlugin.QuickGrabbing_GrabFores.Value) || (__instance is FVRFireArmTopCover && BepInExPlugin.QuickGrabbing_GrabFores.Value) || (__instance is FVRFireArmRound && BepInExPlugin.QuickGrabbing_GrabBullets.Value)))
{
QuickGrab(__instance, hand);
}
}
public static void QuickGrab(FVRInteractiveObject __instance, FVRViveHand hand)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Invalid comparison between Unknown and I4
FVRAlternateGrip val = (FVRAlternateGrip)(object)((__instance is FVRAlternateGrip) ? __instance : null);
if (val != null && val.PrimaryObject.IsAltHeld)
{
return;
}
FVRFireArmMagazine val2 = (FVRFireArmMagazine)(object)((__instance is FVRFireArmMagazine) ? __instance : null);
if ((val2 != null && (int)val2.State == 1) || (BepInExPlugin.QuickGrabbing_DisableWhenRunning.Value && IsArmSwinging(hand) && !(__instance is FVRHandGrabPoint)) || (Object)(object)__instance == (Object)(object)hand.OtherHand.CurrentInteractable || (__instance is BoltActionRifle_Handle && !((BoltActionRifle_Handle)((__instance is BoltActionRifle_Handle) ? __instance : null)).Rifle.CanBoltMove()))
{
return;
}
if (__instance is BoltActionRifle_Handle)
{
BoltActionRifle_Handle val3 = (BoltActionRifle_Handle)(object)((__instance is BoltActionRifle_Handle) ? __instance : null);
if ((Object)(object)((FVRFireArm)val3.Rifle).Magazine != (Object)null && ((FVRFireArm)val3.Rifle).Magazine.m_capacity != ((FVRFireArm)val3.Rifle).Magazine.m_numRounds && (Object)(object)((FVRFireArm)val3.Rifle).Clip != (Object)null && ((FVRFireArm)val3.Rifle).Clip.m_numRounds != 0)
{
return;
}
}
if (hand.Input.IsGrabbing && (int)hand.m_state == 0 && (!(__instance is SosigWeaponPlayerInterface) || (int)((SosigWeaponPlayerInterface)((__instance is SosigWeaponPlayerInterface) ? __instance : null)).W.Type == 2))
{
if (BepInExPlugin.QuickGrabbing_RegrabBolt.Value && __instance is BoltActionRifle_Handle)
{
((BoltActionRifle_Handle)((__instance is BoltActionRifle_Handle) ? __instance : null)).m_wasTPInitiated = true;
}
hand.Buzz(hand.Buzzer.Buzz_BeginInteraction);
hand.ForceSetInteractable(__instance);
__instance.BeginInteraction(hand);
}
}
[HarmonyPatch(typeof(PinnedGrenade), "ReleaseLever")]
[HarmonyPatch(typeof(FVRCappedGrenade), "CapRemoved")]
[HarmonyPatch(typeof(SosigWeapon), "FuseGrenade")]
[HarmonyPostfix]
public static void GrenadeExtendRadius(FVRPhysicalObject __instance)
{
if (BepInExPlugin.QuickGrabbing_IsEnabled.Value)
{
SphereCollider obj = ((Component)__instance).gameObject.AddComponent<SphereCollider>();
((Collider)obj).isTrigger = true;
obj.radius = BepInExPlugin.QuickGrabbing_GrabGrenadeRange.Value;
}
}
[HarmonyPatch(typeof(FVRFireArmClipInterface), "UpdateInteraction")]
[HarmonyPrefix]
public static bool LetGoOfClip(FVRFireArmClipInterface __instance)
{
if (!BepInExPlugin.QuickGrabbing_IsEnabled.Value || !BepInExPlugin.QuickGrabbing_FastClip.Value)
{
return true;
}
if ((Object)(object)__instance.Clip.FireArm != (Object)null && (Object)(object)__instance.Clip.FireArm.Magazine != (Object)null && (__instance.Clip.FireArm.Magazine.IsFull() || __instance.Clip.m_numRounds == 0))
{
((FVRInteractiveObject)__instance).m_hand.ForceSetInteractable((FVRInteractiveObject)null);
return false;
}
return true;
}
public static bool IsArmSwinging(FVRViveHand hand)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
if ((int)hand.MovementManager.Mode == 4)
{
if (hand.IsInStreamlinedMode)
{
if ((int)hand.CMode == 3 || (int)hand.CMode == 2)
{
return hand.Input.Secondary2AxisNorthPressed;
}
return hand.Input.TouchpadNorthPressed;
}
return hand.Input.BYButtonPressed;
}
return false;
}
}
public class SingleActionCCing : MonoBehaviour
{
[HarmonyPatch(typeof(SingleActionRevolver), "UpdateInteraction")]
[HarmonyPrefix]
public static bool SingleActionRevolver_UpdateInteraction_EnableCCing(SingleActionRevolver __instance, ref FVRViveHand hand)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if (!((FVRPhysicalObject)__instance).IsAltHeld && __instance.m_isStateToggled && !((FVRPhysicalObject)__instance).IsAltHeld && !hand.IsInStreamlinedMode && hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f)
{
__instance.CurChamber = __instance.PrevChamber;
((FVRFireArm)__instance).PlayAudioEvent((FirearmAudioEventType)15, 1f);
}
return true;
}
}
public class ThumbBullet : MonoBehaviour
{
[HarmonyPatch(typeof(FVRFireArmChamber), "EjectRound", new Type[]
{
typeof(Vector3),
typeof(Vector3),
typeof(Vector3),
typeof(bool)
})]
[HarmonyPatch(typeof(FVRFireArmChamber), "EjectRound", new Type[]
{
typeof(Vector3),
typeof(Vector3),
typeof(Vector3),
typeof(Vector3),
typeof(Quaternion),
typeof(bool)
})]
[HarmonyPostfix]
public static void ThumbBullet_Chamber_Patch(FVRFireArmChamber __instance, ref FVRFireArmRound __result)
{
if (!(__instance.Firearm is BoltActionRifle) && !(__instance.Firearm is ClosedBoltWeapon) && !(__instance.Firearm is Handgun))
{
return;
}
FVRInteractiveObject val = null;
if (__instance.Firearm is BoltActionRifle)
{
FVRFireArm firearm = __instance.Firearm;
val = (FVRInteractiveObject)(object)((BoltActionRifle)((firearm is BoltActionRifle) ? firearm : null)).BoltHandle;
}
if (__instance.Firearm is ClosedBoltWeapon)
{
FVRFireArm firearm2 = __instance.Firearm;
val = (FVRInteractiveObject)(object)((ClosedBoltWeapon)((firearm2 is ClosedBoltWeapon) ? firearm2 : null)).Bolt;
}
if (__instance.Firearm is Handgun)
{
FVRFireArm firearm3 = __instance.Firearm;
val = (FVRInteractiveObject)(object)((Handgun)((firearm3 is Handgun) ? firearm3 : null)).Slide;
}
if (val.IsHeld)
{
bool flag = false;
flag = (val.m_hand.IsInStreamlinedMode ? val.m_hand.Input.AXButtonPressed : val.m_hand.Input.TouchpadPressed);
if ((Object)(object)__instance.Firearm.Magazine != (Object)null && (Object)(object)__result != (Object)null && flag && !__result.IsSpent && __instance.Firearm.Magazine.m_numRounds < __instance.Firearm.Magazine.m_capacity)
{
__instance.Firearm.Magazine.AddRound(__result, true, true, false);
Object.Destroy((Object)(object)((Component)__result).gameObject);
}
}
}
[HarmonyPatch(typeof(ClosedBolt), "UpdateInteraction")]
[HarmonyPrefix]
public static bool RemoveAntonsBoltLock(ClosedBolt __instance, ref FVRViveHand hand)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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_008d: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
if (BepInExPlugin.AntonBoltLock_IsEnabled.Value)
{
return true;
}
((FVRInteractiveObject)__instance).IsHeld = true;
((FVRInteractiveObject)__instance).m_hand = hand;
if (!((FVRInteractiveObject)__instance).m_hasTriggeredUpSinceBegin && ((FVRInteractiveObject)__instance).m_hand.Input.TriggerFloat < 0.15f)
{
((FVRInteractiveObject)__instance).m_hasTriggeredUpSinceBegin = true;
}
if (((FVRInteractiveObject)__instance).triggerCooldown > 0f)
{
((FVRInteractiveObject)__instance).triggerCooldown = ((FVRInteractiveObject)__instance).triggerCooldown - Time.deltaTime;
}
if (__instance.HasRotatingPart)
{
Vector3 val = ((Component)__instance).transform.position - ((FVRInteractiveObject)__instance).m_hand.PalmTransform.position;
if (Vector3.Dot(((Vector3)(ref val)).normalized, ((Component)__instance).transform.right) > 0f)
{
__instance.RotatingPart.localEulerAngles = __instance.RotatingPartLeftEulers;
}
else
{
__instance.RotatingPart.localEulerAngles = __instance.RotatingPartRightEulers;
}
}
return false;
}
}
public class Transpiler : MonoBehaviour
{
public static int TranspilerMatchCode(List<CodeInstruction> codes, OpCode[] match, bool log = false)
{
int result = -1;
for (int i = 0; i < codes.Count && i + (match.Length - 1) < codes.Count - 1; i++)
{
bool flag = false;
for (int j = 0; j < match.Length; j++)
{
if (codes[i + j].opcode != match[j])
{
if (log)
{
Debug.Log((object)("attempting check at " + i + "- failed at " + j + "; expected " + match[j].ToString() + ", got " + codes[i + j].opcode));
}
flag = true;
break;
}
}
if (!flag)
{
result = i;
}
}
return result;
}
}
}