Decompiled source of HuntBurgess v1.0.3

HuntBurgess.dll

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

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace BitWizrd.HuntBurgess
{
	[BepInPlugin("BitWizrd.HuntBurgess", "HuntBurgess", "1.0.3")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class HuntBurgessPlugin : 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()
		{
			OtherLoader.RegisterDirectLoad(BasePath, "BitWizrd.HuntBurgess", "", "burgess", "", "");
		}
	}
}
public class AudioStopWhenDone : MonoBehaviour
{
	public AudioSource Src;

	public float Delay;

	public float Duration = 1f;

	private void Awake()
	{
		if ((Object)(object)Src == (Object)null)
		{
			Src = ((Component)this).GetComponent<AudioSource>();
		}
	}

	private void OnEnable()
	{
		((MonoBehaviour)this).CancelInvoke();
		if ((Object)(object)Src != (Object)null && Src.loop && !Src.isPlaying)
		{
			Src.Play();
		}
		if (Duration > 0f)
		{
			((MonoBehaviour)this).Invoke("StopLoop", Mathf.Max(0f, Delay) + Duration);
		}
	}

	private void OnDisable()
	{
		((MonoBehaviour)this).CancelInvoke();
	}

	private void StopLoop()
	{
		if ((Object)(object)Src != (Object)null && Src.loop)
		{
			Src.Stop();
		}
		((Behaviour)this).enabled = false;
	}
}
public class AutoDestructWhenDone : MonoBehaviour
{
	[Tooltip("Seconds between checks.")]
	public float PollInterval = 0.5f;

	[Tooltip("Seconds after enabling before the first check, so a delayed start is not mistaken for finished.")]
	public float StartGrace = 1f;

	private ParticleSystem[] m_systems;

	private AudioSource[] m_sources;

	private float m_nextPoll;

	private void OnEnable()
	{
		m_nextPoll = Time.time + Mathf.Max(StartGrace, PollInterval);
	}

	private void Update()
	{
		if (!Application.isPlaying || Time.time < m_nextPoll)
		{
			return;
		}
		m_nextPoll = Time.time + PollInterval;
		if (m_systems == null)
		{
			m_systems = ((Component)this).GetComponentsInChildren<ParticleSystem>(true);
			m_sources = ((Component)this).GetComponentsInChildren<AudioSource>(true);
		}
		for (int i = 0; i < m_systems.Length; i++)
		{
			ParticleSystem val = m_systems[i];
			if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy && val.IsAlive(false))
			{
				return;
			}
		}
		for (int j = 0; j < m_sources.Length; j++)
		{
			AudioSource val2 = m_sources[j];
			if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeInHierarchy && val2.isPlaying)
			{
				return;
			}
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}
}
public class BloodBondSR : MonoBehaviour
{
	private void Awake()
	{
		string name = "Ammo_69_CashMoney_D100(Clone)";
		((Object)((Component)this).gameObject).name = name;
		Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Object)((Component)componentsInChildren[i]).gameObject).name = name;
		}
	}
}
namespace BitWizrd.Shotgun.Burgess
{
	public class BurgessForegrip : FVRAlternateGrip
	{
		[NonSerialized]
		public HingeJoint Hinge;

		[NonSerialized]
		public Rigidbody RB;

		[Header("Unlock Input")]
		[Tooltip("Touchpad deadzone for the latch in non-streamlined mode: how far the thumb must be displaced from centre before a north press counts as deliberate. The direction itself is handled by the north quadrant test in FoldingShotgun.IsFoldUnlatchHeld, so this is purely a magnitude floor. Unused in streamlined mode, where the latch is the BY button.")]
		public float UnlockInputThreshold = 0.1f;

		[Header("Latch Visual")]
		public Transform Latch;

		public Vector3 LatchLockedRotation = Vector3.zero;

		[Tooltip("Local rotation when unlocked (Burgess latch rotates on local Y, negative direction)")]
		public Vector3 LatchUnlockedRotation = new Vector3(0f, -20f, 0f);

		[Header("Secondary Lever (moves in unison with the latch)")]
		public Transform SecondaryLever;

		public Vector3 SecondaryLeverLockedRotation = Vector3.zero;

		[Tooltip("Local rotation when unlocked. The lever arm points the OPPOSITE lateral direction from the latch arm (antiparallel), so the SAME local sign swings both tips the same way (up). Keep the signs matched.")]
		public Vector3 SecondaryLeverUnlockedRotation = new Vector3(0f, -30f, 0f);

		public float LatchSpeed = 12f;

		private FoldingShotgun m_weapon;

		private bool m_isUnlocked;

		private bool m_wasUnlocked;

		private float m_latchLerp;

		private bool m_hasUnlockUpSinceBegin;

		public bool IsUnlocked => m_isUnlocked;

		public override void Awake()
		{
			((FVRAlternateGrip)this).Awake();
			m_weapon = ((Component)this).GetComponentInParent<FoldingShotgun>();
		}

		public override void BeginInteraction(FVRViveHand hand)
		{
			if ((Object)(object)m_weapon != (Object)null && ((FVRPhysicalObject)m_weapon).IsAltHeld && (Object)(object)((FVRInteractiveObject)m_weapon).m_hand != (Object)null && (Object)(object)((FVRInteractiveObject)m_weapon).m_hand != (Object)(object)hand)
			{
				((FVRPhysicalObject)m_weapon).IsAltHeld = false;
				((FVRAlternateGrip)this).BeginInteraction(hand);
				((FVRPhysicalObject)m_weapon).IsAltHeld = true;
			}
			else
			{
				((FVRAlternateGrip)this).BeginInteraction(hand);
			}
			m_isUnlocked = false;
			m_wasUnlocked = false;
			m_hasUnlockUpSinceBegin = false;
		}

		public override void UpdateInteraction(FVRViveHand hand)
		{
			((FVRAlternateGrip)this).UpdateInteraction(hand);
			ProcessUnlockHand(hand);
		}

		public override void PassHandInput(FVRViveHand hand, FVRInteractiveObject o)
		{
			((FVRAlternateGrip)this).PassHandInput(hand, o);
			if (!((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)null) || !((Object)(object)((FVRInteractiveObject)this).m_hand != (Object)(object)hand))
			{
				ProcessUnlockHand(hand);
			}
		}

		public void ClearUnlock()
		{
			m_isUnlocked = false;
			m_wasUnlocked = false;
			m_hasUnlockUpSinceBegin = false;
		}

		private void ProcessUnlockHand(FVRViveHand hand)
		{
			if (!((Object)(object)m_weapon == (Object)null))
			{
				bool flag = FoldingShotgun.IsFoldUnlatchHeld(hand, UnlockInputThreshold);
				if (!flag)
				{
					m_hasUnlockUpSinceBegin = true;
				}
				m_isUnlocked = flag && m_hasUnlockUpSinceBegin;
				if (m_isUnlocked && !m_wasUnlocked)
				{
					((FVRFireArm)m_weapon).PlayAudioEvent((FirearmAudioEventType)14, 1f);
				}
				m_wasUnlocked = m_isUnlocked;
				m_weapon.IsFoldUnlocked = m_isUnlocked;
			}
		}

		public override void FVRFixedUpdate()
		{
			//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_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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)this).FVRFixedUpdate();
			if (!((Object)(object)m_weapon == (Object)null))
			{
				if ((Object)(object)RB != (Object)null)
				{
					RB.mass = ((!((FVRInteractiveObject)m_weapon).IsHeld || !((FVRPhysicalObject)m_weapon).IsAltHeld) ? 0.1f : 0.001f);
				}
				float num = ((!m_isUnlocked) ? 0f : 1f);
				m_latchLerp = Mathf.Lerp(m_latchLerp, num, Time.deltaTime * LatchSpeed);
				if ((Object)(object)Latch != (Object)null)
				{
					Latch.localRotation = Quaternion.Slerp(Quaternion.Euler(LatchLockedRotation), Quaternion.Euler(LatchUnlockedRotation), m_latchLerp);
				}
				if ((Object)(object)SecondaryLever != (Object)null)
				{
					SecondaryLever.localRotation = Quaternion.Slerp(Quaternion.Euler(SecondaryLeverLockedRotation), Quaternion.Euler(SecondaryLeverUnlockedRotation), m_latchLerp);
				}
			}
		}

		public override bool IsInteractable()
		{
			return true;
		}

		public override void EndInteraction(FVRViveHand hand)
		{
			m_isUnlocked = false;
			m_hasUnlockUpSinceBegin = false;
			if ((Object)(object)m_weapon != (Object)null)
			{
				m_weapon.IsFoldUnlocked = false;
			}
			((FVRAlternateGrip)this).EndInteraction(hand);
		}
	}
}
public class ComponentActivateRandomRuntime : MonoBehaviour
{
	public float Probability;

	public int Group;

	public float SelectionStart;

	[NonSerialized]
	private bool rollResolved;

	[NonSerialized]
	private float sharedRoll;

	private void Awake()
	{
		if (Probability >= 1f)
		{
			return;
		}
		bool flag;
		if (Group != 0)
		{
			if (!rollResolved)
			{
				ResolveGroupRollsForRoot();
			}
			flag = sharedRoll >= SelectionStart && sharedRoll <= SelectionStart + Probability;
		}
		else
		{
			flag = Random.value <= Probability;
		}
		if (!flag)
		{
			((Component)this).gameObject.SetActive(false);
		}
	}

	private void ResolveGroupRollsForRoot()
	{
		ComponentActivateRandomRuntime[] componentsInChildren = ((Component)((Component)this).transform.root).GetComponentsInChildren<ComponentActivateRandomRuntime>(true);
		Dictionary<int, float> dictionary = new Dictionary<int, float>();
		foreach (ComponentActivateRandomRuntime componentActivateRandomRuntime in componentsInChildren)
		{
			if (componentActivateRandomRuntime.Group != 0 && !componentActivateRandomRuntime.rollResolved)
			{
				if (!dictionary.TryGetValue(componentActivateRandomRuntime.Group, out var value))
				{
					value = Random.value;
					dictionary[componentActivateRandomRuntime.Group] = value;
				}
				componentActivateRandomRuntime.sharedRoll = value;
				componentActivateRandomRuntime.rollResolved = true;
			}
		}
	}
}
public class CooldownSound : MonoBehaviour
{
	public ClosedBoltWeapon weapon;

