Decompiled source of Hunt1890Calvary v1.0.2
Hunt1890Calvary.dll
Decompiled 2 weeks 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using FistVR; using HarmonyLib; using OtherLoader; using UnityEngine; using UnityEngine.Rendering; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace BitWizrd.Hunt1890Calvary { [BepInPlugin("BitWizrd.Hunt1890Calvary", "Hunt1890Calvary", "1.0.2")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("h3vr.otherloader", "1.3.0")] public class Hunt1890CalvaryPlugin : BaseUnityPlugin { private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; LoadAssets(); } private void LoadAssets() { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "BitWizrd.Hunt1890Calvary"); OtherLoader.RegisterDirectLoad(BasePath, "BitWizrd.Hunt1890Calvary", "", "1890calvary", "", ""); } } } public class BloodBondSR : MonoBehaviour { private void Awake() { string name = "Ammo_69_CashMoney_D100(Clone)"; ((Object)((Component)this).gameObject).name = name; Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Object)((Component)componentsInChildren[i]).gameObject).name = name; } } } namespace BitWizrd.Breech { public class BreechLoadingRifle : FVRFireArm { public enum BreechRifleState { HammerForward, HammerBackBreechClosed, HammerBackBreechOpen } [Header("Base Weapon Params")] public FVRFireArmChamber Chamber; public Transform Trigger; public Vector2 TriggerRots; public Transform Hammer; public Vector2 HammerRots; public Transform EjectPos; [Header("Hammer Settings")] public float hammerCockSpeed = 45f; public float hammerCockDamping = 1.5f; public float hammerReturnSpeed = 60f; public float hammerReturnDamping = 2.5f; public float hammerOvershoot = 4f; public float hammerSnapThreshold = 4f; public float hammerMaxVelocity = 1500f; [Header("Breech Components")] public Transform Breech; public Vector2 BreechRots; [Header("Breech Animation")] public float openDuration = 0.15f; public float closeDuration = 0.18f; public float bounceBaseDuration = 0.3f; public float bounceOvershootMin = 4f; public float bounceOvershootMax = 6f; public float bounceDamping = 3.5f; public float bounceFrequency = 2.8f; [Header("Interaction Settings")] public Transform BreechInteractionPoint; public float BreechInteractionDistance = 0.15f; public bool UseSwipeToInteract = false; public float SwipeInteractionDistance = 0.15f; public float SwipeVelocityThreshold = 1f; public float SwipeAngleThreshold = 60f; [Header("Ejection Settings")] public float forwardMultiplier = 1.2f; public float rightMultiplier = 0.7f; public float upMultiplier = 1.2f; public float ejectForceMultiplier = 2f; public float ejectUnfiredForceMultiplier = 2f; public Vector2 ejectSpinRange = new Vector2(180f, 360f); public bool bypassUnfiredEjection = false; [Header("Trigger Hold Prevention Settings")] public float TriggerBreakThreshold = 0.5f; public float TriggerResetThreshold = 0.3f; private BreechRifleState m_state; private float m_curHammerRot; private float m_tarHammerRot; private float m_triggerVal; private bool m_isPressedDown; private float m_customCurBreechRot; private Coroutine m_breechAnimation; private float m_hammerVelocity; private bool m_triggerWasHeldOnGrab = false; public override void Awake() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) ((FVRFireArm)this).Awake(); base.FChambers.Add(Chamber); base.IsBreachOpenForGasOut = false; m_state = BreechRifleState.HammerForward; m_customCurBreechRot = BreechRots.x; if ((Object)(object)Breech != (Object)null) { Breech.localEulerAngles = new Vector3(m_customCurBreechRot, 0f, 0f); } if ((Object)(object)Hammer != (Object)null) { Hammer.localEulerAngles = new Vector3(HammerRots.x, 0f, 0f); } } public override void BeginInteraction(FVRViveHand hand) { ((FVRFireArm)this).BeginInteraction(hand); m_triggerWasHeldOnGrab = hand.Input.TriggerFloat >= TriggerBreakThreshold; } public override void FVRUpdate() { ((FVRFireArm)this).FVRUpdate(); UpdateHammerPhysics(); UpdateBreechState(); UpdateTriggerVisuals(); } private void UpdateHammerPhysics() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Hammer == (Object)null) { return; } float tarHammerRot = m_tarHammerRot; float curHammerRot = m_curHammerRot; float num = tarHammerRot - curHammerRot; if (Mathf.Abs(num) < hammerSnapThreshold) { m_curHammerRot = tarHammerRot; m_hammerVelocity = 0f; Hammer.localEulerAngles = new Vector3(m_curHammerRot, 0f, 0f); return; } float num2 = 0f; float num3 = 1f; if (m_state == BreechRifleState.HammerBackBreechClosed || m_state == BreechRifleState.HammerBackBreechOpen) { num2 = num * hammerCockSpeed * 3f; num3 = 1f - hammerCockDamping * Time.deltaTime; } else { num2 = num * hammerReturnSpeed * 4f; num3 = 1f - hammerReturnDamping * Time.deltaTime; } m_hammerVelocity += num2 * Time.deltaTime; m_hammerVelocity = Mathf.Clamp(m_hammerVelocity, 0f - hammerMaxVelocity, hammerMaxVelocity); m_hammerVelocity *= Mathf.Clamp01(num3); m_curHammerRot += m_hammerVelocity * Time.deltaTime * 2f; if ((m_state == BreechRifleState.HammerBackBreechClosed || m_state == BreechRifleState.HammerBackBreechOpen) && m_curHammerRot >= HammerRots.y + hammerOvershoot) { m_tarHammerRot = HammerRots.y; } Hammer.localEulerAngles = new Vector3(m_curHammerRot, 0f, 0f); } private void UpdateBreechState() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Breech != (Object)null) { Breech.localEulerAngles = new Vector3(m_customCurBreechRot, 0f, 0f); } } private void UpdateTriggerVisuals() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Trigger != (Object)null) { float num = Mathf.Lerp(TriggerRots.x, TriggerRots.y, m_triggerVal); Trigger.localEulerAngles = new Vector3(num, 0f, 0f); } } public override void UpdateInteraction(FVRViveHand hand) { m_triggerVal = hand.Input.TriggerFloat; if (m_triggerVal < TriggerResetThreshold) { m_triggerWasHeldOnGrab = false; } HandleInputControls(hand); HandleHammerRelease(hand); HandleSwipeInteractions(hand); } private void HandleInputControls(FVRViveHand hand) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.IsInStreamlinedMode) { if (hand.Input.BYButtonDown) { ClickUpward(); } if (hand.Input.AXButtonDown) { ClickDownward(); } } else if (hand.Input.TouchpadDown) { if (touchpadAxes.y > 0f) { ClickUpward(); } else { ClickDownward(); } } } private void HandleHammerRelease(FVRViveHand hand) { if (m_state == BreechRifleState.HammerBackBreechClosed && !((FVRPhysicalObject)this).IsAltHeld && hand.Input.TriggerDown && !m_triggerWasHeldOnGrab) { m_isPressedDown = false; DropHammer(); m_state = BreechRifleState.HammerForward; } } private void HandleSwipeInteractions(FVRViveHand hand) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) if (!UseSwipeToInteract || (Object)(object)hand.OtherHand == (Object)null || !((FVRInteractiveObject)this).IsHeld || (Object)(object)((FVRPhysicalObject)this).AltGrip != (Object)null || ((FVRFireArm)this).IsTwoHandStabilized()) { return; } FVRViveHand otherHand = hand.OtherHand; Vector3 velLinearWorld = otherHand.Input.VelLinearWorld; float num = Vector3.Distance(BreechInteractionPoint.position, otherHand.PalmTransform.position); if (num > SwipeInteractionDistance || ((Vector3)(ref velLinearWorld)).magnitude <= SwipeVelocityThreshold) { return; } float num2 = Vector3.Angle(velLinearWorld, -((Component)this).transform.forward); float num3 = Vector3.Angle(velLinearWorld, ((Component)this).transform.forward); if (num2 < SwipeAngleThreshold) { if (m_state == BreechRifleState.HammerForward) { CockHammerAction(); } else if (m_state == BreechRifleState.HammerBackBreechOpen) { CloseBreechAction(); } } else if (num3 < SwipeAngleThreshold && m_state == BreechRifleState.HammerBackBreechClosed) { OpenBreechAction(); } } private void CockHammerAction() { CockHammer(); m_state = BreechRifleState.HammerBackBreechClosed; } private void CloseBreechAction() { CloseCustomBreech(); m_state = BreechRifleState.HammerBackBreechClosed; } private void OpenBreechAction() { OpenCustomBreech(); m_state = BreechRifleState.HammerBackBreechOpen; } private void ClickUpward() { switch (m_state) { case BreechRifleState.HammerBackBreechClosed: m_state = BreechRifleState.HammerForward; DecockHammer(); break; case BreechRifleState.HammerBackBreechOpen: m_state = BreechRifleState.HammerBackBreechClosed; CloseCustomBreech(); break; } } private void ClickDownward() { switch (m_state) { case BreechRifleState.HammerForward: CockHammer(); m_state = BreechRifleState.HammerBackBreechClosed; break; case BreechRifleState.HammerBackBreechClosed: OpenCustomBreech(); m_state = BreechRifleState.HammerBackBreechOpen; break; } } private void CockHammer() { m_tarHammerRot = HammerRots.y + hammerOvershoot; m_hammerVelocity = 0f; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)7, 1f); } private void DecockHammer() { m_tarHammerRot = HammerRots.x; m_hammerVelocity = 0f; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f); } private void DropHammer() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) m_curHammerRot = HammerRots.x; m_tarHammerRot = HammerRots.x; m_hammerVelocity = 0f; if ((Object)(object)Hammer != (Object)null) { Hammer.localEulerAngles = new Vector3(m_curHammerRot, 0f, 0f); } ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f); if ((Object)(object)Chamber != (Object)null && Chamber.IsFull) { Fire(); } } private void OpenCustomBreech() { if (m_breechAnimation != null) { ((MonoBehaviour)this).StopCoroutine(m_breechAnimation); } m_breechAnimation = ((MonoBehaviour)this).StartCoroutine(AnimateBreechOpen()); ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)17, 1f); if ((Object)(object)Chamber != (Object)null && Chamber.IsFull) { EjectRound(); } base.IsBreachOpenForGasOut = true; Chamber.IsAccessible = true; } private void CloseCustomBreech() { if (m_breechAnimation != null) { ((MonoBehaviour)this).StopCoroutine(m_breechAnimation); } m_breechAnimation = ((MonoBehaviour)this).StartCoroutine(AnimateBreechClose()); ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)18, 1f); base.IsBreachOpenForGasOut = false; Chamber.IsAccessible = false; } private IEnumerator AnimateBreechOpen() { float elapsed = 0f; float startAngle = m_customCurBreechRot; float openAngle = BreechRots.y; while (elapsed < openDuration) { elapsed += Time.deltaTime; m_customCurBreechRot = Mathf.Lerp(startAngle, openAngle, elapsed / openDuration); yield return null; } m_customCurBreechRot = openAngle; float bounceTimer = 0f; float amplitude = Random.Range(bounceOvershootMin, bounceOvershootMax); float naturalFreq = bounceFrequency * (float)Math.PI * 2f; float damping = bounceDamping * 0.5f; float velocity = amplitude * naturalFreq; float position = 0f; while (bounceTimer < bounceBaseDuration) { bounceTimer += Time.deltaTime; float acceleration = (0f - naturalFreq) * naturalFreq * position - damping * velocity; velocity += acceleration * Time.deltaTime; position += velocity * Time.deltaTime; m_customCurBreechRot = openAngle + position * Mathf.Exp((0f - bounceDamping) * bounceTimer); if (Mathf.Abs(position) < 0.5f && velocity < 5f && bounceTimer > bounceBaseDuration * 0.3f) { break; } yield return null; } m_customCurBreechRot = openAngle; m_breechAnimation = null; } private IEnumerator AnimateBreechClose() { float elapsed = 0f; float startAngle = m_customCurBreechRot; float closeAngle = BreechRots.x; while (elapsed < closeDuration) { elapsed += Time.deltaTime; m_customCurBreechRot = Mathf.Lerp(startAngle, closeAngle, elapsed / closeDuration); yield return null; } m_customCurBreechRot = closeAngle; m_breechAnimation = null; } private void Fire() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (Chamber.Fire()) { ((FVRFireArm)this).Fire(Chamber, ((FVRFireArm)this).GetMuzzle(), 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(Chamber.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f); } } public override List<FireArmRoundClass> GetChamberRoundList() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) object result; if (Chamber.IsFull && !Chamber.IsSpent) { List<FireArmRoundClass> list = new List<FireArmRoundClass>(); list.Add(Chamber.GetRound().RoundClass); result = list; } else { result = null; } return (List<FireArmRoundClass>)result; } public override void SetLoadedChambers(List<FireArmRoundClass> rounds) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (rounds.Count > 0) { Chamber.Autochamber(rounds[0]); } } private void EjectRound() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Chamber == (Object)null) && Chamber.IsFull && (Chamber.IsSpent || !bypassUnfiredEjection)) { Vector3 val = ((Component)this).transform.forward * forwardMultiplier + ((Component)this).transform.right * rightMultiplier + ((Component)this).transform.up * upMultiplier; Vector3 normalized = ((Vector3)(ref val)).normalized; float num = ((!Chamber.IsSpent) ? ejectUnfiredForceMultiplier : ejectForceMultiplier); Chamber.EjectRound(((Component)this).transform.position, normalized * num, new Vector3(0f, 0f, Random.Range(ejectSpinRange.x, ejectSpinRange.y)), false); ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)29, 1f); } } } } public class ComponentActivateRandomRuntime : MonoBehaviour { public float Probability; public int Group; public float SelectionStart; [NonSerialized] private bool rollResolved; [NonSerialized] private float sharedRoll; private void Awake() { if (Probability >= 1f) { return; } bool flag; if (Group != 0) { if (!rollResolved) { ResolveGroupRollsForRoot(); } flag = sharedRoll >= SelectionStart && sharedRoll <= SelectionStart + Probability; } else { flag = Random.value <= Probability; } if (!flag) { ((Component)this).gameObject.SetActive(false); } } private void ResolveGroupRollsForRoot() { ComponentActivateRandomRuntime[] componentsInChildren = ((Component)((Component)this).transform.root).GetComponentsInChildren<ComponentActivateRandomRuntime>(true); Dictionary<int, float> dictionary = new Dictionary<int, float>(); foreach (ComponentActivateRandomRuntime componentActivateRandomRuntime in componentsInChildren) { if (componentActivateRandomRuntime.Group != 0 && !componentActivateRandomRuntime.rollResolved) { if (!dictionary.TryGetValue(componentActivateRandomRuntime.Group, out var value)) { value = Random.value; dictionary[componentActivateRandomRuntime.Group] = value; } componentActivateRandomRuntime.sharedRoll = value; componentActivateRandomRuntime.rollResolved = true; } } } } public class CooldownSound : MonoBehaviour { public ClosedBoltWeapon weapon; public AudioClip[] audioClips; public float volume = 1f; public int minShots = 5; public int maxShots = 10; public float minDelay = 0.5f; public float maxDelay = 2f; public float resetTime = 1.5f; private AudioSource audioSource; private int shotCounter = 0; private float lastShotTime; private bool lastRoundSpent; private int nextShotThreshold; private bool isPlayingSound = false; private void Start() { if ((Object)(object)weapon == (Object)null) { weapon = ((Component)this).GetComponent<ClosedBoltWeapon>(); } if ((Object)(object)weapon == (Object)null) { Debug.LogError((object)"CooldownSound: Weapon reference is missing. Attach this script to a ClosedBoltWeapon."); return; } audioSource = ((Component)weapon).gameObject.GetComponent<AudioSource>(); if ((Object)(object)audioSource == (Object)null) { audioSource = ((Component)weapon).gameObject.AddComponent<AudioSource>(); } audioSource.spatialBlend = 1f; audioSource.playOnAwake = false; audioSource.rolloffMode = (AudioRolloffMode)0; lastRoundSpent = weapon.Chamber.IsSpent; SetNewShotThreshold(); } private void Update() { DetectFiring(); } private void DetectFiring() { if (weapon.Chamber.IsFull && weapon.Chamber.IsSpent && !lastRoundSpent) { OnWeaponFired(); } lastRoundSpent = weapon.Chamber.IsSpent; } private void OnWeaponFired() { float num = Time.time - lastShotTime; if (num > resetTime) { shotCounter = 0; SetNewShotThreshold(); } shotCounter++; lastShotTime = Time.time; if (shotCounter >= nextShotThreshold) { ((MonoBehaviour)this).StartCoroutine(PlaySoundWithDelay()); shotCounter = 0; SetNewShotThreshold(); } } private IEnumerator PlaySoundWithDelay() { if (!isPlayingSound) { isPlayingSound = true; float delay = Random.Range(minDelay, maxDelay); yield return (object)new WaitForSeconds(delay); if (audioClips.Length > 0) { int index = Random.Range(0, audioClips.Length); audioSource.clip = audioClips[index]; audioSource.PlayOneShot(audioSource.clip, volume); yield return (object)new WaitForSeconds(audioSource.clip.length); } isPlayingSound = false; } } private void SetNewShotThreshold() { nextShotThreshold = Random.Range(minShots, maxShots + 1); } } [ExecuteInEditMode] public class CryErosionDriver : MonoBehaviour { private static readonly int ErosionValueId = Shader.PropertyToID("_ErosionValue"); [Range(0f, 1f)] public float Burn = 0f; public Renderer[] Renderers; public bool HideWhenGone = true; private MaterialPropertyBlock _block; private float _burnRate; private float _lastApplied = -1f; public void BurnOver(float seconds) { _burnRate = ((!(seconds > 0.0001f)) ? 0f : ((1f - Burn) / seconds)); if (_burnRate <= 0f) { Burn = 1f; } } public void Restore() { _burnRate = 0f; Burn = 0f; Apply(force: true); } private void LateUpdate() { if (_burnRate > 0f && Application.isPlaying) { Burn = Mathf.Min(1f, Burn + _burnRate * Time.deltaTime); if (Burn >= 1f) { _burnRate = 0f; } } Apply(force: false); } private void OnValidate() { Apply(force: true); } private void Apply(bool force) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown float num = Mathf.Clamp01(Burn); if (!force && Mathf.Approximately(num, _lastApplied)) { return; } _lastApplied = num; if (Renderers == null || Renderers.Length == 0) { Renderers = ((Component)this).GetComponentsInChildren<Renderer>(true); } if (_block == null) { _block = new MaterialPropertyBlock(); } bool flag = HideWhenGone && num >= 1f; for (int i = 0; i < Renderers.Length; i++) { Renderer val = Renderers[i]; if (!((Object)(object)val == (Object)null)) { val.GetPropertyBlock(_block); _block.SetFloat(ErosionValueId, 1f - num); val.SetPropertyBlock(_block); if (HideWhenGone) { val.enabled = !flag; } } } } } public class CustomWaggleJoint : MonoBehaviour { public float distanceLimit = 0.25f; public float angleLimitLeft = 45f; public float angleLimitRight = 45f; public float gravityScale = 1f; public bool useSpring; public float springApproachRate = 0.95f; public float damping; public Transform hingeGraphic; public Vector3 hingeGraphicRotationOffset; public bool invertWaggleAxis; public bool ManualExecution; public float onHitLimitCooldown = 0.05f; public Vector3 waggleAxis = Vector3.up; public Vector3 rotationAxis = Vector3.up; [Header("Gizmo Options")] public bool debugGizmos = false; public bool showRotationExtremes = false; public bool showRotationDirectionArrows = false; private Vector3 particlePos; private Vector3 particleVel; private bool leftCatchState; private bool rightCatchState; private float lastTouchTime = float.MinValue; private Vector3 EffectiveWaggleDir() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.TransformDirection((!invertWaggleAxis) ? waggleAxis : (-waggleAxis)); } private void GetEffectiveAngleLimits(out float effectiveAngleMin, out float effectiveAngleMax) { if (invertWaggleAxis) { effectiveAngleMin = 0f - angleLimitLeft; effectiveAngleMax = angleLimitRight; } else { effectiveAngleMin = 0f - angleLimitRight; effectiveAngleMax = angleLimitLeft; } } public void ResetParticlePos() { //IL_0008: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) particlePos = ((Component)this).transform.position + EffectiveWaggleDir() * distanceLimit; particleVel = Vector3.zero; } private void OnHitLimit(float angularVelocity) { } public void Execute() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0090: 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_0094: 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_00be: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; Transform transform = ((Component)this).transform; Vector3 val = Physics.gravity * gravityScale; Vector3 val2 = particlePos; Vector3 val3 = particleVel * Mathf.Pow(1f - damping, deltaTime) + val * deltaTime; Vector3 val4 = val2 + val3 * deltaTime; Vector3 val5 = transform.TransformDirection(((Vector3)(ref rotationAxis)).normalized); Vector3 val6 = EffectiveWaggleDir(); Vector3 position = transform.position; if (useSpring) { val4 = Vector3.Lerp(val4, position + val6 * distanceLimit, 1f - Mathf.Pow(1f - springApproachRate, deltaTime)); } GetEffectiveAngleLimits(out var effectiveAngleMin, out var effectiveAngleMax); particlePos = ProjectOnHinge(val4, position, val5, val6, distanceLimit, effectiveAngleMin, effectiveAngleMax); particleVel = (particlePos - val2) / deltaTime; if ((Object)(object)hingeGraphic != (Object)null) { hingeGraphic.rotation = Quaternion.LookRotation(particlePos - transform.position, val5) * Quaternion.Euler(hingeGraphicRotationOffset); } } private Vector3 ProjectOnHinge(Vector3 point, Vector3 hingePivot, Vector3 hingeAxis, Vector3 hingeDirection, float distanceLimit, float angleMin, float angleMax) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_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_0021: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //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_003b: Unknown result type (might be due to invalid IL or missing references) float num = ToHingeAngle(point, hingePivot, hingeAxis, hingeDirection); num = Mathf.Clamp(num, angleMin, angleMax); Vector3 val = Quaternion.AngleAxis(num, hingeAxis) * hingeDirection; return val * distanceLimit + hingePivot; } private float ToHingeAngle(Vector3 point, Vector3 hingePivot, Vector3 hingeAxis, Vector3 hingeDirection) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point - hingePivot; Vector3 val2 = Vector3.ProjectOnPlane(val, hingeAxis); Vector3 normalized = ((Vector3)(ref val2)).normalized; return SignedAngle(hingeDirection, normalized, hingeAxis); } private float SignedAngle(Vector3 from, Vector3 to, Vector3 axis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Angle(from, to); return num * Mathf.Sign(Vector3.Dot(axis, Vector3.Cross(from, to))); } private void Start() { ResetParticlePos(); } private void Update() { if (!ManualExecution) { Execute(); } } } namespace BitWizrd.Breech { [RequireComponent(typeof(FVRFireArm))] public class EyeReliefAutoStock : MonoBehaviour { private enum SightState { OnScope, Outside, Unavailable } [Header("References (auto-detected if null)")] public FVRFireArm Firearm; public PIPScope Scope; [Tooltip("Optional. Used for the flip-cap state and external-zero rigs.")] public PIPScopeController ScopeController; [Header("Eye Relief")] [Tooltip("Offset from the scope's own ideal eye point. + holds the eye further back. Meters.")] public float ManualTrim = 0f; [Header("Authority (meters of stock-length change)")] [Tooltip("How much the stock may lengthen (pushes gun AWAY from face).")] public float MaxLengthen = 0.07f; [Tooltip("How much the stock may shorten (pulls gun TOWARD face).")] public float MaxShorten = 0.07f; [Header("Gating")] public bool RequireShouldered = true; public float ShoulderEngageDist = 0.25f; [Tooltip("Disengage only beyond this StockDist (hysteresis at the shoulder boundary).")] public float ShoulderReleaseDist = 0.32f; [Tooltip("Max angle between head forward and the scope axis. Degrees.")] public float AimAngleLimit = 25f; [Tooltip("Max eye distance from the scope axis. Meters.")] public float LateralLimit = 0.06f; [Tooltip("Max eye distance from the ideal eye point along the axis to count as looking through the scope. Must cover the uncorrected error. Meters.")] public float SightDistanceWindow = 0.15f; public bool DisableWhenBipod = true; [Tooltip("Once the eye is outside the sight limits, how much further (lateral / along the axis) before the correction has fully faded out. Meters.")] public float ReleaseDistance = 0.1f; [Tooltip("Once the head is past Aim Angle Limit, how many more degrees before the correction has fully faded out.")] public float ReleaseAngle = 20f; [Header("Smoothing")] [Tooltip("Approximate time to settle into eye relief. The approach accelerates and decelerates smoothly (critically damped), so it is quick but never a hard snap. Lower = snappier. Seconds.")] public float CorrectTime = 0.12f; [Tooltip("Speed cap on the approach into eye relief. Meters per second.")] public float CorrectRate = 2f; [Tooltip("Release speed per unit of head speed. 1 = the gun keeps pace with the head leaving the scope.")] public float HeadSpeedGain = 1f; [Tooltip("Head speed smoothing time constant. Seconds.")] public float HeadSpeedSmoothing = 0.05f; [Tooltip("Release speed with a still head. Meters per second.")] public float MinReleaseRate = 0.08f; [Tooltip("Speed cap when zooming out (looking away or lowering the gun). Meters per second.")] public float ReleaseRate = 1f; [Tooltip("Hold correction still this long after a recoil kick is seen.")] public float RecoilFreezeTime = 0.15f; public float RecoilKickThreshold = 0.004f; [Header("Debug")] public bool LogToConsole = false; public float LogInterval = 1f; [NonSerialized] public float CurrentAxialError; [NonSerialized] public float CurrentLateral; [NonSerialized] public float CurrentAdjust; [NonSerialized] public bool IsEngaged; [NonSerialized] public float CurrentHeadSpeed; [NonSerialized] public float CurrentFade; private Vector3 m_baseStockLocalPos; private bool m_hasBase; private float m_curAdjust; private float m_adjustVel; private float m_heldAdjust; private Vector3 m_lastOnScopeEyeRig; private float m_lastOnScopeBehind; private bool m_hasOnScopeRef; private float m_freezeUntil; private float m_resolveTimer; private float m_logTimer; private bool m_shoulderLatch; private Vector3 m_lastHeadRigPos; private bool m_hasHeadSample; public void Awake() { if ((Object)(object)Firearm == (Object)null) { Firearm = ((Component)this).GetComponent<FVRFireArm>(); } m_freezeUntil = -10f; } public void OnEnable() { CacheBaseStock(); } public void OnDisable() { RestoreBaseStock(); } private void CacheBaseStock() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!m_hasBase && (Object)(object)Firearm != (Object)null && (Object)(object)Firearm.StockPos != (Object)null) { m_baseStockLocalPos = Firearm.StockPos.localPosition; m_hasBase = true; } } private void RestoreBaseStock() { m_curAdjust = 0f; m_heldAdjust = 0f; m_adjustVel = 0f; m_hasOnScopeRef = false; ApplyAdjust(); IsEngaged = false; m_shoulderLatch = false; } public void FixedUpdate() { float fixedDeltaTime = Time.fixedDeltaTime; if ((Object)(object)Firearm == (Object)null || !m_hasBase) { if ((Object)(object)Firearm == (Object)null) { Firearm = ((Component)this).GetComponent<FVRFireArm>(); } CacheBaseStock(); if (!m_hasBase) { return; } } if (!IsVirtualStockAvailable()) { m_hasHeadSample = false; MoveTo(0f, ReleaseRate, fixedDeltaTime); m_heldAdjust = m_curAdjust; m_hasOnScopeRef = false; IsEngaged = false; return; } m_resolveTimer -= fixedDeltaTime; if ((Object)(object)Scope == (Object)null && m_resolveTimer <= 0f) { m_resolveTimer = 1f; ResolveScope(); } Transform eyeTransform = GetEyeTransform(); UpdateHeadSpeed(eyeTransform, fixedDeltaTime); float axialError = 0f; float outside = 1f; SightState sightState = ((!((Object)(object)eyeTransform != (Object)null)) ? SightState.Unavailable : EvaluateSight(eyeTransform, out axialError, out outside)); bool flag = sightState == SightState.OnScope; if (Mathf.Abs(Firearm.m_recoilLinearZ) > RecoilKickThreshold) { m_freezeUntil = Time.time + RecoilFreezeTime; } IsEngaged = flag; if (Time.time < m_freezeUntil) { m_adjustVel = 0f; return; } if (flag) { float num = Mathf.Clamp(m_curAdjust + axialError, 0f - MaxLengthen, MaxShorten); m_curAdjust = Mathf.SmoothDamp(m_curAdjust, num, ref m_adjustVel, Mathf.Max(0.01f, CorrectTime), CorrectRate, fixedDeltaTime); ApplyAdjust(); m_heldAdjust = m_curAdjust; CurrentFade = 0f; } else if (sightState == SightState.Outside) { float num2 = (CurrentFade = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(outside))); MoveTo(m_heldAdjust * (1f - num2), HeadPacedRate(MinReleaseRate, ReleaseRate), fixedDeltaTime); } else { CurrentFade = 1f; MoveTo(0f, HeadPacedRate(MinReleaseRate, ReleaseRate), fixedDeltaTime); m_heldAdjust = m_curAdjust; m_hasOnScopeRef = false; } if (LogToConsole) { m_logTimer -= fixedDeltaTime; if (m_logTimer <= 0f) { m_logTimer = LogInterval; Debug.Log((object)string.Concat("[EyeRelief] state=", sightState, " fade=", CurrentFade.ToString("F2"), " axialErr=", CurrentAxialError.ToString("F3"), " lat=", CurrentLateral.ToString("F3"), " relief=", (!((Object)(object)Scope != (Object)null)) ? "-" : Scope.eyeReliefOcular.ToString("F3"), " adj=", m_curAdjust.ToString("F3"), " headSpd=", CurrentHeadSpeed.ToString("F2"))); } } } private bool IsVirtualStockAvailable() { if ((Object)(object)Firearm.StockPos == (Object)null || !Firearm.HasActiveShoulderStock) { return false; } if ((Object)(object)GM.CurrentPlayerBody == (Object)null || GM.Options == null || GM.Options.ControlOptions == null) { return false; } ControlOptions controlOptions = GM.Options.ControlOptions; return controlOptions.UseVirtualStock && !controlOptions.UseGunRigMode2; } private void UpdateHeadSpeed(Transform eye, float dt) { //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0047: 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_005e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)eye == (Object)null) { m_hasHeadSample = false; return; } Vector3 val = ((Component)GM.CurrentPlayerBody).transform.InverseTransformPoint(eye.position); float num; if (m_hasHeadSample) { Vector3 val2 = val - m_lastHeadRigPos; num = ((Vector3)(ref val2)).magnitude / dt; } else { num = 0f; } float num2 = num; m_lastHeadRigPos = val; m_hasHeadSample = true; float num3 = 1f - Mathf.Exp((0f - dt) / Mathf.Max(0.001f, HeadSpeedSmoothing)); CurrentHeadSpeed = Mathf.Lerp(CurrentHeadSpeed, num2, num3); } private float HeadPacedRate(float min, float max) { return Mathf.Clamp(min + CurrentHeadSpeed * HeadSpeedGain, min, Mathf.Max(min, max)); } private void MoveTo(float target, float rate, float dt) { m_adjustVel = 0f; m_curAdjust = Mathf.MoveTowards(m_curAdjust, target, rate * dt); ApplyAdjust(); } private void ApplyAdjust() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (m_hasBase && (Object)(object)Firearm != (Object)null && (Object)(object)Firearm.StockPos != (Object)null) { Firearm.StockPos.localPosition = m_baseStockLocalPos + new Vector3(0f, 0f, m_curAdjust); } CurrentAdjust = m_curAdjust; } private Transform GetEyeTransform() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) FVRPlayerBody currentPlayerBody = GM.CurrentPlayerBody; if ((int)GM.Options.ControlOptions.HandFiltering != 0 && (Object)(object)currentPlayerBody.FilteredHead != (Object)null) { return currentPlayerBody.FilteredHead; } return currentPlayerBody.Head; } private void ResolveScope() { PIPScope[] componentsInChildren = ((Component)Firearm).GetComponentsInChildren<PIPScope>(); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && !componentsInChildren[i].isDecorative) { Scope = componentsInChildren[i]; break; } } if (!((Object)(object)Scope != (Object)null) || !((Object)(object)ScopeController == (Object)null)) { return; } PIPScopeController[] componentsInChildren2 = ((Component)Firearm).GetComponentsInChildren<PIPScopeController>(); for (int j = 0; j < componentsInChildren2.Length; j++) { if ((Object)(object)componentsInChildren2[j] != (Object)null && (Object)(object)componentsInChildren2[j].PScope == (Object)(object)Scope) { ScopeController = componentsInChildren2[j]; break; } } } private SightState EvaluateSight(Transform eye, out float axialError, out float outside) { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) axialError = 0f; outside = 1f; if (!((FVRInteractiveObject)Firearm).IsHeld || ((FVRPhysicalObject)Firearm).IsPivotLocked) { return SightState.Unavailable; } FVRAlternateGrip altGrip = ((FVRPhysicalObject)Firearm).AltGrip; if ((Object)(object)altGrip == (Object)null || !altGrip.FunctionalityEnabled) { return SightState.Unavailable; } if (DisableWhenBipod && (Object)(object)((FVRPhysicalObject)Firearm).Bipod != (Object)null && ((FVRPhysicalObject)Firearm).Bipod.IsBipodActive) { return SightState.Unavailable; } if ((Object)(object)Scope == (Object)null) { return SightState.Unavailable; } if (!((Component)Scope).transform.IsChildOf(((Component)Firearm).transform) && !HasExternalZero()) { Scope = null; ScopeController = null; return SightState.Unavailable; } if (!((Behaviour)Scope).isActiveAndEnabled || Scope.eyeReliefOcular <= 0f) { return SightState.Unavailable; } if ((Object)(object)ScopeController != (Object)null && (Object)(object)ScopeController.FlipTransform != (Object)null && ScopeController.Flipped == 1) { return SightState.Unavailable; } if (RequireShouldered && !IsShoulderLatched()) { return SightState.Unavailable; } Vector3 forward = ((Component)Scope).transform.forward; float num = Vector3.Angle(eye.forward, forward); Vector3 val = Scope.GetWorldEyeReliefPosition() - forward * ManualTrim; Vector3 val2 = eye.position - val; float num2 = 0f - Vector3.Dot(val2, forward); Vector3 val3 = val2 + forward * num2; float magnitude = ((Vector3)(ref val3)).magnitude; CurrentAxialError = num2; CurrentLateral = magnitude; Transform transform = ((Component)GM.CurrentPlayerBody).transform; Vector3 val4 = transform.InverseTransformPoint(eye.position); float behindReading; if (m_hasOnScopeRef) { Vector3 val5 = transform.InverseTransformDirection(forward); behindReading = m_lastOnScopeBehind - Vector3.Dot(val4 - m_lastOnScopeEyeRig, val5); } else { behindReading = num2 - (m_heldAdjust - m_curAdjust); } float num3 = Mathf.Max(0.001f, ReleaseDistance); float num4 = Mathf.Max(0f, num - AimAngleLimit) / Mathf.Max(0.001f, ReleaseAngle); float num5 = Mathf.Max(0f, magnitude - LateralLimit) / num3; float num6 = Mathf.Min(AxialOutside(num2, num3), AxialOutside(behindReading, num3)); outside = Mathf.Max(Mathf.Max(num4, num5), num6); if (outside > 0f) { return SightState.Outside; } axialError = num2; m_lastOnScopeEyeRig = val4; m_lastOnScopeBehind = num2; m_hasOnScopeRef = true; return SightState.OnScope; } private float AxialOutside(float behindReading, float dist) { float num = Scope.eyeReliefOcular + ManualTrim; float num2 = Mathf.Max(0f, Mathf.Abs(behindReading) - SightDistanceWindow); float num3 = Mathf.Max(0f, 0f - num - behindReading); return Mathf.Max(num2, num3) / dist; } private bool IsShoulderLatched() { if (Firearm.IsShoulderStabilized() || Firearm.StockDist <= ShoulderEngageDist) { m_shoulderLatch = true; } else if (Firearm.StockDist > ShoulderReleaseDist) { m_shoulderLatch = false; } return m_shoulderLatch; } private bool HasExternalZero() { return (Object)(object)ScopeController != (Object)null && ((Object)(object)ScopeController.OverrideFireArm != (Object)null || (Object)(object)ScopeController.OverrideMuzzle != (Object)null); } } } public class FireLightFlicker : MonoBehaviour { public Light Light; public float BaseIntensity = 1f; public float FlickerMin = 1f; public float FlickerMax = 1f; public float FlickerSpeed = 1f; private float noiseOffset; private void Awake() { if ((Object)(object)Light == (Object)null) { Light = ((Component)this).GetComponent<Light>(); } noiseOffset = Random.value * 1000f; } private void Update() { if (!((Object)(object)Light == (Object)null)) { float num = Mathf.PerlinNoise(Time.time * FlickerSpeed + noiseOffset, 0f); Light.intensity = BaseIntensity * Mathf.Lerp(FlickerMin, FlickerMax, num); } } } public class GunStockLace : MonoBehaviour { public float length = 0.5f; public float gravity = 9.81f; public float damping = 0.05f; public float maxDeviationAngle = 45f; public LayerMask collisionMask; public bool showGizmos = false; private Vector3 pendulumDirection; private Vector3 angularVelocity; private Quaternion baseRotation; private Vector3 restDirection; private Vector3 previousPosition; private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) baseRotation = ((Component)this).transform.rotation; restDirection = baseRotation * -Vector3.up; pendulumDirection = restDirection; previousPosition = ((Component)this).transform.position; } private void FixedUpdate() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position - previousPosition; previousPosition = ((Component)this).transform.position; float fixedDeltaTime = Time.fixedDeltaTime; Vector3 val2 = Vector3.Cross(((Vector3)(ref pendulumDirection)).normalized, Vector3.down) * gravity / length; Vector3 val3 = val * 10f / fixedDeltaTime; angularVelocity += (val2 + val3) * fixedDeltaTime; angularVelocity *= Mathf.Clamp01(1f - damping * fixedDeltaTime); Quaternion val4 = Quaternion.Euler(angularVelocity * fixedDeltaTime * 57.29578f); pendulumDirection = val4 * pendulumDirection; HandleCollisionLimits(); ClampToMaxAngle(); ((Component)this).transform.rotation = Quaternion.FromToRotation(-Vector3.up, pendulumDirection) * baseRotation; } private void HandleCollisionLimits() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //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_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_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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(((Component)this).transform.position, pendulumDirection, ref val, length, LayerMask.op_Implicit(collisionMask))) { Vector3 normal = ((RaycastHit)(ref val)).normal; Vector3 val2 = Vector3.ProjectOnPlane(pendulumDirection, normal); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Vector3.Angle(pendulumDirection, normalized); pendulumDirection = Vector3.RotateTowards(pendulumDirection, normalized, num * ((float)Math.PI / 180f), 0f); angularVelocity = Vector3.ProjectOnPlane(angularVelocity, normal); } } private void ClampToMaxAngle() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_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) float num = Vector3.Angle(restDirection, pendulumDirection); if (num > maxDeviationAngle) { pendulumDirection = Vector3.RotateTowards(restDirection, pendulumDirection, maxDeviationAngle * ((float)Math.PI / 180f), 0f); angularVelocity *= 0.5f; } } private void OnDrawGizmos() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (showGizmos) { Gizmos.color = Color.yellow; Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + pendulumDirection * length); Gizmos.color = Color.red; Gizmos.DrawWireSphere(((Component)this).transform.position + pendulumDirection * length, 0.02f); } } } public class HuntDollarSR : MonoBehaviour { private IEnumerator Start() { yield return (object)new WaitForSeconds(3f); string str = "CharcoalBriquette(Clone)"; ((Object)((Component)this).gameObject).name = str; Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Component val = (Component)(object)componentsInChildren[i]; ((Object)val.gameObject).name = str; } } } namespace BitWizrd.Breech { public class LoadingBox : MonoBehaviour { public Transform LoadingGateObject; public Vector3 StartRotation = Vector3.zero; public Vector3 EndRotation; private float curRot; private float tarRot; public float Range = 0.02f; [Header("Animation")] public float OpenCloseSpeed = 2f; [Header("Physical Toggle")] public bool AllowPhysicalToggle = false; public float ToggleRange = 0.05f; private bool isHandInRange = false; private bool wasHandInRange = false; [Header("Audio")] public FVRFireArm FireArm; private bool isOpen = false; private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) LoadingGateObject.localEulerAngles = StartRotation; } private void Update() { //IL_017c: Unknown result type (might be due to invalid IL or missing references) if (AllowPhysicalToggle) { CheckForHandToggle(); } else { CheckForBulletProximity(); } float num = curRot; float num2 = OpenCloseSpeed * 2f * Time.deltaTime; if (curRot != tarRot) { curRot = Mathf.MoveTowards(curRot, tarRot, num2); } if (num < 0.1f && curRot >= 0.1f && !isOpen) { if ((Object)(object)FireArm != (Object)null) { FireArm.PlayAudioEvent((FirearmAudioEventType)23, 1f); } isOpen = true; } else if (num > 0.9f && curRot <= 0.9f && isOpen) { if ((Object)(object)FireArm != (Object)null) { FireArm.PlayAudioEvent((FirearmAudioEventType)24, 1f); } isOpen = false; } LoadingGateObject.localEulerAngles = new Vector3(Mathf.Lerp(StartRotation.x, EndRotation.x, curRot), Mathf.Lerp(StartRotation.y, EndRotation.y, curRot), Mathf.Lerp(StartRotation.z, EndRotation.z, curRot)); } private void CheckForBulletProximity() { //IL_008c: 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) bool flag = false; float num = 1f; if (!((Object)(object)GM.CurrentMovementManager != (Object)null)) { return; } for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++) { if ((Object)(object)GM.CurrentMovementManager.Hands[i] != (Object)null && (Object)(object)GM.CurrentMovementManager.Hands[i].CurrentInteractable != (Object)null && GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmRound) { float num2 = Vector3.Distance(((Component)GM.CurrentMovementManager.Hands[i].CurrentInteractable).transform.position, ((Component)this).transform.position); if (num2 < num) { num = num2; flag = true; } } } if (flag && num <= Range) { tarRot = 1f; } else { tarRot = 0f; } } private void CheckForHandToggle() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)GM.CurrentMovementManager != (Object)null)) { return; } isHandInRange = false; float num = ToggleRange + 0.1f; for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++) { FVRViveHand val = GM.CurrentMovementManager.Hands[i]; if (!((Object)(object)val != (Object)null)) { continue; } float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (num2 < num) { num = num2; if (num2 <= ToggleRange && val.Input.TriggerDown) { isHandInRange = true; } } } if (isHandInRange && !wasHandInRange) { tarRot = ((!(tarRot < 0.5f)) ? 0f : 1f); } wasHandInRange = isHandInRange; } } public class Martini : FVRFireArm { public enum BreechRifleState { HammerForward, HammerBackBreechClosed, HammerBackBreechOpen } [Header("Chamber Settings")] public FVRFireArmChamber Chamber; [Header("Transform References")] public Transform Trigger; public Transform Hammer; public Transform Breech; public Transform Lever; public Transform LeverRoot; [Header("Alternate Grip")] public FVRAlternateGrip AltGrip; [Header("Hammer Settings")] public Vector2 HammerRots; public float hammerCockSpeed = 45f; public float hammerReturnSpeed = 60f; [Header("Trigger Settings")] public Vector2 TriggerRots; [Header("Breech Settings")] public Vector2 BreechRots; [Header("Lever Settings")] public Vector2 LeverAngleRange; public float leverSpeed = 900f; public float LeverClosedTolerance = 0.5f; [Header("Ejection Settings")] public float EjectOffset = 0f; public float EjectSpeed = 0f; public bool bypassUnfiredEjection = false; [Header("Auto Close Settings")] public bool AutoCloseOnRegrab = true; private BreechRifleState m_state; private float m_tarHammerRot; private float m_triggerVal; private bool m_isHammerCocked; private float leverProgress; private float m_curLeverRot; private float m_tarLeverRot; private bool m_triggerWasHeldOnGrab; private float m_rackingDisplacement; private float m_lastHandZ; private bool m_handZInitialized; private bool m_wasBreechOpenOnRelease; private float m_lastDistanceBetweenGrips = -1f; public override void Awake() { ((FVRFireArm)this).Awake(); base.FChambers.Add(Chamber); m_tarLeverRot = LeverAngleRange.y; m_curLeverRot = LeverAngleRange.y; } public override void BeginInteraction(FVRViveHand hand) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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) ((FVRFireArm)this).BeginInteraction(hand); if (AutoCloseOnRegrab && m_wasBreechOpenOnRelease) { leverProgress = 0f; m_rackingDisplacement = 0f; m_tarLeverRot = LeverAngleRange.y; m_state = BreechRifleState.HammerBackBreechClosed; CloseCustomBreech(); m_wasBreechOpenOnRelease = false; } m_triggerWasHeldOnGrab = hand.Input.TriggerFloat > 0f; if (Object.op_Implicit((Object)(object)LeverRoot)) { m_lastHandZ = LeverRoot.InverseTransformPoint(hand.PalmTransform.position).z; m_handZInitialized = true; } if ((Object)(object)AltGrip != (Object)null && (Object)(object)((FVRInteractiveObject)AltGrip).m_hand != (Object)null) { m_lastDistanceBetweenGrips = Vector3.Distance(hand.PalmTransform.position, ((FVRInteractiveObject)AltGrip).m_hand.PalmTransform.position); } else { m_lastDistanceBetweenGrips = -1f; } } public override void EndInteraction(FVRViveHand hand) { ((FVRFireArm)this).EndInteraction(hand); m_wasBreechOpenOnRelease = m_state == BreechRifleState.HammerBackBreechOpen; m_handZInitialized = false; m_lastDistanceBetweenGrips = -1f; } public override void FVRUpdate() { ((FVRFireArm)this).FVRUpdate(); UpdateHammerPhysics(); UpdateTriggerVisuals(); } public override void UpdateInteraction(FVRViveHand hand) { m_triggerVal = Mathf.Clamp(hand.Input.TriggerFloat, 0f, 1f); if (m_triggerVal == 0f) { m_triggerWasHeldOnGrab = false; } HandleInputControls(hand); HandleHammerRelease(hand); if ((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) { HandleLeverManualControl(hand); } } public override void FVRFixedUpdate() { //IL_0074: 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) ((FVRFireArm)this).FVRFixedUpdate(); if (!m_isHammerCocked) { leverProgress = 0f; m_rackingDisplacement = 0f; m_tarLeverRot = LeverAngleRange.y; } m_curLeverRot = Mathf.MoveTowards(m_curLeverRot, m_tarLeverRot, leverSpeed * Time.deltaTime); Lever.localEulerAngles = new Vector3(m_curLeverRot, 0f, 0f); float num = (LeverAngleRange.y - m_curLeverRot) / (LeverAngleRange.y - LeverAngleRange.x); num = Mathf.Clamp01(num); if (Object.op_Implicit((Object)(object)Breech)) { Breech.localEulerAngles = new Vector3(Mathf.Lerp(BreechRots.x, BreechRots.y, num), 0f, 0f); } base.IsBreachOpenForGasOut = (Object)(object)Chamber != (Object)null && Chamber.IsAccessible; } private bool IsLeverClosed() { float num = Mathf.Abs(m_curLeverRot - LeverAngleRange.y); return num < LeverClosedTolerance; } private void HandleInputControls(FVRViveHand hand) { bool flag = false; bool flag2 = false; if (hand.IsInStreamlinedMode) { flag = hand.Input.BYButtonDown; flag2 = hand.Input.AXButtonDown; } else if (hand.Input.TouchpadDown) { flag = hand.Input.TouchpadAxes.y > 0f; flag2 = hand.Input.TouchpadAxes.y <= 0f; } if (flag) { HandleUpwardAction(); } if (flag2) { HandleDownwardAction(); } } private void HandleUpwardAction() { if (m_state == BreechRifleState.HammerBackBreechOpen) { leverProgress = 0f; m_rackingDisplacement = 0f; m_tarLeverRot = LeverAngleRange.y; m_state = BreechRifleState.HammerBackBreechClosed; CloseCustomBreech(); } else if (m_state == BreechRifleState.HammerBackBreechClosed) { m_state = BreechRifleState.HammerForward; DecockHammer(); } } private void HandleDownwardAction() { if (!m_isHammerCocked) { CockHammer(); } else if (m_state == BreechRifleState.HammerBackBreechClosed) { leverProgress = 1f; m_rackingDisplacement = 0.04f; m_tarLeverRot = LeverAngleRange.x; m_state = BreechRifleState.HammerBackBreechOpen; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)17, 1f); Chamber.IsAccessible = true; EjectRound(); } } private void HandleHammerRelease(FVRViveHand hand) { if (m_state == BreechRifleState.HammerBackBreechClosed && IsLeverClosed() && !((FVRPhysicalObject)this).IsAltHeld && hand.Input.TriggerDown && !m_triggerWasHeldOnGrab) { DropHammer(); m_state = BreechRifleState.HammerForward; } } private void HandleLeverManualControl(FVRViveHand hand) { //IL_0090: 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) if ((!((Object)(object)Chamber != (Object)null) || !Chamber.IsFull || Chamber.IsSpent || m_state != BreechRifleState.HammerBackBreechClosed) && m_isHammerCocked && !((Object)(object)AltGrip == (Object)null) && !((Object)(object)((FVRInteractiveObject)AltGrip).m_hand == (Object)null)) { float num = Vector3.Distance(hand.PalmTransform.position, ((FVRInteractiveObject)AltGrip).m_hand.PalmTransform.position); if (m_lastDistanceBetweenGrips < 0f) { m_lastDistanceBetweenGrips = num; } if (num < m_lastDistanceBetweenGrips) { float num2 = m_lastDistanceBetweenGrips - num; m_rackingDisplacement += num2; } else { float num3 = num - m_lastDistanceBetweenGrips; m_rackingDisplacement -= num3; } m_lastDistanceBetweenGrips = num; m_rackingDisplacement = Mathf.Clamp(m_rackingDisplacement, 0f, 0.04f); float num4 = Mathf.Clamp01(m_rackingDisplacement * 25f); leverProgress = num4; if (leverProgress >= 1f && m_state == BreechRifleState.HammerBackBreechClosed) { m_tarLeverRot = LeverAngleRange.x; m_state = BreechRifleState.HammerBackBreechOpen; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)17, 1f); Chamber.IsAccessible = true; EjectRound(); m_lastDistanceBetweenGrips = num; } else if (leverProgress <= 0f && m_state == BreechRifleState.HammerBackBreechOpen) { m_tarLeverRot = LeverAngleRange.y; m_state = BreechRifleState.HammerBackBreechClosed; CloseCustomBreech(); m_lastDistanceBetweenGrips = num; } } } private void UpdateHammerPhysics() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Hammer)) { Quaternion val = Quaternion.Euler(m_tarHammerRot, 0f, 0f); float num = ((!(m_tarHammerRot > Hammer.localEulerAngles.x)) ? hammerReturnSpeed : hammerCockSpeed); Hammer.localRotation = Quaternion.RotateTowards(Hammer.localRotation, val, num * Time.deltaTime); } } private void CockHammer() { m_tarHammerRot = HammerRots.x; m_isHammerCocked = true; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)7, 1f); m_state = BreechRifleState.HammerBackBreechClosed; } private void DropHammer() { m_tarHammerRot = HammerRots.y; m_isHammerCocked = false; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f); if (Chamber.IsFull) { Fire(); } } private void DecockHammer() { m_tarHammerRot = HammerRots.y; m_isHammerCocked = false; ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)6, 1f); } private void CloseCustomBreech() { ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)18, 1f); Chamber.IsAccessible = false; } private void EjectRound() { //IL_0067: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Chamber == (Object)null) && Chamber.IsFull && (Chamber.IsSpent || !bypassUnfiredEjection)) { ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)29, 1f); Chamber.EjectRound(((Component)Chamber).transform.position + ((Component)Chamber).transform.forward * EjectOffset, ((Component)Chamber).transform.forward * EjectSpeed, Vector3.right, false); } } private void Fire() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (Chamber.Fire()) { ((FVRFireArm)this).Fire(Chamber, ((FVRFireArm)this).GetMuzzle(), true, 1f, -1f); ((FVRFireArm)this).FireMuzzleSmoke(); bool flag = ((FVRFireArm)this).IsTwoHandStabilized(); bool flag2 = (Object)(object)AltGrip != (Object)null; bool flag3 = ((FVRFireArm)this).IsShoulderStabilized(); ((FVRFireArm)this).Recoil(flag, flag2, flag3, (FVRFireArmRecoilProfile)null, 1f); ((FVRFireArm)this).PlayAudioGunShot(Chamber.GetRound(), GM.CurrentPlayerBody.GetCurrentSoundEnvironment(), 1f); } } public override List<FireArmRoundClass> GetChamberRoundList() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (Chamber.IsFull && !Chamber.IsSpent) { List<FireArmRoundClass> list = new List<FireArmRoundClass>(); list.Add(Chamber.GetRound().RoundClass); return list; } return null; } public override void SetLoadedChambers(List<FireArmRoundClass> rounds) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (rounds.Count > 0) { Chamber.Autochamber(rounds[0]); } } private void UpdateTriggerVisuals() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Trigger)) { float num = Mathf.Lerp(TriggerRots.x, TriggerRots.y, m_triggerVal); Trigger.localEulerAngles = new Vector3(num, 0f, 0f); } } } public class MartiniHenry : FVRFireArm { public enum ZPos { Forward, Middle, Rear } private enum RoundAnimState { NotLoaded, LoadedFromMag, InLowerPath, InUpperPath, ReadyForChamber } [Serializable] public class LeverActuatedPiece { public Transform Piece; public Vector3 PosBack; public Vector3 PosForward; public InterpStyle InterpStyle; public ActuationType ActuationType; } public enum ActuationType { Lever, Hammer } private RoundAnimState m_roundAnimState = RoundAnimState.NotLoaded; [Header("LeverAction Config")] public FVRFireArmChamber Chamber; public bool UsesSecondChamber; public FVRFireArmChamber Chamber2; public Transform SecondEjectionSpot; public Transform SecondMuzzle; private bool m_isHammerCocked2; private bool m_isSecondaryMuzzlePos; public Transform Lever; public Transform LeverRoot; public Transform Hammer; public Transform LoadingGate; public Transform Trigger; public Vector2 TriggerRotRange; public FVRAlternateGrip ForeGrip; public Vector2 LeverAngleRange = new Vector2(-68f, 0f); public Vector2 HammerAngleRange = new Vector2(-36f, 0f); public Vector2 LoadingGateAngleRange = new Vector2(-24f, 0f); public Vector3 EjectionDir = new Vector3(0f, 2f, 0f); public Vector3 EjectionSpin = new Vector3(80f, 0f, 0f); private bool m_isLeverReleasePressed; private float m_curLeverRot; private float m_tarLeverRot; private float m_leverRotSpeed = 700f; private bool m_isActionMovingForward; private ZPos m_curLeverPos = ZPos.Rear; private ZPos m_lastLeverPos = ZPos.Rear; private FVRFirearmMovingProxyRound m_proxy; private FVRFirearmMovingProxyRound m_proxy2; [Header("Round Positions Config")] public Transform ReceiverLowerPathForward; public Transform ReceiverLowerPathRearward; public Transform ReceiverUpperPathForward; public Transform ReceiverUpperPathRearward; public Transform ReceiverEjectionPathForward; public Transform ReceiverEjectionPathRearward; public Transform ReceiverEjectionPoint; public bool GrabsRoundFromMagOnBoltForward; private bool m_isHammerCocked; [Header("Spinning Config")] public Transform PoseSpinHolder; public bool CanSpin; private bool m_isSpinning; public LeverActuatedPiece[] ActuatedPieces; private bool useLinearRacking = true; private float baseDistance = 1f; private float BaseAngleOffset; private bool m_wasLeverLocked; private Vector3 m_baseSpinPosition = Vector3.zero; private float curDistanceBetweenGrips = 1f; private float lastDistanceBetweenGrips = -1f; private float m_rackingDisplacement; private float xSpinRot; private float xSpinVel; [Header("Loading Box Animations")] public bool UseLoadingBoxAnimations = false; public Transform SideBoxHatch; public Transform Kickout; public Transform KickoutArm; public Vector2 SideBoxHatchRotRange = new Vector2(0f, -45f); public Vector2 KickoutRotRange = new Vector2(0f, 30f); public Vector2 KickoutArmRotRange = new Vector2(0f, 45f); public float BoxAnimationSpeed = 1f; private float m_curSideBoxHatchRot = 0f; private float m_curKickoutRot = 0f; private float m_curKickoutArmRot = 0f; private float m_boxAnimSpeed = 300f; private bool m_isBoxAnimating = false; private float m_boxAnimTimer = 0f; private float m_boxAnimDuration = 1.5f; public bool IsHammerCocked => m_isHammerCocked; public override void Awake() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown ((FVRFireArm)this).Awake(); base.FChambers.Add(Chamber); if (UsesSecondChamber && (Object)(object)Chamber2 != (Object)null) { base.FChambers.Add(Chamber2); } GameObject val = new GameObject("m_proxyRound"); m_proxy = val.AddComponent<FVRFirearmMovingProxyRound>(); m_proxy.Init(((Component)this).transform); if (UsesSecondChamber) { GameObject val2 = new GameObject("m_proxyRound2"); m_proxy2 = val2.AddComponent<FVRFirearmMovingProxyRound>(); m_proxy2.Init(((Component)this).transform); } m_baseSpinPosition = PoseSpinHolder.localPosition; } public override Transform GetMuzzle() { if (!UsesSecondChamber) { return ((FVRFireArm)this).GetMuzzle(); } if (m_isSecondaryMuzzlePos) { return SecondMuzzle; } return base.MuzzlePos; } public override void BeginInteraction(FVRViveHand hand) { ((FVRFireArm)this).BeginInteraction(hand); SetBaseHandAngle(hand); } public override void UpdateInteraction(FVRViveHand hand) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) ((FVRPhysicalObject)this).UpdateInteraction(hand); UpdateLever(); if (hand.Input.TriggerDown && !((FVRPhysicalObject)this).IsAltHeld && m_curLeverPos == ZPos.Rear && ((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin && (m_isHammerCocked || m_isHammerCocked2)) { Fire(); } Trigger.localEulerAngles = new Vector3(Mathf.Lerp(TriggerRotRange.x, TriggerRotRange.y, hand.Input.TriggerFloat), 0f, 0f); float num = Mathf.InverseLerp(LeverAngleRange.y, LeverAngleRange.x, m_curLeverRot); if ((Object)(object)Hammer != (Object)null) { if (m_isHammerCocked) { Hammer.localEulerAngles = new Vector3(HammerAngleRange.x, 0f, 0f); } else { Hammer.localEulerAngles = new Vector3(Mathf.Lerp(HammerAngleRange.y, HammerAngleRange.x, num), 0f, 0f); } } } public override void EndInteraction(FVRViveHand hand) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Trigger.localEulerAngles = new Vector3(0f, 0f, 0f); ((FVRFireArm)this).EndInteraction(hand); } private void SetBaseHandAngle(FVRViveHand hand) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) Vector3 val = Vector3.ProjectOnPlane(((FVRInteractiveObject)this).m_hand.PoseOverride.forward, LeverRoot.right); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 forward = LeverRoot.forward; float baseAngleOffset = Mathf.Atan2(Vector3.Dot(LeverRoot.right, Vector3.Cross(forward, normalized)), Vector3.Dot(forward, normalized)) * 57.29578f; BaseAngleOffset = baseAngleOffset; } private void UpdateLever() { //IL_00f0: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Invalid comparison between Unknown and I4 //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_1160: Unknown result type (might be due to invalid IL or missing references) //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07b2: Unknown result type (might be due to invalid IL or missing references) //IL_07c2: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07dd: Unknown result type (might be due to invalid IL or missing references) //IL_07e2: Unknown result type (might be due to invalid IL or missing references) //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_0802: Unknown result type (might be due to invalid IL or missing references) //IL_080d: Unknown result type (might be due to invalid IL or missing references) //IL_081d: Unknown result type (might be due to invalid IL or missing references) //IL_0828: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_083d: Unknown result type (might be due to invalid IL or missing references) //IL_0848: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0868: Unknown result type (might be due to invalid IL or missing references) //IL_0873: Unknown result type (might be due to invalid IL or missing references) //IL_118d: Unknown result type (might be due to invalid IL or missing references) //IL_1198: Unknown result type (might be due to invalid IL or missing references) //IL_119f: Unknown result type (might be due to invalid IL or missing references) //IL_11ba: Unknown result type (might be due to invalid IL or missing references) //IL_11c5: Unknown result type (might be due to invalid IL or missing references) //IL_11cc: Unknown result type (might be due to invalid IL or missing references) //IL_0ce5: Unknown result type (might be due to invalid IL or missing references) //IL_0d00: Unknown result type (might be due to invalid IL or missing references) //IL_0d99: Unknown result type (might be due to invalid IL or missing references) //IL_0da4: Unknown result type (might be due to invalid IL or missing references) //IL_0dab: Unknown result type (might be due to invalid IL or missing references) //IL_0dc6: Unknown result type (might be due to invalid IL or missing references) //IL_0dd1: Unknown result type (might be due to invalid IL or missing references) //IL_0dd8: Unknown result type (might be due to invalid IL or missing references) //IL_0e86: Unknown result type (might be due to invalid IL or missing references) //IL_0e91: Unknown result type (might be due to invalid IL or missing references) //IL_0e98: Unknown result type (might be due to invalid IL or missing references) //IL_0eb3: Unknown result type (might be due to invalid IL or missing references) //IL_0ebe: Unknown result type (might be due to invalid IL or missing references) //IL_0ec5: Unknown result type (might be due to invalid IL or missing references) //IL_0f6a: Unknown result type (might be due to invalid IL or missing references) //IL_0f75: Unknown result type (might be due to invalid IL or missing references) //IL_0f7c: Unknown result type (might be due to invalid IL or missing references) //IL_0f97: Unknown result type (might be due to invalid IL or missing references) //IL_0fa2: Unknown result type (might be due to invalid IL or missing references) //IL_0fa9: Unknown result type (might be due to invalid IL or missing references) //IL_0d37: Unknown result type (might be due to invalid IL or missing references) //IL_0e0f: Unknown result type (might be due to invalid IL or missing references) //IL_0efc: Unknown result type (might be due to invalid IL or missing references) //IL_0fe0: Unknown result type (might be due to invalid IL or missing references) //IL_1204: Unknown result type (might be due to invalid IL or missing references) //IL_120f: Unknown result type (might be due to invalid IL or missing references) //IL_1216: Unknown result type (might be due to invalid IL or missing references) //IL_1231: Unknown result type (might be due to invalid IL or missing references) //IL_123c: Unknown result type (might be due to invalid IL or missing references) //IL_1243: Unknown result type (might be due to invalid IL or missing references) //IL_10a6: Unknown result type (might be due to invalid IL or missing references) //IL_10b1: Unknown result type (might be due to invalid IL or missing references) //IL_10b8: Unknown result type (might be due to invalid IL or missing references) //IL_10d3: Unknown result type (might be due to invalid IL or missing references) //IL_10de: Unknown result type (might be due to invalid IL or missing references) //IL_10e5: Unknown result type (might be due to invalid IL or missing references) //IL_100d: Unknown result type (might be due to invalid IL or missing references) //IL_1018: Unknown result type (might be due to invalid IL or missing references) //IL_101f: Unknown result type (might be due to invalid IL or missing references) //IL_103a: Unknown result type (might be due to invalid IL or missing references) //IL_1045: Unknown result type (might be due to invalid IL or missing references) //IL_104c: Unknown result type (might be due to invalid IL or missing references) //IL_08d4: Unknown result type (might be due to invalid IL or missing references) //IL_08df: Unknown result type (might be due to invalid IL or missing references) //IL_08ef: Unknown result type (might be due to invalid IL or missing references) //IL_08fa: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_090f: Unknown result type (might be due to invalid IL or missing references) //IL_091a: Unknown result type (might be due to invalid IL or missing references) //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_092f: Unknown result type (might be due to invalid IL or missing references) //IL_093a: Unknown result type (might be due to invalid IL or missing references) //IL_094a: Unknown result type (might be due to invalid IL or missing references) //IL_0955: Unknown result type (might be due to invalid IL or missing references) //IL_0965: Unknown result type (might be due to invalid IL or missing references) //IL_096a: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_098a: Unknown result type (might be due to invalid IL or missing references) //IL_0995: Unknown result type (might be due to invalid IL or missing references) //IL_09a0: Unknown result type (might be due to invalid IL or missing references) //IL_111c: Unknown result type (might be due to invalid IL or missing references) //IL_1083: Unknown result type (might be due to invalid IL or missing references) //IL_12e7: Unknown result type (might be due to invalid IL or missing references) //IL_1346: Unknown result type (might be due to invalid IL or missing references) //IL_1354: Unknown result type (might be due to invalid IL or missing references) //IL_135b: Unknown result type (might be due to invalid IL or missing references) //IL_1309: Unknown result type (might be due to invalid IL or missing references) //IL_1317: Unknown result type (might be due to invalid IL or missing references) //IL_131e: Unknown result type (might be due to invalid IL or missing references) bool flag = false; bool flag2 = false; if (((FVRInteractiveObject)this).IsHeld) { if (((FVRInteractiveObject)this).m_hand.IsInStreamlinedMode) { flag = ((FVRInteractiveObject)this).m_hand.Input.BYButtonPressed; flag2 = ((FVRInteractiveObject)this).m_hand.Input.BYButtonUp; } else { flag = ((FVRInteractiveObject)this).m_hand.Input.TouchpadPressed; flag2 = ((FVRInteractiveObject)this).m_hand.Input.TouchpadUp; } } m_isLeverReleasePressed = false; bool flag3 = false; if (!((FVRPhysicalObject)this).IsAltHeld && (Object)(object)((FVRInteractiveObject)ForeGrip).m_hand != (Object)null) { if (((FVRInteractiveObject)ForeGrip).m_hand.Input.TriggerPressed && ((FVRInteractiveObject)ForeGrip).m_hasTriggeredUpSinceBegin && (int)GM.Options.ControlOptions.LongGunSnipingAssist != 1) { flag3 = true; } m_isLeverReleasePressed = true; curDistanceBetweenGrips = Vector3.Distance(((FVRInteractiveObject)this).m_hand.PalmTransform.position, ((FVRInteractiveObject)((FVRPhysicalObject)this).AltGrip).m_hand.PalmTransform.position); if (lastDistanceBetweenGrips < 0f) { lastDistanceBetweenGrips = curDistanceBetweenGrips; } } else { lastDistanceBetweenGrips = -1f; } bool flag4 = !((FVRPhysicalObject)this).IsAltHeld && flag; m_isSpinning = false; if (flag4 && CanSpin) { m_isSpinning = true; } bool flag5 = false; if ((m_isHammerCocked || m_isHammerCocked2) && !flag4 && m_curLeverPos == ZPos.Rear) { flag5 = true; } if (flag3) { flag5 = false; } if ((Object)(object)((FVRPhysicalObject)this).AltGrip == (Object)null && !((FVRPhysicalObject)this).IsAltHeld) { flag5 = true; } if (flag5 && useLinearRacking) { SetBaseHandAngle(((FVRInteractiveObject)this).m_hand); lastDistanceBetweenGrips = curDistanceBetweenGrips; } m_wasLeverLocked = flag5; if (flag2 && m_curLeverPos != ZPos.Forward && m_rackingDisplacement < 0.005f) { m_tarLeverRot = 0f; PoseSpinHolder.localPosition = m_baseSpinPosition; lastDistanceBetweenGrips = curDistanceBetweenGrips; m_rackingDisplacement = 0f; } else if (m_isLeverReleasePressed && !flag5) { if (useLinearRacking) { curDistanceBetweenGrips = Vector3.Distance(((FVRInteractiveObject)this).m_hand.PalmTransform.position, ((FVRInteractiveObject)((FVRPhysicalObject)this).AltGrip).m_hand.PalmTransform.position); Vector3 val = ((FVRInteractiveObject)this).m_hand.Input.VelLinearWorld - ((F