Decompiled source of CZ52 Tokarev v1.0.0

CZ52_Tokarev.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OpenScripts2;
using OtherLoader;
using UnityEngine;
using UnityEngine.UI;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
public class WinterTrigger : FVRInteractiveObject
{
	[Header("Deploy")]
	public Transform Pivot;

	public Vector3 StowedLocalEuler;

	public Vector3 DeployedLocalEuler;

	public float DeploySpeed = 6f;

	[Header("Trigger Follow")]
	public ClosedBoltWeapon Weapon;

	public Transform WeaponTrigger;

	public Transform WinterTriggerTransform;

	public bool FollowRotation = true;

	public Vector3 RotationOffset;

	public bool FollowTranslation;

	public Vector3 PositionOffset;

	private bool m_isDeployed;

	private float m_deployLerp;

	private Quaternion m_stowedTriggerRotation;

	private Vector3 m_stowedTriggerPosition;

	private bool m_hasStowedTriggerPose;

	public override void Awake()
	{
		((FVRInteractiveObject)this).Awake();
		CacheWeaponTrigger();
		CacheStowedTriggerPose();
		SetPivotPose(0f);
	}

	public override void SimpleInteraction(FVRViveHand hand)
	{
		((FVRInteractiveObject)this).SimpleInteraction(hand);
		m_isDeployed = !m_isDeployed;
	}

	public override void FVRUpdate()
	{
		((FVRInteractiveObject)this).FVRUpdate();
		CacheWeaponTrigger();
		float num = ((!m_isDeployed) ? 0f : 1f);
		m_deployLerp = Mathf.MoveTowards(m_deployLerp, num, DeploySpeed * Time.deltaTime);
		SetPivotPose(m_deployLerp);
		if (m_isDeployed)
		{
			ApplyTriggerFollow();
		}
		else
		{
			RestoreStowedTriggerPose();
		}
	}

	private void CacheWeaponTrigger()
	{
		if ((Object)(object)WeaponTrigger == (Object)null && (Object)(object)Weapon != (Object)null)
		{
			WeaponTrigger = Weapon.Trigger;
		}
	}

	private void CacheStowedTriggerPose()
	{
		//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_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)
		if (!((Object)(object)WinterTriggerTransform == (Object)null))
		{
			m_stowedTriggerRotation = WinterTriggerTransform.localRotation;
			m_stowedTriggerPosition = WinterTriggerTransform.localPosition;
			m_hasStowedTriggerPose = true;
		}
	}

	private void SetPivotPose(float t)
	{
		//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_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_0036: 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)
		if (!((Object)(object)Pivot == (Object)null))
		{
			Quaternion val = Quaternion.Euler(StowedLocalEuler);
			Quaternion val2 = Quaternion.Euler(DeployedLocalEuler);
			Pivot.localRotation = Quaternion.Slerp(val, val2, t);
		}
	}

	private void ApplyTriggerFollow()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)WinterTriggerTransform == (Object)null) && !((Object)(object)WeaponTrigger == (Object)null))
		{
			if (FollowRotation)
			{
				WinterTriggerTransform.localRotation = WeaponTrigger.localRotation * Quaternion.Euler(RotationOffset);
			}
			if (FollowTranslation)
			{
				WinterTriggerTransform.localPosition = WeaponTrigger.localPosition + PositionOffset;
			}
		}
	}

	private void RestoreStowedTriggerPose()
	{
		//IL_002a: 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)
		if (m_hasStowedTriggerPose && !((Object)(object)WinterTriggerTransform == (Object)null))
		{
			WinterTriggerTransform.localRotation = m_stowedTriggerRotation;
			WinterTriggerTransform.localPosition = m_stowedTriggerPosition;
		}
	}
}
public class MDTCkyeBipodController : MonoBehaviour
{
	public Transform GroundContactReference;

	public LayerMask ValidGroundLayers;

	public float RaycastDistance = 0.5f;

	private Vector3 lastExternalPosition;

	private void Start()
	{
		//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)
		if ((Object)(object)GroundContactReference != (Object)null)
		{
			lastExternalPosition = GroundContactReference.position;
		}
	}

	private void LateUpdate()
	{
		//IL_0019: 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_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)
		if ((Object)(object)GroundContactReference != (Object)null && GroundContactReference.position != lastExternalPosition)
		{
			UpdateGroundPoint();
			lastExternalPosition = GroundContactReference.position;
		}
	}

	private void UpdateGroundPoint()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		Ray val = default(Ray);
		((Ray)(ref val))..ctor(GroundContactReference.position, -Vector3.up);
		RaycastHit val2 = default(RaycastHit);
		if (Physics.Raycast(val, ref val2, RaycastDistance, LayerMask.op_Implicit(ValidGroundLayers)))
		{
			float y = GroundContactReference.position.y;
			float y2 = ((RaycastHit)(ref val2)).point.y;
			if (Mathf.Abs(y - y2) > 0.001f)
			{
				GroundContactReference.position = new Vector3(GroundContactReference.position.x, y2, GroundContactReference.position.z);
			}
			Debug.DrawRay(GroundContactReference.position, -Vector3.up * RaycastDistance, Color.green);
		}
		else
		{
			Debug.DrawRay(GroundContactReference.position, -Vector3.up * RaycastDistance, Color.red);
		}
	}
}
public class ForeMagRelease : UniversalAdvancedMagazineGrabTrigger
{
	[Header("ForeMagRelease Config")]
	public bool EjectMainMagOnSecondaryRelease = true;

	private bool wasSecondaryMagPresent = true;

	public override void UpdateInteraction(FVRViveHand hand)
	{
		((UniversalAdvancedMagazineGrabTrigger)this).UpdateInteraction(hand);
		if (base.IsSecondarySlotGrab)
		{
			FVRFireArmMagazine magazine = base.FireArm.SecondaryMagazineSlots[base.SecondaryGrabSlot].Magazine;
			if (wasSecondaryMagPresent && (Object)(object)magazine == (Object)null && EjectMainMagOnSecondaryRelease && (Object)(object)base.FireArm.Magazine != (Object)null)
			{
				base.FireArm.EjectMag(false);
			}
			wasSecondaryMagPresent = (Object)(object)magazine != (Object)null;
		}
		else
		{
			wasSecondaryMagPresent = true;
		}
	}
}
public class AmmoRecoilBlast : MonoBehaviour
{
	public BallisticProjectile Projectile;

	[Header("Recoil Settings")]
	public float RecoilForce = 3.5f;

	public bool UseHeadDirection = true;

	private bool _hasBlasted = false;

	private void Start()
	{
		if ((Object)(object)Projectile == (Object)null)
		{
			Projectile = ((Component)this).GetComponent<BallisticProjectile>();
		}
		((MonoBehaviour)this).StartCoroutine(WaitAndApplyRecoil());
	}

	private IEnumerator WaitAndApplyRecoil()
	{
		while ((Object)(object)Projectile != (Object)null && !Projectile.IsMoving())
		{
			yield return null;
		}
		ApplyRecoil();
	}

	private void ApplyRecoil()
	{
		//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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		if (_hasBlasted)
		{
			return;
		}
		_hasBlasted = true;
		if (!((Object)(object)GM.CurrentMovementManager == (Object)null) && !((Object)(object)GM.CurrentPlayerBody == (Object)null))
		{
			Vector3 forward = ((Component)GM.CurrentMovementManager).transform.forward;
			Vector3 up = ((Component)GM.CurrentMovementManager).transform.up;
			Vector3 val = Vector3.ProjectOnPlane(forward, up);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			if ((Object)(object)Projectile != (Object)null && (Object)(object)((Component)Projectile).transform != (Object)null)
			{
				Vector3 val2 = Vector3.ProjectOnPlane(((Component)Projectile).transform.forward, up);
				normalized = ((Vector3)(ref val2)).normalized;
			}
			((MonoBehaviour)this).StartCoroutine(ApplyRecoilSmoothly(-normalized, RecoilForce, 0.2f));
		}
	}