	public AudioClip[] audioClips;

	public float volume = 1f;

	public int minShots = 5;

	public int maxShots = 10;

	public float minDelay = 0.5f;

	public float maxDelay = 2f;

	public float resetTime = 1.5f;

	private AudioSource audioSource;

	private int shotCounter = 0;

	private float lastShotTime;

	private bool lastRoundSpent;

	private int nextShotThreshold;

	private bool isPlayingSound = false;

	private void Start()
	{
		if ((Object)(object)weapon == (Object)null)
		{
			weapon = ((Component)this).GetComponent<ClosedBoltWeapon>();
		}
		if ((Object)(object)weapon == (Object)null)
		{
			Debug.LogError((object)"CooldownSound: Weapon reference is missing. Attach this script to a ClosedBoltWeapon.");
			return;
		}
		audioSource = ((Component)weapon).gameObject.GetComponent<AudioSource>();
		if ((Object)(object)audioSource == (Object)null)
		{
			audioSource = ((Component)weapon).gameObject.AddComponent<AudioSource>();
		}
		audioSource.spatialBlend = 1f;
		audioSource.playOnAwake = false;
		audioSource.rolloffMode = (AudioRolloffMode)0;
		lastRoundSpent = weapon.Chamber.IsSpent;
		SetNewShotThreshold();
	}

	private void Update()
	{
		DetectFiring();
	}

	private void DetectFiring()
	{
		if (weapon.Chamber.IsFull && weapon.Chamber.IsSpent && !lastRoundSpent)
		{
			OnWeaponFired();
		}
		lastRoundSpent = weapon.Chamber.IsSpent;
	}

	private void OnWeaponFired()
	{
		float num = Time.time - lastShotTime;
		if (num > resetTime)
		{
			shotCounter = 0;
			SetNewShotThreshold();
		}
		shotCounter++;
		lastShotTime = Time.time;
		if (shotCounter >= nextShotThreshold)
		{
			((MonoBehaviour)this).StartCoroutine(PlaySoundWithDelay());
			shotCounter = 0;
			SetNewShotThreshold();
		}
	}

	private IEnumerator PlaySoundWithDelay()
	{
		if (!isPlayingSound)
		{
			isPlayingSound = true;
			float delay = Random.Range(minDelay, maxDelay);
			yield return (object)new WaitForSeconds(delay);
			if (audioClips.Length > 0)
			{
				int index = Random.Range(0, audioClips.Length);
				audioSource.clip = audioClips[index];
				audioSource.PlayOneShot(audioSource.clip, volume);
				yield return (object)new WaitForSeconds(audioSource.clip.length);
			}
			isPlayingSound = false;
		}
	}

	private void SetNewShotThreshold()
	{
		nextShotThreshold = Random.Range(minShots, maxShots + 1);
	}
}
[ExecuteInEditMode]
public class CryErosionDriver : MonoBehaviour
{
	private static readonly int ErosionValueId = Shader.PropertyToID("_ErosionValue");

	[Range(0f, 1f)]
	public float Burn = 0f;

	public Renderer[] Renderers;

	public bool HideWhenGone = true;

	private MaterialPropertyBlock _block;

	private float _burnRate;

	private float _lastApplied = -1f;

	public void BurnOver(float seconds)
	{
		_burnRate = ((!(seconds > 0.0001f)) ? 0f : ((1f - Burn) / seconds));
		if (_burnRate <= 0f)
		{
			Burn = 1f;
		}
	}

	public void Restore()
	{
		_burnRate = 0f;
		Burn = 0f;
		Apply(force: true);
	}

	private void LateUpdate()
	{
		if (_burnRate > 0f && Application.isPlaying)
		{
			Burn = Mathf.Min(1f, Burn + _burnRate * Time.deltaTime);
			if (Burn >= 1f)
			{
				_burnRate = 0f;
			}
		}
		Apply(force: false);
	}

	private void OnValidate()
	{
		Apply(force: true);
	}

	private void Apply(bool force)
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		float num = Mathf.Clamp01(Burn);
		if (!force && Mathf.Approximately(num, _lastApplied))
		{
			return;
		}
		_lastApplied = num;
		if (Renderers == null || Renderers.Length == 0)
		{
			Renderers = ((Component)this).GetComponentsInChildren<Renderer>(true);
		}
		if (_block == null)
		{
			_block = new MaterialPropertyBlock();
		}
		bool flag = HideWhenGone && num >= 1f;
		for (int i = 0; i < Renderers.Length; i++)
		{
			Renderer val = Renderers[i];
			if (!((Object)(object)val == (Object)null))
			{
				val.GetPropertyBlock(_block);
				_block.SetFloat(ErosionValueId, 1f - num);
				val.SetPropertyBlock(_block);
				if (HideWhenGone)
				{
					val.enabled = !flag;
				}
			}
		}
	}
}
[ExecuteInEditMode]
public class CryRibbon : MonoBehaviour
{
	private class ParentSlot
	{
		public uint Seed;

		public Vector3 Pos;

		public Vector3 Vel;

		public float Age01 = 1f;

		public bool Dead;
	}

	private struct SeedInfo
	{
		public int Slot;

		public float Fraction;
	}

	private sealed class AgeComparer : IComparer<int>
	{
		public Particle[] Buf;

		public int Compare(int a, int b)
		{
			float num = ((Particle)(ref Buf[a])).startLifetime - ((Particle)(ref Buf[a])).remainingLifetime;
			float num2 = ((Particle)(ref Buf[b])).startLifetime - ((Particle)(ref Buf[b])).remainingLifetime;
			if (num > num2)
			{
				return -1;
			}
			if (num < num2)
			{
				return 1;
			}
			return 0;
		}
	}

	public ParticleSystem OwnPs;

	public ParticleSystem ParentSystem;

	public Transform EffectRoot;

	public Material RibbonMaterial;

	public float SizeConstant = 1f;

	public AnimationCurve SizeOverLife = new AnimationCurve();

	public AnimationCurve SizeBySpawnFraction = new AnimationCurve();

	public float OpacityConstant = 1f;

	public AnimationCurve OpacityOverLife = new AnimationCurve();

	public AnimationCurve OpacityBySpawnFraction = new AnimationCurve();

	public Gradient ColorOverLife = new Gradient();

	public bool StreamFromAge;

	public float TextureFrequency = 1f;

	public bool FlipU;

	public bool FlipV;

	public bool ConnectToParent;

	public bool SampleParentAlpha;

	public AnimationCurve ParentOpacityOverLife = null;

	public AnimationCurve FacingOpacity = null;

	public int PerParentTotal = 1;

	public float SpawnDelay;

	public float SpawnDuration;

	public bool RateMode;

	public float SpawnRate;

	public float CountMin = 1f;

	public float CountMax = 1f;

	public float RestartPeriod;

	public float LifetimeMin = 1f;

	public float LifetimeMax = 1f;

	public int VelocityMode;

	public Vector3 AxisLocal = Vector3.up;

	public float ConeAngle;

	public float SpeedMin;

	public float SpeedMax;

	public AnimationCurve SpeedBySpawnFraction = new AnimationCurve();

	public float Drag;

	public float GravityScale;

	public bool LifetimePerInstance;

	public AnimationCurve DragParentAge = null;

	public AnimationCurve DragSpawnFraction = null;

	private readonly List<ParentSlot> m_parents = new List<ParentSlot>();

	private readonly Dictionary<uint, int> m_parentIndex = new Dictionary<uint, int>();

	private readonly Dictionary<uint, SeedInfo> m_vertSlot = new Dictionary<uint, SeedInfo>();

	private readonly Dictionary<uint, int> m_seedFirstFrame = new Dictionary<uint, int>();

	private readonly List<uint> m_prune = new List<uint>();

	private readonly Dictionary<int, int> m_slotBirthCount = new Dictionary<int, int>();

	private Particle[] m_ownBuf = (Particle[])(object)new Particle[0];

	private Particle[] m_parentBuf = (Particle[])(object)new Particle[0];

	private readonly HashSet<uint> m_liveSeeds = new HashSet<uint>();

	private readonly List<bool> m_seen = new List<bool>();

	private readonly List<int> m_freeSlots = new List<int>();

	private readonly Dictionary<int, int> m_slotRefs = new Dictionary<int, int>();

	private readonly Dictionary<int, int> m_groupIndex = new Dictionary<int, int>();

	private readonly List<List<int>> m_groupLists = new List<List<int>>();

	private readonly List<int> m_groupSlots = new List<int>();

	private readonly AgeComparer m_ageComparer = new AgeComparer();

	private const int k_slotRecycleThreshold = 32;

	private Mesh m_mesh;

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

	private readonly List<Vector2> m_uvs = new List<Vector2>();

	private readonly List<Color32> m_cols = new List<Color32>();

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

	private readonly List<Vector4> m_tans = new List<Vector4>();

	private readonly List<int> m_tris = new List<int>();

	private readonly Vector3[] m_posBuf = (Vector3[])(object)new Vector3[256];

	private readonly float[] m_fracBuf = new float[256];

	private readonly float[] m_ageBuf = new float[256];

	public static readonly List<CryRibbon> EditInstances = new List<CryRibbon>();

	private int m_lastFrame = -1;

	private static Camera s_viewerCamera;

	public bool IsBusy
	{
		get
		{
			if (!((Behaviour)this).isActiveAndEnabled)
			{
				return false;
			}
			if ((Object)(object)OwnPs == (Object)null)
			{
				OwnPs = ((Component)this).GetComponent<ParticleSystem>();
			}
			if ((Object)(object)OwnPs != (Object)null && OwnPs.particleCount > 0)
			{
				return true;
			}
			if ((Object)(object)ParentSystem != (Object)null && ParentSystem.IsAlive(true))
			{
				return true;
			}
			return false;
		}
	}

	public int InstanceCount => m_parents.Count;

	public int TrackCount => m_parents.Count;

