Decompiled source of Dynamic Bones P6 v1.5.0

Mods/DynamicBonesBL.dll

Decompiled 2 weeks 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 BONELABTemplate;
using DynamicBonesFusion;
using FieldInjector;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using LabFusion.SDK.Modules;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Main), "DynamicBonesLoader", "0.2.1", "Coolkidstan", "https://thunderstore.io/c/bonelab/p/CoolkidStan/Dynamic_Bones_P6")]
[assembly: MelonGame("StressLevelZero", "Bonelab")]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: AssemblyTitle("A loader for dynamic bones scripts.")]
[assembly: AssemblyDescription("A loader for dynamic bones scripts.")]
[assembly: AssemblyCompany("Coolio Corp & Subsidary")]
[assembly: AssemblyProduct("DynamicBonesLoader")]
[assembly: AssemblyCopyright("Developed by Coolkidstan")]
[assembly: AssemblyTrademark("Coolio Corp & Subsidary")]
[assembly: AssemblyFileVersion("0.2.1")]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("0.2.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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;
		}
	}
}
public class BonelabDynamicBoneManager
{
	private List<DynamicBone> m_AvatarBones = new List<DynamicBone>();

	private List<MapDbone> m_MapBones = new List<MapDbone>();

	private float m_LastOptimizationTime;

	private const float OPTIMIZATION_INTERVAL = 2f;

	public void Initialize()
	{
		MelonLogger.Msg("[MapBone] Initializing Dynamic Bone Manager...");
		ProcessAllDynamicBones();
		MelonLogger.Msg($"[MapBone] Found {m_AvatarBones.Count} avatar bones and {m_MapBones.Count} map bones");
	}

	public void ProcessAllDynamicBones()
	{
		m_AvatarBones.Clear();
		m_MapBones.Clear();
		MapDboneModDetection.CategorizeAllDynamicBones(out m_AvatarBones, out m_MapBones);
		ProcessAvatarBones();
		ProcessMapBones();
		MapDboneModDetection.LogAllDynamicBones();
	}

	private void ProcessAvatarBones()
	{
		foreach (DynamicBone avatarBone in m_AvatarBones)
		{
			if (avatarBone.m_BlendWeight < 1f)
			{
				avatarBone.m_BlendWeight = 1f;
			}
			MelonLogger.Msg("[AvatarBone] Configured: " + ((Object)avatarBone).name);
		}
	}

	private void ProcessMapBones()
	{
		foreach (MapDbone mapBone in m_MapBones)
		{
			HandleMapDynamicBone(mapBone);
		}
	}

	private void HandleMapDynamicBone(MapDbone mapBone)
	{
		MelonLogger.Msg("[MapBone] Processing: " + ((Object)mapBone).name);
		MelonLogger.Msg($"  Mode: {mapBone.m_RigMode}");
		ConfigureMapBoneSettings(mapBone);
	}

	private void ConfigureMapBoneSettings(MapDbone mapBone)
	{
		mapBone.m_DistantDisable = true;
		mapBone.m_DistanceToObject = 30f;
		switch (mapBone.m_RigMode)
		{
		case MapDbone.RigMode.Hierarchy:
			mapBone.m_UpdateRate = 45f;
			break;
		case MapDbone.RigMode.PhantomRig:
			mapBone.m_UpdateRate = 30f;
			break;
		case MapDbone.RigMode.Automatic:
			mapBone.m_UpdateRate = 60f;
			break;
		}
		ApplyNameBasedSettings(mapBone);
	}

