using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using FistVR;
using Microsoft.CodeAnalysis;
using On.FistVR;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("AccessibilityOptions")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AccessibilityOptions")]
[assembly: AssemblyTitle("AccessibilityOptions")]
[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 AccessibilityOptions
{
[BepInPlugin("okkim.accessibilityoptions", "Accessibility Options", "1.0.0")]
[BepInProcess("h3vr.exe")]
public class AccessibilityOptionsBase : BaseUnityPlugin
{
public static ConfigEntry<bool> oneHandedWristMenuEnabled;
public static ConfigEntry<float> verticalPointerOffset;
public static ConfigEntry<Color> pointerColor;
public static ConfigEntry<float> pointerScale;
public static ConfigEntry<bool> lockPanelsAutomatically;
public static ConfigEntry<string> autoLockPanelWhitelist;
public static ConfigEntry<bool> weaponPoseLockingEnabled;
public static ConfigEntry<float> weaponPoseLockingTriggerDuration;
public static ConfigEntry<bool> gripAngleOverrideEnabled;
public static ConfigEntry<float> overrideGripAngle;
public static ConfigEntry<bool> overrideRecoil;
public static ConfigEntry<bool> oneHandedHoverBench;
public static ConfigEntry<bool> miscWeaponTweaksEnabled;
public static ConfigEntry<bool> oneHandedSAREnabled;
public static ConfigEntry<bool> oneHandedGrenadesEnabled;
public static ConfigEntry<float> pinnedGrenadePinPullDuration;
public static ConfigEntry<bool> oneHandedPumpReleaseEnabled;
private const string ASSET_BUNDLE_NAME = "accessibilityoptions";
public static AssetBundle pointerAssetBundle;
private OneHandedWristMenu oneHandedWristMenu;
private AutoLockingPanels autoLockingPanels;
private WeaponPoseLock weaponPoseLock;
private GripAngleOverride gripAngleOverride;
private OneHandedMiscWeaponTweaks oneHandedMiscWeaponTweaks;
public AccessibilityOptionsBase()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
pointerAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "accessibilityoptions"));
oneHandedWristMenuEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Wrist Menu", "Enable One-Handed Wrist Menu", true, "Enabled/disables one-handed wrist menu (requires game restart)");
verticalPointerOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Wrist Menu", "Vertical Pointer Offset", -10f, "How far up or down (in degrees) the wrist menu pointer is from the center of your view");
pointerColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Wrist Menu", "Pointer Color", Color.green, "Color of the wrist menu pointer (RGBA)");
pointerScale = ((BaseUnityPlugin)this).Config.Bind<float>("Wrist Menu", "Pointer Scale", 0.01f, "How large (in meters) the pointer is");
weaponPoseLockingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapon Pose Locking", "Enable Weapon Pose Locking", true, "Lock weapons in mid-air by holding down the trigger on a safe or empty chamber");
weaponPoseLockingTriggerDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon Pose Locking", "Pose Locking Trigger Hold Duration", 0.35f, "How long the trigger needs to be held down for the weapon to get locked");
overrideRecoil = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality Of Life", "Force Two-Handed Recoil", true, "Force weapons to always recoil like they're being two-handed");
oneHandedHoverBench = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality Of Life", "Enable One-Handed Hoverbench", true, "Allow locking items into the Hoverbench without requiring two hands");
gripAngleOverrideEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality Of Life", "Enable Grip Angle Override", true, "Override the angle weapons are held at, to make one-handed aiming easier");
overrideGripAngle = ((BaseUnityPlugin)this).Config.Bind<float>("Quality Of Life", "Override Grip Angle", -75f, "Determines the up/down angle of a weapon's hold pose");
lockPanelsAutomatically = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality Of Life", "Automatically Lock Option Panels", true, "Option panels lock automatically when spawned");
autoLockPanelWhitelist = ((BaseUnityPlugin)this).Config.Bind<string>("Quality Of Life", "(Advanced) Auto-Locking Panel Whitelist", "OptionsPanel_Screenmanager AmmoSpawnerV2", "Add a panel class name here (case-sensitive, separated by a space) to lock it automatically upon spawning");
miscWeaponTweaksEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Miscellaneous Weapon Tweaks", "Enable Miscellaneous One-Handed Weapon Tweaks", true, "Toggle all miscellaneous weapon tweaks on or off");
oneHandedSAREnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Miscellaneous Weapon Tweaks", "Enable One-Handed Single-Action Revolvers", true, "Automatically advance single-action revolver cylinders upon inserting a round");
oneHandedGrenadesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Miscellaneous Weapon Tweaks", "Enable One-Handed Grenades", true, "Pull pins by holding the touchpad or AX face buttons");
pinnedGrenadePinPullDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Miscellaneous Weapon Tweaks", "Pinned Grenade Pin Pull Duration", 0.5f, "How long (in seconds) the button needs to be held down to pull out a grenade pin (set to 0 for instant)");
oneHandedPumpReleaseEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Miscellaneous Weapon Tweaks", "Enable One-Handed Pump Release", true, "Unlock pump-action weapon pumps by pulling the trigger while holding the pump");
}
private void Awake()
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
if (oneHandedWristMenuEnabled.Value)
{
oneHandedWristMenu = ((Component)this).gameObject.AddComponent<OneHandedWristMenu>();
}
if (lockPanelsAutomatically.Value)
{
autoLockingPanels = ((Component)this).gameObject.AddComponent<AutoLockingPanels>();
}
if (weaponPoseLockingEnabled.Value)
{
weaponPoseLock = ((Component)this).gameObject.AddComponent<WeaponPoseLock>();
}
if (gripAngleOverrideEnabled.Value)
{
gripAngleOverride = ((Component)this).gameObject.AddComponent<GripAngleOverride>();
}
if (overrideRecoil.Value)
{
FVRFireArm.Recoil += new hook_Recoil(FVRFireArm_Recoil);
}
if (oneHandedHoverBench.Value)
{
FVRPivotLocker.TryToLockObject += new hook_TryToLockObject(FVRPivotLocker_TryToLockObject);
}
if (miscWeaponTweaksEnabled.Value)
{
oneHandedMiscWeaponTweaks = ((Component)this).gameObject.AddComponent<OneHandedMiscWeaponTweaks>();
}
}
private void FVRFireArm_Recoil(orig_Recoil orig, FVRFireArm self, bool twoHandStabilized, bool foregripStabilized, bool shoulderStabilized, FVRFireArmRecoilProfile overrideprofile, float VerticalRecoilMult)
{
orig.Invoke(self, true, true, shoulderStabilized, overrideprofile, VerticalRecoilMult);
}
private void FVRPivotLocker_TryToLockObject(orig_TryToLockObject orig, FVRPivotLocker self)
{
//IL_001c: 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_0031: 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)
orig.Invoke(self);
if ((Object)(object)self.m_obj != (Object)null)
{
return;
}
Collider[] array = Physics.OverlapBox(self.TestingBox.position, self.TestingBox.localScale / 1.9f, self.TestingBox.rotation);
for (int i = 0; i < array.Length; i++)
{
FVRPhysicalObject component = ((Component)array[i]).GetComponent<FVRPhysicalObject>();
if ((Object)(object)component != (Object)null)
{
if ((Object)(object)weaponPoseLock.currentlyLockedWeapon != (Object)null && (Object)(object)weaponPoseLock.currentlyLockedWeapon.thisFirearm == (Object)(object)component)
{
weaponPoseLock.currentlyLockedWeapon.UnlockWeapon();
}
self.LockObject(component);
break;
}
}
}
}
internal class AutoLockingPanels : MonoBehaviour
{
private string[] panelWhitelist = new string[0];
public void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
FVRPhysicalObject.Awake += new hook_Awake(FVRPhysicalObject_Awake);
panelWhitelist = AccessibilityOptionsBase.autoLockPanelWhitelist.Value.Split(new char[1] { ' ' });
for (int i = 0; i < panelWhitelist.Length; i++)
{
panelWhitelist[i].Trim();
}
}
private void FVRPhysicalObject_Awake(orig_Awake orig, FVRPhysicalObject self)
{
orig.Invoke(self);
string[] array = panelWhitelist;
foreach (string text in array)
{
Component[] components = ((Component)self).GetComponents(typeof(Component));
for (int j = 0; j < components.Length; j++)
{
if (((object)components[j]).GetType().Name == text)
{
if ((Object)(object)((Component)self).GetComponent<Rigidbody>() != (Object)null)
{
self.SetIsKinematicLocked(true);
}
return;
}
}
}
}
}
internal class GripAngleOverride : MonoBehaviour
{
private float overrideGripAngle;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
overrideGripAngle = AccessibilityOptionsBase.overrideGripAngle.Value;
FVRFireArm.Awake += new hook_Awake(FVRFireArm_Awake);
}
private void FVRFireArm_Awake(orig_Awake orig, FVRFireArm self)
{
//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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((FVRInteractiveObject)self).PoseOverride != (Object)null)
{
((Component)((FVRInteractiveObject)self).PoseOverride).transform.localRotation = Quaternion.Euler(new Vector3(overrideGripAngle, 0f, 0f));
}
if ((Object)(object)((FVRInteractiveObject)self).PoseOverride_Touch != (Object)null)
{
((Component)((FVRInteractiveObject)self).PoseOverride_Touch).transform.localRotation = Quaternion.Euler(new Vector3(overrideGripAngle, 0f, 0f));
}
orig.Invoke(self);
}
}
internal class OneHandedCappedGrenade : MonoBehaviour
{
private FVRCappedGrenadeCap primaryCap;
private FVRCappedGrenadeCap secondaryCap;
private AudioSource? uncapAudioSource;
private void Awake()
{
FVRCappedGrenadeCap[] componentsInChildren = ((Component)this).GetComponentsInChildren<FVRCappedGrenadeCap>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
if (i > 1)
{
Debug.LogError((object)"Too many caps found!");
break;
}
if (componentsInChildren[i].IsPrimaryCap)
{
primaryCap = componentsInChildren[i];
}
else
{
secondaryCap = componentsInChildren[i];
}
}
}
public void FVRFixedUpdate_Hooked(FVRCappedGrenade _self)
{
if ((!((FVRInteractiveObject)_self).m_hand.IsInStreamlinedMode || !((FVRInteractiveObject)_self).m_hand.Input.BYButtonDown) && (((FVRInteractiveObject)_self).m_hand.IsInStreamlinedMode || !((FVRInteractiveObject)_self).m_hand.Input.TouchpadDown))
{
return;
}
if (!_self.IsPrimaryCapRemoved)
{
if ((Object)(object)primaryCap != (Object)null)
{
RemoteCapRemoved(_isPrimary: true, _self, primaryCap);
}
}
else if (_self.UsesSecondaryCap && !_self.IsSecondaryCapRemoved && (Object)(object)secondaryCap != (Object)null)
{
RemoteCapRemoved(_isPrimary: false, _self, secondaryCap);
}
}
private void RemoteCapRemoved(bool _isPrimary, FVRCappedGrenade _self, FVRCappedGrenadeCap _cap)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
if (_isPrimary)
{
SM.PlayCoreSound((FVRPooledAudioType)10, _self.AudEvent_CapRemovePrimary, ((Component)this).transform.position);
_self.IsPrimaryCapRemoved = true;
uncapAudioSource = (AudioSource)((object)_self).GetType().GetField("AudOnUncapped").GetValue(_self);
AudioSource? obj = uncapAudioSource;
if (obj != null)
{
obj.Play();
}
}
else
{
SM.PlayCoreSound((FVRPooledAudioType)10, _self.AudEvent_CapRemoveSecondary, ((Component)this).transform.position);
_self.IsSecondaryCapRemoved = true;
}
if ((_self.UsesSecondaryCap && _self.IsPrimaryCapRemoved && _self.IsSecondaryCapRemoved) || (!_self.UsesSecondaryCap && _self.IsPrimaryCapRemoved))
{
_self.m_IsFuseActive = true;
}
Object.Instantiate<GameObject>(_isPrimary ? _self.Cap_Primary_Prefab : _self.Cap_Secondary_Prefab, ((Component)_cap).transform.position, ((Component)_cap).transform.rotation).GetComponent<FVRPhysicalObject>().RecoverRigidbody();
Object.Destroy((Object)(object)((Component)_cap).gameObject);
if (_self.HasPopOutShell)
{
for (int i = 0; i < _self.ShellPieces.Count; i++)
{
_self.ShellPieces[i].localPosition = _self.ShellPoses[i];
}
}
}
}
internal class OneHandedMiscWeaponTweaks : MonoBehaviour
{
private float pinnedGrenadePinPullDuration;
private void Awake()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
if (AccessibilityOptionsBase.oneHandedSAREnabled.Value)
{
FVRFireArmRound.Chamber += new hook_Chamber(FVRFireArmRound_Chamber);
}
if (AccessibilityOptionsBase.oneHandedGrenadesEnabled.Value)
{
pinnedGrenadePinPullDuration = AccessibilityOptionsBase.pinnedGrenadePinPullDuration.Value;
PinnedGrenade.Awake += new hook_Awake(PinnedGrenade_Awake);
PinnedGrenade.UpdateInteraction += new hook_UpdateInteraction(PinnedGrenade_UpdateInteraction);
PinnedGrenade.IncreaseFuseSetting += new hook_IncreaseFuseSetting(PinnedGrenade_IncreaseFuseSetting);
FVRCappedGrenade.Start += new hook_Start(FVRCappedGrenade_Start);
FVRCappedGrenade.FVRFixedUpdate += new hook_FVRFixedUpdate(FVRCappedGrenade_FVRFixedUpdate);
}
if (AccessibilityOptionsBase.oneHandedPumpReleaseEnabled.Value)
{
TubeFedShotgunHandle.UpdateHandle += new hook_UpdateHandle(TubeFedShotgunHandle_UpdateHandle);
ClosedBoltForeHandle.UpdateInteraction += new hook_UpdateInteraction(ClosedBoltForeHandle_UpdateInteraction);
}
}
private void ClosedBoltForeHandle_UpdateInteraction(orig_UpdateInteraction orig, ClosedBoltForeHandle self, FVRViveHand hand)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//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)
Debug.Log((object)"1");
Vector2 touchpadAxes = hand.Input.TouchpadAxes;
if (!((FVRPhysicalObject)self.Weapon).IsAltHeld)
{
return;
}
Debug.Log((object)"2");
bool flag = false;
if (hand.IsInStreamlinedMode)
{
Debug.Log((object)"3");
if (hand.Input.BYButtonDown)
{
Debug.Log((object)"4");
flag = true;
}
}
else if (hand.Input.TouchpadDown && Vector2.Angle(Vector2.up, touchpadAxes) < 45f && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f)
{
Debug.Log((object)"5");
flag = true;
}
Debug.Log((object)"6");
bool flag2 = Object.op_Implicit((Object)(ClosedBoltForeHandle)((object)self).GetType().GetField("CanSwap").GetValue(self));
Debug.Log((object)"7");
if (flag && flag2)
{
Debug.Log((object)"8");
self.AttemptToToggleMode();
}
Debug.Log((object)"9");
}
private void OnDestroy()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
FVRFireArmRound.Chamber -= new hook_Chamber(FVRFireArmRound_Chamber);
PinnedGrenade.Awake -= new hook_Awake(PinnedGrenade_Awake);
PinnedGrenade.UpdateInteraction -= new hook_UpdateInteraction(PinnedGrenade_UpdateInteraction);
PinnedGrenade.IncreaseFuseSetting -= new hook_IncreaseFuseSetting(PinnedGrenade_IncreaseFuseSetting);
FVRCappedGrenade.Start -= new hook_Start(FVRCappedGrenade_Start);
FVRCappedGrenade.FVRFixedUpdate -= new hook_FVRFixedUpdate(FVRCappedGrenade_FVRFixedUpdate);
}
private void FVRFireArmRound_Chamber(orig_Chamber orig, FVRFireArmRound self, FVRFireArmChamber c, bool makeChamberingSound)
{
orig.Invoke(self, c, makeChamberingSound);
FVRFireArm firearm = c.Firearm;
SingleActionRevolver val = (SingleActionRevolver)(object)((firearm is SingleActionRevolver) ? firearm : null);
if (val != null)
{
val.AdvanceCylinder();
val.UpdateCylinderRot();
}
}
private void PinnedGrenade_Awake(orig_Awake orig, PinnedGrenade self)
{
((Component)self).gameObject.AddComponent<OneHandedPinnedGrenade>();
orig.Invoke(self);
}
private void PinnedGrenade_UpdateInteraction(orig_UpdateInteraction orig, PinnedGrenade self, FVRViveHand hand)
{
((Component)self).GetComponent<OneHandedPinnedGrenade>().UpdateInteraction_Hooked(self, hand);
orig.Invoke(self, hand);
}
private void PinnedGrenade_IncreaseFuseSetting(orig_IncreaseFuseSetting orig, PinnedGrenade self)
{
}
private void FVRCappedGrenade_Start(orig_Start orig, FVRCappedGrenade self)
{
orig.Invoke(self);
((Component)self).gameObject.AddComponent<OneHandedCappedGrenade>();
}
private void FVRCappedGrenade_FVRFixedUpdate(orig_FVRFixedUpdate orig, FVRCappedGrenade self)
{
if (((FVRInteractiveObject)self).IsHeld && !self.m_IsFuseActive)
{
((Component)self).GetComponent<OneHandedCappedGrenade>().FVRFixedUpdate_Hooked(self);
}
orig.Invoke(self);
}
private void TubeFedShotgunHandle_UpdateHandle(orig_UpdateHandle orig, TubeFedShotgunHandle self)
{
if ((Object)(object)WeaponPoseLock.instance.currentlyLockedWeapon != (Object)null && ((FVRPhysicalObject)self.Shotgun).IsAltHeld && (Object)(object)WeaponPoseLock.instance.currentlyLockedWeapon.thisFirearm == (Object)(object)self.Shotgun)
{
FVRViveHand[] hands = GM.CurrentMovementManager.Hands;
foreach (FVRViveHand val in hands)
{
if ((Object)(object)val.CurrentInteractable == (Object)(object)self.Shotgun && (Object)(object)val.OtherHand.CurrentInteractable != (Object)(object)self.Shotgun)
{
if (val.Input.TriggerFloat >= 0.6f)
{
self.UnlockHandle();
}
break;
}
}
}
orig.Invoke(self);
}
}
internal class OneHandedPinnedGrenade : MonoBehaviour
{
private float pinPullDuration;
private bool pinBeingPulled;
private float pinPullDistance;
private PinnedGrenadeRing? curRing;
private bool hasPinPullReset = true;
private void Awake()
{
pinPullDuration = AccessibilityOptionsBase.pinnedGrenadePinPullDuration.Value;
}
public void UpdateInteraction_Hooked(PinnedGrenade self, FVRViveHand hand)
{
if ((hand.IsInStreamlinedMode && hand.Input.BYButtonDown) || (!hand.IsInStreamlinedMode && hand.Input.TouchpadDown))
{
for (int i = 0; i < self.m_rings.Count; i++)
{
if (!self.m_rings[i].HasPinDetached() && !((FVRInteractiveObject)self.m_rings[i]).IsHeld && hasPinPullReset)
{
curRing = self.m_rings[i];
pinPullDistance = curRing.m_posMax - curRing.m_posMin;
pinBeingPulled = true;
break;
}
}
}
if (((hand.IsInStreamlinedMode && hand.Input.BYButtonUp) || (!hand.IsInStreamlinedMode && hand.Input.TouchpadUp)) && (Object)(object)curRing != (Object)null)
{
hasPinPullReset = true;
pinBeingPulled = false;
curRing = null;
}
if (pinBeingPulled)
{
RemoteUpdatePinPos();
}
if (hand.Input.TriggerFloat >= 0.8f && ((FVRInteractiveObject)self).m_hasTriggeredUpSinceBegin)
{
((FVRInteractiveObject)self).m_hasTriggeredUpSinceBegin = false;
if ((Object)(object)self.FuseCylinder != (Object)null && !self.m_isPinPulled)
{
OneHandedIncreaseFuseSetting(self);
}
}
}
private void OneHandedIncreaseFuseSetting(PinnedGrenade grenade)
{
if (grenade.m_fuseCylinderSetting < 4)
{
grenade.m_fuseCylinderSetting++;
}
else
{
grenade.m_fuseCylinderSetting = 0;
}
grenade.m_fuseTarYRotation = (float)grenade.m_fuseCylinderSetting * 24f - 48f;
}
private void RemoteUpdatePinPos()
{
//IL_00b2: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: 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_0135: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)curRing != (Object)null) || curRing.HasPinDetached())
{
return;
}
if (curRing.UsesSwapPin && !curRing.m_hasSwapped)
{
curRing.m_hasSwapped = true;
((Component)curRing.Pin).GetComponent<MeshFilter>().mesh = curRing.SwapPin;
}
if (pinPullDuration > 0f)
{
PinnedGrenadeRing? obj = curRing;
obj.m_posCurrent += pinPullDistance * (Time.deltaTime / pinPullDuration);
((Component)curRing).transform.localPosition = new Vector3(((Component)curRing).transform.localPosition.x, ((Component)curRing).transform.localPosition.y, curRing.m_posCurrent);
((Component)curRing.Pin).transform.localPosition = new Vector3(((Component)curRing.Pin).transform.localPosition.x, ((Component)curRing.Pin).transform.localPosition.y, curRing.m_posCurrent);
if (curRing.m_posCurrent > curRing.m_posMax)
{
RemoteDetachPin(curRing);
}
}
else
{
RemoteDetachPin(curRing);
}
}
private void RemoteDetachPin(PinnedGrenadeRing _ring)
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
if (!_ring.m_hasPinDetached)
{
pinBeingPulled = false;
hasPinPullReset = false;
_ring.m_hasPinDetached = true;
_ring.Pin.RootRigidbody = ((Component)_ring.Pin).gameObject.AddComponent<Rigidbody>();
_ring.Pin.RootRigidbody.mass = 0.02f;
((Component)_ring).transform.SetParent(((Component)_ring.Pin).transform);
((Behaviour)_ring.Pin).enabled = true;
SM.PlayCoreSound((FVRPooledAudioType)10, _ring.G.AudEvent_Pinpull, ((Component)_ring.G).transform.position);
((Component)_ring).GetComponent<Collider>().enabled = false;
((Behaviour)_ring).enabled = false;
}
}
}
internal class OneHandedWristMenu : MonoBehaviour
{
private GameObject pointerPrefab;
private Material pointerMat;
private float verticalPointerOffset;
private Color pointerColor;
private float pointerScale;
private FVRViveHand curHand;
private IEnumerator pointerCoroutine;
private GameObject spawnedPointer;
private FVRPointableButton curPointable;
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//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)
FVRWristMenu2.ActivateOnHand += new hook_ActivateOnHand(FVRWristMenu2_ActivateOnHand);
FVRWristMenu2.Deactivate += new hook_Deactivate(FVRWristMenu2_Deactivate);
verticalPointerOffset = AccessibilityOptionsBase.verticalPointerOffset.Value;
pointerColor = AccessibilityOptionsBase.pointerColor.Value;
pointerScale = AccessibilityOptionsBase.pointerScale.Value;
pointerPrefab = AccessibilityOptionsBase.pointerAssetBundle.LoadAsset<GameObject>("WristMenuPointer");
pointerMat = ((Renderer)pointerPrefab.GetComponent<MeshRenderer>()).material;
pointerCoroutine = PointWithHead();
}
private void FVRWristMenu2_ActivateOnHand(orig_ActivateOnHand orig, FVRWristMenu2 self, FVRViveHand hand)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
Vector3 localPosition = ((Component)hand).transform.localPosition;
if (!(((Vector3)(ref localPosition)).magnitude < 0.01f))
{
orig.Invoke(self, hand);
curHand = hand;
if ((Object)(object)spawnedPointer == (Object)null)
{
spawnedPointer = Object.Instantiate<GameObject>(pointerPrefab);
spawnedPointer.transform.localScale = new Vector3(pointerScale, pointerScale, pointerScale);
pointerMat.color = pointerColor;
}
((MonoBehaviour)this).StartCoroutine(pointerCoroutine);
}
}
private void FVRWristMenu2_Deactivate(orig_Deactivate orig, FVRWristMenu2 self)
{
orig.Invoke(self);
((MonoBehaviour)this).StopCoroutine(pointerCoroutine);
if ((Object)(object)curPointable != (Object)null && (Object)(object)curHand != (Object)null)
{
((FVRPointable)curPointable).EndPoint(curHand);
}
if ((Object)(object)spawnedPointer != (Object)null)
{
Object.Destroy((Object)(object)spawnedPointer);
}
}
private IEnumerator PointWithHead()
{
RaycastHit val2 = default(RaycastHit);
while (true)
{
_ = GM.CurrentPlayerBody.headRotationFiltered;
Vector3 val = Quaternion.AngleAxis(verticalPointerOffset * -1f, GM.CurrentPlayerBody.Head.right) * GM.CurrentPlayerBody.Head.forward;
if (Physics.Raycast(GM.CurrentPlayerBody.headPositionFiltered, val, ref val2, 1f, LayerMask.op_Implicit(curHand.PointingLayerMask), (QueryTriggerInteraction)2))
{
if ((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<FVRWristMenu2>() != (Object)null)
{
spawnedPointer.SetActive(true);
spawnedPointer.transform.position = ((RaycastHit)(ref val2)).point;
if ((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponent<FVRPointableButton>() != (Object)null)
{
FVRPointableButton component = ((Component)((RaycastHit)(ref val2)).collider).GetComponent<FVRPointableButton>();
if ((Object)(object)curPointable != (Object)null && (Object)(object)component != (Object)(object)curPointable)
{
((FVRPointable)curPointable).EndPoint(curHand);
}
curPointable = component;
((FVRPointable)curPointable).OnPoint(curHand);
}
}
}
else
{
if ((Object)(object)curPointable != (Object)null)
{
((FVRPointable)curPointable).EndPoint(curHand);
}
spawnedPointer.SetActive(false);
}
yield return null;
}
}
}
internal static class PluginInfo
{
internal const string NAME = "Accessibility Options";
internal const string GUID = "okkim.accessibilityoptions";
internal const string VERSION = "1.0.0";
}
public static class ReflectiveEnumerator
{
static ReflectiveEnumerator()
{
}
public static IEnumerable<T> GetEnumerableOfType<T>(params object[] constructorArgs) where T : LockableWeapon, IComparable<T>
{
List<T> list = new List<T>();
foreach (Type item in from myType in Assembly.GetAssembly(typeof(T)).GetTypes()
where myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))
select myType)
{
list.Add((T)Activator.CreateInstance(item, constructorArgs));
}
list.Sort();
return list;
}
}
public abstract class LockableWeapon<T> : LockableWeapon where T : MonoBehaviour
{
protected T Target { get; private set; }
protected virtual void Awake()
{
Target = ((Component)this).GetComponent<T>();
thisFirearm = ((Component)this).GetComponent<FVRFireArm>();
chambers = thisFirearm.GetChambers();
durationForPoseLock = WeaponPoseLock.instance.triggerDuration;
}
private void OnDestroy()
{
if ((Object)(object)WeaponPoseLock.instance.currentlyLockedWeapon == (Object)(object)this)
{
UnlockWeapon();
}
}
}
public abstract class LockableWeapon : MonoBehaviour
{
private enum WeaponLockState
{
Unlocked,
Locking,
Locked
}
public FVRFireArm thisFirearm;
protected List<FVRFireArmChamber> chambers;
public float durationForPoseLock;
private float curTriggerDuration;
private bool isValidForPoseLock;
private WeaponLockState lockState;
public abstract bool CanFire();
public virtual bool IsBoltMoving()
{
return false;
}
public void CheckChamberTriggerAmt(bool _isFiring)
{
FVRViveHand hand = ((FVRInteractiveObject)thisFirearm).m_hand;
if (hand != null && hand.Input.TriggerFloat >= 0.6f)
{
if (!_isFiring)
{
isValidForPoseLock = true;
return;
}
bool flag = true;
foreach (FVRFireArmChamber chamber in chambers)
{
if (chamber.IsFull && !chamber.IsSpent)
{
flag = false;
break;
}
}
if (flag)
{
isValidForPoseLock = true;
return;
}
}
isValidForPoseLock = false;
}
private void Update()
{
//IL_0157: 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)
switch (lockState)
{
case WeaponLockState.Unlocked:
curTriggerDuration = 0f;
if (isValidForPoseLock)
{
lockState = WeaponLockState.Locking;
}
break;
case WeaponLockState.Locking:
if (isValidForPoseLock)
{
FVRViveHand hand = ((FVRInteractiveObject)thisFirearm).m_hand;
if ((hand == null || !(hand.Input.TriggerFloat < 0.6f)) && !IsBoltMoving())
{
curTriggerDuration += Time.deltaTime;
if (curTriggerDuration > durationForPoseLock)
{
lockState = WeaponLockState.Locked;
}
break;
}
}
lockState = WeaponLockState.Unlocked;
break;
case WeaponLockState.Locked:
if ((Object)(object)WeaponPoseLock.instance.currentlyLockedWeapon != (Object)null && (Object)(object)WeaponPoseLock.instance.currentlyLockedWeapon != (Object)(object)this)
{
WeaponPoseLock.instance.currentlyLockedWeapon.UnlockWeapon();
}
if ((Object)(object)WeaponPoseLock.instance.currentlyLockedWeapon == (Object)null)
{
LockWeapon();
break;
}
if (!((FVRPhysicalObject)thisFirearm).RootRigidbody.isKinematic)
{
((FVRPhysicalObject)thisFirearm).RootRigidbody.isKinematic = true;
}
if ((Object)(object)((Component)thisFirearm).transform.parent != (Object)null)
{
((Component)thisFirearm).transform.SetParent((Transform)null);
}
((Component)thisFirearm).gameObject.transform.position = WeaponPoseLock.instance.lockedWeaponProxy.transform.position;
((Component)thisFirearm).gameObject.transform.rotation = WeaponPoseLock.instance.lockedWeaponProxy.transform.rotation;
break;
}
}
public virtual void LockWeapon()
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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)
((FVRInteractiveObject)thisFirearm).m_hand.Buzz(((FVRInteractiveObject)thisFirearm).m_hand.Buzzer.Buzz_BeginInteraction);
WeaponPoseLock.instance.currentlyLockedWeapon = this;
((FVRPhysicalObject)thisFirearm).IsKinematicLocked = true;
((FVRPhysicalObject)thisFirearm).RootRigidbody.isKinematic = true;
WeaponPoseLock.instance.lockedWeaponSize = ((FVRPhysicalObject)thisFirearm).Size;
((FVRPhysicalObject)thisFirearm).Size = (FVRPhysicalObjectSize)5;
WeaponPoseLock.instance.lockedWeaponProxy.transform.position = ((Component)thisFirearm).transform.position;
WeaponPoseLock.instance.lockedWeaponProxy.transform.rotation = ((Component)thisFirearm).transform.rotation;
}
public virtual void UnlockWeapon()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
isValidForPoseLock = false;
WeaponPoseLock.instance.currentlyLockedWeapon = null;
lockState = WeaponLockState.Unlocked;
((FVRPhysicalObject)thisFirearm).IsKinematicLocked = false;
((FVRPhysicalObject)thisFirearm).RootRigidbody.isKinematic = false;
((FVRPhysicalObject)thisFirearm).Size = WeaponPoseLock.instance.lockedWeaponSize;
}
}
public class LockableBAP : LockableWeapon<BAP>
{
private BAP BAP;
protected override void Awake()
{
base.Awake();
ref BAP bAP = ref BAP;
FVRFireArm obj = thisFirearm;
bAP = (BAP)(object)((obj is BAP) ? obj : null);
}
public override bool CanFire()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)BAP != (Object)null && (int)BAP.FireSelector_Modes[BAP.m_fireSelectorMode].ModeType == 0)
{
return false;
}
return true;
}
}
public class LockableBoltActionRifle : LockableWeapon<BoltActionRifle>
{
private BoltActionRifle BAR;
protected override void Awake()
{
base.Awake();
ref BoltActionRifle bAR = ref BAR;
FVRFireArm obj = thisFirearm;
bAR = (BoltActionRifle)(object)((obj is BoltActionRifle) ? obj : null);
}
public override bool CanFire()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)BAR != (Object)null && (int)BAR.FireSelector_Modes[BAR.m_fireSelectorMode].ModeType == 0)
{
return false;
}
return true;
}
}
public class LockableBreakActionWeapon : LockableWeapon<BreakActionWeapon>
{
private BreakActionWeapon BAW;
protected override void Awake()
{
base.Awake();
ref BreakActionWeapon bAW = ref BAW;
FVRFireArm obj = thisFirearm;
bAW = (BreakActionWeapon)(object)((obj is BreakActionWeapon) ? obj : null);
}
public override bool CanFire()
{
if ((Object)(object)BAW != (Object)null && (!BAW.IsLatched || !BAW.HasTriggerReset))
{
return false;
}
return true;
}
}
public class LockableClosedBoltWeapon : LockableWeapon<ClosedBoltWeapon>
{
private ClosedBoltWeapon CBW;
private FireSelectorModeType fireMode;
protected override void Awake()
{
base.Awake();
ref ClosedBoltWeapon cBW = ref CBW;
FVRFireArm obj = thisFirearm;
cBW = (ClosedBoltWeapon)(object)((obj is ClosedBoltWeapon) ? obj : null);
}
public override bool CanFire()
{
//IL_0026: 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_0031: 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)
//IL_0041: Invalid comparison between Unknown and I4
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Invalid comparison between Unknown and I4
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Invalid comparison between Unknown and I4
if ((Object)(object)CBW != (Object)null)
{
fireMode = CBW.FireSelector_Modes[CBW.m_fireSelectorMode].ModeType;
if ((int)fireMode == 0)
{
return false;
}
if ((int)fireMode == 1 && !CBW.m_hasTriggerReset)
{
return false;
}
if (((int)fireMode == 2 && CBW.m_CamBurst == 0) || (int)fireMode == 4)
{
return false;
}
}
return true;
}
public override bool IsBoltMoving()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Invalid comparison between Unknown and I4
if ((int)CBW.Bolt.CurPos == 0 || (int)CBW.Bolt.CurPos == 2)
{
return false;
}
return true;
}
}
public class LockableDerringer : LockableWeapon<Derringer>
{
private Derringer derringer;
protected override void Awake()
{
base.Awake();
ref Derringer reference = ref derringer;
FVRFireArm obj = thisFirearm;
reference = (Derringer)(object)((obj is Derringer) ? obj : null);
}
public override bool CanFire()
{
//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)derringer != (Object)null && ((derringer.HasExternalHammer && !derringer.IsExternalHammerCocked()) || !derringer.m_hasTriggerReset || (int)derringer.GetHingeState() == 2))
{
return false;
}
return true;
}
}
public class LockableFlaregun : LockableWeapon<Flaregun>
{
private Flaregun FG;
protected override void Awake()
{
base.Awake();
ref Flaregun fG = ref FG;
FVRFireArm obj = thisFirearm;
fG = (Flaregun)(object)((obj is Flaregun) ? obj : null);
}
public override bool CanFire()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
if ((Object)(object)FG != (Object)null && (!FG.m_isHammerCocked || !FG.m_isTriggerReset || (int)FG.m_hingeState == 2))
{
return false;
}
return true;
}
}
public class LockableHandgun : LockableWeapon<Handgun>
{
private Handgun HG;
private FireSelectorModeType fireMode;
protected override void Awake()
{
base.Awake();
ref Handgun hG = ref HG;
FVRFireArm obj = thisFirearm;
hG = (Handgun)(object)((obj is Handgun) ? obj : null);
}
public override bool CanFire()
{
//IL_0026: 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_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Invalid comparison between Unknown and I4
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Invalid comparison between Unknown and I4
if ((Object)(object)HG != (Object)null)
{
fireMode = HG.FireSelectorModes[HG.m_fireSelectorMode].ModeType;
if ((int)fireMode == 3)
{
return false;
}
if ((int)fireMode == 1 && !HG.HasTriggerReset)
{
return false;
}
if ((int)fireMode == 4 && HG.m_CamBurst == 0)
{
return false;
}
}
return true;
}
public override bool IsBoltMoving()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Invalid comparison between Unknown and I4
if ((int)HG.Slide.CurPos == 0 || (int)HG.Slide.CurPos == 2)
{
return false;
}
return true;
}
}
public class LockableLeverActionFirearm : LockableWeapon<LeverActionFirearm>
{
private LeverActionFirearm LAF;
protected override void Awake()
{
base.Awake();
ref LeverActionFirearm lAF = ref LAF;
FVRFireArm obj = thisFirearm;
lAF = (LeverActionFirearm)(object)((obj is LeverActionFirearm) ? obj : null);
}
public override bool CanFire()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Invalid comparison between Unknown and I4
if ((Object)(object)LAF != (Object)null && (LAF.m_isSpinning || (int)LAF.m_curLeverPos != 2 || !LAF.m_isHammerCocked || (LAF.UsesSecondChamber && !LAF.m_isHammerCocked2)))
{
return false;
}
return true;
}
public override void LockWeapon()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
base.LockWeapon();
LAF.m_curLeverPos = (ZPos)0;
LAF.m_tarLeverRot = LAF.LeverAngleRange.x;
}
public override void UnlockWeapon()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
base.UnlockWeapon();
LAF.m_curLeverPos = (ZPos)2;
LAF.m_tarLeverRot = LAF.LeverAngleRange.y;
}
}
public class LockableOpenBoltReceiver : LockableWeapon<OpenBoltReceiver>
{
private OpenBoltReceiver OBR;
private FireSelectorModeType fireMode;
protected override void Awake()
{
base.Awake();
ref OpenBoltReceiver oBR = ref OBR;
FVRFireArm obj = thisFirearm;
oBR = (OpenBoltReceiver)(object)((obj is OpenBoltReceiver) ? obj : null);
}
public override bool CanFire()
{
//IL_0026: 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_0031: 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)
//IL_0041: Invalid comparison between Unknown and I4
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Invalid comparison between Unknown and I4
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Invalid comparison between Unknown and I4
if ((Object)(object)OBR != (Object)null)
{
fireMode = OBR.FireSelector_Modes[OBR.m_fireSelectorMode].ModeType;
if ((int)fireMode == 0)
{
return false;
}
if ((int)fireMode == 1 && OBR.m_hasTriggerCycled)
{
return false;
}
if (((int)fireMode == 4 && OBR.m_CamBurst == 0) || (int)fireMode == 3)
{
return false;
}
}
return true;
}
public override bool IsBoltMoving()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Invalid comparison between Unknown and I4
if ((int)OBR.Bolt.CurPos == 0 || (int)OBR.Bolt.CurPos == 2)
{
return false;
}
return true;
}
}
public class LockableRevolver : LockableWeapon<Revolver>
{
private Revolver revolver;
protected override void Awake()
{
base.Awake();
ref Revolver reference = ref revolver;
FVRFireArm obj = thisFirearm;
reference = (Revolver)(object)((obj is Revolver) ? obj : null);
}
public override bool CanFire()
{
if ((Object)(object)revolver != (Object)null && (revolver.m_hasTriggerCycled || !revolver.isCylinderArmLocked))
{
return false;
}
return true;
}
}
public class LockableRevolvingShotgun : LockableWeapon<RevolvingShotgun>
{
private RevolvingShotgun RS;
private FireSelectorModeType fireMode;
protected override void Awake()
{
base.Awake();
ref RevolvingShotgun rS = ref RS;
FVRFireArm obj = thisFirearm;
rS = (RevolvingShotgun)(object)((obj is RevolvingShotgun) ? obj : null);
}
public override bool CanFire()
{
//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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Invalid comparison between Unknown and I4
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Invalid comparison between Unknown and I4
if ((Object)(object)RS != (Object)null)
{
fireMode = RS.FireSelector_Modes[RS.m_fireSelectorMode].ModeType;
if ((int)fireMode == 0)
{
return false;
}
if ((int)fireMode == 1 && RS.m_hasTriggerCycled)
{
return false;
}
if ((int)fireMode == 2 && RS.m_hasTriggerCycled && (!RS.Chambers[RS.CurChamber].IsFull || RS.Chambers[RS.CurChamber].IsSpent))
{
return false;
}
}
return true;
}
}
public class LockableRollingBlock : LockableWeapon<RollingBlock>
{
private RollingBlock RB;
protected override void Awake()
{
base.Awake();
ref RollingBlock rB = ref RB;
FVRFireArm obj = thisFirearm;
rB = (RollingBlock)(object)((obj is RollingBlock) ? obj : null);
}
public override bool CanFire()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
if ((Object)(object)RB != (Object)null && ((int)RB.m_state != 1 || !RB.Chamber.IsFull || RB.Chamber.IsSpent))
{
return false;
}
return true;
}
}
public class LockableSingleActionRevolver : LockableWeapon<SingleActionRevolver>
{
private SingleActionRevolver SAR;
protected override void Awake()
{
base.Awake();
ref SingleActionRevolver sAR = ref SAR;
FVRFireArm obj = thisFirearm;
sAR = (SingleActionRevolver)(object)((obj is SingleActionRevolver) ? obj : null);
}
public override bool CanFire()
{
if ((Object)(object)SAR != (Object)null && (!SAR.m_isHammerCocked || SAR.m_isStateToggled))
{
return false;
}
return true;
}
}
public class LockableTubeFedShotgun : LockableWeapon<TubeFedShotgun>
{
private TubeFedShotgun? TFS;
protected override void Awake()
{
base.Awake();
ref TubeFedShotgun? tFS = ref TFS;
FVRFireArm obj = thisFirearm;
tFS = (TubeFedShotgun?)(object)((obj is TubeFedShotgun) ? obj : null);
}
public override bool CanFire()
{
if ((Object)(object)TFS != (Object)null && TFS.HasSafety && TFS.IsSafetyEngaged)
{
return false;
}
return true;
}
public override bool IsBoltMoving()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_0032: Invalid comparison between Unknown and I4
if ((int)TFS.Mode == 0)
{
return false;
}
if ((int)TFS.Bolt.CurPos == 0 || (int)TFS.Bolt.CurPos == 2)
{
return false;
}
return true;
}
}
internal class WeaponPoseLock : MonoBehaviour
{
public static WeaponPoseLock instance;
public Dictionary<Type, Type> LockableWeaponDict = new Dictionary<Type, Type>();
public float triggerDuration;
public LockableWeapon currentlyLockedWeapon;
public FVRPhysicalObjectSize lockedWeaponSize;
public GameObject lockedWeaponProxy;
private void Awake()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
instance = this;
triggerDuration = AccessibilityOptionsBase.weaponPoseLockingTriggerDuration.Value;
GM.InitScene += new hook_InitScene(GM_InitScene);
FVRFireArm.Awake += new hook_Awake(FVRFireArm_Awake);
FVRFireArm.FVRUpdate += new hook_FVRUpdate(FVRFireArm_FVRUpdate);
FVRFireArm.BeginInteraction += new hook_BeginInteraction(FVRFireArm_BeginInteraction);
FVRQuickBeltSlot.MoveContentsInstant += new hook_MoveContentsInstant(FVRQuickBeltSlot_MoveContentsInstant);
FVRQuickBeltSlot.MoveContents += new hook_MoveContents(FVRQuickBeltSlot_MoveContents);
FVRQuickBeltSlot.MoveContentsCheap += new hook_MoveContentsCheap(FVRQuickBeltSlot_MoveContentsCheap);
LockableWeaponDict[typeof(BoltActionRifle)] = typeof(LockableBoltActionRifle);
LockableWeaponDict[typeof(TubeFedShotgun)] = typeof(LockableTubeFedShotgun);
LockableWeaponDict[typeof(ClosedBoltWeapon)] = typeof(LockableClosedBoltWeapon);
LockableWeaponDict[typeof(OpenBoltReceiver)] = typeof(LockableOpenBoltReceiver);
LockableWeaponDict[typeof(Handgun)] = typeof(LockableHandgun);
LockableWeaponDict[typeof(BAP)] = typeof(LockableBAP);
LockableWeaponDict[typeof(Revolver)] = typeof(LockableRevolver);
LockableWeaponDict[typeof(SingleActionRevolver)] = typeof(LockableSingleActionRevolver);
LockableWeaponDict[typeof(Flaregun)] = typeof(LockableFlaregun);
LockableWeaponDict[typeof(BreakActionWeapon)] = typeof(LockableBreakActionWeapon);
LockableWeaponDict[typeof(Derringer)] = typeof(LockableDerringer);
LockableWeaponDict[typeof(RevolvingShotgun)] = typeof(LockableRevolvingShotgun);
LockableWeaponDict[typeof(RollingBlock)] = typeof(LockableRollingBlock);
LockableWeaponDict[typeof(LeverActionFirearm)] = typeof(LockableLeverActionFirearm);
}
private void GM_InitScene(orig_InitScene orig, GM self)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
orig.Invoke(self);
lockedWeaponProxy = Object.Instantiate<GameObject>(new GameObject(), ((Component)GM.CurrentPlayerBody).gameObject.transform);
((Object)lockedWeaponProxy).name = "lockedWeaponProxy";
GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
}
private void FVRFireArm_Awake(orig_Awake orig, FVRFireArm self)
{
orig.Invoke(self);
LockableWeaponDict.TryGetValue(((object)self).GetType(), out Type value);
if ((object)value != null)
{
_ = (LockableWeapon)(object)((Component)self).gameObject.AddComponent(value);
}
}
private void FVRFireArm_BeginInteraction(orig_BeginInteraction orig, FVRFireArm self, FVRViveHand hand)
{
orig.Invoke(self, hand);
if ((Object)(object)currentlyLockedWeapon != (Object)null)
{
LockableWeapon component = ((Component)self).gameObject.GetComponent<LockableWeapon>();
if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)currentlyLockedWeapon && (!((FVRPhysicalObject)component.thisFirearm).IsAltHeld || !((Object)(object)((FVRInteractiveObject)component.thisFirearm).m_hand.OtherHand.m_currentInteractable != (Object)(object)component.thisFirearm)))
{
component.UnlockWeapon();
}
}
}
private void FVRFireArm_FVRUpdate(orig_FVRUpdate orig, FVRFireArm self)
{
orig.Invoke(self);
if ((Object)(object)((FVRInteractiveObject)self).m_hand != (Object)null && !((FVRPhysicalObject)self).IsAltHeld)
{
LockableWeapon component = ((Component)self).GetComponent<LockableWeapon>();
if ((Object)(object)component != (Object)null)
{
component.CheckChamberTriggerAmt(component.CanFire());
}
}
}
private void OnShotFired(FVRFireArm _firearm)
{
if ((Object)(object)currentlyLockedWeapon != (Object)null && (Object)(object)_firearm == (Object)(object)currentlyLockedWeapon.thisFirearm)
{
currentlyLockedWeapon.UnlockWeapon();
}
}
private void FVRQuickBeltSlot_MoveContentsInstant(orig_MoveContentsInstant orig, FVRQuickBeltSlot self, Vector3 dir)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if (!IsQBWeaponLocked(self))
{
orig.Invoke(self, dir);
}
else
{
Debug.Log((object)"Blocked MovecontentsInstant");
}
}
private void FVRQuickBeltSlot_MoveContents(orig_MoveContents orig, FVRQuickBeltSlot self, Vector3 dir)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if (!IsQBWeaponLocked(self))
{
orig.Invoke(self, dir);
}
else
{
Debug.Log((object)"Blocked Movecontents");
}
}
private void FVRQuickBeltSlot_MoveContentsCheap(orig_MoveContentsCheap orig, FVRQuickBeltSlot self, Vector3 dir)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
if (!IsQBWeaponLocked(self))
{
orig.Invoke(self, dir);
}
else
{
Debug.Log((object)"Blocked MovecontentsCheap");
}
}
private bool IsQBWeaponLocked(FVRQuickBeltSlot slot)
{
if ((Object)(object)slot.CurObject != (Object)null && (Object)(object)((Component)slot.CurObject).GetComponent<LockableWeapon>() != (Object)null && (Object)(object)currentlyLockedWeapon == (Object)(object)((Component)slot).GetComponent<LockableWeapon>())
{
Debug.Log((object)"Blocked locked weapon from holstering");
return true;
}
return false;
}
}
}