using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
public class AdvanceLaserSightComponent : LaserLightAttachment
{
public Transform KnobMesh;
public Vector3 RotationAxis = Vector3.up;
public List<float> CustomRotationAngles;
public GameObject ControlledGameObject;
public bool[] GameObjectEnableFlags;
public AudioEvent SettingSwapSound;
private int previousSettingsIndex = -1;
private void Start()
{
UpdateKnobRotationAndGameObject();
}
private void Update()
{
UpdateKnobRotationAndGameObject();
}
private void UpdateKnobRotationAndGameObject()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)KnobMesh != (Object)null && base.Settings.Count > 0 && CustomRotationAngles.Count == base.Settings.Count && GameObjectEnableFlags.Length == base.Settings.Count)
{
float num = CustomRotationAngles[base.SettingsIndex];
KnobMesh.localEulerAngles = RotationAxis * num;
UpdateControlledGameObject(base.SettingsIndex);
if (base.SettingsIndex != previousSettingsIndex)
{
PlaySettingSwapSound();
previousSettingsIndex = base.SettingsIndex;
}
}
}
private void UpdateControlledGameObject(int settingIndex)
{
if ((Object)(object)ControlledGameObject != (Object)null)
{
ControlledGameObject.SetActive(GameObjectEnableFlags[settingIndex]);
}
}
private void PlaySettingSwapSound()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (SettingSwapSound != null && SettingSwapSound.Clips.Count > 0)
{
AudioClip val = SettingSwapSound.Clips[Random.Range(0, SettingSwapSound.Clips.Count)];
AudioSource.PlayClipAtPoint(val, ((Component)this).transform.position, Random.Range(SettingSwapSound.VolumeRange.x, SettingSwapSound.VolumeRange.y));
}
}
}
public class DiceFaceDetector : MonoBehaviour
{
public ParticleSystem effect;
public Transform faceOneMarker;
public float checkThreshold = 0.9f;
public float cooldownTime = 2f;
private float lastTriggerTime = 0f;
private void Update()
{
//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)
if (!((Object)(object)faceOneMarker == (Object)null) && !(Time.time - lastTriggerTime < cooldownTime) && Vector3.Dot(faceOneMarker.up, Vector3.up) > checkThreshold)
{
TriggerEffect();
}
}
private void TriggerEffect()
{
if ((Object)(object)effect != (Object)null)
{
effect.Play();
lastTriggerTime = Time.time;
}
}
}
namespace JerryComponent
{
public class WristAttaching : MonoBehaviour
{
public FVRPhysicalObject mainObj;
public FVRInteractiveObject grabInterface;
public GameObject phys;
public Collider mainCol;
public Rigidbody mainRig;
public bool LeftOn = false;
public bool RightOn = false;
public GameObject posLeft;
public GameObject posRight;
public GameObject WatchGeo;
public GameObject posMiddle;
private void FixedUpdate()
{
//IL_0044: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
if (((FVRInteractiveObject)mainObj).m_isHeld)
{
if ((Object)(object)((FVRInteractiveObject)mainObj).m_hand == (Object)(object)GM.CurrentMovementManager.Hands[0])
{
if (Vector3.Distance(((Component)mainObj).gameObject.transform.position, GM.CurrentMovementManager.Hands[1].PalmTransform.position) < 0.1f)
{
LeftOn = false;
RightOn = true;
}
else if (Vector3.Distance(((Component)mainObj).gameObject.transform.position, GM.CurrentMovementManager.Hands[1].PalmTransform.position) >= 0.1f)
{
LeftOn = false;
RightOn = false;
}
}
if ((Object)(object)((FVRInteractiveObject)mainObj).m_hand == (Object)(object)GM.CurrentMovementManager.Hands[1])
{
if (Vector3.Distance(((Component)mainObj).gameObject.transform.position, GM.CurrentMovementManager.Hands[0].PalmTransform.position) < 0.1f)
{
LeftOn = true;
RightOn = false;
}
else if (Vector3.Distance(((Component)mainObj).gameObject.transform.position, GM.CurrentMovementManager.Hands[0].PalmTransform.position) >= 0.1f)
{
LeftOn = false;
RightOn = false;
}
}
}
if ((!RightOn && !LeftOn) || ((FVRInteractiveObject)mainObj).m_isHeld)
{
WatchGeo.transform.localPosition = posMiddle.transform.localPosition;
WatchGeo.transform.localRotation = posMiddle.transform.localRotation;
mainRig.isKinematic = false;
mainCol.enabled = true;
phys.SetActive(true);
}
if (grabInterface.m_isHeld)
{
WatchGeo.transform.localPosition = posMiddle.transform.localPosition;
WatchGeo.transform.localRotation = posMiddle.transform.localRotation;
mainRig.isKinematic = false;
mainCol.enabled = true;
FVRViveHand hand = grabInterface.m_hand;
grabInterface.ForceBreakInteraction();
((FVRInteractiveObject)mainObj).BeginInteraction(hand);
hand.ForceSetInteractable((FVRInteractiveObject)(object)mainObj);
phys.SetActive(true);
((Component)grabInterface).gameObject.SetActive(false);
}
}
private void Update()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
if (LeftOn && !RightOn && !((FVRInteractiveObject)mainObj).m_isHeld)
{
((Component)mainObj).gameObject.transform.position = ((Component)GM.CurrentMovementManager.Hands[0]).gameObject.transform.position;
((Component)mainObj).gameObject.transform.rotation = ((Component)GM.CurrentMovementManager.Hands[0]).gameObject.transform.rotation;
WatchGeo.transform.localPosition = posLeft.transform.localPosition;
WatchGeo.transform.localRotation = posLeft.transform.localRotation;
mainRig.isKinematic = true;
mainCol.enabled = false;
phys.SetActive(false);
((Component)grabInterface).gameObject.SetActive(true);
}
if (RightOn && !LeftOn && !((FVRInteractiveObject)mainObj).m_isHeld)
{
((Component)mainObj).gameObject.transform.position = ((Component)GM.CurrentMovementManager.Hands[1]).gameObject.transform.position;
((Component)mainObj).gameObject.transform.rotation = ((Component)GM.CurrentMovementManager.Hands[1]).gameObject.transform.rotation;
WatchGeo.transform.localPosition = posRight.transform.localPosition;
WatchGeo.transform.localRotation = posRight.transform.localRotation;
mainRig.isKinematic = true;
mainCol.enabled = false;
phys.SetActive(false);
((Component)grabInterface).gameObject.SetActive(true);
}
}
}
}
public class OpenBoltAltHandle : FVRInteractiveObject
{
public enum HandleRot
{
Down,
Mid,
Up
}
public enum HandleState
{
Forward,
Mid,
Rear
}
[Header("References")]
public OpenBoltReceiver Receiver;
public OpenBoltReceiverBolt Bolt;
[Header("Linear Travel")]
public Transform Point_Fore;
public Transform Point_Rear;
public float ForwardSpeed = 1.5f;
[Header("Rotation / Tilt")]
public Transform BoltHandleRoot;
public Transform BoltHandle;
public float MinRot = 0f;
public float MaxRot = 90f;
public float UnlockThreshold = 65f;
public float LockThreshold = 5f;
public float RotateSnapSpeed = 270f;
public HandleRot CurRot = HandleRot.Down;
public HandleRot LastRot = HandleRot.Down;
public HandleState CurState = HandleState.Forward;
public HandleState LastState = HandleState.Forward;
private float m_boltZ_forward;
private float m_boltZ_rear;
private float m_currentHandleZ;
private float m_rotAngle;
private bool m_hasReleasedBolt;
protected 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_0040: 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)
((FVRInteractiveObject)this).Awake();
m_boltZ_forward = Point_Fore.localPosition.z;
m_boltZ_rear = Point_Rear.localPosition.z;
m_currentHandleZ = BoltHandleRoot.localPosition.z;
m_rotAngle = MinRot;
m_hasReleasedBolt = true;
}
public override void UpdateInteraction(FVRViveHand hand)
{
//IL_002e: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).UpdateInteraction(hand);
UpdateRotationFromHand(hand);
if (CurRot == HandleRot.Up || CurState != 0)
{
Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(Point_Fore.position, Point_Rear.position, ((HandInput)(ref hand.Input)).Pos);
BoltHandleRoot.position = closestValidPoint;
m_currentHandleZ = BoltHandleRoot.localPosition.z;
}
UpdateHandleState();
UpdateRotState();
if (CurState != 0)
{
float num = Mathf.InverseLerp(m_boltZ_forward, m_boltZ_rear, m_currentHandleZ);
Bolt.ChargingHandleHeld(num);
}
else if (CurRot != 0)
{
Bolt.ChargingHandleHeld(0f);
}
if (CurState == HandleState.Forward && CurRot == HandleRot.Down)
{
if (!m_hasReleasedBolt)
{
Bolt.ChargingHandleReleased();
m_hasReleasedBolt = true;
}
}
else
{
m_hasReleasedBolt = false;
}
HandleRotAudioEvents();
HandleStateAudioEvents();
LastRot = CurRot;
LastState = CurState;
}
public override void EndInteraction(FVRViveHand hand)
{
((FVRInteractiveObject)this).EndInteraction(hand);
}
protected void FVRUpdate()
{
//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_0072: 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)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
((FVRInteractiveObject)this).FVRUpdate();
if (((FVRInteractiveObject)this).IsHeld)
{
return;
}
if (Mathf.Abs(m_currentHandleZ - m_boltZ_forward) > 0.001f)
{
m_currentHandleZ = Mathf.MoveTowards(m_currentHandleZ, m_boltZ_forward, Time.deltaTime * ForwardSpeed);
BoltHandleRoot.localPosition = new Vector3(BoltHandleRoot.localPosition.x, BoltHandleRoot.localPosition.y, m_currentHandleZ);
if (CurState != 0)
{
float num = Mathf.InverseLerp(m_boltZ_forward, m_boltZ_rear, m_currentHandleZ);
Bolt.ChargingHandleHeld(num);
}
}
if ((CurState == HandleState.Forward || CurState == HandleState.Mid) && m_rotAngle > MinRot + 0.5f)
{
m_rotAngle = Mathf.MoveTowards(m_rotAngle, MinRot, Time.deltaTime * RotateSnapSpeed);
BoltHandle.localEulerAngles = new Vector3(0f, 0f, m_rotAngle);
}
UpdateHandleState();
UpdateRotState();
if (CurState == HandleState.Forward && CurRot == HandleRot.Down && !m_hasReleasedBolt)
{
Bolt.ChargingHandleReleased();
m_hasReleasedBolt = true;
}
HandleStateAudioEvents();
HandleRotAudioEvents();
LastRot = CurRot;
LastState = CurState;
}
private void UpdateRotationFromHand(FVRViveHand hand)
{
//IL_0007: 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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_0050: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((HandInput)(ref hand.Input)).Pos - BoltHandle.position;
Vector3 val2 = Vector3.ProjectOnPlane(val, BoltHandleRoot.forward);
val = ((Vector3)(ref val2)).normalized;
Vector3 right = BoltHandleRoot.right;
float num = Mathf.Atan2(Vector3.Dot(BoltHandleRoot.forward, Vector3.Cross(right, val)), Vector3.Dot(right, val)) * 57.29578f;
m_rotAngle = Mathf.Clamp(num, MinRot, MaxRot);
BoltHandle.localEulerAngles = new Vector3(0f, 0f, m_rotAngle);
}
private void UpdateRotState()
{
if (m_rotAngle >= UnlockThreshold)
{
CurRot = HandleRot.Up;
}
else if (m_rotAngle <= MinRot + LockThreshold)
{
CurRot = HandleRot.Down;
}
else
{
CurRot = HandleRot.Mid;
}
}
private void UpdateHandleState()
{
if (Mathf.Abs(m_currentHandleZ - m_boltZ_forward) < 0.005f)
{
CurState = HandleState.Forward;
}
else if (Mathf.Abs(m_currentHandleZ - m_boltZ_rear) < 0.005f)
{
CurState = HandleState.Rear;
}
else
{
CurState = HandleState.Mid;
}
}
private void HandleRotAudioEvents()
{
if (!((Object)(object)Receiver == (Object)null))
{
if (CurRot == HandleRot.Up && LastRot != HandleRot.Up)
{
((FVRFireArm)Receiver).PlayAudioEvent((FirearmAudioEventType)12, 1f);
}
else if (CurRot == HandleRot.Down && LastRot != 0)
{
((FVRFireArm)Receiver).PlayAudioEvent((FirearmAudioEventType)13, 1f);
}
}
}
private void HandleStateAudioEvents()
{
if (!((Object)(object)Receiver == (Object)null))
{
if (CurState == HandleState.Rear && LastState != HandleState.Rear)
{
((FVRFireArm)Receiver).PlayAudioEvent((FirearmAudioEventType)10, 1f);
}
else if (CurState == HandleState.Forward && LastState != 0)
{
((FVRFireArm)Receiver).PlayAudioEvent((FirearmAudioEventType)11, 1f);
}
}
}
}
namespace Volks.SaigaSpike
{
[BepInPlugin("Volks.SaigaSpike", "SaigaSpike", "1.1.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class SaigaSpikePlugin : 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.SaigaSpike");
OtherLoader.RegisterDirectLoad(BasePath, "Volks.SaigaSpike", "", "", "saigaspike_shotgun", "");
}
}
}
public class BoltReleaseChargingHandle : MonoBehaviour
{
public ClosedBoltWeapon Weapon;
public ClosedBoltHandle Handle;
public float LaunchSpeed = 5f;
[Tooltip("If true, the handle stays at Rear until bolt release is pressed again. If false, it returns forward when pulled back manually.")]
public bool HandleReturnsManually = false;
private bool m_wasLocked;
private void Start()
{
if ((Object)(object)Weapon == (Object)null || (Object)(object)Handle == (Object)null)
{
Debug.LogWarning((object)"[BoltReleaseChargingHandle] Weapon or Handle reference is missing.", (Object)(object)this);
((Behaviour)this).enabled = false;
}
else
{
m_wasLocked = Weapon.Bolt.IsBoltLocked();
}
}
private void Update()
{
//IL_005f: 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_0040: Invalid comparison between Unknown and I4
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Invalid comparison between Unknown and I4
bool flag = Weapon.Bolt.IsBoltLocked();
if (m_wasLocked && !flag && Weapon.HasBoltReleaseButton && (int)Handle.CurPos == 4)
{
Handle.Speed_Forward = LaunchSpeed;
}
if ((int)Handle.CurPos == 0 && Handle.Speed_Forward > 0f)
{
Handle.Speed_Forward = 0f;
}
if (!HandleReturnsManually && !flag && !((FVRInteractiveObject)Handle).IsHeld && (int)Handle.CurPos == 4 && Handle.Speed_Forward == 0f)
{
Handle.Speed_Forward = LaunchSpeed;
}
m_wasLocked = flag;
}
}
public class PartRecoilImpulse : MonoBehaviour
{
public enum ImpulseMode
{
Rotation,
Translation
}
public enum ImpulseAxis
{
X,
Y,
Z
}
[Serializable]
public class RecoilPart
{
public Transform Piece;
public ImpulseMode Mode = ImpulseMode.Rotation;
public ImpulseAxis Axis = ImpulseAxis.X;
public Vector2 Range = new Vector2(0f, 45f);
public float ReturnSpeed = 5f;
public float ImpulseStrength = 1f;
[NonSerialized]
public float CurrentLerp = 0f;
}
[Header("Parts")]
public List<RecoilPart> Parts = new List<RecoilPart>();
private FVRFireArm m_firearm;
private void Awake()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
}
private void OnDestroy()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
if ((Object)(object)GM.CurrentSceneSettings != (Object)null)
{
GM.CurrentSceneSettings.ShotFiredEvent -= new ShotFired(OnShotFired);
}
}
private void Start()
{
m_firearm = ((Component)this).GetComponentInParent<FVRFireArm>();
if ((Object)(object)m_firearm == (Object)null)
{
Debug.LogWarning((object)"[PartRecoilImpulse] No FVRFireArm found in parent hierarchy.", (Object)(object)this);
}
for (int i = 0; i < Parts.Count; i++)
{
ApplyToPart(Parts[i]);
}
}
private void OnShotFired(FVRFireArm firearm)
{
if (!((Object)(object)firearm != (Object)(object)m_firearm))
{
for (int i = 0; i < Parts.Count; i++)
{
Parts[i].CurrentLerp = Mathf.Clamp01(Parts[i].ImpulseStrength);
ApplyToPart(Parts[i]);
}
}
}
private void Update()
{
for (int i = 0; i < Parts.Count; i++)
{
RecoilPart recoilPart = Parts[i];
if (recoilPart.CurrentLerp > 0f)
{
recoilPart.CurrentLerp = Mathf.MoveTowards(recoilPart.CurrentLerp, 0f, Time.deltaTime * recoilPart.ReturnSpeed);
ApplyToPart(recoilPart);
}
}
}
private void ApplyToPart(RecoilPart part)
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)part.Piece == (Object)null)
{
return;
}
float num = Mathf.Lerp(part.Range.x, part.Range.y, part.CurrentLerp);
if (part.Mode == ImpulseMode.Rotation)
{
Vector3 localEulerAngles = part.Piece.localEulerAngles;
if (part.Axis == ImpulseAxis.X)
{
localEulerAngles.x = num;
}
else if (part.Axis == ImpulseAxis.Y)
{
localEulerAngles.y = num;
}
else
{
localEulerAngles.z = num;
}
part.Piece.localEulerAngles = localEulerAngles;
}
else
{
Vector3 localPosition = part.Piece.localPosition;
if (part.Axis == ImpulseAxis.X)
{
localPosition.x = num;
}
else if (part.Axis == ImpulseAxis.Y)
{
localPosition.y = num;
}
else
{
localPosition.z = num;
}
part.Piece.localPosition = localPosition;
}
}
}
public class SecondaryMagPos : MonoBehaviour
{
[Header("References")]
public FVRFireArm FireArm;
public FVRFireArmReloadTriggerWell TriggerWell;
[Header("Mount Override")]
public Transform MountPos;
public Transform EjectPos;
private Transform m_defaultMountPos;
private Transform m_defaultEjectPos;
private Vector3 m_defaultMountLocalPos;
private Quaternion m_defaultMountLocalRot;
private Vector3 m_defaultEjectLocalPos;
private Quaternion m_defaultEjectLocalRot;
private bool m_initialized = false;
private bool m_overrideActive = false;
private FVRFireArmMagazine m_pendingMag;
private int m_pendingStableFrames;
private const int kStableFramesRequired = 2;
private FVRFireArmMagazine m_appliedMag;
private void Start()
{
//IL_0095: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if ((Object)(object)FireArm == (Object)null || (Object)(object)TriggerWell == (Object)null)
{
((Behaviour)this).enabled = false;
return;
}
if ((Object)(object)MountPos == (Object)null)
{
((Behaviour)this).enabled = false;
return;
}
m_defaultMountPos = FireArm.MagazineMountPos;
m_defaultEjectPos = FireArm.MagazineEjectPos;
if ((Object)(object)m_defaultMountPos == (Object)null)
{
((Behaviour)this).enabled = false;
return;
}
m_defaultMountLocalPos = m_defaultMountPos.localPosition;
m_defaultMountLocalRot = m_defaultMountPos.localRotation;
if ((Object)(object)m_defaultEjectPos != (Object)null)
{
m_defaultEjectLocalPos = m_defaultEjectPos.localPosition;
m_defaultEjectLocalRot = m_defaultEjectPos.localRotation;
}
m_initialized = true;
m_pendingMag = null;
m_pendingStableFrames = 0;
m_appliedMag = null;
}
private void Update()
{
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
if (!m_initialized)
{
return;
}
FVRFireArmMagazine magazine = FireArm.Magazine;
if ((Object)(object)magazine == (Object)(object)m_pendingMag)
{
if (m_pendingStableFrames < 2)
{
m_pendingStableFrames++;
}
}
else
{
m_pendingMag = magazine;
m_pendingStableFrames = 0;
}
if (m_pendingStableFrames < 2 || (Object)(object)m_pendingMag == (Object)(object)m_appliedMag)
{
return;
}
FireArmMagazineType val = ((!TriggerWell.UsesTypeOverride) ? FireArm.MagazineType : TriggerWell.TypeOverride);
if ((Object)(object)m_pendingMag != (Object)null && m_pendingMag.MagazineType == val)
{
m_overrideActive = true;
m_appliedMag = m_pendingMag;
return;
}
if (m_overrideActive)
{
m_overrideActive = false;
RestoreDefaults();
}
m_appliedMag = null;
}
private void LateUpdate()
{
//IL_0028: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (m_initialized && m_overrideActive)
{
m_defaultMountPos.position = MountPos.position;
m_defaultMountPos.rotation = MountPos.rotation;
if ((Object)(object)m_defaultEjectPos != (Object)null && (Object)(object)EjectPos != (Object)null)
{
m_defaultEjectPos.position = EjectPos.position;
m_defaultEjectPos.rotation = EjectPos.rotation;
}
}
}
private void RestoreDefaults()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_004d: Unknown result type (might be due to invalid IL or missing references)
m_defaultMountPos.localPosition = m_defaultMountLocalPos;
m_defaultMountPos.localRotation = m_defaultMountLocalRot;
if ((Object)(object)m_defaultEjectPos != (Object)null)
{
m_defaultEjectPos.localPosition = m_defaultEjectLocalPos;
m_defaultEjectPos.localRotation = m_defaultEjectLocalRot;
}
}
private void OnDisable()
{
if (m_initialized)
{
RestoreDefaults();
}
}
private void OnDestroy()
{
if (m_initialized)
{
RestoreDefaults();
}
}
}
public class InvertClosedBolt : MonoBehaviour
{
public Transform OptionalLockPointOverride;
private void Start()
{
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
ClosedBolt component = ((Component)this).GetComponent<ClosedBolt>();
if ((Object)(object)component == (Object)null)
{
Debug.LogWarning((object)"[InvertClosedBolt] No ClosedBolt component found on this GameObject.");
return;
}
Transform point_Bolt_Forward = component.Point_Bolt_Forward;
component.Point_Bolt_Forward = component.Point_Bolt_Rear;
component.Point_Bolt_Rear = point_Bolt_Forward;
if ((Object)(object)OptionalLockPointOverride != (Object)null)
{
component.Point_Bolt_LockPoint = OptionalLockPointOverride;
}
SetPrivateFloat(component, "m_boltZ_forward", LocalZ(component.Point_Bolt_Forward));
SetPrivateFloat(component, "m_boltZ_rear", LocalZ(component.Point_Bolt_Rear));
SetPrivateFloat(component, "m_boltZ_lock", LocalZ(component.Point_Bolt_LockPoint));
SetPrivateFloat(component, "m_boltZ_current", ((Component)component).transform.localPosition.z);
if (component.UsesAKSafetyLock && (Object)(object)component.Point_Bolt_SafetyLock != (Object)null)
{
SetPrivateFloat(component, "m_boltZ_safetylock", LocalZ(component.Point_Bolt_SafetyLock));
}
component.SnapToRear();
component.UpdateBolt();
}
private static float LocalZ(Transform t)
{
//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)
return (!((Object)(object)t != (Object)null)) ? 0f : t.localPosition.z;
}
private static void SetPrivateFloat(ClosedBolt cb, string name, float value)
{
typeof(ClosedBolt).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(cb, value);
}
}
internal class AutoReleaseOnMagLoad : MonoBehaviour
{
private FVRFireArm weapon;
private Handgun handgun;
private bool wasLoaded;
public void Start()
{
weapon = ((Component)this).GetComponent<FVRFireArm>();
if (!((Object)(object)weapon == (Object)null) && weapon is Handgun)
{
ref Handgun reference = ref handgun;
FVRFireArm obj = weapon;
reference = (Handgun)(object)((obj is Handgun) ? obj : null);
}
}
public void FixedUpdate()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Invalid comparison between Unknown and I4
if ((Object)(object)handgun != (Object)null)
{
if ((Object)(object)weapon.Magazine != (Object)null)
{
if (weapon.Magazine.HasARound())
{
if ((int)handgun.Slide.CurPos >= 2 && !wasLoaded)
{
handgun.Slide.ImpartFiringImpulse();
wasLoaded = true;
}
}
else
{
wasLoaded = false;
}
}
else
{
wasLoaded = false;
}
}
else
{
wasLoaded = false;
}
}
}