	private void ApplyNameBasedSettings(MapDbone mapBone)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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)
		string text = ((Object)mapBone).name.ToLower();
		if (text.Contains("flag") || text.Contains("banner"))
		{
			mapBone.m_Force = new Vector3(0.5f, 0f, 0.3f);
			mapBone.m_Damping = 0.1f;
			mapBone.m_Elasticity = 0.8f;
		}
		else if (text.Contains("chain") || text.Contains("rope"))
		{
			mapBone.m_Gravity = new Vector3(0f, -15f, 0f);
			mapBone.m_Damping = 0.2f;
			mapBone.m_Elasticity = 0.3f;
		}
		else if (text.Contains("hair") || text.Contains("fur"))
		{
			mapBone.m_Gravity = new Vector3(0f, -5f, 0f);
			mapBone.m_Damping = 0.05f;
			mapBone.m_Elasticity = 0.9f;
		}
		else if (text.Contains("cloth") || text.Contains("fabric"))
		{
			mapBone.m_Gravity = new Vector3(0f, -9.81f, 0f);
			mapBone.m_Damping = 0.15f;
			mapBone.m_Elasticity = 0.6f;
		}
	}

	public void Update()
	{
		if (Time.time - m_LastOptimizationTime > 2f)
		{
			OptimizePerformance();
			m_LastOptimizationTime = Time.time;
		}
	}

	public void OptimizePerformance()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if (!((Object)(object)main == (Object)null))
		{
			int num = MapDboneModDetection.OptimizeMapBonesByDistance(((Component)main).transform.position);
			if (num > 0)
			{
				MelonLogger.Msg($"[MapBone] Optimized {num} map bones based on distance");
			}
			MaintainAvatarBoneQuality();
		}
	}

	private void MaintainAvatarBoneQuality()
	{
		foreach (DynamicBone avatarBone in m_AvatarBones)
		{
			if (!((Object)(object)avatarBone == (Object)null))
			{
				if (!((Behaviour)avatarBone).enabled)
				{
					((Behaviour)avatarBone).enabled = true;
				}
				if (avatarBone.m_BlendWeight < 1f)
				{
					avatarBone.m_BlendWeight = 1f;
				}
			}
		}
	}

	public void DisableAllMapBones()
	{
		foreach (MapDbone mapBone in m_MapBones)
		{
			if ((Object)(object)mapBone != (Object)null)
			{
				((Behaviour)mapBone).enabled = false;
			}
		}
		MelonLogger.Msg($"[MapBone] Disabled {m_MapBones.Count} map bones");
	}

	public void EnableAllMapBones()
	{
		foreach (MapDbone mapBone in m_MapBones)
		{
			if ((Object)(object)mapBone != (Object)null)
			{
				((Behaviour)mapBone).enabled = true;
			}
		}
		MelonLogger.Msg($"[MapBone] Enabled {m_MapBones.Count} map bones");
	}

	public void LogPerformanceStats()
	{
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		foreach (MapDbone mapBone in m_MapBones)
		{
			if (!((Object)(object)mapBone == (Object)null))
			{
				if (((Behaviour)mapBone).enabled)
				{
					num++;
				}
				else
				{
					num2++;
				}
				if (mapBone.m_RigMode == MapDbone.RigMode.Hierarchy)
				{
					num3++;
				}
				else if (mapBone.m_RigMode == MapDbone.RigMode.PhantomRig)
				{
					num4++;
				}
			}
		}
		MelonLogger.Msg("=== Dynamic Bone Performance Stats ===");
		MelonLogger.Msg($"Avatar Bones: {m_AvatarBones.Count} (always enabled)");
		MelonLogger.Msg($"Map Bones Total: {m_MapBones.Count}");
		MelonLogger.Msg($"  Enabled: {num}");
		MelonLogger.Msg($"  Disabled: {num2}");
		MelonLogger.Msg($"  Hierarchy Mode: {num3}");
		MelonLogger.Msg($"  Phantom Mode: {num4}");
	}

	public void ConfigureMapBonesByNamePattern(string namePattern, Action<MapDbone> configAction)
	{
		List<MapDbone> list = MapDboneModDetection.FindMapBonesByNamePattern(namePattern);
		foreach (MapDbone item in list)
		{
			configAction?.Invoke(item);
		}
		MelonLogger.Msg($"[MapBone] Configured {list.Count} bones with name pattern '{namePattern}'");
	}
}
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;

	public float m_Damping = 0.1f;

	public AnimationCurve m_DampingDistrib;

	public float m_Elasticity = 0.1f;

	public AnimationCurve m_ElasticityDistrib;

	public float m_Stiffness = 0.1f;

	public AnimationCurve m_StiffnessDistrib;

	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;

	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;

	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 static int s_UpdateCount;

	private static int s_PrepareFrame;

	private bool m_IsMirrorClone;

	private Vector3 m_MirrorPlaneNormal = Vector3.forward;

	private void Start()
	{
		//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_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((Component)this).transform;
		while ((Object)(object)val != (Object)null)
		{
			string text = ((Object)val).name.ToLower();
			if (text.Contains("mirror") || text.Contains("reflection") || text.Contains("reflectionplane"))
			{
				m_IsMirrorClone = true;
				Transform val2 = val;
				if ((Object)(object)val2 != (Object)null)
				{
					m_MirrorPlaneNormal = val2.forward;
				}
				break;
			}
			val = val.parent;
		}
		if (((Vector3)(ref m_Gravity)).magnitude == 0f && ((Vector3)(ref m_Force)).magnitude == 0f)
		{
			m_Gravity = new Vector3(0f, -9.81f, 0f);
		}
		SetupParticles();
	}

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

	private void Update()
	{
		if (m_UpdateMode != UpdateMode.AnimatePhysics)
		{
			PreUpdate();
		}
		s_UpdateCount++;
	}

	private void LateUpdate()
	{
		if (m_PreUpdateCount != 0)
		{
			if (s_UpdateCount > 0)
			{
				s_UpdateCount = 0;
				s_PrepareFrame++;
			}
			SetWeight(m_BlendWeight);
			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_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_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_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_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)
		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_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_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		pt.m_RootWorldToLocalMatrix = pt.m_Root.worldToLocalMatrix;
		pt.m_LocalGravity = m_Gravity;
		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 && ((Il2CppArrayBase<Keyframe>)(object)m_DampingDistrib.keys).Length > 0)
				{
					particle.m_Damping *= m_DampingDistrib.Evaluate(num);
				}
				if (m_ElasticityDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)m_ElasticityDistrib.keys).Length > 0)
				{
					particle.m_Elasticity *= m_ElasticityDistrib.Evaluate(num);
				}
				if (m_StiffnessDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)m_StiffnessDistrib.keys).Length > 0)
				{
					particle.m_Stiffness *= m_StiffnessDistrib.Evaluate(num);
				}
				if (m_InertDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)m_InertDistrib.keys).Length > 0)
				{
					particle.m_Inert *= m_InertDistrib.Evaluate(num);
				}
				if (m_FrictionDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)m_FrictionDistrib.keys).Length > 0)
				{
					particle.m_Friction *= m_FrictionDistrib.Evaluate(num);
				}
				if (m_RadiusDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)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_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_0011: 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_0026: 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_002c: 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)
		//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_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: 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_0134: 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_0085: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_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_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_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_011b: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = m_Gravity;
		Vector3 normalized = ((Vector3)(ref val)).normalized;
		Vector3 val2 = normalized * Mathf.Max(Vector3.Dot(pt.m_RestGravity, normalized), 0f);
		val -= val2;
		val = (val + m_Force) * (m_ObjectScale * timeVar);
		Vector3 val3 = ((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 val4 = particle.m_Position - particle.m_PrevPosition;
				Vector3 val5 = val3 * particle.m_Inert;
				particle.m_PrevPosition = particle.m_Position + val5;
				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 += val4 * (1f - num) + val + val5;
			}
			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 static Vector3 ReflectPointAcrossPlane(Vector3 point, Vector3 planeNormal)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		return point - 2f * Vector3.Dot(point, planeNormal) * planeNormal;
	}

	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;
			}
		}
	}
}
public class DynamicBoneCollider : DynamicBoneColliderBase
{
	public float m_Radius = 0.5f;

