using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FistVR;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HK_VP70_Stock")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HK_VP70_Stock")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f15e12b7-d3db-48bd-8f44-76a9f8abf06c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Cityrobo;
public class HK_VP70_Stock_Interface : AttachableStock
{
public override void OnAttach()
{
((AttachableStock)this).OnAttach();
(((FVRFireArmAttachmentInterface)this).Attachment as HK_VP70_Stock).AddBurst();
}
public override void OnDetach()
{
((AttachableStock)this).OnDetach();
(((FVRFireArmAttachmentInterface)this).Attachment as HK_VP70_Stock).RemoveBurst();
}
}
public class HK_VP70_Stock : FVRFireArmAttachment
{
[Header("Stock Config")]
public Transform FireSelector;
public float ModeSingle;
public float ModeBurst;
public int BurstAmount = 3;
public Transform StockLatch;
public float LatchUnheld;
public float LatchHeld;
public Transform StockCap;
public AR15HandleSightFlipper SightFlipper;
public FVRQuickBeltSlot QBSlot;
private Handgun _handgun;
private FireSelectorMode[] _originalHandgunFireModes;
private bool _handgunHadFireSelectorButton;
public override bool CanDetach()
{
if ((Object)(object)_handgun != (Object)null && _handgun.FireSelectorModeIndex == 1)
{
return false;
}
return ((FVRFireArmAttachment)this).CanDetach();
}
public void AddBurst()
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
ref Handgun handgun = ref _handgun;
FVRPhysicalObject myObject = base.curMount.GetRootMount().MyObject;
handgun = (Handgun)(object)((myObject is Handgun) ? myObject : null);
if ((Object)(object)_handgun != (Object)null)
{
_originalHandgunFireModes = _handgun.FireSelectorModes;
_handgunHadFireSelectorButton = _handgun.HasFireSelector;
if (!_handgunHadFireSelectorButton)
{
_handgun.HasFireSelector = true;
_handgun.FireSelector = new GameObject("FireSelector").transform;
}
FireSelectorMode val = new FireSelectorMode();
val.ModeType = (FireSelectorModeType)4;
val.BurstAmount = BurstAmount;
_handgun.FireSelectorModes = _handgun.FireSelectorModes.Concat((IEnumerable<FireSelectorMode>)(object)new FireSelectorMode[1] { val }).ToArray();
}
}
public void RemoveBurst()
{
if ((Object)(object)_handgun != (Object)null)
{
_handgun.m_fireSelectorMode = _originalHandgunFireModes.Length - 1;
_handgun.FireSelectorModes = _originalHandgunFireModes;
if (!_handgunHadFireSelectorButton)
{
Object.Destroy((Object)(object)((Component)_handgun.FireSelector).gameObject);
_handgun.HasFireSelector = false;
}
}
}
public override void FVRUpdate()
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
((FVRPhysicalObject)this).FVRUpdate();
if ((Object)(object)_handgun != (Object)null)
{
switch (_handgun.FireSelectorModeIndex)
{
case 0:
FireSelector.localRotation = Quaternion.Euler(ModeSingle, 0f, 0f);
break;
case 1:
FireSelector.localRotation = Quaternion.Euler(ModeBurst, 0f, 0f);
break;
}
}
if (((FVRInteractiveObject)this).IsHeld)
{
StockLatch.localPosition = new Vector3(StockLatch.localPosition.x, StockLatch.localPosition.y, LatchHeld);
}
else if (((FVRInteractiveObject)base.AttachmentInterface).IsHeld && ((FVRInteractiveObject)base.AttachmentInterface).m_hand.Input.TouchpadPressed && Vector2.Angle(((FVRInteractiveObject)base.AttachmentInterface).m_hand.Input.TouchpadAxes, Vector2.down) < 45f)
{
StockLatch.localPosition = new Vector3(StockLatch.localPosition.x, StockLatch.localPosition.y, LatchHeld);
}
else
{
StockLatch.localPosition = new Vector3(StockLatch.localPosition.x, StockLatch.localPosition.y, LatchUnheld);
}
if ((Object)(object)QBSlot.HeldObject != (Object)null && (Object)(object)((FVRPhysicalObject)this).QuickbeltSlot != (Object)null)
{
((Component)this).gameObject.layer = LayerMask.NameToLayer("NoCol");
((Component)QBSlot).gameObject.layer = LayerMask.NameToLayer("Interactable");
((FVRPhysicalObject)this).QuickbeltSlot.IsSelectable = false;
}
else if ((Object)(object)QBSlot.HeldObject == (Object)null && (Object)(object)((FVRPhysicalObject)this).QuickbeltSlot != (Object)null)
{
((Component)this).gameObject.layer = LayerMask.NameToLayer("Interactable");
((Component)QBSlot).gameObject.layer = LayerMask.NameToLayer("Interactable");
((FVRPhysicalObject)this).QuickbeltSlot.IsSelectable = true;
}
else
{
((Component)this).gameObject.layer = LayerMask.NameToLayer("Interactable");
}
if (!SightFlipper.m_isLargeAperture)
{
QBSlot.IsSelectable = true;
if ((Object)(object)QBSlot.HeldObject != (Object)null)
{
FVRInteractiveObject heldObject = QBSlot.HeldObject;
Handgun val = (Handgun)(object)((heldObject is Handgun) ? heldObject : null);
if (val != null && ((Component)val.Slide).gameObject.layer != LayerMask.NameToLayer("Interactable"))
{
((Component)val.Slide).gameObject.layer = LayerMask.NameToLayer("Interactable");
}
}
return;
}
QBSlot.IsSelectable = false;
if ((Object)(object)QBSlot.HeldObject != (Object)null)
{
FVRInteractiveObject heldObject2 = QBSlot.HeldObject;
Handgun val2 = (Handgun)(object)((heldObject2 is Handgun) ? heldObject2 : null);
if (val2 != null && ((Component)val2.Slide).gameObject.layer != LayerMask.NameToLayer("NoCol"))
{
((Component)val2.Slide).gameObject.layer = LayerMask.NameToLayer("NoCol");
}
}
}
}
[BepInPlugin("h3vr.cityrobo.HK_VP70_Stock", "Heckler&Koch VP70 Script", "1.0.1")]
internal class HK_VP70_Stock_BepInEx : BaseUnityPlugin
{
private HK_VP70_Stock_BepInEx()
{
}
}