Decompiled source of 100mmHeatBC Launcher v1.0.0
100mmHeatBC_Launcher.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using FistVR; using HarmonyLib; using OpenScripts2; using OtherLoader; using UnityEngine; using UnityEngine.UI; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] public class StickyMineProj : FVRPhysicalObject, IFVRDamageable { [Tooltip("Enables verbose console logging for debugging.")] public bool EnableDebugLogging = false; [Header("Renderers")] [Tooltip("Main body renderer.")] public Renderer Rend; [Tooltip("Dedicated renderer for the warning light/LED mesh. If unassigned, falls back to Rend.")] public Renderer LightRenderer; [Header("Sticking Configuration")] [Tooltip("Enables adhesive sticking to surfaces and entities.")] public bool IsSticky = true; [Tooltip("Layers that the mine can stick to. If 0, defaults to Default, Environment, and AgentBody.")] public LayerMask StickyLayers; [Header("Proximity Settings")] [Tooltip("Radius in meters within which enemy Sosigs or players trigger detonation.")] public float DetectionRadius = 3.5f; [Tooltip("Time interval in seconds between proximity physics scans to preserve performance.")] public float ScanInterval = 0.1f; [Tooltip("Layers checked for target entities (typically AgentBody and AIEntity).")] public LayerMask TargetLayers; [Tooltip("Delay in seconds between detecting a target and triggering detonation.")] public float DetonationDelay = 0.35f; [Header("Pulsing Emission")] [Tooltip("Color of the pulsing warning emission.")] public Color EmissionColor = Color.red; [Tooltip("Pulsing frequency in cycles per second when armed and idle.")] public float IdlePulseSpeed = 2f; [Tooltip("Pulsing frequency in cycles per second when triggered and about to explode.")] public float AlertPulseSpeed = 12f; [Tooltip("Maximum emission intensity multiplier.")] public float MaxEmissionIntensity = 3f; [Header("Payload")] [Tooltip("Explosion prefabs instantiated upon detonation.")] public List<GameObject> SpawnOnExplode = new List<GameObject>(); [Tooltip("Team identification index. Auto-set from player on spawn if 0.")] public int IFF = 0; [Header("Audio Events")] [Tooltip("Sound played when the mine successfully sticks to a surface.")] public AudioEvent AudEvent_Stick; [Tooltip("Sound played when an enemy enters detection range.")] public AudioEvent AudEvent_Warning; private bool m_isStuck = false; private Transform m_stuckTarget; private Vector3 m_stuckLocalPos; private Quaternion m_stuckLocalRot; private bool m_isTriggered = false; private bool m_hasExploded = false; private float m_scanTimer = 0f; private float m_detonationTimer = 0f; private float m_spawnGraceTimer = 0f; private MaterialPropertyBlock m_mpb; private int m_emissionColorId; private List<Collider> m_ignoredColliders = new List<Collider>(); private Collider[] m_myColliders; private Collider[] m_overlapColliders = (Collider[])(object)new Collider[16]; public override void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown ((FVRPhysicalObject)this).Awake(); m_mpb = new MaterialPropertyBlock(); m_emissionColorId = Shader.PropertyToID("_EmissionColor"); m_myColliders = ((Component)this).GetComponentsInChildren<Collider>(true); if (IFF == 0 && (Object)(object)GM.CurrentPlayerBody != (Object)null) { IFF = GM.CurrentPlayerBody.GetPlayerIFF(); } Renderer val = ((!((Object)(object)LightRenderer != (Object)null)) ? Rend : LightRenderer); if ((Object)(object)val != (Object)null && (Object)(object)val.material != (Object)null) { val.material.EnableKeyword("_EMISSION"); } if (((LayerMask)(ref StickyLayers)).value == 0) { int num = LayerMask.NameToLayer("Default"); int num2 = LayerMask.NameToLayer("Environment"); int num3 = LayerMask.NameToLayer("AgentBody"); int num4 = 0; if (num != -1) { num4 |= 1 << num; } if (num2 != -1) { num4 |= 1 << num2; } if (num3 != -1) { num4 |= 1 << num3; } if (num4 != 0) { ((LayerMask)(ref StickyLayers)).value = num4; } } if (((LayerMask)(ref TargetLayers)).value == 0) { int num5 = LayerMask.NameToLayer("AgentBody"); int num6 = LayerMask.NameToLayer("AIEntity"); int num7 = 0; if (num5 != -1) { num7 |= 1 << num5; } if (num6 != -1) { num7 |= 1 << num6; } if (num7 != 0) { ((LayerMask)(ref TargetLayers)).value = num7; } } } public override void FVRUpdate() { ((FVRPhysicalObject)this).FVRUpdate(); if (m_hasExploded) { return; } if (m_spawnGraceTimer > 0f) { m_spawnGraceTimer -= Time.deltaTime; } if (!m_isStuck) { return; } UpdateEmission(); if (m_isTriggered) { m_detonationTimer -= Time.deltaTime; if (m_detonationTimer <= 0f) { Explode(); } return; } m_scanTimer -= Time.deltaTime; if (m_scanTimer <= 0f) { m_scanTimer = ScanInterval; CheckProximity(); } } public override void FVRFixedUpdate() { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) ((FVRPhysicalObject)this).FVRFixedUpdate(); if (m_isStuck) { if ((Object)(object)m_stuckTarget != (Object)null) { ((Component)this).transform.position = m_stuckTarget.TransformPoint(m_stuckLocalPos); ((Component)this).transform.rotation = m_stuckTarget.rotation * m_stuckLocalRot; } else { ((FVRPhysicalObject)this).SetIsKinematicLocked(false); m_isStuck = false; } } } public override void OnCollisionEnter(Collision col) { //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_0182: 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_0283: Unknown result type (might be due to invalid IL or missing references) ((FVRPhysicalObject)this).OnCollisionEnter(col); if (!IsSticky || ((FVRInteractiveObject)this).IsHeld || m_isStuck || m_hasExploded || m_spawnGraceTimer > 0f) { return; } Sosig componentInParent = col.gameObject.GetComponentInParent<Sosig>(); if ((Object)(object)componentInParent == (Object)null && (Object)(object)col.collider.attachedRigidbody != (Object)null) { componentInParent = ((Component)col.collider.attachedRigidbody).GetComponentInParent<Sosig>(); } int num = 1 << col.gameObject.layer; if ((((LayerMask)(ref StickyLayers)).value & num) == 0 && (Object)(object)componentInParent == (Object)null && (Object)(object)col.collider.attachedRigidbody != (Object)null) { return; } ContactPoint[] contacts = col.contacts; if (contacts == null || contacts.Length == 0) { return; } m_isStuck = true; m_stuckTarget = col.gameObject.transform; ((Component)this).transform.position = ((ContactPoint)(ref contacts[0])).point; m_stuckLocalPos = m_stuckTarget.InverseTransformPoint(((Component)this).transform.position); m_stuckLocalRot = Quaternion.Inverse(m_stuckTarget.rotation) * ((Component)this).transform.rotation; if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } ((FVRPhysicalObject)this).SetIsKinematicLocked(true); Collider[] array = ((!((Object)(object)componentInParent != (Object)null)) ? col.gameObject.GetComponentsInChildren<Collider>() : ((Component)componentInParent).GetComponentsInChildren<Collider>()); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)array[i] != (Object)null)) { continue; } for (int j = 0; j < m_myColliders.Length; j++) { if ((Object)(object)m_myColliders[j] != (Object)null) { Physics.IgnoreCollision(m_myColliders[j], array[i], true); } } if (!m_ignoredColliders.Contains(array[i])) { m_ignoredColliders.Add(array[i]); } } if (AudEvent_Stick != null) { SM.PlayGenericSound(AudEvent_Stick, ((Component)this).transform.position); } if (EnableDebugLogging) { Debug.Log((object)("[StickyMineProj] Stuck to " + ((Object)col.gameObject).name + " on layer " + LayerMask.LayerToName(col.gameObject.layer))); } } public override void BeginInteraction(FVRViveHand hand) { //IL_0041: 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) ((FVRPhysicalObject)this).BeginInteraction(hand); if (!m_isStuck) { return; } m_isStuck = false; m_stuckTarget = null; ((FVRPhysicalObject)this).SetIsKinematicLocked(false); if ((Object)(object)((FVRPhysicalObject)this).RootRigidbody != (Object)null) { ((FVRPhysicalObject)this).RootRigidbody.velocity = Vector3.zero; ((FVRPhysicalObject)this).RootRigidbody.angularVelocity = Vector3.zero; } for (int i = 0; i < m_ignoredColliders.Count; i++) { if (!((Object)(object)m_ignoredColliders[i] != (Object)null)) { continue; } for (int j = 0; j < m_myColliders.Length; j++) { if ((Object)(object)m_myColliders[j] != (Object)null) { Physics.IgnoreCollision(m_myColliders[j], m_ignoredColliders[i], false); } } } m_ignoredColliders.Clear(); if (EnableDebugLogging) { Debug.Log((object)"[StickyMineProj] Unstuck by hand interaction."); } } public void Damage(Damage d) { if (!m_hasExploded) { if (EnableDebugLogging) { Debug.Log((object)"[StickyMineProj] Damage received. Detonating!"); } Explode(); } } private void UpdateEmission() { //IL_0079: 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_00a4: Unknown result type (might be due to invalid IL or missing references) Renderer val = ((!((Object)(object)LightRenderer != (Object)null)) ? Rend : LightRenderer); if (!((Object)(object)val == (Object)null)) { float num = ((!m_isTriggered) ? IdlePulseSpeed : AlertPulseSpeed); float num2 = (Mathf.Sin(Time.time * num * (float)Math.PI * 2f) + 1f) * 0.5f; Color val2 = EmissionColor * (num2 * MaxEmissionIntensity); val.GetPropertyBlock(m_mpb); m_mpb.SetColor(m_emissionColorId, val2); val.SetPropertyBlock(m_mpb); } } private void CheckProximity() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, DetectionRadius, m_overlapColliders, ((LayerMask)(ref TargetLayers)).value, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = m_overlapColliders[i]; if ((Object)(object)val != (Object)null && IsEnemy(val)) { TriggerMine(); break; } } } private bool IsEnemy(Collider col) { SosigLink component = ((Component)col).GetComponent<SosigLink>(); if ((Object)(object)component == (Object)null && (Object)(object)col.attachedRigidbody != (Object)null) { component = ((Component)col.attachedRigidbody).GetComponent<SosigLink>(); } if ((Object)(object)component != (Object)null && (Object)(object)component.S != (Object)null && (Object)(object)component.S.E != (Object)null) { if (component.S.GetIFF() != IFF) { return true; } return false; } AIEntity component2 = ((Component)col).GetComponent<AIEntity>(); if ((Object)(object)component2 == (Object)null && (Object)(object)col.attachedRigidbody != (Object)null) { component2 = ((Component)col.attachedRigidbody).GetComponent<AIEntity>(); } if ((Object)(object)component2 != (Object)null && component2.IFFCode >= 0) { if (component2.IFFCode != IFF) { return true; } return false; } FVRPlayerBody componentInParent = ((Component)col).GetComponentInParent<FVRPlayerBody>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)GM.CurrentPlayerBody != (Object)null && GM.CurrentPlayerBody.GetPlayerIFF() != IFF) { return true; } return false; } private void TriggerMine() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) m_isTriggered = true; m_detonationTimer = DetonationDelay; if (AudEvent_Warning != null) { SM.PlayGenericSound(AudEvent_Warning, ((Component)this).transform.position); } if (EnableDebugLogging) { Debug.Log((object)("[StickyMineProj] Target acquired! Detonating in " + DetonationDelay.ToString("F2") + "s")); } } private void Explode() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (m_hasExploded) { return; } m_hasExploded = true; if (SpawnOnExplode != null) { for (int i = 0; i < SpawnOnExplode.Count; i++) { if ((Object)(object)SpawnOnExplode[i] != (Object)null) { GameObject val = Object.Instantiate<GameObject>(SpawnOnExplode[i], ((Component)this).transform.position, Quaternion.identity); Explosion component = val.GetComponent<Explosion>(); if ((Object)(object)component != (Object)null) { component.IFF = IFF; } ExplosionSound component2 = val.GetComponent<ExplosionSound>(); if ((Object)(object)component2 != (Object)null) { component2.IFF = IFF; } GrenadeExplosion component3 = val.GetComponent<GrenadeExplosion>(); if ((Object)(object)component3 != (Object)null) { component3.IFF = IFF; } } } } if (((FVRInteractiveObject)this).IsHeld && (Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { FVRViveHand hand = ((FVRInteractiveObject)this).m_hand; hand.ForceSetInteractable((FVRInteractiveObject)null); ((FVRInteractiveObject)this).EndInteraction(hand); } Object.Destroy((Object)(object)((Component)this).gameObject); } } public class AT4 : SimpleLauncher { [Header("Trigger Settings")] public Transform Trigger; public Axis Trigger_Axis = (Axis)0; public Vector2 Trigger_ValRange = new Vector2(0f, 10f); private float m_triggerVal; [Header("Rocket Settings")] [HideInInspector] public bool hasFired = false; [Header("Self-Destruct")] public float DestroyDelay = 10f; private bool selfDestructStarted = false; public AT4ArmingLever ArmingLever; private void FireAT4() { if (base.Chamber.IsFull && !base.Chamber.IsSpent && !((Object)(object)ArmingLever == (Object)null) && ArmingLever.IsArmed) { base.Chamber.Fire(); ((FVRFireArm)this).FireMuzzleSmoke(); hasFired = true; StartSelfDestructCheck(); } } public override void UpdateInteraction(FVRViveHand hand) { //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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected I4, but got Unknown //IL_00fc: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected I4, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ArmingLever != (Object)null && !ArmingLever.IsArmed) { if ((Object)(object)Trigger != (Object)null && (Object)(object)hand != (Object)null) { Vector3 localPosition = Trigger.localPosition; ((Vector3)(ref localPosition))[(int)Trigger_Axis] = Mathf.Lerp(Trigger_ValRange.x, Trigger_ValRange.y, hand.Input.TriggerFloat); Trigger.localPosition = localPosition; } return; } ((SimpleLauncher)this).UpdateInteraction(hand); if ((Object)(object)Trigger != (Object)null && (Object)(object)hand != (Object)null) { Vector3 localPosition2 = Trigger.localPosition; ((Vector3)(ref localPosition2))[(int)Trigger_Axis] = Mathf.Lerp(Trigger_ValRange.x, Trigger_ValRange.y, hand.Input.TriggerFloat); Trigger.localPosition = localPosition2; } if ((Object)(object)ArmingLever != (Object)null && ArmingLever.IsArmed && !((FVRPhysicalObject)this).IsAltHeld && (Object)(object)hand != (Object)null && hand.Input.TriggerDown && !hasFired && base.Chamber.IsFull && !base.Chamber.IsSpent) { FireAT4(); } if ((!base.Chamber.IsFull || hasFired) && !selfDestructStarted && !((FVRInteractiveObject)this).IsHeld) { StartSelfDestructCheck(); } } private void StartSelfDestructCheck() { if (!selfDestructStarted) { selfDestructStarted = true; ((MonoBehaviour)this).StartCoroutine(SelfDestructCheck()); } } private IEnumerator SelfDestructCheck() { float timer = 0f; while (timer < DestroyDelay) { if (!((FVRInteractiveObject)this).IsHeld) { timer += Time.deltaTime; } yield return null; } Object.Destroy((Object)(object)((Component)this).gameObject); } } public class AT4ArmingLever : FVRInteractiveObject { public AT4 Weapon; [Header("Lever Movement")] public Transform LeverRoot; public Transform ForwardPoint; public Transform RearPoint; [Header("Arming Settings")] public float ArmThreshold = 0.9f; [Header("Lever Rotation Settings")] [Tooltip("Which local axis to rotate around: 0=X, 1=Y, 2=Z")] public int RotationAxis = 1; [Tooltip("Starting rotation (degrees) for the selected axis.")] public float StartRotation = 0f; [Tooltip("Ending rotation (degrees) for the selected axis.")] public float EndRotation = 45f; [Tooltip("How far right (in local X units) the hand must move for full rotation.")] public float MaxRightOffset = 0.1f; private bool isArmed = false; private float leverProgress = 0f; private Vector3 startLocalPos; private Vector3 endLocalPos; public bool IsArmed => isArmed; 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_0053: 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) ((FVRInteractiveObject)this).Awake(); if ((Object)(object)LeverRoot != (Object)null && (Object)(object)ForwardPoint != (Object)null && (Object)(object)RearPoint != (Object)null) { startLocalPos = RearPoint.localPosition; endLocalPos = ForwardPoint.localPosition; } } public override void UpdateInteraction(FVRViveHand hand) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_007d: 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_0084: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).UpdateInteraction(hand); if ((Object)(object)LeverRoot == (Object)null || (Object)(object)ForwardPoint == (Object)null || (Object)(object)RearPoint == (Object)null || (Object)(object)Weapon == (Object)null) { return; } Vector3 position = RearPoint.position; Vector3 position2 = ForwardPoint.position; Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(position, position2, ((HandInput)(ref hand.Input)).Pos); float num = Vector3.Distance(position, closestValidPoint) / Vector3.Distance(position, position2); num = Mathf.Clamp01(num); if (num < 1f) { LeverRoot.position = closestValidPoint; leverProgress = num; SetLeverRotation(StartRotation); } else { LeverRoot.position = position2; float num2 = Mathf.Clamp(ForwardPoint.InverseTransformPoint(((HandInput)(ref hand.Input)).Pos).x, 0f - MaxRightOffset, MaxRightOffset); float num3 = ((!(MaxRightOffset > 0f)) ? 0f : ((num2 + MaxRightOffset) / (2f * MaxRightOffset))); float leverRotation = Mathf.Lerp(StartRotation, EndRotation, num3); SetLeverRotation(leverRotation); leverProgress = 1f; } if (!isArmed && leverProgress >= ArmThreshold) { isArmed = true; if ((Object)(object)Weapon != (Object)null) { ((FVRFireArm)Weapon).PlayAudioEvent((FirearmAudioEventType)12, 1f); } } else if (isArmed && leverProgress < 0.2f) { isArmed = false; } } private void SetLeverRotation(float angle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0047: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; if (RotationAxis == 0) { zero.x = angle; } else if (RotationAxis == 1) { zero.y = angle; } else { zero.z = angle; } LeverRoot.localRotation = Quaternion.Euler(zero); } public override void EndInteraction(FVRViveHand hand) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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) ((FVRInteractiveObject)this).EndInteraction(hand); Vector3 position = RearPoint.position; Vector3 position2 = ForwardPoint.position; float num = Vector3.Distance(LeverRoot.position, position); float num2 = Vector3.Distance(LeverRoot.position, position2); if (num2 < num) { LeverRoot.position = position2; SetLeverRotation(EndRotation); } else { LeverRoot.position = position; SetLeverRotation(StartRotation); } } } public class AT4SightCover : FVRInteractiveObject { [Header("Sight References")] public Transform Sight; public Transform Cover; public Transform CoverRearPos; public Transform CoverForwardPos; [Header("Sight Local Positions & Rotations")] public Vector3 SightDownLocalPos; public Vector3 SightUpLocalPos; public Vector3 SightDownRot; public Vector3 SightUpRot; [Header("Interaction Settings")] [Range(0f, 1f)] public float CoverThreshold = 0.95f; private bool sightUp = false; public override void UpdateInteraction(FVRViveHand hand) { //IL_0047: 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_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_0067: 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_007f: 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_00e9: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_010c: 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_0118: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).UpdateInteraction(hand); if (!((Object)(object)Sight == (Object)null) && !((Object)(object)CoverRearPos == (Object)null) && !((Object)(object)CoverForwardPos == (Object)null)) { Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(CoverRearPos.position, CoverForwardPos.position, ((HandInput)(ref hand.Input)).Pos); float num = Vector3.Distance(CoverRearPos.position, closestValidPoint) / Vector3.Distance(CoverRearPos.position, CoverForwardPos.position); num = Mathf.Clamp01(num); if ((Object)(object)Cover != (Object)null) { Cover.position = Vector3.Lerp(CoverRearPos.position, CoverForwardPos.position, num); } else { ((Component)this).transform.position = Vector3.Lerp(CoverRearPos.position, CoverForwardPos.position, num); } Sight.localPosition = Vector3.Lerp(SightDownLocalPos, SightUpLocalPos, num); Sight.localEulerAngles = Vector3.Lerp(SightDownRot, SightUpRot, num); if (num >= CoverThreshold && !sightUp) { sightUp = true; } else if (num < CoverThreshold && sightUp) { sightUp = false; } } } } public class AdvanceToggleableBayonet : FVRInteractiveObject { public enum BayonetMotionMode { Rotate, Translate } public enum BayonetAxis { X, Y, Z } [Tooltip("Enables verbose console logging for debugging.")] public bool EnableDebugLogging = false; [Header("Component Connections")] [Tooltip("Reference to the parent firearm. Automatically found if null.")] public FVRFireArm FA; [Tooltip("The moving or rotating transform of the bayonet blade/assembly.")] public Transform Bayonet; [Tooltip("Optional transform marking the forward tip of the bayonet. Uses Bayonet if null.")] public Transform BayonetTip; [Tooltip("Optional transform pointing in the forward thrust direction of the bayonet. Uses MuzzlePos if null.")] public Transform StabDirectionOverride; [Tooltip("Colliders belonging to the bayonet blade. Automatically added to firearm melee stab lists when deployed.")] public Collider[] BladeColliders; [Header("Motion Configuration")] [Tooltip("Determines whether the bayonet rotates or translates.")] public BayonetMotionMode Mode = BayonetMotionMode.Rotate; [Tooltip("Local axis along which the bayonet moves or rotates.")] public BayonetAxis MotionAxis = BayonetAxis.X; [Tooltip("Value (angle or position) when the bayonet is folded/stowed.")] public float Value_Closed = 0f; [Tooltip("Value (angle or position) when the bayonet is deployed/locked forward.")] public float Value_Open = 180f; [Tooltip("Speed of motion in units or degrees per second.")] public float MoveSpeed = 720f; [Tooltip("If true, the bayonet spawns locked in the deployed position.")] public bool StartsDeployed = false; [Header("Melee Damage & Penetration")] [Tooltip("Exact penetration depth in meters. The rifle physically stops penetrating once this depth is reached.")] public float BladeLength = 0.25f; [Tooltip("If true, updates the firearm melee damage to piercing/cutting when deployed, and reverts to blunt when stowed.")] public bool OverridesMeleeDamage = true; [Tooltip("Damage when stabbing while deployed (X=Blunt, Y=Cutting, Z=Piercing).")] public Vector3 DeployedStabDamage = new Vector3(10f, 20f, 90f); [Tooltip("Damage when slashing/sweeping while deployed (X=Blunt, Y=Cutting, Z=Piercing).")] public Vector3 DeployedHighDamage = new Vector3(10f, 60f, 20f); [Header("Audio Events")] [Tooltip("Sound played when the bayonet deploys and locks forward.")] public AudioEvent AudEvent_Deploy; [Tooltip("Sound played when the bayonet folds and locks against the stock.")] public AudioEvent AudEvent_Stow; private FVRFireArm m_fa; private bool m_bayonetDeployed = false; private float m_curVal; private float m_tarVal; private Vector3 m_initialLocalPos; private Vector3 m_initialLocalRot; private Vector3 m_storedStabDamage = Vector3.zero; private Vector3 m_storedHighDamage = Vector3.zero; private bool m_hasCachedDamage = false; public override void Awake() { //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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).Awake(); if ((Object)(object)FA != (Object)null) { m_fa = FA; } else { m_fa = ((Component)this).GetComponentInParent<FVRFireArm>(); } if ((Object)(object)m_fa == (Object)null) { Debug.LogError((object)"[AdvanceToggleableBayonet] Missing FVRFireArm reference!"); return; } if ((Object)(object)Bayonet == (Object)null) { Bayonet = ((Component)this).transform; } m_initialLocalPos = Bayonet.localPosition; m_initialLocalRot = Bayonet.localEulerAngles; ((FVRPhysicalObject)m_fa).MP.IsMeleeWeapon = true; m_storedStabDamage = ((FVRPhysicalObject)m_fa).MP.StabDamageBCP; m_storedHighDamage = ((FVRPhysicalObject)m_fa).MP.HighDamageBCP; m_hasCachedDamage = true; if (((FVRPhysicalObject)m_fa).MP.StabColliders == null) { ((FVRPhysicalObject)m_fa).MP.StabColliders = new List<Collider>(); } if (((FVRPhysicalObject)m_fa).MP.HighDamageColliders == null) { ((FVRPhysicalObject)m_fa).MP.HighDamageColliders = new List<Collider>(); } m_bayonetDeployed = StartsDeployed; m_curVal = ((!m_bayonetDeployed) ? Value_Closed : Value_Open); m_tarVal = m_curVal; ApplyTransformValue(m_curVal); ApplyBayonetState(m_bayonetDeployed); } public override void SimpleInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).SimpleInteraction(hand); if ((Object)(object)m_fa != (Object)null && ((FVRPhysicalObject)m_fa).MP.IsJointedToObject) { if (EnableDebugLogging) { Debug.Log((object)"[AdvanceToggleableBayonet] Cannot toggle bayonet while impaled in target!"); } return; } if ((Object)(object)hand != (Object)null) { hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); } ToggleBayonet(); } public override void FVRUpdate() { ((FVRInteractiveObject)this).FVRUpdate(); if (Mathf.Abs(m_tarVal - m_curVal) > 0.01f) { m_curVal = Mathf.MoveTowards(m_curVal, m_tarVal, Time.deltaTime * MoveSpeed); ApplyTransformValue(m_curVal); } } public void ToggleBayonet() { //IL_011b: 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) m_bayonetDeployed = !m_bayonetDeployed; m_tarVal = ((!m_bayonetDeployed) ? Value_Closed : Value_Open); ApplyBayonetState(m_bayonetDeployed); if (m_bayonetDeployed) { if ((Object)(object)m_fa != (Object)null && AudEvent_Deploy != null) { m_fa.PlayAudioAsHandling(AudEvent_Deploy, ((Component)this).transform.position); } else if ((Object)(object)m_fa != (Object)null) { m_fa.PlayAudioEvent((FirearmAudioEventType)32, 1f); } if (EnableDebugLogging) { Debug.Log((object)("[AdvanceToggleableBayonet] Bayonet Deployed. BladeLength set to: " + ((FVRPhysicalObject)m_fa).MP.BladeLength.ToString("F2"))); } } else { if ((Object)(object)m_fa != (Object)null && AudEvent_Stow != null) { m_fa.PlayAudioAsHandling(AudEvent_Stow, ((Component)this).transform.position); } else if ((Object)(object)m_fa != (Object)null) { m_fa.PlayAudioEvent((FirearmAudioEventType)33, 1f); } if (EnableDebugLogging) { Debug.Log((object)"[AdvanceToggleableBayonet] Bayonet Stowed."); } } } private void ApplyBayonetState(bool isDeployed) { //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_fa == (Object)null) { return; } ((FVRPhysicalObject)m_fa).MP.CanNewStab = isDeployed; ((FVRPhysicalObject)m_fa).MP.BladeLength = ((!isDeployed) ? 0.01f : BladeLength); if ((Object)(object)((FVRPhysicalObject)m_fa).MP.HandPoint == (Object)null) { if ((Object)(object)m_fa.StockPos != (Object)null) { ((FVRPhysicalObject)m_fa).MP.HandPoint = m_fa.StockPos; } else { ((FVRPhysicalObject)m_fa).MP.HandPoint = ((Component)m_fa).transform; } } if (isDeployed) { if ((Object)(object)BayonetTip != (Object)null) { ((FVRPhysicalObject)m_fa).MP.EndPoint = BayonetTip; } else { ((FVRPhysicalObject)m_fa).MP.EndPoint = Bayonet; } if ((Object)(object)StabDirectionOverride != (Object)null) { ((FVRPhysicalObject)m_fa).MP.StabDirection = StabDirectionOverride; } else if ((Object)(object)m_fa.MuzzlePos != (Object)null) { ((FVRPhysicalObject)m_fa).MP.StabDirection = m_fa.MuzzlePos; } else { ((FVRPhysicalObject)m_fa).MP.StabDirection = Bayonet; } } else if ((Object)(object)m_fa.MuzzlePos != (Object)null) { ((FVRPhysicalObject)m_fa).MP.EndPoint = m_fa.MuzzlePos; ((FVRPhysicalObject)m_fa).MP.StabDirection = m_fa.MuzzlePos; } else { ((FVRPhysicalObject)m_fa).MP.EndPoint = ((Component)m_fa).transform; ((FVRPhysicalObject)m_fa).MP.StabDirection = ((Component)m_fa).transform; } if (((FVRPhysicalObject)m_fa).MP.StabVelocityRequirement <= 0f) { ((FVRPhysicalObject)m_fa).MP.StabVelocityRequirement = 1f; } if (((FVRPhysicalObject)m_fa).MP.StabAngularThreshold <= 0f) { ((FVRPhysicalObject)m_fa).MP.StabAngularThreshold = 25f; } ((FVRPhysicalObject)m_fa).MP.InitMeleeParams((FVRPhysicalObject)(object)m_fa); if (OverridesMeleeDamage && m_hasCachedDamage) { if (isDeployed) { ((FVRPhysicalObject)m_fa).MP.StabDamageBCP = DeployedStabDamage; ((FVRPhysicalObject)m_fa).MP.HighDamageBCP = DeployedHighDamage; } else { ((FVRPhysicalObject)m_fa).MP.StabDamageBCP = m_storedStabDamage; ((FVRPhysicalObject)m_fa).MP.HighDamageBCP = m_storedHighDamage; } } if (BladeColliders == null) { return; } string text = ((!isDeployed) ? "NoCol" : "Default"); int layer = LayerMask.NameToLayer(text); for (int i = 0; i < BladeColliders.Length; i++) { Collider val = BladeColliders[i]; if (!((Object)(object)val != (Object)null)) { continue; } ((Component)val).gameObject.layer = layer; if (isDeployed) { if (!((FVRPhysicalObject)m_fa).MP.StabColliders.Contains(val)) { ((FVRPhysicalObject)m_fa).MP.StabColliders.Add(val); } if (!((FVRPhysicalObject)m_fa).MP.HighDamageColliders.Contains(val)) { ((FVRPhysicalObject)m_fa).MP.HighDamageColliders.Add(val); } } else { ((FVRPhysicalObject)m_fa).MP.StabColliders.Remove(val); ((FVRPhysicalObject)m_fa).MP.HighDamageColliders.Remove(val); } } } private void ApplyTransformValue(float val) { //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_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_00c9: 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) if ((Object)(object)Bayonet == (Object)null) { return; } if (Mode == BayonetMotionMode.Rotate) { Vector3 initialLocalRot = m_initialLocalRot; if (MotionAxis == BayonetAxis.X) { initialLocalRot.x = val; } else if (MotionAxis == BayonetAxis.Y) { initialLocalRot.y = val; } else { initialLocalRot.z = val; } Bayonet.localEulerAngles = initialLocalRot; } else { Vector3 initialLocalPos = m_initialLocalPos; if (MotionAxis == BayonetAxis.X) { initialLocalPos.x = val; } else if (MotionAxis == BayonetAxis.Y) { initialLocalPos.y = val; } else { initialLocalPos.z = val; } Bayonet.localPosition = initialLocalPos; } } } public class Arwen : FVRFireArm { [Tooltip("Enables verbose console logging for debugging.")] public bool EnableDebugLogging = false; [Header("Arwen 37mm Config")] [Tooltip("Reference to the rotating cylinder script.")] public ArwenCylinder Cylinder; [Tooltip("Array of the 5 chamber components on the cylinder.")] public FVRFireArmChamber[] Chambers; [Header("Trigger")] [Tooltip("Transform of the trigger mesh.")] public Transform Trigger; [Tooltip("Trigger float value at which the weapon fires (DAO pull depth).")] public float TriggerFiringThreshold = 0.95f; [Tooltip("Trigger float value below which a spent shell ejects on release.")] public float TriggerEjectThreshold = 0.35f; [Tooltip("Trigger float value below which the trigger is considered fully reset.")] public float TriggerResetThreshold = 0.1f; [Tooltip("Whether the trigger rotates when pulled.")] public bool TriggerUsesRotation = true; [Tooltip("Local axis around which the trigger rotates.")] public Vector3 TriggerRotationAxis = Vector3.right; [Tooltip("Trigger rotation angle at rest.")] public float TriggerMinAngle = 0f; [Tooltip("Trigger rotation angle at full pull.")] public float TriggerMaxAngle = 30f; [Tooltip("Whether the trigger translates linearly when pulled.")] public bool TriggerUsesTranslation = false; [Tooltip("Local axis along which the trigger translates.")] public Vector3 TriggerTranslationAxis = Vector3.back; [Tooltip("Trigger translation offset at rest.")] public float TriggerMinPosition = 0f; [Tooltip("Trigger translation offset at full pull.")] public float TriggerMaxPosition = 0.02f; [Header("Hammer")] [Tooltip("Transform of the hammer or striker mesh.")] public Transform Hammer; [Tooltip("Whether the hammer rotates as the trigger is pulled.")] public bool HammerUsesRotation = true; [Tooltip("Local axis around which the hammer rotates.")] public Vector3 HammerRotationAxis = Vector3.right; [Tooltip("Hammer rotation angle at rest.")] public float HammerMinAngle = 0f; [Tooltip("Hammer rotation angle at full cock before release.")] public float HammerMaxAngle = 45f; [Tooltip("Whether the hammer translates linearly as the trigger is pulled.")] public bool HammerUsesTranslation = false; [Tooltip("Local axis along which the hammer translates.")] public Vector3 HammerTranslationAxis = Vector3.back; [Tooltip("Hammer translation offset at rest.")] public float HammerMinPosition = 0f; [Tooltip("Hammer translation offset at full cock.")] public float HammerMaxPosition = 0.01f; [Header("Bolt")] [Tooltip("Transform of the bolt assembly that slides rearward as the trigger pulls.")] public Transform BoltTransform; [Tooltip("Forward resting position transform for the bolt.")] public Transform Point_Bolt_Forward; [Tooltip("Rearward position transform for the bolt at full trigger pull.")] public Transform Point_Bolt_Rear; [Header("Chamber Feed")] [Tooltip("Distance in meters the active round nudges forward into the barrel as the trigger pulls.")] public float ChamberFeedDistance = 0.005f; [Header("Ejection")] [Tooltip("Transform marking the shell ejection port position and orientation.")] public Transform EjectionPos; [Tooltip("Local-space ejection velocity relative to EjectionPos.")] public Vector3 EjectionVelocity = new Vector3(0.2f, 0.5f, 0f); [Tooltip("Local-space angular spin velocity relative to EjectionPos.")] public Vector3 EjectionSpin = new Vector3(0f, 200f, 0f); [Header("Cylinder")] [Tooltip("Duration in seconds for automated cylinder indexing rotation.")] public float CylinderRotateDuration = 0.2f; [Header("Safety")] [Tooltip("Left-side safety selector switch transform.")] public Transform SafetySwitchLeft; [Tooltip("Right-side safety selector switch transform.")] public Transform SafetySwitchRight; [Tooltip("Interpolation style for animating the safety switches.")] public InterpStyle SafetyInterpStyle = (InterpStyle)1; [Tooltip("Local axis for safety switch animation.")] public Axis SafetyAxis; [Tooltip("Safety switch angle or position value in Fire mode.")] public float SafetyPosition_Fire = 0f; [Tooltip("Safety switch angle or position value in Safe mode.")] public float SafetyPosition_Safe = 45f; [Header("Audio")] [Tooltip("Native firearm audio event played when ejecting a shell if CustomEjectionAudio is empty.")] public FirearmAudioEventType EjectionAudioType = (FirearmAudioEventType)29; [Tooltip("Optional custom audio event played on shell ejection.")] public AudioEvent CustomEjectionAudio; [Tooltip("Native firearm audio event played when loading a round into a chamber.")] public FirearmAudioEventType LoadAudioType = (FirearmAudioEventType)28; [Tooltip("Native firearm audio event played when toggling the safety.")] public FirearmAudioEventType SafetyAudioType = (FirearmAudioEventType)14; private int m_curChamber = 0; private bool m_isSafetyOn = false; private bool m_hasTriggerCycled = false; private bool m_hasFired = false; private bool m_hasDryFired = false; private bool m_hasSafetyToggled = false; private bool m_isRestoringState = false; private bool[] m_prevChamberFull; private bool[] m_prevChamberPresent; private Coroutine m_cylinderCoroutine; private bool m_hasProxyFeedOffset = false; public override void Awake() { ((FVRFireArm)this).Awake(); if (Chambers != null) { for (int i = 0; i < Chambers.Length; i++) { if ((Object)(object)Chambers[i] != (Object)null) { base.FChambers.Add(Chambers[i]); } } } int num = ((Chambers != null) ? Chambers.Length : 0); m_prevChamberFull = new bool[num]; m_prevChamberPresent = new bool[num]; for (int j = 0; j < num; j++) { if (!((Object)(object)Chambers[j] == (Object)null)) { m_prevChamberFull[j] = Chambers[j].IsFull && !Chambers[j].IsSpent; m_prevChamberPresent[j] = Chambers[j].IsFull; } } SetAllChambersAccessible(accessible: true); UpdateSafetyVisual(); } public override void FVRUpdate() { ((FVRFireArm)this).FVRUpdate(); if (!m_isRestoringState) { DetectShellLoaded(); } } private void DetectShellLoaded() { if (Chambers == null) { return; } for (int i = 0; i < Chambers.Length; i++) { FVRFireArmChamber val = Chambers[i]; if (!((Object)(object)val == (Object)null)) { bool flag = val.IsFull && !val.IsSpent; bool isFull = val.IsFull; if (flag && !m_prevChamberFull[i]) { OnShellLoaded(i); } if (!isFull && m_prevChamberPresent[i]) { OnShellRemoved(i); } m_prevChamberFull[i] = flag; m_prevChamberPresent[i] = isFull; } } } private void OnShellLoaded(int chamberIndex) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (Chambers != null && Chambers.Length != 0) { if (chamberIndex == m_curChamber && ((Object)(object)Cylinder == (Object)null || !((FVRInteractiveObject)Cylinder).IsHeld)) { ResetCurrentChamberProxyOffset(); RotateToChamber(m_curChamber = (m_curChamber - 1 + Chambers.Length) % Chambers.Length); } ((FVRFireArm)this).PlayAudioEvent(LoadAudioType, 1f); if (EnableDebugLogging) { Debug.Log((object)("[Arwen] Shell loaded into chamber " + chamberIndex)); } } } private void OnShellRemoved(int chamberIndex) { if (Chambers != null && Chambers.Length != 0 && chamberIndex == m_curChamber) { ResetCurrentChamberProxyOffset(); int num = FindNextLoadedChamberClockwise(); if (num != m_curChamber) { RotateToChamber(num); m_curChamber = num; } if (EnableDebugLogging) { Debug.Log((object)("[Arwen] Shell manually removed from chamber " + chamberIndex)); } } } private int FindNextLoadedChamberClockwise() { for (int i = 1; i < Chambers.Length; i++) { int num = (m_curChamber + i) % Chambers.Length; if ((Object)(object)Chambers[num] != (Object)null && Chambers[num].IsFull && !Chambers[num].IsSpent) { return num; } } return m_curChamber; } public override void UpdateInteraction(FVRViveHand hand) { ((FVRPhysicalObject)this).UpdateInteraction(hand); if (!((Object)(object)hand == (Object)null)) { float triggerFloat = hand.Input.TriggerFloat; UpdateTriggerVisual(triggerFloat); UpdateHammerVisual(triggerFloat); UpdateBoltVisual(triggerFloat); UpdateChamberFeedVisual(triggerFloat); HandleSafetyInput(hand); if (m_hasFired && triggerFloat < TriggerEjectThreshold) { EjectCurrentChamber(); AdvanceChamberClockwise(); m_hasFired = false; } if (m_hasDryFired && triggerFloat < TriggerResetThreshold) { AdvanceChamberClockwise(); m_hasDryFired = false; } if (!m_isSafetyOn && triggerFloat >= TriggerFiringThreshold && !m_hasTriggerCycled) { FireOrDryFire(); m_hasTriggerCycled = true; } if (triggerFloat < TriggerResetThreshold && m_hasTriggerCycled) { ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f); m_hasTriggerCycled = false; } } } public override void EndInteraction(FVRViveHand hand) { ((FVRFireArm)this).EndInteraction(hand); ResetTriggerMechanicsOnRelease(); } private void ResetTriggerMechanicsOnRelease() { UpdateTriggerVisual(0f); UpdateHammerVisual(0f); UpdateBoltVisual(0f); ResetCurrentChamberProxyOffset(); if (m_hasFired) { EjectCurrentChamber(); AdvanceChamberClockwise(); m_hasFired = false; } if (m_hasDryFired) { AdvanceChamberClockwise(); m_hasDryFired = false; } if (m_hasTriggerCycled) { ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f); m_hasTriggerCycled = false; } m_hasSafetyToggled = false; } private void FireOrDryFire() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (Chambers == null || m_curChamber < 0 || m_curChamber >= Chambers.Length) { return; } FVRFireArmChamber val = Chambers[m_curChamber]; if ((Object)(object)val == (Object)null) { return; } if (val.IsFull && !val.IsSpent) { val.Fire(); Transform val2 = ((!((Object)(object)base.MuzzlePos != (Object)null)) ? ((Component)this).transform : base.MuzzlePos); ((FVRFireArm)this).Fire(val, val2, true, 1f, -1f); ((FVRFireArm)this).FireMuzzleSmoke(); ((FVRFireArm)this).Recoil(((FVRFireArm)this).IsTwoHandStabilized(), (Object)(object)((FVRPhysicalObject)this).AltGrip != (Object)null, ((FVRFireArm)this).IsShoulderStabilized(), (FVRFireArmRecoilProfile)null, 1f); ((FVRFireArm)this).PlayAudioGunShot(val.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f); if (GM.CurrentSceneSettings.IsAmmoInfinite || GM.CurrentPlayerBody.IsInfiniteAmmo) { val.IsSpent = false; val.UpdateProxyDisplay(); } m_hasFired = true; if (EnableDebugLogging) { Debug.Log((object)("[Arwen] Fired chamber " + m_curChamber)); } } else { ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f); m_hasDryFired = true; if (EnableDebugLogging) { Debug.Log((object)("[Arwen] Dry fired chamber " + m_curChamber)); } } } private void EjectCurrentChamber() { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_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_008d: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_018b: 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_00dc: Unknown result type (might be due to invalid IL or missing references) if (Chambers == null || m_curChamber < 0 || m_curChamber >= Chambers.Length) { return; } FVRFireArmChamber val = Chambers[m_curChamber]; if ((Object)(object)val == (Object)null || !val.IsFull) { return; } ResetCurrentChamberProxyOffset(); if ((Object)(object)EjectionPos != (Object)null) { Vector3 val2 = EjectionPos.TransformDirection(EjectionVelocity); Vector3 val3 = EjectionPos.TransformDirection(EjectionSpin); val.EjectRound(EjectionPos.position, val2, val3, EjectionPos.position, EjectionPos.rotation, false); if (CustomEjectionAudio != null) { ((FVRFireArm)this).PlayAudioAsHandling(CustomEjectionAudio, EjectionPos.position); } else { ((FVRFireArm)this).PlayAudioEvent(EjectionAudioType, 1f); } } else { Vector3 val4 = ((Component)this).transform.forward * 3f + Vector3.up * 1.5f; Vector3 val5 = Vector3.up * 200f; val.EjectRound(((Component)val).transform.position + ((Component)val).transform.forward * 0.1f, val4, val5, true); if (CustomEjectionAudio != null) { ((FVRFireArm)this).PlayAudioAsHandling(CustomEjectionAudio, ((Component)val).transform.position); } else { ((FVRFireArm)this).PlayAudioEvent(EjectionAudioType, 1f); } } m_prevChamberFull[m_curChamber] = false; m_prevChamberPresent[m_curChamber] = false; if (EnableDebugLogging) { Debug.Log((object)("[Arwen] Ejected round from chamber " + m_curChamber)); } } private void AdvanceChamberClockwise() { if (Chambers != null && Chambers.Length != 0) { ResetCurrentChamberProxyOffset(); int num = (m_curChamber + 1) % Chambers.Length; RotateToChamber(num); m_curChamber = num; } } private void RotateToChamber(int index) { if (m_cylinderCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(m_cylinderCoroutine); } m_cylinderCoroutine = ((MonoBehaviour)this).StartCoroutine(RotateCylinderTo(index)); } private IEnumerator RotateCylinderTo(int toIndex) { if (!((Object)(object)Cylinder == (Object)null)) { Quaternion from = ((Component)Cylinder).transform.localRotation; Quaternion to = Cylinder.GetLocalRotationFromCylinder(toIndex); float elapsed = 0f; float dur = Mathf.Max(0.01f, CylinderRotateDuration); while (elapsed < 1f) { elapsed += Time.deltaTime / dur; ((Component)Cylinder).transform.localRotation = Quaternion.Slerp(from, to, elapsed); yield return null; } ((Component)Cylinder).transform.localRotation = to; m_cylinderCoroutine = null; } } public void StopCylinderRotation() { if (m_cylinderCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(m_cylinderCoroutine); m_cylinderCoroutine = null; } } public void SyncChamberFromCylinder() { if ((Object)(object)Cylinder != (Object)null) { ResetCurrentChamberProxyOffset(); m_curChamber = Cylinder.GetClosestChamberIndex(); if (EnableDebugLogging) { Debug.Log((object)("[Arwen] Synced active chamber to " + m_curChamber)); } } } private void UpdateTriggerVisual(float t) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) if (!((Object)(object)Trigger == (Object)null)) { if (TriggerUsesRotation) { Trigger.localRotation = Quaternion.AngleAxis(Mathf.Lerp(TriggerMinAngle, TriggerMaxAngle, t), TriggerRotationAxis); } if (TriggerUsesTranslation) { Trigger.localPosition = ((Vector3)(ref TriggerTranslationAxis)).normalized * Mathf.Lerp(TriggerMinPosition, TriggerMaxPosition, t); } } } private void UpdateHammerVisual(float t) { //IL_0054: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Hammer == (Object)null)) { float num = ((!m_isSafetyOn) ? t : 0f); if (HammerUsesRotation) { Hammer.localRotation = Quaternion.AngleAxis(Mathf.Lerp(HammerMinAngle, HammerMaxAngle, num), HammerRotationAxis); } if (HammerUsesTranslation) { Hammer.localPosition = ((Vector3)(ref HammerTranslationAxis)).normalized * Mathf.Lerp(HammerMinPosition, HammerMaxPosition, num); } } } private void UpdateBoltVisual(float t) { //IL_005d: 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_006e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)BoltTransform == (Object)null) && !((Object)(object)Point_Bolt_Forward == (Object)null) && !((Object)(object)Point_Bolt_Rear == (Object)null)) { float num = ((!m_isSafetyOn) ? t : 0f); BoltTransform.localPosition = Vector3.Lerp(Point_Bolt_Forward.localPosition, Point_Bolt_Rear.localPosition, num); } } private void UpdateChamberFeedVisual(float t) { //IL_0096: 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_00a6: 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_00d5: Unknown result type (might be due to invalid IL or missing references) if (Chambers == null || m_curChamber < 0 || m_curChamber >= Chambers.Length) { return; } FVRFireArmChamber val = Chambers[m_curChamber]; if (!((Object)(object)val == (Object)null) && val.IsFull && !((Object)(object)val.ProxyRound == (Object)null)) { float num = ((!m_isSafetyOn) ? t : 0f); if (num > 0.001f) { val.ProxyRound.localPosition = Vector3.Lerp(Vector3.zero, Vector3.forward * ChamberFeedDistance, num); m_hasProxyFeedOffset = true; } else if (m_hasProxyFeedOffset) { val.ProxyRound.localPosition = Vector3.zero; m_hasProxyFeedOffset = false; } } } private void ResetCurrentChamberProxyOffset() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (!m_hasProxyFeedOffset) { return; } if (Chambers != null && m_curChamber >= 0 && m_curChamber < Chambers.Length) { FVRFireArmChamber val = Chambers[m_curChamber]; if ((Object)(object)val != (Object)null && (Object)(object)val.ProxyRound != (Object)null) { val.ProxyRound.localPosition = Vector3.zero; } } m_hasProxyFeedOffset = false; } private void HandleSafetyInput(FVRViveHand hand) { //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_0089: 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) if (hand.IsInStreamlinedMode) { if (hand.Input.BYButtonDown && !m_hasSafetyToggled) { ToggleSafety(); m_hasSafetyToggled = true; } else if (!hand.Input.BYButtonDown) { m_hasSafetyToggled = false; } } else if (hand.Input.TouchpadDown) { Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.left) < 45f) { ToggleSafety(); } } } private void ToggleSafety() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) m_isSafetyOn = !m_isSafetyOn; UpdateSafetyVisual(); ((FVRFireArm)this).PlayAudioEvent(SafetyAudioType, 1f); if (EnableDebugLogging) { Debug.Log((object)("[Arwen] Safety toggled: " + ((!m_isSafetyOn) ? "FIRE" : "SAFE"))); } } private void UpdateSafetyVisual() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) float num = ((!m_isSafetyOn) ? SafetyPosition_Fire : SafetyPosition_Safe); if ((Object)(object)SafetySwitchLeft != (Object)null) { ((FVRPhysicalObject)this).SetAnimatedComponent(SafetySwitchLeft, num, SafetyInterpStyle, SafetyAxis); } if ((Object)(object)SafetySwitchRight != (Object)null) { ((FVRPhysicalObject)this).SetAnimatedComponent(SafetySwitchRight, num, SafetyInterpStyle, SafetyAxis); } } private void SetAllChambersAccessible(bool accessible) { if (Chambers == null) { return; } for (int i = 0; i < Chambers.Length; i++) { if ((Object)(object)Chambers[i] != (Object)null) { Chambers[i].IsAccessible = accessible; } } } public override List<FireArmRoundClass> GetChamberRoundList() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (Chambers == null) { return null; } bool flag = false; List<FireArmRoundClass> list = new List<FireArmRoundClass>(); for (int i = 0; i < Chambers.Length; i++) { if ((Object)(object)Chambers[i] != (Object)null && Chambers[i].IsFull && !Chambers[i].IsSpent) { list.Add(Chambers[i].GetRound().RoundClass); flag = true; } else { list.Add((FireArmRoundClass)(-1)); } } return (!flag) ? null : list; } public override void SetLoadedChambers(List<FireArmRoundClass> rounds) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (rounds == null || Chambers == null) { return; } m_isRestoringState = true; for (int i = 0; i < rounds.Count && i < Chambers.Length; i++) { if ((Object)(object)Chambers[i] != (Object)null && (int)rounds[i] >= 0) { Chambers[i].Autochamber(rounds[i]); } } for (int j = 0; j < Chambers.Length; j++) { if (!((Object)(object)Chambers[j] == (Object)null)) { m_prevChamberFull[j] = Chambers[j].IsFull && !Chambers[j].IsSpent; m_prevChamberPresent[j] = Chambers[j].IsFull; } } m_isRestoringState = false; } } public class ArwenCylinder : FVRInteractiveObject { [Tooltip("Enables verbose console logging for debugging.")] public bool EnableDebugLogging = false; [Header("Arwen Cylinder Config")] [Tooltip("Reference to the parent Arwen weapon controller.")] public Arwen Arwen; [Tooltip("Total number of chambers in the cylinder.")] public int NumChambers = 5; [Header("Spin Physics")] [Tooltip("Degrees per second multiplier applied from vertical hand movement.")] public float SpinSensitivity = 720f; [Tooltip("Maximum cylinder spin rate in degrees per second.")] public float MaxSpinSpeed = 1440f; [Tooltip("Damping factor slowing the cylinder down when released.")] public float SpinDamping = 2.5f; [Tooltip("Spin speed threshold in degrees per second below which the cylinder snaps to the nearest chamber.")] public float SnapStopThreshold = 25f; [Tooltip("Interpolation speed when snapping to the closest chamber detent.")] public float SnapSpeed = 20f; [Tooltip("Audio event type played when a chamber clicks past the index during manual spin.")] public FirearmAudioEventType SpinClickAudioType = (FirearmAudioEventType)42; private float m_fakeAngularVel; private bool m_needsSnap; private int m_lastClickChamber = -1; public override void Awake() { ((FVRInteractiveObject)this).Awake(); m_lastClickChamber = GetClosestChamberIndex(); } public override bool IsInteractable() { return true; } public override void BeginInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).BeginInteraction(hand); m_needsSnap = false; m_fakeAngularVel = 0f; m_lastClickChamber = GetClosestChamberIndex(); if ((Object)(object)Arwen != (Object)null) { Arwen.StopCylinderRotation(); } } public override void UpdateInteraction(FVRViveHand hand) { //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_0046: 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_0099: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).UpdateInteraction(hand); if (!((Object)(object)Arwen == (Object)null) && !((Object)(object)hand == (Object)null)) { float num = 0f - ((Component)Arwen).transform.InverseTransformDirection(hand.Input.VelLinearWorld).y; float num2 = Mathf.Clamp(num * SpinSensitivity, 0f - MaxSpinSpeed, MaxSpinSpeed); float num3 = num2 * Time.deltaTime; ((Component)this).transform.localEulerAngles = new Vector3(0f, 0f, ((Component)this).transform.localEulerAngles.z + num3); m_fakeAngularVel = num2; CheckChamberClickFeedback(); } } public override void EndInteraction(FVRViveHand hand) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Arwen != (Object)null && (Object)(object)hand != (Object)null) { float num = 0f - ((Component)Arwen).transform.InverseTransformDirection(hand.Input.VelLinearWorld).y; m_fakeAngularVel = Mathf.Clamp(num * SpinSensitivity, 0f - MaxSpinSpeed, MaxSpinSpeed); } else { m_fakeAngularVel = 0f; } m_needsSnap = true; ((FVRInteractiveObject)this).EndInteraction(hand); } public override void FVRUpdate() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_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_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_0067: 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) ((FVRInteractiveObject)this).FVRUpdate(); if (((FVRInteractiveObject)this).IsHeld || !m_needsSnap) { return; } if (Mathf.Abs(m_fakeAngularVel) > SnapStopThreshold) { float num = m_fakeAngularVel * Time.deltaTime; ((Component)this).transform.localEulerAngles = new Vector3(0f, 0f, ((Component)this).transform.localEulerAngles.z + num); m_fakeAngularVel = Mathf.Lerp(m_fakeAngularVel, 0f, Time.deltaTime * SpinDamping); CheckChamberClickFeedback(); return; } m_fakeAngularVel = 0f; int closestChamberIndex = GetClosestChamberIndex(); Quaternion localRotationFromCylinder = GetLocalRotationFromCylinder(closestChamberIndex); ((Component)this).transform.localRotation = Quaternion.Slerp(((Component)this).transform.localRotation, localRotationFromCylinder, Time.deltaTime * SnapSpeed); if (Quaternion.Angle(((Component)this).transform.localRotation, localRotationFromCylinder) < 0.25f) { ((Component)this).transform.localRotation = localRotationFromCylinder; m_needsSnap = false; if ((Object)(object)Arwen != (Object)null) { Arwen.SyncChamberFromCylinder(); } if (EnableDebugLogging) { Debug.Log((object)("[ArwenCylinder] Snapped to chamber " + closestChamberIndex)); } } } private void CheckChamberClickFeedback() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) int closestChamberIndex = GetClosestChamberIndex(); if (closestChamberIndex != m_lastClickChamber) { m_lastClickChamber = closestChamberIndex; if ((Object)(object)Arwen != (Object)null) { ((FVRFireArm)Arwen).PlayAudioEvent(SpinClickAudioType, 1f); } if (((FVRInteractiveObject)this).IsHeld && (Object)(object)base.m_hand != (Object)null && (Object)(object)base.m_hand.Buzzer != (Object)null) { base.m_hand.Buzz(base.m_hand.Buzzer.Buzz_OnHoverInteractive); } } } public int GetClosestChamberIndex() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (NumChambers <= 0) { return 0; } float num = 0f - ((Component)this).transform.localEulerAngles.z; num += 360f / (float)NumChambers * 0.5f; num = Mathf.Repeat(num, 360f); return Mathf.Clamp(Mathf.CeilToInt(num / (360f / (float)NumChambers)) - 1, 0, NumChambers - 1); } public Quaternion GetLocalRotationFromCylinder(int cylinder) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (NumChambers <= 0) { return Quaternion.identity; } float num = Mathf.Repeat((float)cylinder * (360f / (float)NumChambers) * -1f, 360f); return Quaternion.Euler(0f, 0f, num); } } public class ClosedBoltHandleCatch : MonoBehaviour { [Tooltip("Enables verbose console logging for debugging.")] public bool EnableDebugLogging = false; [Header("Component Connections")] [Tooltip("Reference to the ClosedBoltWeapon. Automatically found on self or parents if null.")] public ClosedBoltWeapon Weapon; [Tooltip("Reference to the ClosedBoltHandle. Automatically found on self or Weapon if null.")] public ClosedBoltHandle Handle; [Header("Bolt Catch Inputs")] [Tooltip("Allows locking the bolt by pressing A/X (Streamlined) or Touchpad Down (Classic) on the hand holding the charging handle.")] public bool EnableHandleHandCatch = true; [Tooltip("Allows locking the bolt by holding Thumbstick Click (Streamlined) or Touchpad Right (Classic) on the firing hand while racking.")] public bool EnableFiringHandCatch = true; [Header("Manual Loading")] [Tooltip("Automatically toggles Chamber.IsAccessible when the bolt is open/locked back so single rounds can be loaded manually.")] public bool ManageChamberAccessibility = true; [Tooltip("If true, the chamber only becomes accessible when the bolt is at or behind the lock point. If false, opens whenever the bolt is not forward.")] public bool RequireBoltAtOrBehindLock = true; [Header("Audio")] [Tooltip("Optional custom sound played when engaging the bolt catch from the handle. Falls back to CatchOnSear if unassigned.")] public AudioEvent AudEvent_BoltCatch; private bool m_hasInitialized = false; private bool m_wasBoltLocked = false; private bool m_wasChamberAccessible = false; private void Awake() { if ((Object)(object)Weapon == (Object)null) { Weapon = ((Component)this).GetComponent<ClosedBoltWeapon>(); } if ((Object)(object)Weapon == (Object)null) { Weapon = ((Component)this).GetComponentInParent<ClosedBoltWeapon>(); } if ((Object)(object)Handle == (Object)null) { Handle = ((Component)this).GetComponent<ClosedBoltHandle>(); } if ((Object)(object)Handle == (Object)null && (Object)(object)Weapon != (Object)null) { Handle = Weapon.Handle; } if ((Object)(object)Weapon == (Object)null && (Object)(object)Handle != (Object)null) { Weapon = Handle.Weapon; } if ((Object)(object)Weapon == (Object)null || (Object)(object)Handle == (Object)null || (Object)(object)Weapon.Bolt == (Object)null) { Debug.LogError((object)"[ClosedBoltHandleCatch] Missing required references (Weapon, Handle, or Bolt)!"); return; } m_wasBoltLocked = Weapon.Bolt.IsBoltLocked(); if ((Object)(object)Weapon.Chamber != (Object)null) { m_wasChamberAccessible = Weapon.Chamber.IsAccessible; } m_hasInitialized = true; } private void Update() { if (m_hasInitialized && !((Object)(object)Weapon == (Object)null) && !((Object)(object)Handle == (Object)null) && !((Object)(object)Weapon.Bolt == (Object)null)) { ProcessHandleHandCatch(); ProcessFiringHandCatch(); UpdateChamberAccessibility(); MonitorLockStateDebug(); } } private void ProcessHandleHandCatch() { //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_009a: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_012f: Unknown result type (might be due to invalid IL or missing references) if (!EnableHandleHandCatch || !((FVRInteractiveObject)Handle).IsHeld || (Object)(object)((FVRInteractiveObject)Handle).m_hand == (Object)null) { return; } FVRViveHand hand = ((FVRInteractiveObject)Handle).m_hand; bool flag = false; if (hand.IsInStreamlinedMode) { if (hand.Input.AXButtonDown) { flag = true; } } else { Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.down) < 45f) { flag = true; } } if (!flag) { return; } if ((int)Weapon.Bolt.CurPos >= 2) { if (!Weapon.Bolt.IsBoltLocked()) { bool flag2 = (int)Weapon.Bolt.CurPos == 2; Weapon.Bolt.LockBolt(); if (AudEvent_BoltCatch != null) { ((FVRFireArm)Weapon).PlayAudioAsHandling(AudEvent_BoltCatch, ((Component)Handle).transform.position); } else if (flag2) { ((FVRFireArm)Weapon).PlayAudioEvent((FirearmAudioEventType)5, 1f); } hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); ((FVRInteractiveObject)Handle).ForceBreakInteraction(); if (EnableDebugLogging) { Debug.Log((object)"[ClosedBoltHandleCatch] Bolt locked via handle hand button."); } } } else if (EnableDebugLogging) { Debug.Log((object)"[ClosedBoltHandleCatch] Catch ignored: bolt is not pulled back to lock point."); } } private void ProcessFiringHandCatch() { //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_00aa: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Invalid comparison between Unknown and I4 //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Invalid comparison between Unknown and I4 //IL_0143: Unknown result type (might be due to invalid IL or missing references) if (!EnableFiringHandCatch || !((FVRInteractiveObject)Weapon).IsHeld || ((FVRPhysicalObject)Weapon).IsAltHeld || (Object)(object)((FVRInteractiveObject)Weapon).m_hand == (Object)null) { return; } FVRViveHand hand = ((FVRInteractiveObject)Weapon).m_hand; bool flag = false; if (hand.IsInStreamlinedMode) { if (hand.Input.TouchpadPressed) { flag = true; } } else { Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.Input.TouchpadPressed && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.right) <= 45f) { flag = true; } } if (flag && (int)Weapon.Bolt.CurPos >= 2 && !Weapon.Bolt.IsBoltLocked()) { bool flag2 = (int)Weapon.Bolt.CurPos == 2; Weapon.Bolt.LockBolt(); if (AudEvent_BoltCatch != null) { ((FVRFireArm)Weapon).PlayAudioAsHandling(AudEvent_BoltCatch, ((Component)Weapon.Bolt).transform.position); } else if (flag2) { ((FVRFireArm)Weapon).PlayAudioEvent((FirearmAudioEventType)5, 1f); } hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); if (EnableDebugLogging) { Debug.Log((object)"[ClosedBoltHandleCatch] Bolt locked via firing hand catch hold."); } } } private void UpdateChamberAccessibility() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 if (!ManageChamberAccessibility || (Object)(object)Weapon.Chamber == (Object)null) { return; } bool flag = ((!RequireBoltAtOrBehindLock) ? ((int)Weapon.Bolt.CurPos != 0) : ((int)Weapon.Bolt.CurPos >= 2 || Weapon.Bolt.IsBoltLocked())); bool flag2 = flag && !Weapon.HasExtractedRound(); Weapon.Chamber.IsAccessible = flag2; if (flag2 != m_wasChamberAccessible) { m_wasChamberAccessible = flag2; if (EnableDebugLogging) { Debug.Log((object)("[ClosedBoltHandleCatch] Chamber IsAccessible: " + flag2)); } } } private void MonitorLockStateDebug() { bool flag = Weapon.Bolt.IsBoltLocked(); if (flag != m_wasBoltLocked) { m_wasBoltLocked = flag; if (EnableDebugLogging) { Debug.Log((object)("[ClosedBoltHandleCatch] Bolt Lock State Changed: " + flag)); } } } } public class AdvanceCloseBoltRelease : FVRInteractiveObject { public enum SlapDirectionAxis { Forward, NegativeForward, Right, NegativeRight, Up, NegativeUp } [Header("Firearm References")] [Tooltip("Parent closed bolt weapon component.")] public ClosedBoltWeapon Weapon; [Tooltip("Transform used as reference for directional slap normal calculation.")] public Transform SlapNormalTransform; [Header("Slap Detection Config")] [Tooltip("Enable velocity and optional angle thresholds for physical controller slaps.")] public bool EnableSlapDetection = true; [Tooltip("Minimum hand velocity required to register as a slap.")] public float MinSlapSpeed = 0.5f; [Tooltip("Require hand movement to align with a specific surface normal vector.")] public bool CheckSlapDirection; [Tooltip("Axis direction representing the inward slap normal.")] public SlapDirectionAxis SlapAxis = SlapDirectionAxis.NegativeForward; [Tooltip("Minimum dot product alignment required if directional check is enabled.")] public float SlapAngleThreshold = 0.2f; [Tooltip("Cooldown period after a slap to prevent double-triggering.")] public float SlapCooldownDuration = 0.2f; [Header("Grab And Click Config")] [Tooltip("Allow grabbing the button directly and pressing a button to release the bolt.")] public bool EnableGrabAndClick = true; private float m_slapCooldownTimer; public override void Awake() { ((FVRInteractiveObject)this).Awake(); if ((Object)(object)Weapon == (Object)null) { Weapon = ((Component)this).GetComponentInParent<ClosedBoltWeapon>(); } if ((Object)(object)SlapNormalTransform == (Object)null) { SlapNormalTransform = ((Component)this).transform; } } private void OnDisable() { m_slapCooldownTimer = 0f; } public override void Poke(FVRViveHand hand) { //IL_00af: 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_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) if ((Object)(object)hand == (Object)null || (Object)(object)Weapon == (Object)null || (Object)(object)Weapon.Bolt == (Object)null || !Weapon.Bolt.IsBoltLocked() || ((Object)(object)((FVRInteractiveObject)Weapon).m_hand != (Object)null && (Object)(object)hand == (Object)(object)((FVRInteractiveObject)Weapon).m_hand) || m_slapCooldownTimer > 0f) { return; } if (EnableSlapDetection) { Vector3 velLinearWorld = hand.Input.VelLinearWorld; if (((Vector3)(ref velLinearWorld)).magnitude < MinSlapSpeed) { return; } if (CheckSlapDirection && (Object)(object)SlapNormalTransform != (Object)null) { Vector3 inwardNormal = GetInwardNormal(); float num = Vector3.Dot(((Vector3)(ref velLinearWorld)).normalized, inwardNormal); if (num < SlapAngleThreshold) { return; } } } ReleaseBoltAction(hand); m_slapCooldownTimer = SlapCooldownDuration; } public override void UpdateInteraction(FVRViveHand hand) { ((FVRInteractiveObject)this).UpdateInteraction(hand); if (EnableGrabAndClick && !((Object)(object)Weapon == (Object)null) && !((Object)(object)Weapon.Bolt == (Object)null) && Weapon.Bolt.IsBoltLocked() && !((Object)(object)hand == (Object)null) && IsReleaseInputPressed(hand)) { ReleaseBoltAction(hand); ((FVRInteractiveObject)this).EndInteraction(hand); } } public override void FVRUpdate() { ((FVRInteractiveObject)this).FVRUpdate(); if (m_slapCooldownTimer > 0f) { m_slapCooldownTimer -= Time.deltaTime; if (m_slapCooldownTimer < 0f) { m_slapCooldownTimer = 0f; } } } private bool IsReleaseInputPressed(FVRViveHand hand) { if ((Object)(object)hand == (Object)null) { return false; } if (hand.IsInStreamlinedMode) { return hand.Input.AXButtonDown || hand.Input.BYButtonDown || hand.Input.TriggerDown; } return hand.Input.TouchpadDown || hand.Input.TriggerDown; } private void ReleaseBoltAction(FVRViveHand hand) { if ((Object)(object)Weapon != (Object)null && (Object)(object)Weapon.Bolt != (Object)null && Weapon.Bolt.IsBoltLocked()) { Weapon.Bolt.ReleaseBolt(); if ((Object)(object)hand != (Object)null && (Object)(object)hand.Buzzer != (Object)null) { hand.Buzz(hand.Buzzer.Buzz_BeginInteraction); } } } private Vector3 GetInwardNormal() { //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_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_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_0069: 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_007a: 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_0090: 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_00a1: 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_00b2: 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_00d3: 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_00c8: 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) if ((Object)(object)SlapNormalTransform == (Object)null) { return Vector3.forward; } return (Vector3)(SlapAxis switch { SlapDirectionAxis.Forward => SlapNormalTransform.forward, SlapDirectionAxis.NegativeForward => -SlapNormalTransform.forward, SlapDirectionAxis.Right => SlapNormalTransform.right, SlapDirectionAxis.NegativeRight => -SlapNormalTransform.right, SlapDirectionAxis.Up => SlapNormalTransform.up, SlapDirectionAxis.NegativeUp => -SlapNormalTransform.up, _ => -SlapNormalTransform.forward, }); } } public class BouncingBetty : PinnedGrenade { [Header("Betty Settings")] public float BounceHeight = 2f; public float ExplosionDelay = 0.5f; public float ArmDelay = 0.4f; [Header("Proximity Settings")] public float ProxRange = 3f; public LayerMask LM_Prox; [Header("Parts")] public GameObject BottomPartToDisable; public AudioEvent LaunchSound; public AudioEvent ArmSound; [Header("Stick Settings")] [Tooltip("Point Z to direction to check. If an layer object is within 0.05m from the raycastdir, it will lock.")] public Transform RaycastDir; public LayerMask StickLayer; [Tooltip("If velocity is below this, it will allow it to lock.")] public float MinStickVelocity = 0.1f; private bool isArmed = false; private bool isSet = false; private bool hasBounced = false; private bool beginCountdown = false; private float timer = 0f; private bool timerReached = false; private bool hasExploded = false; private bool isPinPulled = false; private bool isStuck = false; private bool isLocked = false; private Vector3 stuckNormal; private Transform stuckToSurface; public override void Awake() { ((PinnedGrenade)this).Awake(); base.m_isLeverReleased = true; base.m_isFused = false; base.m_fuseTime = float.MaxValue; base.m_startFuseTime = float.MaxValue; base.FuseOnSpawn = false; if ((Object)(object)base.FakeHandle != (Object)null) { base.FakeHandle.SetActive(false); } if ((Object)(object)base.RealHandle != (Object)null) { base.RealHandle.SetActive(false); } if ((Object)(object)base.LeverJoint != (Object)null) { Object.Destroy((Object)(object)base.LeverJoint); } } public override void FVRUpdate() { //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) ((PinnedGrenade)this).FVRUpdate(); if (base.m_rings.Count > 0) { isPinPulled = true; foreach (PinnedGrenadeRing ring in base.m_rings) { if (!ring.HasPinDetached()) { isPinPulled = false; } } } if (!isPinPulled || isStuck || !((FVRInteractiveObject)this).IsHeld) { } if (isStuck && !beginCountdown && !isArmed) { BeginArming(); } if (beginCountdown && !timerReached) { timer += Time.deltaTime; if (timer >= ArmDelay) { isSet = true; beginCountdown = false; timerReached = true; isArmed = true; } } if (isSet && isArmed && !hasBounced && !hasExploded) { Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, ProxRange, LayerMask.op_Implicit(LM_Prox)); if (array.Length > 0) { hasBounced = true; ((MonoBehaviour)this).StartCoroutine(BounceAndExplode()); } } } public override void OnCollisionEnter(Collision collision) { //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_007f: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (isPinPulled && !isStuck && !((FVRInteractiveObject)this).IsHeld && ((1 << collision.gameObject.layer) & (LayerMask.GetMask(new string[1] { "Default" }) | LayerMask.GetMask(new string[1] { "Environment" }))) != 0) { ContactPoint val = collision.contacts[0]; ((Component)this).transform.position = ((ContactPoint)(ref val)).point; stuckNormal = ((ContactPoint)(ref val)).normal; stuckToSurface = collision.transform; Rigidbody component = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; } isStuck = true; if ((Object)(object)BottomPartToDisable != (Object)null) { BottomPartToDisable.SetActive(false); } } } private void BeginArming() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) beginCountdown = true; timer = 0f; if (ArmSound != null) { SM.PlayCoreSound((FVRPooledAudioType)0, ArmSound, ((Component)this).transform.position); } } private IEnumerator BounceAndExplode() { Rigidbody rb = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)rb == (Object)null) { rb = ((Component)this).gameObject.AddComponent<Rigidbody>(); } rb.isKinematic = false; float bounceVel = Mathf.Sqrt(19.62f * BounceHeight); rb.velocity = Vector3.zero; rb.AddForce(Vector3.up * bounceVel, (ForceMode)2); if (LaunchSound != null) { SM.PlayCoreSound((FVRPooledAudioType)0, LaunchSound, ((Component)this).transform.position); } yield return (object)new WaitForSeconds(ExplosionDelay); TriggerExplosion(); } private void TriggerExplosion() { //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) if (hasExploded) { return; } hasExploded = true; for (int i = 0; i < base.SpawnOnSplode.Count; i++) { GameObject val = Object.Instantiate<GameObject>(base.SpawnOnSplode[i], ((Component)this).transform.position, Quaternion.identity); Explosion component = val.GetComponent<Explosion>(); if ((Object)(object)component != (Object)null) { component.IFF = base.IFF; } ExplosionSound component2 = val.GetComponent<ExplosionSound>(); if ((Object)(object)component2 != (Object)null) { component2.IFF = base.IFF; } GrenadeExplosion component3 = val.GetComponent<GrenadeExplosion>(); if ((Object)(object)component3 != (Object)null) { component3.IFF = base.IFF; } } if ((Object)(object)base.SmokeEmitter != (Object)null) { base.SmokeEmitter.Engaged = true; } Object.Destroy((Object)(object)((Component)this).gameObject); } private void OnDrawGizmosSelected() { //IL_0001: 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) Gizmos.color = Color.red; Gizmos.DrawWireSphere(((Component)this).transform.position, ProxRange); } public override void FVRFixedUpdate() { //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_007e: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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) ((PinnedGrenade)this).FVRFixedUpdate(); base.m_isImpactFuseActive = false; base.m_impactFuseBurnDown = float.MaxValue; Rigidbody component = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null && !isStuck && isPinPulled && !((FVRInteractiveObject)this).IsHeld) { Vector3 velocity = component.velocity; RaycastHit val = default(RaycastHit); if (((Vector3)(ref velocity)).magnitude <= MinStickVelocity && (Object)(object)RaycastDir != (Object)null && Physics.Raycast(RaycastDir.position, RaycastDir.forward, ref val, 2f, LayerMask.op_Implicit(StickLayer))) { isStuck = true; isLocked = true; component.isKinematic = true; component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; ((Component)this).transform.position = ((RaycastHit)(ref val)).point; stuckNormal = ((RaycastHit)(ref val)).normal; stuckToSurface = ((RaycastHit)(ref val)).transform; if ((Object)(object)BottomPartToDisable != (Object)null) { BottomPartToDisable.SetActive(false); } } } if (isLocked && ((FVRInteractiveObject)this).IsHeld) { isLocked = false; if ((Object)(object)component != (Object)null) { component.isKinematic = false; } } } } public class CaltropDispenser : MonoBehaviour { [Tooltip("Enables verbose console logging for debugging.")] public bool EnableDebugLogging = false; [Tooltip("The CaltropHazard prefab to scatter upon explosion.")] public GameObject CaltropPrefab; [Tooltip("Number of caltrops to instantiate and scatter.")] public int CaltropCount = 20; [Tooltip("Minimum ejection speed in meters per second.")] public float MinSpreadSpeed = 3f; [Tooltip("Maximum ejection speed in meters per second.")] public float MaxSpreadSpeed = 7f; [Tooltip("Upward directional bias added to the radial burst trajectory.")] [Range(0f, 1f)] public float UpwardBias = 0.4f; [Tooltip("Rotational tumble velocity applied to each caltrop.")] public float AngularSpinForce = 15f; [Tooltip("Optional audio event played when caltrops burst out.")] public AudioEvent DispenseAudio; private void Start() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_008f: 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_0169: 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_00c8: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_011b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)CaltropPrefab == (Object)null) { Debug.LogError((object)("[CaltropDispenser] CaltropPrefab is not assigned on " + ((Object)((Component)this).gameObject).name)); Object.Destroy((Object)(object)((Component)this).gameObject); return; } if (DispenseAudio != null) { SM.PlayGenericSound(DispenseAudio, ((Component)this).transform.position); } Vector3 val = ((Component)this).transform.position + Vector3.up * 0.1f; for (int i = 0; i < CaltropCount; i++) { GameObject val2 = Object.Instantiate<GameObject>(CaltropPrefab, val, Random.rotation); Rigidbody val3 = val2.GetComponent<Rigidbody>(); if ((Object)(object)val3 == (Object)null) { val3 = val2.GetComponentInChildren<Rigidbody>(); } if ((Object)(object)val3 != (Object)null) { Vector3 insideUnitSphere = Random.insideUnitSphere; insideUnitSphere.y = Mathf.Abs(insideUnitSphere.y) + UpwardBias; Vector3 normalized = ((Vector3)(ref insideUnitSphere)).normalized; float num = Random.Range(MinSpreadSpeed, MaxSpreadSpeed); val3.velocity = normalized * num; val3.angularVelocity = Random.insideUnitSphere * AngularSpinForce; } } if (EnableDebugLogging) { Debug.Log((object)("[CaltropDispenser] Dispensed " + CaltropCount + " caltrops at " + ((object)((Component)this).transform.position/*cast due to .constrained prefix*/).ToString())); } Object.Destroy((Object)(object)((Component)this).gameObject); } } public class CaltropHazard : MonoBehaviour { [Tooltip("Enables verbose console logging for debugging.")] public bool EnableDebugLogging = false; [Tooltip("Minimum flight duration in seconds before the caltrop can damage targets.")] public float ArmDelay = 0.5f; [Tooltip("Radius of the foot detection trigger volume.")] public float TriggerRadius = 0.25f; [Tooltip("Kinetic piercing damage dealt upon contact.")] public float PiercingDamage = 30f; [Tooltip("Whether contact breaks the lower leg joints and forces the Sosig to limp.")] public bool CausesHobble = true; [Tooltip("Whether contact initiates a mustard bleeding spout.")] public bool CausesBleeding = true; [Tooltip("Amount of mustard bleeding inflicted.")] public float BleedAmount = 15f; [Tooltip("Whether the caltrop can also be triggered by and damage the player.")] public bool AffectsPlayer = false; [Tooltip("Audio event played when stepped on.")] public AudioEvent StepAudio; private Rigidbody m_rb; private float m_armTimer; private bool m_isArmed; private bool m_isTriggered; private void Awake() { m_rb = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)m_rb != (Object)null) { m_rb.isKinematic = false; m_rb.useGravity = true; } SphereCollider val = ((Component)this).gameObject.AddComponent<SphereCollider>(); ((Collider)val).isTrigger = true; val.radius = TriggerRadius; m_armTimer = 0f; m_isArmed = false; m_isTriggered = false; } private void Update() { if (m_isArmed) { return; } m_armTimer += Time.deltaTime; if (m_armTimer >= ArmDelay) { m_isArmed = true; if (EnableDebugLogging) { Debug.Log((object)("[CaltropHazard] Hazard armed on " + ((Object)((Component)this).gameObject).name)); } } } private void OnTriggerEnter(Collider other) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 if (!m_isArmed || m_isTriggered) { return; } SosigLink val = null; if ((Object)(object)other.attachedRigidbody