	public float m_Height;

	public override bool Collide(ref Vector3 particlePosition, float particleRadius)
	{
		return false;
	}
}
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 = -1;

	public virtual void Prepare()
	{
	}

	public virtual bool Collide(ref Vector3 particlePosition, float particleRadius)
	{
		return false;
	}
}
public class DynamicBonePlaneCollider : DynamicBoneColliderBase
{
	public override bool Collide(ref Vector3 particlePosition, float particleRadius)
	{
		return false;
	}
}
public class MapDbone : MonoBehaviour
{
	public enum RigMode
	{
		Automatic,
		Hierarchy,
		PhantomRig
	}

	public enum UpdateMode
	{
		Normal,
		AnimatePhysics,
		UnscaledTime,
		Default
	}

	public enum ColliderGenerationMode
	{
		Manual,
		AutoCapsule,
		DynamicMesh
	}

	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 bool m_IsMapDynamicBone = true;

	public Transform m_Root;

	public RigMode m_RigMode;

	public List<Transform> m_ExcludeFromHierarchy;

	public int m_SegmentCount = 5;

	public Vector3 m_RigDirection = Vector3.up;

	public float m_RigLength;

	public bool m_AutoGenerateFromBounds = true;

	public float m_UpdateRate = 60f;

	public UpdateMode m_UpdateMode = UpdateMode.Default;

