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; [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] [DisallowMultipleComponent] public class MetalClashEffect : MonoBehaviour { [Header("Collider Filtering")] [Tooltip("Specific blade colliders on this weapon. If empty, all non-trigger colliders on this object are used.")] public Collider[] BladeColliders; [Header("Target Material Filtering")] [Tooltip("Specific MatDef assets that are allowed to trigger clashes. If empty, any metal MatDef triggers.")] public MatDef[] AllowedTargetMatDefs; [Header("Velocity Thresholds")] [Tooltip("Minimum collision velocity required to trigger clash effects.")] public float MinClashVelocity = 1.5f; [Tooltip("Velocity required to trigger hard impact sounds and maximum spark magnitude.")] public float HighClashVelocity = 4.5f; [Header("Cooldown")] [Tooltip("Cooldown in seconds between clash events to prevent multiple triggers in a single swing.")] public float CooldownTime = 0.08f; [Header("Spark Configuration")] [Tooltip("If true or if no custom prefab is assigned, uses vanilla FXM sparks.")] public bool UseVanillaSparks = true; [Tooltip("Base visual magnitude when using vanilla sparks.")] public ImpactEffectMagnitude LowSparkMagnitude = (ImpactEffectMagnitude)1; [Tooltip("High-velocity visual magnitude when using vanilla sparks.")] public ImpactEffectMagnitude HighSparkMagnitude = (ImpactEffectMagnitude)2; [Tooltip("Tint color applied to vanilla sparks.")] public Color VanillaSparkColor = Color.white; [Tooltip("Custom particle system prefab to spawn on clash. Overrides vanilla sparks if assigned.")] public GameObject CustomSparkPrefab; [Tooltip("Lifetime in seconds before destroying the instantiated custom spark object.")] public float CustomSparkLifetime = 1f; [Header("Audio Configuration")] [Tooltip("If true or if no custom clips are provided, uses Anton's native SM impact sounds.")] public bool UseVanillaAudio = true; [Tooltip("Vanilla impact sound type to play when using native audio.")] public ImpactType WeaponImpactType = (ImpactType)130; [Tooltip("Vanilla audio pool used for impact playback.")] public FVRPooledAudioType AudioPool = (FVRPooledAudioType)41; [Tooltip("Maximum audible distance for vanilla clash audio.")] public float MaxAudioDistance = 25f; [Tooltip("Custom audio clips to play on clash. Overrides vanilla audio if assigned.")] public AudioClip[] CustomClashClips; [Range(0f, 1f)] [Tooltip("Base volume multiplier for custom audio playback.")] public float CustomAudioVolume = 0.8f; [Range(0.5f, 1.5f)] [Tooltip("Minimum random pitch multiplier for custom audio.")] public float CustomAudioMinPitch = 0.95f; [Range(0.5f, 1.5f)] [Tooltip("Maximum random pitch multiplier for custom audio.")] public float CustomAudioMaxPitch = 1.05f; private float m_cooldownTimer; private HashSet m_bladeColliderSet = new HashSet(); private AudioSource m_audioSource; private void Awake() { if (BladeColliders != null && BladeColliders.Length > 0) { for (int i = 0; i < BladeColliders.Length; i++) { if ((Object)(object)BladeColliders[i] != (Object)null) { m_bladeColliderSet.Add(BladeColliders[i]); } } } else { Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); for (int j = 0; j < componentsInChildren.Length; j++) { if (!componentsInChildren[j].isTrigger) { m_bladeColliderSet.Add(componentsInChildren[j]); } } } m_audioSource = ((Component)this).GetComponent(); if ((Object)(object)m_audioSource == (Object)null) { m_audioSource = ((Component)this).gameObject.AddComponent(); m_audioSource.spatialBlend = 1f; m_audioSource.minDistance = 0.5f; m_audioSource.maxDistance = MaxAudioDistance; m_audioSource.playOnAwake = false; } } private void Update() { if (m_cooldownTimer > 0f) { m_cooldownTimer -= Time.deltaTime; } } private void OnCollisionEnter(Collision col) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (m_cooldownTimer > 0f || col.contacts == null || col.contacts.Length == 0) { return; } Vector3 relativeVelocity = col.relativeVelocity; float magnitude = ((Vector3)(ref relativeVelocity)).magnitude; if (!(magnitude < MinClashVelocity)) { ContactPoint val = col.contacts[0]; if (m_bladeColliderSet.Contains(((ContactPoint)(ref val)).thisCollider) && IsTargetValidMetal(((ContactPoint)(ref val)).otherCollider, col)) { m_cooldownTimer = CooldownTime; TriggerSparks(((ContactPoint)(ref val)).point, ((ContactPoint)(ref val)).normal, magnitude); TriggerAudio(((ContactPoint)(ref val)).point, magnitude); } } } private void TriggerSparks(Vector3 point, Vector3 normal, float speed) { //IL_0045: 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_0061: 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_0071: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!UseVanillaSparks && (Object)(object)CustomSparkPrefab != (Object)null) { Quaternion val = Quaternion.LookRotation(normal); GameObject val2 = Object.Instantiate(CustomSparkPrefab, point, val); Object.Destroy((Object)(object)val2, CustomSparkLifetime); return; } ImpactEffectMagnitude val3 = LowSparkMagnitude; if (speed >= HighClashVelocity) { val3 = HighSparkMagnitude; } bool flag = VanillaSparkColor != Color.white; FXM.SpawnImpactEffect(point, normal, 1, val3, false, flag, VanillaSparkColor, (Material)null); } private void TriggerAudio(Vector3 point, float speed) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (!UseVanillaAudio && CustomClashClips != null && CustomClashClips.Length > 0) { int num = Random.Range(0, CustomClashClips.Length); AudioClip val = CustomClashClips[num]; if ((Object)(object)val != (Object)null) { float num2 = Mathf.InverseLerp(MinClashVelocity, HighClashVelocity, speed); float num3 = Mathf.Lerp(0.4f, 1f, num2) * CustomAudioVolume; m_audioSource.pitch = Random.Range(CustomAudioMinPitch, CustomAudioMaxPitch); m_audioSource.PlayOneShot(val, num3); return; } } AudioImpactIntensity val2 = (AudioImpactIntensity)1; if (speed >= HighClashVelocity) { val2 = (AudioImpactIntensity)2; } SM.PlayImpactSound(WeaponImpactType, (MatSoundType)4, val2, point, AudioPool, MaxAudioDistance); } private bool IsTargetValidMetal(Collider otherCollider, Collision col) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Invalid comparison between Unknown and I4 //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Invalid comparison between Unknown and I4 PMat component = ((Component)otherCollider).GetComponent(); if ((Object)(object)component == (Object)null && (Object)(object)col.collider.attachedRigidbody != (Object)null) { component = ((Component)col.collider.attachedRigidbody).GetComponent(); } if ((Object)(object)component == (Object)null || (Object)(object)component.MatDef == (Object)null) { if ((Object)(object)otherCollider.sharedMaterial != (Object)null) { return ((Object)otherCollider.sharedMaterial).name.IndexOf("Metal", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } MatDef matDef = component.MatDef; if (AllowedTargetMatDefs != null && AllowedTargetMatDefs.Length > 0) { for (int i = 0; i < AllowedTargetMatDefs.Length; i++) { if ((Object)(object)AllowedTargetMatDefs[i] == (Object)(object)matDef) { return true; } } return false; } if ((int)matDef.SoundType == 4 || (int)matDef.SoundType == 0) { return true; } if ((int)matDef.ImpactEffectType == 1) { return true; } return false; } } public class HarshRecoilController : MonoBehaviour { [Header("Weapon Reference")] public FVRFireArm weapon; [Header("Disarm Configuration")] [Tooltip("Probability (0.0 to 1.0) that the gun is knocked out of your hand when fired one-handed.")] public float disarmChance = 1f; public float recoilForceUp = 4f; public float recoilForceBack = 6f; public float recoilTorque = 12f; public float recoilRandomness = 1.5f; [Tooltip("Extra angular drag applied immediately after disarm to prevent endless tumbling in the air.")] public float postDisarmAngularDrag = 3f; [Header("Stabilization & Stock")] [Tooltip("If true, shouldering the stock (IsShoulderStabilized) prevents the weapon from being disarmed.")] public bool checkShoulderStabilization = true; [Header("Recoil Return / Recovery Speed")] [Tooltip("If true, automatically adjusts the weapon's interpolation speeds so it snaps back to hand alignment quickly.")] public bool overrideInterpSpeeds = true; [Tooltip("Speed at which the gun returns to hand position (standard snappy value: 15.0 - 25.0).")] public float targetPositionInterpSpeed = 20f; [Tooltip("Speed at which the gun returns to hand rotation/level (standard snappy value: 15.0 - 25.0).")] public float targetRotationInterpSpeed = 20f; [Header("Debugging")] public bool debug; private List lastFrameSpent = new List(); private List disabledColliders = new List(); private float colliderRestoreTimer; private float dragRestoreTimer; private float origAngularDrag = 0.05f; private bool initialized; private void Start() { TryInitialize(); } private void Update() { //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) if (!initialized) { TryInitialize(); } else { if ((Object)(object)weapon == (Object)null || weapon.FChambers == null) { return; } if (colliderRestoreTimer > 0f) { colliderRestoreTimer -= Time.deltaTime; if (colliderRestoreTimer <= 0f) { RestoreColliders(); } } if (dragRestoreTimer > 0f) { dragRestoreTimer -= Time.deltaTime; if (dragRestoreTimer <= 0f && (Object)(object)((FVRPhysicalObject)weapon).RootRigidbody != (Object)null) { ((FVRPhysicalObject)weapon).RootRigidbody.angularDrag = origAngularDrag; } } for (int i = 0; i < weapon.FChambers.Count; i++) { FVRFireArmChamber val = weapon.FChambers[i]; if ((Object)(object)val == (Object)null) { continue; } if (i >= lastFrameSpent.Count) { lastFrameSpent.Add(val.IsSpent); } bool isSpent = val.IsSpent; bool flag = isSpent && !lastFrameSpent[i]; lastFrameSpent[i] = isSpent; if (!flag) { continue; } bool flag2 = (Object)(object)((FVRPhysicalObject)weapon).AltGrip != (Object)null && ((FVRInteractiveObject)((FVRPhysicalObject)weapon).AltGrip).IsHeld; bool flag3 = weapon.IsTwoHandStabilized(); bool flag4 = checkShoulderStabilization && weapon.IsShoulderStabilized(); bool flag5 = flag3 || flag2 || flag4; if (((FVRInteractiveObject)weapon).IsHeld && !flag5 && Random.value <= disarmChance) { if (debug) { Debug.Log((object)"HarshRecoilController: Weapon fired unsupported. Applying launch physics and disarming."); } FVRViveHand hand = ((FVRInteractiveObject)weapon).m_hand; if ((Object)(object)hand != (Object)null) { hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); } ((FVRInteractiveObject)weapon).ForceBreakInteraction(); DisableColliders(); Rigidbody rootRigidbody = ((FVRPhysicalObject)weapon).RootRigidbody; if ((Object)(object)rootRigidbody != (Object)null) { origAngularDrag = rootRigidbody.angularDrag; rootRigidbody.angularDrag = postDisarmAngularDrag; dragRestoreTimer = 1.5f; Vector3 val2 = -((Component)weapon).transform.forward * recoilForceBack + ((Component)weapon).transform.up * recoilForceUp; Vector3 val3 = Random.insideUnitSphere * recoilRandomness; rootRigidbody.AddForce(val2 + val3, (ForceMode)2); Vector3 val4 = ((Component)weapon).transform.right * recoilTorque; Vector3 val5 = Random.insideUnitSphere * (recoilRandomness * 3f); rootRigidbody.AddTorque(val4 + val5, (ForceMode)2); } } } } } private void DisableColliders() { disabledColliders.Clear(); Collider[] componentsInChildren = ((Component)weapon).GetComponentsInChildren(); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null && val.enabled) { val.enabled = false; disabledColliders.Add(val); } } colliderRestoreTimer = 0.08f; } private void RestoreColliders() { for (int i = 0; i < disabledColliders.Count; i++) { if ((Object)(object)disabledColliders[i] != (Object)null) { disabledColliders[i].enabled = true; } } disabledColliders.Clear(); } private void TryInitialize() { if ((Object)(object)weapon == (Object)null) { weapon = ((Component)this).GetComponent(); } if (!((Object)(object)weapon != (Object)null) || weapon.FChambers == null) { return; } if (overrideInterpSpeeds) { ((FVRInteractiveObject)weapon).PositionInterpSpeed = targetPositionInterpSpeed; ((FVRInteractiveObject)weapon).RotationInterpSpeed = targetRotationInterpSpeed; } lastFrameSpent.Clear(); for (int i = 0; i < weapon.FChambers.Count; i++) { if ((Object)(object)weapon.FChambers[i] != (Object)null) { lastFrameSpent.Add(weapon.FChambers[i].IsSpent); } else { lastFrameSpent.Add(item: false); } } if ((Object)(object)((FVRPhysicalObject)weapon).RootRigidbody != (Object)null) { origAngularDrag = ((FVRPhysicalObject)weapon).RootRigidbody.angularDrag; } initialized = true; } } public class ManualChamberLoad : FVRInteractiveObject { public FVRFireArmChamber chamber; public Transform ChamberSeatedPoint; public Collider vanillaChamberCollider; public float loadThreshold = -0.005f; public float extractThreshold = -0.05f; public float maxCasingPushDistance = 0.025f; public float shuckForceThreshold = 1.5f; public float spentShuckResistance = 6f; public float shuckSensitivity = 1.2f; public AudioEvent AudEvent_ShellInStart; public AudioEvent AudEvent_ShellIn; public AudioEvent AudEvent_ShellOutStart; public AudioEvent AudEvent_ShellOut; public bool debug; private FVRFireArmRound m_loadingRound; private float m_roundHandOffsetZ; private bool m_isExtracting; private float m_gravitySlideZ; public override void Awake() { ((FVRInteractiveObject)this).Awake(); if ((Object)(object)chamber == (Object)null) { chamber = ((Component)this).GetComponent(); } if ((Object)(object)chamber != (Object)null) { Collider[] componentsInChildren = ((Component)chamber).GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val in array) { if ((Object)(object)val != (Object)(object)((Component)this).GetComponent()) { val.enabled = false; } } } if ((Object)(object)vanillaChamberCollider != (Object)null) { vanillaChamberCollider.enabled = false; if (debug) { Debug.Log((object)"ManualChamberLoad: Disabled specified vanilla chamber collider."); } } } private void Update() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: 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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chamber == (Object)null || (Object)(object)ChamberSeatedPoint == (Object)null) { return; } if ((Object)(object)m_loadingRound != (Object)null) { FVRViveHand hand = ((FVRInteractiveObject)m_loadingRound).m_hand; if ((Object)(object)hand == (Object)null || !((FVRInteractiveObject)m_loadingRound).IsHeld) { m_loadingRound = null; return; } float num = ChamberSeatedPoint.InverseTransformPoint(((Component)hand).transform.position).z + m_roundHandOffsetZ; if (num >= loadThreshold) { PlaySound(AudEvent_ShellIn); if (m_loadingRound.ProxyRounds != null && m_loadingRound.ProxyRounds.Count > 0) { m_loadingRound.CycleToProxy(true, false); } ((FVRInteractiveObject)m_loadingRound).ForceBreakInteraction(); chamber.SetRound(m_loadingRound, false); Object.Destroy((Object)(object)((Component)m_loadingRound).gameObject); m_loadingRound = null; if (debug) { Debug.Log((object)"ManualChamberLoad: Round successfully seated with palming preserved."); } } else if (num < extractThreshold * 1.5f) { m_loadingRound = null; if (debug) { Debug.Log((object)"ManualChamberLoad: Loading aborted."); } } else { ((Component)m_loadingRound).transform.position = ChamberSeatedPoint.TransformPoint(new Vector3(0f, 0f, num)); ((Component)m_loadingRound).transform.rotation = ChamberSeatedPoint.rotation; } } if (m_isExtracting) { if (!((FVRInteractiveObject)this).IsHeld || (Object)(object)base.m_hand == (Object)null) { m_isExtracting = false; if ((Object)(object)chamber.ProxyRound != (Object)null) { chamber.ProxyRound.localPosition = Vector3.zero; } return; } float num2 = ChamberSeatedPoint.InverseTransformPoint(((Component)base.m_hand).transform.position).z + m_roundHandOffsetZ; if (num2 <= extractThreshold) { PlaySound(AudEvent_ShellOut); FVRFireArmRound val = chamber.EjectRound(ChamberSeatedPoint.position, Vector3.zero, Vector3.zero, false); if ((Object)(object)val != (Object)null) { ((FVRInteractiveObject)val).BeginInteraction(base.m_hand); base.m_hand.ForceSetInteractable((FVRInteractiveObject)(object)val); } ((FVRInteractiveObject)this).ForceBreakInteraction(); m_isExtracting = false; m_gravitySlideZ = 0f; if (debug) { Debug.Log((object)"ManualChamberLoad: Round successfully extracted."); } } else { float num3 = Mathf.Clamp(num2, extractThreshold, 0f); if ((Object)(object)chamber.ProxyRound != (Object)null) { chamber.ProxyRound.localPosition = new Vector3(0f, 0f, num3); } } } if (!chamber.IsFull || !chamber.IsAccessible || ((FVRInteractiveObject)this).IsHeld || !((Object)(object)m_loadingRound == (Object)null)) { return; } float num4 = Vector3.Angle(((Component)chamber).transform.forward, Vector3.up); float num5 = 0f; if (!chamber.IsSpent && num4 < 70f) { num5 -= Time.deltaTime * 0.2f; } Rigidbody val2 = ((!((Object)(object)chamber.Firearm != (Object)null)) ? null : ((FVRPhysicalObject)chamber.Firearm).RootRigidbody); if ((Object)(object)val2 != (Object)null) { float num6 = 0f - ChamberSeatedPoint.InverseTransformDirection(val2.velocity).z; float num7 = num6 - shuckForceThreshold; if (num7 > 0f) { float num8 = ((!chamber.IsSpent) ? 1f : spentShuckResistance); num5 -= num7 / num8 * Time.deltaTime * shuckSensitivity; } } if (num5 != 0f) { m_gravitySlideZ += num5; if (m_gravitySlideZ <= extractThreshold) { PlaySound(AudEvent_ShellOut); chamber.EjectRound(ChamberSeatedPoint.position, -ChamberSeatedPoint.forward * 0.5f, Random.onUnitSphere, false); m_gravitySlideZ = 0f; if (debug) { Debug.Log((object)"ManualChamberLoad: Round ejected via gravity/shucking."); } } else if ((Object)(object)chamber.ProxyRound != (Object)null) { chamber.ProxyRound.localPosition = new Vector3(0f, 0f, m_gravitySlideZ); } } else if (m_gravitySlideZ < 0f) { m_gravitySlideZ = Mathf.MoveTowards(m_gravitySlideZ, 0f, Time.deltaTime * 0.5f); if ((Object)(object)chamber.ProxyRound != (Object)null) { chamber.ProxyRound.localPosition = new Vector3(0f, 0f, m_gravitySlideZ); } } } private void OnTriggerStay(Collider other) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)chamber == (Object)null || (Object)(object)ChamberSeatedPoint == (Object)null || !chamber.IsAccessible || chamber.IsFull || (Object)(object)m_loadingRound != (Object)null || m_isExtracting) { return; } FVRFireArmRound componentInParent = ((Component)other).GetComponentInParent(); if (!((Object)(object)componentInParent != (Object)null) || !((FVRInteractiveObject)componentInParent).IsHeld || componentInParent.RoundType != chamber.RoundType) { return; } Vector3 val = ChamberSeatedPoint.InverseTransformPoint(((Component)componentInParent).transform.position); if (val.z >= extractThreshold) { return; } FVRViveHand hand = ((FVRInteractiveObject)componentInParent).m_hand; if ((Object)(object)hand != (Object)null) { PlaySound(AudEvent_ShellInStart); m_loadingRound = componentInParent; Vector3 val2 = ChamberSeatedPoint.InverseTransformPoint(((Component)hand).transform.position); m_roundHandOffsetZ = val.z - val2.z; if (debug) { Debug.Log((object)"ManualChamberLoad: Round entered loading zone. Initializing sliding guide."); } } } public override bool IsInteractable() { return (Object)(object)chamber != (Object)null && chamber.IsFull && chamber.IsAccessible; } public override void BeginInteraction(FVRViveHand hand) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_008c: 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) ((FVRInteractiveObject)this).BeginInteraction(hand); if ((Object)(object)chamber != (Object)null && chamber.IsFull && chamber.IsAccessible) { PlaySound(AudEvent_ShellOutStart); m_isExtracting = true; Vector3 val = ChamberSeatedPoint.InverseTransformPoint(((Component)hand).transform.position); float num = 0f; if ((Object)(object)chamber.ProxyRound != (Object)null) { num = chamber.ProxyRound.localPosition.z; } m_roundHandOffsetZ = num - val.z; } } public override void EndInteraction(FVRViveHand hand) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).EndInteraction(hand); m_isExtracting = false; if ((Object)(object)chamber != (Object)null && (Object)(object)chamber.ProxyRound != (Object)null) { chamber.ProxyRound.localPosition = Vector3.zero; } } private void PlaySound(AudioEvent aud) { //IL_005d: 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 (aud != null) { if ((Object)(object)chamber != (Object)null && (Object)(object)chamber.Firearm != (Object)null) { chamber.Firearm.PlayAudioAsHandling(aud, ((Component)this).transform.position); } else { SM.PlayCoreSound((FVRPooledAudioType)10, aud, ((Component)this).transform.position); } } } } internal class ManualCylinderIndex : FVRAlternateGrip { public SingleActionRevolver Revolver; public float indexCooldown = 0.2f; public bool debug; private float m_cooldownTimer; public override void Awake() { if ((Object)(object)((FVRInteractiveObject)this).PoseOverride == (Object)null) { ((FVRInteractiveObject)this).PoseOverride = ((Component)this).transform; } ((FVRAlternateGrip)this).Awake(); if ((Object)(object)base.PrimaryObject == (Object)null && (Object)(object)Revolver != (Object)null) { base.PrimaryObject = (FVRPhysicalObject)(object)Revolver; } base.DoesBracing = false; } private void Update() { if ((Object)(object)Revolver == (Object)null) { return; } if (m_cooldownTimer > 0f) { m_cooldownTimer -= Time.deltaTime; } FVRViveHand holdingHand = GetHoldingHand(); if ((Object)(object)holdingHand != (Object)null) { bool flag = false; if (holdingHand.IsInStreamlinedMode) { if (holdingHand.Input.AXButtonDown || holdingHand.Input.BYButtonDown) { flag = true; } } else if (holdingHand.Input.TouchpadDown) { flag = true; } if (flag && m_cooldownTimer <= 0f && Revolver.m_isStateToggled) { if (debug) { Debug.Log((object)"ManualCylinderIndex: Indexing cylinder forward one chamber."); } Revolver.AdvanceCylinder(); m_cooldownTimer = indexCooldown; holdingHand.Buzz(holdingHand.Buzzer.Buzz_BeginInteraction); } } if ((Object)(object)holdingHand != (Object)null) { Revolver.UpdateCylinderRot(); } } public override bool IsInteractable() { return (Object)(object)Revolver != (Object)null && ((FVRAlternateGrip)this).IsInteractable(); } public override void BeginInteraction(FVRViveHand hand) { ((FVRAlternateGrip)this).BeginInteraction(hand); if (debug) { Debug.Log((object)"ManualCylinderIndex: Cylinder grabbed safely via AltGrip."); } } public override void EndInteraction(FVRViveHand hand) { ((FVRAlternateGrip)this).EndInteraction(hand); if (debug) { Debug.Log((object)"ManualCylinderIndex: Cylinder released."); } } private FVRViveHand GetHoldingHand() { if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { return ((FVRInteractiveObject)this).m_hand; } if ((Object)(object)Revolver != (Object)null && ((FVRPhysicalObject)Revolver).IsAltHeld) { return ((FVRInteractiveObject)Revolver).m_hand; } return null; } } internal class ManualRevolverEjectorRod : FVRInteractiveObject { public SingleActionRevolver Revolver; public Transform EjectorRod; public Transform Point_Rod_Forward; public Transform Point_Rod_Rearward; public float Speed_Forward = 10f; public float Speed_Held = 20f; public float SpringStiffness = 40f; public float EjectThreshold = 0.9f; public float maxCasingPushDistance = 0.025f; public AudioEvent AudEvent_RodBack; public AudioEvent AudEvent_RodForward; public bool debug; private float m_rodZ; private float m_rodZ_forward; private float m_rodZ_rear; private float m_curSpeed; private bool m_isRearPlayed; private bool m_isForwardPlayed; private bool m_isAutoPushing; private int m_autoPushDir = 1; public override void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) ((FVRInteractiveObject)this).Awake(); if ((Object)(object)EjectorRod != (Object)null && (Object)(object)Point_Rod_Forward != (Object)null && (Object)(object)Point_Rod_Rearward != (Object)null) { m_rodZ_forward = Point_Rod_Forward.localPosition.z; m_rodZ_rear = Point_Rod_Rearward.localPosition.z; m_rodZ = m_rodZ_forward; m_isForwardPlayed = true; m_isRearPlayed = false; } } private void Update() { //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: 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) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Revolver == (Object)null || (Object)(object)EjectorRod == (Object)null || (Object)(object)EjectorRod.parent == (Object)null) { return; } bool isHeld = ((FVRInteractiveObject)this).IsHeld; float rodZ_forward = m_rodZ_forward; if ((Object)(object)((FVRInteractiveObject)Revolver).m_hand != (Object)null && ((FVRInteractiveObject)Revolver).m_hand.Input.TriggerDown && Revolver.m_isStateToggled && !isHeld) { m_isAutoPushing = true; m_autoPushDir = 1; } if (m_isAutoPushing) { m_curSpeed = 0f; if (m_autoPushDir == 1) { m_rodZ = Mathf.MoveTowards(m_rodZ, m_rodZ_rear, Speed_Held * 2f * Time.deltaTime); if (Mathf.Abs(m_rodZ - m_rodZ_rear) < 0.001f) { m_autoPushDir = -1; } } else { m_rodZ = Mathf.MoveTowards(m_rodZ, m_rodZ_forward, Speed_Forward * 2f * Time.deltaTime); if (Mathf.Abs(m_rodZ - m_rodZ_forward) < 0.001f) { m_isAutoPushing = false; m_autoPushDir = 1; } } } else if (isHeld && (Object)(object)base.m_hand != (Object)null) { Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(Point_Rod_Forward.position, Point_Rod_Rearward.position, ((HandInput)(ref base.m_hand.Input)).Pos); rodZ_forward = EjectorRod.parent.InverseTransformPoint(closestValidPoint).z; m_curSpeed = 0f; m_rodZ = Mathf.MoveTowards(m_rodZ, rodZ_forward, Speed_Held * Time.deltaTime); } else { m_curSpeed = Mathf.MoveTowards(m_curSpeed, Speed_Forward, Time.deltaTime * SpringStiffness); m_rodZ = Mathf.MoveTowards(m_rodZ, rodZ_forward, m_curSpeed * Time.deltaTime); } float num = Mathf.Min(m_rodZ_forward, m_rodZ_rear); float num2 = Mathf.Max(m_rodZ_forward, m_rodZ_rear); m_rodZ = Mathf.Clamp(m_rodZ, num, num2); EjectorRod.localPosition = new Vector3(EjectorRod.localPosition.x, EjectorRod.localPosition.y, m_rodZ); float num3 = Mathf.InverseLerp(m_rodZ_forward, m_rodZ_rear, m_rodZ); if (num3 > EjectThreshold) { if (!m_isRearPlayed) { PlaySound(AudEvent_RodBack); m_isRearPlayed = true; m_isForwardPlayed = false; if (!m_isAutoPushing) { Revolver.EjectPrevCylinder(); } if (debug) { Debug.Log((object)"ManualRevolverEjectorRod: Rod reached threshold. Ejecting."); } } } else if (num3 < 0.1f && !m_isForwardPlayed) { PlaySound(AudEvent_RodForward); m_isForwardPlayed = true; m_isRearPlayed = false; } int num4 = Revolver.PrevChamber; if (Revolver.IsAccessTwoChambersBack) { num4 = Revolver.PrevChamber2; } if ((Object)(object)Revolver.Cylinder != (Object)null && Revolver.Cylinder.Chambers != null && num4 < Revolver.Cylinder.Chambers.Length) { FVRFireArmChamber val = Revolver.Cylinder.Chambers[num4]; if ((Object)(object)val != (Object)null && val.IsFull && (Object)(object)val.ProxyRound != (Object)null) { val.ProxyRound.localPosition = new Vector3(0f, 0f, (0f - num3) * maxCasingPushDistance); } } } public override bool IsInteractable() { return (Object)(object)Revolver != (Object)null && Revolver.m_isStateToggled; } public override void BeginInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).BeginInteraction(hand); if ((Object)(object)EjectorRod != (Object)null && (Object)(object)Point_Rod_Forward != (Object)null && (Object)(object)EjectorRod.parent != (Object)(object)Point_Rod_Forward.parent) { EjectorRod.SetParent(Point_Rod_Forward.parent); } } private void PlaySound(AudioEvent aud) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (aud != null && (Object)(object)Revolver != (Object)null) { ((FVRFireArm)Revolver).PlayAudioAsHandling(aud, ((Component)this).transform.position); } } } public class SingleActionPhysicalEnhancer : MonoBehaviour { public float CartridgeLength = 0.04f; public float CartridgePivotOffset = 0f; public bool DebugMode = false; private SingleActionRevolver _revolver; private List _slidingRounds = new List(); private FVRViveHand _ejectorHand; private FVRViveHand _gateHand; private FVRViveHand _cylinderHand; private float _gateStartLocalY; private bool _hasEjectedThisStroke; private bool _hasIndexedThisPress; private void Awake() { _revolver = ((Component)this).GetComponent(); if (!((Object)(object)_revolver != (Object)null)) { return; } _revolver.StateToggles = false; if (DebugMode) { Debug.Log((object)("SingleActionPhysicalEnhancer: Initialized on revolver " + ((Object)((Component)this).gameObject).name)); } SingleActionEjectorRod componentInChildren = ((Component)this).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { Collider component = ((Component)componentInChildren).GetComponent(); if ((Object)(object)component != (Object)null) { component.enabled = false; } } } private void Update() { if (!((Object)(object)_revolver == (Object)null)) { FVRViveHand[] hands = Object.FindObjectsOfType(); UpdateGateInteraction(hands); UpdateEjectorInteraction(hands); UpdateCylinderInteraction(hands); UpdateCartridgeDetection(hands); UpdateSlidingRounds(hands); } } private void OffsetChamber(int offset) { int numChambers = _revolver.Cylinder.NumChambers; int num = (_revolver.CurChamber + offset) % numChambers; if (num < 0) { num += numChambers; } _revolver.CurChamber = num; _revolver.UpdateCylinderRot(); } private bool IsHandHoldingGun(FVRViveHand hand) { if ((Object)(object)hand == (Object)null) { return false; } if ((Object)(object)hand.CurrentInteractable == (Object)(object)_revolver) { return true; } if ((Object)(object)((FVRPhysicalObject)_revolver).AltGrip != (Object)null && (Object)(object)hand.CurrentInteractable == (Object)(object)((FVRPhysicalObject)_revolver).AltGrip) { return true; } return false; } private void UpdateGateInteraction(FVRViveHand[] hands) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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) if ((Object)(object)_gateHand == (Object)null) { foreach (FVRViveHand val in hands) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.PalmTransform == (Object)null) && !IsHandHoldingGun(val)) { float num = Vector3.Distance(val.PalmTransform.position, _revolver.LoadingGate.position); if (num < 0.04f && val.Input.TriggerPressed) { _gateHand = val; _gateStartLocalY = ((Component)_revolver).transform.InverseTransformPoint(val.PalmTransform.position).y; break; } } } return; } if (!_gateHand.Input.TriggerPressed) { _gateHand = null; return; } float y = ((Component)_revolver).transform.InverseTransformPoint(_gateHand.PalmTransform.position).y; float num2 = y - _gateStartLocalY; if (num2 < -0.02f && !_revolver.m_isStateToggled) { if (DebugMode) { Debug.Log((object)"SingleActionPhysicalEnhancer: Manual gate opening registered."); } _revolver.ToggleState(); ((FVRFireArm)_revolver).PlayAudioEvent((FirearmAudioEventType)17, 1f); _gateHand = null; } else if (num2 > 0.02f && _revolver.m_isStateToggled) { if (DebugMode) { Debug.Log((object)"SingleActionPhysicalEnhancer: Manual gate closing registered."); } _revolver.ToggleState(); ((FVRFireArm)_revolver).PlayAudioEvent((FirearmAudioEventType)18, 1f); _gateHand = null; } } private void UpdateEjectorInteraction(FVRViveHand[] hands) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0201: 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_0212: 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_0081: Unknown result type (might be due to invalid IL or missing references) Vector3 ejectorRod_Pos_Forward = _revolver.EjectorRod_Pos_Forward; Vector3 ejectorRod_Pos_Rearward = _revolver.EjectorRod_Pos_Rearward; if ((Object)(object)_ejectorHand == (Object)null) { foreach (FVRViveHand val in hands) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.PalmTransform == (Object)null) && !IsHandHoldingGun(val)) { float num = Vector3.Distance(val.PalmTransform.position, _revolver.EjectorRod.position); if (num < 0.04f && val.Input.TriggerPressed) { _ejectorHand = val; break; } } } } else if (!_ejectorHand.Input.TriggerPressed) { _ejectorHand = null; } else { float num2 = Mathf.Clamp(((Component)_revolver).transform.InverseTransformPoint(((HandInput)(ref _ejectorHand.Input)).Pos).z, ejectorRod_Pos_Forward.z, ejectorRod_Pos_Rearward.z); _revolver.EjectorRod.localPosition = new Vector3(_revolver.EjectorRod.localPosition.x, _revolver.EjectorRod.localPosition.y, num2); float num3 = (num2 - ejectorRod_Pos_Forward.z) / (ejectorRod_Pos_Rearward.z - ejectorRod_Pos_Forward.z); if (num3 > 0.9f && !_hasEjectedThisStroke) { if (DebugMode) { Debug.Log((object)"SingleActionPhysicalEnhancer: Ejector stroke completed. Clearing chamber."); } _revolver.EjectPrevCylinder(); _hasEjectedThisStroke = true; } } if ((Object)(object)_ejectorHand == (Object)null) { _revolver.EjectorRod.localPosition = Vector3.MoveTowards(_revolver.EjectorRod.localPosition, ejectorRod_Pos_Forward, Time.deltaTime * 2f); _hasEjectedThisStroke = false; } } private void UpdateCylinderInteraction(FVRViveHand[] hands) { //IL_0057: 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) if ((Object)(object)_cylinderHand == (Object)null) { foreach (FVRViveHand val in hands) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.PalmTransform == (Object)null) && !IsHandHoldingGun(val)) { float num = Vector3.Distance(val.PalmTransform.position, ((Component)_revolver.Cylinder).transform.position); if (num < 0.06f && val.Input.GripPressed && _revolver.m_isStateToggled) { _cylinderHand = val; _hasIndexedThisPress = false; break; } } } } else if (!_cylinderHand.Input.GripPressed || !_revolver.m_isStateToggled) { _cylinderHand = null; } else if (_cylinderHand.Input.TouchpadDown || _cylinderHand.Input.TriggerDown || _cylinderHand.Input.AXButtonDown || _cylinderHand.Input.BYButtonDown) { if (!_hasIndexedThisPress) { if (DebugMode) { Debug.Log((object)"SingleActionPhysicalEnhancer: Offhand index input registered."); } OffsetChamber(1); _hasIndexedThisPress = true; } } else { _hasIndexedThisPress = false; } } private void UpdateCartridgeDetection(FVRViveHand[] hands) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (!_revolver.m_isStateToggled) { return; } int num = _revolver.PrevChamber; if (_revolver.IsAccessTwoChambersBack) { num = _revolver.PrevChamber2; } FVRFireArmChamber val = _revolver.Cylinder.Chambers[num]; if (val.IsFull) { return; } foreach (FVRViveHand val2 in hands) { if ((Object)(object)val2 == (Object)null) { continue; } FVRInteractiveObject currentInteractable = val2.CurrentInteractable; FVRFireArmRound val3 = (FVRFireArmRound)(object)((currentInteractable is FVRFireArmRound) ? currentInteractable : null); if (!((Object)(object)val3 != (Object)null)) { continue; } float num2 = Vector3.Distance(((Component)val3).transform.position, ((Component)val).transform.position); if (num2 < 0.05f && !IsRoundAlreadySliding(val3)) { if (DebugMode) { Debug.Log((object)("SingleActionPhysicalEnhancer: Proximity trigger met. Dropping cartridge and binding round: " + ((Object)val3).name)); } ((FVRInteractiveObject)val3).ForceBreakInteraction(); BindRoundToChamber(val3, val, val2); } } } private bool IsRoundAlreadySliding(FVRFireArmRound round) { for (int i = 0; i < _slidingRounds.Count; i++) { if ((Object)(object)_slidingRounds[i].Round == (Object)(object)round) { return true; } } return false; } private void BindRoundToChamber(FVRFireArmRound round, FVRFireArmChamber chamber, FVRViveHand hand) { Rigidbody component = ((Component)round).GetComponent(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; component.useGravity = false; } Collider[] componentsInChildren = ((Component)round).GetComponentsInChildren(); Collider[] array = componentsInChildren; foreach (Collider val in array) { val.enabled = false; } float num = 0f - CartridgePivotOffset; ActiveSlidingRound activeSlidingRound = new ActiveSlidingRound(); activeSlidingRound.Round = round; activeSlidingRound.Chamber = chamber; activeSlidingRound.Hand = hand; activeSlidingRound.MaxZ = num; activeSlidingRound.MinZ = num - CartridgeLength; activeSlidingRound.LocalProgress = activeSlidingRound.MinZ; _slidingRounds.Add(activeSlidingRound); } private void UpdateSlidingRounds(FVRViveHand[] hands) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0103: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0209: Unknown result type (might be due to invalid IL or missing references) for (int num = _slidingRounds.Count - 1; num >= 0; num--) { ActiveSlidingRound activeSlidingRound = _slidingRounds[num]; if ((Object)(object)activeSlidingRound.Round == (Object)null || (Object)(object)activeSlidingRound.Chamber == (Object)null) { _slidingRounds.RemoveAt(num); } else if (((FVRInteractiveObject)activeSlidingRound.Round).IsHeld) { if (DebugMode) { Debug.Log((object)"SingleActionPhysicalEnhancer: Cartridge was grabbed again. Restoring physics."); } RestoreRoundPhysics(activeSlidingRound.Round); _slidingRounds.RemoveAt(num); } else { Vector3 forward = ((Component)activeSlidingRound.Chamber).transform.forward; Vector3 position = ((Component)activeSlidingRound.Chamber).transform.position; foreach (FVRViveHand val in hands) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.PalmTransform == (Object)null)) { Vector3 val2 = val.PalmTransform.position - position; float num2 = Vector3.Dot(val2, forward); Vector3 val3 = val2 - forward * num2; if (((Vector3)(ref val3)).magnitude < 0.03f && num2 < activeSlidingRound.MaxZ && num2 > activeSlidingRound.LocalProgress) { activeSlidingRound.LocalProgress = num2; } } } ((Component)activeSlidingRound.Round).transform.position = ((Component)activeSlidingRound.Chamber).transform.position + ((Component)activeSlidingRound.Chamber).transform.forward * activeSlidingRound.LocalProgress; ((Component)activeSlidingRound.Round).transform.rotation = ((Component)activeSlidingRound.Chamber).transform.rotation; if (activeSlidingRound.LocalProgress >= activeSlidingRound.MaxZ - 0.002f) { if (DebugMode) { Debug.Log((object)"SingleActionPhysicalEnhancer: Cartridge reached seating threshold. Chambering round."); } activeSlidingRound.Chamber.Autochamber(activeSlidingRound.Round.RoundClass); ((FVRFireArm)_revolver).PlayAudioEvent((FirearmAudioEventType)42, 1f); ((Component)activeSlidingRound.Round).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)activeSlidingRound.Round).gameObject); _slidingRounds.RemoveAt(num); } } } } private void RestoreRoundPhysics(FVRFireArmRound round) { Rigidbody component = ((Component)round).GetComponent(); if ((Object)(object)component != (Object)null) { component.isKinematic = false; component.useGravity = true; } Collider[] componentsInChildren = ((Component)round).GetComponentsInChildren(); Collider[] array = componentsInChildren; foreach (Collider val in array) { val.enabled = true; } } } public class ActiveSlidingRound { public FVRFireArmRound Round; public FVRFireArmChamber Chamber; public FVRViveHand Hand; public float MinZ; public float MaxZ; public float LocalProgress; } public class ManualTubeLoad : FVRInteractiveObject { public enum Axis { X, Y, Z } [Tooltip("Enable diagnostic logs in the Unity console.")] public bool debug = false; [Tooltip("Point 1 (BLUE in Scene): The rear gate entrance where shell sliding begins.")] public Transform CarrierComparePoint1; [Tooltip("Point 2 (GREEN in Scene): The forward point where the shell counts in and seats.")] public Transform CarrierComparePoint2; [Tooltip("The visual carrier/elevator transform on the shotgun.")] public Transform Carrier; [Tooltip("The rotational axis of the carrier.")] public Axis CarrierAxis = Axis.X; [Tooltip("The down/closed (x) and up/open (y) angles for the carrier.")] public Vector2 CarrierRots = new Vector2(0f, 30f); [Tooltip("Distance from Point 1 or the carrier where the lifter opens.")] public float CarrierDetectDistance = 0.12f; [Tooltip("Speed in degrees per second at which the carrier rotates.")] public float CarrierSpeed = 450f; [Tooltip("Optional visual loading gate flap (for lever actions).")] public Transform LoadingGateObject; [Tooltip("The rotational axis of the loading gate flap.")] public Axis LoadingGateAxis = Axis.Y; [Tooltip("The closed (x) and open (y) angles for the loading gate flap.")] public Vector2 LoadingGateRotRange = new Vector2(0f, -30f); public AudioEvent AudEvent_ShellInStart; public AudioEvent AudEvent_ShellIn; private FVRFireArm m_parentGun; private TubeFedShotgun m_parentShotgun; private FVRFireArmMagazine m_magazine; private FVRFireArmRound m_loadingRound; private FVRViveHand m_loadingHand; private float m_curCarrierRot; private float m_tarCarrierRot; private float m_carrierProgress; private float m_slideProgress; private float m_lastTickProgress; private float m_startHandOffset; private float m_loadCooldownTimer; private float m_cycleHoldTimer; public override void Awake() { ((FVRInteractiveObject)this).Awake(); if (debug) { Debug.Log((object)("ManualTubeLoad DIAGNOSTIC: Awake initialized on GameObject: " + ((Object)((Component)this).gameObject).name)); } m_parentGun = ((Component)this).GetComponentInParent(); if ((Object)(object)m_parentGun != (Object)null) { ref TubeFedShotgun parentShotgun = ref m_parentShotgun; FVRFireArm parentGun = m_parentGun; parentShotgun = (TubeFedShotgun)(object)((parentGun is TubeFedShotgun) ? parentGun : null); m_magazine = m_parentGun.Magazine; if ((Object)(object)m_parentShotgun != (Object)null) { m_parentShotgun.UsesAnimatedCarrier = false; if (debug) { Debug.Log((object)"ManualTubeLoad DIAGNOSTIC: Connected to parent TubeFedShotgun. Native animated carrier disabled."); } if ((Object)(object)m_parentShotgun.ReloadTriggerWell != (Object)null) { Collider[] componentsInChildren = m_parentShotgun.ReloadTriggerWell.GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val in array) { val.enabled = false; if (debug) { Debug.Log((object)("ManualTubeLoad DIAGNOSTIC: Disabled collider on shotgun ReloadTriggerWell: " + ((Object)((Component)val).gameObject).name)); } } } } } else if (debug) { Debug.LogError((object)"ManualTubeLoad DIAGNOSTIC ERROR: Could not find parent FVRFireArm component in the hierarchy above this GameObject!"); } FVRFireArmMagazineReloadTrigger componentInChildren = ((Component)this).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { if ((Object)(object)m_magazine == (Object)null) { m_magazine = componentInChildren.Magazine; } if (debug) { Debug.Log((object)("ManualTubeLoad DIAGNOSTIC: Found FVRFireArmMagazineReloadTrigger. Magazine reference is: " + ((!((Object)(object)m_magazine != (Object)null)) ? "NULL!" : ((Object)m_magazine).name))); } GameObject gameObject = ((Component)componentInChildren).gameObject; if ((Object)(object)gameObject != (Object)(object)((Component)this).gameObject) { Object.Destroy((Object)(object)gameObject); if (debug) { Debug.Log((object)"ManualTubeLoad DIAGNOSTIC: Destroyed child native trigger GameObject to permanently silence auto-load."); } } else { Object.Destroy((Object)(object)componentInChildren); if (debug) { Debug.Log((object)"ManualTubeLoad DIAGNOSTIC: Destroyed native trigger component to permanently silence auto-load."); } } } if (((Object)(object)CarrierComparePoint1 == (Object)null || (Object)(object)CarrierComparePoint2 == (Object)null) && debug) { Debug.LogError((object)"ManualTubeLoad DIAGNOSTIC ERROR: CarrierComparePoint1 or CarrierComparePoint2 is not assigned in the Unity Inspector!"); } } private void Update() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_07dc: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0780: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0825: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_magazine == (Object)null || (Object)(object)CarrierComparePoint1 == (Object)null || (Object)(object)CarrierComparePoint2 == (Object)null) { return; } if (m_loadCooldownTimer > 0f) { m_loadCooldownTimer -= Time.deltaTime; } if (m_cycleHoldTimer > 0f) { m_cycleHoldTimer -= Time.deltaTime; } Vector3 val = CarrierComparePoint2.position - CarrierComparePoint1.position; float magnitude = ((Vector3)(ref val)).magnitude; Vector3 val2 = ((!(magnitude > 0.001f)) ? Vector3.forward : (val / magnitude)); bool flag = false; FVRFireArmRound val3 = null; FVRViveHand loadingHand = null; if ((Object)(object)GM.CurrentMovementManager != (Object)null) { for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++) { FVRViveHand val4 = GM.CurrentMovementManager.Hands[i]; if ((Object)(object)val4 == (Object)null || ((Object)(object)m_parentGun != (Object)null && ((FVRInteractiveObject)m_parentGun).IsHeld && (Object)(object)val4 == (Object)(object)((FVRInteractiveObject)m_parentGun).m_hand)) { continue; } Vector3 pos = ((HandInput)(ref val4.Input)).Pos; if ((Object)(object)Carrier != (Object)null && Vector3.Distance(pos, Carrier.position) < CarrierDetectDistance) { flag = true; } else if (Vector3.Distance(pos, CarrierComparePoint1.position) < CarrierDetectDistance) { flag = true; } if (!(val4.CurrentInteractable is FVRFireArmRound)) { continue; } FVRInteractiveObject currentInteractable = val4.CurrentInteractable; FVRFireArmRound val5 = (FVRFireArmRound)(object)((currentInteractable is FVRFireArmRound) ? currentInteractable : null); if (val5.RoundType == m_magazine.RoundType) { float num = ((!((Object)(object)Carrier != (Object)null)) ? 999f : Vector3.Distance(((Component)val5).transform.position, Carrier.position)); float num2 = Vector3.Distance(((Component)val5).transform.position, CarrierComparePoint1.position); if (num < CarrierDetectDistance || num2 < CarrierDetectDistance) { flag = true; } if (num2 < CarrierDetectDistance) { val3 = val5; loadingHand = val4; } } } } if ((Object)(object)m_loadingRound == (Object)null && m_loadCooldownTimer <= 0f && (Object)(object)val3 != (Object)null && !m_magazine.IsFull()) { m_loadingRound = val3; m_loadingHand = loadingHand; ((FVRInteractiveObject)m_loadingRound).SetAllCollidersToLayer(false, "NoCol"); float startHandOffset = Vector3.Dot(((HandInput)(ref m_loadingHand.Input)).Pos - CarrierComparePoint1.position, val2); m_startHandOffset = startHandOffset; m_slideProgress = 0f; m_lastTickProgress = 0f; PlaySound(AudEvent_ShellInStart); if (debug) { Debug.Log((object)"ManualTubeLoad DIAGNOSTIC: Shell engaged on sliding rail. Slide initiated!"); } } if ((Object)(object)m_loadingRound != (Object)null) { if ((Object)(object)m_loadingHand == (Object)null || !((FVRInteractiveObject)m_loadingRound).IsHeld || (Object)(object)m_loadingHand.CurrentInteractable != (Object)(object)m_loadingRound) { ((FVRInteractiveObject)m_loadingRound).SetAllCollidersToLayer(false, "Default"); if ((Object)(object)((FVRPhysicalObject)m_loadingRound).RootRigidbody != (Object)null) { ((FVRPhysicalObject)m_loadingRound).RootRigidbody.velocity = -val2 * 1.2f + GM.CurrentMovementManager.GetFilteredVel(); } m_loadingRound = null; m_loadingHand = null; m_slideProgress = 0f; m_carrierProgress = 0f; if (debug) { Debug.Log((object)"ManualTubeLoad DIAGNOSTIC: Shell released mid-slide. Ejected via backward impulse."); } } else { float num3 = Vector3.Dot(((HandInput)(ref m_loadingHand.Input)).Pos - CarrierComparePoint1.position, val2); float num4 = num3 - m_startHandOffset; if (num4 < -0.04f) { ((FVRInteractiveObject)m_loadingRound).SetAllCollidersToLayer(false, "Default"); m_loadingRound = null; m_loadingHand = null; m_slideProgress = 0f; m_carrierProgress = 0f; if (debug) { Debug.Log((object)"ManualTubeLoad DIAGNOSTIC: Hand pulled backward past entrance. Shell disengaged back to hand."); } } else { m_slideProgress = Mathf.Clamp01(num4 / Mathf.Max(0.01f, magnitude)); Vector3 position = CarrierComparePoint1.position + val2 * (m_slideProgress * magnitude); ((Component)m_loadingRound).transform.position = position; ((Component)m_loadingRound).transform.rotation = Quaternion.LookRotation(val2); m_carrierProgress = Mathf.Clamp01(m_slideProgress * 1.5f); if (Mathf.Abs(m_slideProgress - m_lastTickProgress) > 0.15f) { m_lastTickProgress = m_slideProgress; if ((Object)(object)m_loadingHand.Buzzer != (Object)null) { m_loadingHand.Buzz(m_loadingHand.Buzzer.Buzz_OnHoverInteractive); } } if (m_slideProgress >= 0.9f) { PlaySound(AudEvent_ShellIn); m_magazine.AddRound(m_loadingRound, true, true, false); if (m_loadingRound.ProxyRounds != null && m_loadingRound.ProxyRounds.Count > 0) { m_loadingRound.CycleToProxy(true, false); } Object.Destroy((Object)(object)((Component)m_loadingRound).gameObject); m_loadingRound = null; m_loadingHand = null; m_loadCooldownTimer = 0.15f; m_slideProgress = 0f; m_carrierProgress = 0f; if (debug) { Debug.Log((object)"ManualTubeLoad DIAGNOSTIC: Shell successfully seated into magazine."); } } } } } if ((Object)(object)m_parentShotgun != (Object)null && m_parentShotgun.HasExtractedRound() && !m_parentShotgun.m_isExtractedRoundOnLowerPath) { m_cycleHoldTimer = 0.15f; } if ((Object)(object)m_loadingRound != (Object)null || flag || m_cycleHoldTimer > 0f) { m_tarCarrierRot = CarrierRots.y; } else { m_tarCarrierRot = CarrierRots.x; } m_curCarrierRot = Mathf.MoveTowards(m_curCarrierRot, m_tarCarrierRot, CarrierSpeed * Time.deltaTime); if ((Object)(object)Carrier != (Object)null) { Vector3 zero = Vector3.zero; if (CarrierAxis == Axis.X) { zero.x = m_curCarrierRot; } else if (CarrierAxis == Axis.Y) { zero.y = m_curCarrierRot; } else { zero.z = m_curCarrierRot; } Carrier.localEulerAngles = zero; } if ((Object)(object)LoadingGateObject != (Object)null) { float num5 = Mathf.InverseLerp(CarrierRots.x, CarrierRots.y, m_curCarrierRot); float num6 = Mathf.Lerp(LoadingGateRotRange.x, LoadingGateRotRange.y, num5); Vector3 zero2 = Vector3.zero; if (LoadingGateAxis == Axis.X) { zero2.x = num6; } else if (LoadingGateAxis == Axis.Y) { zero2.y = num6; } else { zero2.z = num6; } LoadingGateObject.localEulerAngles = zero2; } if (debug && Time.frameCount % 90 == 0) { Debug.Log((object)("ManualTubeLoad DIAGNOSTIC STATUS: CarrierAngle: " + m_curCarrierRot + " | TargetAngle: " + m_tarCarrierRot + " | IsLiftTriggered: " + flag + " | IsLoading: " + ((Object)(object)m_loadingRound != (Object)null))); } } private void LateUpdate() { if ((Object)(object)m_magazine != (Object)null) { m_magazine.IsDropInLoadable = false; } } public override bool IsInteractable() { return false; } private void PlaySound(AudioEvent aud) { //IL_005d: 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 (aud != null) { if ((Object)(object)m_magazine != (Object)null && (Object)(object)m_magazine.FireArm != (Object)null) { m_magazine.FireArm.PlayAudioAsHandling(aud, ((Component)this).transform.position); } else { SM.PlayCoreSound((FVRPooledAudioType)10, aud, ((Component)this).transform.position); } } } private void OnDrawGizmosSelected() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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) if ((Object)(object)CarrierComparePoint1 != (Object)null && (Object)(object)CarrierComparePoint2 != (Object)null) { Gizmos.color = Color.yellow; Gizmos.DrawLine(CarrierComparePoint1.position, CarrierComparePoint2.position); Gizmos.color = Color.blue; Gizmos.DrawSphere(CarrierComparePoint1.position, 0.008f); Gizmos.color = Color.green; Gizmos.DrawSphere(CarrierComparePoint2.position, 0.008f); Gizmos.color = Color.cyan; Gizmos.DrawWireSphere(CarrierComparePoint1.position, CarrierDetectDistance); } if ((Object)(object)Carrier != (Object)null) { Gizmos.color = Color.magenta; Gizmos.DrawWireSphere(Carrier.position, CarrierDetectDistance); } } } public class AdvanceInternalMagazineLoading : MonoBehaviour { [Header("Debug")] [Tooltip("Enables on-screen console logging for push-to-seat loading, sticky bolt velocity, and ejection forces.")] public bool Debug; [Header("Target Components")] [Tooltip("Reference to the root BoltActionRifle component.")] public BoltActionRifle Rifle; [Tooltip("Reference to the internal FVRFireArmMagazine component.")] public FVRFireArmMagazine InternalMagazine; [Tooltip("Reference to the child FVRFireArmMagazineReloadTrigger component.")] public FVRFireArmMagazineReloadTrigger ReloadTrigger; [Header("Dynamic Push-To-Seat Ingestion")] [Tooltip("Baseline downward distance in meters the controller must press into the receiver well to seat the first round into an empty magazine.")] public float RequiredInsertionDepth = 0.007f; [Tooltip("Multiplier applied to the required insertion depth when the magazine is nearly full, simulating increasing spring stiffness.")] public float FullMagDepthMultiplier = 1.6f; [Tooltip("Minimum time delay between successive round seatings.")] public float SeatingCooldown = 0.15f; [Tooltip("Optional audio played when a round is successfully pushed down past the internal magazine feed lips.")] public AudioEvent CustomSeatAudio; [Tooltip("Audio played when the player tries to push a round into an already full internal magazine.")] public AudioEvent FullMagAttemptAudio; [Header("Velocity-Sensitive Ejection")] [Tooltip("Enables dynamic scaling of casing ejection forces based on how fast the player pulls the bolt rearward.")] public bool EnableVelocitySensitiveEjection = true; [Tooltip("Bolt retraction speed threshold below which the extracted casing drops weakly or sits loose inside the receiver.")] public float SlowBoltSpeedThreshold = 0.8f; [Tooltip("Multiplier applied to native ejection forces when the bolt is pulled back slower than the SlowBoltSpeedThreshold.")] public float SlowEjectionMultiplier = 0.05f; [Header("Sticky Bolt Resistance")] [Tooltip("Simulates mechanical binding and expanded fired casings by requiring an upward velocity spike (palm slap) to unlock the bolt handle on spent rounds.")] public bool EnableStickyBolt = true; [Tooltip("Upward linear velocity threshold of the controller required to break the initial extraction camming resistance on a fired cartridge.")] public float StickyBreakawayVelocity = 0.75f; [Tooltip("Maximum rotation angle the bolt handle can travel upward before static friction halts it if breakaway velocity is not met.")] public float StickyMaxStuckAngle = 18f; private BoltActionRifle m_rifle; private BoltActionRifle_Handle m_handle; private FVRFireArmChamber m_chamber; private float m_origRightForce; private float m_origUpForce; private float m_origSpinTorque; private float m_prevBoltLerp; private float m_strokeSpeed; private bool m_isStickyBroken; private bool m_requiresStrokeReset; private float m_timeSinceLastSeat; private float m_timeSinceFullWarning; private void Awake() { m_rifle = Rifle; if ((Object)(object)m_rifle == (Object)null) { m_rifle = ((Component)this).GetComponent(); Rifle = m_rifle; } if ((Object)(object)m_rifle != (Object)null) { m_handle = m_rifle.BoltHandle; m_chamber = m_rifle.Chamber; if ((Object)(object)InternalMagazine == (Object)null) { InternalMagazine = ((FVRFireArm)m_rifle).Magazine; } if ((Object)(object)ReloadTrigger == (Object)null) { ReloadTrigger = ((Component)m_rifle).GetComponentInChildren(true); } m_origRightForce = m_rifle.RightwardEjectionForce; m_origUpForce = m_rifle.UpwardEjectionForce; m_origSpinTorque = m_rifle.YSpinEjectionTorque; } m_prevBoltLerp = 0f; m_strokeSpeed = 0f; m_isStickyBroken = false; m_requiresStrokeReset = false; m_timeSinceLastSeat = 0f; m_timeSinceFullWarning = 0f; } private void Start() { if ((Object)(object)ReloadTrigger != (Object)null) { ((Component)ReloadTrigger).gameObject.tag = "Untagged"; } if ((Object)(object)InternalMagazine != (Object)null) { InternalMagazine.IsDropInLoadable = false; InternalMagazine.IsIntegrated = true; } } private void Update() { if (!((Object)(object)m_rifle == (Object)null)) { if (m_timeSinceLastSeat < SeatingCooldown) { m_timeSinceLastSeat += Time.deltaTime; } if (m_timeSinceFullWarning < 0.5f) { m_timeSinceFullWarning += Time.deltaTime; } float num = m_rifle.BoltLerp - m_prevBoltLerp; float strokeSpeed = Mathf.Abs(num) / Mathf.Max(Time.deltaTime, 0.0001f); if (num > 0.001f) { m_strokeSpeed = strokeSpeed; } if (EnableVelocitySensitiveEjection) { ProcessVelocityEjection(); } if (EnableStickyBolt) { ProcessStickyBolt(); } m_prevBoltLerp = m_rifle.BoltLerp; } } private void ProcessVelocityEjection() { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Invalid comparison between Unknown and I4 if (m_rifle.BoltLerp > 0.4f) { if (m_strokeSpeed < SlowBoltSpeedThreshold) { m_rifle.RightwardEjectionForce = m_origRightForce * SlowEjectionMultiplier; m_rifle.UpwardEjectionForce = m_origUpForce * SlowEjectionMultiplier; m_rifle.YSpinEjectionTorque = m_origSpinTorque * SlowEjectionMultiplier; } else { m_rifle.RightwardEjectionForce = m_origRightForce; m_rifle.UpwardEjectionForce = m_origUpForce; m_rifle.YSpinEjectionTorque = m_origSpinTorque; } } else { Rifle.RightwardEjectionForce = m_origRightForce; Rifle.UpwardEjectionForce = m_origUpForce; Rifle.YSpinEjectionTorque = m_origSpinTorque; } if (Debug && (int)m_rifle.CurBoltHandleState == 2) { Debug.Log((object)$"[AdvanceInternalMag] Rear Ejection Speed: {m_strokeSpeed:F2} | Force Mult: {m_rifle.RightwardEjectionForce / Mathf.Max(m_origRightForce, 0.001f):F2}"); } } private void ProcessStickyBolt() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0049: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Invalid comparison between Unknown and I4 //IL_01ce: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_handle == (Object)null || (Object)(object)m_chamber == (Object)null) { return; } if ((int)m_handle.HandleRot == 2) { m_isStickyBroken = false; } if ((int)m_handle.HandleState != 0 || !m_chamber.IsFull || !m_chamber.IsSpent || m_isStickyBroken || !((FVRInteractiveObject)m_handle).IsHeld || !((Object)(object)((FVRInteractiveObject)m_handle).m_hand != (Object)null)) { return; } Vector3 velLinearWorld = ((FVRInteractiveObject)m_handle).m_hand.Input.VelLinearWorld; float num = Vector3.Dot(velLinearWorld, ((Component)m_rifle).transform.up); if (num >= StickyBreakawayVelocity) { m_isStickyBroken = true; ((FVRInteractiveObject)m_handle).m_hand.Buzz(((FVRInteractiveObject)m_handle).m_hand.Buzzer.Buzz_BeginInteraction); if (Debug) { Debug.Log((object)$"[AdvanceInternalMag] Sticky Breakaway Overcome! Speed: {num:F2}"); } } else if (m_handle.rotAngle > StickyMaxStuckAngle) { m_handle.rotAngle = StickyMaxStuckAngle; m_handle.BoltActionHandle.localEulerAngles = new Vector3(0f, 0f, StickyMaxStuckAngle); if (m_handle.UsesExtraRotationPiece && (Object)(object)m_handle.ExtraRotationPiece != (Object)null) { m_handle.ExtraRotationPiece.localEulerAngles = new Vector3(0f, 0f, StickyMaxStuckAngle); } m_handle.HandleRot = (BoltActionHandleRot)1; if ((int)m_rifle.CockType == 1 && m_rifle.m_isHammerCocked) { m_rifle.m_isHammerCocked = false; } ((FVRInteractiveObject)m_handle).m_hand.Buzz(((FVRInteractiveObject)m_handle).m_hand.Buzzer.Buzz_OnHoverInteractive); } } private void OnTriggerStay(Collider other) { //IL_0040: 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_00a9: 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_0114: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_rifle == (Object)null || (Object)(object)InternalMagazine == (Object)null || m_timeSinceLastSeat < SeatingCooldown || (int)m_rifle.CurBoltHandleState == 0) { return; } FVRFireArmRound val = null; if ((Object)(object)other.attachedRigidbody != (Object)null) { val = ((Component)other.attachedRigidbody).GetComponent(); } if ((Object)(object)val == (Object)null) { val = ((Component)other).GetComponent(); } if ((Object)(object)val == (Object)null || val.IsSpent || val.RoundType != InternalMagazine.RoundType || !((FVRInteractiveObject)val).IsHeld || !((Object)(object)((FVRInteractiveObject)val).m_hand != (Object)null)) { return; } Transform val2 = ((!((Object)(object)ReloadTrigger != (Object)null)) ? ((Component)m_rifle).transform : ((Component)ReloadTrigger).transform); Vector3 val3 = ((HandInput)(ref ((FVRInteractiveObject)val).m_hand.Input)).Pos - val2.position; float num = Vector3.Dot(val3, -((Component)m_rifle).transform.up); if (InternalMagazine.IsFull()) { if (num > 0.004f && m_timeSinceFullWarning >= 0.4f) { m_timeSinceFullWarning = 0f; ((FVRInteractiveObject)val).m_hand.Buzz(((FVRInteractiveObject)val).m_hand.Buzzer.Buzz_OnHoverInventorySlot); if (FullMagAttemptAudio != null) { SM.PlayGenericSound(FullMagAttemptAudio, ((Component)this).transform.position); } else if ((Object)(object)InternalMagazine.Profile != (Object)null) { SM.PlayGenericSound(InternalMagazine.Profile.MagazineInsertRound, ((Component)this).transform.position); } if (Debug) { Debug.Log((object)"[AdvanceInternalMag] Magazine is full! Rejection feedback played."); } } } else if (m_requiresStrokeReset) { if (num < 0.003f) { m_requiresStrokeReset = false; if (Debug) { Debug.Log((object)"[AdvanceInternalMag] Stroke reset. Ready for next palmed round."); } } } else { if (num > 0.002f) { ((FVRInteractiveObject)val).m_hand.Buzz(((FVRInteractiveObject)val).m_hand.Buzzer.Buzz_OnHoverInteractive); } float num2 = (float)InternalMagazine.m_numRounds / (float)Mathf.Max(InternalMagazine.m_capacity, 1); float num3 = Mathf.Lerp(RequiredInsertionDepth, RequiredInsertionDepth * FullMagDepthMultiplier, num2); if (num >= num3) { SeatRoundIntoMagazine(val); } } } private void OnTriggerExit(Collider other) { m_requiresStrokeReset = false; } private void SeatRoundIntoMagazine(FVRFireArmRound round) { //IL_003c: 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_009d: Unknown result type (might be due to invalid IL or missing references) m_timeSinceLastSeat = 0f; m_requiresStrokeReset = true; FVRViveHand hand = ((FVRInteractiveObject)round).m_hand; if (round.ProxyRounds.Count > 0) { round.CycleToProxy(true, false); } InternalMagazine.AddRound(round.RoundClass, true, true); if (CustomSeatAudio != null) { SM.PlayGenericSound(CustomSeatAudio, ((Component)this).transform.position); } else if ((Object)(object)InternalMagazine.Profile != (Object)null) { SM.PlayGenericSound(InternalMagazine.Profile.MagazineInsertRound, ((Component)this).transform.position); } if ((Object)(object)hand != (Object)null) { hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); } ((FVRInteractiveObject)round).ForceBreakInteraction(); Object.Destroy((Object)(object)((Component)round).gameObject); if (Debug) { Debug.Log((object)$"[AdvanceInternalMag] Round seated successfully. Magazine count: {InternalMagazine.m_numRounds}/{InternalMagazine.m_capacity}"); } } } public class PushFeedBoltAction : MonoBehaviour { [Header("Rifle Reference")] [Tooltip("The bolt-action rifle this script adds push-feed behavior to. If left empty, it will find one on this GameObject.")] public BoltActionRifle Rifle; [Header("Feed Type")] [Tooltip("If true, push-feed failure behavior is disabled and the rifle behaves like a controlled-feed action.")] public bool UsesControlledFeed = false; [Header("Push-Feed Timing")] [Tooltip("Bolt travel threshold (0 = closed, 1 = open). If the bolt reverses direction after passing below this value without closing, the round is left loose in the action.")] [Range(0.05f, 0.9f)] public float CommitThreshold = 0.4f; [Tooltip("Minimum rearward distance the bolt must travel after passing the threshold before a short-stroke is triggered. Prevents VR hand tracking jitter from dropping rounds.")] [Range(0.01f, 0.1f)] public float ReversalDeadzone = 0.035f; [Header("Muzzle Orientation")] [Tooltip("Angle between muzzle forward and straight up. If pointing downward past this angle during magazine pickup, the round drops free.")] [Range(0f, 180f)] public float MuzzleDownFailureAngle = 120f; [Header("Jam Ejection (Gravity Drops)")] [Tooltip("Velocity applied to a round dropped due to pointing the muzzle down, in local space.")] public Vector3 JamEjectionLocalVelocity = new Vector3(0f, -0.05f, 0.05f); [Tooltip("Angular velocity applied to a dropped round, in local space.")] public Vector3 JamEjectionLocalAngularVelocity = new Vector3(20f, 0f, 0f); [Header("Audio")] [Tooltip("Sound played when a round is left stuck in the action.")] public AudioEvent JamSound; [Header("Debugging")] public bool DebugMode = true; private float m_lastBoltLerp; private float m_lowestBoltLerpThisStroke = 1f; private bool m_wasProxyFullLastFrame; private bool m_hasInitializedLerp; private bool m_isCommittedThisStroke; private FVRFireArmRound m_looseCartridgeRound; private float m_looseCartridgeLerp; private FireArmRoundType m_looseCartridgeType; private FireArmRoundClass m_looseCartridgeClass; private bool m_hasLooseCartridgeInBreech; private bool m_lastTriggerCycledState; private void Awake() { if ((Object)(object)Rifle == (Object)null) { Rifle = ((Component)this).GetComponent(); } } private void OnDestroy() { CleanupLooseCartridge(); } private void Update() { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: 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_033c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Rifle == (Object)null || (Object)(object)Rifle.Chamber == (Object)null || (Object)(object)Rifle.m_proxy == (Object)null || (Object)(object)Rifle.Extraction_ChamberPos == (Object)null || (Object)(object)Rifle.Extraction_MagazinePos == (Object)null) { return; } float boltLerp = Rifle.BoltLerp; bool isFull = Rifle.m_proxy.IsFull; if (!m_hasInitializedLerp) { m_lastBoltLerp = boltLerp; m_lowestBoltLerpThisStroke = boltLerp; m_wasProxyFullLastFrame = isFull; m_hasInitializedLerp = true; return; } if (!UsesControlledFeed) { bool flag = boltLerp < m_lastBoltLerp; bool flag2 = boltLerp > m_lastBoltLerp; if (isFull && !m_wasProxyFullLastFrame && !m_hasLooseCartridgeInBreech) { float num = Vector3.Angle(((Component)Rifle).transform.forward, Vector3.up); if (num >= MuzzleDownFailureAngle) { if (DebugMode) { Debug.Log((object)("[PushFeed] Gravity failure: muzzle angled downward (" + num.ToString("F1") + " deg) during feed.")); } TriggerGravityFailure(); isFull = Rifle.m_proxy.IsFull; } } bool isFull2 = Rifle.Chamber.IsFull; if (isFull && !isFull2 && !m_hasLooseCartridgeInBreech) { if (boltLerp < m_lowestBoltLerpThisStroke) { m_lowestBoltLerpThisStroke = boltLerp; if (m_lowestBoltLerpThisStroke <= CommitThreshold && !m_isCommittedThisStroke) { m_isCommittedThisStroke = true; if (DebugMode) { Debug.Log((object)("[PushFeed] Round committed past feed lips at lerp " + boltLerp.ToString("F3"))); } } } if (m_isCommittedThisStroke && boltLerp > m_lowestBoltLerpThisStroke + ReversalDeadzone) { DetachRoundInBreech(m_lowestBoltLerpThisStroke); } } if (boltLerp >= 0.95f && !m_hasLooseCartridgeInBreech) { m_lowestBoltLerpThisStroke = 1f; m_isCommittedThisStroke = false; } if (m_hasLooseCartridgeInBreech) { if ((Object)(object)m_looseCartridgeRound != (Object)null && ((FVRInteractiveObject)m_looseCartridgeRound).IsHeld) { if (DebugMode) { Debug.Log((object)"[PushFeed] Loose cartridge grabbed by hand from breech."); } SetRifleRoundCollisionsIgnored(m_looseCartridgeRound, ignore: false); m_looseCartridgeRound = null; m_hasLooseCartridgeInBreech = false; m_isCommittedThisStroke = false; m_lowestBoltLerpThisStroke = 1f; Rifle.m_proxy.ClearProxy(); } else if (flag && boltLerp <= m_looseCartridgeLerp) { ReattachRoundToBoltProxy(boltLerp); } else if (boltLerp > 0.45f && (Object)(object)m_looseCartridgeRound != (Object)null) { float num2 = Vector3.Angle(((Component)Rifle).transform.forward, Vector3.up); float num3 = Vector3.Angle(((Component)Rifle).transform.up, Vector3.down); if (num2 >= MuzzleDownFailureAngle || num3 < 60f) { DumpLooseCartridgeToWorld(); } } } } if (DebugMode) { RunFiringDiagnostic(); } m_lastBoltLerp = boltLerp; m_wasProxyFullLastFrame = Rifle.m_proxy.IsFull; } private void LateUpdate() { if ((Object)(object)Rifle != (Object)null && (Object)(object)Rifle.Chamber != (Object)null && m_hasLooseCartridgeInBreech) { Rifle.Chamber.IsAccessible = false; } } private void RunFiringDiagnostic() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Invalid comparison between Unknown and I4 bool hasTriggerCycled = Rifle.m_hasTriggerCycled; if (hasTriggerCycled && !m_lastTriggerCycledState) { FireSelectorMode firingMode = Rifle.GetFiringMode(); bool flag = firingMode != null && (int)firingMode.ModeType == 0; bool isAltHeld = ((FVRPhysicalObject)Rifle).IsAltHeld; bool flag2 = (Object)(object)Rifle.BoltHandle != (Object)null && (int)Rifle.BoltHandle.HandleState == 0; bool flag3 = (Object)(object)Rifle.BoltHandle != (Object)null && (int)Rifle.BoltHandle.HandleRot != 0; bool isHammerCocked = Rifle.IsHammerCocked; bool isFull = Rifle.Chamber.IsFull; bool isSpent = Rifle.Chamber.IsSpent; FVRFireArmRound round = Rifle.Chamber.GetRound(); string text = ((!((Object)(object)round != (Object)null)) ? "NULL" : (((object)Unsafe.As(ref round.RoundType)/*cast due to .constrained prefix*/).ToString() + ":" + ((object)Unsafe.As(ref round.RoundClass)/*cast due to .constrained prefix*/).ToString())); Debug.Log((object)("[PushFeed Diagnostic] Trigger Pulled! | Safe: " + flag + " | AltHeld: " + isAltHeld + " | HandleForward: " + flag2 + " | HandleLockedDown: " + flag3 + " | HammerCocked: " + isHammerCocked + " | ChamberFull: " + isFull + " | ChamberSpent: " + isSpent + " | ChamberRound: " + text + " | ProxyFull: " + Rifle.m_proxy.IsFull + " | HasLooseInBreech: " + m_hasLooseCartridgeInBreech)); } m_lastTriggerCycledState = hasTriggerCycled; } private void TriggerGravityFailure() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_00c6: 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_00d5: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) FVRFireArmRound round = Rifle.m_proxy.Round; if ((Object)(object)round == (Object)null) { return; } FireArmRoundType roundType = round.RoundType; FireArmRoundClass roundClass = round.RoundClass; Rifle.m_proxy.ClearProxy(); GameObject gameObject = ((AnvilAsset)AM.GetRoundSelfPrefab(roundType, roundClass)).GetGameObject(); if ((Object)(object)gameObject != (Object)null) { Vector3 position = Rifle.Extraction_ChamberPos.position; Quaternion rotation = Rifle.Extraction_ChamberPos.rotation; GameObject val = Object.Instantiate(gameObject, position, rotation); FVRFireArmRound component = val.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)((FVRPhysicalObject)component).RootRigidbody != (Object)null) { Vector3 velocity = ((Component)Rifle).transform.TransformVector(JamEjectionLocalVelocity) + GM.CurrentMovementManager.GetFilteredVel(); Vector3 angularVelocity = ((Component)Rifle).transform.TransformVector(JamEjectionLocalAngularVelocity); ((FVRPhysicalObject)component).RootRigidbody.velocity = velocity; ((FVRPhysicalObject)component).RootRigidbody.maxAngularVelocity = 200f; ((FVRPhysicalObject)component).RootRigidbody.angularVelocity = angularVelocity; } } if (JamSound != null) { SM.PlayCoreSound((FVRPooledAudioType)10, JamSound, Rifle.Extraction_ChamberPos.position); } m_isCommittedThisStroke = false; m_lowestBoltLerpThisStroke = 1f; } private void DetachRoundInBreech(float detachmentLerp) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) FVRFireArmRound round = Rifle.m_proxy.Round; if ((Object)(object)round == (Object)null) { return; } m_looseCartridgeType = round.RoundType; m_looseCartridgeClass = round.RoundClass; m_looseCartridgeLerp = detachmentLerp; m_hasLooseCartridgeInBreech = true; CleanupLooseCartridge(); GameObject gameObject = ((AnvilAsset)AM.GetRoundSelfPrefab(m_looseCartridgeType, m_looseCartridgeClass)).GetGameObject(); if ((Object)(object)gameObject != (Object)null) { Vector3 val = Vector3.Lerp(Rifle.Extraction_ChamberPos.position, Rifle.Extraction_MagazinePos.position, detachmentLerp); Quaternion val2 = Quaternion.Slerp(Rifle.Extraction_ChamberPos.rotation, Rifle.Extraction_MagazinePos.rotation, detachmentLerp); GameObject val3 = Object.Instantiate(gameObject, val, val2); m_looseCartridgeRound = val3.GetComponent(); if ((Object)(object)m_looseCartridgeRound != (Object)null) { SetRifleRoundCollisionsIgnored(m_looseCartridgeRound, ignore: true); ((Component)m_looseCartridgeRound).transform.SetParent(((Component)Rifle).transform, true); if ((Object)(object)((FVRPhysicalObject)m_looseCartridgeRound).RootRigidbody != (Object)null) { ((FVRPhysicalObject)m_looseCartridgeRound).RootRigidbody.isKinematic = true; } } } if ((Object)(object)Rifle.m_proxy.ProxyRenderer != (Object)null) { ((Renderer)Rifle.m_proxy.ProxyRenderer).enabled = false; } if (JamSound != null) { SM.PlayCoreSound((FVRPooledAudioType)10, JamSound, Rifle.Extraction_ChamberPos.position); } if (DebugMode) { Debug.Log((object)string.Concat("[PushFeed] Short-stroke: Cartridge detached in breech at lerp ", detachmentLerp.ToString("F3"), " (", m_looseCartridgeType, " ", m_looseCartridgeClass, ")")); } m_isCommittedThisStroke = false; } private void ReattachRoundToBoltProxy(float currentBoltLerp) { if ((Object)(object)Rifle.m_proxy.ProxyRenderer != (Object)null) { ((Renderer)Rifle.m_proxy.ProxyRenderer).enabled = true; } CleanupLooseCartridge(); m_hasLooseCartridgeInBreech = false; m_isCommittedThisStroke = true; m_lowestBoltLerpThisStroke = currentBoltLerp; if (DebugMode) { Debug.Log((object)("[PushFeed] Bolt face contacted loose cartridge at lerp " + currentBoltLerp.ToString("F3") + "; pushing into battery.")); } } private void DumpLooseCartridgeToWorld() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_looseCartridgeRound == (Object)null) { m_hasLooseCartridgeInBreech = false; return; } SetRifleRoundCollisionsIgnored(m_looseCartridgeRound, ignore: false); ((Component)m_looseCartridgeRound).transform.SetParent((Transform)null, true); if ((Object)(object)((FVRPhysicalObject)m_looseCartridgeRound).RootRigidbody != (Object)null) { ((FVRPhysicalObject)m_looseCartridgeRound).RootRigidbody.isKinematic = false; ((FVRPhysicalObject)m_looseCartridgeRound).RootRigidbody.useGravity = true; ((FVRPhysicalObject)m_looseCartridgeRound).RootRigidbody.velocity = GM.CurrentMovementManager.GetFilteredVel(); ((FVRPhysicalObject)m_looseCartridgeRound).RootRigidbody.maxAngularVelocity = 200f; ((FVRPhysicalObject)m_looseCartridgeRound).RootRigidbody.angularVelocity = ((Component)Rifle).transform.right * 5f; } m_looseCartridgeRound = null; m_hasLooseCartridgeInBreech = false; m_isCommittedThisStroke = false; m_lowestBoltLerpThisStroke = 1f; Rifle.m_proxy.ClearProxy(); if (DebugMode) { Debug.Log((object)"[PushFeed] Loose cartridge dumped out of open action."); } } private void CleanupLooseCartridge() { if ((Object)(object)m_looseCartridgeRound != (Object)null) { SetRifleRoundCollisionsIgnored(m_looseCartridgeRound, ignore: false); if (!((FVRInteractiveObject)m_looseCartridgeRound).IsHeld) { Object.Destroy((Object)(object)((Component)m_looseCartridgeRound).gameObject); } m_looseCartridgeRound = null; } } private void SetRifleRoundCollisionsIgnored(FVRFireArmRound round, bool ignore) { if ((Object)(object)round == (Object)null || (Object)(object)Rifle == (Object)null) { return; } Collider[] componentsInChildren = ((Component)round).GetComponentsInChildren(true); Collider[] componentsInChildren2 = ((Component)Rifle).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { for (int j = 0; j < componentsInChildren2.Length; j++) { Physics.IgnoreCollision(componentsInChildren[i], componentsInChildren2[j], ignore); } } } } [DefaultExecutionOrder(-100)] public class StockControlFMG9 : MonoBehaviour { public ClosedBoltWeapon Gun; public MovableObjectPart FoldingPart; public List InteractiveObjectsToDisable = new List(); public List CollidersToDisable = new List(); public List GameObjectsToNoCol = new List(); public float FlickAngularThreshold = 10f; public float FlickLinearThreshold = 3f; public E_State FoldedState = (E_State)2; public bool IsSafeWhenMid = true; public bool DebugMode = false; private FieldInfo _currentPositionValueField; private FieldInfo _lastStateField; private Dictionary _originalColliderLayers = new Dictionary(); private Dictionary _originalGOLayers = new Dictionary(); private List _foldingPartColliders = new List(); private FireSelectorModeType[] _originalModes; private bool _wasFolded = false; private bool _hasInteractedYet = false; private float _flickCooldown = 0f; private void Start() { if ((Object)(object)FoldingPart != (Object)null) { _currentPositionValueField = typeof(MovableObjectPart).GetField("_currentPositionValue", BindingFlags.Instance | BindingFlags.NonPublic); _lastStateField = typeof(MovableObjectPart).GetField("_lastState", BindingFlags.Instance | BindingFlags.NonPublic); _foldingPartColliders.AddRange(((Component)FoldingPart).GetComponentsInChildren()); } if ((object)_currentPositionValueField == null || (object)_lastStateField == null) { Debug.LogError((object)"StockControlFMG9: Reflection failed to find required fields! Disabling script."); ((Behaviour)this).enabled = false; return; } foreach (Collider item in CollidersToDisable) { if ((Object)(object)item != (Object)null) { _originalColliderLayers[item] = ((Component)item).gameObject.layer; } } foreach (GameObject item2 in GameObjectsToNoCol) { if ((Object)(object)item2 != (Object)null) { _originalGOLayers[item2] = item2.layer; } } _wasFolded = false; OnUnfold(); } private void Update() { //IL_00c5: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Invalid comparison between Unknown and I4 //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)FoldingPart == (Object)null || (Object)(object)Gun == (Object)null) { return; } if (_flickCooldown > 0f) { _flickCooldown -= Time.deltaTime; } if (!_hasInteractedYet) { if (!((FVRInteractiveObject)FoldingPart).IsHeld) { _wasFolded = false; return; } _hasInteractedYet = true; if (DebugMode) { Debug.Log((object)"StockControlFMG9: Interaction detected. Activating tracking."); } } bool flag = EvaluateFoldState(); if (DebugMode) { Debug.Log((object)string.Concat("StockControlFMG9: State: ", FoldingPart.State, " | isFolded: ", flag, " | FoldedStateConfig: ", FoldedState)); } if (flag) { if (!_wasFolded) { _wasFolded = true; OnFold(); } } else if (_wasFolded) { _wasFolded = false; OnUnfold(); } if ((Object)(object)Gun.Bolt != (Object)null) { if ((int)Gun.Bolt.CurPos != 0 && !flag) { if (((FVRInteractiveObject)FoldingPart).IsHeld) { ((FVRInteractiveObject)FoldingPart).ForceBreakInteraction(); if (DebugMode) { Debug.Log((object)"StockControlFMG9: Bolt is back! Forcing stock interaction release."); } } SetCollidersActive(_foldingPartColliders, active: false); } else { SetCollidersActive(_foldingPartColliders, active: true); } } if (!flag || !(_flickCooldown <= 0f) || ((FVRInteractiveObject)FoldingPart).IsHeld || !((FVRInteractiveObject)Gun).IsHeld || (!((Object)(object)((FVRPhysicalObject)Gun).AltGrip == (Object)null) && ((FVRInteractiveObject)((FVRPhysicalObject)Gun).AltGrip).IsHeld) || !((Object)(object)((FVRPhysicalObject)Gun).RootRigidbody != (Object)null)) { return; } Vector3 angularVelocity = ((FVRPhysicalObject)Gun).RootRigidbody.angularVelocity; float magnitude = ((Vector3)(ref angularVelocity)).magnitude; Vector3 velocity = ((FVRPhysicalObject)Gun).RootRigidbody.velocity; float magnitude2 = ((Vector3)(ref velocity)).magnitude; if (magnitude > FlickAngularThreshold && magnitude2 > FlickLinearThreshold) { if (DebugMode) { Debug.Log((object)("StockControlFMG9: Flick detected! Angular: " + magnitude + " Linear: " + magnitude2)); } DeployStock(); } } private void DeployStock() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_008f: 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) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_00b7: 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_0108: Invalid comparison between Unknown and I4 //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_0189: Unknown result type (might be due to invalid IL or missing references) _flickCooldown = 0.5f; E_State val = (E_State)(((int)FoldedState == 0) ? 2 : 0); float num = (((int)val != 0) ? FoldingPart.UpperLimit : FoldingPart.LowerLimit); if ((object)_currentPositionValueField != null) { _currentPositionValueField.SetValue(FoldingPart, num); } if ((object)_lastStateField != null) { _lastStateField.SetValue(FoldingPart, val); } FoldingPart.State = val; if ((int)FoldingPart.MovementMode == 0) { UnityEngineExtensions.ModifyLocalPositionAxisValue(FoldingPart.ObjectToMove, FoldingPart.MovementAxis, num); } else if ((int)FoldingPart.MovementMode == 1) { UnityEngineExtensions.ModifyLocalRotationAxisValue(FoldingPart.ObjectToMove, FoldingPart.MovementAxis, num); } else if ((int)FoldingPart.MovementMode == 2) { FoldingPart.ObjectToMove.localRotation = OpenScripts2_BasePlugin.GetTargetQuaternionFromAxis(num, FoldingPart.MovementAxis); } ManipulateTransforms[] componentsInChildren = ((Component)Gun).GetComponentsInChildren(true); if (componentsInChildren != null) { for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { componentsInChildren[i].Awake(); } } } SM.PlayGenericSound(FoldingPart.OpenSounds, FoldingPart.ObjectToMove.position); } private bool EvaluateFoldState() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((int)FoldingPart.State == 1) { return IsSafeWhenMid; } return FoldingPart.State == FoldedState; } private void OnFold() { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected I4, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"StockControlFMG9: Safety engaged. Disabling target colliders."); } foreach (FVRInteractiveObject item in InteractiveObjectsToDisable) { if (!((Object)(object)item != (Object)null)) { continue; } item.ForceBreakInteraction(); if (item.m_colliders == null) { continue; } for (int i = 0; i < item.m_colliders.Length; i++) { if ((Object)(object)item.m_colliders[i] != (Object)null) { item.m_colliders[i].enabled = false; } } } if (Gun.FireSelector_Modes != null) { _originalModes = (FireSelectorModeType[])(object)new FireSelectorModeType[Gun.FireSelector_Modes.Length]; for (int j = 0; j < Gun.FireSelector_Modes.Length; j++) { if (Gun.FireSelector_Modes[j] != null) { _originalModes[j] = (FireSelectorModeType)(int)Gun.FireSelector_Modes[j].ModeType; Gun.FireSelector_Modes[j].ModeType = (FireSelectorModeType)0; } } } int num = LayerMask.NameToLayer("NoCol"); if (num == -1) { return; } foreach (Collider item2 in CollidersToDisable) { if ((Object)(object)item2 != (Object)null) { ((Component)item2).gameObject.layer = num; item2.enabled = false; } } foreach (GameObject item3 in GameObjectsToNoCol) { if ((Object)(object)item3 != (Object)null) { SetLayerRecursive(item3, num); } } } private void OnUnfold() { //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"StockControlFMG9: Safety disengaged. Restoring target colliders."); } foreach (FVRInteractiveObject item in InteractiveObjectsToDisable) { if (!((Object)(object)item != (Object)null) || item.m_colliders == null) { continue; } for (int i = 0; i < item.m_colliders.Length; i++) { if ((Object)(object)item.m_colliders[i] != (Object)null) { item.m_colliders[i].enabled = true; } } } if (Gun.FireSelector_Modes != null && _originalModes != null) { for (int j = 0; j < Gun.FireSelector_Modes.Length; j++) { if (Gun.FireSelector_Modes[j] != null && j < _originalModes.Length) { Gun.FireSelector_Modes[j].ModeType = _originalModes[j]; } } } foreach (Collider item2 in CollidersToDisable) { if ((Object)(object)item2 != (Object)null && _originalColliderLayers.TryGetValue(item2, out var value)) { ((Component)item2).gameObject.layer = value; item2.enabled = true; } } foreach (GameObject item3 in GameObjectsToNoCol) { if ((Object)(object)item3 != (Object)null && _originalGOLayers.TryGetValue(item3, out var value2)) { SetLayerRecursive(item3, value2); } } } private FieldInfo GetPrivateField(Type targetType, string fieldName) { Type type = targetType; while ((object)type != null) { FieldInfo field = type.GetField(fieldName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if ((object)field != null) { return field; } type = type.BaseType; } return null; } private void SetCollidersActive(List colliders, bool active) { for (int i = 0; i < colliders.Count; i++) { if ((Object)(object)colliders[i] != (Object)null && colliders[i].enabled != active) { colliders[i].enabled = active; } } } private void SetLayerRecursive(GameObject obj, int layer) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown obj.layer = layer; foreach (Transform item in obj.transform) { Transform val = item; SetLayerRecursive(((Component)val).gameObject, layer); } } private void OnDestroy() { _originalColliderLayers.Clear(); _originalGOLayers.Clear(); _foldingPartColliders.Clear(); } } public class ITR2Rack : MonoBehaviour { private class StoredItemTransform { public Vector3 localPosition; public Quaternion localRotation; } [Header("Rack Behavior")] [Tooltip("If true, objects already sitting inside the rack when the scene loads will automatically freeze in place.")] public bool freezeOnSceneStart = true; [Header("Slot Feedback")] [Tooltip("Optional placeholder geometry (e.g. a translucent silhouette or box outline) shown while a held item is inside the rack.")] public GameObject HoverGeo; [Tooltip("If true, the hand carrying an item gets a haptic buzz when the item enters the rack volume.")] public bool useHapticBuzzOnApproach = true; [Header("Audio Feedback")] [Tooltip("Optional audio to play when an item locks onto the rack.")] public AudioEvent lockSound; [Tooltip("Optional audio to play when an item is pulled off the rack.")] public AudioEvent grabSound; [Header("Debugging")] public bool debug = false; private List _trackedObjects = new List(); private List _frozenObjects = new List(); private Dictionary _wasHeldState = new Dictionary(); private Dictionary _storedItemOffsets = new Dictionary(); private List _rackColliders = new List(); private bool _hasHeldItemInside = false; private void Awake() { CacheRackColliders(); } private void Start() { if ((Object)(object)HoverGeo != (Object)null) { HoverGeo.SetActive(false); } } private void CacheRackColliders() { _rackColliders.Clear(); Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && !componentsInChildren[i].isTrigger) { _rackColliders.Add(componentsInChildren[i]); } } } private void Update() { bool flag = false; FVRViveHand val = null; for (int num = _trackedObjects.Count - 1; num >= 0; num--) { FVRPhysicalObject val2 = _trackedObjects[num]; if ((Object)(object)val2 == (Object)null || !((Component)val2).gameObject.activeInHierarchy) { _trackedObjects.RemoveAt(num); _frozenObjects.Remove(val2); _wasHeldState.Remove(val2); _storedItemOffsets.Remove(val2); } else { bool isHeld = ((FVRInteractiveObject)val2).IsHeld; bool value = false; _wasHeldState.TryGetValue(val2, out value); if (value && !isHeld) { FreezeObject(val2); _wasHeldState[val2] = false; } else if (!value && isHeld) { UnfreezeObject(val2); _wasHeldState[val2] = true; } if (isHeld) { flag = true; if ((Object)(object)val == (Object)null) { val = ((FVRInteractiveObject)val2).m_hand; } } } } if (flag && !_hasHeldItemInside) { if ((Object)(object)HoverGeo != (Object)null) { HoverGeo.SetActive(true); } if (useHapticBuzzOnApproach && (Object)(object)val != (Object)null) { val.Buzz(val.Buzzer.Buzz_OnHoverInventorySlot); } if (debug) { Debug.Log((object)"ITR2Rack: Held item entered the rack - showing indicator."); } } else if (!flag && _hasHeldItemInside) { if ((Object)(object)HoverGeo != (Object)null) { HoverGeo.SetActive(false); } if (debug) { Debug.Log((object)"ITR2Rack: No held item inside - hiding indicator."); } } _hasHeldItemInside = flag; } private void LateUpdate() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _frozenObjects.Count; i++) { FVRPhysicalObject val = _frozenObjects[i]; if ((Object)(object)val != (Object)null && !((FVRInteractiveObject)val).IsHeld && _storedItemOffsets.ContainsKey(val)) { StoredItemTransform storedItemTransform = _storedItemOffsets[val]; ((Component)val).transform.position = ((Component)this).transform.TransformPoint(storedItemTransform.localPosition); ((Component)val).transform.rotation = ((Component)this).transform.rotation * storedItemTransform.localRotation; } } } private void OnTriggerEnter(Collider other) { if ((Object)(object)other == (Object)null || (Object)(object)other.attachedRigidbody == (Object)null) { return; } FVRPhysicalObject component = ((Component)other.attachedRigidbody).GetComponent(); if ((Object)(object)component != (Object)null && !_trackedObjects.Contains(component)) { _trackedObjects.Add(component); _wasHeldState[component] = ((FVRInteractiveObject)component).IsHeld; if (freezeOnSceneStart && !((FVRInteractiveObject)component).IsHeld) { FreezeObject(component); } if (debug) { Debug.Log((object)("ITR2Rack: Object '" + ((Object)component).name + "' entered rack volume.")); } } } private void OnTriggerExit(Collider other) { if ((Object)(object)other == (Object)null || (Object)(object)other.attachedRigidbody == (Object)null) { return; } FVRPhysicalObject component = ((Component)other.attachedRigidbody).GetComponent(); if ((Object)(object)component != (Object)null && _trackedObjects.Contains(component) && !_frozenObjects.Contains(component)) { _trackedObjects.Remove(component); _wasHeldState.Remove(component); _storedItemOffsets.Remove(component); if (debug) { Debug.Log((object)("ITR2Rack: Object '" + ((Object)component).name + "' exited rack volume.")); } } } private void FreezeObject(FVRPhysicalObject physObj) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)physObj.RootRigidbody != (Object)null) { physObj.RootRigidbody.velocity = Vector3.zero; physObj.RootRigidbody.angularVelocity = Vector3.zero; physObj.SetIsKinematicLocked(true); physObj.RootRigidbody.detectCollisions = true; } StoredItemTransform storedItemTransform = new StoredItemTransform(); storedItemTransform.localPosition = ((Component)this).transform.InverseTransformPoint(((Component)physObj).transform.position); storedItemTransform.localRotation = Quaternion.Inverse(((Component)this).transform.rotation) * ((Component)physObj).transform.rotation; StoredItemTransform value = storedItemTransform; _storedItemOffsets[physObj] = value; SetCollisionIgnores(physObj, ignore: true); if (!_frozenObjects.Contains(physObj)) { _frozenObjects.Add(physObj); } if (lockSound != null) { SM.PlayCoreSound((FVRPooledAudioType)10, lockSound, ((Component)physObj).transform.position); } if (debug) { Debug.Log((object)("ITR2Rack: Froze '" + ((Object)physObj).name + "' (detectCollisions = true for hand grabbing).")); } } private void UnfreezeObject(FVRPhysicalObject physObj) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) SetCollisionIgnores(physObj, ignore: false); if ((Object)(object)physObj.RootRigidbody != (Object)null) { physObj.SetIsKinematicLocked(false); } _frozenObjects.Remove(physObj); _storedItemOffsets.Remove(physObj); if (grabSound != null) { SM.PlayCoreSound((FVRPooledAudioType)10, grabSound, ((Component)physObj).transform.position); } if (debug) { Debug.Log((object)("ITR2Rack: Unfroze '" + ((Object)physObj).name + "' for player interaction.")); } } private void SetCollisionIgnores(FVRPhysicalObject physObj, bool ignore) { if ((Object)(object)physObj == (Object)null) { return; } Collider[] componentsInChildren = ((Component)physObj).GetComponentsInChildren(true); for (int i = 0; i < _rackColliders.Count; i++) { Collider val = _rackColliders[i]; if ((Object)(object)val == (Object)null) { continue; } foreach (Collider val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !val2.isTrigger) { Physics.IgnoreCollision(val, val2, ignore); } } } for (int k = 0; k < _frozenObjects.Count; k++) { FVRPhysicalObject val3 = _frozenObjects[k]; if ((Object)(object)val3 == (Object)null || (Object)(object)val3 == (Object)(object)physObj) { continue; } Collider[] componentsInChildren2 = ((Component)val3).GetComponentsInChildren(true); foreach (Collider val4 in componentsInChildren) { if ((Object)(object)val4 == (Object)null || val4.isTrigger) { continue; } foreach (Collider val5 in componentsInChildren2) { if (!((Object)(object)val5 == (Object)null) && !val5.isTrigger) { Physics.IgnoreCollision(val4, val5, ignore); } } } } } private void OnDestroy() { for (int i = 0; i < _frozenObjects.Count; i++) { if ((Object)(object)_frozenObjects[i] != (Object)null) { UnfreezeObject(_frozenObjects[i]); } } _trackedObjects.Clear(); _frozenObjects.Clear(); _wasHeldState.Clear(); _rackColliders.Clear(); if ((Object)(object)HoverGeo != (Object)null) { HoverGeo.SetActive(false); } } } [DefaultExecutionOrder(-50)] public class QuickBeltAreaVaultFixer : MonoBehaviour { public QuickBeltArea targetArea; public bool snapObjectsOnLoad = true; public bool debug = false; private FieldInfo _dictField; private IDictionary _subQBSlotsDict; private void Awake() { if (((Object)((Component)this).gameObject).name.Contains("(Clone)")) { ((Object)((Component)this).gameObject).name = ((Object)((Component)this).gameObject).name.Replace("(Clone)", ""); if (debug) { Debug.Log((object)("QuickBeltAreaVaultFixer: Sanitized GameObject name to '" + ((Object)((Component)this).gameObject).name + "'.")); } } if ((Object)(object)targetArea == (Object)null) { targetArea = ((Component)this).GetComponent(); } _dictField = typeof(QuickBeltArea).GetField("_subQBSlotsDictionary", BindingFlags.Instance | BindingFlags.NonPublic); } private void Start() { if (((Object)((Component)this).gameObject).name.Contains("(Clone)")) { ((Object)((Component)this).gameObject).name = ((Object)((Component)this).gameObject).name.Replace("(Clone)", ""); } } private void LateUpdate() { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)targetArea == (Object)null || (object)_dictField == null) { return; } if (_subQBSlotsDict == null) { _subQBSlotsDict = _dictField.GetValue(targetArea) as IDictionary; if (_subQBSlotsDict == null) { return; } } List list = null; foreach (DictionaryEntry item in _subQBSlotsDict) { object key = item.Key; FVRQuickBeltSlot val = (FVRQuickBeltSlot)((key is FVRQuickBeltSlot) ? key : null); object? value = item.Value; FVRPhysicalObject val2 = (FVRPhysicalObject)((value is FVRPhysicalObject) ? value : null); if ((Object)(object)val != (Object)null && (Object)(object)val.CurObject != (Object)null && (Object)(object)val2 == (Object)null) { if (list == null) { list = new List(); } list.Add(val); } } if (list == null) { return; } for (int i = 0; i < list.Count; i++) { FVRQuickBeltSlot val3 = list[i]; FVRPhysicalObject curObject = val3.CurObject; _subQBSlotsDict[val3] = curObject; if (snapObjectsOnLoad && (Object)(object)curObject != (Object)null) { ((Component)curObject).transform.position = ((Component)val3).transform.position; ((Component)curObject).transform.rotation = ((Component)val3).transform.rotation; if ((Object)(object)curObject.RootRigidbody != (Object)null) { curObject.RootRigidbody.velocity = Vector3.zero; curObject.RootRigidbody.angularVelocity = Vector3.zero; } } if (debug) { Debug.Log((object)("QuickBeltAreaVaultFixer: Successfully synced and snapped unvaulted object '" + ((Object)curObject).name + "' into slot '" + ((Object)val3).name + "'.")); } } } } public class MagTapeFix : MonoBehaviour { private enum ActiveMagazine { primary, secondary } private enum AttachedMagazine { none, primary, secondary } [Tooltip("Enable status logging in the Unity console.")] public bool EnableDebug = false; [Tooltip("Main Magazine")] public FVRFireArmMagazine PrimaryMagazine; [Tooltip("Attached Magazine")] public FVRFireArmMagazine SecondaryMagazine; [Tooltip("The GameObject containing ONLY the Primary Magazine's 3D meshes/renderers.")] public GameObject PrimaryVisuals; [Tooltip("The GameObject containing ONLY the Secondary Magazine's 3D meshes/renderers.")] public GameObject SecondaryVisuals; [Tooltip("Tape visuals (optional)")] public GameObject Tape = null; [Header("Relative Mag Positions (Use Context Menu to calculate)")] [Tooltip("Primary mag position when parented to secondary mag.")] [ReadOnly] public Vector3 Primary2SecondaryPos; [Tooltip("Primary mag rotation when parented to secondary mag.")] [ReadOnly] public Quaternion Primary2SecondaryRot; [Tooltip("Secondary mag position when parented to primary mag.")] [ReadOnly] public Vector3 Secondary2PrimaryPos; [Tooltip("Primary mag rotation when parented to primary mag.")] [ReadOnly] public Quaternion Secondary2PrimaryRot; private ActiveMagazine _activeMagazine = ActiveMagazine.primary; private AttachedMagazine _attachedMagazine = AttachedMagazine.none; private void Log(string message, params object[] args) { if (EnableDebug) { if (args != null && args.Length > 0) { Debug.Log((object)string.Format(message, args)); } else { Debug.Log((object)message); } } } [ContextMenu("Calculate Relative Mag Positions")] public void CalculateReltativeMagPositions() { //IL_0018: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Secondary2PrimaryPos = ((Component)PrimaryMagazine).transform.InverseTransformPoint(((Component)SecondaryMagazine).transform.position); Secondary2PrimaryRot = Quaternion.Inverse(((Component)PrimaryMagazine).transform.rotation) * ((Component)SecondaryMagazine).transform.rotation; Primary2SecondaryPos = ((Component)SecondaryMagazine).transform.InverseTransformPoint(((Component)PrimaryMagazine).transform.position); Primary2SecondaryRot = Quaternion.Inverse(((Component)SecondaryMagazine).transform.rotation) * ((Component)PrimaryMagazine).transform.rotation; Log("[MagTapeFix] Relative positions calculated and updated in Inspector."); } public void Start() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Invalid comparison between Unknown and I4 Log("[MagTapeFix] Initializing..."); if ((int)PrimaryMagazine.State == 1) { Log("[MagTapeFix] Primary Magazine spawned in LOCKED state."); _attachedMagazine = AttachedMagazine.primary; ((FVRPhysicalObject)SecondaryMagazine).StoreAndDestroyRigidbody(); SecondaryVisuals.transform.SetParent(((Component)PrimaryMagazine).transform, true); ((Component)SecondaryMagazine).gameObject.SetActive(false); ((Component)PrimaryMagazine).gameObject.SetActive(true); PrimaryVisuals.transform.SetParent(((Component)PrimaryMagazine).transform, true); } else if ((int)SecondaryMagazine.State == 1) { Log("[MagTapeFix] Secondary Magazine spawned in LOCKED state."); _attachedMagazine = AttachedMagazine.secondary; _activeMagazine = ActiveMagazine.secondary; ((FVRPhysicalObject)PrimaryMagazine).StoreAndDestroyRigidbody(); PrimaryVisuals.transform.SetParent(((Component)SecondaryMagazine).transform, true); ((Component)PrimaryMagazine).gameObject.SetActive(false); ((Component)SecondaryMagazine).gameObject.SetActive(true); SecondaryVisuals.transform.SetParent(((Component)SecondaryMagazine).transform, true); } else if ((Object)(object)((Component)PrimaryMagazine).transform.parent == (Object)(object)((Component)SecondaryMagazine).transform) { Log("[MagTapeFix] Spawning with Secondary as parent."); _activeMagazine = ActiveMagazine.secondary; ((FVRPhysicalObject)PrimaryMagazine).StoreAndDestroyRigidbody(); PrimaryVisuals.transform.SetParent(((Component)SecondaryMagazine).transform, true); ((Component)PrimaryMagazine).gameObject.SetActive(false); ((Component)SecondaryMagazine).gameObject.SetActive(true); SecondaryVisuals.transform.SetParent(((Component)SecondaryMagazine).transform, true); } else { Log("[MagTapeFix] Spawning default (Primary Active)."); _activeMagazine = ActiveMagazine.primary; ((FVRPhysicalObject)SecondaryMagazine).StoreAndDestroyRigidbody(); SecondaryVisuals.transform.SetParent(((Component)PrimaryMagazine).transform, true); ((Component)SecondaryMagazine).gameObject.SetActive(false); ((Component)PrimaryMagazine).gameObject.SetActive(true); PrimaryVisuals.transform.SetParent(((Component)PrimaryMagazine).transform, true); } } public void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Invalid comparison between Unknown and I4 //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) try { if ((int)PrimaryMagazine.State == 1 && _attachedMagazine == AttachedMagazine.none && _activeMagazine == ActiveMagazine.secondary) { Log("[MagTapeFix] Auto-Reload: Primary Magazine locked into magwell. Swapping parents automatically."); _attachedMagazine = AttachedMagazine.primary; ((FVRInteractiveObject)SecondaryMagazine).ForceBreakInteraction(); ((FVRInteractiveObject)SecondaryMagazine).IsHeld = false; UsePrimaryAsParent(((Component)PrimaryMagazine).transform.parent); ((FVRPhysicalObject)SecondaryMagazine).StoreAndDestroyRigidbody(); SecondaryVisuals.transform.SetParent(((Component)PrimaryMagazine).transform, true); ((Component)SecondaryMagazine).gameObject.SetActive(false); ((Component)PrimaryMagazine).gameObject.SetActive(true); PrimaryVisuals.transform.SetParent(((Component)PrimaryMagazine).transform, true); } else if ((int)SecondaryMagazine.State == 1 && _attachedMagazine == AttachedMagazine.none && _activeMagazine == ActiveMagazine.primary) { Log("[MagTapeFix] Auto-Reload: Secondary Magazine locked into magwell. Swapping parents automatically."); _attachedMagazine = AttachedMagazine.secondary; ((FVRInteractiveObject)PrimaryMagazine).ForceBreakInteraction(); ((FVRInteractiveObject)PrimaryMagazine).IsHeld = false; UseSecondaryAsParent(((Component)SecondaryMagazine).transform.parent); ((FVRPhysicalObject)PrimaryMagazine).StoreAndDestroyRigidbody(); PrimaryVisuals.transform.SetParent(((Component)SecondaryMagazine).transform, true); ((Component)PrimaryMagazine).gameObject.SetActive(false); ((Component)SecondaryMagazine).gameObject.SetActive(true); SecondaryVisuals.transform.SetParent(((Component)SecondaryMagazine).transform, true); } else if ((int)PrimaryMagazine.State == 0 && (int)SecondaryMagazine.State == 0 && _attachedMagazine != AttachedMagazine.none) { Log("[MagTapeFix] Both magazines are now free (unlocked). Resetting attachment tracking."); _attachedMagazine = AttachedMagazine.none; } if (_activeMagazine == ActiveMagazine.primary) { UpdateSecondaryMagTransform(); } else if (_activeMagazine == ActiveMagazine.secondary) { UpdatePrimaryMagTransform(); } } catch (Exception ex) { if ((Object)(object)PrimaryMagazine == (Object)null || (Object)(object)SecondaryMagazine == (Object)null) { Debug.LogWarning((object)"[MagTapeFix] A magazine was destroyed! Cleaning up component."); Object.Destroy((Object)(object)Tape); Object.Destroy((Object)(object)((Component)this).GetComponent()); } else { Debug.LogError((object)("[MagTapeFix] Error in Update Loop: " + ex.Message)); } } if (_activeMagazine == ActiveMagazine.primary) { if (!((Object)(object)((FVRInteractiveObject)PrimaryMagazine).m_hand != (Object)null)) { return; } FVRViveHand hand = ((FVRInteractiveObject)PrimaryMagazine).m_hand; if (hand.IsInStreamlinedMode) { if (hand.Input.AXButtonDown || hand.Input.TouchpadDown) { Log("[MagTapeFix] Input detected (Streamlined). Initiating manual pose swap to Secondary."); ChangeActiveToSecondary(hand); } } else if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.right) < 45f) { Log("[MagTapeFix] Input detected (Classic). Initiating manual pose swap to Secondary."); ChangeActiveToSecondary(hand); } } else { if (_activeMagazine != ActiveMagazine.secondary || !((Object)(object)((FVRInteractiveObject)SecondaryMagazine).m_hand != (Object)null)) { return; } FVRViveHand hand2 = ((FVRInteractiveObject)SecondaryMagazine).m_hand; if (hand2.IsInStreamlinedMode) { if (hand2.Input.AXButtonDown || hand2.Input.TouchpadDown) { Log("[MagTapeFix] Input detected (Streamlined). Initiating manual pose swap to Primary."); ChangeActiveToPrimary(hand2); } } else if (hand2.Input.TouchpadDown && Vector2.Angle(hand2.Input.TouchpadAxes, Vector2.right) < 45f) { Log("[MagTapeFix] Input detected (Classic). Initiating manual pose swap to Primary."); ChangeActiveToPrimary(hand2); } } } private void UsePrimaryAsParent(Transform parent = null) { Log("[MagTapeFix] Parenting Secondary under Primary."); _activeMagazine = ActiveMagazine.primary; ((Component)PrimaryMagazine).transform.SetParent(parent); ((Component)SecondaryMagazine).transform.SetParent(((Component)PrimaryMagazine).transform); } private void UseSecondaryAsParent(Transform parent = null) { Log("[MagTapeFix] Parenting Primary under Secondary."); _activeMagazine = ActiveMagazine.secondary; ((Component)SecondaryMagazine).transform.SetParent(parent); ((Component)PrimaryMagazine).transform.SetParent(((Component)SecondaryMagazine).transform); } private void UpdateSecondaryMagTransform() { //IL_000d: 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) ((Component)SecondaryMagazine).transform.localPosition = Secondary2PrimaryPos; ((Component)SecondaryMagazine).transform.localRotation = Secondary2PrimaryRot; } private void UpdatePrimaryMagTransform() { //IL_000d: 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) ((Component)PrimaryMagazine).transform.localPosition = Primary2SecondaryPos; ((Component)PrimaryMagazine).transform.localRotation = Primary2SecondaryRot; } private void ChangeActiveToPrimary(FVRViveHand hand) { Log("[MagTapeFix] Manually activating Primary Magazine..."); ((FVRInteractiveObject)SecondaryMagazine).ForceBreakInteraction(); ((FVRInteractiveObject)SecondaryMagazine).IsHeld = false; ((Component)SecondaryMagazine).gameObject.layer = LayerMask.NameToLayer("NoCol"); SecondaryVisuals.transform.SetParent(((Component)PrimaryMagazine).transform, true); ((Component)SecondaryMagazine).gameObject.SetActive(false); ((Component)PrimaryMagazine).gameObject.SetActive(true); PrimaryVisuals.transform.SetParent(((Component)PrimaryMagazine).transform, true); ((FVRPhysicalObject)PrimaryMagazine).RecoverRigidbody(); UsePrimaryAsParent(); ((FVRPhysicalObject)SecondaryMagazine).StoreAndDestroyRigidbody(); hand.ForceSetInteractable((FVRInteractiveObject)(object)PrimaryMagazine); ((FVRInteractiveObject)PrimaryMagazine).BeginInteraction(hand); ((Component)PrimaryMagazine).gameObject.layer = LayerMask.NameToLayer("Interactable"); Log("[MagTapeFix] Manual pose swap complete. Primary is now active."); } private void ChangeActiveToSecondary(FVRViveHand hand) { Log("[MagTapeFix] Manually activating Secondary Magazine..."); ((FVRInteractiveObject)PrimaryMagazine).ForceBreakInteraction(); ((FVRInteractiveObject)PrimaryMagazine).IsHeld = false; ((Component)PrimaryMagazine).gameObject.layer = LayerMask.NameToLayer("NoCol"); PrimaryVisuals.transform.SetParent(((Component)SecondaryMagazine).transform, true); ((Component)PrimaryMagazine).gameObject.SetActive(false); ((Component)SecondaryMagazine).gameObject.SetActive(true); SecondaryVisuals.transform.SetParent(((Component)SecondaryMagazine).transform, true); ((FVRPhysicalObject)SecondaryMagazine).RecoverRigidbody(); UseSecondaryAsParent(); ((FVRPhysicalObject)PrimaryMagazine).StoreAndDestroyRigidbody(); hand.ForceSetInteractable((FVRInteractiveObject)(object)SecondaryMagazine); ((FVRInteractiveObject)SecondaryMagazine).BeginInteraction(hand); ((Component)SecondaryMagazine).gameObject.layer = LayerMask.NameToLayer("Interactable"); Log("[MagTapeFix] Manual pose swap complete. Secondary is now active."); } } public class LinearBayonet : AttachableMeleeWeapon { public enum State { Free, Locked, Sliding } public State CurrentState = State.Free; public bool DebugMode = false; [HideInInspector] public LinearSheath Sheath; public Collider HandleCollider; public Collider[] BladeColliders; public Vector3 RotationOffset = Vector3.zero; public float LockThreshold = 0.04f; public float MinTravelToLock = 0.05f; public float DetachMargin = 0.03f; public float DropLockThreshold = 0.06f; private float _grabOffset; private bool _canLock = false; private QuickbeltSlotType _origSlotType; private FVRPhysicalObjectSize _origSize; private bool _origUsesSweepTesting; public override void Awake() { //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArmAttachment)this).Awake(); if (DebugMode) { Debug.Log((object)"[LinearBayonet] Awake called."); } _origSlotType = ((FVRPhysicalObject)this).QBSlotType; _origSize = ((FVRPhysicalObject)this).Size; _origUsesSweepTesting = ((FVRPhysicalObject)this).MP != null && ((FVRPhysicalObject)this).MP.UsesSweepTesting; } public override bool IsInteractable() { if (CurrentState == State.Locked || CurrentState == State.Sliding) { return !((FVRPhysicalObject)this).IsPickUpLocked; } return ((FVRFireArmAttachment)this).IsInteractable(); } public override bool IsDistantGrabbable() { if ((Object)(object)((Component)this).transform.parent != (Object)null && (CurrentState == State.Locked || CurrentState == State.Sliding)) { return false; } return ((FVRPhysicalObject)this).IsDistantGrabbable(); } public override void FVRFixedUpdate() { ((FVRFireArmAttachment)this).FVRFixedUpdate(); if ((Object)(object)((Component)this).transform.parent == (Object)null && !((FVRInteractiveObject)this).IsHeld && (CurrentState == State.Locked || CurrentState == State.Sliding)) { CurrentState = State.Free; if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = false; ((FVRPhysicalObject)this).RootRigidbody.useGravity = ((FVRPhysicalObject)this).UsesGravity; } } } public override void BeginInteraction(FVRViveHand hand) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_00b2: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)("[LinearBayonet] BeginInteraction in State: " + CurrentState)); } if ((CurrentState == State.Locked || CurrentState == State.Sliding) && (Object)(object)((Component)this).transform.parent != (Object)null && (Object)(object)Sheath != (Object)null) { bool flag = CurrentState == State.Locked; CurrentState = State.Sliding; ((FVRFireArmAttachment)this).BeginInteraction(hand); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } ((FVRPhysicalObject)this).QBSlotType = (QuickbeltSlotType)(-1); ((FVRPhysicalObject)this).Size = (FVRPhysicalObjectSize)(-1); Vector3 val = Sheath.UnsheathedPoint.position - Sheath.SheathedPoint.position; Vector3 normalized = ((Vector3)(ref val)).normalized; _grabOffset = Vector3.Dot(((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position, normalized); _canLock = !flag; } else { CurrentState = State.Free; ((FVRFireArmAttachment)this).BeginInteraction(hand); } } public override void UpdateInteraction(FVRViveHand hand) { //IL_0054: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArmAttachment)this).UpdateInteraction(hand); if (CurrentState != State.Sliding) { return; } if ((Object)(object)((Component)this).transform.parent == (Object)null || (Object)(object)Sheath == (Object)null) { DetachBayonetFromSheath(hand); return; } Vector3 val = Sheath.UnsheathedPoint.position - Sheath.SheathedPoint.position; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = ((FVRInteractiveObject)this).m_handPos - normalized * _grabOffset; Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(Sheath.UnsheathedPoint.position, Sheath.SheathedPoint.position, val2); ((Component)this).transform.position = closestValidPoint; ((Component)this).transform.rotation = Sheath.SheathedPoint.rotation * Quaternion.Euler(RotationOffset); float num = Vector3.Distance(((Component)this).transform.position, Sheath.SheathedPoint.position); float num2 = Vector3.Distance(Sheath.SheathedPoint.position, Sheath.UnsheathedPoint.position); if (DebugMode) { Debug.Log((object)("[LinearBayonet] Slide Dist: " + num + " / " + num2 + " (Can Lock: " + _canLock + ")")); } if (num > MinTravelToLock) { _canLock = true; } if (_canLock && num <= LockThreshold) { LockToSheathInternal(); return; } float num3 = Vector3.Dot(val2 - Sheath.SheathedPoint.position, normalized); if (num3 > num2 + DetachMargin) { DetachBayonetFromSheath(hand); } } public override void EndInteraction(FVRViveHand hand) { //IL_0074: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)("[LinearBayonet] EndInteraction in State: " + CurrentState)); } State currentState = CurrentState; ((FVRFireArmAttachment)this).EndInteraction(hand); if (currentState == State.Locked && (Object)(object)Sheath != (Object)null) { ((Component)this).transform.SetParent(((Component)Sheath).transform); ((Component)this).transform.position = Sheath.SheathedPoint.position; ((Component)this).transform.rotation = Sheath.SheathedPoint.rotation * Quaternion.Euler(RotationOffset); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } CurrentState = State.Locked; } else { if (currentState != State.Sliding || !((Object)(object)Sheath != (Object)null)) { return; } float num = Vector3.Distance(((Component)this).transform.position, Sheath.SheathedPoint.position); float num2 = Vector3.Distance(Sheath.SheathedPoint.position, Sheath.UnsheathedPoint.position); if (num <= DropLockThreshold) { LockToSheathInternal(); return; } if (num >= num2 * 0.85f) { DetachBayonetFromSheath(null); return; } ((Component)this).transform.SetParent(((Component)Sheath).transform); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } CurrentState = State.Sliding; } } public override void SetQuickBeltSlot(FVRQuickBeltSlot slot) { ((FVRPhysicalObject)this).SetQuickBeltSlot(slot); if ((Object)(object)slot != (Object)null && (Object)(object)Sheath != (Object)null && Sheath.CurrentState == LinearSheath.SheathState.Locked && (Object)(object)Sheath.SheathBodyCollider != (Object)null) { ((Component)Sheath.SheathBodyCollider).gameObject.layer = LayerMask.NameToLayer("Interactable"); } } public void InitiateSheathing(LinearSheath sheath) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"[LinearBayonet] InitiateSheathing called."); } if (((FVRInteractiveObject)this).IsHeld && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { ((FVRInteractiveObject)this).m_hand.ForceSetInteractable((FVRInteractiveObject)null); } Sheath = sheath; ((Component)this).transform.SetParent(((Component)sheath).transform); ((Component)this).transform.position = sheath.SheathedPoint.position; ((Component)this).transform.rotation = sheath.SheathedPoint.rotation * Quaternion.Euler(RotationOffset); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } CurrentState = State.Locked; ((FVRPhysicalObject)this).QBSlotType = _origSlotType; ((FVRPhysicalObject)this).Size = _origSize; if (((FVRPhysicalObject)this).MP != null) { ((FVRPhysicalObject)this).MP.UsesSweepTesting = false; } if ((Object)(object)HandleCollider != (Object)null) { ((Component)HandleCollider).gameObject.layer = LayerMask.NameToLayer("Interactable"); } } public void MountToTrackForInsertion(LinearSheath sheath, FVRViveHand hand) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_0124: 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) //IL_012e: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"[LinearBayonet] MountToTrackForInsertion triggered."); } Sheath = sheath; ((Component)this).transform.SetParent(((Component)sheath).transform); ((Component)this).transform.position = ((FVRInteractiveObject)this).GetClosestValidPoint(sheath.UnsheathedPoint.position, sheath.SheathedPoint.position, ((Component)this).transform.position); ((Component)this).transform.rotation = sheath.SheathedPoint.rotation * Quaternion.Euler(RotationOffset); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } CurrentState = State.Sliding; ((FVRPhysicalObject)this).QBSlotType = (QuickbeltSlotType)(-1); ((FVRPhysicalObject)this).Size = (FVRPhysicalObjectSize)(-1); _canLock = true; Vector3 val = sheath.UnsheathedPoint.position - sheath.SheathedPoint.position; Vector3 normalized = ((Vector3)(ref val)).normalized; if ((Object)(object)hand != (Object)null) { _grabOffset = Vector3.Dot(((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position, normalized); } } public void LockToSheathInternal() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //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_0116: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"[LinearBayonet] LockToSheathInternal triggered."); } ((Component)this).transform.position = Sheath.SheathedPoint.position; ((Component)this).transform.rotation = Sheath.SheathedPoint.rotation * Quaternion.Euler(RotationOffset); CurrentState = State.Locked; ((FVRPhysicalObject)this).QBSlotType = _origSlotType; ((FVRPhysicalObject)this).Size = _origSize; if ((Object)(object)HandleCollider != (Object)null) { ((Component)HandleCollider).gameObject.layer = LayerMask.NameToLayer("Interactable"); } if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { ((FVRInteractiveObject)this).m_hand.Buzz(((FVRInteractiveObject)this).m_hand.Buzzer.Buzz_BeginInteraction); ((FVRInteractiveObject)this).m_hand.ForceSetInteractable((FVRInteractiveObject)null); } if ((Object)(object)Sheath != (Object)null && Sheath.AudioSheathLock != null) { SM.PlayCoreSound((FVRPooledAudioType)0, Sheath.AudioSheathLock, ((Component)this).transform.position); } } private void DetachBayonetFromSheath(FVRViveHand hand) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0148: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"[LinearBayonet] DetachBayonetFromSheath triggered."); } CurrentState = State.Free; ((Component)this).transform.SetParent((Transform)null); ((FVRPhysicalObject)this).QBSlotType = _origSlotType; ((FVRPhysicalObject)this).Size = _origSize; if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = false; ((FVRPhysicalObject)this).RootRigidbody.useGravity = ((FVRPhysicalObject)this).UsesGravity; } if (((FVRPhysicalObject)this).MP != null) { ((FVRPhysicalObject)this).MP.UsesSweepTesting = _origUsesSweepTesting; } if (BladeColliders != null) { Collider[] bladeColliders = BladeColliders; foreach (Collider val in bladeColliders) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.layer = LayerMask.NameToLayer("Default"); } } } if ((Object)(object)Sheath != (Object)null) { Sheath.SetSheathingCooldown(Sheath.SheathCooldownDuration); Sheath.Bayonet = null; } if ((Object)(object)hand != (Object)null) { hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); if (((FVRFireArmAttachment)this).AudClipDettach != null) { SM.PlayCoreSound((FVRPooledAudioType)0, ((FVRFireArmAttachment)this).AudClipDettach, ((Component)this).transform.position); } hand.ForceSetInteractable((FVRInteractiveObject)(object)this); ((FVRPhysicalObject)this).SetQuickBeltSlot((FVRQuickBeltSlot)null); ((FVRInteractiveObject)this).BeginInteraction(hand); } } } public class LinearSheath : FVRPhysicalObject { public enum SheathState { Free, Locked, Sliding } public SheathState CurrentState = SheathState.Free; public bool DebugMode = false; [HideInInspector] public LinearBayonet Bayonet; public Collider SheathBodyCollider; public Collider EntranceTrigger; public AudioEvent AudioSheathLock; public AudioEvent AudioDrawDetach; public Transform SheathedPoint; public Transform UnsheathedPoint; public Vector3 RotationOffset = Vector3.zero; public float LockThreshold = 0.04f; public float DetachMargin = 0.03f; public float DropLockThreshold = 0.06f; public float SheathCooldownDuration = 1.5f; private float _grabOffset; private float _sheathingCooldown = 0f; public override void Awake() { ((FVRPhysicalObject)this).Awake(); if (DebugMode) { Debug.Log((object)"[LinearSheath] Awake called."); } if ((Object)(object)EntranceTrigger != (Object)null) { ((Component)EntranceTrigger).gameObject.layer = LayerMask.NameToLayer("Default"); EntranceTrigger.isTrigger = true; SheathTrigger sheathTrigger = ((Component)EntranceTrigger).gameObject.GetComponent(); if ((Object)(object)sheathTrigger == (Object)null) { sheathTrigger = ((Component)EntranceTrigger).gameObject.AddComponent(); } sheathTrigger.Sheath = this; } } public override void FVRUpdate() { ((FVRPhysicalObject)this).FVRUpdate(); if (_sheathingCooldown > 0f) { _sheathingCooldown -= Time.deltaTime; } } public override void FVRFixedUpdate() { ((FVRPhysicalObject)this).FVRFixedUpdate(); if ((Object)(object)((Component)this).transform.parent == (Object)null && !((FVRInteractiveObject)this).IsHeld && (CurrentState == SheathState.Locked || CurrentState == SheathState.Sliding)) { CurrentState = SheathState.Free; if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = false; ((FVRPhysicalObject)this).RootRigidbody.useGravity = base.UsesGravity; } } } public void SetSheathingCooldown(float duration) { _sheathingCooldown = duration; } public override bool IsInteractable() { if (CurrentState == SheathState.Locked || CurrentState == SheathState.Sliding) { return !base.IsPickUpLocked; } return ((FVRPhysicalObject)this).IsInteractable(); } public override bool IsDistantGrabbable() { if ((Object)(object)((Component)this).transform.parent != (Object)null && (CurrentState == SheathState.Locked || CurrentState == SheathState.Sliding)) { return false; } return ((FVRPhysicalObject)this).IsDistantGrabbable(); } public override void BeginInteraction(FVRViveHand hand) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00a1: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)("[LinearSheath] BeginInteraction in State: " + CurrentState)); } if ((CurrentState == SheathState.Locked || CurrentState == SheathState.Sliding) && (Object)(object)((Component)this).transform.parent != (Object)null) { bool flag = CurrentState == SheathState.Locked; CurrentState = SheathState.Sliding; ((FVRPhysicalObject)this).BeginInteraction(hand); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } Vector3 val = UnsheathedPoint.position - SheathedPoint.position; Vector3 normalized = ((Vector3)(ref val)).normalized; _grabOffset = Vector3.Dot(((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position, normalized); } else { CurrentState = SheathState.Free; ((FVRPhysicalObject)this).BeginInteraction(hand); } } public override void UpdateInteraction(FVRViveHand hand) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_005d: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_00c7: 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_016e: 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_017f: Unknown result type (might be due to invalid IL or missing references) ((FVRPhysicalObject)this).UpdateInteraction(hand); if (CurrentState != SheathState.Sliding) { return; } if ((Object)(object)((Component)this).transform.parent == (Object)null) { DetachSheathFromBayonet(hand); return; } Vector3 val = UnsheathedPoint.position - SheathedPoint.position; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = ((FVRInteractiveObject)this).m_handPos - normalized * _grabOffset; Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(UnsheathedPoint.position, SheathedPoint.position, val2); ((Component)this).transform.position = closestValidPoint; if ((Object)(object)Bayonet != (Object)null) { ((Component)this).transform.rotation = ((Component)Bayonet).transform.rotation * Quaternion.Euler(RotationOffset); } float num = Vector3.Distance(((Component)this).transform.position, SheathedPoint.position); float num2 = Vector3.Distance(SheathedPoint.position, UnsheathedPoint.position); if (DebugMode) { Debug.Log((object)("[LinearSheath] Slide Dist: " + num + " / " + num2)); } if (num <= LockThreshold) { LockToBayonetInternal(); return; } float num3 = Vector3.Dot(val2 - SheathedPoint.position, normalized); if (num3 > num2 + DetachMargin) { DetachSheathFromBayonet(hand); } } public override void EndInteraction(FVRViveHand hand) { //IL_006f: 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) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)("[LinearSheath] EndInteraction in State: " + CurrentState)); } SheathState currentState = CurrentState; ((FVRPhysicalObject)this).EndInteraction(hand); if (currentState == SheathState.Locked && (Object)(object)Bayonet != (Object)null) { ((Component)this).transform.SetParent(((Component)Bayonet).transform); ((Component)this).transform.position = SheathedPoint.position; ((Component)this).transform.rotation = ((Component)Bayonet).transform.rotation * Quaternion.Euler(RotationOffset); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } CurrentState = SheathState.Locked; } else { if (currentState != SheathState.Sliding || !((Object)(object)Bayonet != (Object)null)) { return; } float num = Vector3.Distance(((Component)this).transform.position, SheathedPoint.position); float num2 = Vector3.Distance(SheathedPoint.position, UnsheathedPoint.position); if (num <= DropLockThreshold) { LockToBayonetInternal(); return; } if (num >= num2 * 0.85f) { DetachSheathFromBayonet(null); return; } ((Component)this).transform.SetParent(((Component)Bayonet).transform); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } CurrentState = SheathState.Sliding; } } public override void SetQuickBeltSlot(FVRQuickBeltSlot slot) { ((FVRPhysicalObject)this).SetQuickBeltSlot(slot); if ((Object)(object)slot != (Object)null && (Object)(object)Bayonet != (Object)null && Bayonet.CurrentState == LinearBayonet.State.Locked && (Object)(object)Bayonet.HandleCollider != (Object)null) { ((Component)Bayonet.HandleCollider).gameObject.layer = LayerMask.NameToLayer("Interactable"); } } public void InitiateSheathing(LinearBayonet bayonet) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"[LinearSheath] InitiateSheathing called."); } if (((FVRInteractiveObject)this).IsHeld && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { ((FVRInteractiveObject)this).m_hand.ForceSetInteractable((FVRInteractiveObject)null); } Bayonet = bayonet; ((Component)this).transform.SetParent(((Component)bayonet).transform); ((Component)this).transform.position = SheathedPoint.position; ((Component)this).transform.rotation = ((Component)bayonet).transform.rotation * Quaternion.Euler(RotationOffset); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } CurrentState = SheathState.Locked; SetMeleeGunState(active: false); if ((Object)(object)SheathBodyCollider != (Object)null) { ((Component)SheathBodyCollider).gameObject.layer = LayerMask.NameToLayer("Interactable"); } } public void MountToTrackForInsertion(LinearBayonet bayonet, FVRViveHand hand) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0120: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"[LinearSheath] MountToTrackForInsertion triggered."); } Bayonet = bayonet; ((Component)this).transform.SetParent(((Component)bayonet).transform); ((Component)this).transform.position = ((FVRInteractiveObject)this).GetClosestValidPoint(UnsheathedPoint.position, SheathedPoint.position, ((Component)this).transform.position); ((Component)this).transform.rotation = ((Component)bayonet).transform.rotation * Quaternion.Euler(RotationOffset); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = true; ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } CurrentState = SheathState.Sliding; SetMeleeGunState(active: false); Vector3 val = UnsheathedPoint.position - SheathedPoint.position; Vector3 normalized = ((Vector3)(ref val)).normalized; if ((Object)(object)hand != (Object)null) { _grabOffset = Vector3.Dot(((HandInput)(ref hand.Input)).Pos - ((Component)this).transform.position, normalized); } } public void LockToBayonetInternal() { //IL_0022: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"[LinearSheath] LockToBayonetInternal triggered."); } ((Component)this).transform.position = SheathedPoint.position; if ((Object)(object)Bayonet != (Object)null) { ((Component)this).transform.rotation = ((Component)Bayonet).transform.rotation * Quaternion.Euler(RotationOffset); } CurrentState = SheathState.Locked; SetMeleeGunState(active: false); if ((Object)(object)SheathBodyCollider != (Object)null) { ((Component)SheathBodyCollider).gameObject.layer = LayerMask.NameToLayer("Interactable"); } if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { ((FVRInteractiveObject)this).m_hand.Buzz(((FVRInteractiveObject)this).m_hand.Buzzer.Buzz_BeginInteraction); ((FVRInteractiveObject)this).m_hand.ForceSetInteractable((FVRInteractiveObject)null); } if (AudioSheathLock != null) { SM.PlayCoreSound((FVRPooledAudioType)0, AudioSheathLock, ((Component)this).transform.position); } } private void DetachSheathFromBayonet(FVRViveHand hand) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (DebugMode) { Debug.Log((object)"[LinearSheath] DetachSheathFromBayonet triggered."); } CurrentState = SheathState.Free; ((Component)this).transform.SetParent((Transform)null); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.isKinematic = false; ((FVRPhysicalObject)this).RootRigidbody.useGravity = base.UsesGravity; } SetMeleeGunState(active: true); SetSheathingCooldown(SheathCooldownDuration); if ((Object)(object)hand != (Object)null) { hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); if (AudioDrawDetach != null) { SM.PlayCoreSound((FVRPooledAudioType)0, AudioDrawDetach, ((Component)this).transform.position); } } hand.ForceSetInteractable((FVRInteractiveObject)(object)this); ((FVRPhysicalObject)this).SetQuickBeltSlot((FVRQuickBeltSlot)null); ((FVRInteractiveObject)this).BeginInteraction(hand); } private void SetMeleeGunState(bool active) { if ((Object)(object)Bayonet != (Object)null && (Object)(object)((FVRFireArmAttachment)Bayonet).curMount != (Object)null) { FVRPhysicalObject parent = ((FVRFireArmAttachment)Bayonet).curMount.GetRootMount().Parent; FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null); if ((Object)(object)val != (Object)null) { val.RegisterAttachedMeleeWeapon((AttachableMeleeWeapon)(object)((!active) ? null : Bayonet)); } } } public void SetCollidersIgnore(bool ignore) { if ((Object)(object)Bayonet == (Object)null) { return; } Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); Collider[] componentsInChildren2 = ((Component)Bayonet).GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val in array) { if ((Object)(object)val == (Object)(object)EntranceTrigger) { continue; } Collider[] array2 = componentsInChildren2; foreach (Collider val2 in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { Physics.IgnoreCollision(val, val2, ignore); } } } } } public class SheathTrigger : MonoBehaviour { public LinearSheath Sheath; public string TipColliderName = "Cube Tip"; public float AlignmentThreshold = 0.75f; private void OnTriggerEnter(Collider other) { //IL_00d5: 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) if ((Object)(object)Sheath == (Object)null) { return; } if (Sheath.DebugMode) { Debug.Log((object)("[SheathTrigger] OnTriggerEnter detected: " + ((Object)((Component)other).gameObject).name)); } if (Sheath.CurrentState != LinearSheath.SheathState.Free || (!(((Object)((Component)other).gameObject).name == TipColliderName) && !(((Object)((Component)other).gameObject).name == "BayonetTip") && !((Object)((Component)other).gameObject).name.EndsWith("Tip"))) { return; } LinearBayonet componentInParent = ((Component)other).GetComponentInParent(); if (!((Object)(object)componentInParent != (Object)null) || componentInParent.CurrentState != LinearBayonet.State.Free) { return; } float num = Vector3.Dot(((Component)Sheath).transform.forward, ((Component)componentInParent).transform.forward); if (Sheath.DebugMode) { Debug.Log((object)("[SheathTrigger] Tip detected. Alignment Dot: " + num)); } if (num > AlignmentThreshold) { if (Sheath.DebugMode) { Debug.Log((object)"[SheathTrigger] Alignment valid. Mounting bayonet to track."); } Sheath.Bayonet = componentInParent; Sheath.SetCollidersIgnore(ignore: true); FVRViveHand hand = ((FVRInteractiveObject)componentInParent).m_hand; componentInParent.MountToTrackForInsertion(Sheath, hand); } } } public class MarsPistolController : MonoBehaviour { public enum MarsState { LockedForward, Recoiling, BarrelReturning, SlideReturning } [Header("Debug Settings")] public bool EnableDebugLogging = false; [Header("Component References")] [Tooltip("The main Handgun component on this weapon.")] public Handgun Handgun; [Tooltip("The HandgunSlide component on this weapon.")] public HandgunSlide Slide; [Tooltip("The physical barrel mesh/transform that will recoil.")] public Transform Barrel; [Tooltip("The elevator lift mechanism that carries the round up.")] public Transform Elevator; [Header("Slide Physical Travel Override")] [Tooltip("The slide position coordinate when fully rearward. (Matches Slide.Point_Slide_Rear local Z)")] public float SlideZ_Rear; [Tooltip("The slide position coordinate when locked back. (Matches Slide.Point_Slide_LockPoint local Z)")] public float SlideZ_Lock; [Tooltip("The slide position coordinate when fully forward. (Matches Slide.Point_Slide_Forward local Z)")] public float SlideZ_Forward; [Header("Barrel Travel Coordinates")] public Vector3 BarrelLocalPos_Forward; public Vector3 BarrelLocalPos_Rear; [Tooltip("How fast the barrel returns forward under virtual spring tension.")] public float BarrelReturnSpeed = 10f; [Header("Elevator Coordinates")] public Vector3 ElevatorLocalPos_Down; public Vector3 ElevatorLocalPos_Up; [Tooltip("How fast the elevator lifts the cartridge up.")] public float ElevatorLiftSpeed = 15f; [Tooltip("How fast the elevator drops back down after chambering.")] public float ElevatorDropSpeed = 15f; [Header("Feeding Parametrization")] [Range(0f, 1f)] [Tooltip("At what percentage of slide rearward travel should the round be extracted from the magazine?")] public float ExtractionThreshold = 0.5f; [Header("Visual Proxy Coordinates")] [Tooltip("Transform representing where the cartridge starts extraction from the mag.")] public Transform RoundPos_Extraction; [Tooltip("Transform representing the cartridge seated inside the chamber.")] public Transform RoundPos_ElevatorTop; [Tooltip("Transform representing the cartridge seated inside the chamber.")] public Transform RoundPos_Chamber; private MarsState _currentState = MarsState.LockedForward; private float _currentBarrelProgress = 0f; private float _currentElevatorProgress = 0f; private bool _hasExtractedThisCycle = false; private float _originalSlideForwardZ; private float _originalSlideLockZ; private float _originalSlideRearZ; private FieldInfo _fSlideZForward; private FieldInfo _fSlideZLock; private FieldInfo _fSlideZRear; private FieldInfo _fProxy; private FVRFirearmMovingProxyRound _cachedProxy; private bool _reflectionFailed = false; private void Awake() { if ((Object)(object)Handgun == (Object)null) { Handgun = ((Component)this).GetComponent(); } if ((Object)(object)Slide == (Object)null) { Slide = ((Component)this).GetComponentInChildren(); } } private void Start() { ResolveReflection(); if ((Object)(object)Handgun == (Object)null || (Object)(object)Slide == (Object)null) { if (EnableDebugLogging) { Debug.LogError((object)"[MarsDebug] Critical component reference missing. Disabling component."); } ((Behaviour)this).enabled = false; return; } Handgun.HasTiltingBarrel = false; _originalSlideForwardZ = SafeGetFloat(_fSlideZForward, Slide, SlideZ_Forward); _originalSlideLockZ = SafeGetFloat(_fSlideZLock, Slide, SlideZ_Lock); _originalSlideRearZ = SafeGetFloat(_fSlideZRear, Slide, SlideZ_Rear); if (!_reflectionFailed && (object)_fProxy != null) { try { ref FVRFirearmMovingProxyRound cachedProxy = ref _cachedProxy; object? value = _fProxy.GetValue(Handgun); cachedProxy = (FVRFirearmMovingProxyRound)((value is FVRFirearmMovingProxyRound) ? value : null); } catch (Exception ex) { _cachedProxy = null; if (EnableDebugLogging) { Debug.LogWarning((object)$"[MarsDebug] Failed to resolve moving proxy round: {ex.Message}"); } } } ResetMechanisms(); } private void Update() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Invalid comparison between Unknown and I4 //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Slide == (Object)null || (Object)(object)Barrel == (Object)null || (Object)(object)Elevator == (Object)null) { return; } float z = ((Component)Slide).transform.localPosition.z; float num = Mathf.InverseLerp(_originalSlideForwardZ, _originalSlideRearZ, z); switch (_currentState) { case MarsState.LockedForward: Barrel.localPosition = BarrelLocalPos_Forward; Elevator.localPosition = ElevatorLocalPos_Down; _currentBarrelProgress = 1f; _currentElevatorProgress = 0f; if (Slide.GetSlideSpeed() > 0.1f || num > 0.05f) { _hasExtractedThisCycle = false; TransitionToState(MarsState.Recoiling); } break; case MarsState.Recoiling: Barrel.localPosition = Vector3.Lerp(BarrelLocalPos_Forward, BarrelLocalPos_Rear, num); _currentBarrelProgress = 1f - num; if (!_hasExtractedThisCycle && num >= ExtractionThreshold) { if (EnableDebugLogging) { Debug.Log((object)$"[MarsDebug] Extraction triggered at {num:F2} slide progress."); } Handgun.ExtractRound(); _hasExtractedThisCycle = true; } if ((int)Slide.CurPos == 4 || num >= 0.98f) { if (EnableDebugLogging) { Debug.Log((object)$"[MarsDebug] Rearward limits reached. Slide CurPos: {Slide.CurPos}, Normal travel: {num:F2}. Locking slide back."); } SetSlideClampingBoundaries(_originalSlideRearZ, _originalSlideRearZ); TransitionToState(MarsState.BarrelReturning); } break; case MarsState.BarrelReturning: _currentBarrelProgress = Mathf.MoveTowards(_currentBarrelProgress, 1f, Time.deltaTime * BarrelReturnSpeed); Barrel.localPosition = Vector3.Lerp(BarrelLocalPos_Rear, BarrelLocalPos_Forward, _currentBarrelProgress); if (!(_currentBarrelProgress >= 1f)) { break; } _currentElevatorProgress = Mathf.MoveTowards(_currentElevatorProgress, 1f, Time.deltaTime * ElevatorLiftSpeed); Elevator.localPosition = Vector3.Lerp(ElevatorLocalPos_Down, ElevatorLocalPos_Up, _currentElevatorProgress); if (_currentElevatorProgress >= 1f) { if (EnableDebugLogging) { Debug.Log((object)"[MarsDebug] Barrel returned and elevator raised. Releasing slide forward."); } SetSlideClampingBoundaries(_originalSlideForwardZ, _originalSlideLockZ); TransitionToState(MarsState.SlideReturning); } break; case MarsState.SlideReturning: if ((int)Slide.CurPos == 0) { _currentElevatorProgress = Mathf.MoveTowards(_currentElevatorProgress, 0f, Time.deltaTime * ElevatorDropSpeed); Elevator.localPosition = Vector3.Lerp(ElevatorLocalPos_Down, ElevatorLocalPos_Up, _currentElevatorProgress); if (_currentElevatorProgress <= 0f) { TransitionToState(MarsState.LockedForward); } } break; } } private void LateUpdate() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Handgun == (Object)null) && !((Object)(object)Slide == (Object)null) && !((Object)(object)RoundPos_Extraction == (Object)null) && !((Object)(object)RoundPos_ElevatorTop == (Object)null) && !((Object)(object)RoundPos_Chamber == (Object)null) && !((Object)(object)Handgun.RoundPos_Magazine == (Object)null) && !((Object)(object)_cachedProxy == (Object)null) && _cachedProxy.IsFull && !((Object)(object)_cachedProxy.ProxyRound == (Object)null)) { float z = ((Component)Slide).transform.localPosition.z; float num = Mathf.InverseLerp(_originalSlideForwardZ, _originalSlideRearZ, z); switch (_currentState) { case MarsState.Recoiling: _cachedProxy.ProxyRound.position = Vector3.Lerp(Handgun.RoundPos_Magazine.position, RoundPos_Extraction.position, num); _cachedProxy.ProxyRound.rotation = Quaternion.Slerp(Handgun.RoundPos_Magazine.rotation, RoundPos_Extraction.rotation, num); break; case MarsState.BarrelReturning: _cachedProxy.ProxyRound.position = Vector3.Lerp(RoundPos_Extraction.position, RoundPos_ElevatorTop.position, _currentElevatorProgress); _cachedProxy.ProxyRound.rotation = Quaternion.Slerp(RoundPos_Extraction.rotation, RoundPos_ElevatorTop.rotation, _currentElevatorProgress); break; case MarsState.SlideReturning: { float num2 = 1f - num; _cachedProxy.ProxyRound.position = Vector3.Lerp(RoundPos_ElevatorTop.position, RoundPos_Chamber.position, num2); _cachedProxy.ProxyRound.rotation = Quaternion.Slerp(RoundPos_ElevatorTop.rotation, RoundPos_Chamber.rotation, num2); break; } } } } private void ResolveReflection() { try { _fSlideZForward = typeof(HandgunSlide).GetField("m_slideZ_forward", BindingFlags.Instance | BindingFlags.NonPublic); _fSlideZLock = typeof(HandgunSlide).GetField("m_slideZ_lock", BindingFlags.Instance | BindingFlags.NonPublic); _fSlideZRear = typeof(HandgunSlide).GetField("m_slideZ_rear", BindingFlags.Instance | BindingFlags.NonPublic); _fProxy = typeof(Handgun).GetField("m_proxy", BindingFlags.Instance | BindingFlags.NonPublic); if ((object)_fSlideZForward == null || (object)_fSlideZLock == null || (object)_fSlideZRear == null || (object)_fProxy == null) { _reflectionFailed = true; if (EnableDebugLogging) { Debug.LogWarning((object)"[MarsDebug] Reflection failed to find one or more private fields. Switching to safe fallback mode."); } } } catch (Exception ex) { _reflectionFailed = true; if (EnableDebugLogging) { Debug.LogWarning((object)$"[MarsDebug] Exception occurred during reflection lookup: {ex.Message}. Switching to safe fallback mode."); } } } private float SafeGetFloat(FieldInfo field, object obj, float fallback) { if (_reflectionFailed || (object)field == null || obj == null) { return fallback; } try { object value = field.GetValue(obj); if (value != null) { return Convert.ToSingle(value); } } catch (Exception ex) { if (EnableDebugLogging) { Debug.LogWarning((object)$"[MarsDebug] Failed to read field {field.Name}: {ex.Message}"); } } return fallback; } private void SafeSetFloat(FieldInfo field, object obj, float value) { if (_reflectionFailed || (object)field == null || obj == null) { return; } try { field.SetValue(obj, value); } catch (Exception ex) { if (EnableDebugLogging) { Debug.LogWarning((object)$"[MarsDebug] Failed to write field {field.Name}: {ex.Message}"); } } } private void TransitionToState(MarsState newState) { if (EnableDebugLogging) { Debug.Log((object)$"[MarsDebug] Transitioning state: {_currentState} -> {newState}"); } _currentState = newState; } private void SetSlideClampingBoundaries(float forwardZ, float lockZ) { if (!_reflectionFailed) { if (EnableDebugLogging) { Debug.Log((object)$"[MarsDebug] Slide boundaries overridden. Forward limit: {forwardZ:F4}, Lock limit: {lockZ:F4}"); } SafeSetFloat(_fSlideZForward, Slide, forwardZ); SafeSetFloat(_fSlideZLock, Slide, lockZ); } } private void ResetMechanisms() { //IL_0042: 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) if (EnableDebugLogging) { Debug.Log((object)"[MarsDebug] Resetting all physical mechanism states to home defaults."); } SetSlideClampingBoundaries(_originalSlideForwardZ, _originalSlideLockZ); if ((Object)(object)Barrel != (Object)null) { Barrel.localPosition = BarrelLocalPos_Forward; } if ((Object)(object)Elevator != (Object)null) { Elevator.localPosition = ElevatorLocalPos_Down; } _currentState = MarsState.LockedForward; _currentBarrelProgress = 1f; _currentElevatorProgress = 0f; _hasExtractedThisCycle = false; } private void OnDisable() { if ((Object)(object)Slide != (Object)null) { ResetMechanisms(); } } } internal class Mauser0608Controller : MonoBehaviour { public FVRFireArm weapon; public float slideForwardShiftOnMagEject = 0.004f; public bool debug; public Transform manualReleaseTriggerPoint; public float triggerRadius = 0.03f; private Handgun hg; private FVRFireArmMagazine lastFrameMag; private float originalSlideZLock; private FieldInfo slideZLockField; private FieldInfo slideSpeedField; private bool initialized; private void Start() { TryInitialize(); } private void Update() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Invalid comparison between Unknown and I4 //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) if (!initialized) { TryInitialize(); } else { if ((Object)(object)hg == (Object)null) { return; } FVRFireArmMagazine magazine = ((FVRFireArm)hg).Magazine; if ((Object)(object)magazine != (Object)(object)lastFrameMag) { if ((Object)(object)magazine != (Object)null && (Object)(object)lastFrameMag == (Object)null) { OnMagazineInserted(); } else if ((Object)(object)magazine == (Object)null && (Object)(object)lastFrameMag != (Object)null) { OnMagazineEjected(); } lastFrameMag = magazine; } if (!((Object)(object)magazine == (Object)null) || !((Object)(object)hg.Slide != (Object)null)) { return; } if ((int)hg.Slide.CurPos == 4 && !hg.IsSlideLockUp) { if (debug) { Debug.Log((object)"Mauser0608Controller: Slide racked to rear without a magazine. Locking open."); } hg.EngageSlideRelease(); } if (((FVRInteractiveObject)hg.Slide).IsHeld && (Object)(object)((FVRInteractiveObject)hg.Slide).m_hand != (Object)null) { FVRViveHand hand = ((FVRInteractiveObject)hg.Slide).m_hand; bool flag = false; if (hand.IsInStreamlinedMode) { if (hand.Input.BYButtonDown || hand.Input.AXButtonDown) { flag = true; } } else if (hand.Input.TouchpadDown && Vector2.Angle(hand.Input.TouchpadAxes, Vector2.down) <= 45f) { flag = true; } if (flag && hg.IsSlideLockUp) { if (debug) { Debug.Log((object)"Mauser0608Controller: Manual slide release override triggered via hand input."); } hg.DropSlideRelease(); } } if (!((Object)(object)manualReleaseTriggerPoint != (Object)null) || !hg.IsSlideLockUp) { return; } Collider[] array = Physics.OverlapSphere(manualReleaseTriggerPoint.position, triggerRadius); for (int i = 0; i < array.Length; i++) { FVRViveHand componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)((FVRInteractiveObject)hg).m_hand && ((Object)(object)hg.Slide == (Object)null || (Object)(object)componentInParent != (Object)(object)((FVRInteractiveObject)hg.Slide).m_hand)) { if (debug) { Debug.Log((object)"Mauser0608Controller: Hand detected near trigger point. Releasing slide."); } hg.DropSlideRelease(); break; } } } } private void TryInitialize() { if (!((Object)(object)weapon != (Object)null) || !(weapon is Handgun)) { return; } ref Handgun reference = ref hg; FVRFireArm obj = weapon; reference = (Handgun)(object)((obj is Handgun) ? obj : null); lastFrameMag = ((FVRFireArm)hg).Magazine; slideZLockField = typeof(HandgunSlide).GetField("m_slideZ_lock", BindingFlags.Instance | BindingFlags.NonPublic); slideSpeedField = typeof(HandgunSlide).GetField("m_curSlideSpeed", BindingFlags.Instance | BindingFlags.NonPublic); if ((Object)(object)hg.Slide != (Object)null && (object)slideZLockField != null) { originalSlideZLock = (float)slideZLockField.GetValue(hg.Slide); initialized = true; if ((Object)(object)lastFrameMag == (Object)null) { float num = originalSlideZLock + slideForwardShiftOnMagEject; slideZLockField.SetValue(hg.Slide, num); } if (debug) { Debug.Log((object)("Mauser0608Controller: Initialized. Original Z lock is " + originalSlideZLock)); } } } private void OnMagazineInserted() { if (debug) { Debug.Log((object)"Mauser0608Controller: Magazine inserted."); } ResetSlideLock(); if (hg.IsSlideLockUp) { if (debug) { Debug.Log((object)"Mauser0608Controller: Slide is locked. Dropping slide release."); } hg.DropSlideRelease(); } } private void OnMagazineEjected() { if (debug) { Debug.Log((object)"Mauser0608Controller: Magazine ejected."); } if (hg.IsSlideLockUp && (object)slideZLockField != null) { float num = originalSlideZLock + slideForwardShiftOnMagEject; if (debug) { Debug.Log((object)("Mauser0608Controller: Shifting slide lock to " + num)); } slideZLockField.SetValue(hg.Slide, num); if ((object)slideSpeedField != null) { slideSpeedField.SetValue(hg.Slide, hg.Slide.Speed_Forward); } } } private void ResetSlideLock() { if ((Object)(object)hg.Slide != (Object)null && (object)slideZLockField != null) { if (debug) { Debug.Log((object)("Mauser0608Controller: Resetting slide lock to " + originalSlideZLock)); } slideZLockField.SetValue(hg.Slide, originalSlideZLock); } } } namespace Volks.VG2_Rifle; [BepInPlugin("Volks.VG2_Rifle", "VG2_Rifle", "1.0.0")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("h3vr.otherloader", "1.3.0")] public class VG2_RiflePlugin : BaseUnityPlugin { private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; LoadAssets(); } private void LoadAssets() { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Volks.VG2_Rifle"); OtherLoader.RegisterDirectLoad(BasePath, "Volks.VG2_Rifle", "", "", "vg2_boltactionrifle", ""); } } public class AttachableStockFix : MonoBehaviour { [Tooltip("Prints stock state restoration events to the Unity console.")] public bool EnableDebugLogging = false; [Tooltip("Optional: Manually assign the base stock position transform. If empty, automatically captured on Awake.")] public Transform OverrideBaseStockPos; [Tooltip("Optional: Fallback setting for whether the base firearm has an active stock.")] public bool OverrideHasActiveStock = true; private FVRFireArm m_firearm; private AttachableStock m_attachableStock; private FVRFireArmAttachment m_attachment; private Transform m_savedBaseStockPos; private bool m_savedBaseHasStock; private bool m_isFirearmMode; private FVRFireArm m_lastAttachedGun; private Transform m_preMountStockPos; private bool m_preMountHasStock; private bool m_wasAttached; private void Awake() { m_firearm = ((Component)this).GetComponent(); m_attachableStock = ((Component)this).GetComponent(); m_attachment = ((Component)this).GetComponent(); if ((Object)(object)m_attachment == (Object)null && (Object)(object)m_attachableStock != (Object)null) { m_attachment = ((FVRFireArmAttachmentInterface)m_attachableStock).Attachment; } if ((Object)(object)m_firearm != (Object)null) { m_isFirearmMode = true; m_savedBaseStockPos = ((!((Object)(object)OverrideBaseStockPos != (Object)null)) ? m_firearm.StockPos : OverrideBaseStockPos); m_savedBaseHasStock = m_firearm.HasActiveShoulderStock || ((Object)(object)m_savedBaseStockPos != (Object)null && OverrideHasActiveStock); if (EnableDebugLogging) { Debug.Log((object)("[AttachableStockFix] Initialized on Firearm: " + ((Object)((Component)m_firearm).gameObject).name + " | Default Stock: " + ((!((Object)(object)m_savedBaseStockPos != (Object)null)) ? "None" : ((Object)m_savedBaseStockPos).name))); } } else if ((Object)(object)m_attachableStock != (Object)null || (Object)(object)m_attachment != (Object)null) { m_isFirearmMode = false; if (EnableDebugLogging) { Debug.Log((object)("[AttachableStockFix] Initialized on Stock Attachment: " + ((Object)((Component)this).gameObject).name)); } } } private void Update() { if (m_isFirearmMode) { UpdateFirearmMode(); } else { UpdateAttachmentMode(); } } private void UpdateFirearmMode() { if (!((Object)(object)m_firearm == (Object)null) && m_savedBaseHasStock && !m_firearm.HasActiveShoulderStock && (Object)(object)m_firearm.StockPos == (Object)null && !HasMountedStockAttachment()) { m_firearm.StockPos = m_savedBaseStockPos; m_firearm.HasActiveShoulderStock = true; if (EnableDebugLogging) { Debug.Log((object)("[AttachableStockFix] Restored native stock on Firearm: " + ((Object)((Component)m_firearm).gameObject).name)); } } } private void UpdateAttachmentMode() { if ((Object)(object)m_attachment == (Object)null) { if (!((Object)(object)m_attachableStock != (Object)null) || !((Object)(object)((FVRFireArmAttachmentInterface)m_attachableStock).Attachment != (Object)null)) { return; } m_attachment = ((FVRFireArmAttachmentInterface)m_attachableStock).Attachment; } if (!((Object)(object)m_attachment.curMount != (Object)null)) { if ((Object)(object)m_attachment.Sensor != (Object)null && (Object)(object)m_attachment.Sensor.CurHoveredMount != (Object)null) { FVRPhysicalObject parent = m_attachment.Sensor.CurHoveredMount.Parent; FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null); if ((Object)(object)val != (Object)null) { m_preMountStockPos = val.StockPos; m_preMountHasStock = val.HasActiveShoulderStock; } } if (!m_wasAttached || !((Object)(object)m_lastAttachedGun != (Object)null)) { return; } if (m_preMountHasStock) { m_lastAttachedGun.StockPos = m_preMountStockPos; m_lastAttachedGun.HasActiveShoulderStock = true; if (EnableDebugLogging) { Debug.Log((object)("[AttachableStockFix] Attachment detached. Restored stock on Firearm: " + ((Object)((Component)m_lastAttachedGun).gameObject).name)); } } m_lastAttachedGun = null; m_wasAttached = false; } else if (!m_wasAttached) { ref FVRFireArm lastAttachedGun = ref m_lastAttachedGun; FVRPhysicalObject parent2 = m_attachment.curMount.Parent; lastAttachedGun = (FVRFireArm)(object)((parent2 is FVRFireArm) ? parent2 : null); m_wasAttached = true; if (EnableDebugLogging && (Object)(object)m_lastAttachedGun != (Object)null) { Debug.Log((object)("[AttachableStockFix] Attachment mounted to Firearm: " + ((Object)((Component)m_lastAttachedGun).gameObject).name)); } } } private bool HasMountedStockAttachment() { AttachableStock[] componentsInChildren = ((Component)m_firearm).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)((FVRFireArmAttachmentInterface)componentsInChildren[i]).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)componentsInChildren[i]).Attachment.curMount != (Object)null) { return true; } } return false; } } public class UnderbarrelChainsaw : AttachableMeleeWeapon { public AudioSource SawAudio; public AudioSource StartingAudio; public AudioClip AudClip_Start; public AudioClip AudClip_Idle; public AudioClip AudClip_Buzzing; public AudioClip AudClip_Hitting; public bool UsesBladeSolidBits = true; public Renderer BladeSolid; public Renderer BladeBits; public Collider[] BladeCols; public ParticleSystem Sparks; public Transform BladePoint1; public Transform BladePoint2; public ParticleSystem EngineSmoke; public bool UsesEngineRot = true; public Transform EngineRot; public float PerceptibleEventVolume = 50f; public float PerceptibleEventRange = 30f; public float BaseCuttingDamage = 250f; public bool ChainsawDebugMode; private Material m_matBladeSolid; private Material m_matBladeBits; private EmitParams emitParams; private List DamageablesToDo = new List(); private HashSet DamageablesToDoHS = new HashSet(); private List DamageableHitPoints = new List(); private List DamageableHitNormals = new List(); private HashSet m_bladeCols = new HashSet(); private Collider[] m_overlapResults = (Collider[])(object)new Collider[10]; [NonSerialized] [HideInInspector] public float m_sawingIntensity; [NonSerialized] [HideInInspector] public float triggerAmount; [NonSerialized] [HideInInspector] public bool m_isRunning; [NonSerialized] [HideInInspector] public float m_motorSpeed; private float TimeSinceDamageDealing = 0.2f; private float m_timeTilPerceptibleEventTick = 0.2f; private float m_timeSinceCollision = 1f; private int framesTilFlash; private bool m_isCustomLodged; private FixedJoint m_customLodgeJoint; private Rigidbody m_customLodgeTargetRB; private SosigLink m_customLodgeLink; private float m_lodgeContactTimer; public override void Awake() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArmAttachment)this).Awake(); emitParams = default(EmitParams); if (UsesBladeSolidBits && (Object)(object)BladeSolid != (Object)null && (Object)(object)BladeBits != (Object)null) { m_matBladeSolid = BladeSolid.materials[0]; m_matBladeBits = BladeBits.material; } for (int i = 0; i < BladeCols.Length; i++) { m_bladeCols.Add(BladeCols[i]); } } public override void UpdateInteraction(FVRViveHand hand) { ((FVRFireArmAttachment)this).UpdateInteraction(hand); if ((Object)(object)hand != (Object)null) { SetMotorPower(hand.Input.TriggerFloat); } } public override void EndInteraction(FVRViveHand hand) { StopMotor(); ((FVRFireArmAttachment)this).EndInteraction(hand); } public override void FVRUpdate() { //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Expected O, but got Unknown //IL_067d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06b4: Expected O, but got Unknown //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_06dd: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_088d: Unknown result type (might be due to invalid IL or missing references) //IL_08b1: Unknown result type (might be due to invalid IL or missing references) //IL_0b4a: Unknown result type (might be due to invalid IL or missing references) //IL_0b4f: Unknown result type (might be due to invalid IL or missing references) //IL_0b53: Unknown result type (might be due to invalid IL or missing references) //IL_0b58: Unknown result type (might be due to invalid IL or missing references) //IL_0ba4: Unknown result type (might be due to invalid IL or missing references) //IL_0afd: Unknown result type (might be due to invalid IL or missing references) //IL_0b02: Unknown result type (might be due to invalid IL or missing references) //IL_0b21: Unknown result type (might be due to invalid IL or missing references) //IL_0b26: Unknown result type (might be due to invalid IL or missing references) //IL_0a1d: Unknown result type (might be due to invalid IL or missing references) //IL_0a22: Unknown result type (might be due to invalid IL or missing references) //IL_0a42: Unknown result type (might be due to invalid IL or missing references) //IL_0a47: Unknown result type (might be due to invalid IL or missing references) //IL_083d: Unknown result type (might be due to invalid IL or missing references) //IL_0842: Unknown result type (might be due to invalid IL or missing references) //IL_0857: Unknown result type (might be due to invalid IL or missing references) //IL_085c: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0c34: Unknown result type (might be due to invalid IL or missing references) //IL_0c39: Unknown result type (might be due to invalid IL or missing references) //IL_0d3f: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0cb1: Unknown result type (might be due to invalid IL or missing references) ((FVRPhysicalObject)this).FVRUpdate(); bool flag = false; if ((Object)(object)((FVRFireArmAttachment)this).curMount != (Object)null && ((FVRFireArmAttachment)this).curMount.Parent is FVRFireArm) { FVRPhysicalObject parent = ((FVRFireArmAttachment)this).curMount.Parent; FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null); UnderbarrelChainsawInterface underbarrelChainsawInterface = ((FVRFireArmAttachment)this).AttachmentInterface as UnderbarrelChainsawInterface; if ((Object)(object)((FVRPhysicalObject)val).AltGrip != (Object)null && (Object)(object)((FVRPhysicalObject)val).AltGrip.LastGrabbedInGrip == (Object)(object)underbarrelChainsawInterface && ((FVRInteractiveObject)((FVRPhysicalObject)val).AltGrip).IsHeld) { flag = true; m_isRunning = true; if ((Object)(object)((FVRInteractiveObject)((FVRPhysicalObject)val).AltGrip).m_hand != (Object)null) { triggerAmount = ((FVRInteractiveObject)((FVRPhysicalObject)val).AltGrip).m_hand.Input.TriggerFloat; } } } if (!flag) { if (((FVRInteractiveObject)this).IsHeld && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { m_isRunning = true; triggerAmount = ((FVRInteractiveObject)this).m_hand.Input.TriggerFloat; } else if (m_isRunning) { StopMotor(); } } if (m_isCustomLodged) { if ((Object)(object)m_customLodgeJoint == (Object)null || (Object)(object)m_customLodgeTargetRB == (Object)null) { BreakCustomLodge(spawnBurst: false); } else { Rigidbody activeRigidbody = GetActiveRigidbody(); if ((Object)(object)activeRigidbody != (Object)null) { float num = Vector3.Dot(activeRigidbody.velocity, -((Component)this).transform.forward); if (num > 3f) { BreakCustomLodge(spawnBurst: true); } } } } else { m_lodgeContactTimer = 0f; } if (framesTilFlash > 0) { framesTilFlash--; } if (m_timeSinceCollision < 1f) { m_timeSinceCollision += Time.deltaTime; } if (TimeSinceDamageDealing > 0f) { TimeSinceDamageDealing -= Time.deltaTime; } else { if (m_isRunning && m_sawingIntensity > 0.1f && (Object)(object)BladePoint1 != (Object)null && (Object)(object)BladePoint2 != (Object)null) { Vector3 val2 = (BladePoint1.position + BladePoint2.position) * 0.5f; Vector3 val3 = BladePoint2.position - BladePoint1.position; Quaternion val4 = Quaternion.LookRotation(val3, ((Component)this).transform.up); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(0.04f, 0.12f, ((Vector3)(ref val3)).magnitude * 0.5f); int num2 = Physics.OverlapBoxNonAlloc(val2, val5, m_overlapResults, val4, -1, (QueryTriggerInteraction)2); int num3 = 0; for (int i = 0; i < num2; i++) { Collider val6 = m_overlapResults[i]; if ((Object)(object)val6 == (Object)null || m_bladeCols.Contains(val6) || (Object)(object)((Component)val6).transform.root == (Object)(object)((Component)this).transform.root) { continue; } Vector3 val7 = val6.ClosestPoint(val2); if (num3 < 2) { m_timeSinceCollision = 0f; num3++; Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(BladePoint1.position, BladePoint2.position, val7); Vector3 val8 = val7 - closestValidPoint; val8 = Vector3.ClampMagnitude(val8, 0.04f); Vector3 val9 = closestValidPoint + val8; ((EmitParams)(ref emitParams)).position = val9; Vector3 val10 = Vector3.Cross(((Vector3)(ref val8)).normalized, ((Component)this).transform.right) * Random.Range(1f, 10f); val10 += Random.onUnitSphere * 3f; val10 += val8 * 2f; ((EmitParams)(ref emitParams)).velocity = val10; if ((Object)(object)Sparks != (Object)null) { Sparks.Emit(emitParams, 1); } if (framesTilFlash <= 0) { framesTilFlash = Random.Range(3, 7); Vector3 val11 = ((Component)this).transform.position - val7; FXM.InitiateMuzzleFlash(val9, ((Vector3)(ref val11)).normalized, Random.Range(0.25f, 2f), Color.white, Random.Range(0.5f, 1f)); } } IFVRDamageable component = ((Component)val6).GetComponent(); if (component == null && (Object)(object)val6.attachedRigidbody != (Object)null) { component = ((Component)val6.attachedRigidbody).GetComponent(); } if (component == null || !DamageablesToDoHS.Add(component)) { continue; } if (ChainsawDebugMode) { Debug.Log((object)("Chainsaw: Spatial contact detected with " + ((Object)val6).name)); } DamageablesToDo.Add(component); DamageableHitPoints.Add(val7); List damageableHitNormals = DamageableHitNormals; Vector3 val12 = ((Component)this).transform.position - val7; damageableHitNormals.Add(((Vector3)(ref val12)).normalized); SosigLink component2 = ((Component)val6).GetComponent(); if ((Object)(object)component2 == (Object)null && (Object)(object)val6.attachedRigidbody != (Object)null) { component2 = ((Component)val6.attachedRigidbody).GetComponent(); } if ((Object)(object)component2 != (Object)null && m_sawingIntensity > 0.5f && !m_isCustomLodged) { m_lodgeContactTimer += Time.deltaTime; if (m_lodgeContactTimer >= 0.4f) { TriggerCustomLodge(component2, val6.attachedRigidbody); } } } } if (DamageablesToDo.Count > 0) { if (ChainsawDebugMode) { Debug.Log((object)("Chainsaw: Ticking damage on " + DamageablesToDo.Count + " victims.")); } Damage val13 = new Damage(); val13.Dam_Blunt = 15f; val13.Dam_Cutting = BaseCuttingDamage * m_sawingIntensity; val13.Dam_TotalKinetic = val13.Dam_Cutting + val13.Dam_Blunt; val13.Class = (DamageClass)3; val13.Source_IFF = GM.CurrentPlayerBody.GetPlayerIFF(); for (int j = 0; j < DamageablesToDo.Count; j++) { if ((Object)(MonoBehaviour)DamageablesToDo[j] != (Object)null) { val13.hitNormal = DamageableHitNormals[j]; val13.point = DamageableHitPoints[j]; val13.strikeDir = -val13.hitNormal; DamageablesToDo[j].Damage(val13); } } } DamageablesToDo.Clear(); DamageablesToDoHS.Clear(); DamageableHitPoints.Clear(); DamageableHitNormals.Clear(); Array.Clear(m_overlapResults, 0, m_overlapResults.Length); TimeSinceDamageDealing = 0.1f; } if (!m_isRunning) { if ((Object)(object)SawAudio != (Object)null) { SawAudio.volume = m_motorSpeed * 0.7f; } if ((Object)(object)StartingAudio != (Object)null) { StartingAudio.volume = m_motorSpeed; } if (m_motorSpeed <= 0f && (Object)(object)StartingAudio != (Object)null && StartingAudio.isPlaying) { StartingAudio.Stop(); } if (UsesBladeSolidBits && (Object)(object)m_matBladeSolid != (Object)null && (Object)(object)m_matBladeBits != (Object)null) { m_matBladeSolid.SetVector("_MainTexVelocity", Vector4.op_Implicit(Vector2.zero)); m_matBladeBits.SetVector("_MainTexVelocity", Vector4.op_Implicit(Vector2.zero)); } if ((Object)(object)EngineSmoke != (Object)null) { EmissionModule emission = EngineSmoke.emission; MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime; ((MinMaxCurve)(ref rateOverTime)).mode = (ParticleSystemCurveMode)0; ((MinMaxCurve)(ref rateOverTime)).constantMax = 0f; ((MinMaxCurve)(ref rateOverTime)).constantMin = 0f; ((EmissionModule)(ref emission)).rateOverTime = rateOverTime; } } else { if ((Object)(object)SawAudio != (Object)null && !SawAudio.isPlaying) { SawAudio.Play(); } triggerAmount += Random.Range(-0.05f, 0.05f); m_sawingIntensity = Mathf.Lerp(m_sawingIntensity, triggerAmount, Time.deltaTime * 5f); if (m_sawingIntensity > 0.1f) { if ((Object)(object)SawAudio != (Object)null) { SawAudio.volume = (0.8f + m_sawingIntensity * 0.5f) * 0.3f; SawAudio.pitch = 0.6f + m_sawingIntensity * 0.7f; AudioClip val14 = ((!(m_timeSinceCollision < 0.2f)) ? AudClip_Buzzing : AudClip_Hitting); if ((Object)(object)SawAudio.clip != (Object)(object)val14) { SawAudio.clip = val14; } } if (UsesBladeSolidBits && (Object)(object)m_matBladeSolid != (Object)null && (Object)(object)m_matBladeBits != (Object)null) { m_matBladeSolid.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(m_sawingIntensity, 0f))); m_matBladeBits.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(m_sawingIntensity, 0f))); } } else { if ((Object)(object)SawAudio != (Object)null) { SawAudio.volume = 0.25f; SawAudio.pitch = 1f; if ((Object)(object)SawAudio.clip != (Object)(object)AudClip_Idle) { SawAudio.clip = AudClip_Idle; } } if (UsesBladeSolidBits && (Object)(object)m_matBladeSolid != (Object)null && (Object)(object)m_matBladeBits != (Object)null) { m_matBladeSolid.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(0.01f, 0f))); m_matBladeBits.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(0.01f, 0f))); } } if ((Object)(object)EngineSmoke != (Object)null) { EmissionModule emission2 = EngineSmoke.emission; MinMaxCurve rateOverTime2 = ((EmissionModule)(ref emission2)).rateOverTime; ((MinMaxCurve)(ref rateOverTime2)).mode = (ParticleSystemCurveMode)0; ((MinMaxCurve)(ref rateOverTime2)).constantMax = m_motorSpeed * 2f + m_sawingIntensity * 20f; ((MinMaxCurve)(ref rateOverTime2)).constantMin = m_motorSpeed * 2f + m_sawingIntensity * 20f; ((EmissionModule)(ref emission2)).rateOverTime = rateOverTime2; } } if (m_isRunning) { if (m_motorSpeed < 1f) { m_motorSpeed = 1f; } } else { m_motorSpeed -= Time.deltaTime * 3f; m_motorSpeed = Mathf.Clamp(m_motorSpeed, 0f, 1f); } if (UsesEngineRot && (Object)(object)EngineRot != (Object)null) { float x = EngineRot.localEulerAngles.x; x = ((!(m_sawingIntensity > 0f)) ? (x + Time.deltaTime * (360f * m_motorSpeed)) : (x + Time.deltaTime * (360f + m_sawingIntensity * 1200f))); x = Mathf.Repeat(x, 360f); EngineRot.localEulerAngles = new Vector3(x, 0f, 0f); } if (m_isRunning) { m_timeTilPerceptibleEventTick -= Time.deltaTime; if (m_timeTilPerceptibleEventTick <= 0f) { m_timeTilPerceptibleEventTick = Random.Range(0.2f, 0.3f); GM.CurrentSceneSettings.OnPerceiveableSound(PerceptibleEventVolume * m_motorSpeed * m_sawingIntensity * 0.5f, PerceptibleEventRange * m_motorSpeed * m_sawingIntensity * 0.5f, ((Component)this).transform.position, GM.CurrentPlayerBody.GetPlayerIFF(), GM.CurrentPlayerBody.PlayerEntities[0]); } } } public override void FVRFixedUpdate() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0068: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArmAttachment)this).FVRFixedUpdate(); if (m_isRunning) { Rigidbody activeRigidbody = GetActiveRigidbody(); if ((Object)(object)activeRigidbody != (Object)null) { float num = 0.1f + m_sawingIntensity * 0.3f; activeRigidbody.velocity += Random.onUnitSphere * num; activeRigidbody.angularVelocity += Random.onUnitSphere * num; } } } public void SetMotorPower(float intensity) { if (ChainsawDebugMode) { Debug.Log((object)("Chainsaw: SetMotorPower called with intensity: " + intensity)); } triggerAmount = intensity; m_isRunning = true; if (m_motorSpeed <= 0.1f && (Object)(object)StartingAudio != (Object)null && !StartingAudio.isPlaying) { StartingAudio.Play(); } m_motorSpeed += Time.deltaTime * 3f; m_motorSpeed = Mathf.Clamp(m_motorSpeed, 0f, 1f); } public void StopMotor() { if (ChainsawDebugMode) { Debug.Log((object)"Chainsaw: StopMotor called"); } m_isRunning = false; triggerAmount = 0f; m_sawingIntensity = 0f; DamageablesToDo.Clear(); DamageablesToDoHS.Clear(); DamageableHitPoints.Clear(); DamageableHitNormals.Clear(); Array.Clear(m_overlapResults, 0, m_overlapResults.Length); BreakCustomLodge(spawnBurst: false); } private Rigidbody GetActiveRigidbody() { if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { return ((FVRPhysicalObject)this).RootRigidbody; } return ((Component)this).GetComponentInParent(); } private void TriggerCustomLodge(SosigLink link, Rigidbody targetRB) { Rigidbody activeRigidbody = GetActiveRigidbody(); if (!((Object)(object)activeRigidbody == (Object)null) && !((Object)(object)targetRB == (Object)null)) { m_isCustomLodged = true; m_customLodgeTargetRB = targetRB; m_customLodgeLink = link; m_customLodgeJoint = ((Component)activeRigidbody).gameObject.AddComponent(); ((Joint)m_customLodgeJoint).connectedBody = targetRB; ((Joint)m_customLodgeJoint).enableCollision = false; if (ChainsawDebugMode) { Debug.Log((object)("Chainsaw: Custom lodged into " + ((Object)link).name)); } } } private void BreakCustomLodge(bool spawnBurst) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00da: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0107: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_customLodgeJoint != (Object)null) { Object.Destroy((Object)(object)m_customLodgeJoint); } if (spawnBurst && (Object)(object)m_customLodgeLink != (Object)null && (Object)(object)m_customLodgeLink.S != (Object)null && (Object)(object)BladePoint1 != (Object)null && (Object)(object)BladePoint2 != (Object)null) { Vector3 val = (BladePoint1.position + BladePoint2.position) * 0.5f; m_customLodgeLink.S.SpawnLargeMustardBurst(val, -((Component)this).transform.forward * 5f); Damage val2 = new Damage(); val2.Dam_Cutting = BaseCuttingDamage * 1.5f; val2.Class = (DamageClass)3; val2.Source_IFF = GM.CurrentPlayerBody.GetPlayerIFF(); val2.point = val; val2.strikeDir = -((Component)this).transform.forward; m_customLodgeLink.Damage(val2); } m_isCustomLodged = false; m_customLodgeTargetRB = null; m_customLodgeLink = null; m_lodgeContactTimer = 0f; } } public class UnderbarrelChainsawInterface : AttachableForegrip { public bool ChainsawInterfaceDebug; public override void OnAttach() { ((FVRFireArmAttachmentInterface)this).OnAttach(); if (ChainsawInterfaceDebug) { Debug.Log((object)"Interface: OnAttach called"); } if ((Object)(object)((FVRFireArmAttachmentInterface)this).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)this).Attachment.curMount != (Object)null && ((FVRFireArmAttachmentInterface)this).Attachment.curMount.Parent is FVRFireArm) { FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)this).Attachment.curMount.Parent; FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null); ? val2 = val; FVRFireArmAttachment attachment = ((FVRFireArmAttachmentInterface)this).Attachment; ((FVRFireArm)val2).RegisterAttachedMeleeWeapon((AttachableMeleeWeapon)(object)((attachment is AttachableMeleeWeapon) ? attachment : null)); } } public override void OnDetach() { if (ChainsawInterfaceDebug) { Debug.Log((object)"Interface: OnDetach called"); } if ((Object)(object)((FVRFireArmAttachmentInterface)this).Attachment != (Object)null && (Object)(object)((FVRFireArmAttachmentInterface)this).Attachment.curMount != (Object)null && ((FVRFireArmAttachmentInterface)this).Attachment.curMount.Parent is FVRFireArm) { FVRPhysicalObject parent = ((FVRFireArmAttachmentInterface)this).Attachment.curMount.Parent; FVRFireArm val = (FVRFireArm)(object)((parent is FVRFireArm) ? parent : null); val.RegisterAttachedMeleeWeapon((AttachableMeleeWeapon)null); } ((FVRFireArmAttachmentInterface)this).OnDetach(); } }