	private void OnEnable()
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		if (!Application.isPlaying && !EditInstances.Contains(this))
		{
			EditInstances.Add(this);
		}
		m_parents.Clear();
		m_parentIndex.Clear();
		m_freeSlots.Clear();
		m_vertSlot.Clear();
		m_seedFirstFrame.Clear();
		m_slotBirthCount.Clear();
		if ((Object)(object)OwnPs == (Object)null)
		{
			OwnPs = ((Component)this).GetComponent<ParticleSystem>();
		}
		if ((Object)(object)m_mesh == (Object)null)
		{
			m_mesh = new Mesh();
			((Object)m_mesh).hideFlags = (HideFlags)61;
			((Object)m_mesh).name = "CryRibbon";
			m_mesh.MarkDynamic();
		}
	}

	private void OnDisable()
	{
		EditInstances.Remove(this);
	}

	public void EditorTick()
	{
		if (!Application.isPlaying && !((Object)(object)this == (Object)null))
		{
			LateUpdate();
		}
	}

	private void OnDestroy()
	{
		if (!((Object)(object)m_mesh == (Object)null))
		{
			if (Application.isPlaying)
			{
				Object.Destroy((Object)(object)m_mesh);
			}
			else
			{
				Object.DestroyImmediate((Object)(object)m_mesh);
			}
		}
	}

	private void LateUpdate()
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)RibbonMaterial == (Object)null)
		{
			return;
		}
		int frame = CryEditClock.Frame;
		if (m_lastFrame == frame)
		{
			return;
		}
		m_lastFrame = frame;
		if ((Object)(object)OwnPs == (Object)null)
		{
			OwnPs = ((Component)this).GetComponent<ParticleSystem>();
		}
		if (!((Object)(object)OwnPs == (Object)null))
		{
			UpdateParents();
			Camera val = ResolveViewerCamera();
			if (!((Object)(object)val == (Object)null))
			{
				BuildAndDraw(((Component)val).transform.position);
			}
		}
	}

	private void UpdateParents()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: 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)
		if ((Object)(object)ParentSystem == (Object)null)
		{
			return;
		}
		MainModule main = ParentSystem.main;
		int maxParticles = ((MainModule)(ref main)).maxParticles;
		if (m_parentBuf.Length < maxParticles)
		{
			m_parentBuf = (Particle[])(object)new Particle[maxParticles];
		}
		int particles = ParentSystem.GetParticles(m_parentBuf);
		RecycleDeadSlots();
		m_seen.Clear();
		for (int i = 0; i < m_parents.Count; i++)
		{
			m_seen.Add(item: false);
		}
		for (int j = 0; j < particles; j++)
		{
			uint randomSeed = ((Particle)(ref m_parentBuf[j])).randomSeed;
			if (!m_parentIndex.TryGetValue(randomSeed, out var value))
			{
				if (m_freeSlots.Count > 0)
				{
					value = m_freeSlots[m_freeSlots.Count - 1];
					m_freeSlots.RemoveAt(m_freeSlots.Count - 1);
					m_parents[value].Seed = randomSeed;
				}
				else
				{
					ParentSlot parentSlot = new ParentSlot();
					parentSlot.Seed = randomSeed;
					value = m_parents.Count;
					m_parents.Add(parentSlot);
					m_seen.Add(item: false);
				}
				m_parentIndex[randomSeed] = value;
			}
			ParentSlot parentSlot2 = m_parents[value];
			parentSlot2.Pos = ToWorldPoint(ParentSystem, ((Particle)(ref m_parentBuf[j])).position);
			parentSlot2.Vel = ToWorldVector(ParentSystem, ((Particle)(ref m_parentBuf[j])).velocity);
			float startLifetime = ((Particle)(ref m_parentBuf[j])).startLifetime;
			float num = startLifetime - ((Particle)(ref m_parentBuf[j])).remainingLifetime;
			parentSlot2.Age01 = ((!(startLifetime > 1E-06f)) ? 1f : Mathf.Clamp01(num / startLifetime));
			parentSlot2.Dead = false;
			m_seen[value] = true;
		}
		for (int k = 0; k < m_parents.Count; k++)
		{
			if (!m_seen[k])
			{
				m_parents[k].Dead = true;
			}
		}
	}

	private void RecycleDeadSlots()
	{
		if (m_parents.Count < 32)
		{
			return;
		}
		m_slotRefs.Clear();
		foreach (KeyValuePair<uint, SeedInfo> item in m_vertSlot)
		{
			m_slotRefs[item.Value.Slot] = 1;
		}
		for (int i = 0; i < m_parents.Count; i++)
		{
			ParentSlot parentSlot = m_parents[i];
			if (parentSlot.Dead && !m_slotRefs.ContainsKey(i) && m_parentIndex.TryGetValue(parentSlot.Seed, out var value) && value == i)
			{
				m_parentIndex.Remove(parentSlot.Seed);
				m_slotBirthCount.Remove(i);
				m_freeSlots.Add(i);
			}
		}
	}

	private float ParentAge01(int slot)
	{
		if (slot < 0 || slot >= m_parents.Count)
		{
			return 1f;
		}
		return m_parents[slot].Age01;
	}

	private void BuildAndDraw(Vector3 camPos)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: 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_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_05c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0695: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		m_verts.Clear();
		m_uvs.Clear();
		m_cols.Clear();
		m_norms.Clear();
		m_tans.Clear();
		m_tris.Clear();
		MainModule main = OwnPs.main;
		int maxParticles = ((MainModule)(ref main)).maxParticles;
		if (m_ownBuf.Length < maxParticles)
		{
			m_ownBuf = (Particle[])(object)new Particle[maxParticles];
		}
		int particles = OwnPs.GetParticles(m_ownBuf);
		bool flag = m_parents.Count > 0;
		int frame = CryEditClock.Frame;
		for (int i = 0; i < particles; i++)
		{
			uint randomSeed = ((Particle)(ref m_ownBuf[i])).randomSeed;
			if (m_vertSlot.ContainsKey(randomSeed))
			{
				continue;
			}
			if (!m_seedFirstFrame.ContainsKey(randomSeed))
			{
				m_seedFirstFrame[randomSeed] = frame;
			}
			Vector3 val = ToWorldVector(OwnPs, ((Particle)(ref m_ownBuf[i])).velocity);
			bool flag2 = ((Vector3)(ref val)).sqrMagnitude > 1E-08f;
			bool flag3 = frame - m_seedFirstFrame[randomSeed] >= 3;
			if (!flag2 && !flag3 && flag)
			{
				continue;
			}
			SeedInfo value = new SeedInfo
			{
				Slot = 0,
				Fraction = 0f
			};
			if (flag)
			{
				int slot = 0;
				Vector3 val2 = ToWorldPoint(OwnPs, ((Particle)(ref m_ownBuf[i])).position);
				float num = float.MaxValue;
				float num2 = float.MaxValue;
				for (int j = 0; j < m_parents.Count; j++)
				{
					if (!m_parents[j].Dead)
					{
						Vector3 val3 = val2 - m_parents[j].Pos;
						float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
						if (sqrMagnitude < num)
						{
							num2 = num;
							num = sqrMagnitude;
							slot = j;
						}
						else if (sqrMagnitude < num2)
						{
							num2 = sqrMagnitude;
						}
					}
				}
				bool flag4 = num2 > 1E-12f && num <= num2 * 0.25f;
				if (!flag4 && flag2)
				{
					float num3 = -2f;
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					for (int k = 0; k < m_parents.Count; k++)
					{
						if (m_parents[k].Dead)
						{
							continue;
						}
						Vector3 vel = m_parents[k].Vel;
						if (!(((Vector3)(ref vel)).sqrMagnitude < 1E-08f))
						{
							float num4 = Vector3.Dot(normalized, ((Vector3)(ref vel)).normalized);
							if (num4 > num3)
							{
								num3 = num4;
								slot = k;
							}
						}
					}
					flag4 = true;
				}
				if (!flag4)
				{
					continue;
				}
				value.Slot = slot;
			}
			int value2 = 0;
			m_slotBirthCount.TryGetValue(value.Slot, out value2);
			int num5 = Mathf.Max(2, PerParentTotal);
			value.Fraction = Mathf.Clamp01((float)value2 / (float)(num5 - 1));
			m_slotBirthCount[value.Slot] = value2 + 1;
			m_vertSlot[randomSeed] = value;
		}
		m_liveSeeds.Clear();
		for (int l = 0; l < particles; l++)
		{
			m_liveSeeds.Add(((Particle)(ref m_ownBuf[l])).randomSeed);
		}
		m_prune.Clear();
		foreach (KeyValuePair<uint, SeedInfo> item in m_vertSlot)
		{
			if (!m_liveSeeds.Contains(item.Key))
			{
				m_prune.Add(item.Key);
			}
		}
		for (int m = 0; m < m_prune.Count; m++)
		{
			m_vertSlot.Remove(m_prune[m]);
			m_seedFirstFrame.Remove(m_prune[m]);
		}
		m_groupIndex.Clear();
		m_groupSlots.Clear();
		for (int n = 0; n < particles; n++)
		{
			if (!m_vertSlot.TryGetValue(((Particle)(ref m_ownBuf[n])).randomSeed, out var value3))
			{
				continue;
			}
			if (!m_groupIndex.TryGetValue(value3.Slot, out var value4))
			{
				value4 = m_groupSlots.Count;
				if (value4 == m_groupLists.Count)
				{
					m_groupLists.Add(new List<int>());
				}
				else
				{
					m_groupLists[value4].Clear();
				}
				m_groupIndex[value3.Slot] = value4;
				m_groupSlots.Add(value3.Slot);
			}
			m_groupLists[value4].Add(n);
		}
		m_ageComparer.Buf = m_ownBuf;
		for (int num6 = 0; num6 < m_groupSlots.Count; num6++)
		{
			List<int> list = m_groupLists[num6];
			list.Sort(m_ageComparer);
			BuildStrip(list, m_groupSlots[num6], camPos);
			if (m_verts.Count >= 500)
			{
				break;
			}
		}
		m_mesh.Clear();
		if (m_verts.Count >= 4)
		{
			m_mesh.SetVertices(m_verts);
			m_mesh.SetUVs(0, m_uvs);
			m_mesh.SetColors(m_cols);
			m_mesh.SetNormals(m_norms);
			m_mesh.SetTangents(m_tans);
			m_mesh.SetTriangles(m_tris, 0);
			m_mesh.RecalculateBounds();
			Graphics.DrawMesh(m_mesh, Matrix4x4.identity, RibbonMaterial, ((Component)this).gameObject.layer, (Camera)null, 0, (MaterialPropertyBlock)null, false, false);
		}
	}

	private void BuildStrip(List<int> order, int slot, Vector3 camPos)
	{
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: 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_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_020f: 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_0224: 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_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_065e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0660: Unknown result type (might be due to invalid IL or missing references)
		//IL_0664: Unknown result type (might be due to invalid IL or missing references)
		//IL_0669: Unknown result type (might be due to invalid IL or missing references)
		//IL_067d: Unknown result type (might be due to invalid IL or missing references)
		//IL_068d: Unknown result type (might be due to invalid IL or missing references)
		//IL_069a: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0408: 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_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_049b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04db: Unknown result type (might be due to invalid IL or missing references)
		//IL_04df: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0508: Unknown result type (might be due to invalid IL or missing references)
		//IL_0515: Unknown result type (might be due to invalid IL or missing references)
		//IL_0522: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: 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_0545: 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_055e: Unknown result type (might be due to invalid IL or missing references)
		//IL_056e: Unknown result type (might be due to invalid IL or missing references)
		//IL_057b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0588: Unknown result type (might be due to invalid IL or missing references)
		//IL_0593: Unknown result type (might be due to invalid IL or missing references)
		//IL_0595: Unknown result type (might be due to invalid IL or missing references)
		//IL_059b: 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)
		int num = order.Count;
		bool flag = ConnectToParent && (Object)(object)ParentSystem != (Object)null && slot >= 0 && slot < m_parents.Count && !m_parents[slot].Dead;
		if (num + (flag ? 1 : 0) < 2)
		{
			return;
		}
		if (num > m_posBuf.Length)
		{
			num = m_posBuf.Length;
		}
		int count = m_verts.Count;
		for (int i = 0; i < num; i++)
		{
			int num2 = order[i];
			ref Vector3 reference = ref m_posBuf[i];
			reference = ToWorldPoint(OwnPs, ((Particle)(ref m_ownBuf[num2])).position);
			float num3 = 0f;
			if (m_vertSlot.TryGetValue(((Particle)(ref m_ownBuf[num2])).randomSeed, out var value))
			{
				num3 = value.Fraction;
			}
			m_fracBuf[i] = num3;
			float startLifetime = ((Particle)(ref m_ownBuf[num2])).startLifetime;
			float num4 = startLifetime - ((Particle)(ref m_ownBuf[num2])).remainingLifetime;
			m_ageBuf[i] = ((!(startLifetime > 1E-06f)) ? 1f : Mathf.Clamp01(num4 / startLifetime));
		}
		bool flag2 = FacingOpacity != null && FacingOpacity.length > 0;
		Vector3 val = Vector3.right;
		float num5 = 0f;
		Color32 item = default(Color32);
		((Color32)(ref item))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0);
		float num6 = 0f;
		Vector3 val2 = Vector3.forward;
		Vector4 item2 = default(Vector4);
		for (int j = 0; j < num; j++)
		{
			float num7 = m_ageBuf[j];
			Vector3 val3 = m_posBuf[Mathf.Min(j + 1, num - 1)] - m_posBuf[Mathf.Max(j - 1, 0)];
			Vector3 val4 = m_posBuf[j] - camPos;
			Vector3 val5 = Vector3.Cross(val3, val4);
			if (((Vector3)(ref val5)).sqrMagnitude < 1E-12f)
			{
				val5 = val;
			}
			else
			{
				((Vector3)(ref val5)).Normalize();
			}
			val = val5;
			float num8 = ((SizeOverLife == null || SizeOverLife.length <= 0) ? SizeConstant : SizeOverLife.Evaluate(num7));
			if (SizeBySpawnFraction != null && SizeBySpawnFraction.length > 0)
			{
				num8 *= SizeBySpawnFraction.Evaluate(m_fracBuf[j]);
			}
			float num9 = Mathf.Max(num8, 0f);
			float num10 = ((OpacityOverLife == null || OpacityOverLife.length <= 0) ? OpacityConstant : OpacityOverLife.Evaluate(num7));
			if (OpacityBySpawnFraction != null && OpacityBySpawnFraction.length > 0)
			{
				num10 *= OpacityBySpawnFraction.Evaluate(m_fracBuf[j]);
			}
			if (SampleParentAlpha)
			{
				num10 *= EvaluateParentAlpha(ParentAge01(slot));
			}
			if (flag2)
			{
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (magnitude > 1E-06f)
				{
					num10 *= FacingOpacity.Evaluate(Mathf.Clamp01(Mathf.Abs(Vector3.Dot(val3 / magnitude, ((Vector3)(ref val4)).normalized))));
				}
			}
			Color val6 = ((ColorOverLife == null) ? Color.white : ColorOverLife.Evaluate(num7));
			num10 *= 1f - Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num7 - 0.85f) / 0.15f));
			val6.a = Mathf.Clamp01(num10);
			Color32 val7 = Color32.op_Implicit(val6);
			float num11 = 1f - ((!StreamFromAge) ? m_fracBuf[j] : num7) * TextureFrequency;
			num11 -= Mathf.Floor(num11);
			if (FlipV)
			{
				num11 = 1f - num11;
			}
			float num12 = ((!FlipU) ? 0f : 1f);
			float num13 = ((!FlipU) ? 1f : 0f);
			Vector3 val8 = -((Vector3)(ref val4)).normalized;
			((Vector4)(ref item2))..ctor(val5.x, val5.y, val5.z, -1f);
			m_verts.Add(m_posBuf[j] - val5 * num9);
			m_uvs.Add(new Vector2(num12, num11));
			m_cols.Add(val7);
			m_norms.Add(val8);
			m_tans.Add(item2);
			m_verts.Add(m_posBuf[j] + val5 * num9);
			m_uvs.Add(new Vector2(num13, num11));
			m_cols.Add(val7);
			m_norms.Add(val8);
			m_tans.Add(item2);
			num5 = num9;
			item = val7;
			num6 = num11;
			val2 = val8;
		}
		int num14 = num - 1;
		if (flag)
		{
			Vector3 pos = m_parents[slot].Pos;
			Vector3 item3 = pos - camPos;
			item3 = ((!(((Vector3)(ref item3)).sqrMagnitude < 1E-12f)) ? (-((Vector3)(ref item3)).normalized) : val2);
			Vector4 item4 = default(Vector4);
			((Vector4)(ref item4))..ctor(val.x, val.y, val.z, -1f);
			float num15 = ((!FlipU) ? 0f : 1f);
			float num16 = ((!FlipU) ? 1f : 0f);
			m_verts.Add(pos - val * num5);
			m_uvs.Add(new Vector2(num15, num6));
			m_cols.Add(item);
			m_norms.Add(item3);
			m_tans.Add(item4);
			m_verts.Add(pos + val * num5);
			m_uvs.Add(new Vector2(num16, num6));
			m_cols.Add(item);
			m_norms.Add(item3);
			m_tans.Add(item4);
			num14 = num;
		}
		for (int k = 0; k < num14; k++)
		{
			int num17 = count + k * 2;
			m_tris.Add(num17);
			m_tris.Add(num17 + 2);
			m_tris.Add(num17 + 1);
			m_tris.Add(num17 + 1);
			m_tris.Add(num17 + 2);
			m_tris.Add(num17 + 3);
			m_tris.Add(num17);
			m_tris.Add(num17 + 1);
			m_tris.Add(num17 + 2);
			m_tris.Add(num17 + 1);
			m_tris.Add(num17 + 3);
			m_tris.Add(num17 + 2);
		}
	}

	private float EvaluateParentAlpha(float parentAge01)
	{
		if (ParentOpacityOverLife == null || ParentOpacityOverLife.length == 0)
		{
			return 1f;
		}
		return Mathf.Clamp01(ParentOpacityOverLife.Evaluate(Mathf.Clamp01(parentAge01)));
	}

	private static Vector3 ToWorldPoint(ParticleSystem ps, Vector3 p)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		MainModule main = ps.main;
		return ((int)((MainModule)(ref main)).simulationSpace != 1) ? ((Component)ps).transform.TransformPoint(p) : p;
	}

	private static Vector3 ToWorldVector(ParticleSystem ps, Vector3 v)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		MainModule main = ps.main;
		return ((int)((MainModule)(ref main)).simulationSpace != 1) ? ((Component)ps).transform.TransformVector(v) : v;
	}

	private static Camera ResolveViewerCamera()
	{
		if ((Object)(object)s_viewerCamera != (Object)null && ((Behaviour)s_viewerCamera).isActiveAndEnabled)
		{
			return s_viewerCamera;
		}
		s_viewerCamera = Camera.main;
		if ((Object)(object)s_viewerCamera != (Object)null && ((Behaviour)s_viewerCamera).isActiveAndEnabled)
		{
			return s_viewerCamera;
		}
		s_viewerCamera = Camera.current;
		if ((Object)(object)s_viewerCamera != (Object)null && ((Behaviour)s_viewerCamera).isActiveAndEnabled)
		{
			return s_viewerCamera;
		}
		Camera[] allCameras = Camera.allCameras;
		s_viewerCamera = ((allCameras == null || allCameras.Length <= 0) ? null : allCameras[0]);
		return s_viewerCamera;
	}
}
public class CustomWaggleJoint : MonoBehaviour
{
	public float distanceLimit = 0.25f;