	private IEnumerator ApplyRecoilSmoothly(Vector3 direction, float force, float duration)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		float elapsed = 0f;
		while (elapsed < duration)
		{
			float stepForce = force * Time.deltaTime / duration;
			GM.CurrentMovementManager.Blast(direction, stepForce, true);
			elapsed += Time.deltaTime;
			yield return null;
		}
	}
}
public class BoxMagBeltFix : MonoBehaviour
{
	public FVRFireArm targetGun;

	public GameObject boxMagazineObject;

	private FVRFireArmMagazine boxMagazine;

	private GameObject beltVisual;

	private bool beltHidden = false;

	private void Start()
	{
		if ((Object)(object)targetGun == (Object)null)
		{
			Debug.LogError((object)"BoxMagBeltFix: targetGun not assigned!");
			((Behaviour)this).enabled = false;
			return;
		}
		if ((Object)(object)targetGun.BeltDD != (Object)null)
		{
			beltVisual = ((Component)targetGun.BeltDD).gameObject;
		}
		if ((Object)(object)boxMagazineObject != (Object)null)
		{
			boxMagazine = boxMagazineObject.GetComponent<FVRFireArmMagazine>();
			if ((Object)(object)boxMagazine == (Object)null)
			{
				Debug.LogError((object)"BoxMagBeltFix: boxMagazineObject does not have FVRFireArmMagazine component!");
				((Behaviour)this).enabled = false;
				return;
			}
			FVRFireArmBeltSegment[] componentsInChildren = ((Component)targetGun).GetComponentsInChildren<FVRFireArmBeltSegment>(true);
			FVRFireArmBeltSegment[] array = componentsInChildren;
			foreach (FVRFireArmBeltSegment val in array)
			{
				if ((Object)(object)targetGun.BeltDD == (Object)null || (Object)(object)((Component)val).gameObject != (Object)(object)((Component)targetGun.BeltDD).gameObject)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}
		else
		{
			Debug.LogError((object)"BoxMagBeltFix: boxMagazineObject not assigned!");
			((Behaviour)this).enabled = false;
		}
	}

	private void Update()
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)boxMagazine == (Object)null || (Object)(object)targetGun == (Object)null)
		{
			return;
		}
		if ((Object)(object)targetGun.Magazine != (Object)(object)boxMagazine && (int)boxMagazine.State == 0)
		{
			targetGun.LoadMag(boxMagazine);
		}
		bool flag = (Object)(object)targetGun.Magazine == (Object)(object)boxMagazine;
		if (flag && !beltHidden)
		{
			if ((Object)(object)beltVisual != (Object)null)
			{
				beltVisual.SetActive(false);
			}
			FVRFireArmBeltSegment[] componentsInChildren = ((Component)targetGun).GetComponentsInChildren<FVRFireArmBeltSegment>(true);
			FVRFireArmBeltSegment[] array = componentsInChildren;
			foreach (FVRFireArmBeltSegment val in array)
			{
				if ((Object)(object)((Component)val).gameObject != (Object)(object)((Component)targetGun.BeltDD).gameObject)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
			beltHidden = true;
		}
		else if (!flag && beltHidden)
		{
			if ((Object)(object)beltVisual != (Object)null)
			{
				beltVisual.SetActive(true);
			}
			beltHidden = false;
		}
	}
}
public class ForwardAssist : FVRInteractiveObject
{
	[Header("Animation Settings")]
	public Transform TargetTransform;

	public Vector3 StartPosition;

	public Vector3 EndPosition;

	public Vector3 StartRotation;

	public Vector3 EndRotation;

	public float MoveSpeed = 10f;

	public float ResetDelay = 0.2f;

	[Header("Audio Settings")]
	public AudioEvent PokeAudioEvent;

	public FVRPooledAudioType AudioType = (FVRPooledAudioType)0;

	private float m_animFloat = 0f;

	private bool m_isPoked = false;

	private float m_resetTimer = 0f;

	protected void Awake()
	{
		//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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).Awake();
		if ((Object)(object)TargetTransform == (Object)null)
		{
			TargetTransform = ((Component)this).transform;
		}
		if (StartPosition == Vector3.zero)
		{
			StartPosition = TargetTransform.localPosition;
		}
		if (StartRotation == Vector3.zero)
		{
			StartRotation = TargetTransform.localEulerAngles;
		}
	}

	public override void Poke(FVRViveHand hand)
	{
		//IL_000e: 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)
		if (PokeAudioEvent != null)
		{
			SM.PlayCoreSound(AudioType, PokeAudioEvent, ((Component)this).transform.position);
		}
		m_isPoked = true;
		m_resetTimer = ResetDelay;
	}

	private void Update()
	{
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: 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_00c5: 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)
		if (m_isPoked)
		{
			m_animFloat = Mathf.MoveTowards(m_animFloat, 1f, Time.deltaTime * MoveSpeed);
			m_resetTimer -= Time.deltaTime;
			if (m_resetTimer <= 0f)
			{
				m_isPoked = false;
			}
		}
		else
		{
			m_animFloat = Mathf.MoveTowards(m_animFloat, 0f, Time.deltaTime * MoveSpeed);
		}
		if ((Object)(object)TargetTransform != (Object)null)
		{
			TargetTransform.localPosition = Vector3.Lerp(StartPosition, EndPosition, m_animFloat);
			TargetTransform.localEulerAngles = Vector3.Lerp(StartRotation, EndRotation, m_animFloat);
		}
	}
}
public class ResidualBeltLinkHandler : MonoBehaviour
{
	public enum Axis
	{
		X,
		Y,
		Z
	}

	[Header("References")]
	public FVRFireArm Firearm;

	public Transform FeedTraySpawnPoint;

	public GameObject BeltLinkPrefab;

	[Header("Feed Tray")]
	public Transform FeedTray;

	public float FeedTrayClearAngleMin = 55f;

	public float FeedTrayClearAngleMax = 70f;

	public Axis FeedTrayClearAxis = Axis.X;

	[Header("Behavior")]
	public float AutoCleanupTime = 10f;

	public float ShakeClearAngularVelocity = 6f;

	public float HandClearVelocity = 0.5f;

	private GameObject _spawnedLink;

	private Rigidbody _linkRB;

	private bool _hasResidualLink;

	private float _cleanupTimer;

	private float _currentClearAngle;

	private int _lastKnownRounds = -1;

