Decompiled source of SolidLib v1.2.2

SolidLib.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Extras;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using SolidLib.Components;
using SolidLib.NetcodePatcher;
using SolidLib.Registry;
using SolidLib.Utils;
using SolidLib.Utils.AssetLoading;
using SolidLib.Utils.Extensions;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SolidLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6e683211441854aeebd064d70abfd4fd3e392c0e")]
[assembly: AssemblyProduct("SolidLib")]
[assembly: AssemblyTitle("SolidLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[AddComponentMenu("Dynamic Bone/Dynamic Bone")]
public class DynamicBone : MonoBehaviour
{
	public enum UpdateMode
	{
		Normal,
		AnimatePhysics,
		UnscaledTime,
		Default
	}

	public enum FreezeAxis
	{
		None,
		X,
		Y,
		Z
	}

	private class Particle
	{
		public Transform m_Transform;

		public int m_ParentIndex;

		public int m_ChildCount;

		public float m_Damping;

		public float m_Elasticity;

		public float m_Stiffness;

		public float m_Inert;

		public float m_Friction;

		public float m_Radius;

		public float m_BoneLength;

		public bool m_isCollide;

		public bool m_TransformNotNull;

		public Vector3 m_Position;

		public Vector3 m_PrevPosition;

		public Vector3 m_EndOffset;

		public Vector3 m_InitLocalPosition;

		public Quaternion m_InitLocalRotation;

		public Vector3 m_TransformPosition;

		public Vector3 m_TransformLocalPosition;

		public Matrix4x4 m_TransformLocalToWorldMatrix;
	}

	private class ParticleTree
	{
		public Transform m_Root;

		public Vector3 m_LocalGravity;

		public Matrix4x4 m_RootWorldToLocalMatrix;

		public float m_BoneTotalLength;

		public List<Particle> m_Particles = new List<Particle>();

		public Vector3 m_RestGravity;
	}

	public Transform m_Root;

	public List<Transform> m_Roots;

	public float m_UpdateRate = 60f;

	public UpdateMode m_UpdateMode = UpdateMode.Default;

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

	public AnimationCurve m_DampingDistrib;

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

	public AnimationCurve m_ElasticityDistrib;

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

	public AnimationCurve m_StiffnessDistrib;

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

	public AnimationCurve m_InertDistrib;

	public float m_Friction;

	public AnimationCurve m_FrictionDistrib;

	public float m_Radius;

	public AnimationCurve m_RadiusDistrib;

	public float m_EndLength;

	public Vector3 m_EndOffset = Vector3.zero;

	public Vector3 m_Gravity = Vector3.zero;

	public Vector3 m_Force = Vector3.zero;

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

	public List<DynamicBoneColliderBase> m_Colliders;

	public List<Transform> m_Exclusions;

	public FreezeAxis m_FreezeAxis;

	public bool m_DistantDisable;

	public Transform m_ReferenceObject;

	public float m_DistanceToObject = 20f;

	[HideInInspector]
	public bool m_Multithread = true;

	private Vector3 m_ObjectMove;

	private Vector3 m_ObjectPrevPosition;

	private float m_ObjectScale;

	private float m_Time;

	private float m_Weight = 1f;

	private bool m_DistantDisabled;

	private int m_PreUpdateCount;

	private List<ParticleTree> m_ParticleTrees = new List<ParticleTree>();

	private float m_DeltaTime;

	private List<DynamicBoneColliderBase> m_EffectiveColliders;

	private bool m_WorkAdded;

	private static List<DynamicBone> s_PendingWorks = new List<DynamicBone>();

	private static List<DynamicBone> s_EffectiveWorks = new List<DynamicBone>();

	private static AutoResetEvent s_AllWorksDoneEvent;

	private static int s_RemainWorkCount;

	private static Semaphore s_WorkQueueSemaphore;

	private static int s_WorkQueueIndex;

	private static int s_UpdateCount;

	private static int s_PrepareFrame;

	private void Start()
	{
		SetupParticles();
	}

	private void FixedUpdate()
	{
		if (m_UpdateMode == UpdateMode.AnimatePhysics)
		{
			PreUpdate();
		}
	}

	private void Update()
	{
		if (m_UpdateMode != UpdateMode.AnimatePhysics)
		{
			PreUpdate();
		}
		if (m_PreUpdateCount > 0 && m_Multithread)
		{
			AddPendingWork(this);
			m_WorkAdded = true;
		}
		s_UpdateCount++;
	}

	private void LateUpdate()
	{
		if (m_PreUpdateCount == 0)
		{
			return;
		}
		if (s_UpdateCount > 0)
		{
			s_UpdateCount = 0;
			s_PrepareFrame++;
		}
		SetWeight(m_BlendWeight);
		if (m_WorkAdded)
		{
			m_WorkAdded = false;
			ExecuteWorks();
		}
		else
		{
			CheckDistance();
			if (IsNeedUpdate())
			{
				Prepare();
				UpdateParticles();
				ApplyParticlesToTransforms();
			}
		}
		m_PreUpdateCount = 0;
	}

	private void Prepare()
	{
		//IL_0012: 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_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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		m_DeltaTime = Time.deltaTime;
		m_ObjectScale = Mathf.Abs(((Component)this).transform.lossyScale.x);
		m_ObjectMove = ((Component)this).transform.position - m_ObjectPrevPosition;
		m_ObjectPrevPosition = ((Component)this).transform.position;
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			ParticleTree particleTree = m_ParticleTrees[i];
			particleTree.m_RestGravity = particleTree.m_Root.TransformDirection(particleTree.m_LocalGravity);
			for (int j = 0; j < particleTree.m_Particles.Count; j++)
			{
				Particle particle = particleTree.m_Particles[j];
				if (particle.m_TransformNotNull)
				{
					particle.m_TransformPosition = particle.m_Transform.position;
					particle.m_TransformLocalPosition = particle.m_Transform.localPosition;
					particle.m_TransformLocalToWorldMatrix = particle.m_Transform.localToWorldMatrix;
				}
			}
		}
		if (m_EffectiveColliders != null)
		{
			m_EffectiveColliders.Clear();
		}
		if (m_Colliders == null)
		{
			return;
		}
		for (int k = 0; k < m_Colliders.Count; k++)
		{
			DynamicBoneColliderBase dynamicBoneColliderBase = m_Colliders[k];
			if ((Object)(object)dynamicBoneColliderBase != (Object)null && ((Behaviour)dynamicBoneColliderBase).enabled)
			{
				if (m_EffectiveColliders == null)
				{
					m_EffectiveColliders = new List<DynamicBoneColliderBase>();
				}
				m_EffectiveColliders.Add(dynamicBoneColliderBase);
				if (dynamicBoneColliderBase.PrepareFrame != s_PrepareFrame)
				{
					dynamicBoneColliderBase.Prepare();
					dynamicBoneColliderBase.PrepareFrame = s_PrepareFrame;
				}
			}
		}
	}

	private bool IsNeedUpdate()
	{
		if (m_Weight > 0f)
		{
			if (m_DistantDisable)
			{
				return !m_DistantDisabled;
			}
			return true;
		}
		return false;
	}

	private void PreUpdate()
	{
		if (IsNeedUpdate())
		{
			InitTransforms();
		}
		m_PreUpdateCount++;
	}

	private void CheckDistance()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		if (!m_DistantDisable)
		{
			return;
		}
		Transform val = m_ReferenceObject;
		if ((Object)(object)val == (Object)null && (Object)(object)Camera.main != (Object)null)
		{
			val = ((Component)Camera.main).transform;
		}
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		Vector3 val2 = val.position - ((Component)this).transform.position;
		bool flag = ((Vector3)(ref val2)).sqrMagnitude > m_DistanceToObject * m_DistanceToObject;
		if (flag != m_DistantDisabled)
		{
			if (!flag)
			{
				ResetParticlesPosition();
			}
			m_DistantDisabled = flag;
		}
	}

	private void OnEnable()
	{
		ResetParticlesPosition();
	}

	private void OnDisable()
	{
		InitTransforms();
	}

	private void OnValidate()
	{
		m_UpdateRate = Mathf.Max(m_UpdateRate, 0f);
		m_Damping = Mathf.Clamp01(m_Damping);
		m_Elasticity = Mathf.Clamp01(m_Elasticity);
		m_Stiffness = Mathf.Clamp01(m_Stiffness);
		m_Inert = Mathf.Clamp01(m_Inert);
		m_Friction = Mathf.Clamp01(m_Friction);
		m_Radius = Mathf.Max(m_Radius, 0f);
		if (Application.isEditor && Application.isPlaying)
		{
			if (IsRootChanged())
			{
				InitTransforms();
				SetupParticles();
			}
			else
			{
				UpdateParameters();
			}
		}
	}

	private bool IsRootChanged()
	{
		List<Transform> list = new List<Transform>();
		if ((Object)(object)m_Root != (Object)null)
		{
			list.Add(m_Root);
		}
		if (m_Roots != null)
		{
			foreach (Transform root in m_Roots)
			{
				if ((Object)(object)root != (Object)null && !list.Contains(root))
				{
					list.Add(root);
				}
			}
		}
		if (list.Count != m_ParticleTrees.Count)
		{
			return true;
		}
		for (int i = 0; i < list.Count; i++)
		{
			if ((Object)(object)list[i] != (Object)(object)m_ParticleTrees[i].m_Root)
			{
				return true;
			}
		}
		return false;
	}

	private void OnDidApplyAnimationProperties()
	{
		UpdateParameters();
	}

	private void OnDrawGizmosSelected()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		if (((Behaviour)this).enabled)
		{
			if (Application.isEditor && !Application.isPlaying && ((Component)this).transform.hasChanged)
			{
				SetupParticles();
			}
			Gizmos.color = Color.white;
			for (int i = 0; i < m_ParticleTrees.Count; i++)
			{
				DrawGizmos(m_ParticleTrees[i]);
			}
		}
	}

	private void DrawGizmos(ParticleTree pt)
	{
		//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_004b: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < pt.m_Particles.Count; i++)
		{
			Particle particle = pt.m_Particles[i];
			if (particle.m_ParentIndex >= 0)
			{
				Particle particle2 = pt.m_Particles[particle.m_ParentIndex];
				Gizmos.DrawLine(particle.m_Position, particle2.m_Position);
			}
			if (particle.m_Radius > 0f)
			{
				Gizmos.DrawWireSphere(particle.m_Position, particle.m_Radius * m_ObjectScale);
			}
		}
	}

	public void SetWeight(float w)
	{
		if (m_Weight != w)
		{
			if (w == 0f)
			{
				InitTransforms();
			}
			else if (m_Weight == 0f)
			{
				ResetParticlesPosition();
			}
			m_Weight = (m_BlendWeight = w);
		}
	}

	public float GetWeight()
	{
		return m_Weight;
	}

	private void UpdateParticles()
	{
		if (m_ParticleTrees.Count <= 0)
		{
			return;
		}
		int num = 1;
		float timeVar = 1f;
		float deltaTime = m_DeltaTime;
		if (m_UpdateMode == UpdateMode.Default)
		{
			if (m_UpdateRate > 0f)
			{
				timeVar = deltaTime * m_UpdateRate;
			}
		}
		else if (m_UpdateRate > 0f)
		{
			float num2 = 1f / m_UpdateRate;
			m_Time += deltaTime;
			num = 0;
			while (m_Time >= num2)
			{
				m_Time -= num2;
				if (++num >= 3)
				{
					m_Time = 0f;
					break;
				}
			}
		}
		if (num > 0)
		{
			for (int i = 0; i < num; i++)
			{
				UpdateParticles1(timeVar, i);
				UpdateParticles2(timeVar);
			}
		}
		else
		{
			SkipUpdateParticles();
		}
	}

	public void SetupParticles()
	{
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		m_ParticleTrees.Clear();
		if ((Object)(object)m_Root != (Object)null)
		{
			AppendParticleTree(m_Root);
		}
		if (m_Roots != null)
		{
			for (int i = 0; i < m_Roots.Count; i++)
			{
				Transform root = m_Roots[i];
				if (!((Object)(object)root == (Object)null) && !m_ParticleTrees.Exists((ParticleTree x) => (Object)(object)x.m_Root == (Object)(object)root))
				{
					AppendParticleTree(root);
				}
			}
		}
		m_ObjectScale = Mathf.Abs(((Component)this).transform.lossyScale.x);
		m_ObjectPrevPosition = ((Component)this).transform.position;
		m_ObjectMove = Vector3.zero;
		for (int j = 0; j < m_ParticleTrees.Count; j++)
		{
			ParticleTree particleTree = m_ParticleTrees[j];
			AppendParticles(particleTree, particleTree.m_Root, -1, 0f);
		}
		UpdateParameters();
	}

	private void AppendParticleTree(Transform root)
	{
		//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)
		if (!((Object)(object)root == (Object)null))
		{
			ParticleTree particleTree = new ParticleTree();
			particleTree.m_Root = root;
			particleTree.m_RootWorldToLocalMatrix = root.worldToLocalMatrix;
			m_ParticleTrees.Add(particleTree);
		}
	}

	private void AppendParticles(ParticleTree pt, Transform b, int parentIndex, float boneLength)
	{
		//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_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		Particle particle = new Particle();
		particle.m_Transform = b;
		particle.m_TransformNotNull = (Object)(object)b != (Object)null;
		particle.m_ParentIndex = parentIndex;
		Vector3 val;
		if ((Object)(object)b != (Object)null)
		{
			val = (particle.m_Position = (particle.m_PrevPosition = b.position));
			particle.m_InitLocalPosition = b.localPosition;
			particle.m_InitLocalRotation = b.localRotation;
		}
		else
		{
			Transform transform = pt.m_Particles[parentIndex].m_Transform;
			if (m_EndLength > 0f)
			{
				Transform parent = transform.parent;
				if ((Object)(object)parent != (Object)null)
				{
					particle.m_EndOffset = transform.InverseTransformPoint(transform.position * 2f - parent.position) * m_EndLength;
				}
				else
				{
					particle.m_EndOffset = new Vector3(m_EndLength, 0f, 0f);
				}
			}
			else
			{
				particle.m_EndOffset = transform.InverseTransformPoint(((Component)this).transform.TransformDirection(m_EndOffset) + transform.position);
			}
			val = (particle.m_Position = (particle.m_PrevPosition = transform.TransformPoint(particle.m_EndOffset)));
			particle.m_InitLocalPosition = Vector3.zero;
			particle.m_InitLocalRotation = Quaternion.identity;
		}
		if (parentIndex >= 0)
		{
			float num = boneLength;
			val = pt.m_Particles[parentIndex].m_Transform.position - particle.m_Position;
			boneLength = num + ((Vector3)(ref val)).magnitude;
			particle.m_BoneLength = boneLength;
			pt.m_BoneTotalLength = Mathf.Max(pt.m_BoneTotalLength, boneLength);
			pt.m_Particles[parentIndex].m_ChildCount++;
		}
		int count = pt.m_Particles.Count;
		pt.m_Particles.Add(particle);
		if (!((Object)(object)b != (Object)null))
		{
			return;
		}
		for (int i = 0; i < b.childCount; i++)
		{
			Transform child = b.GetChild(i);
			bool flag = false;
			if (m_Exclusions != null)
			{
				flag = m_Exclusions.Contains(child);
			}
			if (!flag)
			{
				AppendParticles(pt, child, count, boneLength);
			}
			else if (m_EndLength > 0f || m_EndOffset != Vector3.zero)
			{
				AppendParticles(pt, null, count, boneLength);
			}
		}
		if (b.childCount == 0 && (m_EndLength > 0f || m_EndOffset != Vector3.zero))
		{
			AppendParticles(pt, null, count, boneLength);
		}
	}

	public void UpdateParameters()
	{
		SetWeight(m_BlendWeight);
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			UpdateParameters(m_ParticleTrees[i]);
		}
	}

	private void UpdateParameters(ParticleTree pt)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((Matrix4x4)(ref pt.m_RootWorldToLocalMatrix)).MultiplyVector(m_Gravity);
		pt.m_LocalGravity = ((Vector3)(ref val)).normalized * ((Vector3)(ref m_Gravity)).magnitude;
		for (int i = 0; i < pt.m_Particles.Count; i++)
		{
			Particle particle = pt.m_Particles[i];
			particle.m_Damping = m_Damping;
			particle.m_Elasticity = m_Elasticity;
			particle.m_Stiffness = m_Stiffness;
			particle.m_Inert = m_Inert;
			particle.m_Friction = m_Friction;
			particle.m_Radius = m_Radius;
			if (pt.m_BoneTotalLength > 0f)
			{
				float num = particle.m_BoneLength / pt.m_BoneTotalLength;
				if (m_DampingDistrib != null && m_DampingDistrib.keys.Length != 0)
				{
					particle.m_Damping *= m_DampingDistrib.Evaluate(num);
				}
				if (m_ElasticityDistrib != null && m_ElasticityDistrib.keys.Length != 0)
				{
					particle.m_Elasticity *= m_ElasticityDistrib.Evaluate(num);
				}
				if (m_StiffnessDistrib != null && m_StiffnessDistrib.keys.Length != 0)
				{
					particle.m_Stiffness *= m_StiffnessDistrib.Evaluate(num);
				}
				if (m_InertDistrib != null && m_InertDistrib.keys.Length != 0)
				{
					particle.m_Inert *= m_InertDistrib.Evaluate(num);
				}
				if (m_FrictionDistrib != null && m_FrictionDistrib.keys.Length != 0)
				{
					particle.m_Friction *= m_FrictionDistrib.Evaluate(num);
				}
				if (m_RadiusDistrib != null && m_RadiusDistrib.keys.Length != 0)
				{
					particle.m_Radius *= m_RadiusDistrib.Evaluate(num);
				}
			}
			particle.m_Damping = Mathf.Clamp01(particle.m_Damping);
			particle.m_Elasticity = Mathf.Clamp01(particle.m_Elasticity);
			particle.m_Stiffness = Mathf.Clamp01(particle.m_Stiffness);
			particle.m_Inert = Mathf.Clamp01(particle.m_Inert);
			particle.m_Friction = Mathf.Clamp01(particle.m_Friction);
			particle.m_Radius = Mathf.Max(particle.m_Radius, 0f);
		}
	}

	private void InitTransforms()
	{
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			InitTransforms(m_ParticleTrees[i]);
		}
	}

	private void InitTransforms(ParticleTree pt)
	{
		//IL_0020: 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)
		for (int i = 0; i < pt.m_Particles.Count; i++)
		{
			Particle particle = pt.m_Particles[i];
			if (particle.m_TransformNotNull)
			{
				particle.m_Transform.localPosition = particle.m_InitLocalPosition;
				particle.m_Transform.localRotation = particle.m_InitLocalRotation;
			}
		}
	}

	private void ResetParticlesPosition()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			ResetParticlesPosition(m_ParticleTrees[i]);
		}
		m_ObjectPrevPosition = ((Component)this).transform.position;
	}

	private void ResetParticlesPosition(ParticleTree pt)
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_002e: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < pt.m_Particles.Count; i++)
		{
			Particle particle = pt.m_Particles[i];
			if (particle.m_TransformNotNull)
			{
				particle.m_Position = (particle.m_PrevPosition = particle.m_Transform.position);
			}
			else
			{
				Transform transform = pt.m_Particles[particle.m_ParentIndex].m_Transform;
				particle.m_Position = (particle.m_PrevPosition = transform.TransformPoint(particle.m_EndOffset));
			}
			particle.m_isCollide = false;
		}
	}

	private void UpdateParticles1(float timeVar, int loopIndex)
	{
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			UpdateParticles1(m_ParticleTrees[i], timeVar, loopIndex);
		}
	}

	private void UpdateParticles1(ParticleTree pt, float timeVar, int loopIndex)
	{
		//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_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_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_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_0062: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: 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)
		Vector3 gravity = m_Gravity;
		Vector3 normalized = ((Vector3)(ref m_Gravity)).normalized;
		Vector3 val = normalized * Mathf.Max(Vector3.Dot(pt.m_RestGravity, normalized), 0f);
		gravity -= val;
		gravity = (gravity + m_Force) * (m_ObjectScale * timeVar);
		Vector3 val2 = ((loopIndex == 0) ? m_ObjectMove : Vector3.zero);
		for (int i = 0; i < pt.m_Particles.Count; i++)
		{
			Particle particle = pt.m_Particles[i];
			if (particle.m_ParentIndex >= 0)
			{
				Vector3 val3 = particle.m_Position - particle.m_PrevPosition;
				Vector3 val4 = val2 * particle.m_Inert;
				particle.m_PrevPosition = particle.m_Position + val4;
				float num = particle.m_Damping;
				if (particle.m_isCollide)
				{
					num += particle.m_Friction;
					if (num > 1f)
					{
						num = 1f;
					}
					particle.m_isCollide = false;
				}
				particle.m_Position += val3 * (1f - num) + gravity + val4;
			}
			else
			{
				particle.m_PrevPosition = particle.m_Position;
				particle.m_Position = particle.m_TransformPosition;
			}
		}
	}

	private void UpdateParticles2(float timeVar)
	{
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			UpdateParticles2(m_ParticleTrees[i], timeVar);
		}
	}

	private void UpdateParticles2(ParticleTree pt, float timeVar)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: 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_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: 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_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: 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_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: 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_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		Plane val = default(Plane);
		for (int i = 1; i < pt.m_Particles.Count; i++)
		{
			Particle particle = pt.m_Particles[i];
			Particle particle2 = pt.m_Particles[particle.m_ParentIndex];
			Vector3 val2;
			float magnitude;
			if (particle.m_TransformNotNull)
			{
				val2 = particle2.m_TransformPosition - particle.m_TransformPosition;
				magnitude = ((Vector3)(ref val2)).magnitude;
			}
			else
			{
				val2 = ((Matrix4x4)(ref particle2.m_TransformLocalToWorldMatrix)).MultiplyVector(particle.m_EndOffset);
				magnitude = ((Vector3)(ref val2)).magnitude;
			}
			float num = Mathf.Lerp(1f, particle.m_Stiffness, m_Weight);
			if (num > 0f || particle.m_Elasticity > 0f)
			{
				Matrix4x4 transformLocalToWorldMatrix = particle2.m_TransformLocalToWorldMatrix;
				((Matrix4x4)(ref transformLocalToWorldMatrix)).SetColumn(3, Vector4.op_Implicit(particle2.m_Position));
				Vector3 val3 = ((!particle.m_TransformNotNull) ? ((Matrix4x4)(ref transformLocalToWorldMatrix)).MultiplyPoint3x4(particle.m_EndOffset) : ((Matrix4x4)(ref transformLocalToWorldMatrix)).MultiplyPoint3x4(particle.m_TransformLocalPosition));
				Vector3 val4 = val3 - particle.m_Position;
				particle.m_Position += val4 * (particle.m_Elasticity * timeVar);
				if (num > 0f)
				{
					val4 = val3 - particle.m_Position;
					float magnitude2 = ((Vector3)(ref val4)).magnitude;
					float num2 = magnitude * (1f - num) * 2f;
					if (magnitude2 > num2)
					{
						particle.m_Position += val4 * ((magnitude2 - num2) / magnitude2);
					}
				}
			}
			if (m_EffectiveColliders != null)
			{
				float particleRadius = particle.m_Radius * m_ObjectScale;
				for (int j = 0; j < m_EffectiveColliders.Count; j++)
				{
					DynamicBoneColliderBase dynamicBoneColliderBase = m_EffectiveColliders[j];
					particle.m_isCollide |= dynamicBoneColliderBase.Collide(ref particle.m_Position, particleRadius);
				}
			}
			if (m_FreezeAxis != 0)
			{
				Vector4 column = ((Matrix4x4)(ref particle2.m_TransformLocalToWorldMatrix)).GetColumn((int)(m_FreezeAxis - 1));
				Vector3 val5 = Vector4.op_Implicit(((Vector4)(ref column)).normalized);
				((Plane)(ref val)).SetNormalAndPosition(val5, particle2.m_Position);
				particle.m_Position -= ((Plane)(ref val)).normal * ((Plane)(ref val)).GetDistanceToPoint(particle.m_Position);
			}
			Vector3 val6 = particle2.m_Position - particle.m_Position;
			float magnitude3 = ((Vector3)(ref val6)).magnitude;
			if (magnitude3 > 0f)
			{
				particle.m_Position += val6 * ((magnitude3 - magnitude) / magnitude3);
			}
		}
	}

	private void SkipUpdateParticles()
	{
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			SkipUpdateParticles(m_ParticleTrees[i]);
		}
	}

	private void SkipUpdateParticles(ParticleTree pt)
	{
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: 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_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_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_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < pt.m_Particles.Count; i++)
		{
			Particle particle = pt.m_Particles[i];
			if (particle.m_ParentIndex >= 0)
			{
				particle.m_PrevPosition += m_ObjectMove;
				particle.m_Position += m_ObjectMove;
				Particle particle2 = pt.m_Particles[particle.m_ParentIndex];
				Vector3 val;
				float magnitude;
				if (particle.m_TransformNotNull)
				{
					val = particle2.m_TransformPosition - particle.m_TransformPosition;
					magnitude = ((Vector3)(ref val)).magnitude;
				}
				else
				{
					val = ((Matrix4x4)(ref particle2.m_TransformLocalToWorldMatrix)).MultiplyVector(particle.m_EndOffset);
					magnitude = ((Vector3)(ref val)).magnitude;
				}
				float num = Mathf.Lerp(1f, particle.m_Stiffness, m_Weight);
				if (num > 0f)
				{
					Matrix4x4 transformLocalToWorldMatrix = particle2.m_TransformLocalToWorldMatrix;
					((Matrix4x4)(ref transformLocalToWorldMatrix)).SetColumn(3, Vector4.op_Implicit(particle2.m_Position));
					Vector3 val2 = ((!particle.m_TransformNotNull) ? ((Matrix4x4)(ref transformLocalToWorldMatrix)).MultiplyPoint3x4(particle.m_EndOffset) : ((Matrix4x4)(ref transformLocalToWorldMatrix)).MultiplyPoint3x4(particle.m_TransformLocalPosition));
					Vector3 val3 = val2 - particle.m_Position;
					float magnitude2 = ((Vector3)(ref val3)).magnitude;
					float num2 = magnitude * (1f - num) * 2f;
					if (magnitude2 > num2)
					{
						particle.m_Position += val3 * ((magnitude2 - num2) / magnitude2);
					}
				}
				Vector3 val4 = particle2.m_Position - particle.m_Position;
				float magnitude3 = ((Vector3)(ref val4)).magnitude;
				if (magnitude3 > 0f)
				{
					particle.m_Position += val4 * ((magnitude3 - magnitude) / magnitude3);
				}
			}
			else
			{
				particle.m_PrevPosition = particle.m_Position;
				particle.m_Position = particle.m_TransformPosition;
			}
		}
	}

	private static Vector3 MirrorVector(Vector3 v, Vector3 axis)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_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)
		return v - axis * (Vector3.Dot(v, axis) * 2f);
	}

	private void ApplyParticlesToTransforms()
	{
		//IL_0000: 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_0006: 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_0011: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		Vector3 right = Vector3.right;
		Vector3 up = Vector3.up;
		Vector3 forward = Vector3.forward;
		bool flag = false;
		bool flag2 = false;
		bool flag3 = false;
		Vector3 lossyScale = ((Component)this).transform.lossyScale;
		if (lossyScale.x < 0f || lossyScale.y < 0f || lossyScale.z < 0f)
		{
			Transform val = ((Component)this).transform;
			do
			{
				Vector3 localScale = val.localScale;
				flag = localScale.x < 0f;
				if (flag)
				{
					right = val.right;
				}
				flag2 = localScale.y < 0f;
				if (flag2)
				{
					up = val.up;
				}
				flag3 = localScale.z < 0f;
				if (flag3)
				{
					forward = val.forward;
				}
				if (flag || flag2 || flag3)
				{
					break;
				}
				val = val.parent;
			}
			while ((Object)(object)val != (Object)null);
		}
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			ApplyParticlesToTransforms(m_ParticleTrees[i], right, up, forward, flag, flag2, flag3);
		}
	}

	private void ApplyParticlesToTransforms(ParticleTree pt, Vector3 ax, Vector3 ay, Vector3 az, bool nx, bool ny, bool nz)
	{
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0097: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 1; i < pt.m_Particles.Count; i++)
		{
			Particle particle = pt.m_Particles[i];
			Particle particle2 = pt.m_Particles[particle.m_ParentIndex];
			if (particle2.m_ChildCount <= 1)
			{
				Vector3 val = ((!particle.m_TransformNotNull) ? particle.m_EndOffset : particle.m_Transform.localPosition);
				Vector3 val2 = particle2.m_Transform.TransformDirection(val);
				Vector3 val3 = particle.m_Position - particle2.m_Position;
				if (nx)
				{
					val3 = MirrorVector(val3, ax);
				}
				if (ny)
				{
					val3 = MirrorVector(val3, ay);
				}
				if (nz)
				{
					val3 = MirrorVector(val3, az);
				}
				Quaternion val4 = Quaternion.FromToRotation(val2, val3);
				particle2.m_Transform.rotation = val4 * particle2.m_Transform.rotation;
			}
			if (particle.m_TransformNotNull)
			{
				particle.m_Transform.position = particle.m_Position;
			}
		}
	}

	private static void AddPendingWork(DynamicBone db)
	{
		s_PendingWorks.Add(db);
	}

	private static void AddWorkToQueue(DynamicBone db)
	{
		s_WorkQueueSemaphore.Release();
	}

	private static DynamicBone GetWorkFromQueue()
	{
		int index = Interlocked.Increment(ref s_WorkQueueIndex);
		return s_EffectiveWorks[index];
	}

	private static void ThreadProc()
	{
		while (true)
		{
			s_WorkQueueSemaphore.WaitOne();
			GetWorkFromQueue().UpdateParticles();
			if (Interlocked.Decrement(ref s_RemainWorkCount) <= 0)
			{
				s_AllWorksDoneEvent.Set();
			}
		}
	}

	private static void InitThreadPool()
	{
		s_AllWorksDoneEvent = new AutoResetEvent(initialState: false);
		s_WorkQueueSemaphore = new Semaphore(0, int.MaxValue);
		int processorCount = Environment.ProcessorCount;
		for (int i = 0; i < processorCount; i++)
		{
			Thread thread = new Thread(ThreadProc);
			thread.IsBackground = true;
			thread.Start();
		}
	}

	private static void ExecuteWorks()
	{
		if (s_PendingWorks.Count <= 0)
		{
			return;
		}
		s_EffectiveWorks.Clear();
		for (int i = 0; i < s_PendingWorks.Count; i++)
		{
			DynamicBone dynamicBone = s_PendingWorks[i];
			if ((Object)(object)dynamicBone != (Object)null && ((Behaviour)dynamicBone).enabled)
			{
				dynamicBone.CheckDistance();
				if (dynamicBone.IsNeedUpdate())
				{
					s_EffectiveWorks.Add(dynamicBone);
				}
			}
		}
		s_PendingWorks.Clear();
		if (s_EffectiveWorks.Count > 0)
		{
			if (s_AllWorksDoneEvent == null)
			{
				InitThreadPool();
			}
			int num = (s_RemainWorkCount = s_EffectiveWorks.Count);
			s_WorkQueueIndex = -1;
			for (int j = 0; j < num; j++)
			{
				DynamicBone dynamicBone2 = s_EffectiveWorks[j];
				dynamicBone2.Prepare();
				AddWorkToQueue(dynamicBone2);
			}
			s_AllWorksDoneEvent.WaitOne();
			for (int k = 0; k < num; k++)
			{
				s_EffectiveWorks[k].ApplyParticlesToTransforms();
			}
		}
	}
}
[AddComponentMenu("Dynamic Bone/Dynamic Bone Collider")]
public class DynamicBoneCollider : DynamicBoneColliderBase
{
	public float m_Radius = 0.5f;