	public float angleLimitLeft = 45f;

	public float angleLimitRight = 45f;

	public float gravityScale = 1f;

	public bool useSpring;

	public float springApproachRate = 0.95f;

	public float damping;

	public Transform hingeGraphic;

	public Vector3 hingeGraphicRotationOffset;

	public bool invertWaggleAxis;

	public bool ManualExecution;

	public float onHitLimitCooldown = 0.05f;

	public Vector3 waggleAxis = Vector3.up;

	public Vector3 rotationAxis = Vector3.up;

	[Header("Gizmo Options")]
	public bool debugGizmos = false;

	public bool showRotationExtremes = false;

	public bool showRotationDirectionArrows = false;

	private Vector3 particlePos;

	private Vector3 particleVel;

	private bool leftCatchState;

	private bool rightCatchState;

	private float lastTouchTime = float.MinValue;

	private Vector3 EffectiveWaggleDir()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		return ((Component)this).transform.TransformDirection((!invertWaggleAxis) ? waggleAxis : (-waggleAxis));
	}

	private void GetEffectiveAngleLimits(out float effectiveAngleMin, out float effectiveAngleMax)
	{
		if (invertWaggleAxis)
		{
			effectiveAngleMin = 0f - angleLimitLeft;
			effectiveAngleMax = angleLimitRight;
		}
		else
		{
			effectiveAngleMin = 0f - angleLimitRight;
			effectiveAngleMax = angleLimitLeft;
		}
	}

	public void ResetParticlePos()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		particlePos = ((Component)this).transform.position + EffectiveWaggleDir() * distanceLimit;
		particleVel = Vector3.zero;
	}

	private void OnHitLimit(float angularVelocity)
	{
	}

	public void Execute()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		float deltaTime = Time.deltaTime;
		Transform transform = ((Component)this).transform;
		Vector3 val = Physics.gravity * gravityScale;
		Vector3 val2 = particlePos;
		Vector3 val3 = particleVel * Mathf.Pow(1f - damping, deltaTime) + val * deltaTime;
		Vector3 val4 = val2 + val3 * deltaTime;
		Vector3 val5 = transform.TransformDirection(((Vector3)(ref rotationAxis)).normalized);
		Vector3 val6 = EffectiveWaggleDir();
		Vector3 position = transform.position;
		if (useSpring)
		{
			val4 = Vector3.Lerp(val4, position + val6 * distanceLimit, 1f - Mathf.Pow(1f - springApproachRate, deltaTime));
		}
		GetEffectiveAngleLimits(out var effectiveAngleMin, out var effectiveAngleMax);
		particlePos = ProjectOnHinge(val4, position, val5, val6, distanceLimit, effectiveAngleMin, effectiveAngleMax);
		particleVel = (particlePos - val2) / deltaTime;
		if ((Object)(object)hingeGraphic != (Object)null)
		{
			hingeGraphic.rotation = Quaternion.LookRotation(particlePos - transform.position, val5) * Quaternion.Euler(hingeGraphicRotationOffset);
		}
	}

	private Vector3 ProjectOnHinge(Vector3 point, Vector3 hingePivot, Vector3 hingeAxis, Vector3 hingeDirection, float distanceLimit, float angleMin, float angleMax)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		float num = ToHingeAngle(point, hingePivot, hingeAxis, hingeDirection);
		num = Mathf.Clamp(num, angleMin, angleMax);
		Vector3 val = Quaternion.AngleAxis(num, hingeAxis) * hingeDirection;
		return val * distanceLimit + hingePivot;
	}

	private float ToHingeAngle(Vector3 point, Vector3 hingePivot, Vector3 hingeAxis, Vector3 hingeDirection)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = point - hingePivot;
		Vector3 val2 = Vector3.ProjectOnPlane(val, hingeAxis);
		Vector3 normalized = ((Vector3)(ref val2)).normalized;
		return SignedAngle(hingeDirection, normalized, hingeAxis);
	}

	private float SignedAngle(Vector3 from, Vector3 to, Vector3 axis)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		float num = Vector3.Angle(from, to);
		return num * Mathf.Sign(Vector3.Dot(axis, Vector3.Cross(from, to)));
	}

	private void Start()
	{
		ResetParticlePos();
	}

	private void Update()
	{
		if (!ManualExecution)
		{
			Execute();
		}
	}
}
public class DecalLayFlat : MonoBehaviour
{
	private void Awake()
	{
		Flatten();
	}