	private void Update()
	{
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Firearm != (Object)null && (Object)(object)Firearm.Magazine != (Object)null)
		{
			int numRounds = Firearm.Magazine.m_numRounds;
			if (_lastKnownRounds > 0 && numRounds == 0 && !_hasResidualLink)
			{
				SpawnResidualLink();
			}
			_lastKnownRounds = numRounds;
		}
		if (!_hasResidualLink)
		{
			return;
		}
		_cleanupTimer += Time.deltaTime;
		if ((Object)(object)_spawnedLink == (Object)null || _cleanupTimer > AutoCleanupTime)
		{
			ClearResidualLink();
			return;
		}
		if ((Object)(object)Firearm != (Object)null && (Object)(object)((FVRPhysicalObject)Firearm).RootRigidbody != (Object)null)
		{
			Vector3 angularVelocity = ((FVRPhysicalObject)Firearm).RootRigidbody.angularVelocity;
			if (((Vector3)(ref angularVelocity)).magnitude > ShakeClearAngularVelocity)
			{
				ClearResidualLink();
			}
		}
		if ((Object)(object)FeedTray != (Object)null)
		{
			float num = 0f;
			switch (FeedTrayClearAxis)
			{
			case Axis.X:
				num = Mathf.Abs(Mathf.DeltaAngle(FeedTray.localEulerAngles.x, 0f));
				break;
			case Axis.Y:
				num = Mathf.Abs(Mathf.DeltaAngle(FeedTray.localEulerAngles.y, 0f));
				break;
			case Axis.Z:
				num = Mathf.Abs(Mathf.DeltaAngle(FeedTray.localEulerAngles.z, 0f));
				break;
			}
			if (num > _currentClearAngle && num < 180f)
			{
				ClearResidualLink();
			}
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		if (_hasResidualLink)
		{
			FVRViveHand componentInParent = ((Component)other).GetComponentInParent<FVRViveHand>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)_linkRB != (Object)null)
			{
				Vector3 normalized = ((Vector3)(ref componentInParent.Input.VelLinearWorld)).normalized;
				_linkRB.AddForce(normalized * 5f, (ForceMode)1);
				_linkRB.AddTorque(Random.onUnitSphere * 2f, (ForceMode)1);
				ClearResidualLinkPhysicsDelayed(5f);
			}
		}
	}

	public void SpawnResidualLink()
	{
		//IL_002f: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		if (!_hasResidualLink && !((Object)(object)BeltLinkPrefab == (Object)null))
		{
			_spawnedLink = Object.Instantiate<GameObject>(BeltLinkPrefab, FeedTraySpawnPoint.position, FeedTraySpawnPoint.rotation);
			_linkRB = _spawnedLink.GetComponent<Rigidbody>();
			if ((Object)(object)_linkRB != (Object)null && (Object)(object)((FVRPhysicalObject)Firearm).RootRigidbody != (Object)null)
			{
				_linkRB.velocity = ((FVRPhysicalObject)Firearm).RootRigidbody.velocity;
			}
			_cleanupTimer = 0f;
			_hasResidualLink = true;
			_currentClearAngle = Random.Range(FeedTrayClearAngleMin, FeedTrayClearAngleMax);
			Firearm.HasBelt = false;
			Firearm.ConnectedToBox = false;
		}
	}

	private void ClearResidualLinkPhysicsDelayed(float delay)
	{
		if ((Object)(object)_spawnedLink != (Object)null)
		{
			Object.Destroy((Object)(object)_spawnedLink, delay);
		}
		_spawnedLink = null;
		_linkRB = null;
		_hasResidualLink = false;
		_cleanupTimer = 0f;
	}

	private void ClearResidualLink()
	{
		if ((Object)(object)_spawnedLink != (Object)null)
		{
			Object.Destroy((Object)(object)_spawnedLink);
		}
		_spawnedLink = null;
		_linkRB = null;
		_hasResidualLink = false;
		_cleanupTimer = 0f;
	}

	public bool CanAcceptNewBelt()
	{
		return !_hasResidualLink;
	}
}
public class SAFA_BoltController : MonoBehaviour
{
	private enum BoltState
	{
		semiAuto,
		fullAuto,
		safe,
		uncocked
	}

	public OpenBoltReceiver weapon;

	public int semiAuto;

	public int fullAuto;

	public Transform closedBoltSearPosition;

	private OpenBoltReceiverBolt bolt;

	private Transform sear;

	private Vector3 uncockedPos;

	private Transform openBoltSearPosition;

	private string lastMessage = "";

	private bool waitForShot;

	private BoltState boltState;

	public void Start()
	{
		//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)
		bolt = weapon.Bolt;
		sear = weapon.Bolt.Point_Bolt_LockPoint;
		uncockedPos = weapon.Bolt.Point_Bolt_Forward.localPosition;
		openBoltSearPosition = sear;
	}

	public void Update()
	{
		//IL_000c: 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_003a: 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_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		if (((Component)bolt).transform.localPosition == uncockedPos)
		{
			boltState = BoltState.uncocked;
		}
		else if (((Component)bolt).transform.localPosition == openBoltSearPosition.localPosition)
		{
			boltState = BoltState.fullAuto;
		}
		else if (((Component)bolt).transform.localPosition == closedBoltSearPosition.localPosition)
		{
			boltState = BoltState.semiAuto;
		}
		if (boltState == BoltState.uncocked && weapon.m_fireSelectorMode == fullAuto)
		{
			bolt.m_boltZ_lock = openBoltSearPosition.localPosition.z;
		}
		else if (boltState == BoltState.uncocked && weapon.m_fireSelectorMode == semiAuto)
		{
			bolt.m_boltZ_lock = closedBoltSearPosition.localPosition.z;
		}
		else if (boltState == BoltState.semiAuto && weapon.m_fireSelectorMode == fullAuto)
		{
			waitForShot = true;
		}
		else if (boltState == BoltState.fullAuto && weapon.m_fireSelectorMode == semiAuto)
		{
			bolt.m_boltZ_lock = closedBoltSearPosition.localPosition.z;
			bolt.LastPos = (BoltPos)4;
			bolt.CurPos = (BoltPos)3;
		}
		if (waitForShot && (int)bolt.LastPos == 0)
		{
			bolt.m_boltZ_lock = openBoltSearPosition.localPosition.z;
			waitForShot = false;
		}
	}

	public void DebugOnce(string message)
	{
		if (message != lastMessage)
		{
			Debug.Log((object)message);
		}
		lastMessage = message;
	}
}
public class EjectMagRounds : FVRInteractiveObject
{
	[Header("References")]
	public FVRFireArm firearm;

	public FVRFireArmMagazine targetMagazine;

	[Header("Ejection")]
	public Transform ejectOrigin;

	public float ejectionForce = 1f;

	[Range(0f, 45f)]
	public float spreadAngle = 8f;

	[Tooltip("Time in seconds between each spawned round. 0 => all spawn in the same frame (but still yields once per round).")]
	public float perRoundSpawnDelay = 0.06f;

	[Header("Direction override")]
	[Tooltip("If non-zero, uses this vector as the base ejection direction. If UseLocalDirection = true, this vector is interpreted in the ejectOrigin's local space (or firearm/local if ejectOrigin is null).")]
	public Vector3 ejectDirection = Vector3.zero;

	public bool UseLocalEjectDirection = true;

	[Header("Audio")]
	public AudioEvent AudEvent_ButtonPress;

	public AudioEvent AudEvent_RoundEject;

	private bool m_isEjecting;

	[Header("Auto-assign")]
	public int magazineIndex = -1;

	[Header("Button visual (ClosedBolt-style)")]
	[Tooltip("Transform to animate (press/unpress).")]
	public Transform ButtonTransform;

	[Tooltip("Unpressed target vector (local pos or euler depending on interp).")]
	public Vector3 ButtonUnpressed = Vector3.zero;

	[Tooltip("Pressed target vector (local pos or euler depending on interp).")]
	public Vector3 ButtonPressed = new Vector3(0f, 0f, -0.02f);

	public InterpStyle ButtonInterp = (InterpStyle)0;

	[Tooltip("Speed of button return/press interpolation (larger = faster).")]
	public float ButtonAnimSpeed = 12f;

	private bool WasButtonHeldDown;

	private bool m_isAnimating;

	private Vector3 m_animStartPos;

	private Vector3 m_animTargetPos;

	private Quaternion m_animStartRot;

	private Quaternion m_animTargetRot;

	private float m_animT;

	private InterpStyle m_animInterp;

	private Transform m_animTransform;