	public float m_Height;

	public float m_Radius2;

	private float m_ScaledRadius;

	private float m_ScaledRadius2;

	private Vector3 m_C0;

	private Vector3 m_C1;

	private float m_C01Distance;

	private int m_CollideType;

	private void OnValidate()
	{
		m_Radius = Mathf.Max(m_Radius, 0f);
		m_Height = Mathf.Max(m_Height, 0f);
		m_Radius2 = Mathf.Max(m_Radius2, 0f);
	}

	public override void Prepare()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: 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_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Abs(((Component)this).transform.lossyScale.x);
		float num2 = m_Height * 0.5f;
		Vector3 val;
		if (m_Radius2 <= 0f || Mathf.Abs(m_Radius - m_Radius2) < 0.01f)
		{
			m_ScaledRadius = m_Radius * num;
			float num3 = num2 - m_Radius;
			if (num3 <= 0f)
			{
				m_C0 = ((Component)this).transform.TransformPoint(m_Center);
				if (m_Bound == Bound.Outside)
				{
					m_CollideType = 0;
				}
				else
				{
					m_CollideType = 1;
				}
				return;
			}
			Vector3 center = m_Center;
			Vector3 center2 = m_Center;
			switch (m_Direction)
			{
			case Direction.X:
				center.x += num3;
				center2.x -= num3;
				break;
			case Direction.Y:
				center.y += num3;
				center2.y -= num3;
				break;
			case Direction.Z:
				center.z += num3;
				center2.z -= num3;
				break;
			}
			m_C0 = ((Component)this).transform.TransformPoint(center);
			m_C1 = ((Component)this).transform.TransformPoint(center2);
			val = m_C1 - m_C0;
			m_C01Distance = ((Vector3)(ref val)).magnitude;
			if (m_Bound == Bound.Outside)
			{
				m_CollideType = 2;
			}
			else
			{
				m_CollideType = 3;
			}
			return;
		}
		float num4 = Mathf.Max(m_Radius, m_Radius2);
		if (num2 - num4 <= 0f)
		{
			m_ScaledRadius = num4 * num;
			m_C0 = ((Component)this).transform.TransformPoint(m_Center);
			if (m_Bound == Bound.Outside)
			{
				m_CollideType = 0;
			}
			else
			{
				m_CollideType = 1;
			}
			return;
		}
		m_ScaledRadius = m_Radius * num;
		m_ScaledRadius2 = m_Radius2 * num;
		float num5 = num2 - m_Radius;
		float num6 = num2 - m_Radius2;
		Vector3 center3 = m_Center;
		Vector3 center4 = m_Center;
		switch (m_Direction)
		{
		case Direction.X:
			center3.x += num5;
			center4.x -= num6;
			break;
		case Direction.Y:
			center3.y += num5;
			center4.y -= num6;
			break;
		case Direction.Z:
			center3.z += num5;
			center4.z -= num6;
			break;
		}
		m_C0 = ((Component)this).transform.TransformPoint(center3);
		m_C1 = ((Component)this).transform.TransformPoint(center4);
		val = m_C1 - m_C0;
		m_C01Distance = ((Vector3)(ref val)).magnitude;
		if (m_Bound == Bound.Outside)
		{
			m_CollideType = 4;
		}
		else
		{
			m_CollideType = 5;
		}
	}

	public override bool Collide(ref Vector3 particlePosition, float particleRadius)
	{
		//IL_002d: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: 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)
		return m_CollideType switch
		{
			0 => OutsideSphere(ref particlePosition, particleRadius, m_C0, m_ScaledRadius), 
			1 => InsideSphere(ref particlePosition, particleRadius, m_C0, m_ScaledRadius), 
			2 => OutsideCapsule(ref particlePosition, particleRadius, m_C0, m_C1, m_ScaledRadius, m_C01Distance), 
			3 => InsideCapsule(ref particlePosition, particleRadius, m_C0, m_C1, m_ScaledRadius, m_C01Distance), 
			4 => OutsideCapsule2(ref particlePosition, particleRadius, m_C0, m_C1, m_ScaledRadius, m_ScaledRadius2, m_C01Distance), 
			5 => InsideCapsule2(ref particlePosition, particleRadius, m_C0, m_C1, m_ScaledRadius, m_ScaledRadius2, m_C01Distance), 
			_ => false, 
		};
	}

	private static bool OutsideSphere(ref Vector3 particlePosition, float particleRadius, Vector3 sphereCenter, float sphereRadius)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0032: 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)
		float num = sphereRadius + particleRadius;
		float num2 = num * num;
		Vector3 val = particlePosition - sphereCenter;
		float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
		if (sqrMagnitude > 0f && sqrMagnitude < num2)
		{
			float num3 = Mathf.Sqrt(sqrMagnitude);
			particlePosition = sphereCenter + val * (num / num3);
			return true;
		}
		return false;
	}

	private static bool InsideSphere(ref Vector3 particlePosition, float particleRadius, Vector3 sphereCenter, float sphereRadius)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		float num = sphereRadius - particleRadius;
		float num2 = num * num;
		Vector3 val = particlePosition - sphereCenter;
		float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
		if (sqrMagnitude > num2)
		{
			float num3 = Mathf.Sqrt(sqrMagnitude);
			particlePosition = sphereCenter + val * (num / num3);
			return true;
		}
		return false;
	}

	private static bool OutsideCapsule(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius, float dirlen)
	{
		//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_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_001e: 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_00c0: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		float num = capsuleRadius + particleRadius;
		float num2 = num * num;
		Vector3 val = capsuleP1 - capsuleP0;
		Vector3 val2 = particlePosition - capsuleP0;
		float num3 = Vector3.Dot(val2, val);
		if (num3 <= 0f)
		{
			float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
			if (sqrMagnitude > 0f && sqrMagnitude < num2)
			{
				float num4 = Mathf.Sqrt(sqrMagnitude);
				particlePosition = capsuleP0 + val2 * (num / num4);
				return true;
			}
		}
		else
		{
			float num5 = dirlen * dirlen;
			if (num3 >= num5)
			{
				val2 = particlePosition - capsuleP1;
				float sqrMagnitude2 = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude2 > 0f && sqrMagnitude2 < num2)
				{
					float num6 = Mathf.Sqrt(sqrMagnitude2);
					particlePosition = capsuleP1 + val2 * (num / num6);
					return true;
				}
			}
			else
			{
				Vector3 val3 = val2 - val * (num3 / num5);
				float sqrMagnitude3 = ((Vector3)(ref val3)).sqrMagnitude;
				if (sqrMagnitude3 > 0f && sqrMagnitude3 < num2)
				{
					float num7 = Mathf.Sqrt(sqrMagnitude3);
					particlePosition += val3 * ((num - num7) / num7);
					return true;
				}
			}
		}
		return false;
	}

	private static bool InsideCapsule(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius, float dirlen)
	{
		//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_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_001e: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		float num = capsuleRadius - particleRadius;
		float num2 = num * num;
		Vector3 val = capsuleP1 - capsuleP0;
		Vector3 val2 = particlePosition - capsuleP0;
		float num3 = Vector3.Dot(val2, val);
		if (num3 <= 0f)
		{
			float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
			if (sqrMagnitude > num2)
			{
				float num4 = Mathf.Sqrt(sqrMagnitude);
				particlePosition = capsuleP0 + val2 * (num / num4);
				return true;
			}
		}
		else
		{
			float num5 = dirlen * dirlen;
			if (num3 >= num5)
			{
				val2 = particlePosition - capsuleP1;
				float sqrMagnitude2 = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude2 > num2)
				{
					float num6 = Mathf.Sqrt(sqrMagnitude2);
					particlePosition = capsuleP1 + val2 * (num / num6);
					return true;
				}
			}
			else
			{
				Vector3 val3 = val2 - val * (num3 / num5);
				float sqrMagnitude3 = ((Vector3)(ref val3)).sqrMagnitude;
				if (sqrMagnitude3 > num2)
				{
					float num7 = Mathf.Sqrt(sqrMagnitude3);
					particlePosition += val3 * ((num - num7) / num7);
					return true;
				}
			}
		}
		return false;
	}

	private static bool OutsideCapsule2(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius0, float capsuleRadius1, float dirlen)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_0007: 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_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: 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_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: 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_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)
		Vector3 val = capsuleP1 - capsuleP0;
		Vector3 val2 = particlePosition - capsuleP0;
		float num = Vector3.Dot(val2, val);
		if (num <= 0f)
		{
			float num2 = capsuleRadius0 + particleRadius;
			float num3 = num2 * num2;
			float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
			if (sqrMagnitude > 0f && sqrMagnitude < num3)
			{
				float num4 = Mathf.Sqrt(sqrMagnitude);
				particlePosition = capsuleP0 + val2 * (num2 / num4);
				return true;
			}
		}
		else
		{
			float num5 = dirlen * dirlen;
			if (num >= num5)
			{
				float num6 = capsuleRadius1 + particleRadius;
				float num7 = num6 * num6;
				val2 = particlePosition - capsuleP1;
				float sqrMagnitude2 = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude2 > 0f && sqrMagnitude2 < num7)
				{
					float num8 = Mathf.Sqrt(sqrMagnitude2);
					particlePosition = capsuleP1 + val2 * (num6 / num8);
					return true;
				}
			}
			else
			{
				Vector3 val3 = val2 - val * (num / num5);
				float sqrMagnitude3 = ((Vector3)(ref val3)).sqrMagnitude;
				float num9 = Vector3.Dot(val2, val / dirlen);
				float num10 = Mathf.Lerp(capsuleRadius0, capsuleRadius1, num9 / dirlen) + particleRadius;
				float num11 = num10 * num10;
				if (sqrMagnitude3 > 0f && sqrMagnitude3 < num11)
				{
					float num12 = Mathf.Sqrt(sqrMagnitude3);
					particlePosition += val3 * ((num10 - num12) / num12);
					return true;
				}
			}
		}
		return false;
	}

	private static bool InsideCapsule2(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius0, float capsuleRadius1, float dirlen)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_0007: 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_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: 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_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_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: 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)
		//IL_0120: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = capsuleP1 - capsuleP0;
		Vector3 val2 = particlePosition - capsuleP0;
		float num = Vector3.Dot(val2, val);
		if (num <= 0f)
		{
			float num2 = capsuleRadius0 - particleRadius;
			float num3 = num2 * num2;
			float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
			if (sqrMagnitude > num3)
			{
				float num4 = Mathf.Sqrt(sqrMagnitude);
				particlePosition = capsuleP0 + val2 * (num2 / num4);
				return true;
			}
		}
		else
		{
			float num5 = dirlen * dirlen;
			if (num >= num5)
			{
				float num6 = capsuleRadius1 - particleRadius;
				float num7 = num6 * num6;
				val2 = particlePosition - capsuleP1;
				float sqrMagnitude2 = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude2 > num7)
				{
					float num8 = Mathf.Sqrt(sqrMagnitude2);
					particlePosition = capsuleP1 + val2 * (num6 / num8);
					return true;
				}
			}
			else
			{
				Vector3 val3 = val2 - val * (num / num5);
				float sqrMagnitude3 = ((Vector3)(ref val3)).sqrMagnitude;
				float num9 = Vector3.Dot(val2, val / dirlen);
				float num10 = Mathf.Lerp(capsuleRadius0, capsuleRadius1, num9 / dirlen) - particleRadius;
				float num11 = num10 * num10;
				if (sqrMagnitude3 > num11)
				{
					float num12 = Mathf.Sqrt(sqrMagnitude3);
					particlePosition += val3 * ((num10 - num12) / num12);
					return true;
				}
			}
		}
		return false;
	}

	private void OnDrawGizmosSelected()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		if (((Behaviour)this).enabled)
		{
			Prepare();
			if (m_Bound == Bound.Outside)
			{
				Gizmos.color = Color.yellow;
			}
			else
			{
				Gizmos.color = Color.magenta;
			}
			switch (m_CollideType)
			{
			case 0:
			case 1:
				Gizmos.DrawWireSphere(m_C0, m_ScaledRadius);
				break;
			case 2:
			case 3:
				DrawCapsule(m_C0, m_C1, m_ScaledRadius, m_ScaledRadius);
				break;
			case 4:
			case 5:
				DrawCapsule(m_C0, m_C1, m_ScaledRadius, m_ScaledRadius2);
				break;
			}
		}
	}

	private static void DrawCapsule(Vector3 c0, Vector3 c1, float radius0, float radius1)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: 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_000e: Unknown result type (might be due to invalid IL or missing references)
		Gizmos.DrawLine(c0, c1);
		Gizmos.DrawWireSphere(c0, radius0);
		Gizmos.DrawWireSphere(c1, radius1);
	}
}
public class DynamicBoneColliderBase : MonoBehaviour
{
	public enum Direction
	{
		X,
		Y,
		Z
	}