	private void OnEnable()
	{
		if (Application.isPlaying)
		{
			Flatten();
		}
	}

	private void Flatten()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		Quaternion rotation = ((Component)this).transform.rotation;
		float y = ((Quaternion)(ref rotation)).eulerAngles.y;
		((Component)this).transform.rotation = Quaternion.Euler(90f, y, 0f);
	}
}
public class ExplosionLightFade : MonoBehaviour
{
	public Light Light;

	public float BaseIntensity = 1f;

	public float Delay;

	public float Lifetime = 1f;

	public AnimationCurve IntensityOverLife;

	public float FlickerMin;

	public float FlickerMax;

	public float FlickerSpeed = 1f;

	private float startTime;

	private float noiseOffset;

	private void Awake()
	{
		if ((Object)(object)Light == (Object)null)
		{
			Light = ((Component)this).GetComponent<Light>();
		}
		noiseOffset = Random.value * 1000f;
	}

	private void OnEnable()
	{
		startTime = Time.time;
	}

	private void Update()
	{
		if ((Object)(object)Light == (Object)null || Lifetime <= 0f)
		{
			return;
		}
		float num = (Time.time - startTime - Delay) / Lifetime;
		if (num < 0f)
		{
			Light.intensity = 0f;
			return;
		}
		if (num >= 1f)
		{
			((Behaviour)Light).enabled = false;
			((Behaviour)this).enabled = false;
			return;
		}
		float num2 = ((IntensityOverLife == null) ? 1f : Mathf.Max(0f, IntensityOverLife.Evaluate(num)));
		float num3 = 1f;
		if (FlickerMax > FlickerMin)
		{
			num3 = Mathf.Lerp(FlickerMin, FlickerMax, Mathf.PerlinNoise(Time.time * FlickerSpeed + noiseOffset, 0f));
		}
		Light.intensity = BaseIntensity * num2 * num3;
	}
}
public class FireLightFlicker : MonoBehaviour
{
	public Light Light;

	public float BaseIntensity = 1f;

	public float FlickerMin = 1f;

	public float FlickerMax = 1f;

	public float FlickerSpeed = 1f;

	private float noiseOffset;

	private void Awake()
	{
		if ((Object)(object)Light == (Object)null)
		{
			Light = ((Component)this).GetComponent<Light>();
		}
		noiseOffset = Random.value * 1000f;
	}

	private void Update()
	{
		if (!((Object)(object)Light == (Object)null))
		{
			float num = Mathf.PerlinNoise(Time.time * FlickerSpeed + noiseOffset, 0f);
			Light.intensity = BaseIntensity * Mathf.Lerp(FlickerMin, FlickerMax, num);
		}
	}
}
namespace BitWizrd.Shotgun.Burgess
{
	public class FoldingShotgun : BreakActionWeapon
	{
		public enum FoldState
		{
			Folded,
			Unfolded
		}

		public enum FoldAxis
		{
			X,
			Y,
			Z
		}

		public enum TravelAxis
		{
			X,
			Y,
			Z
		}

		[Header("Burgess Config")]
		public FVRFireArmChamber LifterChamber;

		public FVRFireArmChamber Chamber;

		public BurgessForegrip ForeGrip;

		[Header("Component Connections")]
		public FVRFireArmMagazineReloadTrigger MagazineReloadTrigger;

		[Header("Barrel / Hammer")]
		public Transform Muzzle;

		public Transform Hammer;

		public InterpStyle HammerInterpStyle = (InterpStyle)1;

		public Axis HammerAxis = (Axis)1;

		public float HammerUncocked;

		public float HammerCocked;

		private bool m_isHammerCocked;

		private bool m_wasCockButtonHeld;

		private bool m_cockButtonConsumed;

		[Header("Folding")]
		public FoldState CurrentFoldState = FoldState.Folded;

		public FoldAxis FoldRotationAxis = FoldAxis.Y;

		public float FoldAngleThreshold = 10f;

		public float UnfoldAngleThreshold = 35f;

		[Header("Authored Weld Poses (hinge GO local space under its ORIGINAL parent)")]
		public Vector3 FoldedLocalPosition = Vector3.zero;

		public Vector3 FoldedLocalEuler = Vector3.zero;

		public Vector3 UnfoldedLocalPosition = new Vector3(0.00055f, 0f, 0.00698f);

		public Vector3 UnfoldedLocalEuler = new Vector3(0f, -168f, 0f);

		[Header("Fold Drive")]
		[Tooltip("Hinge spring strength used while a hand is on the foregrip and the barrel is unwelded. Vanilla FVRShotgunForegrip hardcodes 10, tuned for a stubby fore-end swinging ~45 degrees. Burgess swings a whole barrel through 168.5 degrees, so its moment of inertia about the hinge is far larger and the same constant yields proportionally less angular acceleration - the barrel lags the hand. Raise to sharpen, set back to 10 for exact vanilla feel.")]
		public float ForeGripDriveSpring = 40f;

		[Tooltip("How much of the barrel's own weight the hand is treated as carrying while it holds the foregrip, 0 = none (raw physics), 1 = all of it. Gravity torque about this hinge is m*g*r*cos(angle): near maximum at BOTH ends of the swing and zero in the middle. At the folded end it is 98% of maximum, which is precisely where you are trying to be delicate - and because the drive spring is proportional, its standing error grows with that load, so the barrel drifts off your hand exactly when you want it most controllable. In reality your hand carries the barrel; here it is never attached to it, so it carries none. 1 restores that. Only applied while the foregrip is held.")]
		[Range(0f, 1f)]
		public float ForeGripGravityCompensation = 1f;

		[Tooltip("Viscous friction in the hinge while nobody is on the foregrip, as a decay rate in 1/seconds - 2 sheds about half the swing speed every 0.35s. Gravity is left fully intact: the barrel SHOULD fall open. The problem this solves is that an unfrictioned barrel is a pendulum, so released at one lock it arrives at the far lock with nearly the energy it started with and completes the fold on its own. Real folding hardware has enough friction that it falls, slows and settles, leaving the player to WHIP energy back in to climb to the far lock. Raise it if the barrel still coasts all the way round, lower it if the drop feels sticky or a good flick can no longer make the trip. 0 is frictionless.")]
		public float FreeSwingFriction = 2f;