	public override void Awake()
	{
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_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)
		((FVRInteractiveObject)this).Awake();
		if (!((Object)(object)targetMagazine == (Object)null) || !((Object)(object)firearm != (Object)null))
		{
			return;
		}
		try
		{
			FVRFireArmMagazine[] componentsInChildren = ((Component)firearm).GetComponentsInChildren<FVRFireArmMagazine>(true);
			if (componentsInChildren == null || componentsInChildren.Length <= 0)
			{
				return;
			}
			if (magazineIndex >= 0 && magazineIndex < componentsInChildren.Length)
			{
				targetMagazine = componentsInChildren[magazineIndex];
				return;
			}
			Vector3 val = ((!((Object)(object)ejectOrigin != (Object)null)) ? ((Component)this).transform.position : ejectOrigin.position);
			float num = float.MaxValue;
			int num2 = 0;
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Vector3 val2 = ((Component)componentsInChildren[i]).transform.position - val;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					num2 = i;
				}
			}
			targetMagazine = componentsInChildren[num2];
		}
		catch
		{
		}
	}

	public override void SimpleInteraction(FVRViveHand hand)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).SimpleInteraction(hand);
		if ((Object)(object)firearm == (Object)null && (Object)(object)targetMagazine == (Object)null)
		{
			return;
		}
		if (AudEvent_ButtonPress != null)
		{
			SM.PlayGenericSound(AudEvent_ButtonPress, ((Component)this).transform.position);
		}
		else
		{
			try
			{
				if ((Object)(object)firearm != (Object)null)
				{
					firearm.PlayAudioEvent((FirearmAudioEventType)29, 1f);
				}
			}
			catch
			{
			}
		}
		if (!m_isEjecting)
		{
			((MonoBehaviour)this).StartCoroutine(EjectAllRoundsCoroutine());
		}
	}

	private IEnumerator EjectAllRoundsCoroutine()
	{
		m_isEjecting = true;
		if ((Object)(object)firearm == (Object)null && (Object)(object)targetMagazine == (Object)null)
		{
			m_isEjecting = false;
			yield break;
		}
		FVRFireArmMagazine mag = targetMagazine;
		if ((Object)(object)mag == (Object)null && (Object)(object)firearm != (Object)null)
		{
			try
			{
				mag = firearm.Magazine;
			}
			catch
			{
				mag = null;
			}
		}
		if ((Object)(object)mag == (Object)null)
		{
			m_isEjecting = false;
			yield break;
		}
		while (mag.HasARound())
		{
			GameObject prefab = null;
			try
			{
				prefab = mag.RemoveRound(false);
			}
			catch
			{
				try
				{
					mag.RemoveRound();
				}
				catch
				{
				}
			}
			if ((Object)(object)prefab != (Object)null)
			{
				Vector3 val;
				Quaternion val2;
				if ((Object)(object)ejectOrigin != (Object)null)
				{
					val = ejectOrigin.position;
					val2 = ejectOrigin.rotation;
				}
				else
				{
					val = ((!((Object)(object)firearm != (Object)null)) ? (((Component)this).transform.position + ((Component)this).transform.forward * 0.12f) : (((Component)firearm).transform.position + ((Component)firearm).transform.forward * 0.12f));
					val2 = Quaternion.LookRotation((!((Object)(object)firearm != (Object)null)) ? ((Component)this).transform.forward : ((Component)firearm).transform.forward);
				}
				GameObject val3 = Object.Instantiate<GameObject>(prefab, val, val2);
				FVRFireArmRound component = val3.GetComponent<FVRFireArmRound>();
				if ((Object)(object)component != (Object)null)
				{
					try
					{
						((FVRPhysicalObject)component).SetIFF(GM.CurrentPlayerBody.GetPlayerIFF());
					}
					catch
					{
					}
				}
				Rigidbody component2 = val3.GetComponent<Rigidbody>();
				if ((Object)(object)component2 != (Object)null)
				{
					Transform val4;
					Vector3 val5;
					if (ejectDirection != Vector3.zero)
					{
						if (UseLocalEjectDirection)
						{
							val4 = (((Object)(object)ejectOrigin != (Object)null) ? ejectOrigin : ((!((Object)(object)firearm != (Object)null)) ? ((Component)this).transform : ((Component)firearm).transform));
							val5 = val4.TransformDirection(((Vector3)(ref ejectDirection)).normalized);
						}
						else
						{
							val5 = ((Vector3)(ref ejectDirection)).normalized;
							val4 = (((Object)(object)ejectOrigin != (Object)null) ? ejectOrigin : ((!((Object)(object)firearm != (Object)null)) ? ((Component)this).transform : ((Component)firearm).transform));
						}
					}
					else
					{
						val4 = (((Object)(object)ejectOrigin != (Object)null) ? ejectOrigin : ((!((Object)(object)firearm != (Object)null)) ? ((Component)this).transform : ((Component)firearm).transform));
						val5 = val4.forward;
					}
					Vector3 val6 = val5;
					val6 = Quaternion.AngleAxis(Random.Range(0f - spreadAngle, spreadAngle), val4.up) * val6;
					val6 = Quaternion.AngleAxis(Random.Range(0f - spreadAngle, spreadAngle), val4.right) * val6;
					component2.AddForce(((Vector3)(ref val6)).normalized * ejectionForce, (ForceMode)2);
				}
				if (AudEvent_RoundEject != null)
				{
					SM.PlayGenericSound(AudEvent_RoundEject, val);
				}
				else
				{
					try
					{
						if ((Object)(object)firearm != (Object)null)
						{
							firearm.PlayAudioEvent((FirearmAudioEventType)29, 1f);
						}
					}
					catch
					{
					}
				}
			}
			if (perRoundSpawnDelay > 0f)
			{
				yield return (object)new WaitForSeconds(perRoundSpawnDelay);
			}
			else
			{
				yield return null;
			}
		}
		m_isEjecting = false;
	}

	private void SetAnimatedComponent(Transform t, Vector3 targetLocal, InterpStyle interp)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Invalid comparison between Unknown and I4
		//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_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_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)t == (Object)null))
		{
			m_animTransform = t;
			m_animInterp = interp;
			m_isAnimating = true;
			m_animT = 0f;
			if ((int)interp == 1)
			{
				m_animStartRot = t.localRotation;
				m_animTargetRot = Quaternion.Euler(targetLocal);
			}
			else
			{
				m_animStartPos = t.localPosition;
				m_animTargetPos = targetLocal;
			}
		}
	}

	private void Update()
	{
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Invalid comparison between Unknown and I4
		//IL_0045: 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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: 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_0052: 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_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Invalid comparison between Unknown and I4
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ButtonTransform != (Object)null)
		{
			bool isEjecting = m_isEjecting;
			if (WasButtonHeldDown != isEjecting)
			{
				WasButtonHeldDown = isEjecting;
				Vector3 targetLocal = ((!WasButtonHeldDown) ? ButtonUnpressed : ButtonPressed);
				SetAnimatedComponent(ButtonTransform, targetLocal, ButtonInterp);
			}
		}
		if (!m_isAnimating || !((Object)(object)m_animTransform != (Object)null))
		{
			return;
		}
		m_animT += Time.deltaTime * ButtonAnimSpeed;
		float num = Mathf.Clamp01(m_animT);
		if ((int)m_animInterp == 1)
		{
			m_animTransform.localRotation = Quaternion.Slerp(m_animStartRot, m_animTargetRot, num);
		}
		else
		{
			m_animTransform.localPosition = Vector3.Lerp(m_animStartPos, m_animTargetPos, num);
		}
		if (num >= 1f - Mathf.Epsilon)
		{
			if ((int)m_animInterp == 1)
			{
				m_animTransform.localRotation = m_animTargetRot;
			}
			else
			{
				m_animTransform.localPosition = m_animTargetPos;
			}
			m_isAnimating = false;
			m_animTransform = null;
		}
	}
}
public class ShotgunMagSwitcher : FVRInteractiveObject
{
	public enum MagState
	{
		LeftMag,
		NoMag,
		RightMag
	}

	[Serializable]
	public class FauxMag
	{
		public FVRFireArmMagazine Mag;

		public Transform LowerPathForward;

		public Transform LowerPathRearward;

		public Transform TrigPoint;
	}

	[Serializable]
	public enum ManipulationType
	{
		None,
		Rotation,
		Translation
	}

	[Serializable]
	public enum Axis
	{
		X,
		Y,
		Z
	}

	[Serializable]
	public class SideSwitchAction
	{
		public ManipulationType Type = ManipulationType.Rotation;

		public Axis Axis = Axis.Z;

		[Tooltip("Degrees for Rotation; units for Translation.")]
		public float Value = 0f;

		[Tooltip("Apply to local space (true) or world space (false).")]
		public bool UseLocal = true;
	}

	public TubeFedShotgun Shotgun;

	public FVRFireArmMagazineReloadTrigger Trig;

	public Transform Switch;

	public List<FauxMag> FauxMags;

	public MagState CurState;

	public SideSwitchAction LeftAction = new SideSwitchAction
	{
		Type = ManipulationType.Rotation,
		Axis = Axis.Z,
		Value = -16f,
		UseLocal = true
	};

	public SideSwitchAction RightAction = new SideSwitchAction
	{
		Type = ManipulationType.Rotation,
		Axis = Axis.Z,
		Value = 16f,
		UseLocal = true
	};

