Decompiled source of M2 Flamethrower v1.0.0
M2_Flamethrower.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; 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 OpenScripts2; using OtherLoader; using UnityEngine; using UnityEngine.UI; using VolksScripts; [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 RealisticSpeedloader : Speedloader { public enum LoadingMode { InstantVanilla, RealisticGuidance } public enum ReleaseStyle { TwistToRelease, PushToRelease } [Header("Operation Mode")] [Tooltip("Choose between instant vanilla loading (InstantVanilla) or physical guided rail/twist insertion (RealisticGuidance).")] public LoadingMode OperationMode = LoadingMode.InstantVanilla; [Header("Debug Settings")] [Tooltip("Enables diagnostic telemetry logging in the Unity console.")] public bool EnableDebugLogging = false; [Header("Mechanical Configuration (Realistic Mode Only)")] [Tooltip("Whether the speedloader releases rounds by twisting the knob/wrist or pushing the body forward.")] public ReleaseStyle MechanicalReleaseStyle = ReleaseStyle.TwistToRelease; [Tooltip("If true, automatically ungrabs and drops the empty carrier to the floor after pulling it clear.")] public bool AutoDropCarrierOnEmpty = false; [Header("Guidance & Compliance Settings (Realistic Mode Only)")] [Tooltip("Maximum allowed angle in degrees between speedloader and cylinder to begin entry.")] public float EntryAngleCone = 35f; [Tooltip("Maximum allowed distance in meters from the cylinder face to catch the entry rail.")] public float EntryDistanceWindow = 0.12f; [Tooltip("Lateral play/wobble allowed at the mouth when bullet tips first touch.")] public float InitialLateralTolerance = 0.02f; [Tooltip("Distance the hand can pull away perpendicular to the cylinder before popping off the rail.")] public float BreakawayDistance = 0.06f; [Tooltip("Clockwise wrist rotation in degrees required to trip the twist release.")] public float TwistAngleRequired = 25f; [Tooltip("Forward hand speed required while seated to trip a push-release loader.")] public float PushSpeedRequired = 0.8f; [Tooltip("Visual animated knob or star that rotates when twisting.")] public Transform ReleaseKnob; [Tooltip("Visual animated plunger that depresses when pushed.")] public Transform ReleasePlunger; private RevolverCylinder _activeCylinder; private RevolvingShotgunTrigger _activeRSTrigger; private bool _isSeated; private bool _hasTrippedRelease; private float _insertionDepth; private float _initialHandRoll; private float _lastHapticDepth; private bool _isRestingInCylinder; private bool[] _lastChamberLoadedStates; [ContextMenu("Copy Settings From Base Speedloader")] public void CopySettingsFromBaseSpeedloader() { //IL_006d: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_017a: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: 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) Speedloader[] components = ((Component)this).GetComponents<Speedloader>(); Speedloader val = null; for (int i = 0; i < components.Length; i++) { if ((Object)(object)components[i] != (Object)(object)this && (object)((object)components[i]).GetType() == typeof(Speedloader)) { val = components[i]; break; } } if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"[RealisticSpeedloader] No original Speedloader component found on this GameObject to copy from!"); return; } ((FVRInteractiveObject)this).ControlType = ((FVRInteractiveObject)val).ControlType; ((FVRInteractiveObject)this).IsSimpleInteract = ((FVRInteractiveObject)val).IsSimpleInteract; ((FVRInteractiveObject)this).HandlingGrabSound = ((FVRInteractiveObject)val).HandlingGrabSound; ((FVRInteractiveObject)this).HandlingReleaseSound = ((FVRInteractiveObject)val).HandlingReleaseSound; ((FVRInteractiveObject)this).PoseOverride = ((FVRInteractiveObject)val).PoseOverride; ((FVRInteractiveObject)this).QBPoseOverride = ((FVRInteractiveObject)val).QBPoseOverride; ((FVRInteractiveObject)this).PoseOverride_Touch = ((FVRInteractiveObject)val).PoseOverride_Touch; ((FVRInteractiveObject)this).UseGrabPointChild = ((FVRInteractiveObject)val).UseGrabPointChild; ((FVRInteractiveObject)this).UseGripRotInterp = ((FVRInteractiveObject)val).UseGripRotInterp; ((FVRInteractiveObject)this).PositionInterpSpeed = ((FVRInteractiveObject)val).PositionInterpSpeed; ((FVRInteractiveObject)this).RotationInterpSpeed = ((FVRInteractiveObject)val).RotationInterpSpeed; ((FVRInteractiveObject)this).EndInteractionIfDistant = ((FVRInteractiveObject)val).EndInteractionIfDistant; ((FVRInteractiveObject)this).EndInteractionDistance = ((FVRInteractiveObject)val).EndInteractionDistance; ((FVRInteractiveObject)this).UXGeo_Hover = ((FVRInteractiveObject)val).UXGeo_Hover; ((FVRInteractiveObject)this).UXGeo_Held = ((FVRInteractiveObject)val).UXGeo_Held; ((FVRInteractiveObject)this).UseFilteredHandTransform = ((FVRInteractiveObject)val).UseFilteredHandTransform; ((FVRInteractiveObject)this).UseFilteredHandPosition = ((FVRInteractiveObject)val).UseFilteredHandPosition; ((FVRInteractiveObject)this).UseFilteredHandRotation = ((FVRInteractiveObject)val).UseFilteredHandRotation; ((FVRInteractiveObject)this).UseSecondStepRotationFiltering = ((FVRInteractiveObject)val).UseSecondStepRotationFiltering; ((FVRPhysicalObject)this).ObjectWrapper = ((FVRPhysicalObject)val).ObjectWrapper; ((FVRPhysicalObject)this).SpawnLockable = ((FVRPhysicalObject)val).SpawnLockable; ((FVRPhysicalObject)this).Harnessable = ((FVRPhysicalObject)val).Harnessable; ((FVRPhysicalObject)this).HandlingReleaseIntoSlotSound = ((FVRPhysicalObject)val).HandlingReleaseIntoSlotSound; ((FVRPhysicalObject)this).Size = ((FVRPhysicalObject)val).Size; ((FVRPhysicalObject)this).QBSlotType = ((FVRPhysicalObject)val).QBSlotType; ((FVRPhysicalObject)this).DoesReleaseOverrideVelocity = ((FVRPhysicalObject)val).DoesReleaseOverrideVelocity; ((FVRPhysicalObject)this).DoesReleaseAddVelocity = ((FVRPhysicalObject)val).DoesReleaseAddVelocity; ((FVRPhysicalObject)this).ThrowVelMultiplier = ((FVRPhysicalObject)val).ThrowVelMultiplier; ((FVRPhysicalObject)this).ThrowAngMultiplier = ((FVRPhysicalObject)val).ThrowAngMultiplier; ((FVRPhysicalObject)this).MoveIntensity = ((FVRPhysicalObject)val).MoveIntensity; ((FVRPhysicalObject)this).RotIntensity = ((FVRPhysicalObject)val).RotIntensity; ((FVRPhysicalObject)this).UsesGravity = ((FVRPhysicalObject)val).UsesGravity; ((FVRPhysicalObject)this).DependantRBs = ((FVRPhysicalObject)val).DependantRBs; ((FVRPhysicalObject)this).DistantGrabbable = ((FVRPhysicalObject)val).DistantGrabbable; ((FVRPhysicalObject)this).IsDebug = ((FVRPhysicalObject)val).IsDebug; ((FVRPhysicalObject)this).IsKinematicLocked = ((FVRPhysicalObject)val).IsKinematicLocked; ((FVRPhysicalObject)this).DoesQuickbeltSlotFollowHead = ((FVRPhysicalObject)val).DoesQuickbeltSlotFollowHead; ((FVRPhysicalObject)this).IsInWater = ((FVRPhysicalObject)val).IsInWater; ((FVRPhysicalObject)this).CollisionSound = ((FVRPhysicalObject)val).CollisionSound; ((FVRPhysicalObject)this).IsPickUpLocked = ((FVRPhysicalObject)val).IsPickUpLocked; ((FVRPhysicalObject)this).OverridesObjectToHand = ((FVRPhysicalObject)val).OverridesObjectToHand; base.SLType = val.SLType; if (val.Chambers != null) { base.Chambers = new List<SpeedloaderChamber>(val.Chambers); } base.ProfileOverride = val.ProfileOverride; base.IsPretendingToBeAMagazine = val.IsPretendingToBeAMagazine; base.forwardEjectionDisplacement = val.forwardEjectionDisplacement; base.InjectsOnInsertion = val.InjectsOnInsertion; base.CanManuallyEjectRounds = val.CanManuallyEjectRounds; base.IgnoreAlignmentCheck = val.IgnoreAlignmentCheck; Debug.Log((object)"[RealisticSpeedloader] Successfully copied all verified FVRInteractiveObject, FVRPhysicalObject, and Speedloader fields!"); } public override void Start() { ((Speedloader)this).Start(); if (base.Chambers == null || base.Chambers.Count <= 0) { return; } _lastChamberLoadedStates = new bool[base.Chambers.Count]; for (int i = 0; i < base.Chambers.Count; i++) { if ((Object)(object)base.Chambers[i] != (Object)null) { _lastChamberLoadedStates[i] = base.Chambers[i].IsLoaded; base.Chambers[i].UpdateViz(); } } } public override void UpdateInteraction(FVRViveHand hand) { if (OperationMode == LoadingMode.InstantVanilla) { ((Speedloader)this).UpdateInteraction(hand); return; } if (_isRestingInCylinder) { _isRestingInCylinder = false; ((FVRPhysicalObject)this).RootRigidbody.isKinematic = false; } if ((Object)(object)_activeCylinder != (Object)null && ((FVRInteractiveObject)_activeCylinder).IsInteractable()) { ProcessRailGuidance(hand, ((Component)_activeCylinder).transform, _activeCylinder.CartridgeLength); } else if ((Object)(object)_activeRSTrigger != (Object)null && (Object)(object)_activeRSTrigger.Shotgun != (Object)null && ((FVRFireArm)_activeRSTrigger.Shotgun).EjectDelay <= 0f && !_activeRSTrigger.Shotgun.CylinderLoaded) { ProcessRailGuidance(hand, ((Component)_activeRSTrigger).transform, 0.05f); } else { ((Speedloader)this).UpdateInteraction(hand); } } public override void EndInteraction(FVRViveHand hand) { if (OperationMode == LoadingMode.RealisticGuidance && (Object)(object)_activeCylinder != (Object)null && !_hasTrippedRelease) { float cartridgeLength = _activeCylinder.CartridgeLength; if (_insertionDepth >= cartridgeLength * 0.25f) { _isRestingInCylinder = true; ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).EndInteraction(hand); return; } DetachFromCylinder(); } ((FVRPhysicalObject)this).EndInteraction(hand); } public override void FVRFixedUpdate() { ((Speedloader)this).FVRFixedUpdate(); if (OperationMode == LoadingMode.RealisticGuidance && _isRestingInCylinder && (Object)(object)_activeCylinder != (Object)null && !((FVRInteractiveObject)_activeCylinder).IsInteractable()) { _isRestingInCylinder = false; ((FVRPhysicalObject)this).RootRigidbody.isKinematic = false; DetachFromCylinder(); } } public override void FVRUpdate() { ((Speedloader)this).FVRUpdate(); if (base.Chambers == null || _lastChamberLoadedStates == null) { return; } for (int i = 0; i < base.Chambers.Count; i++) { if ((Object)(object)base.Chambers[i] != (Object)null && i < _lastChamberLoadedStates.Length && base.Chambers[i].IsLoaded != _lastChamberLoadedStates[i]) { _lastChamberLoadedStates[i] = base.Chambers[i].IsLoaded; base.Chambers[i].UpdateViz(); } } } public void OnTriggerEnter(Collider c) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((FVRPhysicalObject)this).QuickbeltSlot != (Object)null) { return; } RevolverCylinder val = ((Component)c).GetComponent<RevolverCylinder>(); if ((Object)(object)val == (Object)null) { val = ((Component)c).GetComponentInParent<RevolverCylinder>(); } if ((Object)(object)val == (Object)null) { val = ((Component)c).GetComponentInChildren<RevolverCylinder>(); } if ((Object)(object)val != (Object)null && ((FVRInteractiveObject)val).IsInteractable() && (Object)(object)val.Revolver != (Object)null && ((FVRFireArm)val.Revolver).RoundType == base.Chambers[0].Type) { if (!IsCylinderClear(val)) { if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { ((FVRInteractiveObject)this).m_hand.Buzz(((FVRInteractiveObject)this).m_hand.Buzzer.Buzz_BeginInteraction); } ((FVRFireArm)val.Revolver).PlayAudioEvent((FirearmAudioEventType)6, 0.8f); return; } if (OperationMode == LoadingMode.InstantVanilla) { _activeCylinder = val; ExecuteRoundDischarge(((FVRInteractiveObject)this).m_hand); return; } Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; float num = Vector3.Angle(((Component)this).transform.forward, ((Component)val).transform.forward); if (num <= EntryAngleCone && ((Vector3)(ref val2)).magnitude <= EntryDistanceWindow) { AttachToCylinder(val); } return; } RevolvingShotgunTrigger val3 = ((Component)c).GetComponent<RevolvingShotgunTrigger>(); if ((Object)(object)val3 == (Object)null) { val3 = ((Component)c).GetComponentInParent<RevolvingShotgunTrigger>(); } if ((Object)(object)val3 == (Object)null) { val3 = ((Component)c).GetComponentInChildren<RevolvingShotgunTrigger>(); } if (!((Object)(object)val3 != (Object)null) || !((Object)(object)val3.Shotgun != (Object)null)) { return; } bool flag = ((Component)c).gameObject.CompareTag("FVRFireArmReloadTriggerWell") || ((Component)val3).gameObject.CompareTag("FVRFireArmReloadTriggerWell"); bool flag2 = ((FVRFireArm)val3.Shotgun).RoundType == base.Chambers[0].Type; bool flag3 = base.SLType == val3.Shotgun.SLType; bool flag4 = !val3.Shotgun.CylinderLoaded; bool flag5 = ((FVRFireArm)val3.Shotgun).EjectDelay <= 0f; if (!flag || !flag2 || !flag3 || !flag4 || !flag5) { return; } if (OperationMode == LoadingMode.InstantVanilla) { _activeRSTrigger = val3; ExecuteRoundDischarge(((FVRInteractiveObject)this).m_hand); return; } Vector3 val4 = ((Component)val3).transform.position - ((Component)this).transform.position; float num2 = Vector3.Angle(((Component)this).transform.forward, ((Component)val3).transform.forward); if (num2 <= EntryAngleCone && ((Vector3)(ref val4)).magnitude <= EntryDistanceWindow) { AttachToRSTrigger(val3); } } public void OnTriggerExit(Collider c) { if (OperationMode == LoadingMode.InstantVanilla) { return; } RevolverCylinder val = ((Component)c).GetComponent<RevolverCylinder>(); if ((Object)(object)val == (Object)null) { val = ((Component)c).GetComponentInParent<RevolverCylinder>(); } if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)_activeCylinder && !_isRestingInCylinder && _insertionDepth <= 0.005f) { DetachFromCylinder(); return; } RevolvingShotgunTrigger val2 = ((Component)c).GetComponent<RevolvingShotgunTrigger>(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)c).GetComponentInParent<RevolvingShotgunTrigger>(); } if ((Object)(object)val2 != (Object)null && (Object)(object)val2 == (Object)(object)_activeRSTrigger && _insertionDepth <= 0.005f) { DetachFromCylinder(); } } private void AttachToCylinder(RevolverCylinder cylinder) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) _activeCylinder = cylinder; _activeRSTrigger = null; _isSeated = false; _hasTrippedRelease = false; _insertionDepth = 0f; _lastHapticDepth = 0f; if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { _initialHandRoll = ((Component)((FVRInteractiveObject)this).m_hand).transform.localEulerAngles.z; ((FVRInteractiveObject)this).m_hand.Buzz(((FVRInteractiveObject)this).m_hand.Buzzer.Buzz_BeginInteraction); } if ((Object)(object)cylinder.Revolver != (Object)null) { ((FVRFireArm)cylinder.Revolver).PlayAudioEvent((FirearmAudioEventType)9, 1.2f); } } private void AttachToRSTrigger(RevolvingShotgunTrigger rsTrigger) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) _activeRSTrigger = rsTrigger; _activeCylinder = null; _isSeated = false; _hasTrippedRelease = false; _insertionDepth = 0f; _lastHapticDepth = 0f; if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { _initialHandRoll = ((Component)((FVRInteractiveObject)this).m_hand).transform.localEulerAngles.z; ((FVRInteractiveObject)this).m_hand.Buzz(((FVRInteractiveObject)this).m_hand.Buzzer.Buzz_BeginInteraction); } if ((Object)(object)rsTrigger.Shotgun != (Object)null) { ((FVRFireArm)rsTrigger.Shotgun).PlayAudioEvent((FirearmAudioEventType)9, 1.2f); } } private void DetachFromCylinder() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) _activeCylinder = null; _activeRSTrigger = null; _isSeated = false; _hasTrippedRelease = false; _insertionDepth = 0f; if ((Object)(object)ReleaseKnob != (Object)null) { ReleaseKnob.localEulerAngles = Vector3.zero; } if ((Object)(object)ReleasePlunger != (Object)null) { ReleasePlunger.localPosition = Vector3.zero; } } private void ProcessRailGuidance(FVRViveHand hand, Transform targetTransform, float maxDepth) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_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_0056: 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_0060: 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_0063: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_0103: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) Vector3 position = targetTransform.position; Vector3 forward = targetTransform.forward; Vector3 pos = ((HandInput)(ref hand.Input)).Pos; Vector3 val = pos - position; float num = Vector3.Dot(val, forward); _insertionDepth = Mathf.Clamp(num, 0f, maxDepth); float num2 = Mathf.Clamp01(_insertionDepth / maxDepth); Vector3 val2 = position + forward * _insertionDepth; Vector3 val3 = pos - (position + forward * Vector3.Dot(val, forward)); if (((Vector3)(ref val3)).magnitude > BreakawayDistance && !_hasTrippedRelease) { DetachFromCylinder(); hand.Buzz(((FVRInteractiveObject)this).m_hand.Buzzer.Buzz_BeginInteraction); return; } float num3 = Mathf.Lerp(InitialLateralTolerance, 0.001f, num2); Vector3 position2 = val2 + Vector3.ClampMagnitude(val3, num3); Quaternion rotation = targetTransform.rotation; float num4 = Mathf.Lerp(12f, 0f, num2); ((Component)this).transform.position = position2; ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)hand).transform.rotation, rotation, 180f - num4); if (Mathf.Abs(_insertionDepth - _lastHapticDepth) > 0.008f) { _lastHapticDepth = _insertionDepth; hand.Buzz(((FVRInteractiveObject)this).m_hand.Buzzer.Buzz_BeginInteraction); } _isSeated = num2 >= 0.96f; if (_isSeated && !_hasTrippedRelease) { EvaluateReleaseMechanism(hand, targetTransform); } if (_hasTrippedRelease && _insertionDepth <= 0.005f) { FVRViveHand hand2 = ((FVRInteractiveObject)this).m_hand; DetachFromCylinder(); if ((Object)(object)base.ProfileOverride != (Object)null) { SM.PlayGenericSound(base.ProfileOverride.MagazineEjectRound, ((Component)this).transform.position); } if (AutoDropCarrierOnEmpty && (Object)(object)hand2 != (Object)null) { hand2.ForceSetInteractable((FVRInteractiveObject)null); } } } private void EvaluateReleaseMechanism(FVRViveHand hand, Transform targetTransform) { //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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) bool flag = false; if (MechanicalReleaseStyle == ReleaseStyle.TwistToRelease) { float z = ((Component)hand).transform.localEulerAngles.z; float num = Mathf.DeltaAngle(_initialHandRoll, z); if ((Object)(object)ReleaseKnob != (Object)null) { ReleaseKnob.localEulerAngles = new Vector3(0f, 0f, Mathf.Clamp(num, 0f, TwistAngleRequired)); } if (num >= TwistAngleRequired) { flag = true; } if (hand.IsInStreamlinedMode && hand.Input.AXButtonDown) { flag = true; } else if (!hand.IsInStreamlinedMode && hand.Input.TouchpadDown) { flag = true; } } else if (MechanicalReleaseStyle == ReleaseStyle.PushToRelease) { float num2 = Vector3.Dot(hand.Input.VelLinearWorld, targetTransform.forward); if ((Object)(object)ReleasePlunger != (Object)null) { float num3 = Mathf.Clamp(num2 * 0.02f, 0f, 0.012f); ReleasePlunger.localPosition = new Vector3(0f, 0f, num3); } if (num2 >= PushSpeedRequired) { flag = true; } } if (flag) { ExecuteRoundDischarge(hand); } } private void ExecuteRoundDischarge(FVRViveHand hand) { _hasTrippedRelease = true; if ((Object)(object)hand != (Object)null) { hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); } if ((Object)(object)_activeCylinder != (Object)null) { if ((Object)(object)_activeCylinder.Revolver != (Object)null) { ((FVRFireArm)_activeCylinder.Revolver).PlayAudioEvent((FirearmAudioEventType)20, 1f); } _activeCylinder.LoadFromSpeedLoader((Speedloader)(object)this); } else if ((Object)(object)_activeRSTrigger != (Object)null && (Object)(object)_activeRSTrigger.Shotgun != (Object)null) { _activeRSTrigger.Shotgun.LoadCylinder((Speedloader)(object)this); Object.Destroy((Object)(object)((Component)this).gameObject); } } private bool IsCylinderClear(RevolverCylinder cylinder) { if ((Object)(object)cylinder == (Object)null || (Object)(object)cylinder.Revolver == (Object)null || cylinder.Revolver.Chambers == null) { return false; } for (int i = 0; i < cylinder.Revolver.Chambers.Length; i++) { if ((Object)(object)cylinder.Revolver.Chambers[i] != (Object)null && cylinder.Revolver.Chambers[i].IsFull) { return false; } } return true; } } namespace VolksScripts { public class Remington1858 : FVRFireArm { public enum ComparisonType { GreaterThan, LessThan, EqualTo } [Header("Debugging")] public bool DebugLogging = false; [Header("Latch Configuration")] [Tooltip("The Transform representing the latch's moving mesh.")] public Transform LatchTransform; public bool LatchUsesRotation = true; public Axis LatchAxis = (Axis)0; public ComparisonType LatchOpenComparison = ComparisonType.GreaterThan; public float LatchOpenThreshold = 15f; public float LatchTolerance = 5f; [Header("Rod Configuration")] [Tooltip("The Transform representing the rod/pin's moving mesh.")] public Transform RodTransform; public bool RodUsesRotation = false; public Axis RodAxis = (Axis)2; public ComparisonType RodOpenComparison = ComparisonType.GreaterThan; public float RodOpenThreshold = 0.08f; public ComparisonType RodClosedComparison = ComparisonType.LessThan; public float RodClosedThreshold = 0.02f; public float RodTolerance = 0.01f; [Header("Colliders to Control")] [Tooltip("The grab collider on the loading rod. Locked until the Latch is pulled open.")] public Collider RodCollider; [Tooltip("The trigger collider on the gun frame that detects the physical cylinder (Speedloader). Enabled only when the Rod is open.")] public Collider CylinderReloadTrigger; [Header("Cylinder Configuration")] public bool CylinderLoaded = true; public Transform ProxyCylinder; public bool DoesCylinderRotate = true; public bool IsCylinderRotClockwise = true; public int NumChambers = 6; public FVRFireArmChamber[] Chambers; public GameObject CylinderPrefab; public Transform CylinderMountPoint; [Header("Single Action Components")] public Transform Hammer; public Transform Trigger; public Transform HammerFanDir; [Header("Component Rotation Values")] public float Hammer_Rot_Uncocked = 0f; public float Hammer_Rot_Cocked = -49f; public float Trigger_Rot_Forward = 0f; public float Trigger_Rot_Rearward = 30f; public float TriggerThreshold = 0.9f; private float m_triggerFloat; private bool m_hasTriggerReset = true; private bool m_isHammerCocked = false; private bool m_isHammerCocking = false; private float m_hammerCockLerp; private float m_hammerCockSpeed = 10f; private bool m_hasTriggerCycled; private bool m_shouldRecock; private float m_triggerCurrentRot; private float lastTriggerRot; private int m_curChamber; private float m_tarChamberLerp; private float m_curChamberLerp; private bool m_lastLatchOpen; private bool m_lastRodOpen; private bool m_lastRodAtHome; private bool m_hasEjectedThisPull = false; public override void Awake() { ((FVRFireArm)this).Awake(); if (Chambers != null) { for (int i = 0; i < Chambers.Length; i++) { if ((Object)(object)Chambers[i] != (Object)null) { base.FChambers.Add(Chambers[i]); } } } if ((Object)(object)ProxyCylinder != (Object)null) { ((Component)ProxyCylinder).gameObject.SetActive(CylinderLoaded); } } public override void FVRUpdate() { //IL_003c: 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) ((FVRFireArm)this).FVRUpdate(); if ((Object)(object)LatchTransform == (Object)null || (Object)(object)RodTransform == (Object)null) { return; } float value = GetValue(LatchTransform, LatchUsesRotation, LatchAxis); float value2 = GetValue(RodTransform, RodUsesRotation, RodAxis); bool flag = EvaluateState(value, LatchOpenThreshold, LatchOpenComparison); bool flag2 = EvaluateState(value2, RodOpenThreshold, RodOpenComparison); bool flag3 = EvaluateState(value2, RodClosedThreshold, RodClosedComparison); if (DebugLogging) { if (flag != m_lastLatchOpen) { m_lastLatchOpen = flag; Debug.Log((object)("Remington1858: Latch Open State Changed to: " + flag + " (Value: " + value + ")")); } if (flag2 != m_lastRodOpen) { m_lastRodOpen = flag2; Debug.Log((object)("Remington1858: Rod Open State Changed to: " + flag2 + " (Value: " + value2 + ")")); } if (flag3 != m_lastRodAtHome) { m_lastRodAtHome = flag3; Debug.Log((object)("Remington1858: Rod At Home State Changed to: " + flag3 + " (Value: " + value2 + ")")); } } if (flag) { if ((Object)(object)RodCollider != (Object)null && !RodCollider.enabled) { RodCollider.enabled = true; LogDebug("Latch is open. Rod is now unlocked."); } } else if (flag3 && (Object)(object)RodCollider != (Object)null && RodCollider.enabled) { RodCollider.enabled = false; LogDebug("Latch is closed. Rod is now locked."); } if ((Object)(object)CylinderReloadTrigger != (Object)null && CylinderReloadTrigger.enabled != flag2) { CylinderReloadTrigger.enabled = flag2; } if (flag2) { if (CylinderLoaded && !m_hasEjectedThisPull) { PerformCylinderEjection(); m_hasEjectedThisPull = true; } } else { m_hasEjectedThisPull = false; } } public override void UpdateInteraction(FVRViveHand hand) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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) ((FVRPhysicalObject)this).UpdateInteraction(hand); if (((FVRPhysicalObject)this).IsAltHeld) { return; } Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.IsInStreamlinedMode) { if (hand.Input.AXButtonDown && !m_isHammerCocked && !m_isHammerCocking) { CockHammer(10f); } } else if (hand.Input.TouchpadDown && Vector2.Angle(touchpadAxes, Vector2.down) < 45f && !m_isHammerCocked && !m_isHammerCocking) { CockHammer(5f); } if (((FVRInteractiveObject)this).IsHeld && !m_isHammerCocked && !m_isHammerCocking && (Object)(object)hand.OtherHand != (Object)null) { Vector3 velLinearWorld = hand.OtherHand.Input.VelLinearWorld; float num = Vector3.Distance(hand.OtherHand.PalmTransform.position, HammerFanDir.position); if (num < 0.15f && Vector3.Angle(velLinearWorld, HammerFanDir.forward) < 60f && ((Vector3)(ref velLinearWorld)).magnitude > 1f) { CockHammer(10f); } } UpdateTriggerHammer(); UpdateCylinderRot(); } private void CockHammer(float speed) { if (!m_isHammerCocked && !m_isHammerCocking) { m_hammerCockSpeed = speed; m_isHammerCocking = true; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)7, 1f); } } private void DropHammer() { if (m_isHammerCocked) { m_isHammerCocked = false; m_isHammerCocking = false; m_hammerCockLerp = 0f; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f); TryFireActiveChamber(); } } private void TryFireActiveChamber() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if (CylinderLoaded && Chambers[m_curChamber].IsFull && !Chambers[m_curChamber].IsSpent) { Chambers[m_curChamber].Fire(); FVRFireArmChamber val = Chambers[m_curChamber]; Transform muzzle = ((FVRFireArm)this).GetMuzzle(); ((FVRFireArm)this).Fire(val, muzzle, true, 1f, -1f); ((FVRFireArm)this).FireMuzzleSmoke(); bool flag = ((FVRFireArm)this).IsTwoHandStabilized(); bool flag2 = (Object)(object)((FVRPhysicalObject)this).AltGrip != (Object)null; bool flag3 = ((FVRFireArm)this).IsShoulderStabilized(); ((FVRFireArm)this).Recoil(flag, flag2, flag3, (FVRFireArmRecoilProfile)null, 1f); ((FVRFireArm)this).PlayAudioGunShot(val.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f); if (GM.CurrentSceneSettings.IsAmmoInfinite || GM.CurrentPlayerBody.IsInfiniteAmmo) { val.IsSpent = false; val.UpdateProxyDisplay(); } else { val.SetRound((FVRFireArmRound)null, false); } } } private void UpdateTriggerHammer() { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) if (m_isHammerCocking) { if (m_hammerCockLerp < 1f) { m_hammerCockLerp += Time.deltaTime * m_hammerCockSpeed; } else { m_hammerCockLerp = 1f; m_isHammerCocking = false; m_isHammerCocked = true; if (IsCylinderRotClockwise) { m_curChamber = (m_curChamber + 1) % NumChambers; } else { m_curChamber--; if (m_curChamber < 0) { m_curChamber = NumChambers - 1; } } m_curChamberLerp = 0f; m_tarChamberLerp = 0f; } } if ((Object)(object)Hammer != (Object)null) { Hammer.localEulerAngles = new Vector3(Mathf.Lerp(Hammer_Rot_Uncocked, Hammer_Rot_Cocked, m_hammerCockLerp), 0f, 0f); } m_triggerFloat = 0f; if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin) { m_triggerFloat = ((FVRInteractiveObject)this).m_hand.Input.TriggerFloat; } if ((Object)(object)Trigger != (Object)null) { Trigger.localEulerAngles = new Vector3(Mathf.Lerp(Trigger_Rot_Forward, Trigger_Rot_Rearward, m_triggerFloat), 0f, 0f); } if (m_triggerFloat > TriggerThreshold) { DropHammer(); } } private void UpdateCylinderRot() { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (m_isHammerCocking) { m_tarChamberLerp = m_hammerCockLerp; } else { m_tarChamberLerp = 0f; } m_curChamberLerp = Mathf.Lerp(m_curChamberLerp, m_tarChamberLerp, Time.deltaTime * 16f); int cylinder = ((!IsCylinderRotClockwise) ? ((m_curChamber - 1) % NumChambers) : ((m_curChamber + 1) % NumChambers)); if (DoesCylinderRotate && (Object)(object)ProxyCylinder != (Object)null) { ProxyCylinder.localRotation = Quaternion.Slerp(GetLocalRotationFromCylinder(m_curChamber), GetLocalRotationFromCylinder(cylinder), m_curChamberLerp); } } public bool LoadCylinder(Speedloader s) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (CylinderLoaded || (Object)(object)s == (Object)null) { return false; } CylinderLoaded = true; if ((Object)(object)ProxyCylinder != (Object)null) { ((Component)ProxyCylinder).gameObject.SetActive(true); ProxyCylinder.localRotation = GetLocalRotationFromCylinder(m_curChamber); } ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)20, 1f); m_curChamber = 0; for (int i = 0; i < Chambers.Length; i++) { if (i < s.Chambers.Count && s.Chambers[i].IsLoaded) { Chambers[i].Autochamber(s.Chambers[i].LoadedClass); Chambers[i].IsSpent = s.Chambers[i].IsSpent; } else { Chambers[i].Unload(); } Chambers[i].UpdateProxyDisplay(); } return true; } public void PerformCylinderEjection() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)CylinderPrefab == (Object)null || (Object)(object)CylinderMountPoint == (Object)null) { return; } LogDebug("Auto-ejecting cylinder..."); GameObject val = Object.Instantiate<GameObject>(CylinderPrefab, CylinderMountPoint.position, CylinderMountPoint.rotation); Speedloader component = val.GetComponent<Speedloader>(); ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)21, 1f); Rigidbody component2 = val.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.velocity = -((Component)this).transform.forward * 0.5f; } for (int i = 0; i < component.Chambers.Count; i++) { if (i < Chambers.Length) { if (!Chambers[i].IsFull) { component.Chambers[i].Unload(); } else { component.Chambers[i].Load(Chambers[i].GetRound().RoundClass, false); component.Chambers[i].IsSpent = Chambers[i].IsSpent; } Chambers[i].SetRound((FVRFireArmRound)null, false); Chambers[i].UpdateProxyDisplay(); } component.Chambers[i].UpdateViz(); } CylinderLoaded = false; if ((Object)(object)ProxyCylinder != (Object)null) { ((Component)ProxyCylinder).gameObject.SetActive(false); } } private void OnTriggerEnter(Collider other) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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) float value = GetValue(RodTransform, RodUsesRotation, RodAxis); bool flag = EvaluateState(value, RodOpenThreshold, RodOpenComparison); if (CylinderLoaded || !flag) { return; } Speedloader component = ((Component)other).GetComponent<Speedloader>(); if ((Object)(object)component == (Object)null && (Object)(object)other.attachedRigidbody != (Object)null) { component = ((Component)other.attachedRigidbody).GetComponent<Speedloader>(); } if ((Object)(object)component != (Object)null && component.Chambers[0].Type == base.RoundType) { if (((FVRInteractiveObject)component).IsHeld) { ((FVRInteractiveObject)component).EndInteraction(((FVRInteractiveObject)component).m_hand); } LoadCylinder(component); Object.Destroy((Object)(object)((Component)component).gameObject); } } public override List<FireArmRoundClass> GetChamberRoundList() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) bool flag = false; List<FireArmRoundClass> list = new List<FireArmRoundClass>(); for (int i = 0; i < Chambers.Length; i++) { if (Chambers[i].IsFull) { list.Add(Chambers[i].GetRound().RoundClass); flag = true; } } return (!flag) ? null : list; } public override void SetLoadedChambers(List<FireArmRoundClass> rounds) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (rounds.Count <= 0) { return; } for (int i = 0; i < Chambers.Length; i++) { if (i < rounds.Count) { Chambers[i].Autochamber(rounds[i]); } } } public Quaternion GetLocalRotationFromCylinder(int cylinder) { //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) float num = (float)cylinder * (360f / (float)NumChambers) * -1f; num = Mathf.Repeat(num, 360f); return Quaternion.Euler(new Vector3(0f, 0f, num)); } private float GetValue(Transform t, bool usesRotation, Axis axis) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0036: 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_003e: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 if ((Object)(object)t == (Object)null) { return 0f; } Vector3 val = ((!usesRotation) ? t.localPosition : t.localEulerAngles); float num = 0f; if ((int)axis != 0) { if ((int)axis != 1) { if ((int)axis == 2) { num = val.z; } } else { num = val.y; } } else { num = val.x; } if (usesRotation && num > 180f) { num -= 360f; } return num; } private bool EvaluateState(float value, float threshold, ComparisonType comp) { return comp switch { ComparisonType.GreaterThan => value > threshold, ComparisonType.LessThan => value < threshold, ComparisonType.EqualTo => Mathf.Abs(value - threshold) <= 0.01f, _ => false, }; } private void LogDebug(string message) { if (DebugLogging) { Debug.Log((object)("Remington1858: " + message)); } } } } public class RemingtonCylinderController : MonoBehaviour { public enum ComparisonType { GreaterThan, LessThan, EqualTo } [Header("Debugging")] public bool DebugLogging = false; [Header("Core Weapon Reference")] public Revolver Weapon; [Header("Latch Configuration")] [Tooltip("The Transform representing the latch's moving mesh.")] public Transform LatchTransform; public bool LatchUsesRotation = true; public Axis LatchAxis = (Axis)0; public ComparisonType LatchOpenComparison = ComparisonType.GreaterThan; public float LatchOpenThreshold = 15f; [Header("Rod Configuration")] [Tooltip("The Transform representing the rod/pin's moving mesh.")] public Transform RodTransform; public bool RodUsesRotation = false; public Axis RodAxis = (Axis)2; public ComparisonType RodOpenComparison = ComparisonType.GreaterThan; public float RodOpenThreshold = 0.08f; public ComparisonType RodClosedComparison = ComparisonType.LessThan; public float RodClosedThreshold = 0.02f; [Header("Colliders to Control")] [Tooltip("The grab collider on the loading rod. Locked until the Latch is pulled open.")] public Collider RodCollider; [Header("Cylinder Spawn Configuration")] [Tooltip("The Item ID of your spare cylinder in the item database (IM.OD).")] public string DefaultCylinderPrefabID; [Header("Current State Tracker")] public bool IsCylinderLoaded = true; private FieldInfo m_isCylinderArmLockedField; private FieldInfo m_wasCylinderArmLockedField; private FieldInfo m_hasEjectedSinceOpeningField; private FieldInfo m_isCylinderReleasePressedField; private bool m_lastLatchOpen; private bool m_lastRodOpen; private bool m_lastRodAtHome; private bool m_hasEjectedThisPull = false; private void Start() { if ((Object)(object)Weapon == (Object)null) { Weapon = ((Component)this).GetComponent<Revolver>(); } if ((Object)(object)Weapon != (Object)null) { try { m_isCylinderArmLockedField = typeof(Revolver).GetField("m_isCylinderArmLocked", BindingFlags.Instance | BindingFlags.NonPublic); m_wasCylinderArmLockedField = typeof(Revolver).GetField("m_wasCylinderArmLocked", BindingFlags.Instance | BindingFlags.NonPublic); m_hasEjectedSinceOpeningField = typeof(Revolver).GetField("m_hasEjectedSinceOpening", BindingFlags.Instance | BindingFlags.NonPublic); m_isCylinderReleasePressedField = typeof(Revolver).GetField("m_isCylinderReleasePressed", BindingFlags.Instance | BindingFlags.NonPublic); LogDebug("Successfully bound reflection fields for Revolver states."); } catch (Exception ex) { Debug.LogError((object)("RemingtonCylinderController: Failed to bind reflection fields! " + ex.Message)); } } } private void Update() { //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Weapon == (Object)null || (Object)(object)LatchTransform == (Object)null || (Object)(object)RodTransform == (Object)null) { return; } if ((object)m_isCylinderReleasePressedField != null) { m_isCylinderReleasePressedField.SetValue(Weapon, false); } if (!IsCylinderLoaded && (Object)(object)Weapon.Cylinder != (Object)null && Weapon.Cylinder.HasSpeedLoadedIn) { IsCylinderLoaded = true; if ((object)m_isCylinderArmLockedField != null && (object)m_wasCylinderArmLockedField != null && (object)m_hasEjectedSinceOpeningField != null) { m_isCylinderArmLockedField.SetValue(Weapon, true); m_wasCylinderArmLockedField.SetValue(Weapon, true); m_hasEjectedSinceOpeningField.SetValue(Weapon, false); if ((Object)(object)Weapon.CylinderArm != (Object)null) { Weapon.CylinderArm.localEulerAngles = Vector3.zero; } ((Component)Weapon.Cylinder).transform.localRotation = Quaternion.identity; SetChambersAccessible(accessible: false); LogDebug("Cylinder inserted. Instantly locked and aligned."); } } float value = GetValue(LatchTransform, LatchUsesRotation, LatchAxis); float value2 = GetValue(RodTransform, RodUsesRotation, RodAxis); bool flag = EvaluateState(value, LatchOpenThreshold, LatchOpenComparison); bool flag2 = EvaluateState(value2, RodOpenThreshold, RodOpenComparison); bool flag3 = EvaluateState(value2, RodClosedThreshold, RodClosedComparison); if (DebugLogging) { if (flag != m_lastLatchOpen) { m_lastLatchOpen = flag; Debug.Log((object)("RemingtonCylinderController: Latch Open State Changed to: " + flag + " (Value: " + value + ")")); } if (flag2 != m_lastRodOpen) { m_lastRodOpen = flag2; Debug.Log((object)("RemingtonCylinderController: Rod Open State Changed to: " + flag2 + " (Value: " + value2 + ")")); } if (flag3 != m_lastRodAtHome) { m_lastRodAtHome = flag3; Debug.Log((object)("RemingtonCylinderController: Rod At Home State Changed to: " + flag3 + " (Value: " + value2 + ")")); } } if (flag) { if ((Object)(object)RodCollider != (Object)null && !RodCollider.enabled) { RodCollider.enabled = true; LogDebug("Latch is open. Rod is now unlocked."); } } else if (flag3 && (Object)(object)RodCollider != (Object)null && RodCollider.enabled) { RodCollider.enabled = false; LogDebug("Latch is closed. Rod is now locked."); } if (flag2) { if (IsCylinderLoaded && !m_hasEjectedThisPull) { PerformCylinderEjection(); m_hasEjectedThisPull = true; } } else { m_hasEjectedThisPull = false; } } private void PerformCylinderEjection() { //IL_0102: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Weapon == (Object)null || (Object)(object)Weapon.Cylinder == (Object)null) { return; } LogDebug("Rod opened. Auto-ejecting cylinder..."); if (string.IsNullOrEmpty(Weapon.Cylinder.SpeedLoaderID)) { Weapon.Cylinder.SpeedLoaderID = DefaultCylinderPrefabID; } if ((object)m_isCylinderArmLockedField != null && (object)m_wasCylinderArmLockedField != null && (object)m_hasEjectedSinceOpeningField != null) { m_isCylinderArmLockedField.SetValue(Weapon, false); m_wasCylinderArmLockedField.SetValue(Weapon, false); m_hasEjectedSinceOpeningField.SetValue(Weapon, true); if ((Object)(object)Weapon.CylinderArm != (Object)null) { Weapon.CylinderArm.localEulerAngles = new Vector3(0f, 0f, 45f); } SetChambersAccessible(accessible: true); } Weapon.EjectChambers(); IsCylinderLoaded = false; } private void SetChambersAccessible(bool accessible) { if ((Object)(object)Weapon == (Object)null || Weapon.Chambers == null) { return; } for (int i = 0; i < Weapon.Chambers.Length; i++) { if ((Object)(object)Weapon.Chambers[i] != (Object)null) { Weapon.Chambers[i].IsAccessible = accessible; } } } private float GetValue(Transform t, bool usesRotation, Axis axis) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0036: 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_003e: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 if ((Object)(object)t == (Object)null) { return 0f; } Vector3 val = ((!usesRotation) ? t.localPosition : t.localEulerAngles); float num = 0f; if ((int)axis != 0) { if ((int)axis != 1) { if ((int)axis == 2) { num = val.z; } } else { num = val.y; } } else { num = val.x; } if (usesRotation && num > 180f) { num -= 360f; } return num; } private bool EvaluateState(float value, float threshold, ComparisonType comp) { return comp switch { ComparisonType.GreaterThan => value > threshold, ComparisonType.LessThan => value < threshold, ComparisonType.EqualTo => Mathf.Abs(value - threshold) <= 0.01f, _ => false, }; } private void LogDebug(string message) { if (DebugLogging) { Debug.Log((object)("RemingtonCylinderController: " + message)); } } } public class SARevolverWithCylinderChange : RevolvingShotgun { [Header("Debug Settings")] [Tooltip("Enables diagnostic telemetry logging in the Unity console.")] public bool EnableDebugLogging = false; [Header("Physical Transforms")] [Tooltip("The loading lever or cylinder pin transform that slides forward and rearward.")] public Transform EjectorRod; [Tooltip("The grab collider on the ejector rod. If unassigned, will be searched automatically.")] public Collider EjectorRodCollider; [Tooltip("The locking latch transform that rotates open and closed.")] public Transform CylinderLatch; [Tooltip("The grab collider on the cylinder latch. If unassigned, will be searched automatically.")] public Collider CylinderLatchCollider; [Tooltip("The GameObject or RevolvingShotgunTrigger collider that the player grabs to eject the cylinder.")] public GameObject CylinderEjectTrigger; [Tooltip("Optional explicit reload well trigger GameObject tagged FVRFireArmReloadTriggerWell.")] public GameObject CylinderLoadTrigger; [Header("Single Action Configuration")] [Tooltip("Transform representing the hammer component.")] public Transform Hammer; [Tooltip("Transform used for offhand palm fanning detection. Palm must move across this forward vector.")] public Transform HammerFanDir; [Tooltip("Pivot transform used when spinning the revolver around the trigger guard.")] public Transform PoseSpinHolder; [Tooltip("Allows the weapon to be spun around the trigger finger.")] public bool CanSpin = true; [Tooltip("Time in seconds the trigger must be held while uncocked to initiate a gun spin.")] public float TriggerSpinHoldTime = 0.5f; [Tooltip("Rotation angle of the hammer when fully uncocked and resting on a chamber.")] public float Hammer_Rot_Uncocked = 0f; [Tooltip("Rotation angle of the hammer when held at half-cock for safety and loading.")] public float Hammer_Rot_Halfcocked = -35f; [Tooltip("Rotation angle of the hammer when fully cocked and ready to fire.")] public float Hammer_Rot_Cocked = -75f; [Tooltip("Trigger pull threshold required to drop the hammer.")] public float TriggerThreshold = 0.9f; [Tooltip("If true, the hammer must be strictly at half-cock to eject or insert a cylinder.")] public bool RequireHalfCockToReload = true; [Header("Decocking Settings")] [Tooltip("Time in seconds the decock input must be held to ease the hammer down to uncocked.")] public float DecockHoldTime = 0.4f; [Tooltip("Speed in degrees per second at which the hammer visually lowers when eased down.")] public float DecockEaseSpeed = 120f; [Header("Spinning Audio Configuration")] [Tooltip("Custom audio clip played once per full revolution while spinning (whoosh sound).")] public AudioClip SpinAudioClip; [Tooltip("Volume multiplier for the spinning whoosh sound.")] public float SpinAudioMaxVolume = 0.8f; [Header("Percussion Cap Sparks")] [Tooltip("Particle system emitted at the hammer/nipple recess when the hammer strikes.")] public ParticleSystem PSystem_CapSparks; [Tooltip("Number of spark particles emitted per cap strike.")] public int CapSparksEmitCount = 15; [Header("Fallback Thresholds")] [Tooltip("Fallback local position of the ejector rod when forward.")] public Vector3 EjectorRod_Pos_Forward; [Tooltip("Fallback local position of the ejector rod when rearward.")] public Vector3 EjectorRod_Pos_Rearward; [Tooltip("Allowed distance tolerance in meters for fallback rod position checks.")] public float RodDistanceTolerance = 0.02f; [Tooltip("Fallback local X Euler angle of the latch when locked shut.")] public float Latch_Rot_Closed = 0f; [Tooltip("Fallback local X Euler angle of the latch when rotated open.")] public float Latch_Rot_Open = 75f; [Tooltip("Allowed angle tolerance in degrees for fallback latch angle checks.")] public float LatchAngleTolerance = 10f; [Tooltip("Angular velocity required on controller flick to pop the cylinder out when unlatched.")] public float FlickEjectThreshold = 12f; [Tooltip("If true, the revolver cannot discharge from being dropped on an uncocked hammer.")] public bool HasTransferBarSafety = false; [Header("Real-Time Status Indicators")] [Tooltip("Displays whether the script detects the latch as open.")] public bool Status_IsLatchOpen; [Tooltip("Displays whether the script detects the latch as closed.")] public bool Status_IsLatchClosed; [Tooltip("Displays whether the script detects the rod as forward.")] public bool Status_IsRodForward; [Tooltip("Displays whether the script permits reloading and ejecting.")] public bool Status_CanReload; private Quaternion m_storedSpinHolderRot; private bool m_isSpinning; private bool m_isHammerCocking; private bool m_isHammerCocked; private bool m_isHalfCocked; private bool m_isEasingDown; private float m_hammerCurrentAngle; private float m_hammerCockLerp; private float m_hammerCockSpeed = 10f; private float m_decockHoldTimer; private float m_triggerSpinHoldTimer; private float m_triggerFloat; private float m_xSpinRot; private float m_xSpinVel; private float m_timeSinceColFire = 3f; private float m_debugLogTimer; private bool m_spinAudioTriggeredThisRev; private bool m_isTriggerSpinning; private bool m_wasCylinderLoaded; private bool[] m_firedChambers; private FVRFoldingStockXAxis m_latchStockScript; private MovableObjectPart m_rodMovablePart; private List<Collider> m_cachedReloadWellColliders = new List<Collider>(); private AudioSource m_spinAudioSource; public override void Awake() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0259: 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) ((RevolvingShotgun)this).Awake(); base.DoesCylinderRotate = false; base.m_isHammerLocked = false; base.m_shouldRecock = false; base.DoesFiringRecock = false; int num = ((base.NumChambers <= 0) ? 6 : base.NumChambers); m_firedChambers = new bool[num]; FireSelectorMode val = new FireSelectorMode(); val.ModeType = (FireSelectorModeType)0; val.SelectorPosition = 0f; base.FireSelector_Modes = (FireSelectorMode[])(object)new FireSelectorMode[1] { val }; base.m_fireSelectorMode = 0; if ((Object)(object)CylinderLatch != (Object)null) { m_latchStockScript = ((Component)CylinderLatch).GetComponent<FVRFoldingStockXAxis>(); if ((Object)(object)m_latchStockScript == (Object)null) { m_latchStockScript = ((Component)CylinderLatch).GetComponentInParent<FVRFoldingStockXAxis>(); } if ((Object)(object)m_latchStockScript == (Object)null) { m_latchStockScript = ((Component)CylinderLatch).GetComponentInChildren<FVRFoldingStockXAxis>(); } if ((Object)(object)CylinderLatchCollider == (Object)null) { CylinderLatchCollider = ((Component)CylinderLatch).GetComponent<Collider>(); if ((Object)(object)CylinderLatchCollider == (Object)null) { CylinderLatchCollider = ((Component)CylinderLatch).GetComponentInChildren<Collider>(); } } } if ((Object)(object)EjectorRod != (Object)null) { m_rodMovablePart = ((Component)EjectorRod).GetComponent<MovableObjectPart>(); if ((Object)(object)m_rodMovablePart == (Object)null) { m_rodMovablePart = ((Component)EjectorRod).GetComponentInParent<MovableObjectPart>(); } if ((Object)(object)m_rodMovablePart == (Object)null) { m_rodMovablePart = ((Component)EjectorRod).GetComponentInChildren<MovableObjectPart>(); } if ((Object)(object)EjectorRodCollider == (Object)null) { EjectorRodCollider = ((Component)EjectorRod).GetComponent<Collider>(); if ((Object)(object)EjectorRodCollider == (Object)null) { EjectorRodCollider = ((Component)EjectorRod).GetComponentInChildren<Collider>(); } } } Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (((Component)componentsInChildren[i]).CompareTag("FVRFireArmReloadTriggerWell")) { m_cachedReloadWellColliders.Add(componentsInChildren[i]); if ((Object)(object)CylinderLoadTrigger == (Object)null) { CylinderLoadTrigger = ((Component)componentsInChildren[i]).gameObject; } } } if ((Object)(object)PoseSpinHolder != (Object)null) { m_storedSpinHolderRot = PoseSpinHolder.localRotation; m_spinAudioSource = ((Component)PoseSpinHolder).gameObject.AddComponent<AudioSource>(); m_spinAudioSource.playOnAwake = false; m_spinAudioSource.loop = false; m_spinAudioSource.spatialBlend = 1f; m_spinAudioSource.minDistance = 0.5f; m_spinAudioSource.maxDistance = 15f; m_spinAudioSource.clip = SpinAudioClip; } m_hammerCurrentAngle = Hammer_Rot_Uncocked; m_wasCylinderLoaded = base.CylinderLoaded; } public override void FVRUpdate() { //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) ((RevolvingShotgun)this).FVRUpdate(); if (m_wasCylinderLoaded && !base.CylinderLoaded) { if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { if ((Object)(object)((FVRInteractiveObject)this).m_hand.OtherHand != (Object)null && ((FVRInteractiveObject)this).m_hand.OtherHand.CurrentInteractable is Speedloader) { FVRInteractiveObject currentInteractable = ((FVRInteractiveObject)this).m_hand.OtherHand.CurrentInteractable; ApplyCapVisualsToEjectedSpeedloader((Speedloader)(object)((currentInteractable is Speedloader) ? currentInteractable : null)); } else if (((FVRInteractiveObject)this).m_hand.CurrentInteractable is Speedloader) { FVRInteractiveObject currentInteractable2 = ((FVRInteractiveObject)this).m_hand.CurrentInteractable; ApplyCapVisualsToEjectedSpeedloader((Speedloader)(object)((currentInteractable2 is Speedloader) ? currentInteractable2 : null)); } } } else if (!m_wasCylinderLoaded && base.CylinderLoaded) { for (int i = 0; i < m_firedChambers.Length; i++) { m_firedChambers[i] = false; } if (base.Chambers != null) { for (int j = 0; j < base.Chambers.Length; j++) { if (!((Object)(object)base.Chambers[j] != (Object)null)) { continue; } if (base.Chambers[j].IsFull && !base.Chambers[j].IsSpent) { if ((Object)(object)base.Chambers[j].ShowOnSpent != (Object)null) { base.Chambers[j].ShowOnSpent.SetActive(false); } if ((Object)(object)base.Chambers[j].ShowOnUnspent != (Object)null) { base.Chambers[j].ShowOnUnspent.SetActive(true); } } else if (base.Chambers[j].IsFull && base.Chambers[j].IsSpent) { if ((Object)(object)base.Chambers[j].ShowOnSpent != (Object)null) { base.Chambers[j].ShowOnSpent.SetActive(true); } if ((Object)(object)base.Chambers[j].ShowOnUnspent != (Object)null) { base.Chambers[j].ShowOnUnspent.SetActive(false); } } else { if ((Object)(object)base.Chambers[j].ShowOnSpent != (Object)null) { base.Chambers[j].ShowOnSpent.SetActive(false); } if ((Object)(object)base.Chambers[j].ShowOnUnspent != (Object)null) { base.Chambers[j].ShowOnUnspent.SetActive(false); } } } } } m_wasCylinderLoaded = base.CylinderLoaded; bool flag = IsLatchOpen(); bool flag2 = IsLatchClosed(); bool flag3 = IsRodForward(); bool flag4 = IsRodRearward(); bool flag5 = CheckReloadConditions(); bool flag6 = !flag2 || flag3; bool flag7 = flag4; Status_IsLatchOpen = flag; Status_IsLatchClosed = flag2; Status_IsRodForward = flag3; Status_CanReload = flag5; if (!flag5) { ((FVRFireArm)this).EjectDelay = 0.5f; } if ((Object)(object)CylinderLatchCollider != (Object)null && CylinderLatchCollider.enabled != flag7) { CylinderLatchCollider.enabled = flag7; } if ((Object)(object)EjectorRodCollider != (Object)null && EjectorRodCollider.enabled != flag6) { EjectorRodCollider.enabled = flag6; } if (!base.CylinderLoaded && base.Chambers != null) { for (int k = 0; k < base.Chambers.Length; k++) { if ((Object)(object)base.Chambers[k] != (Object)null && base.Chambers[k].IsFull) { base.Chambers[k].Unload(); base.Chambers[k].UpdateProxyDisplay(); } } } for (int l = 0; l < m_cachedReloadWellColliders.Count; l++) { if ((Object)(object)m_cachedReloadWellColliders[l] != (Object)null && m_cachedReloadWellColliders[l].enabled != flag5) { m_cachedReloadWellColliders[l].enabled = flag5; } } if ((Object)(object)CylinderLoadTrigger != (Object)null && CylinderLoadTrigger.activeSelf != flag5) { CylinderLoadTrigger.SetActive(flag5); } if ((Object)(object)CylinderEjectTrigger != (Object)null && CylinderEjectTrigger.activeSelf != flag5) { CylinderEjectTrigger.SetActive(flag5); } if (EnableDebugLogging) { m_debugLogTimer += Time.deltaTime; if (m_debugLogTimer >= 0.75f) { m_debugLogTimer = 0f; string text = ((!((Object)(object)m_latchStockScript != (Object)null)) ? "NoScript" : ((object)Unsafe.As<StockPos, StockPos>(ref m_latchStockScript.m_curPos)/*cast due to .constrained prefix*/).ToString()); float num = ((!((Object)(object)CylinderLatch != (Object)null)) ? (-999f) : CylinderLatch.localEulerAngles.x); string text2 = ((!((Object)(object)m_rodMovablePart != (Object)null)) ? "NoScript" : ((object)Unsafe.As<E_State, E_State>(ref m_rodMovablePart.State)/*cast due to .constrained prefix*/).ToString()); bool flag8 = (Object)(object)EjectorRodCollider != (Object)null && EjectorRodCollider.enabled; bool flag9 = (Object)(object)CylinderLatchCollider != (Object)null && CylinderLatchCollider.enabled; Debug.Log((object)$"[SARevolver] LatchClosed:{flag2} | LatchOpen:{flag} | StockPos:{text} | LatchX:{num:F1} | LatchCol:{flag9} | RodUnlocked:{flag6} | RodCol:{flag8} | RodForward:{flag3} | RodState:{text2} | HalfCock:{m_isHalfCocked} | CanReload:{flag5}"); } } } public override void FVRFixedUpdate() { ((FVRFireArm)this).FVRFixedUpdate(); UpdateSpinning(); if (m_timeSinceColFire < 3f) { m_timeSinceColFire += Time.deltaTime; } } public override void UpdateInteraction(FVRViveHand hand) { //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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) base.m_isHammerLocked = false; base.m_shouldRecock = false; ((RevolvingShotgun)this).UpdateInteraction(hand); bool flag = false; if (!((FVRPhysicalObject)this).IsAltHeld) { bool flag2 = false; bool flag3 = false; if (hand.IsInStreamlinedMode) { if (hand.Input.AXButtonDown) { CockHammer(5f); } if (hand.Input.TouchpadPressed) { flag = true; } flag2 = hand.Input.BYButtonPressed; flag3 = hand.Input.BYButtonDown; } else { if (hand.Input.TouchpadPressed && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.up) < 45f) { flag = true; } if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) < 45f) { CockHammer(5f); } flag2 = hand.Input.TouchpadPressed && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.left) < 45f; flag3 = hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.left) < 45f; } if (!m_isHalfCocked && !m_isHammerCocked && !m_isHammerCocking && !m_isEasingDown) { if (hand.Input.TriggerFloat > 0.5f) { m_triggerSpinHoldTimer += Time.deltaTime; if (m_triggerSpinHoldTimer >= TriggerSpinHoldTime) { m_isTriggerSpinning = true; } } else { m_triggerSpinHoldTimer = 0f; m_isTriggerSpinning = false; } } else { m_triggerSpinHoldTimer = 0f; m_isTriggerSpinning = false; } m_isSpinning = (flag || m_isTriggerSpinning) && CanSpin; if (m_isSpinning) { SetHandControllerVisibility(hand, visible: false); } else { SetHandControllerVisibility(hand, visible: true); } if (!m_isHalfCocked && !m_isHammerCocked && !m_isEasingDown) { if (flag3) { EngageHalfCock(); } m_decockHoldTimer = 0f; } else if (m_isHalfCocked || m_isHammerCocked) { if (flag2) { m_decockHoldTimer += Time.deltaTime; if (m_decockHoldTimer >= DecockHoldTime) { InitiateEaseDown(); } } else { if (DecockHoldTime <= 0.05f && flag3) { InitiateEaseDown(); } m_decockHoldTimer = 0f; } } if (base.CylinderLoaded && CheckReloadConditions() && ((Vector3)(ref hand.Input.VelAngularLocal)).magnitude > FlickEjectThreshold) { Speedloader val = ((RevolvingShotgun)this).EjectCylinder(); if ((Object)(object)val != (Object)null) { ApplyCapVisualsToEjectedSpeedloader(val); if ((Object)(object)((FVRPhysicalObject)val).RootRigidbody != (Object)null) { ((FVRPhysicalObject)val).RootRigidbody.velocity = hand.Input.VelLinearWorld + ((Component)this).transform.right * 0.5f; } } } } UpdateSAHammerAndTrigger(); UpdateCylinderVisuals(); if (!((FVRInteractiveObject)this).IsHeld) { m_isSpinning = false; } } public override void EndInteraction(FVRViveHand hand) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) m_triggerFloat = 0f; m_decockHoldTimer = 0f; m_triggerSpinHoldTimer = 0f; m_isTriggerSpinning = false; if (m_isHammerCocking && !m_isHammerCocked) { m_isHammerCocking = false; m_hammerCockLerp = 0f; } m_isSpinning = false; SetHandControllerVisibility(hand, visible: true); ((FVRFireArm)this).EndInteraction(hand); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.AddRelativeTorque(new Vector3(m_xSpinVel, 0f, 0f), (ForceMode)1); } } private void ApplyCapVisualsToEjectedSpeedloader(Speedloader loader) { if ((Object)(object)loader == (Object)null || loader.Chambers == null || base.Chambers == null) { return; } for (int i = 0; i < loader.Chambers.Count; i++) { if (!((Object)(object)loader.Chambers[i] != (Object)null) || i >= m_firedChambers.Length) { continue; } if (m_firedChambers[i]) { if ((Object)(object)loader.Chambers[i].ShowOnSpent != (Object)null) { loader.Chambers[i].ShowOnSpent.SetActive(true); } if ((Object)(object)loader.Chambers[i].ShowOnUnspent != (Object)null) { loader.Chambers[i].ShowOnUnspent.SetActive(false); } } else { if ((Object)(object)loader.Chambers[i].ShowOnSpent != (Object)null) { loader.Chambers[i].ShowOnSpent.SetActive(false); } if ((Object)(object)loader.Chambers[i].ShowOnUnspent != (Object)null) { loader.Chambers[i].ShowOnUnspent.SetActive(true); } } } } private void SetHandControllerVisibility(FVRViveHand hand, bool visible) { if ((Object)(object)hand == (Object)null) { return; } if (!visible) { if ((Object)(object)hand.Display_Controller != (Object)null) { hand.Display_Controller.SetActive(false); } if ((Object)(object)hand.Display_Controller_Quest2 != (Object)null) { hand.Display_Controller_Quest2.SetActive(false); } if ((Object)(object)hand.Display_Controller_Quest3 != (Object)null) { hand.Display_Controller_Quest3.SetActive(false); } if ((Object)(object)hand.Display_Controller_Touch != (Object)null) { hand.Display_Controller_Touch.SetActive(false); } if ((Object)(object)hand.Display_Controller_Index != (Object)null) { hand.Display_Controller_Index.SetActive(false); } if ((Object)(object)hand.Display_Controller_Vive != (Object)null) { hand.Display_Controller_Vive.SetActive(false); } if ((Object)(object)hand.Display_Controller_WMR != (Object)null) { hand.Display_Controller_WMR.SetActive(false); } if ((Object)(object)hand.Display_Controller_RiftS != (Object)null) { hand.Display_Controller_RiftS.SetActive(false); } if ((Object)(object)hand.Display_Controller_Cosmos != (Object)null) { hand.Display_Controller_Cosmos.SetActive(false); } if ((Object)(object)hand.Display_Controller_HPR2 != (Object)null) { hand.Display_Controller_HPR2.SetActive(false); } } else { hand.UpdateControllerDefinition(); } } private void UpdateSAHammerAndTrigger() { //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (((FVRInteractiveObject)this).IsHeld && !m_isHalfCocked && !m_isHammerCocked && !m_isHammerCocking && !m_isEasingDown && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)this).m_hand.OtherHand != (Object)null && (Object)(object)HammerFanDir != (Object)null) { Vector3 velLinearWorld = ((FVRInteractiveObject)this).m_hand.OtherHand.Input.VelLinearWorld; float num = Vector3.Distance(((FVRInteractiveObject)this).m_hand.OtherHand.PalmTransform.position, HammerFanDir.position); if (num < 0.15f && Vector3.Angle(velLinearWorld, HammerFanDir.forward) < 60f && ((Vector3)(ref velLinearWorld)).magnitude > 1f) { CockHammer(12f); } } if (m_isHammerCocking) { if (m_hammerCockLerp < 1f) { m_hammerCockLerp += Time.deltaTime * m_hammerCockSpeed; } else { m_hammerCockLerp = 1f; m_isHammerCocking = false; m_isHammerCocked = true; if (base.IsCylinderRotClockwise) { ((RevolvingShotgun)this).CurChamber = ((RevolvingShotgun)this).CurChamber + 1; } else { ((RevolvingShotgun)this).CurChamber = ((RevolvingShotgun)this).CurChamber - 1; } } } if ((Object)(object)Hammer != (Object)null) { if (m_isEasingDown) { m_hammerCurrentAngle = Mathf.MoveTowards(m_hammerCurrentAngle, Hammer_Rot_Uncocked, Time.deltaTime * DecockEaseSpeed); Hammer.localEulerAngles = new Vector3(m_hammerCurrentAngle, 0f, 0f); if (Mathf.Abs(m_hammerCurrentAngle - Hammer_Rot_Uncocked) < 0.5f) { m_hammerCurrentAngle = Hammer_Rot_Uncocked; Hammer.localEulerAngles = new Vector3(Hammer_Rot_Uncocked, 0f, 0f); m_isEasingDown = false; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 0.6f); } } else if (m_isHalfCocked) { m_hammerCurrentAngle = Hammer_Rot_Halfcocked; Hammer.localEulerAngles = new Vector3(Hammer_Rot_Halfcocked, 0f, 0f); } else { m_hammerCurrentAngle = Mathf.Lerp(Hammer_Rot_Uncocked, Hammer_Rot_Cocked, m_hammerCockLerp); Hammer.localEulerAngles = new Vector3(m_hammerCurrentAngle, 0f, 0f); } } m_triggerFloat = 0f; if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin && !m_isSpinning && !m_isHalfCocked && !m_isEasingDown && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { m_triggerFloat = ((FVRInteractiveObject)this).m_hand.Input.TriggerFloat; } if ((Object)(object)base.Trigger != (Object)null) { float num2 = Mathf.Lerp(base.Trigger_ForwardValue, base.Trigger_RearwardValue, m_triggerFloat); base.Trigger.localEulerAngles = new Vector3(num2, 0f, 0f); } if (m_triggerFloat > TriggerThreshold && m_isHammerCocked) { DropHammer(); } } private void UpdateCylinderVisuals() { //IL_0082: 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_008f: Unknown result type (might be due to invalid IL or missing references) float num = ((!m_isHammerCocking) ? 0f : m_hammerCockLerp); int num2 = ((!base.IsCylinderRotClockwise) ? ((((RevolvingShotgun)this).CurChamber - 1 + base.NumChambers) % base.NumChambers) : ((((RevolvingShotgun)this).CurChamber + 1) % base.NumChambers)); if ((Object)(object)base.ProxyCylinder != (Object)null && base.CylinderLoaded) { base.ProxyCylinder.localRotation = Quaternion.Slerp(((RevolvingShotgun)this).GetLocalRotationFromCylinder(((RevolvingShotgun)this).CurChamber), ((RevolvingShotgun)this).GetLocalRotationFromCylinder(num2), num); } } public void DropHammer() { //IL_0185: Unknown result type (might be due to invalid IL or missing references) if (!m_isHammerCocked || !CheckFiringConditions()) { return; } m_isHammerCocked = false; m_isHammerCocking = false; m_hammerCockLerp = 0f; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f); if (!base.CylinderLoaded || base.Chambers == null || ((RevolvingShotgun)this).CurChamber < 0 || ((RevolvingShotgun)this).CurChamber >= base.Chambers.Length || !base.Chambers[((RevolvingShotgun)this).CurChamber].Fire()) { return; } if ((Object)(object)PSystem_CapSparks != (Object)null && CapSparksEmitCount > 0) { PSystem_CapSparks.Emit(CapSparksEmitCount); } if (((RevolvingShotgun)this).CurChamber < m_firedChambers.Length) { m_firedChambers[((RevolvingShotgun)this).CurChamber] = true; } FVRFireArmChamber val = base.Chambers[((RevolvingShotgun)this).CurChamber]; Transform val2 = ((!base.UsesMultipleMuzzles || base.Muzzles == null || ((RevolvingShotgun)this).CurChamber >= base.Muzzles.Count) ? ((FVRFireArm)this).GetMuzzle() : base.Muzzles[((RevolvingShotgun)this).CurChamber]); ((FVRFireArm)this).Fire(val, val2, true, 1f, -1f); ((FVRFireArm)this).FireMuzzleSmoke(); bool flag = ((FVRFireArm)this).IsTwoHandStabilized(); bool flag2 = (Object)(object)((FVRPhysicalObject)this).AltGrip != (Object)null; bool flag3 = ((FVRFireArm)this).IsShoulderStabilized(); ((FVRFireArm)this).Recoil(flag, flag2, flag3, (FVRFireArmRecoilProfile)null, 1f); ((FVRFireArm)this).PlayAudioGunShot(val.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f); if (GM.CurrentSceneSettings.IsAmmoInfinite || GM.CurrentPlayerBody.IsInfiniteAmmo) { val.IsSpent = false; val.UpdateProxyDisplay(); if (((RevolvingShotgun)this).CurChamber < m_firedChambers.Length) { m_firedChambers[((RevolvingShotgun)this).CurChamber] = false; } } else { val.IsFull = false; } } public void CockHammer(float speed) { if (!m_isHammerCocked && !m_isHammerCocking) { m_isHalfCocked = false; m_isEasingDown = false; m_decockHoldTimer = 0f; m_hammerCockLerp = 0f; m_hammerCockSpeed = Mathf.Max(0.1f, speed); m_isHammerCocking = true; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)7, 1f); } } public void EngageHalfCock() { m_isHalfCocked = true; m_isHammerCocking = false; m_isHammerCocked = false; m_isEasingDown = false; m_hammerCockLerp = 0f; m_decockHoldTimer = 0f; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)7, 1.2f); } public void InitiateEaseDown() { m_decockHoldTimer = 0f; m_isHalfCocked = false; m_isHammerCocked = false; m_isHammerCocking = false; m_hammerCockLerp = 0f; m_isEasingDown = true; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f); } public void UpdateSpinning() { //IL_002c: 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_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0054: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) if (!((FVRInteractiveObject)this).IsHeld || !CanSpin) { m_isSpinning = false; } if (m_isSpinning) { Vector3 val = Vector3.zero; if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { val = ((FVRInteractiveObject)this).m_hand.Input.VelLinearWorld; } float num = Vector3.Dot(((Vector3)(ref val)).normalized, ((Component)this).transform.up); num = Mathf.Clamp(num, 0f - ((Vector3)(ref val)).magnitude, ((Vector3)(ref val)).magnitude); if (Mathf.Abs(m_xSpinVel) < 90f || Mathf.Sign(num) == Mathf.Sign(m_xSpinVel)) { m_xSpinVel += num * Time.deltaTime * 600f; } if (Mathf.Abs(m_xSpinVel) < 90f) { if (Vector3.Dot(((Component)this).transform.up, Vector3.down) >= 0f && Mathf.Sign(m_xSpinVel) >= 0f) { m_xSpinVel += Time.deltaTime * 50f; } if (Vector3.Dot(((Component)this).transform.up, Vector3.down) < 0f && Mathf.Sign(m_xSpinVel) < 0f) { m_xSpinVel -= Time.deltaTime * 50f; } } m_xSpinVel = Mathf.Clamp(m_xSpinVel, -500f, 500f); m_xSpinRot += m_xSpinVel * Time.deltaTime * 5f; if ((Object)(object)PoseSpinHolder != (Object)null) { PoseSpinHolder.localEulerAngles = new Vector3(m_xSpinRot, 0f, 0f); } float num2 = Mathf.Repeat(m_xSpinRot, 360f); if (num2 >= 260f && num2 <= 280f) { if (!m_spinAudioTriggeredThisRev && Mathf.Abs(m_xSpinVel) > 40f) { m_spinAudioTriggeredThisRev = true; if ((Object)(object)m_spinAudioSource != (Object)null && (Object)(object)SpinAudioClip != (Object)null) { m_spinAudioSource.pitch = Mathf.Lerp(0.9f, 1.25f, Mathf.Abs(m_xSpinVel) / 500f); m_spinAudioSource.PlayOneShot(SpinAudioClip, SpinAudioMaxVolume); } if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { ((FVRInteractiveObject)this).m_hand.Buzz(((FVRInteractiveObject)this).m_hand.Buzzer.Buzz_BeginInteraction); } } } else { m_spinAudioTriggeredThisRev = false; } m_xSpinVel = Mathf.Lerp(m_xSpinVel, 0f, Time.deltaTime * 0.6f); return; } m_xSpinVel = 0f; m_spinAudioTriggeredThisRev = false; if ((Object)(object)PoseSpinHolder != (Object)null) { PoseSpinHolder.localRotation = Quaternion.RotateTowards(PoseSpinHolder.localRotation, m_storedSpinHolderRot, Time.deltaTime * 500f); m_xSpinRot = PoseSpinHolder.localEulerAngles.x; } else { m_xSpinRot = 0f; } if ((Object)(object)m_spinAudioSource != (Object)null && m_spinAudioSource.isPlaying) { m_spinAudioSource.volume = Mathf.MoveTowards(m_spinAudioSource.volume, 0f, Time.deltaTime * 4f); if (m_spinAudioSource.volume <= 0.01f) { m_spinAudioSource.Stop(); } } } public bool IsLatchOpen() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_003f: 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) if ((Object)(object)m_latchStockScript != (Object)null) { return (int)m_latchStockScript.m_curPos == 2; } if ((Object)(object)CylinderLatch != (Object)null) { float x = CylinderLatch.localEulerAngles.x; return Mathf.Abs(Mathf.DeltaAngle(x, Latch_Rot_Open)) <= LatchAngleTolerance; } return true; } public bool IsLatchClosed() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_003f: 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) if ((Object)(object)m_latchStockScript != (Object)null) { return (int)m_latchStockScript.m_curPos == 0; } if ((Object)(object)CylinderLatch != (Object)null) { float x = CylinderLatch.localEulerAngles.x; return Mathf.Abs(Mathf.DeltaAngle(x, Latch_Rot_Closed)) <= LatchAngleTolerance; } return true; } public bool IsRodForward() { //IL_003c: 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) if ((Object)(object)m_rodMovablePart != (Object)null) { return m_rodMovablePart.IsClosed; } if ((Object)(object)EjectorRod != (Object)null) { return Vector3.Distance(EjectorRod.localPosition, EjectorRod_Pos_Forward) <= RodDistanceTolerance; } return true; } public bool IsRodRearward() { //IL_003c: 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) if ((Object)(object)m_rodMovablePart != (Object)null) { return m_rodMovablePart.IsOpen; } if ((Object)(object)EjectorRod != (Object)null) { return Vector3.Distance(EjectorRod.localPosition, EjectorRod_Pos_Rearward) <= RodDistanceTolerance; } return true; } private bool CheckFiringConditions() { return IsRodRearward() && IsLatchClosed(); } public bool CheckReloadConditions() { bool flag = true; if (RequireHalfCockToReload) { flag = m_isHalfCocked; } return IsRodForward() && IsLatchOpen() && flag; } public override void OnCollisionEnter(Collision col) { //IL_00b9: 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) ((FVRPhysicalObject)this).OnCollisionEnter(col); if (!HasTransferBarSafety && (Object)(object)col.collider.attachedRigidbody == (Object)null && base.CylinderLoaded && base.Chambers != null && ((RevolvingShotgun)this).CurChamber >= 0 && ((RevolvingShotgun)this).CurChamber < base.Chambers.Length && base.Chambers[((RevolvingShotgun)this).CurChamber].IsFull && !base.Chambers[((RevolvingShotgun)this).CurChamber].IsSpent && !m_isHammerCocked && !m_isHammerCocking && !m_isHalfCocked && !m_isEasingDown) { Vector3 relativeVelocity = col.relativeVelocity; if (((Vector3)(ref relativeVelocity)).magnitude > 2f && m_timeSinceColFire > 2.9f) { m_timeSinceColFire = 0f; m_isHammerCocked = true; DropHammer(); } } } } public class ActiveDefenseSystem : FVRPhysicalObject, IFVRDamageable { public enum ADSMode { Placement, Armed, Discharged } [Header("Debugging")] public bool DebugLogging = false; [Header("Modal Configuration")] public ADSMode Mode = ADSMode.Placement; [Header("Physical Visuals")] public Transform FlipPiece; public Vector2 FlipPieceRots; public GameObject Light_Red; public GameObject Light_Green; [Header("Deploy Base Plate")] [Tooltip("Place an empty GameObject exactly on the back/bottom plate of your model. Ensure its Z+ (blue arrow) points straight out of the base.")] public Transform AttachmentOrigin; [Tooltip("How long (in seconds) you must hold the base plate against a surface before it deploys.")] public float AttachmentTime = 0.5f; [Tooltip("How long (in seconds) the device takes to prime and arm itself once attached to a surface.")] public float PrimingTime = 2.5f; [Header("Radar Rotation")] [Tooltip("The mesh transform representing the radar head that rotates indefinitely when armed.")] public Transform RadarMesh; [Tooltip("Speed of the radar rotation in degrees per second.")] public float RadarRotationSpeed = 90f; [Tooltip("The local axis the radar mesh rotates around.")] public Axis RadarRotationAxis = (Axis)1; [Header("Interception Settings")] public float InterceptionRadius = 5f; public LayerMask InterceptionLayerMask; [Tooltip("The minimum time delay (in seconds) between zaps.")] public float CooldownBetweenZaps = 0.5f; [Tooltip("The mathematical probability (from 0.0 to 1.0) that each shot hits. Lower values delay destruction.")] public float HitChance = 0.7f; [Tooltip("Maximum amount of zaps before the gadget is depleted.")] public int MaxCharges = 3; [Tooltip("How long (in seconds) the gadget stays armed before powering down. Set to 0 for infinite.")] public float ExpirationTime = 60f; [Tooltip("How long (in seconds) after the gadget powers down before it completely deletes itself.")] public float SelfDestructDelay = 2f; [Tooltip("Should the gadget intercept enemy Sosig-thrown grenades?")] public bool InterceptSosigGrenades = true; [Tooltip("Should the gadget intercept rockets, mortars, or slow ballistic projectiles?")] public bool InterceptBallisticProjectiles = true; [Tooltip("If false, the device will ignore grenades thrown by the player.")] public bool InterceptFriendlyProjectiles = false; [Header("Effects & Spawn Points")] [Tooltip("Assign multiple muzzle points. The script will automatically fire from the one closest to the target.")] public List<Transform> InterceptionMuzzles; public LineRenderer LaserBeamEffect; public float LaserBeamDuration = 0.1f; public GameObject InterceptionEffectPrefab; [Header("Audio")] public AudioEvent AudEvent_Flip; public AudioEvent AudEvent_ArmButtonClick; public AudioEvent AudEvent_Priming; public AudioEvent AudEvent_Armed; public AudioEvent AudEvent_Zap; public AudioEvent AudEvent_HitConfirmation; public AudioEvent AudEvent_Discharged; [Header("Line of Sight & Placement Layers")] public LayerMask LM_Attach; [Tooltip("The layers (like environments/walls) that block the device's line of sight to projectiles.")] public LayerMask LineOfSightObstacleLayers; private int m_chargesLeft; private float m_timeRemaining; private float m_laserResetTimer; private RaycastHit m_hit; private bool m_isPriming; private float m_primeLerp; private bool m_isPrimed; private float m_attachTimer; private float m_zapCooldownTimer; private FieldInfo m_isFuseTickingDownField; private MethodInfo m_shatterMethodField; public override bool IsInteractable() { return Mode != ADSMode.Armed && ((FVRPhysicalObject)this).IsInteractable(); } public override bool IsDistantGrabbable() { return Mode != ADSMode.Armed && ((FVRPhysicalObject)this).IsDistantGrabbable(); } public override void Awake() { ((FVRPhysicalObject)this).Awake(); m_chargesLeft = MaxCharges; m_timeRemaining = ExpirationTime; if ((Object)(object)LaserBeamEffect != (Object)null) { ((Renderer)LaserBeamEffect).enabled = false; } try { m_isFuseTickingDownField = typeof(SosigWeapon).GetField("m_isFuseTickingDown", BindingFlags.Instance | BindingFlags.NonPublic); m_shatterMethodField = typeof(SosigWeapon).GetMethod("Shatter", BindingFlags.Instance | BindingFlags.NonPublic); } catch (Exception ex) { Debug.LogError((object)("ActiveDefenseSystem: Failed to get reflection fields. " + ex.Message)); } SetMode(ADSMode.Placement); } public void SetMode(ADSMode m) { //IL_0054: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) Mode = m; switch (Mode) { case ADSMode.Placement: if ((Object)(object)FlipPiece != (Object)null) { FlipPiece.localEulerAngles = new Vector3(FlipPieceRots.x, 0f, 0f); } if ((Object)(object)Light_Red != (Object)null) { Light_Red.SetActive(false); } if ((Object)(object)Light_Green != (Object)null) { Light_Green.SetActive(true); } base.Size = (FVRPhysicalObjectSize)1; ((FVRPhysicalObject)this).RootRigidbody.isKinematic = false; m_isPrimed = false; m_isPriming = false; break; case ADSMode.Armed: if ((Object)(object)FlipPiece != (Object)null) { FlipPiece.localEulerAngles = new Vector3(FlipPieceRots.y, 0f, 0f); } if ((Object)(object)Light_Red != (Object)null) { Light_Red.SetActive(true); } if ((Object)(object)Light_Green != (Object)null) { Light_Green.SetActive(false); } PrimeDevice(); base.Size = (FVRPhysicalObjectSize)5; break; case ADSMode.Discharged: if ((Object)(object)FlipPiece != (Object)null) { FlipPiece.localEulerAngles = new Vector3(FlipPieceRots.x, 0f, 0f); } if ((Object)(object)Light_Red != (Object)null) { Light_Red.SetActive(false); } if ((Object)(object)Light_Green != (Object)null) { Light_Green.SetActive(false); } if ((Object)(object)LaserBeamEffect != (Object)null) { ((Renderer)LaserBeamEffect).enabled = false; } DetachAndDisarm(); break; } } private void DetachAndDisarm() { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = false; m_isPrimed = false; m_isPriming = false; } private void PrimeDevice() { m_isPriming = true; m_primeLerp = 0f; } public override void BeginInteraction(FVRViveHand hand) { if (Mode == ADSMode.Armed || Mode == ADSMode.Discharged) { LogDebug("Player grabbed deployed device off the wall. Disarming..."); SetMode(ADSMode.Placement); } ((FVRPhysicalObject)this).BeginInteraction(hand); } public override void FVRUpdate() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Invalid comparison between Unknown and I4 //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Invalid comparison between Unknown and I4 //IL_013a: Unknown result type (might be due to invalid IL or missing references) ((FVRPhysicalObject)this).FVRUpdate(); if ((Object)(object)LaserBeamEffect != (Object)null && ((Renderer)LaserBeamEffect).enabled) { m_laserResetTimer -= Time.deltaTime; if (m_laserResetTimer <= 0f) { ((Renderer)LaserBeamEffect).enabled = false; } } if (m_isPriming) { m_primeLerp += Time.deltaTime; if (m_primeLerp > PrimingTime) { m_isPriming = false; m_isPrimed = true; SM.PlayCoreSound((FVRPooledAudioType)0, AudEvent_Armed, ((Component)this).transform.position); } } if (m_isPrimed && Mode == ADSMode.Armed) { if ((Object)(object)RadarMesh != (Object)null) { Vector3 zero = Vector3.zero; float num = RadarRotationSpeed * Time.deltaTime; if ((int)RadarRotationAxis == 0) { zero.x = num; } else if ((int)RadarRotationAxis == 1) { zero.y = num; } else if ((int)RadarRotationAxis == 2) { zero.z = num; } RadarMesh.Rotate(zero, (Space)1); } if (m_zapCooldownTimer > 0f) { m_zapCooldownTimer -= Time.deltaTime; } if (ExpirationTime > 0f) { m_timeRemaining -= Time.deltaTime; if (m_timeRemaining <= 0f) { PowerDownDevice(); return; } } if (m_zapCooldownTimer <= 0f) { ScanAndIntercept(); } } if (Mode == ADSMode.Placement && (Object)(object)((FVRPhysicalObject)this).QuickbeltSlot == (Object)null && ((FVRInteractiveObject)this).IsHeld) { AttachTest(); } } private void AttachTest() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a5: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00e9: 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) if ((Object)(object)AttachmentOrigin == (Object)null) { Debug.LogError((object)"ActiveDefenseSystem: AttachmentOrigin Transform is not assigned in the inspector!"); } else if (Physics.Raycast(AttachmentOrigin.position, AttachmentOrigin.forward, ref m_hit, 0.15f, LayerMask.op_Implicit(LM_Attach), (QueryTriggerInteraction)1)) { m_attachTimer += Time.deltaTime; if (m_attachTimer >= AttachmentTime) { Quaternion val = Quaternion.FromToRotation(AttachmentOrigin.forward, -((RaycastHit)(ref m_hit)).normal); ((Component)this).transform.rotation = val * ((Component)this