	public float m_Damping = 0.1f;

	public AnimationCurve m_DampingDistrib;

	public float m_Elasticity = 0.1f;

	public AnimationCurve m_ElasticityDistrib;

	public float m_Stiffness = 0.1f;

	public AnimationCurve m_StiffnessDistrib;

	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 Vector3 m_Gravity = Vector3.zero;

	public Vector3 m_Force = Vector3.zero;

	public float m_BlendWeight = 1f;

	public List<DynamicBoneColliderBase> m_Colliders;

	public ColliderGenerationMode m_ColliderMode;

	public bool m_CollideWithOtherChains;

	public bool m_CollideWithExternal = true;

	public float m_AutoCapsuleRadiusMultiplier = 1f;

	public bool m_GenerateCapsuleAlongChain = true;

	public int m_MeshUpdateInterval = 3;

	public int m_MeshSimplification = 1;

	public FreezeAxis m_FreezeAxis;

	public bool m_DistantDisable;

	public Transform m_ReferenceObject;

	public float m_DistanceToObject = 20f;

	public bool m_Multithread = true;

	private List<Transform> m_RigBones = new List<Transform>();

	private GameObject m_PhantomRigRoot;

	private Bounds m_OriginalBounds;

	private bool m_UsingHierarchyMode;

	private List<DynamicBoneColliderBase> m_GeneratedColliders = new List<DynamicBoneColliderBase>();

	private GameObject m_ColliderContainer;

	private int m_FrameCount;

	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 static int s_UpdateCount;

	private static int s_PrepareFrame;

	private void Start()
	{
		if ((Object)(object)((Component)this).GetComponent<MapDboneMarker>() == (Object)null)
		{
			((Component)this).gameObject.AddComponent<MapDboneMarker>();
		}
		InitializeRig();
		SetupParticles();
		GenerateColliders();
	}

	private void OnDestroy()
	{
		CleanupRig();
		CleanupColliders();
	}

	private void InitializeRig()
	{
		m_IsMapDynamicBone = true;
		if ((Object)(object)m_Root == (Object)null)
		{
			m_Root = ((Component)this).transform;
		}
		m_UsingHierarchyMode = false;
		m_RigBones.Clear();
		RigMode rigMode = m_RigMode;
		if (rigMode == RigMode.Automatic)
		{
			rigMode = (HasValidHierarchy() ? RigMode.Hierarchy : RigMode.PhantomRig);
		}
		if (rigMode == RigMode.Hierarchy)
		{
			InitializeHierarchyMode();
		}
		else
		{
			GeneratePhantomRig();
		}
		MelonLogger.Msg($"MapDbone: Initialized in {(m_UsingHierarchyMode ? "Hierarchy" : "Phantom")} mode with {m_RigBones.Count} bones");
	}

