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 ModularWorkshop; using OtherLoader; using UnityEngine; using UnityEngine.UI; [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] namespace Volks.Zastava_M70s; [BepInPlugin("Volks.Zastava_M70s", "Zastava_M70s", "1.0.1")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("h3vr.otherloader", "1.3.0")] public class Zastava_M70sPlugin : 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.Zastava_M70s"); OtherLoader.RegisterDirectLoad(BasePath, "Volks.Zastava_M70s", "", "", "zastava_m70s", ""); } } [RequireComponent(typeof(ModularWeaponPart))] public class AKGasTuner : MonoBehaviour, IPartFireArmRequirement { public enum AKProfilePreset { Custom, Standard_AKM, AKS_74U, Heavy_RPK } [Serializable] public class RegulatorSetting { public string SettingName; public float SelectorPosition; [Header("Cycle Multipliers")] public float ForwardSpeedMultiplier = 1f; public float RearwardSpeedMultiplier = 1f; public float SpringStiffnessMultiplier = 1f; [Header("Recoil Multipliers")] public float VerticalRecoilMultiplier = 1f; public float HorizontalRecoilMultiplier = 1f; public float ZLinearRecoilMultiplier = 1f; public float XYLinearRecoilMultiplier = 1f; [Header("Weapon Behavior Overrides")] public bool ForceManualCycle = false; public bool AllowSubsonicUnsuppressedCycling = true; public float CasingEjectionMultiplier = 1f; public float MuzzleFlashMultiplier = 1f; public float GasPuffMultiplier = 1f; public bool ApplySuppressorDelay = false; } [Header("Debugging")] public bool EnableDebug = false; [Header("Regulator Logic")] [Tooltip("The setting index active by default when the weapon spawns.")] public int DefaultSettingIndex = 2; public RegulatorSetting[] Settings; private int _currentIndex = 2; [Header("MWS UI / Physical Needle")] public Transform RegulatorGeo; public Axis Axis; public InterpStyle InterpStyle; [Header("Audio")] public AudioEvent SwitchSound; [Header("Audio Tuning")] public bool EnableSubsonicVolumeMuffling = true; [Range(0f, 1f)] public float SubsonicVolumeMultiplier = 0.5f; public float SubsonicLoudnessSuppressed = 10f; [Header("Player Comfort HUD UI")] public GameObject TextRoot; public Text TextField; public float TextDisplayDuration = 2f; [Header("Feature Toggles")] public bool EnableShortStroking = true; public bool EnableCasingEjectionScaling = true; public bool EnableMuzzleFlashScaling = true; public bool EnableGasPuffing = true; public bool EnableSuppressorDelay = false; public bool EnableRecoilScaling = true; [Header("Casing Ejection Tuning")] public float OvergassedEjectionMult = 1.5f; public float UndergassedEjectionMult = 0.4f; [Header("Muzzle Flash Tuning")] public float OvergassedFlashMult = 0.8f; public float UndergassedFlashMult = 1.3f; [Header("Suppressor Delay Tuning")] public float SuppressorRearwardSpeedMult = 0.85f; [Header("Base Weapon Parameters (For Manual RPM Calculation)")] public float BoltTravelDistance = 0.12f; public float TestBaseForwardSpeed = 2.2f; public float TestBaseRearwardSpeed = 4f; public float TestBaseSpringStiffness = 150f; public AKProfilePreset TestProfile = AKProfilePreset.Standard_AKM; public int TestSettingIndex = 2; private ClosedBoltWeapon _parentWeapon; private ClosedBolt _closedBolt; private bool _textVisible = false; private float _textTimer = 0f; private float _origSpeedForward; private float _origSpeedRearward; private float _origSpringStiffness; private Vector3 _origEjectionSpeed; private float _origLoudnessSuppressed; private Vector2 _origVolumeRange; private bool _hasCachedDefaults = false; private FVRFireArmRecoilProfile _activeRecoilProfile; private float _origVerticalRecoil; private float _origHorizontalRecoil; private float _origZLinearRecoil; private float _origXYLinearRecoil; private List _origStartSizesConstant = new List(); private List _origStartSizesMin = new List(); private List _origStartSizesMax = new List(); private float _lastAppliedMuzzleScale = -1f; private Vector2[] _origGasPerEvent; private float[] _origMaxGasRate; public FVRFireArm FireArm { get { return (FVRFireArm)(object)_parentWeapon; } set { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) if (EnableDebug) { string text = ((!((Object)(object)value != (Object)null)) ? "null" : ((Object)value).name); Debug.Log((object)("[AKGasTuner] FireArm Property Setter Invoked. Value: " + text)); } if ((Object)(object)value != (Object)null && value is ClosedBoltWeapon) { _parentWeapon = (ClosedBoltWeapon)value; _closedBolt = _parentWeapon.Bolt; if (!((Object)(object)_closedBolt != (Object)null)) { return; } _origSpeedForward = _closedBolt.Speed_Forward; _origSpeedRearward = _closedBolt.Speed_Rearward; _origSpringStiffness = _closedBolt.SpringStiffness; _origEjectionSpeed = _parentWeapon.EjectionSpeed; if ((Object)(object)((FVRFireArm)_parentWeapon).AudioClipSet != (Object)null) { _origLoudnessSuppressed = ((FVRFireArm)_parentWeapon).AudioClipSet.Loudness_Suppressed; if (((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed != null) { _origVolumeRange = ((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed.VolumeRange; } } if ((Object)(object)((FVRFireArm)_parentWeapon).RecoilProfile != (Object)null) { _activeRecoilProfile = ((FVRFireArm)_parentWeapon).RecoilProfile; _origVerticalRecoil = _activeRecoilProfile.VerticalRotPerShot; _origHorizontalRecoil = _activeRecoilProfile.HorizontalRotPerShot; _origZLinearRecoil = _activeRecoilProfile.ZLinearPerShot; _origXYLinearRecoil = _activeRecoilProfile.XYLinearPerShot; } if (((FVRFireArm)_parentWeapon).GasOutEffects != null) { _origGasPerEvent = (Vector2[])(object)new Vector2[((FVRFireArm)_parentWeapon).GasOutEffects.Length]; _origMaxGasRate = new float[((FVRFireArm)_parentWeapon).GasOutEffects.Length]; for (int i = 0; i < ((FVRFireArm)_parentWeapon).GasOutEffects.Length; i++) { if (((FVRFireArm)_parentWeapon).GasOutEffects[i] != null) { ref Vector2 reference = ref _origGasPerEvent[i]; reference = ((FVRFireArm)_parentWeapon).GasOutEffects[i].GasPerEvent; _origMaxGasRate[i] = ((FVRFireArm)_parentWeapon).GasOutEffects[i].MaxGasRate; } } } _hasCachedDefaults = true; ApplySetting(_currentIndex); if (EnableDebug) { Debug.Log((object)("[AKGasTuner] Initialized successfully. Caching original speeds -> Fwd: " + _origSpeedForward + ", Rear: " + _origSpeedRearward + ", Stiff: " + _origSpringStiffness)); } } else { if (!((Object)(object)value == (Object)null) || !((Object)(object)_parentWeapon != (Object)null)) { return; } if (_hasCachedDefaults && (Object)(object)_closedBolt != (Object)null) { if (EnableDebug) { Debug.Log((object)("[AKGasTuner] Detached from weapon. Restoring original speeds -> Fwd: " + _origSpeedForward + ", Rear: " + _origSpeedRearward + ", Stiff: " + _origSpringStiffness)); } _closedBolt.Speed_Forward = _origSpeedForward; _closedBolt.Speed_Rearward = _origSpeedRearward; _closedBolt.SpringStiffness = _origSpringStiffness; _parentWeapon.EjectionSpeed = _origEjectionSpeed; _parentWeapon.ReciprocatesOnShot = true; ScaleMuzzleFlash(1f); if ((Object)(object)_activeRecoilProfile != (Object)null) { _activeRecoilProfile.VerticalRotPerShot = _origVerticalRecoil; _activeRecoilProfile.HorizontalRotPerShot = _origHorizontalRecoil; _activeRecoilProfile.ZLinearPerShot = _origZLinearRecoil; _activeRecoilProfile.XYLinearPerShot = _origXYLinearRecoil; } if (((FVRFireArm)_parentWeapon).GasOutEffects != null && _origGasPerEvent != null) { for (int j = 0; j < ((FVRFireArm)_parentWeapon).GasOutEffects.Length; j++) { if (((FVRFireArm)_parentWeapon).GasOutEffects[j] != null && j < _origGasPerEvent.Length) { ((FVRFireArm)_parentWeapon).GasOutEffects[j].GasPerEvent = _origGasPerEvent[j]; ((FVRFireArm)_parentWeapon).GasOutEffects[j].MaxGasRate = _origMaxGasRate[j]; } } } if ((Object)(object)((FVRFireArm)_parentWeapon).AudioClipSet != (Object)null) { ((FVRFireArm)_parentWeapon).AudioClipSet.Loudness_Suppressed = _origLoudnessSuppressed; if (((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed != null) { ((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed.VolumeRange = _origVolumeRange; } } } _parentWeapon = null; _closedBolt = null; _activeRecoilProfile = null; _origStartSizesMin.Clear(); _origStartSizesMax.Clear(); _origStartSizesConstant.Clear(); _origGasPerEvent = null; _origMaxGasRate = null; _hasCachedDefaults = false; _lastAppliedMuzzleScale = -1f; } } } private void Awake() { if ((Object)(object)TextRoot != (Object)null) { TextRoot.SetActive(false); } _currentIndex = DefaultSettingIndex; } private void InitializeWithWeapon(FVRFireArm gun) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) if (!(gun is ClosedBoltWeapon)) { return; } _parentWeapon = (ClosedBoltWeapon)gun; _closedBolt = _parentWeapon.Bolt; if (!((Object)(object)_closedBolt != (Object)null) || _hasCachedDefaults) { return; } _origSpeedForward = _closedBolt.Speed_Forward; _origSpeedRearward = _closedBolt.Speed_Rearward; _origSpringStiffness = _closedBolt.SpringStiffness; _origEjectionSpeed = _parentWeapon.EjectionSpeed; if ((Object)(object)((FVRFireArm)_parentWeapon).AudioClipSet != (Object)null) { _origLoudnessSuppressed = ((FVRFireArm)_parentWeapon).AudioClipSet.Loudness_Suppressed; if (((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed != null) { _origVolumeRange = ((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed.VolumeRange; } } if ((Object)(object)((FVRFireArm)_parentWeapon).RecoilProfile != (Object)null) { _activeRecoilProfile = ((FVRFireArm)_parentWeapon).RecoilProfile; _origVerticalRecoil = _activeRecoilProfile.VerticalRotPerShot; _origHorizontalRecoil = _activeRecoilProfile.HorizontalRotPerShot; _origZLinearRecoil = _activeRecoilProfile.ZLinearPerShot; _origXYLinearRecoil = _activeRecoilProfile.XYLinearPerShot; } if (((FVRFireArm)_parentWeapon).GasOutEffects != null) { _origGasPerEvent = (Vector2[])(object)new Vector2[((FVRFireArm)_parentWeapon).GasOutEffects.Length]; _origMaxGasRate = new float[((FVRFireArm)_parentWeapon).GasOutEffects.Length]; for (int i = 0; i < ((FVRFireArm)_parentWeapon).GasOutEffects.Length; i++) { if (((FVRFireArm)_parentWeapon).GasOutEffects[i] != null) { ref Vector2 reference = ref _origGasPerEvent[i]; reference = ((FVRFireArm)_parentWeapon).GasOutEffects[i].GasPerEvent; _origMaxGasRate[i] = ((FVRFireArm)_parentWeapon).GasOutEffects[i].MaxGasRate; } } } _hasCachedDefaults = true; ApplySetting(_currentIndex); if (EnableDebug) { Debug.Log((object)("[AKGasTuner] Successfully initialized with Parent Gun: " + ((Object)_parentWeapon).name)); } } public void AdvanceSetting(FVRViveHand hand) { //IL_0117: 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) if (Settings == null || Settings.Length == 0) { return; } _currentIndex++; if (_currentIndex >= Settings.Length) { _currentIndex = 0; } ApplySetting(_currentIndex); if (EnableDebug) { string text = ((Settings[_currentIndex] == null) ? "Unnamed" : Settings[_currentIndex].SettingName); Debug.Log((object)("[AKGasTuner] AdvanceSetting Triggered via Dial. Settings Index advanced to: " + _currentIndex + " (" + text + ")")); } if (SwitchSound != null) { if ((Object)(object)_parentWeapon != (Object)null) { ((FVRFireArm)_parentWeapon).PlayAudioAsHandling(SwitchSound, ((Component)this).transform.position); } else { SM.PlayCoreSound((FVRPooledAudioType)0, SwitchSound, ((Component)this).transform.position); } } ShowText(Settings[_currentIndex].SettingName); } private void ApplySetting(int index) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) if (Settings == null || index >= Settings.Length || (Object)(object)_parentWeapon == (Object)null || (Object)(object)_closedBolt == (Object)null) { return; } RegulatorSetting regulatorSetting = Settings[index]; if ((Object)(object)RegulatorGeo != (Object)null) { ((FVRPhysicalObject)_parentWeapon).SetAnimatedComponent(RegulatorGeo, regulatorSetting.SelectorPosition, InterpStyle, Axis); } float num = _origSpeedForward; float num2 = _origSpeedRearward; float num3 = _origSpringStiffness; FirearmModificationAddon[] componentsInChildren = ((Component)_parentWeapon).GetComponentsInChildren(true); FirearmModificationAddon[] array = componentsInChildren; foreach (FirearmModificationAddon val in array) { if ((Object)(object)val != (Object)null && val.AdjustsFireRate) { num = val.BoltSpeed_Forward; num2 = val.BoltSpeed_Rearward; num3 = val.BoltSpringStiffness; if (EnableDebug) { Debug.Log((object)("[AKGasTuner] Active custom Bolt Carrier mod detected. Baseline speeds resolved to -> Fwd: " + num + ", Rear: " + num2 + ", Stiff: " + num3)); } break; } } float num4 = regulatorSetting.RearwardSpeedMultiplier; if (regulatorSetting.ApplySuppressorDelay && ((FVRFireArm)_parentWeapon).IsSuppressed()) { num4 *= SuppressorRearwardSpeedMult; } _closedBolt.Speed_Forward = num * regulatorSetting.ForwardSpeedMultiplier; _closedBolt.Speed_Rearward = num2 * num4; _closedBolt.SpringStiffness = num3 * regulatorSetting.SpringStiffnessMultiplier; if (EnableRecoilScaling && (Object)(object)_activeRecoilProfile != (Object)null) { _activeRecoilProfile.VerticalRotPerShot = _origVerticalRecoil * regulatorSetting.VerticalRecoilMultiplier; _activeRecoilProfile.HorizontalRotPerShot = _origHorizontalRecoil * regulatorSetting.HorizontalRecoilMultiplier; _activeRecoilProfile.ZLinearPerShot = _origZLinearRecoil * regulatorSetting.ZLinearRecoilMultiplier; _activeRecoilProfile.XYLinearPerShot = _origXYLinearRecoil * regulatorSetting.XYLinearRecoilMultiplier; } if (EnableGasPuffing && ((FVRFireArm)_parentWeapon).GasOutEffects != null && _origGasPerEvent != null) { for (int j = 0; j < ((FVRFireArm)_parentWeapon).GasOutEffects.Length; j++) { if (((FVRFireArm)_parentWeapon).GasOutEffects[j] != null && j < _origGasPerEvent.Length) { ((FVRFireArm)_parentWeapon).GasOutEffects[j].GasPerEvent = _origGasPerEvent[j] * regulatorSetting.GasPuffMultiplier; ((FVRFireArm)_parentWeapon).GasOutEffects[j].MaxGasRate = _origMaxGasRate[j] * regulatorSetting.GasPuffMultiplier; } } } if (EnableDebug) { Debug.Log((object)("[AKGasTuner] Applied Setting -> Fwd: " + _closedBolt.Speed_Forward + ", Rear: " + _closedBolt.Speed_Rearward + ", Stiff: " + _closedBolt.SpringStiffness)); } } private void Update() { //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) if (_textVisible) { _textTimer -= Time.deltaTime; if (_textTimer <= 0f) { _textVisible = false; if ((Object)(object)TextRoot != (Object)null) { TextRoot.SetActive(false); } } } if ((Object)(object)_parentWeapon == (Object)null) { FVRFireArm componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { InitializeWithWeapon(componentInParent); } } if ((Object)(object)_parentWeapon == (Object)null || !_hasCachedDefaults || (Object)(object)_closedBolt == (Object)null) { return; } bool flag = IsChamberedRoundSubsonic(); bool flag2 = ((FVRFireArm)_parentWeapon).IsSuppressed(); RegulatorSetting regulatorSetting = Settings[_currentIndex]; if (EnableShortStroking) { if (regulatorSetting.ForceManualCycle) { _parentWeapon.ReciprocatesOnShot = false; } else if (flag && !flag2 && !regulatorSetting.AllowSubsonicUnsuppressedCycling) { _parentWeapon.ReciprocatesOnShot = false; } else { _parentWeapon.ReciprocatesOnShot = true; } } else { _parentWeapon.ReciprocatesOnShot = true; } if (EnableCasingEjectionScaling) { if (((FVRInteractiveObject)_closedBolt).IsHeld || _closedBolt.m_isHandleHeld) { _parentWeapon.EjectionSpeed = _origEjectionSpeed; } else { _parentWeapon.EjectionSpeed = _origEjectionSpeed * regulatorSetting.CasingEjectionMultiplier; } } else { _parentWeapon.EjectionSpeed = _origEjectionSpeed; } float num = 1f; if (EnableMuzzleFlashScaling && !flag2) { num = regulatorSetting.MuzzleFlashMultiplier; } if (Mathf.Abs(num - _lastAppliedMuzzleScale) > 0.01f) { _lastAppliedMuzzleScale = num; ScaleMuzzleFlash(num); } if (flag && flag2 && (Object)(object)((FVRFireArm)_parentWeapon).AudioClipSet != (Object)null) { ((FVRFireArm)_parentWeapon).AudioClipSet.Loudness_Suppressed = SubsonicLoudnessSuppressed; if (EnableSubsonicVolumeMuffling && ((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed != null) { ((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed.VolumeRange = _origVolumeRange * SubsonicVolumeMultiplier; } } else if ((Object)(object)((FVRFireArm)_parentWeapon).AudioClipSet != (Object)null) { ((FVRFireArm)_parentWeapon).AudioClipSet.Loudness_Suppressed = _origLoudnessSuppressed; if (((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed != null) { ((FVRFireArm)_parentWeapon).AudioClipSet.Shots_Suppressed.VolumeRange = _origVolumeRange; } } } private void CacheMuzzleParticleSizes() { //IL_007a: 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_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) _origStartSizesConstant.Clear(); _origStartSizesMin.Clear(); _origStartSizesMax.Clear(); for (int i = 0; i < ((FVRFireArm)_parentWeapon).m_muzzleSystems.Count; i++) { if (((FVRFireArm)_parentWeapon).m_muzzleSystems[i] != null && (Object)(object)((FVRFireArm)_parentWeapon).m_muzzleSystems[i].PSystem != (Object)null) { ParticleSystem pSystem = ((FVRFireArm)_parentWeapon).m_muzzleSystems[i].PSystem; MainModule main = pSystem.main; MinMaxCurve startSize = ((MainModule)(ref main)).startSize; _origStartSizesConstant.Add(((MinMaxCurve)(ref startSize)).constant); _origStartSizesMin.Add(((MinMaxCurve)(ref startSize)).constantMin); _origStartSizesMax.Add(((MinMaxCurve)(ref startSize)).constantMax); } else { _origStartSizesConstant.Add(1f); _origStartSizesMin.Add(1f); _origStartSizesMax.Add(1f); } } } private void ScaleMuzzleFlash(float scale) { //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_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_0129: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_parentWeapon == (Object)null || ((FVRFireArm)_parentWeapon).m_muzzleSystems == null) { return; } if (_origStartSizesMin.Count != ((FVRFireArm)_parentWeapon).m_muzzleSystems.Count) { CacheMuzzleParticleSizes(); } if (EnableDebug) { Debug.Log((object)("[AKGasTuner] Scaling muzzle flash transforms to: " + scale)); } for (int i = 0; i < ((FVRFireArm)_parentWeapon).m_muzzleSystems.Count; i++) { if (((FVRFireArm)_parentWeapon).m_muzzleSystems[i] != null && (Object)(object)((FVRFireArm)_parentWeapon).m_muzzleSystems[i].PSystem != (Object)null && i < _origStartSizesConstant.Count) { ParticleSystem pSystem = ((FVRFireArm)_parentWeapon).m_muzzleSystems[i].PSystem; MainModule main = pSystem.main; MinMaxCurve startSize = ((MainModule)(ref main)).startSize; ((MinMaxCurve)(ref startSize)).constant = _origStartSizesConstant[i] * scale; ((MinMaxCurve)(ref startSize)).constantMin = _origStartSizesMin[i] * scale; ((MinMaxCurve)(ref startSize)).constantMax = _origStartSizesMax[i] * scale; ((MainModule)(ref main)).startSize = startSize; } } } private bool IsChamberedRoundSubsonic() { if ((Object)(object)_parentWeapon.Chamber == (Object)null || !_parentWeapon.Chamber.IsFull) { return false; } FVRFireArmRound round = _parentWeapon.Chamber.GetRound(); if ((Object)(object)round != (Object)null && (Object)(object)round.BallisticProjectilePrefab != (Object)null) { BallisticProjectile component = round.BallisticProjectilePrefab.GetComponent(); if ((Object)(object)component != (Object)null) { return component.MuzzleVelocityBase < 340f; } } return false; } private void ShowText(string settingName) { if (!((Object)(object)TextRoot == (Object)null)) { if ((Object)(object)TextField != (Object)null) { TextField.text = settingName; } TextRoot.SetActive(true); _textVisible = true; _textTimer = TextDisplayDuration; } } [ContextMenu("Calculate and Log RPM")] public void CalculateAndLogRPM() { if (Settings == null || TestSettingIndex >= Settings.Length) { Debug.LogWarning((object)"[GasTuner RPM Test] Settings array is empty or the selected index is out of bounds."); return; } RegulatorSetting regulatorSetting = Settings[TestSettingIndex]; float num = TestBaseForwardSpeed * regulatorSetting.ForwardSpeedMultiplier; float num2 = TestBaseRearwardSpeed * regulatorSetting.RearwardSpeedMultiplier; float num3 = TestBaseSpringStiffness * regulatorSetting.SpringStiffnessMultiplier; if (num2 <= 0f || num <= 0f || num3 <= 0f) { Debug.LogWarning((object)"[GasTuner RPM Test] Speed or Stiffness values cannot be zero or negative."); return; } float num4 = BoltTravelDistance / num2; float num5 = num / num3; float num6 = 0.5f * num3 * (num5 * num5); float num7 = 0f; if (num6 >= BoltTravelDistance) { num7 = Mathf.Sqrt(2f * BoltTravelDistance / num3); } else { float num8 = BoltTravelDistance - num6; float num9 = num8 / num; num7 = num5 + num9; } float num10 = num4 + num7; int num11 = Mathf.RoundToInt(60f / num10); string settingName = regulatorSetting.SettingName; string text = $"[GasTuner RPM Test] Setting: {settingName} | Target Forward Speed: {num:F2} | Target Rearward Speed: {num2:F2} | Spring Stiffness: {num3:F1} | Calculated Cyclic Rate: {num11} RPM"; Debug.Log((object)text); } } public class AudioConsistencyEnforcer : MonoBehaviour { [Header("Audio Profiles")] public FVRFirearmAudioSet BaseHandlingAudioProfile; private FVRFireArm _firearm; private FVRFirearmAudioSet _lastAudioClipSet; private void Awake() { _firearm = ((Component)this).GetComponent(); if ((Object)(object)_firearm != (Object)null && (Object)(object)_firearm.AudioClipSet != (Object)null) { _lastAudioClipSet = _firearm.AudioClipSet; BaseHandlingAudioProfile = ScriptableObject.CreateInstance(); SaveBaseHandlingAudio(_lastAudioClipSet); } } private void LateUpdate() { if ((Object)(object)_firearm == (Object)null) { return; } FVRFirearmAudioSet audioClipSet = _firearm.AudioClipSet; if (!((Object)(object)audioClipSet == (Object)null)) { if ((Object)(object)audioClipSet != (Object)(object)_lastAudioClipSet) { _lastAudioClipSet = audioClipSet; } EnforceHandlingSounds(audioClipSet); } } private void SaveBaseHandlingAudio(FVRFirearmAudioSet source) { BaseHandlingAudioProfile.BoltRelease = source.BoltRelease; BaseHandlingAudioProfile.BoltSlideBack = source.BoltSlideBack; BaseHandlingAudioProfile.BoltSlideForward = source.BoltSlideForward; BaseHandlingAudioProfile.BoltSlideBackHeld = source.BoltSlideBackHeld; BaseHandlingAudioProfile.BoltSlideBackLocked = source.BoltSlideBackLocked; BaseHandlingAudioProfile.BreachOpen = source.BreachOpen; BaseHandlingAudioProfile.BreachClose = source.BreachClose; BaseHandlingAudioProfile.CatchOnSear = source.CatchOnSear; BaseHandlingAudioProfile.ChamberManual = source.ChamberManual; BaseHandlingAudioProfile.FireSelector = source.FireSelector; BaseHandlingAudioProfile.HammerHit = source.HammerHit; BaseHandlingAudioProfile.HandleBack = source.HandleBack; BaseHandlingAudioProfile.HandleBackEmpty = source.HandleBackEmpty; BaseHandlingAudioProfile.HandleForward = source.HandleForward; BaseHandlingAudioProfile.HandleForwardEmpty = source.HandleForwardEmpty; BaseHandlingAudioProfile.HandleUp = source.HandleUp; BaseHandlingAudioProfile.HandleDown = source.HandleDown; BaseHandlingAudioProfile.HandleGrab = source.HandleGrab; BaseHandlingAudioProfile.Prefire = source.Prefire; BaseHandlingAudioProfile.Safety = source.Safety; BaseHandlingAudioProfile.TriggerReset = source.TriggerReset; BaseHandlingAudioProfile.TopCoverRelease = source.TopCoverRelease; BaseHandlingAudioProfile.TopCoverUp = source.TopCoverUp; BaseHandlingAudioProfile.TopCoverDown = source.TopCoverDown; BaseHandlingAudioProfile.StockOpen = source.StockOpen; BaseHandlingAudioProfile.StockClosed = source.StockClosed; BaseHandlingAudioProfile.BipodOpen = source.BipodOpen; BaseHandlingAudioProfile.BipodClosed = source.BipodClosed; BaseHandlingAudioProfile.BeltGrab = source.BeltGrab; BaseHandlingAudioProfile.BeltRelease = source.BeltRelease; BaseHandlingAudioProfile.BeltSeat = source.BeltSeat; BaseHandlingAudioProfile.BeltSettle = source.BeltSettle; } private void EnforceHandlingSounds(FVRFirearmAudioSet targetProfile) { targetProfile.BoltRelease = BaseHandlingAudioProfile.BoltRelease; targetProfile.BoltSlideBack = BaseHandlingAudioProfile.BoltSlideBack; targetProfile.BoltSlideForward = BaseHandlingAudioProfile.BoltSlideForward; targetProfile.BoltSlideBackHeld = BaseHandlingAudioProfile.BoltSlideBackHeld; targetProfile.BoltSlideBackLocked = BaseHandlingAudioProfile.BoltSlideBackLocked; targetProfile.BreachOpen = BaseHandlingAudioProfile.BreachOpen; targetProfile.BreachClose = BaseHandlingAudioProfile.BreachClose; targetProfile.CatchOnSear = BaseHandlingAudioProfile.CatchOnSear; targetProfile.ChamberManual = BaseHandlingAudioProfile.ChamberManual; targetProfile.FireSelector = BaseHandlingAudioProfile.FireSelector; targetProfile.HammerHit = BaseHandlingAudioProfile.HammerHit; targetProfile.HandleBack = BaseHandlingAudioProfile.HandleBack; targetProfile.HandleBackEmpty = BaseHandlingAudioProfile.HandleBackEmpty; targetProfile.HandleForward = BaseHandlingAudioProfile.HandleForward; targetProfile.HandleForwardEmpty = BaseHandlingAudioProfile.HandleForwardEmpty; targetProfile.HandleUp = BaseHandlingAudioProfile.HandleUp; targetProfile.HandleDown = BaseHandlingAudioProfile.HandleDown; targetProfile.HandleGrab = BaseHandlingAudioProfile.HandleGrab; targetProfile.Prefire = BaseHandlingAudioProfile.Prefire; targetProfile.Safety = BaseHandlingAudioProfile.Safety; targetProfile.TriggerReset = BaseHandlingAudioProfile.TriggerReset; targetProfile.TopCoverRelease = BaseHandlingAudioProfile.TopCoverRelease; targetProfile.TopCoverUp = BaseHandlingAudioProfile.TopCoverUp; targetProfile.TopCoverDown = BaseHandlingAudioProfile.TopCoverDown; targetProfile.StockOpen = BaseHandlingAudioProfile.StockOpen; targetProfile.StockClosed = BaseHandlingAudioProfile.StockClosed; targetProfile.BipodOpen = BaseHandlingAudioProfile.BipodOpen; targetProfile.BipodClosed = BaseHandlingAudioProfile.BipodClosed; targetProfile.BeltGrab = BaseHandlingAudioProfile.BeltGrab; targetProfile.BeltRelease = BaseHandlingAudioProfile.BeltRelease; targetProfile.BeltSeat = BaseHandlingAudioProfile.BeltSeat; targetProfile.BeltSettle = BaseHandlingAudioProfile.BeltSettle; } } public class GasTunerDial : FVRInteractiveObject { [Header("Master Tuner Connection")] [Tooltip("Drag and drop your root AKGasTuner component here in your prefab. Unity preserves this reference even after MWS re-parents the dial.")] public AKGasTuner Tuner; public override void Awake() { ((FVRInteractiveObject)this).Awake(); if ((Object)(object)Tuner != (Object)null) { return; } Tuner = ((Component)this).GetComponentInParent(); if (!((Object)(object)Tuner != (Object)null)) { FVRFireArm componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { Tuner = ((Component)componentInParent).GetComponentInChildren(); } } } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); if ((Object)(object)Tuner != (Object)null) { Tuner.AdvanceSetting(hand); } } } [RequireComponent(typeof(ModularWeaponPart))] public class ManualFireSelectorAddon : MonoBehaviour, IPartFireArmRequirement { [Header("Debug Settings")] [Tooltip("Enable detailed console logs to track component auto-detection, linking, and physical registration.")] public bool EnableDebugLogging = true; [Header("Modular Workshop Connections")] private FVRFireArm _firearm; [Tooltip("Drag the native ClosedBoltSecondarySwitch components from your child GameObjects here.")] public ClosedBoltSecondarySwitch[] SecondarySwitches; [Tooltip("Which native index array slot to reset to Safe (0) on unequip to prevent IndexOutOfRange crashes on the next receiver.")] public int ModeIndexToSub = 1; private static FieldInfo _fInteractiveObjectsField; private static FieldInfo _fCollidersField; private static FieldInfo _parentField; public FVRFireArm FireArm { get { return _firearm; } set { if ((Object)(object)value != (Object)null) { _firearm = value; FVRFireArm firearm = _firearm; ClosedBoltWeapon val = (ClosedBoltWeapon)(object)((firearm is ClosedBoltWeapon) ? firearm : null); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Equipping - FireArm assigned: {((Object)value).name}. Is ClosedBoltWeapon: {(Object)(object)val != (Object)null}"); } if (!((Object)(object)val != (Object)null) || SecondarySwitches == null) { return; } for (int i = 0; i < SecondarySwitches.Length; i++) { ClosedBoltSecondarySwitch val2 = SecondarySwitches[i]; if (!((Object)(object)val2 != (Object)null)) { continue; } val2.Weapon = val; try { SetParentPhysicalObject((FVRInteractiveObject)(object)val2, (FVRPhysicalObject)(object)val); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Equipping - Set Parent for switch: {((Object)((Component)val2).gameObject).name}"); } } catch (Exception ex) { if (EnableDebugLogging) { Debug.LogError((object)("[ManualFireSelectorAddon] Equipping - Exception setting Parent on switch: " + ex.Message)); } } try { RegisterPhysicsLists((FVRInteractiveObject)(object)val2, (FVRFireArm)(object)val); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Equipping - Registered physics lists for switch: {((Object)((Component)val2).gameObject).name}"); } } catch (Exception ex2) { if (EnableDebugLogging) { Debug.LogError((object)("[ManualFireSelectorAddon] Equipping - Exception registering physics lists: " + ex2.Message)); } } try { if (val.FireSelector_Modes != null && val.FireSelector_Modes.Length == 1) { val2.ModeIndexToSub = 0; if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Equipping - Dynamically set ModeIndexToSub to 0 on switch: {((Object)((Component)val2).gameObject).name}"); } } } catch (Exception ex3) { if (EnableDebugLogging) { Debug.LogError((object)("[ManualFireSelectorAddon] Equipping - Exception configuring ModeIndexToSub: " + ex3.Message)); } } try { ((Component)val2).gameObject.SetActive(true); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Equipping - Activated GameObject: {((Object)((Component)val2).gameObject).name}"); } } catch (Exception ex4) { if (EnableDebugLogging) { Debug.LogError((object)("[ManualFireSelectorAddon] Equipping - Exception activating GameObject: " + ex4.Message)); } } try { val2.UpdateBaseGunSelector(val2.CurModeIndex); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Equipping - Initialized switch: {((Object)((Component)val2).gameObject).name} to mode index: {val2.CurModeIndex}"); } } catch (Exception ex5) { if (EnableDebugLogging) { Debug.LogError((object)("[ManualFireSelectorAddon] Equipping - Exception initializing switch: " + ex5.Message)); } } } } else { if (!((Object)(object)value == (Object)null) || !((Object)(object)_firearm != (Object)null)) { return; } if (EnableDebugLogging) { Debug.Log((object)"[ManualFireSelectorAddon] Swapping away - Starting unregister."); } if (SecondarySwitches != null) { for (int j = 0; j < SecondarySwitches.Length; j++) { ClosedBoltSecondarySwitch val3 = SecondarySwitches[j]; if (!((Object)(object)val3 != (Object)null)) { continue; } try { UnregisterPhysicsLists((FVRInteractiveObject)(object)val3, _firearm); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Swapping away - Unregistered physics lists for switch: {((Object)((Component)val3).gameObject).name}"); } } catch (Exception ex6) { if (EnableDebugLogging) { Debug.LogError((object)("[ManualFireSelectorAddon] Swapping away - Exception unregistering physics: " + ex6.Message)); } } val3.Weapon = null; try { SetParentPhysicalObject((FVRInteractiveObject)(object)val3, null); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Swapping away - Cleared Parent for switch: {((Object)((Component)val3).gameObject).name}"); } } catch (Exception ex7) { if (EnableDebugLogging) { Debug.LogError((object)("[ManualFireSelectorAddon] Swapping away - Exception clearing Parent: " + ex7.Message)); } } } } FVRFireArm firearm2 = _firearm; ClosedBoltWeapon val4 = (ClosedBoltWeapon)(object)((firearm2 is ClosedBoltWeapon) ? firearm2 : null); if ((Object)(object)val4 != (Object)null) { try { val4.m_fireSelectorMode = 0; val4.ResetCamBurst(); if (EnableDebugLogging) { Debug.Log((object)"[ManualFireSelectorAddon] Swapping away - Base firearm active mode reset to 0 (Safe)."); } } catch (Exception ex8) { if (EnableDebugLogging) { Debug.LogError((object)("[ManualFireSelectorAddon] Swapping away - Exception resetting active selector mode: " + ex8.Message)); } } } _firearm = null; } } } private static void InitializeReflection() { if ((object)_fInteractiveObjectsField == null) { Type typeFromHandle = typeof(FVRPhysicalObject); _fInteractiveObjectsField = typeFromHandle.GetField("m_fInteractiveObjects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeFromHandle.GetField("FInteractiveObjects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _fCollidersField = typeFromHandle.GetField("m_colliders", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeFromHandle.GetField("Colliders", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeFromHandle.GetField("m_fColliders", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeFromHandle.GetField("FColliders", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } } private static void InitializeParentReflection() { if ((object)_parentField == null) { Type typeFromHandle = typeof(FVRInteractiveObject); _parentField = typeFromHandle.GetField("parent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeFromHandle.GetField("Parent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeFromHandle.GetField("m_parent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } } private void SetParentPhysicalObject(FVRInteractiveObject sw, FVRPhysicalObject value) { InitializeParentReflection(); if ((object)_parentField != null && (Object)(object)sw != (Object)null) { _parentField.SetValue(sw, value); } } private void RegisterPhysicsLists(FVRInteractiveObject sw, FVRFireArm firearm) { if ((Object)(object)sw == (Object)null || (Object)(object)firearm == (Object)null) { return; } InitializeReflection(); if ((object)_fInteractiveObjectsField != null) { object value = _fInteractiveObjectsField.GetValue(firearm); if (value is List) { List list = (List)value; if (!list.Contains(sw)) { list.Add(sw); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Register - Added {((Object)((Component)sw).gameObject).name} to firearm's master interactive objects List."); } } } else if (value is FVRInteractiveObject[]) { FVRInteractiveObject[] array = (FVRInteractiveObject[])value; if (Array.IndexOf(array, sw) == -1) { List list2 = new List(array); list2.Add(sw); _fInteractiveObjectsField.SetValue(firearm, list2.ToArray()); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Register - Added {((Object)((Component)sw).gameObject).name} to firearm's master interactive objects Array."); } } } } if ((object)_fCollidersField == null) { return; } object value2 = _fCollidersField.GetValue(firearm); Collider[] componentsInChildren = ((Component)sw).GetComponentsInChildren(true); if (value2 is List) { List list3 = (List)value2; if (componentsInChildren == null) { return; } int num = 0; for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && !list3.Contains(componentsInChildren[i])) { list3.Add(componentsInChildren[i]); num++; } } if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Register - Added {num} colliders from {((Object)((Component)sw).gameObject).name} to firearm's master colliders List."); } } else { if (!(value2 is Collider[])) { return; } Collider[] collection = (Collider[])value2; List list4 = new List(collection); if (componentsInChildren == null) { return; } int num2 = 0; for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)null && !list4.Contains(componentsInChildren[j])) { list4.Add(componentsInChildren[j]); num2++; } } _fCollidersField.SetValue(firearm, list4.ToArray()); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Register - Added {num2} colliders from {((Object)((Component)sw).gameObject).name} to firearm's master colliders Array."); } } } private void UnregisterPhysicsLists(FVRInteractiveObject sw, FVRFireArm firearm) { if ((Object)(object)sw == (Object)null || (Object)(object)firearm == (Object)null) { return; } InitializeReflection(); if ((object)_fInteractiveObjectsField != null) { object value = _fInteractiveObjectsField.GetValue(firearm); if (value is List) { List list = (List)value; if (list.Contains(sw)) { list.Remove(sw); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Unregister - Removed {((Object)((Component)sw).gameObject).name} from firearm's master interactive objects List."); } } } else if (value is FVRInteractiveObject[]) { FVRInteractiveObject[] collection = (FVRInteractiveObject[])value; List list2 = new List(collection); if (list2.Contains(sw)) { list2.Remove(sw); _fInteractiveObjectsField.SetValue(firearm, list2.ToArray()); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Unregister - Removed {((Object)((Component)sw).gameObject).name} from firearm's master interactive objects Array."); } } } } if ((object)_fCollidersField == null) { return; } object value2 = _fCollidersField.GetValue(firearm); Collider[] componentsInChildren = ((Component)sw).GetComponentsInChildren(true); if (value2 is List) { List list3 = (List)value2; if (componentsInChildren == null) { return; } int num = 0; for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && list3.Contains(componentsInChildren[i])) { list3.Remove(componentsInChildren[i]); num++; } } if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Unregister - Removed {num} colliders from {((Object)((Component)sw).gameObject).name} from firearm's master colliders List."); } } else { if (!(value2 is Collider[])) { return; } Collider[] collection2 = (Collider[])value2; List list4 = new List(collection2); if (componentsInChildren == null) { return; } int num2 = 0; for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)null && list4.Contains(componentsInChildren[j])) { list4.Remove(componentsInChildren[j]); num2++; } } _fCollidersField.SetValue(firearm, list4.ToArray()); if (EnableDebugLogging) { Debug.Log((object)$"[ManualFireSelectorAddon] Unregister - Removed {num2} colliders from {((Object)((Component)sw).gameObject).name} from firearm's master colliders Array."); } } } } public class GasCutOff : FVRInteractiveObject { public enum RotationAxis { X, Y, Z } private enum BoltType { Null, Open, Closed } [Header("Bolt Reference")] [Tooltip("Assign the GameObject that contains either a ClosedBolt or an OpenBoltReceiverBolt component.")] public GameObject Bolt; private BoltType m_boltType = BoltType.Null; private OpenBoltReceiverBolt m_openBolt; private ClosedBolt m_closedBolt; [Header("Axis Configuration")] [Tooltip("The local rotation axis that the gas cut-off handle turns on.")] public RotationAxis Axis = RotationAxis.Z; public Transform GasCutOffGeo; private bool m_isOpen; public float OpenRot; public float ClosedRot; public float RotSpeed = 360f; private float m_curRot; private float m_tarRot; private float m_originalRearwardSpeed; public AudioEvent AudEvent_CoverOpen; public AudioEvent AudEvent_CoverClose; public override void Awake() { ((FVRInteractiveObject)this).Awake(); m_curRot = ClosedRot; m_tarRot = ClosedRot; if ((Object)(object)Bolt != (Object)null) { if ((Object)(object)Bolt.GetComponent() != (Object)null) { m_boltType = BoltType.Open; m_openBolt = Bolt.GetComponent(); } else if ((Object)(object)Bolt.GetComponent() != (Object)null) { m_boltType = BoltType.Closed; m_closedBolt = Bolt.GetComponent(); } } if (m_boltType == BoltType.Null) { FVRFireArm componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { OpenBoltReceiverBolt componentInChildren = ((Component)componentInParent).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { m_boltType = BoltType.Open; m_openBolt = componentInChildren; } else { ClosedBolt componentInChildren2 = ((Component)componentInParent).GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { m_boltType = BoltType.Closed; m_closedBolt = componentInChildren2; } } } } if (m_boltType == BoltType.Open && (Object)(object)m_openBolt != (Object)null) { m_originalRearwardSpeed = m_openBolt.BoltSpeed_Rearward; } else if (m_boltType == BoltType.Closed && (Object)(object)m_closedBolt != (Object)null) { m_originalRearwardSpeed = m_closedBolt.Speed_Rearward; } } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); ToggleGasCutOffState(); } private void ToggleGasCutOffState() { if (m_isOpen) { Close(); } else { Open(); } } public override 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_00c5: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).FVRUpdate(); if (!(Mathf.Abs(m_tarRot - m_curRot) > 0.01f)) { return; } m_curRot = Mathf.MoveTowards(m_curRot, m_tarRot, Time.deltaTime * RotSpeed); if ((Object)(object)GasCutOffGeo != (Object)null) { Vector3 localEulerAngles = GasCutOffGeo.localEulerAngles; if (Axis == RotationAxis.X) { localEulerAngles.x = m_curRot; } else if (Axis == RotationAxis.Y) { localEulerAngles.y = m_curRot; } else if (Axis == RotationAxis.Z) { localEulerAngles.z = m_curRot; } GasCutOffGeo.localEulerAngles = localEulerAngles; } } private void Open() { //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (m_isOpen) { return; } m_isOpen = true; m_tarRot = OpenRot; RotSpeed = 1900f; if (m_boltType == BoltType.Open && (Object)(object)m_openBolt != (Object)null) { if (m_openBolt.BoltSpeed_Rearward > 0f) { m_originalRearwardSpeed = m_openBolt.BoltSpeed_Rearward; } m_openBolt.BoltSpeed_Rearward = 0f; } else if (m_boltType == BoltType.Closed && (Object)(object)m_closedBolt != (Object)null) { if (m_closedBolt.Speed_Rearward > 0f) { m_originalRearwardSpeed = m_closedBolt.Speed_Rearward; } m_closedBolt.Speed_Rearward = 0f; } FVRFireArm weapon = GetWeapon(); if ((Object)(object)weapon != (Object)null && AudEvent_CoverOpen != null) { weapon.PlayAudioAsHandling(AudEvent_CoverOpen, ((Component)this).transform.position); } } private void Close() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (m_isOpen) { m_isOpen = false; m_tarRot = ClosedRot; RotSpeed = 800f; if (m_boltType == BoltType.Open && (Object)(object)m_openBolt != (Object)null) { m_openBolt.BoltSpeed_Rearward = m_originalRearwardSpeed; } else if (m_boltType == BoltType.Closed && (Object)(object)m_closedBolt != (Object)null) { m_closedBolt.Speed_Rearward = m_originalRearwardSpeed; } FVRFireArm weapon = GetWeapon(); if ((Object)(object)weapon != (Object)null && AudEvent_CoverClose != null) { weapon.PlayAudioAsHandling(AudEvent_CoverClose, ((Component)this).transform.position); } } } private FVRFireArm GetWeapon() { if (m_boltType == BoltType.Open && (Object)(object)m_openBolt != (Object)null) { return (FVRFireArm)(object)m_openBolt.Receiver; } if (m_boltType == BoltType.Closed && (Object)(object)m_closedBolt != (Object)null) { return (FVRFireArm)(object)m_closedBolt.Weapon; } return null; } }