		[Tooltip("ON: the barrel holds the angle you grabbed it at and tracks your hand 1:1, the way vanilla's pump handle holds its grab offset. A sloppy grab stays sloppy for the whole stroke, and driving the hand past a lock winds up, so the barrel does not move again until the hand comes back - both faithful, both deliberate. OFF: the barrel converges toward the hand instead, which self-corrects a bad grab but is not 1:1. Toggle to compare; neither can reintroduce the wrap seam.")]
		public bool ForeGripPreserveGrabOffset = true;

		[Tooltip("How fast, in degrees per second, the barrel is allowed to chase the hand. This is the primary feel control for hand-folding. Vanilla's HandCrankFrankCrank clamps its equivalent to 10 degrees per tick, which is ~600 deg/s at 60Hz, so 720 sits just above that. Lower it for a heavier, more deliberate fold; raise it to track the hand more tightly at the cost of a sharper catch-up when you grab the barrel far from where your hand is. 0 removes the limit entirely.")]
		public float ForeGripMaxTrackSpeed = 720f;

		[Tooltip("Damper for that same drive spring, and the knob for ringing. Vanilla uses 0, which is survivable only because its spring is weak and its arc is short - an undamped spring at this strength oscillates around the target instead of settling, which reads as the barrel buzzing or snapping past where you want it. Raise if it overshoots or vibrates, lower if it feels syrupy to push.")]
		public float ForeGripDriveDamper = 2f;

		[Tooltip("Amplifies the inertial whip when the gun is flicked with NO hand on the foregrip. PhysX does already transmit the pivot's acceleration through the hinge, but the true response is only about 1.5*a/L and is mass-independent, so for a barrel this long it is real yet far too soft to flick open or shut. This re-applies that same inertial torque, scaled, so the barrel carries like a longer/heavier arm - amplifying physics that is already there rather than inventing a spring the real gun does not have. 0 disables it entirely and leaves the pure PhysX response.")]
		public float WhipAssistGain = 2f;

		[Tooltip("Degrees per second of swing added by a decisive flick, on top of the continuous assist above. Size this against the 168.5 degree arc: too little and the barrel stalls before reaching the far lock, which is why whipping it OPEN is harder than whipping it shut. 0 disables the impulse and leaves only the continuous assist.")]
		public float WhipImpulse = 250f;

		[Tooltip("Hand speed, in metres/second, below which a flick is ignored entirely. This is the knob that decides WHETHER the barrel whips, as opposed to how hard. Vanilla's slap gestures use 1.0; a deliberate wrist flick is comfortably above 2, while ordinary aiming and walking sit well below 1. Raise it if the barrel still goes off during normal handling, lower it if real flicks get ignored.")]
		public float WhipFlickSpeed = 2f;

		[Tooltip("Minimum seconds between impulses, so one flick cannot fire on several consecutive physics ticks and stack into a barrel that slams across the arc.")]
		public float WhipImpulseCooldown = 0.25f;

		[Header("Barrel Lock Interface")]
		[Tooltip("Nudge applied to the hinge's PARENT transform while the barrel is released from its unfolded locking interface - from the moment the latch opens until it relatches unfolded, folded included. Expressed in that parent's own parent space, exactly like its localPosition. The default is the negative of the authored parent offset, so the released pivot lands on that parent's origin and the seated pivot sits where the art has it.")]
		public Vector3 UnlatchedHingeParentOffset = new Vector3(-0.00055f, 0f, -0.00698f);

		[Header("Debug")]
		public bool DebugDisableFolding = false;

		private bool m_debugWasEnabled;

		private bool m_wasUnlatchRequested;

		private bool m_unlatchRequested;

		private bool m_primaryUnlatchHeld;

		private bool m_hasUnlatchUpSinceBegin;

		private bool m_wasForeGripDriving;

		private float m_foreGripGrabOffset;

		private bool m_hasForeGripGrabOffset;

		private bool m_hasLeftStartZoneSinceSeparate;

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

		public Vector3 EjectionForce = new Vector3(0.3f, 1f, -0.2f);

		public Vector3 EjectionTorque = new Vector3(80f, 0f, 30f);

		public Vector3 FoldEjectionForce = new Vector3(0f, 0.05f, -0.15f);

		public Vector3 FoldEjectionTorque = Vector3.zero;

		public float FoldEjectionAngleThreshold = 70f;

		public bool UsesSimplifiedFoldedChamberAccess = false;

		public Transform ChamberExtractedPos;

		[Header("Magazine Follower")]
		public Transform MagazineFollower;

		public Vector3 MagazineFollowerEmptyPos = Vector3.zero;

		public Vector3 MagazineFollowerFullPos = new Vector3(0f, 0f, -0.05f);

		[Header("Carrier")]
		public Transform Carrier;

		public TravelAxis CarrierRotationAxis = TravelAxis.X;

		public float CarrierDownAngle = 0f;

		public float CarrierUpAngle = -25f;

		public float CarrierSnapSpeed = 400f;

		private bool m_carrierUp;

		private float m_carrierCurrentAngle;

		[Header("Pump Configuration")]
		public TravelAxis PumpTravelAxis = TravelAxis.X;

		public float Speed_Held = 12f;

		[Range(0f, 1f)]
		public float PumpPositionDamping = 0.85f;

		[Header("Pump Reference Points (REQUIRED)")]
		public Transform Point_Grip_Forward;

		public Transform Point_Grip_Rear;

		[Header("Bolt Reference Points (REQUIRED)")]
		public Transform Point_Bolt_Forward;

		public Transform Point_Bolt_LockPoint;

		public Transform Point_Bolt_Rear;

		[Header("Pump Visuals")]
		public Transform Bolt;

		public TravelAxis BoltTravelAxis = TravelAxis.X;

		public Transform Sleeve;

		public Transform SlideBottom;

		public float SlideBottomForwardAngle = 0f;

		public float SlideBottomRearAngle = -20f;

		[Header("Quickbelt Size")]
		public FVRPhysicalObjectSize FoldedSize = (FVRPhysicalObjectSize)1;

		public FVRPhysicalObjectSize UnfoldedSize = (FVRPhysicalObjectSize)2;

		[Tooltip("Optional second quickbelt pose, used instead of the inherited QBPoseOverride while the barrel is folded - a folded Burgess is a different shape and hangs differently. Author it as a child transform posed for the folded silhouette. Leave empty to use the one QBPoseOverride for both states.")]
		public Transform QBPoseOverride_Folded;

		private Transform m_qbPoseOverrideDeployed;

		public bool UsesSlamFireTrigger;

		private const float TRIGGER_RESET_THRESHOLD = 0.45f;

		private const float TRIGGER_BREAK_THRESHOLD = 0.85f;

		private bool m_hasTriggerReset = true;

		private float m_lastFireTime;

		private float m_strokeDistance = 0.1f;

		private float m_directionSign = -1f;

		private Vector2 m_boltRange = new Vector2(0f, -0.12f);

		private float m_lockT = 0.5f;

		private const float REAR_ARRIVAL = 0.95f;

		private const float FORE_ARRIVAL = 0.05f;

		private float m_handStartTravel;

		private float m_grabStartPumpPos;

		private float m_curPumpPos;

		private float m_curBoltPos;

		private bool m_wasPastLock;

		private bool m_hasReachedRear;

		private bool m_hasReachedFore = true;

		private bool m_isHandleLocked;

		private FVRViveHand m_lastBraceHand;

		private bool m_isPumpCycling;

		private Vector3 m_sleeveStartLocal = Vector3.zero;

		private bool m_sleeveInit;

		private Quaternion m_carrierRestRotation = Quaternion.identity;

		private Quaternion m_slideBottomRestRotation = Quaternion.identity;

		private GameObject m_hingeGO;

		private Transform m_hingeOriginalParent;

		private Rigidbody m_hingeRB;

		private bool m_isWelded;

		private Vector3 m_hingeParentSeatedLocalPos;

		private HingeJoint m_decoyHinge;

		private Vector3 m_weldedLocalPos;

		private Quaternion m_weldedLocalRot;

		private bool m_needsPreciseWeldSnap;

		private float m_cachedMass;

		private float m_cachedDrag;

		private float m_cachedAngularDrag;

		private bool m_cachedUseGravity;

		private RigidbodyInterpolation m_cachedInterpolation;

		private CollisionDetectionMode m_cachedCollisionDetection;

		private RigidbodyConstraints m_cachedConstraints;

		private Vector3 m_cachedAxis;

		private Vector3 m_cachedAnchor;

		private bool m_cachedAutoConfigureConnectedAnchor;

		private Vector3 m_cachedConnectedAnchor;

		private Rigidbody m_cachedConnectedBody;

		private JointLimits m_cachedLimits;

		private bool m_cachedUseSpring;

		private JointSpring m_cachedSpring;

		private bool m_cachedUseMotor;

		private JointMotor m_cachedMotor;

		private bool m_isAutoClosingAction;

		private Vector3 m_lastPivotVel;

		private bool m_hasPivotVelSample;

		private float m_lastWhipImpulseTime;

		private const float WHIP_ALIGNMENT = 0.3f;

		public float CurrentPumpPos => m_curPumpPos;

		public float CurrentBoltPos => m_curBoltPos;

		public bool IsHandleLocked => m_isHandleLocked;

		public bool IsActionOpen => m_curPumpPos > m_lockT;

		public FoldState CurrentFold => CurrentFoldState;

		public bool IsFoldUnlocked { get; set; }

		public bool IsWelded => m_isWelded;

		private bool HasBarrel => (Object)(object)Chamber != (Object)null;

		private bool IsDeployedAndLocked => m_isWelded && CurrentFoldState == FoldState.Unfolded;

		private Transform PumpFrame => (!((Object)(object)Point_Grip_Forward != (Object)null)) ? ((Component)this).transform : Point_Grip_Forward.parent;

		public void LockHandle()
		{
			m_isHandleLocked = true;
		}

		public void UnlockHandle()
		{
			m_isHandleLocked = false;
		}