	private bool HasValidHierarchy()
	{
		if ((Object)(object)m_Root == (Object)null)
		{
			return false;
		}
		int num = 0;
		try
		{
			for (int i = 0; i < m_Root.childCount; i++)
			{
				Transform child = m_Root.GetChild(i);
				if ((Object)(object)child != (Object)null && !IsExcluded(child))
				{
					num++;
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Msg("[MapDbone] Error checking hierarchy for " + ((Object)this).name + ": " + ex.Message);
			return false;
		}
		return num > 0;
	}

	private void InitializeHierarchyMode()
	{
		m_UsingHierarchyMode = true;
		m_RigBones.Clear();
		CollectBonesFromHierarchy(m_Root);
		MelonLogger.Msg($"MapDbone: Using existing hierarchy with {m_RigBones.Count} bones");
	}

	private void CollectBonesFromHierarchy(Transform parent, bool isRootCall = true)
	{
		if ((Object)(object)parent == (Object)null)
		{
			return;
		}
		if (!isRootCall)
		{
			m_RigBones.Add(parent);
		}
		try
		{
			for (int i = 0; i < parent.childCount; i++)
			{
				Transform child = parent.GetChild(i);
				if ((Object)(object)child != (Object)null && !IsExcluded(child))
				{
					MapDbone component = ((Component)child).GetComponent<MapDbone>();
					if ((Object)(object)component != (Object)null && (Object)(object)component.m_Root == (Object)(object)parent)
					{
						CollectBonesFromHierarchy(child, isRootCall: false);
					}
					else if ((Object)(object)component == (Object)null)
					{
						CollectBonesFromHierarchy(child, isRootCall: false);
					}
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Msg("[MapDbone] Error collecting bones from hierarchy for " + ((Object)parent).name + ": " + ex.Message);
		}
	}

	private bool IsExcluded(Transform t)
	{
		if (m_ExcludeFromHierarchy == null)
		{
			return false;
		}
		return m_ExcludeFromHierarchy.Contains(t);
	}

	private void GeneratePhantomRig()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		CleanupRig();
		m_UsingHierarchyMode = false;
		m_PhantomRigRoot = new GameObject("PhantomRig_" + ((Object)m_Root).name);
		m_PhantomRigRoot.transform.SetParent(m_Root);
		m_PhantomRigRoot.transform.localPosition = Vector3.zero;
		m_PhantomRigRoot.transform.localRotation = Quaternion.identity;
		List<Transform> validChildObjects = GetValidChildObjects();
		if (validChildObjects.Count > 0)
		{
			GeneratePhantomRigFromChildren(validChildObjects);
		}
		else
		{
			GenerateUniformPhantomRig();
		}
		MelonLogger.Msg($"MapDbone: Generated phantom rig with {m_RigBones.Count} bones");
	}

	private List<Transform> GetValidChildObjects()
	{
		List<Transform> list = new List<Transform>();
		try
		{
			for (int i = 0; i < m_Root.childCount; i++)
			{
				Transform child = m_Root.GetChild(i);
				if (!((Object)(object)child == (Object)null) && !((Object)child).name.StartsWith("PhantomRig_") && !IsExcluded(child))
				{
					list.Add(child);
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Msg("[MapDbone] Error getting valid child objects for " + ((Object)m_Root).name + ": " + ex.Message);
		}
		return list;
	}

	private void GeneratePhantomRigFromChildren(List<Transform> childObjects)
	{
		//IL_0010: 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_0038: Unknown result type (might be due to invalid IL or missing references)
		m_RigBones.Clear();
		Transform transform = new GameObject("PhantomBone_Root").transform;
		transform.SetParent(m_PhantomRigRoot.transform);
		transform.localPosition = Vector3.zero;
		transform.localRotation = Quaternion.identity;
		m_RigBones.Add(transform);
		GenerateBonesRecursive(m_Root, transform, new HashSet<Transform>());
		MelonLogger.Msg($"MapDbone: Generated {m_RigBones.Count} phantom bones from {childObjects.Count} child objects (with branching)");
	}

	private void GenerateBonesRecursive(Transform currentObject, Transform parentBone, HashSet<Transform> processed)
	{
		//IL_0134: 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_013c: 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_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: 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_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		if (processed.Contains(currentObject))
		{
			return;
		}
		processed.Add(currentObject);
		List<Transform> list = new List<Transform>();
		try
		{
			for (int i = 0; i < currentObject.childCount; i++)
			{
				Transform child = currentObject.GetChild(i);
				if (!((Object)(object)child == (Object)null) && !((Object)child).name.StartsWith("PhantomRig_") && !IsExcluded(child))
				{
					list.Add(child);
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Msg("[MapDbone] Error getting children for " + ((Object)currentObject).name + ": " + ex.Message);
			return;
		}
		if (list.Count == 0)
		{
			return;
		}
		if (list.Count == 1)
		{
			Transform val = list[0];
			if (HasValidChildren(val))
			{
				GetObjectCenter(currentObject);
				Vector3 objectCenter = GetObjectCenter(val);
				Transform transform = new GameObject($"PhantomBone_{m_RigBones.Count}").transform;
				transform.SetParent(parentBone);
				transform.position = objectCenter;
				transform.rotation = Quaternion.identity;
				m_RigBones.Add(transform);
				GenerateBonesRecursive(val, transform, processed);
			}
			return;
		}
		Vector3 objectCenter2 = GetObjectCenter(currentObject);
		Vector3 position = parentBone.position;
		Transform parent = parentBone;
		if (Vector3.Distance(position, objectCenter2) > 0.01f)
		{
			Transform transform2 = new GameObject($"PhantomBone_ToBranch_{m_RigBones.Count}").transform;
			transform2.SetParent(parentBone);
			transform2.position = objectCenter2;
			transform2.rotation = Quaternion.identity;
			m_RigBones.Add(transform2);
			parent = transform2;
		}
		MelonLogger.Msg($"[MapDbone] Created branch point at {((Object)currentObject).name} with {list.Count} branches");
		for (int j = 0; j < list.Count; j++)
		{
			Transform val2 = list[j];
			if (HasValidChildren(val2))
			{
				Vector3 objectCenter3 = GetObjectCenter(val2);
				Transform transform3 = new GameObject($"PhantomBone_Branch{j}_{m_RigBones.Count}").transform;
				transform3.SetParent(parent);
				transform3.position = objectCenter3;
				transform3.rotation = Quaternion.identity;
				m_RigBones.Add(transform3);
				GenerateBonesRecursive(val2, transform3, processed);
			}
		}
	}

	private bool HasValidChildren(Transform t)
	{
		try
		{
			for (int i = 0; i < t.childCount; i++)
			{
				Transform child = t.GetChild(i);
				if (!((Object)(object)child == (Object)null) && !((Object)child).name.StartsWith("PhantomRig_") && !IsExcluded(child))
				{
					return true;
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Msg("[MapDbone] Error checking valid children for " + ((Object)t).name + ": " + ex.Message);
		}
		return false;
	}

	private Vector3 GetObjectCenter(Transform t)
	{
		//IL_0020: 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_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		Renderer component = ((Component)t).GetComponent<Renderer>();
		if ((Object)(object)component != (Object)null)
		{
			Bounds bounds = component.bounds;
			return ((Bounds)(ref bounds)).center;
		}
		return t.position;
	}

	private Vector3 GetCenterOrConnectionPoint(Transform parent, Transform child)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		return GetObjectCenter(child);
	}

	private void GenerateUniformPhantomRig()
	{
		//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_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_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_00b9: 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_00f5: 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_0101: Unknown result type (might be due to invalid IL or missing references)
		float num = m_RigLength;
		Vector3 normalized = ((Vector3)(ref m_RigDirection)).normalized;
		if (m_AutoGenerateFromBounds && num == 0f)
		{
			Renderer componentInChildren = ((Component)m_Root).GetComponentInChildren<Renderer>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				m_OriginalBounds = componentInChildren.bounds;
				Vector3 size = ((Bounds)(ref m_OriginalBounds)).size;
				num = ((Vector3)(ref size)).magnitude;
			}
			else
			{
				num = 1f;
			}
		}
		if (num == 0f)
		{
			num = 1f;
		}
		m_RigBones.Clear();
		float num2 = num / (float)(m_SegmentCount - 1);
		Transform parent = null;
		for (int i = 0; i < m_SegmentCount; i++)
		{
			Transform transform = new GameObject($"PhantomBone_{i}").transform;
			if (i == 0)
			{
				transform.SetParent(m_PhantomRigRoot.transform);
				transform.localPosition = Vector3.zero;
			}
			else
			{
				transform.SetParent(parent);
				transform.localPosition = normalized * num2;
			}
			transform.localRotation = Quaternion.identity;
			m_RigBones.Add(transform);
			parent = transform;
		}
	}

	private void CleanupRig()
	{
		if (!m_UsingHierarchyMode && (Object)(object)m_PhantomRigRoot != (Object)null)
		{
			if (Application.isPlaying)
			{
				Object.Destroy((Object)(object)m_PhantomRigRoot);
			}
			else
			{
				Object.DestroyImmediate((Object)(object)m_PhantomRigRoot);
			}
			m_PhantomRigRoot = null;
		}
		m_RigBones.Clear();
	}

	private void GenerateColliders()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_0050: 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)
		CleanupColliders();
		if (m_ColliderMode != 0)
		{
			m_ColliderContainer = new GameObject("GeneratedColliders_" + ((Object)((Component)this).gameObject).name);
			m_ColliderContainer.transform.SetParent(((Component)this).transform);
			m_ColliderContainer.transform.localPosition = Vector3.zero;
			m_ColliderContainer.transform.localRotation = Quaternion.identity;
			if (m_ColliderMode == ColliderGenerationMode.AutoCapsule)
			{
				GenerateAutoCapsuleColliders();
			}
			MelonLogger.Msg($"[MapDbone] Generated {m_GeneratedColliders.Count} colliders in {m_ColliderMode} mode");
		}
	}

	private void CleanupColliders()
	{
		foreach (DynamicBoneColliderBase generatedCollider in m_GeneratedColliders)
		{
			if ((Object)(object)generatedCollider != (Object)null && (Object)(object)((Component)generatedCollider).gameObject != (Object)null)
			{
				if (Application.isPlaying)
				{
					Object.Destroy((Object)(object)((Component)generatedCollider).gameObject);
				}
				else
				{
					Object.DestroyImmediate((Object)(object)((Component)generatedCollider).gameObject);
				}
			}
		}
		m_GeneratedColliders.Clear();
		if ((Object)(object)m_ColliderContainer != (Object)null)
		{
			if (Application.isPlaying)
			{
				Object.Destroy((Object)(object)m_ColliderContainer);
			}
			else
			{
				Object.DestroyImmediate((Object)(object)m_ColliderContainer);
			}
			m_ColliderContainer = null;
		}
	}

	private void GenerateAutoCapsuleColliders()
	{
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected O, but got Unknown
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: 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_0157: Unknown result type (might be due to invalid IL or missing references)
		if (m_ParticleTrees.Count == 0 || m_RigBones.Count == 0)
		{
			return;
		}
		foreach (ParticleTree particleTree in m_ParticleTrees)
		{
			for (int i = 0; i < particleTree.m_Particles.Count - 1; i++)
			{
				Particle particle = particleTree.m_Particles[i];
				Particle particle2 = particleTree.m_Particles[i + 1];
				if (particle.m_TransformNotNull && particle2.m_TransformNotNull)
				{
					GameObject val = new GameObject($"CapsuleCollider_{i}");
					val.transform.SetParent(particle.m_Transform);
					DynamicBoneCollider dynamicBoneCollider = val.AddComponent<DynamicBoneCollider>();
					_ = particle.m_Transform.position;
					Vector3 position = particle2.m_Transform.position;
					Vector3 val2 = particle.m_Transform.InverseTransformPoint(position);
					Vector3 localPosition = val2 * 0.5f;
					val.transform.localPosition = localPosition;
					float magnitude = ((Vector3)(ref val2)).magnitude;
					float radius = Mathf.Max(m_Radius, magnitude * 0.3f) * m_AutoCapsuleRadiusMultiplier;
					dynamicBoneCollider.m_Radius = radius;
					dynamicBoneCollider.m_Height = magnitude;
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					if (normalized != Vector3.zero)
					{
						val.transform.localRotation = Quaternion.FromToRotation(Vector3.up, normalized);
					}
					dynamicBoneCollider.m_Bound = DynamicBoneColliderBase.Bound.Outside;
					m_GeneratedColliders.Add(dynamicBoneCollider);
				}
			}
		}
	}

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

	private void Update()
	{
		if (m_UpdateMode != UpdateMode.AnimatePhysics)
		{
			PreUpdate();
		}
		s_UpdateCount++;
	}

	private void LateUpdate()
	{
		if (m_PreUpdateCount != 0)
		{
			if (s_UpdateCount > 0)
			{
				s_UpdateCount = 0;
				s_PrepareFrame++;
			}
			SetWeight(m_BlendWeight);
			CheckDistance();
			if (IsNeedUpdate())
			{
				Prepare();
				UpdateParticles();
				ApplyParticlesToTransforms();
			}
			m_PreUpdateCount = 0;
		}
	}

	private void Prepare()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_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_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_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		m_DeltaTime = Time.deltaTime;
		if (m_UpdateMode == UpdateMode.UnscaledTime)
		{
			m_DeltaTime = Time.unscaledDeltaTime;
		}
		else if (m_UpdateMode == UpdateMode.AnimatePhysics)
		{
			m_DeltaTime = Time.fixedDeltaTime * (float)m_PreUpdateCount;
		}
		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_CollideWithExternal && m_Colliders != null)
		{
			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;
					}
				}
			}
		}
		if (m_CollideWithOtherChains && m_GeneratedColliders != null && m_GeneratedColliders.Count > 0)
		{
			for (int l = 0; l < m_GeneratedColliders.Count; l++)
			{
				DynamicBoneColliderBase dynamicBoneColliderBase2 = m_GeneratedColliders[l];
				if ((Object)(object)dynamicBoneColliderBase2 != (Object)null && ((Behaviour)dynamicBoneColliderBase2).enabled)
				{
					if (m_EffectiveColliders == null)
					{
						m_EffectiveColliders = new List<DynamicBoneColliderBase>();
					}
					m_EffectiveColliders.Add(dynamicBoneColliderBase2);
					if (dynamicBoneColliderBase2.PrepareFrame != s_PrepareFrame)
					{
						dynamicBoneColliderBase2.Prepare();
						dynamicBoneColliderBase2.PrepareFrame = s_PrepareFrame;
					}
				}
			}
		}
		if (!m_CollideWithOtherChains)
		{
			return;
		}
		MapDbone[] array = Il2CppArrayBase<MapDbone>.op_Implicit(((Component)this).GetComponentsInParent<MapDbone>(true));
		foreach (MapDbone mapDbone in array)
		{
			if ((Object)(object)mapDbone == (Object)(object)this || mapDbone.m_GeneratedColliders == null)
			{
				continue;
			}
			foreach (DynamicBoneColliderBase generatedCollider in mapDbone.m_GeneratedColliders)
			{
				if ((Object)(object)generatedCollider != (Object)null && ((Behaviour)generatedCollider).enabled)
				{
					if (m_EffectiveColliders == null)
					{
						m_EffectiveColliders = new List<DynamicBoneColliderBase>();
					}
					m_EffectiveColliders.Add(generatedCollider);
					if (generatedCollider.PrepareFrame != s_PrepareFrame)
					{
						generatedCollider.Prepare();
						generatedCollider.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_IsMapDynamicBone = true;
		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);
		m_SegmentCount = Mathf.Max(m_SegmentCount, 2);
		m_RigLength = Mathf.Max(m_RigLength, 0f);
		if (Application.isEditor && Application.isPlaying)
		{
			UpdateParameters();
		}
	}

	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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		m_ParticleTrees.Clear();
		if (m_UsingHierarchyMode)
		{
			AppendParticleTree(m_Root);
		}
		else if (m_RigBones.Count > 0)
		{
			AppendParticleTree(m_RigBones[0]);
		}
		m_ObjectScale = Mathf.Abs(((Component)this).transform.lossyScale.x);
		m_ObjectPrevPosition = ((Component)this).transform.position;
		m_ObjectMove = Vector3.zero;
		for (int i = 0; i < m_ParticleTrees.Count; i++)
		{
			ParticleTree particleTree = m_ParticleTrees[i];
			if (m_UsingHierarchyMode)
			{
				using List<Transform>.Enumerator enumerator = m_RigBones.GetEnumerator();
				if (enumerator.MoveNext())
				{
					Transform current = enumerator.Current;
					AppendParticles(particleTree, current, -1, 0f);
				}
			}
			else
			{
				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_006e: 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_007e: 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;
		}
		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)
		{
			for (int i = 0; i < b.childCount; i++)
			{
				Transform child = b.GetChild(i);
				AppendParticles(pt, child, 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 && ((Il2CppArrayBase<Keyframe>)(object)m_DampingDistrib.keys).Length > 0)
				{
					particle.m_Damping *= m_DampingDistrib.Evaluate(num);
				}
				if (m_ElasticityDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)m_ElasticityDistrib.keys).Length > 0)
				{
					particle.m_Elasticity *= m_ElasticityDistrib.Evaluate(num);
				}
				if (m_StiffnessDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)m_StiffnessDistrib.keys).Length > 0)
				{
					particle.m_Stiffness *= m_StiffnessDistrib.Evaluate(num);
				}
				if (m_InertDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)m_InertDistrib.keys).Length > 0)
				{
					particle.m_Inert *= m_InertDistrib.Evaluate(num);
				}
				if (m_FrictionDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)m_FrictionDistrib.keys).Length > 0)
				{
					particle.m_Friction *= m_FrictionDistrib.Evaluate(num);
				}
				if (m_RadiusDistrib != null && ((Il2CppArrayBase<Keyframe>)(object)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_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);
			}
			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.