	public override void SimpleInteraction(FVRViveHand hand)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		((FVRInteractiveObject)this).SimpleInteraction(hand);
		if (Shotgun.CanCycleMagState())
		{
			CycleSwitch();
			((FVRFireArm)Shotgun).PlayAudioAsHandling(((FVRFireArm)Shotgun).AudioClipSet.Safety, ((Component)this).transform.position);
		}
	}

	private void Awake()
	{
		if (CurState == MagState.NoMag)
		{
			CurState = MagState.LeftMag;
		}
		UpdateState();
	}

	private void CycleSwitch()
	{
		if (CurState == MagState.LeftMag)
		{
			CurState = MagState.RightMag;
		}
		else
		{
			CurState = MagState.LeftMag;
		}
		UpdateState();
	}

	private void UpdateState()
	{
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Shotgun == (Object)null)
		{
			Debug.LogWarning((object)"[ShotgunMagSwitcher] Shotgun reference is null. Assign in Inspector.");
			return;
		}
		if ((Object)(object)Trig == (Object)null)
		{
			Debug.LogWarning((object)"[ShotgunMagSwitcher] Trig reference is null. Assign in Inspector.");
			return;
		}
		if (FauxMags == null || FauxMags.Count < 2)
		{
			Debug.LogWarning((object)"[ShotgunMagSwitcher] FauxMags must contain at least 2 entries (left/right).");
			return;
		}
		switch (CurState)
		{
		case MagState.LeftMag:
			if (FauxMags[0] == null || (Object)(object)FauxMags[0].Mag == (Object)null)
			{
				Debug.LogWarning((object)"[ShotgunMagSwitcher] Left FauxMag or its Mag is null.");
				break;
			}
			((FVRFireArm)Shotgun).Magazine = FauxMags[0].Mag;
			Trig.Magazine = FauxMags[0].Mag;
			((Component)Trig).gameObject.SetActive(true);
			if ((Object)(object)FauxMags[0].LowerPathForward != (Object)null)
			{
				Shotgun.RoundPos_LowerPath_Forward.position = FauxMags[0].LowerPathForward.position;
			}
			if ((Object)(object)FauxMags[0].LowerPathRearward != (Object)null)
			{
				Shotgun.RoundPos_LowerPath_Rearward.position = FauxMags[0].LowerPathRearward.position;
			}
			if ((Object)(object)FauxMags[0].TrigPoint != (Object)null)
			{
				((Component)Trig).transform.position = FauxMags[0].TrigPoint.position;
			}
			ApplySideAction(LeftAction);
			break;
		case MagState.NoMag:
			((FVRFireArm)Shotgun).Magazine = null;
			((Component)Trig).gameObject.SetActive(false);
			ApplySideAction(null);
			break;
		case MagState.RightMag:
			if (FauxMags[1] == null || (Object)(object)FauxMags[1].Mag == (Object)null)
			{
				Debug.LogWarning((object)"[ShotgunMagSwitcher] Right FauxMag or its Mag is null.");
				break;
			}
			((FVRFireArm)Shotgun).Magazine = FauxMags[1].Mag;
			Trig.Magazine = FauxMags[1].Mag;
			((Component)Trig).gameObject.SetActive(true);
			if ((Object)(object)FauxMags[1].LowerPathForward != (Object)null)
			{
				Shotgun.RoundPos_LowerPath_Forward.position = FauxMags[1].LowerPathForward.position;
			}
			if ((Object)(object)FauxMags[1].LowerPathRearward != (Object)null)
			{
				Shotgun.RoundPos_LowerPath_Rearward.position = FauxMags[1].LowerPathRearward.position;
			}
			if ((Object)(object)FauxMags[1].TrigPoint != (Object)null)
			{
				((Component)Trig).transform.position = FauxMags[1].TrigPoint.position;
			}
			ApplySideAction(RightAction);
			break;
		}
	}

	private void ApplySideAction(SideSwitchAction action)
	{
		//IL_002f: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: 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_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Switch == (Object)null)
		{
			return;
		}
		if (action == null || action.Type == ManipulationType.None)
		{
			Switch.localEulerAngles = Vector3.zero;
			Switch.localPosition = Vector3.zero;
		}
		else if (action.Type == ManipulationType.Rotation)
		{
			if (action.UseLocal)
			{
				Vector3 localEulerAngles = Switch.localEulerAngles;
				switch (action.Axis)
				{
				case Axis.X:
					localEulerAngles.x = action.Value;
					break;
				case Axis.Y:
					localEulerAngles.y = action.Value;
					break;
				case Axis.Z:
					localEulerAngles.z = action.Value;
					break;
				}
				Switch.localEulerAngles = localEulerAngles;
			}
			else
			{
				Vector3 eulerAngles = Switch.eulerAngles;
				switch (action.Axis)
				{
				case Axis.X:
					eulerAngles.x = action.Value;
					break;
				case Axis.Y:
					eulerAngles.y = action.Value;
					break;
				case Axis.Z:
					eulerAngles.z = action.Value;
					break;
				}
				Switch.eulerAngles = eulerAngles;
			}
		}
		else
		{
			if (action.Type != ManipulationType.Translation)
			{
				return;
			}
			if (action.UseLocal)
			{
				Vector3 localPosition = Switch.localPosition;
				switch (action.Axis)
				{
				case Axis.X:
					localPosition.x = action.Value;
					break;
				case Axis.Y:
					localPosition.y = action.Value;
					break;
				case Axis.Z:
					localPosition.z = action.Value;
					break;
				}
				Switch.localPosition = localPosition;
			}
			else
			{
				Vector3 position = Switch.position;
				switch (action.Axis)
				{
				case Axis.X:
					position.x = action.Value;
					break;
				case Axis.Y:
					position.y = action.Value;
					break;
				case Axis.Z:
					position.z = action.Value;
					break;
				}
				Switch.position = position;
			}
		}
	}
}
public class OpenBoltSafety : OpenBoltSecondarySelectorSwitch
{
	private class BoltGuard
	{
		public OpenBoltReceiverBolt Bolt;

		public FieldInfo FI_m_boltZ_current;

		public FieldInfo FI_m_boltZ_heldTarget;

		public FieldInfo FI_m_curBoltSpeed;

		public FieldInfo FI_m_isChargingHandleHeld;

		public bool IsBlocked;

		public float BlockedZ;
	}

	[Tooltip("When true the selector will prevent bolt Z movement while leaving the bolt component enabled (grabs/sounds still work).")]
	public bool preventBoltMovementWhenSafe = true;

	private readonly List<BoltGuard> _guards = new List<BoltGuard>();

	public void Awake()
	{
		((OpenBoltSecondarySelectorSwitch)this).Awake();
		RefreshGuards();
		UpdateBoltBlockState();
	}

	public override void SimpleInteraction(FVRViveHand hand)
	{
		((OpenBoltSecondarySelectorSwitch)this).SimpleInteraction(hand);
		RefreshGuards();
		UpdateBoltBlockState();
	}