		private static float AxisComponent(Vector3 v, TravelAxis a)
		{
			return a switch
			{
				TravelAxis.X => v.x, 
				TravelAxis.Y => v.y, 
				_ => v.z, 
			};
		}

		private static Vector3 SetAxisComponent(Vector3 v, TravelAxis a, float value)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			switch (a)
			{
			case TravelAxis.X:
				v.x = value;
				break;
			case TravelAxis.Y:
				v.y = value;
				break;
			default:
				v.z = value;
				break;
			}
			return v;
		}

		private static Vector3 TravelAxisVector(TravelAxis a)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: Unknown result type (might be due to invalid IL or missing references)
			return (Vector3)(a switch
			{
				TravelAxis.X => Vector3.right, 
				TravelAxis.Y => Vector3.up, 
				_ => Vector3.forward, 
			});
		}

		private static bool IsSlideReleaseHeld(FVRViveHand hand)
		{
			if (hand.IsInStreamlinedMode)
			{
				return hand.Input.AXButtonPressed;
			}
			return hand.Input.TouchpadPressed && hand.Input.TouchpadSouthPressed;
		}

		public static bool IsFoldUnlatchHeld(FVRViveHand hand, float touchpadDeadzone)
		{
			if (hand.IsInStreamlinedMode)
			{
				return hand.Input.BYButtonPressed;
			}
			return hand.Input.TouchpadPressed && hand.Input.TouchpadNorthPressed && ((Vector2)(ref hand.Input.TouchpadAxes)).magnitude > touchpadDeadzone;
		}

		public override Transform GetMuzzle()
		{
			if ((Object)(object)((FVRFireArm)this).CurrentMuzzle != (Object)null)
			{
				return ((FVRFireArm)this).CurrentMuzzle;
			}
			return Muzzle;
		}

		public FVRPhysicalObjectSize GetCurrentSize()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			return (CurrentFoldState != FoldState.Folded) ? UnfoldedSize : FoldedSize;
		}

		public override void Awake()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//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_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: 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_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: 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_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: 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_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: 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)
			if (base.Barrels == null)
			{
				base.Barrels = (BreakActionBarrel[])(object)new BreakActionBarrel[0];
			}
			((BreakActionWeapon)this).Awake();
			base.m_hasEjector = false;
			base.m_hasExtraEjectors = false;
			base.m_hasLatch = false;
			base.m_hasLatchButton = false;
			base.UsesManuallyCockedHammers = false;
			base.m_EjectsOnOpen = false;
			GameObject val = new GameObject("BaseHingeDecoy");
			val.transform.SetParent(((Component)this).transform, false);
			Rigidbody val2 = val.AddComponent<Rigidbody>();
			val2.isKinematic = true;
			val2.useGravity = false;
			val2.detectCollisions = false;
			m_decoyHinge = val.AddComponent<HingeJoint>();
			m_qbPoseOverrideDeployed = ((FVRInteractiveObject)this).QBPoseOverride;
			if ((Object)(object)LifterChamber != (Object)null)
			{
				LifterChamber.Firearm = (FVRFireArm)(object)this;
				((FVRFireArm)this).FChambers.Add(LifterChamber);
				EnsureChamberProxyStub(LifterChamber);
			}
			if ((Object)(object)Chamber != (Object)null)
			{
				Chamber.Firearm = (FVRFireArm)(object)this;
				((FVRFireArm)this).FChambers.Add(Chamber);
				EnsureChamberProxyStub(Chamber);
				Chamber.IsManuallyChamberable = false;
			}
			if ((Object)(object)base.Hinge != (Object)null)
			{
				m_hingeGO = ((Component)base.Hinge).gameObject;
				m_hingeRB = m_hingeGO.GetComponent<Rigidbody>();
				m_hingeOriginalParent = m_hingeGO.transform.parent;
				if ((Object)(object)m_hingeOriginalParent != (Object)null)
				{
					m_hingeParentSeatedLocalPos = m_hingeOriginalParent.localPosition;
				}
				if ((Object)(object)m_hingeRB != (Object)null)
				{
					m_cachedMass = m_hingeRB.mass;
					m_cachedDrag = m_hingeRB.drag;
					m_cachedAngularDrag = m_hingeRB.angularDrag;
					m_cachedUseGravity = m_hingeRB.useGravity;
					m_cachedInterpolation = m_hingeRB.interpolation;
					m_cachedCollisionDetection = m_hingeRB.collisionDetectionMode;
					m_cachedConstraints = m_hingeRB.constraints;
				}
				m_cachedAxis = ((Joint)base.Hinge).axis;
				m_cachedAnchor = ((Joint)base.Hinge).anchor;
				m_cachedAutoConfigureConnectedAnchor = ((Joint)base.Hinge).autoConfigureConnectedAnchor;
				m_cachedConnectedAnchor = ((Joint)base.Hinge).connectedAnchor;
				m_cachedConnectedBody = ((Joint)base.Hinge).connectedBody;
				m_cachedLimits = base.Hinge.limits;
				m_cachedUseSpring = base.Hinge.useSpring;
				m_cachedSpring = base.Hinge.spring;
				m_cachedUseMotor = base.Hinge.useMotor;
				m_cachedMotor = base.Hinge.motor;
			}
			if ((Object)(object)Point_Grip_Forward != (Object)null && (Object)(object)Point_Grip_Rear != (Object)null)
			{
				float num = AxisComponent(Point_Grip_Forward.localPosition, PumpTravelAxis);
				float num2 = AxisComponent(Point_Grip_Rear.localPosition, PumpTravelAxis);
				float num3 = num2 - num;
				if (Mathf.Abs(num3) > 0.0001f)
				{
					m_strokeDistance = Mathf.Abs(num3);
					m_directionSign = ((!(num3 >= 0f)) ? (-1f) : 1f);
				}
			}
			if ((Object)(object)Point_Bolt_Forward != (Object)null && (Object)(object)Point_Bolt_Rear != (Object)null)
			{
				float num4 = AxisComponent(Point_Bolt_Forward.localPosition, BoltTravelAxis);
				float num5 = AxisComponent(Point_Bolt_Rear.localPosition, BoltTravelAxis);
				m_boltRange = new Vector2(num4, num5);
				if ((Object)(object)Point_Bolt_LockPoint != (Object)null)
				{
					float num6 = AxisComponent(Point_Bolt_LockPoint.localPosition, BoltTravelAxis);
					float num7 = num5 - num4;
					if (Mathf.Abs(num7) > 0.0001f)
					{
						m_lockT = Mathf.Clamp01((num6 - num4) / num7);
					}
				}
			}
			RecordSleeveStart();
			if ((Object)(object)Carrier != (Object)null)
			{
				m_carrierRestRotation = Carrier.localRotation;
			}
			if ((Object)(object)SlideBottom != (Object)null)
			{
				m_slideBottomRestRotation = SlideBottom.localRotation;
			}
			if (DebugDisableFolding)
			{
				CurrentFoldState = FoldState.Unfolded;
				m_debugWasEnabled = true;
				SnapHingeToFoldPose(FoldState.Unfolded);
				WeldBarrel();
			}
			else if (CurrentFoldState == FoldState.Folded)
			{
				SnapHingeToFoldPose(FoldState.Folded);
				WeldBarrel();
			}
			else
			{
				SnapHingeToFoldPose(FoldState.Unfolded);
				WeldBarrel();
			}
		}

		private static void EnsureChamberProxyStub(FVRFireArmChamber chamber)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			if (!((Object)(object)chamber == (Object)null))
			{
				if ((Object)(object)chamber.ProxyRound == (Object)null)
				{
					GameObject val = new GameObject("ProxyRoundStub");
					val.transform.SetParent(((Component)chamber).transform, false);
					chamber.ProxyRound = val.transform;
				}
				if ((Object)(object)chamber.ProxyMesh == (Object)null)
				{
					chamber.ProxyMesh = ((Component)chamber.ProxyRound).gameObject.AddComponent<MeshFilter>();
				}
				if ((Object)(object)chamber.ProxyRenderer == (Object)null)
				{
					chamber.ProxyRenderer = ((Component)chamber.ProxyRound).gameObject.AddComponent<MeshRenderer>();
					((Renderer)chamber.ProxyRenderer).enabled = false;
				}
			}
		}

		public override void BeginInteraction(FVRViveHand hand)
		{
			((FVRFireArm)this).BeginInteraction(hand);
			m_hasTriggerReset = true;
			m_hasUnlatchUpSinceBegin = false;
			m_wasCockButtonHeld = true;
			m_cockButtonConsumed = true;
		}

		public override void UpdateInteraction(FVRViveHand hand)
		{
			base.HasTriggerReset = true;
			((BreakActionWeapon)this).UpdateInteraction(hand);
			bool flag = IsSlideReleaseHeld(hand);
			if (flag && !m_wasCockButtonHeld && ShouldButtonCockHammer() && CockHammerManually())
			{
				m_cockButtonConsumed = true;
			}
			if (!flag)
			{
				m_cockButtonConsumed = false;
			}
			m_wasCockButtonHeld = flag;
			bool flag2 = (Object)(object)ForeGrip != (Object)null && IsFoldUnlatchHeld(hand, ForeGrip.UnlockInputThreshold);
			if (!flag2)
			{
				m_hasUnlatchUpSinceBegin = true;
			}
			if (CurrentFoldState == FoldState.Folded)
			{
				m_primaryUnlatchHeld = flag2 && m_hasUnlatchUpSinceBegin;
				return;
			}
			m_primaryUnlatchHeld = false;
			UpdateBurgessInput(hand);
		}

		private bool CockHammerManually()
		{
			if (!HasBarrel || m_isHammerCocked)
			{
				return false;
			}
			m_isHammerCocked = true;
			((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)7, 1f);
			return true;
		}

		private bool ShouldButtonCockHammer()
		{
			if (m_isHammerCocked || !HasBarrel)
			{
				return false;
			}
			if (!IsDeployedAndLocked)
			{
				return true;
			}
			return (Object)(object)Chamber != (Object)null && Chamber.IsFull && !Chamber.IsSpent;
		}

		private void UpdateBurgessInput(FVRViveHand hand)
		{
			if (!((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin || !HasBarrel)
			{
				return;
			}
			float triggerFloat = hand.Input.TriggerFloat;
			if (!m_hasTriggerReset && triggerFloat <= 0.45f)
			{
				m_hasTriggerReset = true;
				((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)16, 1f);
			}
			if (triggerFloat >= 0.85f && m_isHammerCocked && m_isWelded && m_hasReachedFore)
			{
				if ((m_hasTriggerReset || UsesSlamFireTrigger) && Time.time - m_lastFireTime >= 0.1f)
				{
					FireBurgess();
				}
				m_hasTriggerReset = false;
			}
		}

		private Transform GetEjectPoint()
		{
			if ((Object)(object)EjectionPort != (Object)null)
			{
				return EjectionPort;
			}
			return (!HasBarrel) ? ((Component)this).transform : Muzzle;
		}

		private void UpdateFoldedEjection()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			if (UsesSimplifiedFoldedChamberAccess || CurrentFoldState != FoldState.Folded || (Object)(object)Chamber == (Object)null || !Chamber.IsFull)
			{
				return;
			}
			Vector3 val = ((Component)this).transform.TransformDirection(FoldEjectionForce);
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f) && !(Vector3.Angle(Vector3.down, val) > FoldEjectionAngleThreshold))
			{
				FVRFireArmRound round = Chamber.GetRound();
				if (!((Object)(object)round == (Object)null))
				{
					Transform ejectPoint = GetEjectPoint();
					((FVRFireArm)this).PlayAudioEvent((FirearmAudioEventType)29, 1f);
					Chamber.EjectRound(ejectPoint.position, val, ((Component)this).transform.TransformDirection(FoldEjectionTorque), ejectPoint.position, ((Component)Chamber).transform.rotation, false);
				}
			}
		}

		public void EjectChamberShell()
		{
			//IL_0035: 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_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_005d: 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)
			if (!((Object)(object)Chamber == (Object)null) && Chamber.IsFull)
			{
				Transform ejectPoint = GetEjectPoint();
				Chamber.EjectRound(ejectPoint.position, ((Component)this).transform.TransformDirection(EjectionForce), ((Component)this).transform.TransformDirection(EjectionTorque), ejectPoint.position, ((Component)Chamber).transform.rotation, false);
			}
		}

		private void SnapHingeToPose(Vector3 localPos, Vector3 localEuler)
		{
			//IL_006a: 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_0099: 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)
			if (!((Object)(object)m_hingeGO == (Object)null))
			{
				if ((Object)(object)m_hingeOriginalParent != (Object)null && (Object)(object)m_hingeGO.transform.parent != (Object)(object)m_hingeOriginalParent)
				{
					m_hingeGO.transform.SetParent(m_hingeOriginalParent, true);
				}
				m_hingeGO.transform.localPosition = localPos;
				m_hingeGO.transform.localEulerAngles = localEuler;
				if ((Object)(object)m_hingeRB != (Object)null)
				{
					m_hingeRB.velocity = Vector3.zero;
					m_hingeRB.angularVelocity = Vector3.zero;
				}
			}
		}

		private void ApplyHingeSeating(bool seated)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_hingeOriginalParent == (Object)null))
			{
				m_hingeOriginalParent.localPosition = ((!seated) ? (m_hingeParentSeatedLocalPos + UnlatchedHingeParentOffset) : m_hingeParentSeatedLocalPos);
			}
		}

		private void SnapHingeToFoldPose(FoldState state)
		{
			//IL_002a: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			ApplyHingeSeating(state == FoldState.Unfolded);
			if (state == FoldState.Folded)
			{
				SnapHingeToPose(FoldedLocalPosition, FoldedLocalEuler);
			}
			else
			{
				SnapHingeToPose(UnfoldedLocalPosition, UnfoldedLocalEuler);
			}
		}

		private void WeldBarrel()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005e: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_hingeGO == (Object)null))
			{
				m_weldedLocalPos = ((Component)this).transform.InverseTransformPoint(m_hingeGO.transform.position);
				m_weldedLocalRot = Quaternion.Inverse(((Component)this).transform.rotation) * m_hingeGO.transform.rotation;
				if ((Object)(object)m_hingeRB != (Object)null)
				{
					m_hingeRB.velocity = Vector3.zero;
					m_hingeRB.angularVelocity = Vector3.zero;
				}
				if ((Object)(object)base.Hinge != (Object)null)
				{
					Object.Destroy((Object)(object)base.Hinge);
					base.Hinge = null;
				}
				if ((Object)(object)m_hingeRB != (Object)null)
				{
					Object.Destroy((Object)(object)m_hingeRB);
					m_hingeRB = null;
				}
				if ((Object)(object)ForeGrip != (Object)null)
				{
					ForeGrip.Hinge = null;
					ForeGrip.RB = null;
				}
				m_hingeGO.transform.SetParent(((Component)this).transform, true);
				m_isWelded = true;
				m_needsPreciseWeldSnap = true;
				m_wasUnlatchRequested = true;
			}
		}

		private static Vector3 PickFoldReferenceAxis(Vector3 localAxis)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_002d: 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_0058: 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_004f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.forward;
			float num = Mathf.Abs(Vector3.Dot(localAxis, val));
			float num2 = Mathf.Abs(Vector3.Dot(localAxis, Vector3.up));
			if (num2 < num)
			{
				val = Vector3.up;
				num = num2;
			}
			float num3 = Mathf.Abs(Vector3.Dot(localAxis, Vector3.right));
			if (num3 < num)
			{
				val = Vector3.right;
				num = num3;
			}
			return val;
		}

		private static float SignedAngleAbout(Vector3 from, Vector3 to, Vector3 axis)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Angle(from, to);
			float num2 = Mathf.Sign(Vector3.Dot(axis, Vector3.Cross(from, to)));
			return num * num2;
		}

		private static float UnwrapNear(float angle, float center)
		{
			while (angle - center > 180f)
			{
				angle -= 360f;
			}
			while (angle - center < -180f)
			{
				angle += 360f;
			}
			return angle;
		}

		private float GetFoldToUnfoldSign(out Vector3 hingeAxisWorld, out Vector3 closedDir, out Vector3 openDir)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = TravelAxisVector((TravelAxis)FoldRotationAxis);
			hingeAxisWorld = m_hingeOriginalParent.TransformDirection(val);
			Vector3 val2 = PickFoldReferenceAxis(val);
			closedDir = m_hingeOriginalParent.rotation * Quaternion.Euler(FoldedLocalEuler) * val2;
			openDir = m_hingeOriginalParent.rotation * Quaternion.Euler(UnfoldedLocalEuler) * val2;
			return Mathf.Sign(Vector3.Dot(hingeAxisWorld, Vector3.Cross(closedDir, openDir)));
		}

		private void SeparateBarrel()
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: 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_00e1: 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_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//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_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: 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_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_hingeGO == (Object)null)
			{
				return;
			}
			bool isWelded = m_isWelded;
			m_needsPreciseWeldSnap = false;
			m_hingeGO.transform.SetParent(m_hingeOriginalParent, true);
			ApplyHingeSeating(seated: false);
			if ((Object)(object)m_hingeGO.GetComponent<Rigidbody>() == (Object)null)
			{
				m_hingeRB = m_hingeGO.AddComponent<Rigidbody>();
				m_hingeRB.mass = ((!(m_cachedMass > 0f)) ? 1f : m_cachedMass);
				m_hingeRB.drag = m_cachedDrag;
				m_hingeRB.angularDrag = m_cachedAngularDrag;
				m_hingeRB.useGravity = m_cachedUseGravity;
				m_hingeRB.interpolation = m_cachedInterpolation;
				m_hingeRB.collisionDetectionMode = m_cachedCollisionDetection;
				m_hingeRB.constraints = m_cachedConstraints;
			}
			else
			{
				m_hingeRB = m_hingeGO.GetComponent<Rigidbody>();
			}
			m_hingeRB.velocity = Vector3.zero;
			m_hingeRB.angularVelocity = Vector3.zero;
			m_hingeRB.maxAngularVelocity = 20f;
			HingeJoint val = m_hingeGO.GetComponent<HingeJoint>();
			if ((Object)(object)val == (Object)null)
			{
				val = m_hingeGO.AddComponent<HingeJoint>();
				((Joint)val).axis = m_cachedAxis;
				((Joint)val).anchor = m_cachedAnchor;
				((Joint)val).autoConfigureConnectedAnchor = false;
				Vector3 val2 = Vector3.zero;
				if ((Object)(object)m_hingeOriginalParent != (Object)null)
				{
					Vector3 val3 = m_hingeOriginalParent.localPosition - m_hingeParentSeatedLocalPos;
					if (((Vector3)(ref val3)).sqrMagnitude > 0f)
					{
						Transform parent = m_hingeOriginalParent.parent;
						Vector3 val4 = ((!((Object)(object)parent != (Object)null)) ? val3 : parent.TransformVector(val3));
						Transform val5 = ((!((Object)(object)m_cachedConnectedBody != (Object)null)) ? ((Component)this).transform : ((Component)m_cachedConnectedBody).transform);
						val2 = val5.InverseTransformVector(val4);
					}
				}
				((Joint)val).connectedAnchor = m_cachedConnectedAnchor + val2;
				((Joint)val).connectedBody = m_cachedConnectedBody;
				val.useLimits = true;
				Vector3 hingeAxisWorld;
				Vector3 closedDir;
				Vector3 openDir;
				float foldToUnfoldSign = GetFoldToUnfoldSign(out hingeAxisWorld, out closedDir, out openDir);
				float num = ((CurrentFoldState != FoldState.Folded) ? (0f - foldToUnfoldSign) : foldToUnfoldSign);
				JointLimits cachedLimits = m_cachedLimits;
				if (num > 0f)
				{
					((JointLimits)(ref cachedLimits)).min = 0f;
					((JointLimits)(ref cachedLimits)).max = base.HingeLimit;
				}
				else
				{
					((JointLimits)(ref cachedLimits)).min = 0f - base.HingeLimit;