	public enum Bound
	{
		Outside,
		Inside
	}

	public Direction m_Direction = Direction.Y;

	public Vector3 m_Center = Vector3.zero;

	public Bound m_Bound;

	public int PrepareFrame { get; set; }

	public virtual void Start()
	{
	}

	public virtual void Prepare()
	{
	}

	public virtual bool Collide(ref Vector3 particlePosition, float particleRadius)
	{
		return false;
	}
}
[AddComponentMenu("Dynamic Bone/Dynamic Bone Plane Collider")]
public class DynamicBonePlaneCollider : DynamicBoneColliderBase
{
	private Plane m_Plane;

	private void OnValidate()
	{
	}

	public override void Prepare()
	{
		//IL_0000: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_0050: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Vector3.up;
		switch (m_Direction)
		{
		case Direction.X:
			val = ((Component)this).transform.right;
			break;
		case Direction.Y:
			val = ((Component)this).transform.up;
			break;
		case Direction.Z:
			val = ((Component)this).transform.forward;
			break;
		}
		Vector3 val2 = ((Component)this).transform.TransformPoint(m_Center);
		((Plane)(ref m_Plane)).SetNormalAndPosition(val, val2);
	}

	public override bool Collide(ref Vector3 particlePosition, float particleRadius)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		float distanceToPoint = ((Plane)(ref m_Plane)).GetDistanceToPoint(particlePosition);
		if (m_Bound == Bound.Outside)
		{
			if (distanceToPoint < 0f)
			{
				particlePosition -= ((Plane)(ref m_Plane)).normal * distanceToPoint;
				return true;
			}
		}
		else if (distanceToPoint > 0f)
		{
			particlePosition -= ((Plane)(ref m_Plane)).normal * distanceToPoint;
			return true;
		}
		return false;
	}

	private void OnDrawGizmosSelected()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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)
		if (((Behaviour)this).enabled)
		{
			Prepare();
			if (m_Bound == Bound.Outside)
			{
				Gizmos.color = Color.yellow;
			}
			else
			{
				Gizmos.color = Color.magenta;
			}
			Vector3 val = ((Component)this).transform.TransformPoint(m_Center);
			Gizmos.DrawLine(val, val + ((Plane)(ref m_Plane)).normal);
		}
	}
}
namespace SolidLib
{
	public static class WalkieTalkieExtensions
	{
		public static void TransmitOneShotAudio(Transform audioSource, AudioClip clip, float vol = 1f, float pitch = 1f)
		{
			//IL_006f: 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)
			if ((Object)(object)clip == (Object)null || (Object)(object)audioSource == (Object)null)
			{
				return;
			}
			for (int i = 0; i < WalkieTalkie.allWalkieTalkies.Count; i++)
			{
				if ((Object)(object)((GrabbableObject)WalkieTalkie.allWalkieTalkies[i]).playerHeldBy == (Object)null || !WalkieTalkie.allWalkieTalkies[i].clientIsHoldingAndSpeakingIntoThis || !((GrabbableObject)WalkieTalkie.allWalkieTalkies[i]).isBeingUsed)
				{
					continue;
				}
				float num = Vector3.Distance(((Component)WalkieTalkie.allWalkieTalkies[i]).transform.position, ((Component)audioSource).transform.position);
				if (!(num < WalkieTalkie.allWalkieTalkies[i].recordingRange))
				{
					continue;
				}
				for (int j = 0; j < WalkieTalkie.allWalkieTalkies.Count; j++)
				{
					if (j != i && ((GrabbableObject)WalkieTalkie.allWalkieTalkies[j]).isBeingUsed)
					{
						float num2 = Mathf.Lerp(WalkieTalkie.allWalkieTalkies[i].maxVolume, 0f, num / (WalkieTalkie.allWalkieTalkies[i].recordingRange + 3f));
						WalkieTalkie.allWalkieTalkies[j].target.pitch = pitch;
						WalkieTalkie.allWalkieTalkies[j].target.PlayOneShot(clip, num2 * vol);
					}
				}
			}
		}
	}
	public class LibConfig
	{
		public ConfigEntry<bool> extendedLogging;

