Decompiled source of Wuthering Waves Characters v1.0.2

4.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using JigglePhysics;
using Microsoft.CodeAnalysis;
using ModelReplacement.AvatarBodyUpdater;
using ModelReplacement.Monobehaviors;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

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

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ModelReplacement
{
	public class WuWaReplacement : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			List<UnlockableItem> unlockables = StartOfRound.Instance.unlockablesList.unlockables;
			int currentSuitID = ((BodyReplacementBase)this).controller.currentSuitID;
			string text = ((currentSuitID >= 0 && currentSuitID < unlockables.Count) ? unlockables[currentSuitID].unlockableName : "");
			GameObject? obj = WuWaCharacters.LoadModel(text);
			if ((Object)(object)obj == (Object)null)
			{
				ManualLogSource? log = Plugin.Log;
				if (log == null)
				{
					return obj;
				}
				log.LogError((object)("[WuWa] no model for suit '" + text + "'"));
			}
			return obj;
		}

		protected override void AddModelScripts()
		{
			WuWaSize.Apply(base.replacementModel);
			WuWaColliders.Setup(base.replacementModel);
		}
	}
	[BepInPlugin("com.thatumi.taoqiv2", "Wuthering_Waves_Characters", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource? Log;

		internal static ConfigEntry<bool> EnableColliders;

		internal static ConfigEntry<float> ThighRadius;

		internal static ConfigEntry<float> CalfRadius;

		internal static ConfigEntry<float> TorsoRadius;

		internal static ConfigEntry<float> ArmRadius;

		internal static ConfigEntry<float> HipRadius;

		internal static ConfigEntry<float> ParticleRadiusMultiplier;

		internal static ConfigEntry<float> BodyColliderScale;

		internal static ConfigEntry<float> ClothColliderScale;

		internal static ConfigEntry<bool> GroundFeet;

		internal static ConfigEntry<float> HeadColliderScale;

		internal static ConfigEntry<bool> RealisticSize;

		internal static ConfigEntry<float> HeightOffset;

		internal static ConfigEntry<float> PlayerHeadHeight;

		internal static ConfigEntry<float> ReferenceHeadHeight;

		internal static ConfigEntry<string> AutoSuit;

		internal static ConfigEntry<bool> TestKeys;

		private void Awake()
		{
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			EnableColliders = ((BaseUnityPlugin)this).Config.Bind<bool>("Physics", "EnableBodyColliders", true, "Leg/torso colliders for cloth and hair physics (only on rigs using the WuWa_* presets).");
			ThighRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "ThighRadius", 0.16f, "Thigh capsule radius as a fraction of thigh length.");
			CalfRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "CalfRadius", 0.11f, "Calf capsule radius as a fraction of calf length.");
			TorsoRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "TorsoRadius", 0.45f, "Torso capsule radius as a fraction of Spine1->Neck length.");
			ArmRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "ArmRadius", 0.17f, "Upper arm capsule radius as a fraction of upper arm length (forearm uses 85%). Hair collides with it.");
			HipRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "HipRadius", 0.22f, "Hip capsule (across both hip joints) radius as a fraction of thigh length.");
			ParticleRadiusMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "ParticleRadiusMultiplier", 1f, "Multiplier for the cloth/hair bone collision radius from the physics presets.");
			BodyColliderScale = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "BodyColliderScale", 1f, "Multiplier for the body capsule radii (mesh-fitted from colliders/<id>.txt; Thigh/Calf/Torso/Arm/HipRadius are only used when that file is missing).");
			RealisticSize = ((BaseUnityPlugin)this).Config.Bind<bool>("Size", "RealisticSize", true, "Scale characters by their real in-game height (Encore small, Fleurdelys tall) instead of making everyone the same height.");
			PlayerHeadHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "PlayerHeadHeight", 2.5f, "World head height (game units) given to a character of ReferenceHeadHeight.");
			ReferenceHeadHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "ReferenceHeadHeight", 1.45f, "Native head bone height (metres) that maps to PlayerHeadHeight.");
			ClothColliderScale = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "ClothColliderScale", 1.3f, "Extra multiplier for all body capsules used by skirts/coats (cloth hangs outside the body; each cloth bone is still allowed as close as it is at rest).");
			HeadColliderScale = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "HeadColliderScale", 0.9f, "Extra multiplier for the head/neck capsules (hair only). Lower it if the hair puffs up off the head, raise it if hair still cuts into the head.");
			GroundFeet = ((BaseUnityPlugin)this).Config.Bind<bool>("Size", "GroundFeet", true, "Every frame put the model's lowest sole at the height of the player's lowest sole (fixes feet sinking into the floor).");
			HeightOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Size", "HeightOffset", 0f, "Extra vertical offset of every WuWa model in game units (+ = up). Fine-tune if the feet sink into / float above the floor.");
			AutoSuit = ((BaseUnityPlugin)this).Config.Bind<string>("Debug", "AutoSuit", "", "Suit to equip automatically when you spawn (e.g. Changli). Empty = off. Keys: F6/F7 prev/next WuWa suit, F8 showcase camera.");
			TestKeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "TestKeys", false, "Testing shortcuts: F10 = pull the ship lever (host), F11 = teleport outside the landed ship. Off by default (they are cheats).");
			WuWaCharacters.Load();
			foreach (string key in WuWaCharacters.Suits.Keys)
			{
				ModelReplacementAPI.RegisterSuitModelReplacement(key, typeof(WuWaReplacement));
			}
			WuWaDebug.Create();
			new Harmony("com.thatumi.taoqiv2").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Wuthering Waves Characters loaded: {WuWaCharacters.Suits.Count} suits.");
		}
	}
	public static class WuWaCharacters
	{
		public static readonly Dictionary<string, string> Suits = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		public static readonly List<string> Order = new List<string>();

		private static readonly Dictionary<string, AssetBundle> loaded = new Dictionary<string, AssetBundle>();

		internal static string Dir => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		public static void Load()
		{
			string text = Path.Combine(Dir, "suits.txt");
			if (!File.Exists(text))
			{
				ManualLogSource? log = Plugin.Log;
				if (log != null)
				{
					log.LogError((object)("[WuWa] missing " + text));
				}
				return;
			}
			string[] array = File.ReadAllLines(text);
			for (int i = 0; i < array.Length; i++)
			{
				string text2 = array[i].Trim();
				if (text2.Length == 0 || text2.StartsWith("#"))
				{
					continue;
				}
				int num = text2.IndexOf('=');
				if (num <= 0)
				{
					continue;
				}
				string text3 = text2.Substring(0, num).Trim();
				string text4 = text2.Substring(num + 1).Trim();
				if (!File.Exists(Path.Combine(Dir, "bundles", "wuwa_" + text4)))
				{
					ManualLogSource? log2 = Plugin.Log;
					if (log2 != null)
					{
						log2.LogWarning((object)("[WuWa] no bundle for " + text3 + " (" + text4 + ")"));
					}
				}
				else if (!Suits.ContainsKey(text3))
				{
					Suits[text3] = text4;
					Order.Add(text3);
				}
			}
		}

		public static GameObject? LoadModel(string suit)
		{
			if (!Suits.TryGetValue(suit, out string value))
			{
				return null;
			}
			if (!loaded.TryGetValue(value, out AssetBundle value2) || (Object)(object)value2 == (Object)null)
			{
				value2 = AssetBundle.LoadFromFile(Path.Combine(Dir, "bundles", "wuwa_" + value));
				if ((Object)(object)value2 == (Object)null)
				{
					ManualLogSource? log = Plugin.Log;
					if (log != null)
					{
						log.LogError((object)("[WuWa] failed to load bundle wuwa_" + value));
					}
					return null;
				}
				loaded[value] = value2;
			}
			return value2.LoadAsset<GameObject>(value);
		}
	}
	internal sealed class WuWaCapsule
	{
		public string Kind = "";

		public Transform A;

		public Transform B;

		public Vector3 LocalA;

		public Vector3 LocalB;

		public float RadiusA;

		public float RadiusB;

		public Vector3 WorldA;

		public Vector3 WorldB;

		public int Frame = -1;

		public bool Refresh(int frame)
		{
			//IL_0031: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			if (Frame == frame)
			{
				return true;
			}
			if ((Object)(object)A == (Object)null || (Object)(object)B == (Object)null)
			{
				return false;
			}
			WorldA = A.TransformPoint(LocalA);
			WorldB = B.TransformPoint(LocalB);
			Frame = frame;
			return true;
		}
	}
	internal sealed class WuWaCapsuleSet
	{
		public WuWaCapsule[] Capsules;

		public Dictionary<Transform, float[]> BoneFactor = new Dictionary<Transform, float[]>();

		public float[] Ones;

		public Transform ModelRoot;

		public bool Cloth;
	}
	[HarmonyPatch(typeof(JiggleBone), "CollisionPass")]
	internal static class JiggleCollisionPatch
	{
		internal static readonly ConditionalWeakTable<List<Collider>, WuWaCapsuleSet> Sets = new ConditionalWeakTable<List<Collider>, WuWaCapsuleSet>();

		internal static int Pushes;

		private static readonly FieldRef<JiggleBone, Vector3> WorkingPos = AccessTools.FieldRefAccess<JiggleBone, Vector3>("workingPosition");

		internal static float KindScale(string kind, bool cloth)
		{
			float num = Plugin.BodyColliderScale.Value;
			if (cloth)
			{
				num *= Plugin.ClothColliderScale.Value;
			}
			if (kind == "head")
			{
				num *= Plugin.HeadColliderScale.Value;
			}
			return num;
		}

		private static Vector3 Push(WuWaCapsule c, Vector3 q, float r, float radiusScale, float gain)
		{
			//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_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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_003b: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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)
			Vector3 worldA = c.WorldA;
			Vector3 val = c.WorldB - worldA;
			float num = Mathf.Clamp01(Vector3.Dot(q - worldA, val) / Mathf.Max(((Vector3)(ref val)).sqrMagnitude, 1E-08f));
			Vector3 val2 = q - (worldA + val * num);
			float num2 = Mathf.Lerp(c.RadiusA, c.RadiusB, num) * radiusScale + r;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (magnitude >= num2 || magnitude < 1E-06f)
			{
				return Vector3.zero;
			}
			Pushes++;
			return val2 * ((num2 - magnitude) / magnitude * gain);
		}

		private static bool Prefix(JiggleBone __instance, JiggleSettingsBase jiggleSettings, List<Collider> colliders, ref Vector3 ___workingPosition, float ___normalizedIndex)
		{
			//IL_007a: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			if (colliders == null || !Sets.TryGetValue(colliders, out WuWaCapsuleSet value))
			{
				return true;
			}
			if ((Object)(object)value.ModelRoot == (Object)null || __instance.parent == null)
			{
				return false;
			}
			Transform val = (((Object)(object)__instance.transform != (Object)null) ? __instance.transform : __instance.parent.transform);
			if ((Object)(object)val == (Object)null || !value.BoneFactor.TryGetValue(val, out float[] value2))
			{
				value2 = value.Ones;
			}
			int frameCount = Time.frameCount;
			float y = value.ModelRoot.lossyScale.y;
			float r = jiggleSettings.GetRadius(___normalizedIndex) * y * Plugin.ParticleRadiusMultiplier.Value;
			WuWaCapsule[] capsules = value.Capsules;
			Vector3 val2 = ___workingPosition;
			for (int i = 0; i < 2; i++)
			{
				for (int j = 0; j < capsules.Length; j++)
				{
					WuWaCapsule wuWaCapsule = capsules[j];
					if (!(value2[j] <= 0.05f) && wuWaCapsule.Refresh(frameCount))
					{
						val2 += Push(wuWaCapsule, val2, r, y * KindScale(wuWaCapsule.Kind, value.Cloth) * value2[j], 1f);
					}
				}
			}
			if (__instance.parent != null && __instance.parent.parent != null)
			{
				Vector3 val3 = WorkingPos.Invoke(__instance.parent);
				for (int k = 0; k < capsules.Length; k++)
				{
					WuWaCapsule wuWaCapsule2 = capsules[k];
					if (!(value2[k] <= 0.05f) && wuWaCapsule2.Refresh(frameCount))
					{
						val2 += Push(wuWaCapsule2, (val3 + val2) * 0.5f, r, y * KindScale(wuWaCapsule2.Kind, value.Cloth) * value2[k], 2f);
					}
				}
			}
			___workingPosition = val2;
			return false;
		}
	}
	public static class WuWaColliders
	{
		private const string PresetPrefix = "WuWa_";

		private static readonly HashSet<string> ClothKinds = new HashSet<string> { "leg", "foot", "hip", "body" };

		public static void Setup(GameObject model)
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)model == (Object)null || !Plugin.EnableColliders.Value)
			{
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform[] componentsInChildren = model.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (!dictionary.ContainsKey(((Object)val).name))
				{
					dictionary[((Object)val).name] = val;
				}
			}
			string text = ((Object)model).name;
			int num = text.IndexOf('(');
			if (num > 0)
			{
				text = text.Substring(0, num);
			}
			bool ok;
			List<WuWaCapsule> list = LoadFitted(text, dictionary, out ok);
			if (!ok)
			{
				list = Procedural(model.transform, dictionary);
			}
			List<WuWaCapsule> list2 = new List<WuWaCapsule>();
			foreach (WuWaCapsule item in list)
			{
				if (ClothKinds.Contains(item.Kind))
				{
					list2.Add(item);
				}
			}
			WuWaCapsule[] array = list2.ToArray();
			WuWaCapsule[] array2 = list.ToArray();
			GameObject val2 = new GameObject("WuWaJiggleDummyCollider");
			val2.transform.SetParent(model.transform, false);
			SphereCollider val3 = val2.AddComponent<SphereCollider>();
			((Collider)val3).isTrigger = true;
			val3.radius = 0.0001f;
			val3.center = new Vector3(0f, -10000f, 0f);
			((Collider)val3).enabled = false;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			JiggleRigBuilder[] componentsInChildren2 = model.GetComponentsInChildren<JiggleRigBuilder>(true);
			foreach (JiggleRigBuilder val4 in componentsInChildren2)
			{
				JiggleSettingsBase jiggleSettings = val4.jiggleSettings;
				if ((Object)(object)jiggleSettings == (Object)null || !((Object)jiggleSettings).name.StartsWith("WuWa_"))
				{
					continue;
				}
				bool flag = ((Object)jiggleSettings).name.Contains("Cloth");
				if (!flag && !((Object)jiggleSettings).name.Contains("Hair"))
				{
					continue;
				}
				WuWaCapsule[] array3 = (flag ? array : array2);
				if (array3.Length == 0)
				{
					continue;
				}
				WuWaCapsuleSet wuWaCapsuleSet = new WuWaCapsuleSet
				{
					Capsules = array3,
					ModelRoot = model.transform,
					Cloth = flag
				};
				wuWaCapsuleSet.Ones = new float[array3.Length];
				for (int j = 0; j < array3.Length; j++)
				{
					wuWaCapsuleSet.Ones[j] = 1f;
				}
				RestFactors(wuWaCapsuleSet, val4, jiggleSettings);
				foreach (float[] value in wuWaCapsuleSet.BoneFactor.Values)
				{
					foreach (float num6 in value)
					{
						if (num6 <= 0.05f)
						{
							num5++;
						}
						else if (num6 < 0.999f)
						{
							num4++;
						}
					}
				}
				val4.colliders = new List<Collider> { (Collider)(object)val3 };
				JiggleCollisionPatch.Sets.Add(val4.colliders, wuWaCapsuleSet);
				if (flag)
				{
					num2++;
				}
				else
				{
					num3++;
				}
			}
			ManualLogSource? log = Plugin.Log;
			if (log != null)
			{
				log.LogInfo((object)(string.Format("[WuWa] {0}: {1} capsules, {2} for cloth / {3} for hair, ", ((Object)model).name, ok ? "mesh-fitted" : "procedural", array.Length, array2.Length) + $"{num2} cloth / {num3} hair rigs; rest-pose fit: {num4} capsule uses shrunk, {num5} off."));
			}
		}

		private static void RestFactors(WuWaCapsuleSet set, JiggleRigBuilder jb, JiggleSettingsBase st)
		{
			//IL_0017: 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_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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			Transform rootTransform = jb.GetRootTransform();
			if ((Object)(object)rootTransform == (Object)null)
			{
				return;
			}
			float y = set.ModelRoot.lossyScale.y;
			float num = st.GetRadius(0.5f) * y * Plugin.ParticleRadiusMultiplier.Value;
			int num2 = set.Capsules.Length;
			(Vector3, Vector3, float, bool)[] array = new(Vector3, Vector3, float, bool)[num2];
			for (int i = 0; i < num2; i++)
			{
				WuWaCapsule wuWaCapsule = set.Capsules[i];
				if ((Object)(object)wuWaCapsule.A == (Object)null || (Object)(object)wuWaCapsule.B == (Object)null)
				{
					array[i] = (Vector3.zero, Vector3.zero, 0f, false);
					continue;
				}
				Vector3 val = wuWaCapsule.A.TransformPoint(wuWaCapsule.LocalA);
				array[i] = (val, wuWaCapsule.B.TransformPoint(wuWaCapsule.LocalB) - val, y * JiggleCollisionPatch.KindScale(wuWaCapsule.Kind, set.Cloth), true);
			}
			Transform[] componentsInChildren = ((Component)rootTransform).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren)
			{
				if ((Object)(object)val2 == (Object)(object)rootTransform)
				{
					continue;
				}
				float[] array2 = new float[num2];
				Vector3 position = val2.position;
				for (int k = 0; k < num2; k++)
				{
					array2[k] = 1f;
					(Vector3, Vector3, float, bool) tuple = array[k];
					if (!tuple.Item4)
					{
						array2[k] = 0f;
						continue;
					}
					float num3 = Mathf.Clamp01(Vector3.Dot(position - tuple.Item1, tuple.Item2) / Mathf.Max(((Vector3)(ref tuple.Item2)).sqrMagnitude, 1E-08f));
					Vector3 val3 = position - (tuple.Item1 + tuple.Item2 * num3);
					float magnitude = ((Vector3)(ref val3)).magnitude;
					float num4 = Mathf.Lerp(set.Capsules[k].RadiusA, set.Capsules[k].RadiusB, num3) * tuple.Item3;
					if (num4 > 1E-06f && magnitude < num4 + num)
					{
						array2[k] = Mathf.Max(0f, (magnitude - num) / num4);
					}
				}
				set.BoneFactor[val2] = array2;
			}
		}

		private static List<WuWaCapsule> LoadFitted(string id, Dictionary<string, Transform> bones, out bool ok)
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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)
			List<WuWaCapsule> list = new List<WuWaCapsule>();
			ok = false;
			string path = Path.Combine(WuWaCharacters.Dir, "colliders", id + ".txt");
			if (!File.Exists(path))
			{
				return list;
			}
			CultureInfo ci = CultureInfo.InvariantCulture;
			string[] array = File.ReadAllLines(path);
			foreach (string text in array)
			{
				string[] f = text.Trim().Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
				if (f.Length == 11 && !f[0].StartsWith("#") && bones.TryGetValue(f[1], out Transform value) && bones.TryGetValue(f[5], out Transform value2))
				{
					list.Add(new WuWaCapsule
					{
						Kind = f[0],
						A = value,
						B = value2,
						LocalA = new Vector3(F(2), F(3), F(4)),
						LocalB = new Vector3(F(6), F(7), F(8)),
						RadiusA = F(9),
						RadiusB = F(10)
					});
				}
				float F(int num)
				{
					return float.Parse(f[num], NumberStyles.Float, ci);
				}
			}
			ok = list.Count > 0;
			return list;
		}

		private static List<WuWaCapsule> Procedural(Transform root, Dictionary<string, Transform> bones)
		{
			List<WuWaCapsule> list = new List<WuWaCapsule>();
			string[] array = new string[2] { "L", "R" };
			foreach (string text in array)
			{
				Add("leg", B("Bip001" + text + "Thigh"), B("Bip001" + text + "Calf"), Plugin.ThighRadius.Value);
				Add("leg", B("Bip001" + text + "Calf"), B("Bip001" + text + "Foot"), Plugin.CalfRadius.Value);
				Add("arm", B("Bip001" + text + "UpperArm"), B("Bip001" + text + "Forearm"), Plugin.ArmRadius.Value);
				Add("arm", B("Bip001" + text + "Forearm"), B("Bip001" + text + "Hand"), Plugin.ArmRadius.Value * 0.85f);
			}
			Add("hip", B("Bip001LThigh"), B("Bip001RThigh"), Plugin.HipRadius.Value, B("Bip001LThigh"), B("Bip001LCalf"));
			Add("body", B("Bip001Spine1"), B("Bip001Neck"), Plugin.TorsoRadius.Value);
			return list;
			void Add(string kind, Transform? a, Transform? b, float frac, Transform? refA = null, Transform? refB = null)
			{
				//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_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0085: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)a == (Object)null) && !((Object)(object)b == (Object)null))
				{
					Vector3 val = root.InverseTransformPoint((refB ?? b).position) - root.InverseTransformPoint((refA ?? a).position);
					float num = ((Vector3)(ref val)).magnitude * frac;
					list.Add(new WuWaCapsule
					{
						Kind = kind,
						A = a,
						B = b,
						LocalA = Vector3.zero,
						LocalB = Vector3.zero,
						RadiusA = num,
						RadiusB = num
					});
				}
			}
			Transform? B(string n)
			{
				if (!bones.TryGetValue(n, out Transform value))
				{
					return null;
				}
				return value;
			}
		}
	}
	[HarmonyPatch(typeof(ViewStateManager), "GetViewState")]
	internal static class ShowcaseViewStatePatch
	{
		private static void Postfix(ViewStateManager __instance, ref ViewState __result)
		{
			if (WuWaDebug.ShowcaseActive && (int)__result == 2 && ((ManagerBase)__instance).localPlayer)
			{
				__result = (ViewState)1;
			}
		}
	}
	public class WuWaDebug : MonoBehaviour
	{
		internal static bool ShowcaseActive;

		private PlayerControllerB? autoSuitDoneFor;

		private float nextAutoTry;

		private float nextPushLog;

		private Camera? showCam;

		private Camera? hiddenCam;

		private float yaw;

		private float pitch = 5f;

		private float distance = 2.6f;

		private bool autoRotate;

		internal static string[] SuitNames => WuWaCharacters.Order.ToArray();

		private static PlayerControllerB? Local
		{
			get
			{
				if (!((Object)(object)GameNetworkManager.Instance != (Object)null))
				{
					return null;
				}
				return GameNetworkManager.Instance.localPlayerController;
			}
		}

		internal static void Create()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("WuWaDebug");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<WuWaDebug>();
		}

		private static UnlockableSuit? FindSuit(string name)
		{
			List<UnlockableItem> list = StartOfRound.Instance?.unlockablesList?.unlockables;
			if (list == null)
			{
				return null;
			}
			UnlockableSuit[] array = Object.FindObjectsOfType<UnlockableSuit>();
			foreach (UnlockableSuit val in array)
			{
				int value = val.syncedSuitID.Value;
				if (value >= 0 && value < list.Count && string.Equals(list[value].unlockableName, name, StringComparison.OrdinalIgnoreCase))
				{
					return val;
				}
			}
			return null;
		}

		private static void PullShipLever()
		{
			StartMatchLever val = Object.FindObjectOfType<StartMatchLever>();
			if (!((Object)(object)val == (Object)null))
			{
				val.leverHasBeenPulled = !val.leverHasBeenPulled;
				val.PullLever();
				ManualLogSource? log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)$"[WuWa] Ship lever pulled (pulled={val.leverHasBeenPulled}).");
				}
			}
		}

		private static void TeleportOutside(PlayerControllerB p)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if (!((Object)(object)instance == (Object)null) && instance.shipHasLanded && !((Object)(object)instance.groundOutsideShipSpawnPosition == (Object)null))
			{
				p.TeleportPlayer(instance.groundOutsideShipSpawnPosition.position, false, 0f, false, true);
				p.isInElevator = false;
				p.isInHangarShipRoom = false;
				p.isInsideFactory = false;
				ManualLogSource? log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)"[WuWa] Teleported outside the ship.");
				}
			}
		}

		private static string CurrentSuitName(PlayerControllerB p)
		{
			List<UnlockableItem> list = StartOfRound.Instance?.unlockablesList?.unlockables;
			if (list == null || p.currentSuitID < 0 || p.currentSuitID >= list.Count)
			{
				return "";
			}
			return list[p.currentSuitID].unlockableName;
		}

		private static bool Equip(string name)
		{
			PlayerControllerB local = Local;
			if ((Object)(object)local == (Object)null)
			{
				return false;
			}
			UnlockableSuit val = FindSuit(name);
			if ((Object)(object)val == (Object)null)
			{
				ManualLogSource? log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[WuWa] Suit '" + name + "' not found on the rack."));
				}
				return false;
			}
			int value = val.syncedSuitID.Value;
			if (local.currentSuitID == value)
			{
				return true;
			}
			UnlockableSuit.SwitchSuitForPlayer(local, value, true);
			val.SwitchSuitServerRpc((int)local.playerClientId);
			ManualLogSource? log2 = Plugin.Log;
			if (log2 != null)
			{
				log2.LogInfo((object)("[WuWa] Equipped suit '" + name + "'."));
			}
			return true;
		}

		private void Cycle(int dir)
		{
			PlayerControllerB p = Local;
			if ((Object)(object)p == (Object)null)
			{
				return;
			}
			int num = Array.FindIndex(SuitNames, (string n) => string.Equals(n, CurrentSuitName(p), StringComparison.OrdinalIgnoreCase));
			for (int num2 = 1; num2 <= SuitNames.Length; num2++)
			{
				int num3 = (((num >= 0) ? num : ((dir > 0) ? (-1) : 0)) + dir * num2 + SuitNames.Length * 4) % SuitNames.Length;
				if (Equip(SuitNames[num3]))
				{
					break;
				}
			}
		}

		private void Update()
		{
			PlayerControllerB local = Local;
			Keyboard current = Keyboard.current;
			string value = Plugin.AutoSuit.Value;
			if ((Object)(object)local != (Object)null && local.isPlayerControlled && !string.IsNullOrWhiteSpace(value) && (Object)(object)autoSuitDoneFor != (Object)(object)local && Time.time >= nextAutoTry)
			{
				nextAutoTry = Time.time + 1f;
				if (string.Equals(CurrentSuitName(local), value, StringComparison.OrdinalIgnoreCase) || Equip(value))
				{
					autoSuitDoneFor = local;
				}
			}
			if (Time.time >= nextPushLog)
			{
				nextPushLog = Time.time + 10f;
				if (JiggleCollisionPatch.Pushes > 0)
				{
					ManualLogSource? log = Plugin.Log;
					if (log != null)
					{
						log.LogInfo((object)$"[WuWa] jiggle collision pushes in last 10 s: {JiggleCollisionPatch.Pushes}");
					}
				}
				JiggleCollisionPatch.Pushes = 0;
			}
			if (current == null || (Object)(object)local == (Object)null)
			{
				if ((Object)(object)showCam != (Object)null)
				{
					StopShowcase();
				}
			}
			else
			{
				if (local.isTypingChat || local.inTerminalMenu)
				{
					return;
				}
				if (((ButtonControl)current.f6Key).wasPressedThisFrame)
				{
					Cycle(-1);
				}
				if (((ButtonControl)current.f7Key).wasPressedThisFrame)
				{
					Cycle(1);
				}
				if (((ButtonControl)current.f8Key).wasPressedThisFrame)
				{
					if ((Object)(object)showCam == (Object)null)
					{
						StartShowcase(local);
					}
					else
					{
						StopShowcase();
					}
				}
				if (((ButtonControl)current.f9Key).wasPressedThisFrame)
				{
					autoRotate = !autoRotate;
				}
				if (Plugin.TestKeys.Value)
				{
					if (((ButtonControl)current.f10Key).wasPressedThisFrame)
					{
						PullShipLever();
					}
					if (((ButtonControl)current.f11Key).wasPressedThisFrame)
					{
						TeleportOutside(local);
					}
				}
				if ((Object)(object)showCam != (Object)null)
				{
					float deltaTime = Time.deltaTime;
					if (((ButtonControl)current.leftArrowKey).isPressed)
					{
						yaw -= 90f * deltaTime;
					}
					if (((ButtonControl)current.rightArrowKey).isPressed)
					{
						yaw += 90f * deltaTime;
					}
					if (((ButtonControl)current.upArrowKey).isPressed)
					{
						pitch = Mathf.Clamp(pitch + 45f * deltaTime, -60f, 80f);
					}
					if (((ButtonControl)current.downArrowKey).isPressed)
					{
						pitch = Mathf.Clamp(pitch - 45f * deltaTime, -60f, 80f);
					}
					if (((ButtonControl)current.pageUpKey).isPressed)
					{
						distance = Mathf.Max(0.4f, distance - 1.2f * deltaTime);
					}
					if (((ButtonControl)current.pageDownKey).isPressed)
					{
						distance = Mathf.Min(6f, distance + 1.2f * deltaTime);
					}
					if (((ButtonControl)current.homeKey).wasPressedThisFrame)
					{
						yaw = 0f;
						pitch = 5f;
						distance = 2.6f;
					}
					if (autoRotate)
					{
						yaw += 40f * deltaTime;
					}
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004a: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_007e: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB local = Local;
			if (!((Object)(object)showCam == (Object)null) && !((Object)(object)local == (Object)null))
			{
				Vector3 val = ((Component)local).transform.position + Vector3.up * 1.25f;
				Quaternion val2 = Quaternion.Euler(pitch, ((Component)local).transform.eulerAngles.y + 180f + yaw, 0f);
				Vector3 val3 = val - val2 * Vector3.forward * distance;
				((Component)showCam).transform.SetPositionAndRotation(val3, Quaternion.LookRotation(val - val3));
			}
		}

		private void StartShowcase(PlayerControllerB p)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Camera gameplayCamera = p.gameplayCamera;
			if (!((Object)(object)gameplayCamera == (Object)null))
			{
				GameObject val = new GameObject("WuWaShowcaseCamera");
				Object.DontDestroyOnLoad((Object)(object)val);
				showCam = val.AddComponent<Camera>();
				showCam.CopyFrom(gameplayCamera);
				showCam.fieldOfView = 50f;
				showCam.nearClipPlane = 0.05f;
				int num = gameplayCamera.cullingMask | 0x800000 | 0x20000 | 1;
				num &= -17;
				num &= 0x7FFFFFFF;
				showCam.cullingMask = num;
				hiddenCam = gameplayCamera;
				((Behaviour)gameplayCamera).enabled = false;
				ShowcaseActive = true;
				ManualLogSource? log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)"[WuWa] Showcase camera ON (arrows orbit, PgUp/PgDn zoom, Home reset, F9 auto-rotate, F8 off).");
				}
			}
		}

		private void StopShowcase()
		{
			ShowcaseActive = false;
			if ((Object)(object)hiddenCam != (Object)null)
			{
				((Behaviour)hiddenCam).enabled = true;
			}
			hiddenCam = null;
			if ((Object)(object)showCam != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)showCam).gameObject);
			}
			showCam = null;
			ManualLogSource? log = Plugin.Log;
			if (log != null)
			{
				log.LogInfo((object)"[WuWa] Showcase camera OFF.");
			}
		}
	}
	public class WuWaSizeInfo : MonoBehaviour
	{
		public float Rel = 1f;

		public float HipShift;

		public float NativeAnkle;

		public float GroundDelta;

		public bool HasGround;
	}
	public static class WuWaSize
	{
		public static void Apply(GameObject model)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: 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)
			if ((Object)(object)model == (Object)null)
			{
				return;
			}
			Animator componentInChildren = model.GetComponentInChildren<Animator>();
			bool flag = (Object)(object)componentInChildren != (Object)null && componentInChildren.isHuman;
			Transform val = (flag ? componentInChildren.GetBoneTransform((HumanBodyBones)10) : null);
			if ((Object)(object)val == (Object)null)
			{
				Transform[] componentsInChildren = model.GetComponentsInChildren<Transform>(true);
				foreach (Transform val2 in componentsInChildren)
				{
					if (((Object)val2).name == "Bip001Head")
					{
						val = val2;
						break;
					}
				}
			}
			if (!((Object)(object)val == (Object)null))
			{
				float y = model.transform.InverseTransformPoint(val.position).y;
				float y2 = model.transform.lossyScale.y;
				float num = y * y2;
				float num2 = ((y > 10f) ? (y * 0.01f) : y);
				float num3 = 1f;
				if (Plugin.RealisticSize.Value && num2 > 0.3f && num > 0.0001f)
				{
					num3 = Mathf.Clamp(Plugin.PlayerHeadHeight.Value * (num2 / Plugin.ReferenceHeadHeight.Value) / num, 0.5f, 1.8f);
				}
				Transform val3 = (flag ? componentInChildren.GetBoneTransform((HumanBodyBones)0) : null);
				Transform val4 = (flag ? componentInChildren.GetBoneTransform((HumanBodyBones)5) : null);
				Transform val5 = (flag ? componentInChildren.GetBoneTransform((HumanBodyBones)6) : null);
				float num4 = (((Object)(object)val3 != (Object)null) ? model.transform.InverseTransformPoint(val3.position).y : 0f);
				float num5 = -1f;
				if ((Object)(object)val4 != (Object)null && (Object)(object)val5 != (Object)null)
				{
					num5 = Mathf.Min(model.transform.InverseTransformPoint(val4.position).y, model.transform.InverseTransformPoint(val5.position).y);
				}
				Transform transform = model.transform;
				transform.localScale *= num3;
				WuWaSizeInfo obj = model.GetComponent<WuWaSizeInfo>() ?? model.AddComponent<WuWaSizeInfo>();
				obj.Rel = num3;
				obj.HipShift = num4 * y2 * (1f - num3);
				obj.NativeAnkle = num5;
				ManualLogSource? log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)$"[WuWa] size {((Object)model).name}: native head {y:F3}, ankle {num5:F3}, MRAPI scale {y2:F3}, world head {num:F3} -> x{num3:F3} = {num * num3:F3}");
				}
			}
		}
	}
	[HarmonyPatch(typeof(AvatarUpdater), "UpdateModel")]
	internal static class SizeHipsPatch
	{
		private static void Postfix(GameObject ___replacement, GameObject ___player, Animator ___replacementAnimator)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_0101: 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)
			if ((Object)(object)___replacement == (Object)null || (Object)(object)___player == (Object)null || (Object)(object)___replacementAnimator == (Object)null)
			{
				return;
			}
			WuWaSizeInfo component = ___replacement.GetComponent<WuWaSizeInfo>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			Transform boneTransform = ___replacementAnimator.GetBoneTransform((HumanBodyBones)0);
			if ((Object)(object)boneTransform == (Object)null)
			{
				return;
			}
			Transform transform = ___player.transform;
			Vector3 up = transform.up;
			float num = 0f - component.HipShift;
			Transform boneTransform2 = ___replacementAnimator.GetBoneTransform((HumanBodyBones)5);
			Transform boneTransform3 = ___replacementAnimator.GetBoneTransform((HumanBodyBones)6);
			if (Plugin.GroundFeet.Value && component.NativeAnkle >= 0f && (Object)(object)boneTransform2 != (Object)null && (Object)(object)boneTransform3 != (Object)null && (Object)(object)StartOfRound.Instance != (Object)null)
			{
				float num2 = Mathf.Min(Vector3.Dot(boneTransform2.position, up), Vector3.Dot(boneTransform3.position, up)) - component.NativeAnkle * ___replacement.transform.lossyScale.y;
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(transform.position + up * 0.5f, -up, ref val, 0.75f, StartOfRound.Instance.allPlayersCollideWithMask, (QueryTriggerInteraction)1))
				{
					float num3 = Vector3.Dot(((RaycastHit)(ref val)).point, up) - num2;
					component.GroundDelta = (component.HasGround ? Mathf.Lerp(component.GroundDelta, num3, 1f - Mathf.Exp(-20f * Time.deltaTime)) : num3);
					if (!component.HasGround)
					{
						ManualLogSource? log = Plugin.Log;
						if (log != null)
						{
							log.LogInfo((object)$"[WuWa] grounding {((Object)___replacement).name}: floor {((RaycastHit)(ref val)).distance - 0.5f:F3} below player origin, lift {num3:F3}");
						}
					}
					component.HasGround = true;
				}
				if (component.HasGround)
				{
					num = component.GroundDelta;
				}
			}
			num += Plugin.HeightOffset.Value;
			if (Mathf.Abs(num) > 1E-05f)
			{
				boneTransform.position += up * num;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}