using System; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using FistVR; using HarmonyLib; using OtherLoader; using UnityEngine; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace BitWizrd.HuntBornheimNo3Silencer { [BepInProcess("h3vr.exe")] [BepInPlugin("BitWizrd.HuntBornheimNo3Silencer", "HuntBornheimNo3Silencer", "1.0.8")] [BepInDependency("h3vr.otherloader", "1.3.0")] [Description("Built with MeatKit")] public class HuntBornheimNo3SilencerPlugin : 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.HuntBornheimNo3Silencer"); OtherLoader.RegisterDirectLoad(BasePath, "BitWizrd.HuntBornheimNo3Silencer", "", "bornheimno3silencer", "", ""); } } } 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(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Object)((Component)componentsInChildren[i]).gameObject).name = name; } } } namespace BitWizrd.BornheimPistol { public class Bornheim : Handgun { [Header("Follower Control")] public Transform Follower; public Axis FollowerAxis = (Axis)0; public float[] FollowerRotations; public float FollowerLoweredRotation = 0f; public BornheimMagazineDoor MagazineDoor; [Header("Magazine Door Ejection")] public bool EnableDoorEjection = true; private bool _autoEjected; private bool _prevHasMag; private int _prevRoundCount = -1; private bool _isSlideReleaseHeldDown; private HeldTouchpadAction _heldTouchpadAction; private Vector2 _touchpadClickInitiation = Vector2.zero; private bool _wasDoorClosed = true; private bool _magazineInsertedWhileClosed = false; private bool _isDoorOpen = false; public override void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) ((Handgun)this).Awake(); base.HasMagReleaseInput = false; if (EnableDoorEjection && (Object)(object)MagazineDoor != (Object)null) { float num = ((Component)MagazineDoor).transform.localEulerAngles.x; if (num > 180f) { num -= 360f; } _isDoorOpen = num > 15f; } } public override void FVRUpdate() { ((Handgun)this).FVRUpdate(); bool prevHasMag = (Object)(object)((FVRFireArm)this).Magazine != (Object)null; _prevHasMag = prevHasMag; AutoEjectEmptyMagazine(); UpdateFollower(); if (EnableDoorEjection) { UpdateDoorEjectionLogic(); } } private void UpdateDoorEjectionLogic() { //IL_0022: 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) if ((Object)(object)MagazineDoor == (Object)null) { return; } float num = ((Component)MagazineDoor).transform.localEulerAngles.x; if (num > 180f) { num -= 360f; } bool flag = num <= 15f; if (num >= 75f && (Object)(object)((FVRFireArm)this).Magazine != (Object)null && _magazineInsertedWhileClosed) { ((FVRFireArm)this).EjectMag(false); _magazineInsertedWhileClosed = false; } if (flag) { if (_isDoorOpen) { _isDoorOpen = false; if ((Object)(object)((FVRFireArm)this).Magazine != (Object)null) { _magazineInsertedWhileClosed = true; } } } else { if (!_isDoorOpen) { } _isDoorOpen = true; } } public override void LoadMag(FVRFireArmMagazine mag) { //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) ((FVRFireArm)this).LoadMag(mag); if (EnableDoorEjection && (Object)(object)MagazineDoor != (Object)null) { float num = ((Component)MagazineDoor).transform.localEulerAngles.x; if (num > 180f) { num -= 360f; } if (num <= 15f) { _magazineInsertedWhileClosed = true; } else { _magazineInsertedWhileClosed = false; } } } public override void UpdateInteraction(FVRViveHand hand) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Invalid comparison between Unknown and I4 //IL_0076: 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_0106: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) _isSlideReleaseHeldDown = false; if (!((FVRPhysicalObject)this).IsAltHeld) { if (hand.IsInStreamlinedMode) { if (hand.Input.AXButtonPressed) { _isSlideReleaseHeldDown = true; } } else { Vector2 touchpadAxes = hand.Input.TouchpadAxes; if (hand.Input.TouchpadDown) { _touchpadClickInitiation = touchpadAxes; if (((Vector2)(ref touchpadAxes)).magnitude > 0.2f) { if (Vector2.Angle(touchpadAxes, Vector2.down) <= 45f) { _heldTouchpadAction = (HeldTouchpadAction)3; } else { _heldTouchpadAction = (HeldTouchpadAction)0; } } } if (hand.Input.TouchpadPressed && (int)_heldTouchpadAction == 3 && ((Vector2)(ref touchpadAxes)).magnitude > 0.2f && Vector2.Angle(touchpadAxes, Vector2.down) <= 45f) { _isSlideReleaseHeldDown = true; } if (hand.Input.TouchpadUp) { _heldTouchpadAction = (HeldTouchpadAction)0; } } if (_isSlideReleaseHeldDown) { TryEngageSlideRelease(); } } ((Handgun)this).UpdateInteraction(hand); } private void TryEngageSlideRelease() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if (!((Object)(object)base.Slide == (Object)null) && (int)base.Slide.CurPos >= 2 && !((Handgun)this).IsSlideCatchEngaged()) { ((Handgun)this).EngageSlideRelease(); ((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)4, 1f); } } private void AutoEjectEmptyMagazine() { if ((Object)(object)((FVRFireArm)this).Magazine == (Object)null) { _autoEjected = false; } else if (!_autoEjected && !((FVRFireArm)this).Magazine.HasARound()) { ((FVRFireArm)this).EjectMag(false); _autoEjected = true; } else if (((FVRFireArm)this).Magazine.HasARound()) { _autoEjected = false; } } private void UpdateFollower() { //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Invalid comparison between Unknown and I4 //IL_0253: 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_021c: Invalid comparison between Unknown and I4 //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Follower == (Object)null || FollowerRotations == null || FollowerRotations.Length == 0) { return; } int num = 0; if ((Object)(object)((FVRFireArm)this).Magazine != (Object)null) { num = ((FVRFireArm)this).Magazine.m_numRounds; } bool flag = num != _prevRoundCount; bool flag2 = false; if (flag) { _prevRoundCount = num; flag2 = true; } if (!flag2 && (!((Object)(object)((FVRFireArm)this).Magazine == (Object)null) || !((Object)(object)MagazineDoor != (Object)null)) && (!EnableDoorEjection || !((Object)(object)MagazineDoor != (Object)null))) { return; } float num2 = 0f; if ((Object)(object)((FVRFireArm)this).Magazine != (Object)null) { int num3 = FollowerRotations.Length - 1 - Mathf.Clamp(num, 0, FollowerRotations.Length - 1); num2 = FollowerRotations[num3]; if (EnableDoorEjection && (Object)(object)MagazineDoor != (Object)null && _isDoorOpen) { float num4 = ((Component)MagazineDoor).transform.localEulerAngles.x; if (num4 > 180f) { num4 -= 360f; } float num5 = Mathf.Clamp01(num4 / MagazineDoor.MaxRotation); num2 = Mathf.Lerp(num2, FollowerLoweredRotation, num5); } } else if ((Object)(object)MagazineDoor != (Object)null) { float num6 = ((Component)MagazineDoor).transform.localEulerAngles.x; if (num6 > 180f) { num6 -= 360f; } float num7 = Mathf.Clamp01(num6 / MagazineDoor.MaxRotation); float num8 = FollowerRotations[FollowerRotations.Length - 1]; num2 = Mathf.Lerp(num8, FollowerLoweredRotation, num7); } Vector3 localEulerAngles = Follower.localEulerAngles; Axis followerAxis = FollowerAxis; if ((int)followerAxis != 0) { if ((int)followerAxis != 1) { if ((int)followerAxis == 2) { localEulerAngles.z = num2; } } else { localEulerAngles.y = num2; } } else { localEulerAngles.x = num2; } Follower.localEulerAngles = localEulerAngles; } } public class BornheimMagazineDoor : FVRInteractiveObject { public FVRFireArm FireArm; [Header("Magazine Door Settings")] [Tooltip("Maximum rotation angle (degrees)")] public float MaxRotation = 90f; [Tooltip("Hand movement distance (in meters) that equals full door rotation")] public float HandMovementRange = 0.1f; [Tooltip("Threshold for playing opening sound")] public float OpeningSoundThreshold = 15f; [Tooltip("Threshold for playing closing sound")] public float ClosingSoundThreshold = 10f; [Tooltip("Show direction gizmos and interaction distance in scene view")] [Header("Debug Gizmos")] public bool ShowGizmos = true; private Vector3 startHandPos; private float startRotation; private float lastValidRotation; private float lastRotation; private bool hasPlayedOpeningSound = false; private bool hasPlayedClosingSound = false; private bool hadMagazine = false; private Coroutine fastCloseCoroutine; public bool HasPlayedOpeningSound => hasPlayedOpeningSound; public bool HasPlayedClosingSound => hasPlayedClosingSound; private float GetScaledDistance(float distance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_002e: 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) float num = (((Component)this).transform.lossyScale.x + ((Component)this).transform.lossyScale.y + ((Component)this).transform.lossyScale.z) / 3f; return distance * num; } private float NormalizeAngle(float angle) { while (angle > 360f) { angle -= 360f; } while (angle < 0f) { angle += 360f; } return angle; } private IEnumerator FastCloseDoor() { float startAngle = NormalizeAngle(((Component)this).transform.localEulerAngles.x); float elapsed = 0f; float duration = 0.1f; while (elapsed < duration) { elapsed += Time.deltaTime; float t = elapsed / duration; float currentAngle = Mathf.Lerp(startAngle, 0f, t); ((Component)this).transform.localEulerAngles = new Vector3(currentAngle, 0f, 0f); lastValidRotation = currentAngle; if (currentAngle < ClosingSoundThreshold && !hasPlayedClosingSound) { FireArm.PlayAudioEvent((FirearmAudioEventType)24, 1f); hasPlayedClosingSound = true; hasPlayedOpeningSound = false; } yield return null; } ((Component)this).transform.localEulerAngles = new Vector3(0f, 0f, 0f); lastValidRotation = 0f; FireArm.IsTopCoverUp = false; fastCloseCoroutine = null; } private void StartFastClose() { if (fastCloseCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(fastCloseCoroutine); } fastCloseCoroutine = ((MonoBehaviour)this).StartCoroutine(FastCloseDoor()); } private void CheckAudioThresholds(float currentRotation) { if (currentRotation > lastRotation) { if (!hasPlayedOpeningSound && lastRotation <= OpeningSoundThreshold && currentRotation > OpeningSoundThreshold) { FireArm.PlayAudioEvent((FirearmAudioEventType)23, 1f); hasPlayedOpeningSound = true; hasPlayedClosingSound = false; } } else if (currentRotation < lastRotation && !hasPlayedClosingSound && lastRotation >= ClosingSoundThreshold && currentRotation < ClosingSoundThreshold) { FireArm.PlayAudioEvent((FirearmAudioEventType)24, 1f); hasPlayedClosingSound = true; hasPlayedOpeningSound = false; } } public void Start() { hadMagazine = (Object)(object)FireArm != (Object)null && (Object)(object)FireArm.Magazine != (Object)null; ((FVRInteractiveObject)this).Start(); } private void Update() { //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) bool flag = (Object)(object)FireArm != (Object)null && (Object)(object)FireArm.Magazine != (Object)null; if (!hadMagazine && flag) { float num = NormalizeAngle(((Component)this).transform.localEulerAngles.x); if (num > 5f && (Object)(object)base.m_hand == (Object)null) { StartFastClose(); } } hadMagazine = flag; } public override void BeginInteraction(FVRViveHand hand) { //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_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) if (fastCloseCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(fastCloseCoroutine); fastCloseCoroutine = null; } startHandPos = ((HandInput)(ref hand.Input)).Pos; startRotation = NormalizeAngle(((Component)this).transform.localEulerAngles.x); lastValidRotation = startRotation; lastRotation = startRotation; hasPlayedOpeningSound = startRotation > OpeningSoundThreshold; hasPlayedClosingSound = startRotation < ClosingSoundThreshold; ((FVRInteractiveObject)this).BeginInteraction(hand); } public override void UpdateInteraction(FVRViveHand hand) { //IL_000e: 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_002a: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) ((FVRInteractiveObject)this).UpdateInteraction(hand); Vector3 val = ((HandInput)(ref hand.Input)).Pos - startHandPos; Vector3 val2 = ((Component)FireArm).transform.forward * 0.7f + -((Component)FireArm).transform.up * 0.3f; Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Vector3.Dot(val, normalized); float scaledDistance = GetScaledDistance(HandMovementRange); float num2 = startRotation + num / scaledDistance * MaxRotation; num2 = Mathf.Clamp(num2, 0f, MaxRotation); CheckAudioThresholds(num2); lastRotation = num2; lastValidRotation = num2; ((Component)this).transform.localEulerAngles = new Vector3(num2, 0f, 0f); } public override void EndInteraction(FVRViveHand hand) { //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_0044: Unknown result type (might be due to invalid IL or missing references) float num = NormalizeAngle(((Component)this).transform.localEulerAngles.x); if (num >= MaxRotation - 10f) { ((Component)this).transform.localEulerAngles = new Vector3(MaxRotation, 0f, 0f); lastValidRotation = MaxRotation; FireArm.IsTopCoverUp = true; } else { StartFastClose(); } ((FVRInteractiveObject)this).EndInteraction(hand); } public override void TestHandDistance() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (base.EndInteractionIfDistant) { float scaledDistance = GetScaledDistance(base.EndInteractionDistance); float num = Vector3.Distance(((FVRInteractiveObject)this).m_handPos, base.Transform.position); if (num >= scaledDistance) { float num2 = lastValidRotation; ((FVRInteractiveObject)this).ForceBreakInteraction(); ((Component)this).transform.localEulerAngles = new Vector3(num2, 0f, 0f); } } } public void CloseDoor() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) lastValidRotation = 0f; ((Component)this).transform.localEulerAngles = new Vector3(0f, 0f, 0f); FireArm.IsTopCoverUp = false; hasPlayedClosingSound = true; hasPlayedOpeningSound = false; FireArm.PlayAudioEvent((FirearmAudioEventType)24, 1f); } private void OnDrawGizmosSelected() { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0088: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) if (ShowGizmos && !((Object)(object)FireArm == (Object)null)) { Vector3 position = ((Component)this).transform.position; float num = (((Component)this).transform.lossyScale.x + ((Component)this).transform.lossyScale.y + ((Component)this).transform.lossyScale.z) / 3f; float num2 = 1f / num; float scaledDistance = GetScaledDistance(base.EndInteractionDistance); Gizmos.color = Color.yellow; Gizmos.DrawWireSphere(position, scaledDistance); Vector3 val = ((Component)FireArm).transform.forward * 0.7f + -((Component)FireArm).transform.up * 0.3f; Vector3 normalized = ((Vector3)(ref val)).normalized; float scaledDistance2 = GetScaledDistance(HandMovementRange); Gizmos.color = Color.cyan; Vector3 val2 = position; Vector3 val3 = position + normalized * scaledDistance2; Gizmos.DrawLine(val2, val3); Gizmos.DrawWireCube(val3, Vector3.one * 0.02f * num2); } } } } 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(); } 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(); if ((Object)(object)audioSource == (Object)null) { audioSource = ((Component)weapon).gameObject.AddComponent(); } 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); } } 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(); } } } 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(true); for (int i = 0; i < componentsInChildren.Length; i++) { Component val = (Component)(object)componentsInChildren[i]; ((Object)val.gameObject).name = str; } } } public class PlayRandomSoundOnSpawn : MonoBehaviour { public AudioClip[] spawnSounds; public float volume = 1f; [Header("Pitch Settings")] public float minPitch = 0.9f; public float maxPitch = 1.1f; private AudioSource audioSource; private void Start() { if (spawnSounds.Length > 0) { audioSource = ((Component)this).gameObject.AddComponent(); audioSource.playOnAwake = false; audioSource.spatialBlend = 1f; audioSource.volume = volume; AudioClip val = spawnSounds[Random.Range(0, spawnSounds.Length)]; audioSource.pitch = Random.Range(minPitch, maxPitch); audioSource.PlayOneShot(val); } } } public class RandomSpinOnSpawn : MonoBehaviour { public float spinForce = 0.5f; public Vector3 torqueAxis = new Vector3(1f, 0f, 0f); private Rigidbody rb; private void Start() { //IL_003e: 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_005f: Unknown result type (might be due to invalid IL or missing references) rb = ((Component)this).GetComponent(); if ((Object)(object)rb != (Object)null) { ((Component)this).transform.rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); rb.AddTorque(((Vector3)(ref torqueAxis)).normalized * spinForce, (ForceMode)1); } } }