		public LibConfig(ConfigFile cfg)
		{
			extendedLogging = cfg.Bind<bool>("General", "ExtendedLogging", false, "Extra logging for debugging");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			((Dictionary<ConfigDefinition, string>)((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(cfg, null)).Clear();
			cfg.Save();
		}
	}
	public static class PluginInformation
	{
		public const string PLUGIN_GUID = "solidlib";

		public const string PLUGIN_NAME = "Solid's Library";

		public const string PLUGIN_VERSION = "1.2.1";
	}
	[BepInPlugin("solidlib", "Solid's Library", "1.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SolidLib : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private readonly Harmony harmony = new Harmony("solidlib");

		private AssetBundle solidLibBundle;

		public static GameObject UtilsPrefab;

		private int materialCount;

		internal static LibConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Initializing Library");
			BoundConfig = new LibConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			Registries.InitRegistries();
			LoadAllIngameAssetsIntoRegistry();
			solidLibBundle = BundleUtils.LoadBundleFromInternalAssembly("solidlibassets");
			UtilsPrefab = solidLibBundle.LoadAsset<GameObject>("SolidLibUtils.prefab");
			NetworkPrefabs.RegisterNetworkPrefab(UtilsPrefab);
			harmony.PatchAll(Assembly.GetExecutingAssembly());
		}

		public static void LogExtended(object log)
		{
			if (BoundConfig.extendedLogging.Value)
			{
				Log.LogInfo(log);
			}
		}

		private void LoadAllIngameAssetsIntoRegistry()
		{
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace SolidLib.Utils
{
	public class SolidLibUtils : NetworkBehaviour
	{
		private static Random random;

		private static Dictionary<ulong, Action<GameObject>> pendingSpawns = new Dictionary<ulong, Action<GameObject>>();

		public static SolidLibUtils Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnItemServerRpc(ulong requestId, string itemName, Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Invalid comparison between Unknown and I4
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(569755127u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, requestId);
				bool flag = itemName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(itemName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 569755127u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				CompleteSpawn(requestId, null);
				return;
			}
			if (random == null)
			{
				random = new Random(StartOfRound.Instance.randomMapSeed + 85);
			}
			if (!Registries.ItemRegistry.TryGetValue(itemName, out Item item))
			{
				SolidLib.Log.LogInfo((object)"[Spawner] Failed to get item from registry");
				CompleteSpawn(requestId, null);
				return;
			}
			GameObject val3 = Object.Instantiate<GameObject>(item.spawnPrefab, position + Vector3.up, Quaternion.identity, StartOfRound.Instance.propsContainer);
			val3.GetComponent<NetworkObject>().TrySetParent(StartOfRound.Instance.propsContainer, true);
			val3.GetComponent<NetworkObject>().Spawn(false);
			val3.GetComponent<NetworkObject>().TrySetParent(StartOfRound.Instance.propsContainer, true);
			val3.GetComponent<NetworkObject>().TrySetParent(StartOfRound.Instance.propsContainer, true);
			int num = random.Next(item.minValue, item.maxValue);
			ScanNodeProperties componentInChildren = val3.GetComponentInChildren<ScanNodeProperties>();
			componentInChildren.scrapValue = num;
			componentInChildren.subText = $"Value: ${num}";
			val3.GetComponent<GrabbableObject>().scrapValue = num;
			SolidLib.Log.LogInfo((object)"[Spawner] Syncing Spawned Object");
			UpdateScanNodeClientRpc(new NetworkObjectReference(val3), num);
			CompleteSpawn(requestId, val3);
		}

		private void CompleteSpawn(ulong requestId, GameObject go)
		{
			if (pendingSpawns.TryGetValue(requestId, out Action<GameObject> value))
			{
				pendingSpawns.Remove(requestId);
				value?.Invoke(go);
			}
		}

		[ClientRpc]
		public void UpdateScanNodeClientRpc(NetworkObjectReference go, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(666025953u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref go, default(ForNetworkSerializable));
					BytePacker.WriteValueBitPacked(val2, value);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 666025953u, val, (RpcDelivery)0);
				}
				NetworkObject val3 = default(NetworkObject);
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ((NetworkObjectReference)(ref go)).TryGet(ref val3, (NetworkManager)null))
				{
					ScanNodeProperties componentInChildren = ((Component)val3).GetComponentInChildren<ScanNodeProperties>();
					componentInChildren.scrapValue = value;
					componentInChildren.subText = $"Value: ${value}";
				}
			}
		}

		public void SpawnItem(string itemName, Vector3 position, Action<GameObject> callback)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			ulong localClientId = NetworkManager.Singleton.LocalClientId;
			pendingSpawns[localClientId] = callback;
			SpawnItemServerRpc(localClientId, itemName, position);
		}

		public static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from s in configMoonRarity.Split(',')
				select s.Trim())
			{
				string[] array = item.Split(':');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (int.TryParse(array[1], out var result))
				{
					if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
					{
						dictionary[result2] = result;
					}
					else
					{
						dictionary2[text] = result;
					}
				}
			}
			return (dictionary, dictionary2);
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SolidLibUtils()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(569755127u, new RpcReceiveHandler(__rpc_handler_569755127));
			NetworkManager.__rpc_func_table.Add(666025953u, new RpcReceiveHandler(__rpc_handler_666025953));
		}

		private static void __rpc_handler_569755127(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong requestId = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref requestId);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string itemName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref itemName, false);
				}
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SolidLibUtils)(object)target).SpawnItemServerRpc(requestId, itemName, position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_666025953(N