	private void RefreshGuards()
	{
		_guards.Clear();
		OpenBoltReceiver gun = base.Gun;
		if ((Object)(object)gun == (Object)null)
		{
			return;
		}
		OpenBoltReceiverBolt[] componentsInChildren = ((Component)gun).GetComponentsInChildren<OpenBoltReceiverBolt>(true);
		if (componentsInChildren == null || componentsInChildren.Length == 0)
		{
			return;
		}
		OpenBoltReceiverBolt[] array = componentsInChildren;
		foreach (OpenBoltReceiverBolt val in array)
		{
			if (!((Object)(object)val == (Object)null))
			{
				Type type = ((object)val).GetType();
				FieldInfo field = type.GetField("m_boltZ_current", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field2 = type.GetField("m_boltZ_heldTarget", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field3 = type.GetField("m_curBoltSpeed", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field4 = type.GetField("m_isChargingHandleHeld", BindingFlags.Instance | BindingFlags.NonPublic);
				_guards.Add(new BoltGuard
				{
					Bolt = val,
					FI_m_boltZ_current = field,
					FI_m_boltZ_heldTarget = field2,
					FI_m_curBoltSpeed = field3,
					FI_m_isChargingHandleHeld = field4,
					IsBlocked = false,
					BlockedZ = float.NaN
				});
			}
		}
	}

	public void UpdateBoltBlockState()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Invalid comparison between Unknown and I4
		bool flag = false;
		if (base.Modes != null && base.CurModeIndex >= 0 && base.CurModeIndex < base.Modes.Length)
		{
			try
			{
				flag = (int)base.Modes[base.CurModeIndex].ModeType == 0;
			}
			catch
			{
				flag = false;
			}
		}
		if (!preventBoltMovementWhenSafe)
		{
			foreach (BoltGuard guard in _guards)
			{
				if (guard != null)
				{
					guard.IsBlocked = false;
				}
			}
			return;
		}
		if (_guards.Count == 0)
		{
			RefreshGuards();
		}
		if (_guards.Count == 0)
		{
			return;
		}
		foreach (BoltGuard guard2 in _guards)
		{
			if (guard2 == null || (Object)(object)guard2.Bolt == (Object)null)
			{
				continue;
			}
			if (flag)
			{
				if (guard2.IsBlocked)
				{
					continue;
				}
				float num = float.NaN;
				try
				{
					if ((object)guard2.FI_m_boltZ_current != null)
					{
						object value = guard2.FI_m_boltZ_current.GetValue(guard2.Bolt);
						if (value is float)
						{
							num = (float)value;
						}
					}
				}
				catch
				{
					num = float.NaN;
				}
				if (float.IsNaN(num))
				{
					num = ((Component)guard2.Bolt).transform.localPosition.z;
				}
				guard2.BlockedZ = num;
				try
				{
					if ((object)guard2.FI_m_curBoltSpeed != null)
					{
						guard2.FI_m_curBoltSpeed.SetValue(guard2.Bolt, 0f);
					}
				}
				catch
				{
				}
				try
				{
					if ((object)guard2.FI_m_boltZ_heldTarget != null)
					{
						guard2.FI_m_boltZ_heldTarget.SetValue(guard2.Bolt, guard2.BlockedZ);
					}
				}
				catch
				{
				}
				try
				{
					if ((object)guard2.FI_m_isChargingHandleHeld != null)
					{
						guard2.FI_m_isChargingHandleHeld.SetValue(guard2.Bolt, false);
					}
				}
				catch
				{
				}
				guard2.IsBlocked = true;
			}
			else if (guard2.IsBlocked)
			{
				guard2.IsBlocked = false;
			}
		}
	}

	private void Update()
	{
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		if (!preventBoltMovementWhenSafe || _guards.Count == 0)
		{
			return;
		}
		foreach (BoltGuard guard in _guards)
		{
			if (guard == null || (Object)(object)guard.Bolt == (Object)null || !guard.IsBlocked)
			{
				continue;
			}
			try
			{
				if ((object)guard.FI_m_boltZ_current != null)
				{
					guard.FI_m_boltZ_current.SetValue(guard.Bolt, guard.BlockedZ);
				}
			}
			catch
			{
			}
			try
			{
				if ((object)guard.FI_m_curBoltSpeed != null)
				{
					guard.FI_m_curBoltSpeed.SetValue(guard.Bolt, 0f);
				}
			}
			catch
			{
			}
			try
			{
				if ((object)guard.FI_m_boltZ_heldTarget != null)
				{
					guard.FI_m_boltZ_heldTarget.SetValue(guard.Bolt, guard.BlockedZ);
				}
			}
			catch
			{
			}
			try
			{
				Transform transform = ((Component)guard.Bolt).transform;
				Vector3 localPosition = transform.localPosition;
				if (Mathf.Abs(localPosition.z - guard.BlockedZ) > Mathf.Epsilon)
				{
					transform.localPosition = new Vector3(localPosition.x, localPosition.y, guard.BlockedZ);
				}
			}
			catch
			{
			}
		}
	}

	private void LateUpdate()
	{
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		if (!preventBoltMovementWhenSafe || _guards.Count == 0)
		{
			return;
		}
		foreach (BoltGuard guard in _guards)
		{
			if (guard == null || (Object)(object)guard.Bolt == (Object)null || !guard.IsBlocked)
			{
				continue;
			}
			try
			{
				if ((object)guard.FI_m_boltZ_current != null)
				{
					guard.FI_m_boltZ_current.SetValue(guard.Bolt, guard.BlockedZ);
				}
			}
			catch
			{
			}
			try
			{
				if ((object)guard.FI_m_curBoltSpeed != null)
				{
					guard.FI_m_curBoltSpeed.SetValue(guard.Bolt, 0f);
				}
			}
			catch
			{
			}
			try
			{
				Transform transform = ((Component)guard.Bolt).transform;
				Vector3 localPosition = transform.localPosition;
				if (Mathf.Abs(localPosition.z - guard.BlockedZ) > Mathf.Epsilon)
				{
					transform.localPosition = new Vector3(localPosition.x, localPosition.y, guard.BlockedZ);
				}
			}
			catch
			{
			}
		}
	}
}
namespace Volks.CZ52_Tokarev;

[BepInPlugin("Volks.CZ52_Tokarev", "CZ52_Tokarev", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class CZ52_TokarevPlugin : BaseUnityPlugin
{
	private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	internal static ManualLogSource Logger;

	private void Awake()
	{
		Logger = ((BaseUnityPlugin)this).Logger;
		LoadAssets();
	}

	private void LoadAssets()
	{
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Volks.CZ52_Tokarev");
		OtherLoader.RegisterDirectLoad(BasePath, "Volks.CZ52_Tokarev", "", "", "cz52_tokarev", "");
	}
}
public class ThermalOverlayWithZoomDisplay : PIPScopeGUIDrawer
{
	public PIPScopeController ScopeController;

	public Canvas OverlayCanvas;

	public Text ZoomText;

	public Material OverlayMaterial;

	public Texture2D OverlayTexture;

	public Color OverlayColor = Color.white;

	public float UpdateInterval = 0.1f;

	private float nextUpdateTime = 0f;

	private int lastThermalZoomIndex = -1;

	public override void DrawGUI(PIPScope scope, Canvas canvas, Vector2 canvasSize)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		if (scope.enableThermal)
		{
			if ((Object)(object)OverlayMaterial != (Object)null && (Object)(object)OverlayTexture != (Object)null)
			{
				OverlayMaterial.mainTexture = (Texture)(object)OverlayTexture;
				OverlayMaterial.color = OverlayColor;
				OverlayMaterial.SetPass(0);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(0f, 0f, canvasSize.x, canvasSize.y);
				GUI.DrawTexture(val, (Texture)(object)OverlayTexture);
			}
			UpdateZoomLevelDisplay();
		}
	}

	private void UpdateZoomLevelDisplay()
	{
		if (Time.time < nextUpdateTime)
		{
			return;
		}
		nextUpdateTime = Time.time + UpdateInterval;
		if ((Object)(object)ScopeController == (Object)null || (Object)(object)ZoomText == (Object)null)
		{
			Debug.LogWarning((object)"ThermalOverlayWithZoomDisplay: Missing necessary references!");
			return;
		}
		int thermalZoomIndex = ScopeController.ThermalZoomIndex;
		if (lastThermalZoomIndex != thermalZoomIndex)
		{
			lastThermalZoomIndex = thermalZoomIndex;
			if (ScopeController.ThermalDigitalZoomMagnifications != null && thermalZoomIndex >= 0 && thermalZoomIndex < ScopeController.ThermalDigitalZoomMagnifications.Count)
			{
				float num = ScopeController.ThermalDigitalZoomMagnifications[thermalZoomIndex];
				ZoomText.text = $"Zoom Level: {num:F1}x";
			}
			else
			{
				ZoomText.text = "Zoom Level: N/A";
			}
		}
	}
}
public class BeltPhysic : MonoBehaviour
{
	[Header("Belt Settings")]
	public GameObject BeltLinkPrefab;

	public int MaxLinks = 50;

	public float LinkSpacing = 0.04f;

	public Transform BeltStart;

	public float GravityStrength = 9.8f;

	public int ConstraintIterations = 8;

	public float MaxBendAngle = 45f;

	public float SpacingStiffness = 0.6f;

	public float BendStiffness = 0.6f;

	public float MaxTwistAngle = 120f;

	public float VelocityDamping = 0.9f;

	public bool ConstrainToBeltPlane = true;

	[Header("Roll Settings")]
	public bool LockRollToBeltUp = false;

	public bool UseBeltRightAsUp = true;

	[Header("Feed Path")]
	public Transform[] FeedPathPoints;

	public float FeedPathStiffness = 1f;

	[Header("Link Visual Offsets")]
	[Tooltip("Offset from the link's pivot to the point that should connect to the next round.")]
	public Vector3 LinkPositionOffset = Vector3.zero;

	[Tooltip("Euler rotation offset for each link.")]
	public Vector3 LinkRotationOffset = Vector3.zero;

	[Header("Link Collision")]
	public float LinkCollisionRadius = 0.015f;

	public LayerMask CollisionMask = LayerMask.op_Implicit(-1);

	public float CollisionPushStrength = 1f;

	[Header("Magazine Reference (optional)")]
	public FVRFireArmMagazine Magazine;

	public bool AutoSyncMagazine = true;

	public bool ClampToMagazineCapacity = true;

	public int ManualRounds = 0;

	[Header("Anchoring")]
	public Transform StartAnchorOverride;

	[Header("Delinker Sync (optional)")]
	[Tooltip("Assign the firearm's delinker emitter transform here.")]
	public Transform DelinkerEmitterTransform;

	[Tooltip("Particle system to emit a fake delinker link.")]
	public ParticleSystem FakeDelinkerParticles;

	[Header("Debug")]
	[Tooltip("Toggle runtime Scene-view gizmos for belt links (requires Gizmos enabled).")]
	public bool ShowDebugGizmos = true;

	public Color GizmoAnchorColor = Color.green;

	public Color GizmoLinkColor = Color.cyan;

	public Color GizmoLineColor = Color.gray;

	public Color GizmoUpColor = Color.yellow;

	public Color GizmoVelocityColor = Color.magenta;

	public float GizmoSphereSize = 0.012f;

	public float GizmoUpLength = 0.03f;

	public float GizmoVelocityScale = 0.05f;

	private readonly List<GameObject> _linkPool = new List<GameObject>();

	private readonly List<Vector3> _positions = new List<Vector3>();

	private readonly List<Vector3> _prevPositions = new List<Vector3>();

	private readonly List<Vector3> _upVectors = new List<Vector3>();

	private int _currentRounds = 0;

	private bool _isBeltSeated = false;

	private Vector3 _lastAnchorPos;

	private Quaternion _lastAnchorRot;

	private void Awake()
	{
		//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_0054: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < MaxLinks; i++)
		{
			GameObject val = Object.Instantiate<GameObject>(BeltLinkPrefab, ((Component)this).transform);
			val.SetActive(false);
			_linkPool.Add(val);
			_positions.Add(Vector3.zero);
			_prevPositions.Add(Vector3.zero);
			_upVectors.Add(Vector3.up);
		}
	}

	private void Start()
	{
		SeatBelt();
	}

	private void FixedUpdate()
	{
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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_00b4: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: 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)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		if (!_isBeltSeated)
		{
			return;
		}
		Transform val = ((!((Object)(object)StartAnchorOverride != (Object)null)) ? BeltStart : StartAnchorOverride);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogWarning((object)"[BeltPhysic] start anchor is NULL — assign BeltStart or StartAnchorOverride.");
			return;
		}
		if (_currentRounds > 0)
		{
			if (_lastAnchorRot == Quaternion.identity && _lastAnchorPos == Vector3.zero)
			{
				_lastAnchorPos = val.position;
				_lastAnchorRot = val.rotation;
			}
			else
			{
				Vector3 lastAnchorPos = _lastAnchorPos;
				Quaternion lastAnchorRot = _lastAnchorRot;
				Vector3 position = val.position;
				Quaternion rotation = val.rotation;
				Quaternion val2 = rotation * Quaternion.Inverse(lastAnchorRot);
				Vector3 val3 = position - lastAnchorPos;
				for (int i = 0; i < _currentRounds; i++)
				{
					Vector3 val4 = _positions[i] - lastAnchorPos;
					_positions[i] = position + val2 * val4;
					Vector3 val5 = _prevPositions[i] - lastAnchorPos;
					_prevPositions[i] = position + val2 * val5;
					List<Vector3> upVectors = _upVectors;
					int index = i;
					Vector3 val6 = val2 * _upVectors[i];
					upVectors[index] = ((Vector3)(ref val6)).normalized;
				}
				_lastAnchorPos = position;
				_lastAnchorRot = rotation;
			}
		}
		Debug.DrawLine(val.position, val.position + val.forward * 0.25f, Color.green, Time.fixedDeltaTime);
		Debug.DrawLine(val.position, val.position + val.up * 0.25f, Color.yellow, Time.fixedDeltaTime);
		int currentRoundCount = GetCurrentRoundCount();
		if (currentRoundCount != _currentRounds)
		{
			Debug.LogFormat("[BeltPhysic] rounds changed {0} -> {1}", new object[2] { _currentRounds, currentRoundCount });
			int currentRounds = _currentRounds;
			SetRounds(currentRoundCount);
			if (currentRoundCount < currentRounds)
			{
				int num = currentRounds - currentRoundCount;
				for (int j = 0; j < num; j++)
				{
					EmitFakeDelinker();
				}
			}
		}
		SimulateChainPhysics(val.position);
		for (int k = 0; k < Mathf.Min(_currentRounds, 8); k++)
		{
			Debug.DrawLine(_positions[k], _positions[k] + Vector3.up * 0.02f, Color.cyan, Time.fixedDeltaTime);
		}
		UpdateBeltDisplay();
		if (_currentRounds == 0)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}

	private int GetCurrentRoundCount()
	{
		if (AutoSyncMagazine && (Object)(object)Magazine != (Object)null)
		{
			int num = Magazine.m_numRounds;
			if (ClampToMagazineCapacity)
			{
				num = Mathf.Min(num, Magazine.m_capacity);
			}
			return num;
		}
		return ManualRounds;
	}

	public void SetRounds(int count)
	{
		//IL_0066: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_009c: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((!((Object)(object)StartAnchorOverride != (Object)null)) ? BeltStart : StartAnchorOverride);
		if (!((Object)(object)val == (Object)null))
		{
			int currentRounds = _currentRounds;
			_currentRounds = Mathf.Clamp(count, 0, MaxLinks);
			Vector3 value = ((!UseBeltRightAsUp) ? val.up : val.right);
			for (int i = currentRounds; i < _currentRounds; i++)
			{
				Vector3 value2 = val.position + val.forward * ((float)i * LinkSpacing);
				_positions[i] = value2;
				_prevPositions[i] = value2;
				_upVectors[i] = value;
			}
			_lastAnchorPos = val.position;
			_lastAnchorRot = val.rotation;
		}
	}

	private void SimulateChainPhysics(Vector3 anchorPos)
	{
		//IL_0007: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0061: 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_0064: 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_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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: 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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0504: Unknown result type (might be due to invalid IL or missing references)
		//IL_050c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0511: Unknown result type (might be due to invalid IL or missing references)
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0480: Unknown result type (might be due to invalid IL or missing references)
		//IL_0485: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0531: Unknown result type (might be due to invalid IL or missing references)
		//IL_0536: Unknown result type (might be due to invalid IL or missing references)
		//IL_0538: Unknown result type (might be due to invalid IL or missing references)
		//IL_053d: Unknown result type (might be due to invalid IL or missing references)
		//IL_053f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0541: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Unknown result type (might be due to invalid IL or missing references)
		//IL_054c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0555: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: Unknown result type (might be due to invalid IL or missing references)
		//IL_0584: Unknown result type (might be due to invalid IL or missing references)
		//IL_0586: Unknown result type (might be due to invalid IL or missing references)
		//IL_058a: Unknown result type (might be due to invalid IL or missing references)
		//IL_058f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0594: Unknown result type (might be due to invalid IL or missing references)
		//IL_0598: Unknown result type (might be due to invalid IL or missing references)
		//IL_059d: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_049d: Unknown result type (might be due to invalid IL or missing references)
		//IL_049e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_038a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		//IL_039e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: 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_0205: 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_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: 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_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_040a: 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_0411: Unknown result type (might be due to invalid IL or missing references)
		//IL_0413: Unknown result type (might be due to invalid IL or missing references)
		//IL_041e: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		float fixedDeltaTime = Time.fixedDeltaTime;
		Vector3 val = Vector3.down * GravityStrength;
		for (int i = 0; i < _currentRounds; i++)
		{
			if (i == 0)
			{
				_positions[0] = anchorPos;
				_prevPositions[0] = anchorPos;
				continue;
			}
			Vector3 val2 = _positions[i];
			Vector3 val3 = _prevPositions[i];
			Vector3 val4 = (val2 - val3) * VelocityDamping;
			Vector3 value = val2 + val4 + val * fixedDeltaTime * fixedDeltaTime;
			_prevPositions[i] = val2;
			_positions[i] = value;
		}
		for (int j = 0; j < ConstraintIterations; j++)
		{
			if (_currentRounds > 0)
			{
				_positions[0] = anchorPos;
			}
			if (FeedPathPoints != null && FeedPathPoints.Length > 0)
			{
				if (FeedPathPoints.Length == 1)
				{
					Transform val5 = FeedPathPoints[0];
					Vector3 val6 = ((!((Object)(object)BeltStart != (Object)null)) ? val5.forward : BeltStart.forward);
					for (int k = 0; k < _currentRounds; k++)
					{
						Vector3 val7 = val5.position + val6 * ((float)k * LinkSpacing);
						Vector3 val8 = val7 - _positions[k];
						List<Vector3> positions;
						int index;
						(positions = _positions)[index = k] = positions[index] + val8 * FeedPathStiffness * 0.1f;
					}
				}
				else
				{
					for (int l = 0; l < _currentRounds; l++)
					{
						float t = (float)l / (float)Mathf.Max(_currentRounds - 1, 1);
						Vector3 splinePosition = GetSplinePosition(t);
						Vector3 val9 = splinePosition - _positions[l];
						List<Vector3> positions;
						int index2;
						(positions = _positions)[index2 = l] = positions[index2] + val9 * FeedPathStiffness * 0.1f;
					}
				}
			}
			for (int m = 1; m < _currentRounds; m++)
			{
				Vector3 val10 = _positions[m] - _positions[m - 1];
				float magnitude = ((Vector3)(ref val10)).magnitude;
				if (magnitude > 0f)
				{
					float num = magnitude - LinkSpacing;
					Vector3 val11 = ((Vector3)(ref val10)).normalized * (num * 0.5f * SpacingStiffness);
					if (m == 1)
					{
						List<Vector3> positions;
						int index3;
						(positions = _positions)[index3 = m] = positions[index3] - val11 * 2f;
					}
					else
					{
						int index4;
						List<Vector3> positions;
						(positions = _positions)[index4 = m] = positions[index4] - val11;
						int index5;
						(positions = _positions)[index5 = m - 1] = positions[index5] + val11;
					}
				}
				if (m > 1)
				{
					Vector3 val12 = _positions[m - 1] - _positions[m - 2];
					Vector3 normalized = ((Vector3)(ref val12)).normalized;
					Vector3 val13 = _positions[m] - _positions[m - 1];
					Vector3 normalized2 = ((Vector3)(ref val13)).normalized;
					float num2 = Vector3.Angle(normalized, normalized2);
					if (num2 > MaxBendAngle)
					{
						Vector3 val14 = Vector3.Cross(normalized, normalized2);
						Vector3 normalized3 = ((Vector3)(ref val14)).normalized;
						float num3 = (num2 - MaxBendAngle) * BendStiffness;
						Quaternion val15 = Quaternion.AngleAxis(num3, normalized3);
						_positions[m] = _positions[m - 1] + val15 * normalized * LinkSpacing;
					}
				}
			}
		}
		ResolveCollisions();
		if (ConstrainToBeltPlane && (Object)(object)BeltStart != (Object)null)
		{
			Vector3 up = BeltStart.up;
			for (int n = 0; n < _currentRounds; n++)
			{
				Vector3 val16 = _positions[n] - anchorPos;
				Vector3 val17 = Vector3.ProjectOnPlane(val16, up);
				_positions[n] = anchorPos + val17;
			}
		}
		if ((Object)(object)BeltStart != (Object)null)
		{
			Vector3 position = BeltStart.position;
			Vector3 forward = BeltStart.forward;
			Vector3 right = BeltStart.right;
			Vector3 up2 = BeltStart.up;
			for (int num4 = 0; num4 < _currentRounds; num4++)
			{
				Vector3 val18 = _positions[num4] - position;
				float num5 = Vector3.Dot(val18, forward);
				float num6 = Vector3.Dot(val18, right);
				float num7 = Vector3.Dot(val18, up2);
				float num8 = (float)num4 * LinkSpacing;
				float num9 = Mathf.Lerp(num5, num8, 0.25f);
				_positions[num4] = position + right * num6 + up2 * num7 + forward * num9;
			}
		}
	}

	private Vector3 GetSplinePosition(float t)
	{
		//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_01c5: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: 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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: 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_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: 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_01a2: 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_01b0: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		if (FeedPathPoints == null || FeedPathPoints.Length == 0)
		{
			return Vector3.zero;
		}
		if (FeedPathPoints.Length == 1)
		{
			return FeedPathPoints[0].position;
		}
		if (FeedPathPoints.Length == 2)
		{
			return Vector3.Lerp(FeedPathPoints[0].position, FeedPathPoints[1].position, t);
		}
		int num = FeedPathPoints.Length;
		int num2 = Mathf.FloorToInt(t * (float)(num - 1));
		int num3 = Mathf.Min(num2 + 1, num - 1);
		int num4 = Mathf.Min(num2 + 2, num - 1);
		int num5 = Mathf.Min(num2 + 3, num - 1);
		Vector3 position = FeedPathPoints[num2].position;
		Vector3 position2 = FeedPathPoints[num3].position;
		Vector3 position3 = FeedPathPoints[num4].position;
		Vector3 position4 = FeedPathPoints[num5].position;
		float num6 = t * (float)(num - 1) - (float)num2;
		return 0.5f * (2f * position2 + (-position + position3) * num6 + (2f * position - 5f * position2 + 4f * position3 - position4) * num6 * num6 + (-position + 3f * position2 - 3f * position3 + position4) * num6 * num6 * num6);
	}

	private void ResolveCollisions()
	{
		//IL_0010: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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)
		//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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < _currentRounds; i++)
		{
			Collider[] array = Physics.OverlapSphere(_positions[i], LinkCollisionRadius, LayerMask.op_Implicit(CollisionMask), (QueryTriggerInteraction)1);
			foreach (Collider val in array)
			{
				Vector3 val2 = val.ClosestPoint(_positions[i]);
				Vector3 val3 = _positions[i] - val2;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (magnitude < LinkCollisionRadius)
				{
					if (magnitude > 0f)
					{
						float num = (LinkCollisionRadius - magnitude) * CollisionPushStrength;
						List<Vector3> positions;
						int index;
						(positions = _positions)[index = i] = positions[index] + ((Vector3)(ref val3)).normalized * num;
					}
					else
					{
						List<Vector3> positions;
						int index2;
						(positions = _positions)[index2 = i] = positions[index2] + Vector3.up * (LinkCollisionRadius * CollisionPushStrength);
					}
				}
			}
		}
	}

	private void UpdateBeltDisplay()
	{
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: 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_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: 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_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: 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_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: 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_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03df: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_0422: Unknown result type (might be due to invalid IL or missing references)
		//IL_0427: Unknown result type (might be due to invalid IL or missing references)
		//IL_042a: 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_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: 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_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_039d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or