using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OpenScripts2;
using OtherLoader;
using UnityEngine;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
public class ForeMagRelease : UniversalAdvancedMagazineGrabTrigger
{
[Header("ForeMagRelease Config")]
public bool EjectMainMagOnSecondaryRelease = true;
private bool wasSecondaryMagPresent = true;
public override void UpdateInteraction(FVRViveHand hand)
{
((UniversalAdvancedMagazineGrabTrigger)this).UpdateInteraction(hand);
if (base.IsSecondarySlotGrab)
{
FVRFireArmMagazine magazine = base.FireArm.SecondaryMagazineSlots[base.SecondaryGrabSlot].Magazine;
if (wasSecondaryMagPresent && (Object)(object)magazine == (Object)null && EjectMainMagOnSecondaryRelease && (Object)(object)base.FireArm.Magazine != (Object)null)
{
base.FireArm.EjectMag(false);
}
wasSecondaryMagPresent = (Object)(object)magazine != (Object)null;
}
else
{
wasSecondaryMagPresent = true;
}
}
}
public class AmmoRecoilBlast : MonoBehaviour
{
public BallisticProjectile Projectile;
[Header("Recoil Settings")]
public float RecoilForce = 3.5f;
public bool UseHeadDirection = true;
private bool _hasBlasted = false;
private void Start()
{
if ((Object)(object)Projectile == (Object)null)
{
Projectile = ((Component)this).GetComponent<BallisticProjectile>();
}
((MonoBehaviour)this).StartCoroutine(WaitAndApplyRecoil());
}
private IEnumerator WaitAndApplyRecoil()
{
while ((Object)(object)Projectile != (Object)null && !Projectile.IsMoving())
{
yield return null;
}
ApplyRecoil();
}
private void ApplyRecoil()
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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 (_hasBlasted)
{
return;
}
_hasBlasted = true;
if (!((Object)(object)GM.CurrentMovementManager == (Object)null) && !((Object)(object)GM.CurrentPlayerBody == (Object)null))
{
Vector3 val = ((!((Object)(object)Projectile != (Object)null) || !((Object)(object)((Component)Projectile).transform != (Object)null)) ? ((Component)GM.CurrentPlayerBody).transform.forward : ((Component)Projectile).transform.forward);
val.y = 0f;
if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
{
val = -((Component)GM.CurrentPlayerBody).transform.forward;
}
((Vector3)(ref val)).Normalize();
((MonoBehaviour)this).StartCoroutine(ApplyRecoilSmoothly(-val, RecoilForce, 0.2f));
}
}
private IEnumerator ApplyRecoilSmoothly(Vector3 direction, float force, float duration)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
float elapsed = 0f;
while (elapsed < duration)
{
float stepForce = force * Time.deltaTime / duration;
GM.CurrentMovementManager.Blast(direction, stepForce, true);
elapsed += Time.deltaTime;
yield return null;
}
}
}
public class BoxMagBeltFix : MonoBehaviour
{
public FVRFireArm targetGun;
public GameObject boxMagazineObject;
private FVRFireArmMagazine boxMagazine;
private GameObject beltVisual;
private bool beltHidden = false;
private void Start()
{
if ((Object)(object)targetGun == (Object)null)
{
Debug.LogError((object)"BoxMagBeltFix: targetGun not assigned!");
((Behaviour)this).enabled = false;
return;
}
if ((Object)(object)targetGun.BeltDD != (Object)null)
{
beltVisual = ((Component)targetGun.BeltDD).gameObject;
}
if ((Object)(object)boxMagazineObject != (Object)null)
{
boxMagazine = boxMagazineObject.GetComponent<FVRFireArmMagazine>();
if ((Object)(object)boxMagazine == (Object)null)
{
Debug.LogError((object)"BoxMagBeltFix: boxMagazineObject does not have FVRFireArmMagazine component!");
((Behaviour)this).enabled = false;
return;
}
FVRFireArmBeltSegment[] componentsInChildren = ((Component)targetGun).GetComponentsInChildren<FVRFireArmBeltSegment>(true);
FVRFireArmBeltSegment[] array = componentsInChildren;
foreach (FVRFireArmBeltSegment val in array)
{
if ((Object)(object)targetGun.BeltDD == (Object)null || (Object)(object)((Component)val).gameObject != (Object)(object)((Component)targetGun.BeltDD).gameObject)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
}
else
{
Debug.LogError((object)"BoxMagBeltFix: boxMagazineObject not assigned!");
((Behaviour)this).enabled = false;
}
}
private void Update()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)boxMagazine == (Object)null || (Object)(object)targetGun == (Object)null)
{
return;
}
if ((Object)(object)targetGun.Magazine != (Object)(object)boxMagazine && (int)boxMagazine.State == 0)
{
targetGun.LoadMag(boxMagazine);
}
bool flag = (Object)(object)targetGun.Magazine == (Object)(object)boxMagazine;
if (flag && !beltHidden)
{
if ((Object)(object)beltVisual != (Object)null)
{
beltVisual.SetActive(false);
}
FVRFireArmBeltSegment[] componentsInChildren = ((Component)targetGun).GetComponentsInChildren<FVRFireArmBeltSegment>(true);
FVRFireArmBeltSegment[] array = componentsInChildren;
foreach (FVRFireArmBeltSegment val in array)
{
if ((Object)(object)((Component)val).gameObject != (Object)(object)((Component)targetGun.BeltDD).gameObject)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
beltHidden = true;
}
else if (!flag && beltHidden)
{
if ((Object)(object)beltVisual != (Object)null)
{
beltVisual.SetActive(true);
}
beltHidden = false;
}
}
}
public class ResidualBeltLinkHandler : MonoBehaviour
{
public enum Axis
{
X,
Y,
Z
}
[Header("References")]
public FVRFireArm Firearm;
public Transform FeedTraySpawnPoint;
public GameObject BeltLinkPrefab;
[Header("Feed Tray")]
public Transform FeedTray;
public float FeedTrayClearAngleMin = 55f;
public float FeedTrayClearAngleMax = 70f;
public Axis FeedTrayClearAxis = Axis.X;
[Header("Behavior")]
public float AutoCleanupTime = 10f;
public float ShakeClearAngularVelocity = 6f;
public float HandClearVelocity = 0.5f;
private GameObject _spawnedLink;
private Rigidbody _linkRB;
private bool _hasResidualLink;
private float _cleanupTimer;
private float _currentClearAngle;
private int _lastKnownRounds = -1;
private void Update()
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: 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_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Firearm != (Object)null && (Object)(object)Firearm.Magazine != (Object)null)
{
int numRounds = Firearm.Magazine.m_numRounds;
if (_lastKnownRounds > 0 && numRounds == 0 && !_hasResidualLink)
{
SpawnResidualLink();
}
_lastKnownRounds = numRounds;
}
if (!_hasResidualLink)
{
return;
}
_cleanupTimer += Time.deltaTime;
if ((Object)(object)_spawnedLink == (Object)null || _cleanupTimer > AutoCleanupTime)
{
ClearResidualLink();
return;
}
if ((Object)(object)Firearm != (Object)null && (Object)(object)((FVRPhysicalObject)Firearm).RootRigidbody != (Object)null)
{
Vector3 angularVelocity = ((FVRPhysicalObject)Firearm).RootRigidbody.angularVelocity;
if (((Vector3)(ref angularVelocity)).magnitude > ShakeClearAngularVelocity)
{
ClearResidualLink();
}
}
if ((Object)(object)FeedTray != (Object)null)
{
float num = 0f;
switch (FeedTrayClearAxis)
{
case Axis.X:
num = Mathf.Abs(Mathf.DeltaAngle(FeedTray.localEulerAngles.x, 0f));
break;
case Axis.Y:
num = Mathf.Abs(Mathf.DeltaAngle(FeedTray.localEulerAngles.y, 0f));
break;
case Axis.Z:
num = Mathf.Abs(Mathf.DeltaAngle(FeedTray.localEulerAngles.z, 0f));
break;
}
if (num > _currentClearAngle && num < 180f)
{
ClearResidualLink();
}
}
}
private void OnTriggerEnter(Collider other)
{
//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)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
if (_hasResidualLink)
{
FVRViveHand componentInParent = ((Component)other).GetComponentInParent<FVRViveHand>();
if ((Object)(object)componentInParent != (Object)null && (Object)(object)_linkRB != (Object)null)
{
Vector3 normalized = ((Vector3)(ref componentInParent.Input.VelLinearWorld)).normalized;
_linkRB.AddForce(normalized * 5f, (ForceMode)1);
_linkRB.AddTorque(Random.onUnitSphere * 2f, (ForceMode)1);
ClearResidualLinkPhysicsDelayed(5f);
}
}
}
public void SpawnResidualLink()
{
//IL_002f: 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_0093: Unknown result type (might be due to invalid IL or missing references)
if (!_hasResidualLink && !((Object)(object)BeltLinkPrefab == (Object)null))
{
_spawnedLink = Object.Instantiate<GameObject>(BeltLinkPrefab, FeedTraySpawnPoint.position, FeedTraySpawnPoint.rotation);
_linkRB = _spawnedLink.GetComponent<Rigidbody>();
if ((Object)(object)_linkRB != (Object)null && (Object)(object)((FVRPhysicalObject)Firearm).RootRigidbody != (Object)null)
{
_linkRB.velocity = ((FVRPhysicalObject)Firearm).RootRigidbody.velocity;
}
_cleanupTimer = 0f;
_hasResidualLink = true;
_currentClearAngle = Random.Range(FeedTrayClearAngleMin, FeedTrayClearAngleMax);
Firearm.HasBelt = false;
Firearm.ConnectedToBox = false;
}
}
private void ClearResidualLinkPhysicsDelayed(float delay)
{
if ((Object)(object)_spawnedLink != (Object)null)
{
Object.Destroy((Object)(object)_spawnedLink, delay);
}
_spawnedLink = null;
_linkRB = null;
_hasResidualLink = false;
_cleanupTimer = 0f;
}
private void ClearResidualLink()
{
if ((Object)(object)_spawnedLink != (Object)null)
{
Object.Destroy((Object)(object)_spawnedLink);
}
_spawnedLink = null;
_linkRB = null;
_hasResidualLink = false;
_cleanupTimer = 0f;
}
public bool CanAcceptNewBelt()
{
return !_hasResidualLink;
}
}
public class SAFA_BoltController : MonoBehaviour
{
private enum BoltState
{
semiAuto,
fullAuto,
safe,
uncocked
}
public OpenBoltReceiver weapon;
public int semiAuto;
public int fullAuto;
public Transform closedBoltSearPosition;
private OpenBoltReceiverBolt bolt;
private Transform sear;
private Vector3 uncockedPos;
private Transform openBoltSearPosition;
private string lastMessage = "";
private bool waitForShot;
private BoltState boltState;
public void Start()
{
//IL_0039: 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)
bolt = weapon.Bolt;
sear = weapon.Bolt.Point_Bolt_LockPoint;
uncockedPos = weapon.Bolt.Point_Bolt_Forward.localPosition;
openBoltSearPosition = sear;
}
public void Update()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0045: 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)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: 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)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
if (((Component)bolt).transform.localPosition == uncockedPos)
{
boltState = BoltState.uncocked;
}
else if (((Component)bolt).transform.localPosition == openBoltSearPosition.localPosition)
{
boltState = BoltState.fullAuto;
}
else if (((Component)bolt).transform.localPosition == closedBoltSearPosition.localPosition)
{
boltState = BoltState.semiAuto;
}
if (boltState == BoltState.uncocked && weapon.m_fireSelectorMode == fullAuto)
{
bolt.m_boltZ_lock = openBoltSearPosition.localPosition.z;
}
else if (boltState == BoltState.uncocked && weapon.m_fireSelectorMode == semiAuto)
{
bolt.m_boltZ_lock = closedBoltSearPosition.localPosition.z;
}
else if (boltState == BoltState.semiAuto && weapon.m_fireSelectorMode == fullAuto)
{
waitForShot = true;
}
else if (boltState == BoltState.fullAuto && weapon.m_fireSelectorMode == semiAuto)
{
bolt.m_boltZ_lock = closedBoltSearPosition.localPosition.z;
bolt.LastPos = (BoltPos)4;
bolt.CurPos = (BoltPos)3;
}
if (waitForShot && (int)bolt.LastPos == 0)
{
bolt.m_boltZ_lock = openBoltSearPosition.localPosition.z;
waitForShot = false;
}
}
public void DebugOnce(string message)
{
if (message != lastMessage)
{
Debug.Log((object)message);
}
lastMessage = message;
}
}
namespace Volks.KAC_LAMG;
[BepInPlugin("Volks.KAC_LAMG", "KAC_LAMG", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class KAC_LAMGPlugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Volks.KAC_LAMG");
OtherLoader.RegisterDirectLoad(BasePath, "Volks.KAC_LAMG", "", "", "kac_lamg", "");
}
}
public class ManualEjectorRod : FVRInteractiveObject
{
[Header("Ejector Rod Points")]
public Transform Point_Rod_Rest;
public Transform Point_Rod_FullyOut;
public Transform Point_Rod_Eject;
public Transform Point_Rod_Closed;
[Header("Spring Visual")]
public Transform SpringObject;
public Vector3 SpringScale_Rest = Vector3.one;
public Vector3 SpringScale_FullyOut = new Vector3(1f, 1f, 0.5f);
[Header("Revolver Reference")]
public SingleActionRevolver Revolver;
private float m_rodZ_rest;
private float m_rodZ_out;
private float m_rodZ_eject;
private float m_rodZ_closed;
private float m_rodZ_current;
private float m_rodZ_heldTarget;
private bool m_isHeld;
public override void Awake()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).Awake();
m_rodZ_rest = Point_Rod_Rest.localPosition.z;
m_rodZ_out = Point_Rod_FullyOut.localPosition.z;
m_rodZ_current = m_rodZ_rest;
m_rodZ_eject = Point_Rod_Eject.localPosition.z;
m_rodZ_closed = Point_Rod_Closed.localPosition.z;
}
public override void BeginInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).BeginInteraction(hand);
m_isHeld = true;
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_000f: 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_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: 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_013f: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).UpdateInteraction(hand);
Vector3 closestValidPoint = GetClosestValidPoint(Point_Rod_Rest.position, Point_Rod_FullyOut.position, ((HandInput)(ref hand.Input)).Pos);
m_rodZ_heldTarget = ((Component)this).transform.parent.InverseTransformPoint(closestValidPoint).z;
float num = Mathf.Min(m_rodZ_rest, m_rodZ_out);
float num2 = Mathf.Max(m_rodZ_rest, m_rodZ_out);
if ((Object)(object)Revolver != (Object)null && !Revolver.m_isStateToggled)
{
if (m_rodZ_rest < m_rodZ_out)
{
num2 = Mathf.Min(num2, m_rodZ_closed);
}
else
{
num = Mathf.Max(num, m_rodZ_closed);
}
}
m_rodZ_current = Mathf.Clamp(m_rodZ_heldTarget, num, num2);
Vector3 localPosition = ((Component)this).transform.localPosition;
localPosition.z = m_rodZ_current;
((Component)this).transform.localPosition = localPosition;
if ((Object)(object)SpringObject != (Object)null)
{
float num3 = Mathf.InverseLerp(m_rodZ_rest, m_rodZ_out, m_rodZ_current);
SpringObject.localScale = Vector3.Lerp(SpringScale_Rest, SpringScale_FullyOut, num3);
}
if ((Object)(object)Revolver != (Object)null && Revolver.m_isStateToggled && ((!(m_rodZ_rest < m_rodZ_out)) ? (m_rodZ_current <= m_rodZ_eject) : (m_rodZ_current >= m_rodZ_eject)))
{
Revolver.EjectPrevCylinder();
}
}
public override void EndInteraction(FVRViveHand hand)
{
//IL_0015: 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_002e: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).EndInteraction(hand);
m_isHeld = false;
Vector3 localPosition = ((Component)this).transform.localPosition;
localPosition.z = m_rodZ_rest;
((Component)this).transform.localPosition = localPosition;
}
private Vector3 GetClosestValidPoint(Vector3 a, Vector3 b, Vector3 point)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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_0012: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0039: 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)
Vector3 val = b - a;
float num = Vector3.Dot(point - a, ((Vector3)(ref val)).normalized) / ((Vector3)(ref val)).magnitude;
num = Mathf.Clamp01(num);
return a + val * num;
}
public void AnimateEject()
{
((MonoBehaviour)this).StartCoroutine(AnimateEjectRoutine());
}
private IEnumerator AnimateEjectRoutine()
{
float duration = 0.15f;
float t2 = 0f;
Vector3 localPos = ((Component)this).transform.localPosition;
float startZ = m_rodZ_rest;
float endZ = m_rodZ_eject;
while (t2 < duration)
{
t2 += Time.deltaTime;
float lerp = Mathf.Clamp01(t2 / duration);
localPos.z = Mathf.Lerp(startZ, endZ, lerp);
((Component)this).transform.localPosition = localPos;
yield return null;
}
localPos.z = endZ;
((Component)this).transform.localPosition = localPos;
if ((Object)(object)Revolver != (Object)null && Revolver.m_isStateToggled)
{
Revolver.EjectPrevCylinder();
}
t2 = 0f;
while (t2 < duration)
{
t2 += Time.deltaTime;
float lerp2 = Mathf.Clamp01(t2 / duration);
localPos.z = Mathf.Lerp(endZ, startZ, lerp2);
((Component)this).transform.localPosition = localPos;
yield return null;
}
localPos.z = startZ;
((Component)this).transform.localPosition = localPos;
}
}
public class SARotatingCylinder : FVRInteractiveObject
{
[Header("References")]
public SingleActionRevolver Revolver;
public ManualEjectorRod EjectorRod;
[Header("Rotation Settings")]
public float SnapSpeed = 12f;
public float RotationThreshold = 15f;
[Header("Cylinder Direction")]
public bool RotateClockwise = true;
private int m_lastChamber = -1;
private float m_lastAngle = 0f;
private bool m_isProxyHoldingRevolver = false;
private SingleActionRevolverCylinder Cylinder => (!((Object)(object)Revolver != (Object)null)) ? null : Revolver.Cylinder;
private int GetAccessibleChamber()
{
return (!Revolver.IsAccessTwoChambersBack) ? Revolver.PrevChamber : Revolver.PrevChamber2;
}
public override void BeginInteraction(FVRViveHand hand)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0039: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).BeginInteraction(hand);
if (!((Object)(object)Cylinder == (Object)null))
{
Vector3 val = ((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position;
m_lastAngle = Mathf.Atan2(val.y, val.x) * 57.29578f;
if ((Object)(object)Revolver != (Object)null && !((FVRInteractiveObject)Revolver).IsHeld)
{
((FVRInteractiveObject)Revolver).BeginInteraction(hand);
m_isProxyHoldingRevolver = true;
}
}
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: 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_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).UpdateInteraction(hand);
if ((Object)(object)Cylinder == (Object)null || (Object)(object)Revolver == (Object)null || !Revolver.m_isStateToggled)
{
return;
}
Vector3 val = ((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position;
float num = Mathf.Atan2(val.y, val.x) * 57.29578f;
float num2 = Mathf.DeltaAngle(m_lastAngle, num);
if (base.m_isHeld && Mathf.Abs(num2) > RotationThreshold)
{
int num3 = (RotateClockwise ? 1 : (-1));
int accessibleChamber = GetAccessibleChamber();
int curChamber = (accessibleChamber + num3 + Cylinder.NumChambers) % Cylinder.NumChambers;
Revolver.CurChamber = curChamber;
m_lastChamber = Revolver.CurChamber;
m_lastAngle = num;
((Component)this).transform.localRotation = Cylinder.GetLocalRotationFromCylinder(Revolver.CurChamber);
((FVRFireArm)Revolver).PlayAudioEvent((FirearmAudioEventType)15, 1f);
if (hand.Input.TriggerDown && (Object)(object)EjectorRod != (Object)null)
{
EjectorRod.AnimateEject();
}
}
else
{
int accessibleChamber2 = GetAccessibleChamber();
Revolver.CurChamber = accessibleChamber2;
Quaternion localRotationFromCylinder = Cylinder.GetLocalRotationFromCylinder(accessibleChamber2);
((Component)this).transform.localRotation = Quaternion.Slerp(((Component)this).transform.localRotation, localRotationFromCylinder, Time.deltaTime * SnapSpeed);
if (accessibleChamber2 != m_lastChamber)
{
m_lastChamber = accessibleChamber2;
}
}
}
public override void EndInteraction(FVRViveHand hand)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).EndInteraction(hand);
if ((Object)(object)Cylinder != (Object)null && (Object)(object)Revolver != (Object)null)
{
int accessibleChamber = GetAccessibleChamber();
Revolver.CurChamber = accessibleChamber;
((Component)this).transform.localRotation = Cylinder.GetLocalRotationFromCylinder(accessibleChamber);
}
if (m_isProxyHoldingRevolver && (Object)(object)Revolver != (Object)null && ((FVRInteractiveObject)Revolver).IsHeld)
{
((FVRInteractiveObject)Revolver).EndInteraction(hand);
m_isProxyHoldingRevolver = false;
}
}
}
public class EjectionFollow : MonoBehaviour
{
[Header("Open Bolt Weapon Config")]
public OpenBoltReceiver FireArm;
public Transform EjectionPortTransform;
public Vector3 LocalEjectionSpeed = new Vector3(1f, 0f, 0f);
public Vector3 LocalEjectionSpin = Vector3.zero;
private void LateUpdate()
{
//IL_0034: 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_004f: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)FireArm == (Object)null) && !((Object)(object)EjectionPortTransform == (Object)null))
{
FireArm.EjectionSpeed = EjectionPortTransform.right * LocalEjectionSpeed.x + EjectionPortTransform.up * LocalEjectionSpeed.y + EjectionPortTransform.forward * LocalEjectionSpeed.z;
FireArm.EjectionSpin = EjectionPortTransform.right * LocalEjectionSpin.x + EjectionPortTransform.up * LocalEjectionSpin.y + EjectionPortTransform.forward * LocalEjectionSpin.z;
}
}
}
public class OneHandedFiring : MonoBehaviour
{
public FVRFireArm Firearm;
public bool ForegripWhenShouldered = true;
public float StabilizeDistance = 0.22f;
private FVRAlternateGrip _dummyAltGrip;
private void Update()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Firearm == (Object)null)
{
return;
}
bool flag = false;
if ((Object)(object)Firearm.StockPos != (Object)null && (Object)(object)GM.CurrentPlayerBody != (Object)null && (Object)(object)GM.CurrentPlayerBody.Torso != (Object)null)
{
float num = Vector3.Distance(Firearm.StockPos.position, GM.CurrentPlayerBody.Torso.position);
flag = num < StabilizeDistance;
}
if (ForegripWhenShouldered && flag && (Object)(object)((FVRInteractiveObject)Firearm).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)Firearm).m_hand.OtherHand == (Object)null)
{
if ((Object)(object)((FVRPhysicalObject)Firearm).AltGrip == (Object)null || (Object)(object)((FVRPhysicalObject)Firearm).AltGrip == (Object)(object)_dummyAltGrip)
{
if ((Object)(object)_dummyAltGrip == (Object)null)
{
_dummyAltGrip = ((Component)Firearm).gameObject.AddComponent<FVRAlternateGrip>();
_dummyAltGrip.PrimaryObject = (FVRPhysicalObject)(object)Firearm;
((FVRInteractiveObject)_dummyAltGrip).m_hand = ((FVRInteractiveObject)Firearm).m_hand;
}
((FVRPhysicalObject)Firearm).AltGrip = _dummyAltGrip;
}
}
else if ((Object)(object)((FVRPhysicalObject)Firearm).AltGrip == (Object)(object)_dummyAltGrip)
{
Object.Destroy((Object)(object)_dummyAltGrip);
((FVRPhysicalObject)Firearm).AltGrip = null;
_dummyAltGrip = null;
}
}
}
public class StockExtension : MonoBehaviour
{
public FVRFireArm Firearm;
[Tooltip("How far forward the weapon moves when shouldered")]
public float PushDistance = 0.06f;
public float LerpSpeed = 10f;
private Vector3 _originalLocalPos;
private float _lerp;
private void Awake()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
_originalLocalPos = ((Component)this).transform.localPosition;
}
private void Update()
{
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: 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_008c: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: 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_00a4: 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)
//IL_00b1: 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)
if (!((Object)(object)Firearm == (Object)null))
{
bool flag = Firearm.IsShoulderStabilized();
_lerp = Mathf.MoveTowards(_lerp, (!flag) ? 0f : 1f, Time.deltaTime * LerpSpeed);
if ((Object)(object)((Component)this).transform.parent != (Object)null)
{
Vector3 val = ((Component)this).transform.parent.InverseTransformDirection(((Component)Firearm).transform.forward);
Vector3 val2 = _originalLocalPos + val * PushDistance;
((Component)this).transform.localPosition = Vector3.Lerp(_originalLocalPos, val2, _lerp);
}
else
{
Vector3 val3 = _originalLocalPos + Vector3.forward * PushDistance;
((Component)this).transform.localPosition = Vector3.Lerp(_originalLocalPos, val3, _lerp);
}
}
}
}