Decompiled source of Pipi Caca Mod v0.5.1

plugins/Caca.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Caca")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9d6c7aa1ff55cd7708e382b3ca0dc76c4a0db3c3")]
[assembly: AssemblyProduct("Caca")]
[assembly: AssemblyTitle("Caca")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
namespace Caca
{
	internal static class Body
	{
		private static readonly FieldRef<Character, Animator> s_animator = AccessTools.FieldRefAccess<Character, Animator>("m_animator");

		private static readonly FieldRef<VisEquipment, GameObject> s_rightItem = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_rightItemInstance");

		private static readonly HumanBodyBones[] s_fingers;

		public static Animator AnimatorOf(Character c)
		{
			if (!((Object)(object)c != (Object)null))
			{
				return null;
			}
			return s_animator.Invoke(c);
		}

		public static GameObject RightItem(VisEquipment ve)
		{
			if (!((Object)(object)ve != (Object)null))
			{
				return null;
			}
			return s_rightItem.Invoke(ve);
		}

		public static Vector3 Vec(string s, Vector3 fallback)
		{
			//IL_0008: 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_0064: 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)
			if (string.IsNullOrEmpty(s))
			{
				return fallback;
			}
			string[] array = s.Split(new char[3] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length != 3)
			{
				return fallback;
			}
			float[] array2 = new float[3];
			for (int i = 0; i < 3; i++)
			{
				if (!float.TryParse(array[i], NumberStyles.Float, CultureInfo.InvariantCulture, out array2[i]))
				{
					return fallback;
				}
			}
			return new Vector3(array2[0], array2[1], array2[2]);
		}

		private static Vector3 FromHips(Character c, Transform hips, Vector3 offset)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)c).transform;
			return hips.position + transform.right * offset.x + transform.up * offset.y + transform.forward * offset.z;
		}

		public static bool Tip(Character c, out Vector3 tip)
		{
			//IL_008f: 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_0099: 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_0033: 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_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_0058: 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)
			Animator val = AnimatorOf(c);
			Transform val2 = (((Object)(object)val != (Object)null && val.isHuman) ? val.GetBoneTransform((HumanBodyBones)0) : null);
			if ((Object)(object)val2 == (Object)null)
			{
				tip = ((Component)c).transform.position + ((Component)c).transform.up * 0.95f + ((Component)c).transform.forward * 0.2f;
				return false;
			}
			tip = FromHips(c, val2, Vec(Plugin.TipOffset.Value, new Vector3(0f, -0.13f, 0.2f)));
			return true;
		}

		public static bool SquatTip(Character c, out Vector3 tip)
		{
			//IL_008f: 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_0099: 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_0033: 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_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_0058: 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)
			Animator val = AnimatorOf(c);
			Transform val2 = (((Object)(object)val != (Object)null && val.isHuman) ? val.GetBoneTransform((HumanBodyBones)0) : null);
			if ((Object)(object)val2 == (Object)null)
			{
				tip = ((Component)c).transform.position + ((Component)c).transform.up * 0.45f + ((Component)c).transform.forward * 0.08f;
				return false;
			}
			tip = FromHips(c, val2, Vec(Plugin.SquatTipOffset.Value, new Vector3(0f, -0.1f, 0.05f)));
			return true;
		}

		public static void HoldTip(Character c, float weight, Vector3 aimDir)
		{
			//IL_008f: 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_0099: 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_00a1: 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_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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: 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_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			if (weight <= 0.001f)
			{
				return;
			}
			Animator val = AnimatorOf(c);
			if ((Object)(object)val == (Object)null || !val.isHuman)
			{
				return;
			}
			Transform boneTransform = val.GetBoneTransform((HumanBodyBones)0);
			Transform boneTransform2 = val.GetBoneTransform((HumanBodyBones)14);
			Transform boneTransform3 = val.GetBoneTransform((HumanBodyBones)16);
			Transform boneTransform4 = val.GetBoneTransform((HumanBodyBones)18);
			if ((Object)(object)boneTransform == (Object)null || (Object)(object)boneTransform2 == (Object)null || (Object)(object)boneTransform3 == (Object)null || (Object)(object)boneTransform4 == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)c).transform;
			Vector3 target = FromHips(c, boneTransform, Vec(Plugin.WristOffset.Value, new Vector3(0.09f, -0.06f, 0.1f)));
			Vector3 pole = boneTransform2.position + transform.right * 0.35f - transform.forward * 0.25f - transform.up * 0.3f;
			Quaternion rotation = boneTransform2.rotation;
			Quaternion rotation2 = boneTransform3.rotation;
			Quaternion rotation3 = boneTransform4.rotation;
			SolveTwoBone(boneTransform2, boneTransform3, boneTransform4, target, pole);
			Vector3 val2 = FingerDir(val, boneTransform4, boneTransform3);
			Vector3 val3 = Vec(Plugin.FingerDir.Value, new Vector3(-0.7f, -0.55f, 0.35f));
			Vector3 val4 = transform.TransformDirection(((Vector3)(ref val3)).normalized);
			boneTransform4.rotation = Quaternion.FromToRotation(val2, val4) * boneTransform4.rotation;
			Transform boneTransform5 = val.GetBoneTransform((HumanBodyBones)39);
			if ((Object)(object)boneTransform5 != (Object)null)
			{
				Vector3 val5 = Vector3.ProjectOnPlane(boneTransform5.position - boneTransform4.position, val4);
				Vector3 val6 = Vector3.ProjectOnPlane(aimDir, val4);
				if (((Vector3)(ref val5)).sqrMagnitude > 1E-06f && ((Vector3)(ref val6)).sqrMagnitude > 1E-06f)
				{
					boneTransform4.rotation = Quaternion.FromToRotation(val5, val6) * boneTransform4.rotation;
				}
			}
			CurlFingers(val, weight);
			if (weight < 0.999f)
			{
				boneTransform2.rotation = Quaternion.Slerp(rotation, boneTransform2.rotation, weight);
				boneTransform3.rotation = Quaternion.Slerp(rotation2, boneTransform3.rotation, weight);
				boneTransform4.rotation = Quaternion.Slerp(rotation3, boneTransform4.rotation, weight);
			}
		}

		public static bool Fist(Character c, out Vector3 fist)
		{
			//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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			fist = Vector3.zero;
			Animator val = AnimatorOf(c);
			if ((Object)(object)val == (Object)null || !val.isHuman)
			{
				return false;
			}
			Transform boneTransform = val.GetBoneTransform((HumanBodyBones)18);
			Transform boneTransform2 = val.GetBoneTransform((HumanBodyBones)45);
			if ((Object)(object)boneTransform == (Object)null)
			{
				return false;
			}
			fist = (((Object)(object)boneTransform2 != (Object)null) ? Vector3.Lerp(boneTransform.position, boneTransform2.position, 0.7f) : boneTransform.position);
			return true;
		}

		private static Vector3 FingerDir(Animator anim, Transform hand, Transform lower)
		{
			//IL_0026: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_004e: 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)
			Transform boneTransform = anim.GetBoneTransform((HumanBodyBones)45);
			Vector3 val = (((Object)(object)boneTransform != (Object)null) ? (boneTransform.position - hand.position) : (hand.position - lower.position));
			if (!(((Vector3)(ref val)).sqrMagnitude > 1E-08f))
			{
				return hand.forward;
			}
			return ((Vector3)(ref val)).normalized;
		}

		private static void CurlFingers(Animator anim, float weight)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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)
			//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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_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)
			Transform boneTransform = anim.GetBoneTransform((HumanBodyBones)18);
			Transform boneTransform2 = anim.GetBoneTransform((HumanBodyBones)39);
			Transform boneTransform3 = anim.GetBoneTransform((HumanBodyBones)45);
			Transform boneTransform4 = anim.GetBoneTransform((HumanBodyBones)42);
			Transform boneTransform5 = anim.GetBoneTransform((HumanBodyBones)51);
			if ((Object)(object)boneTransform == (Object)null || (Object)(object)boneTransform2 == (Object)null || (Object)(object)boneTransform3 == (Object)null || (Object)(object)boneTransform4 == (Object)null || (Object)(object)boneTransform5 == (Object)null)
			{
				return;
			}
			Vector3 val = boneTransform3.position - boneTransform.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = boneTransform4.position - boneTransform5.position;
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			val = Vector3.Cross(normalized, normalized2);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (Vector3.Dot(val2, boneTransform2.position - boneTransform.position) < 0f)
			{
				val2 = -val2;
			}
			val = Vector3.Cross(normalized, val2);
			Vector3 normalized3 = ((Vector3)(ref val)).normalized;
			float num = Plugin.FingerCurl.Value * weight;
			HumanBodyBones[] array = s_fingers;
			foreach (HumanBodyBones val3 in array)
			{
				Transform boneTransform6 = anim.GetBoneTransform(val3);
				if ((Object)(object)boneTransform6 != (Object)null)
				{
					boneTransform6.rotation = Quaternion.AngleAxis(num, normalized3) * boneTransform6.rotation;
				}
			}
		}

		private static void SolveTwoBone(Transform a, Transform b, Transform c, Vector3 target, Vector3 pole)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00a1: 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_00dc: 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_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_00f8: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_0136: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(a.position, b.position);
			float num2 = Vector3.Distance(b.position, c.position);
			Vector3 val = target - a.position;
			float num3 = Mathf.Clamp(((Vector3)(ref val)).magnitude, Mathf.Abs(num - num2) + 0.001f, num + num2 - 0.001f);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num4 = (num * num - num2 * num2 + num3 * num3) / (2f * num3);
			float num5 = Mathf.Sqrt(Mathf.Max(0f, num * num - num4 * num4));
			Vector3 val2 = Vector3.ProjectOnPlane(pole - a.position, normalized);
			if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f)
			{
				val2 = Vector3.ProjectOnPlane(b.position - a.position, normalized);
			}
			((Vector3)(ref val2)).Normalize();
			Vector3 val3 = a.position + normalized * num4 + val2 * num5;
			a.rotation = Quaternion.FromToRotation(b.position - a.position, val3 - a.position) * a.rotation;
			Vector3 position = c.position;
			b.rotation = Quaternion.FromToRotation(position - b.position, a.position + normalized * num3 - b.position) * b.rotation;
		}

		static Body()
		{
			HumanBodyBones[] array = new HumanBodyBones[12];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			s_fingers = (HumanBodyBones[])(object)array;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "LateUpdate")]
	internal static class LabCameraPatch
	{
		private static void Postfix(GameCamera __instance)
		{
			if (Lab.CamOn)
			{
				Lab.PlaceCamera(((Component)__instance).transform);
			}
		}
	}
	[HarmonyPatch(typeof(CharacterAnimEvent), "CustomLateUpdate")]
	internal static class ArmPatch
	{
		private static readonly FieldRef<CharacterAnimEvent, Character> s_character = AccessTools.FieldRefAccess<CharacterAnimEvent, Character>("m_character");

		private static void Postfix(CharacterAnimEvent __instance)
		{
			//IL_003c: 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_0060: 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)
			Character val = s_character.Invoke(__instance);
			if (!(val is Player))
			{
				return;
			}
			PeeStream peeStream = PeeStream.Of(val);
			if (!((Object)(object)peeStream == (Object)null) && !(peeStream.HandWeight <= 0.001f))
			{
				Body.HoldTip(val, peeStream.HandWeight, peeStream.Dir);
				if (peeStream.HandWeight > 0.9f && Body.Fist(val, out var fist))
				{
					peeStream.SetHandTip(fist + peeStream.Dir * Plugin.TipFromHand.Value);
				}
			}
		}
	}
	internal static class Fart
	{
		private const string Key = "caca_fart";

		public static float Value;

		private static Player s_for;

		private static float s_saveAt;

		private static void Load(Player p)
		{
			s_for = p;
			Value = ((p.m_customData.TryGetValue("caca_fart", out var value) && float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) ? result : 0f);
		}

		public static void Save()
		{
			if ((Object)(object)s_for != (Object)null)
			{
				s_for.m_customData["caca_fart"] = Value.ToString("0.###", CultureInfo.InvariantCulture);
			}
		}

		public static void AddMeal()
		{
			Value = Mathf.Min(100f, Value + Plugin.FartPerMeal.Value);
		}

		public static void Tick(Player p)
		{
			if ((Object)(object)p != (Object)(object)s_for)
			{
				Load(p);
			}
			if (!((Character)p).IsDead() && !((Character)p).InBed())
			{
				Value = Mathf.Min(100f, Value + Plugin.FartFillPerMinute.Value / 60f * Time.deltaTime);
			}
			if (Value >= 100f && !((Character)p).IsDead() && !((Character)p).InBed() && !((Character)p).IsTeleporting() && !Need.Busy)
			{
				Let(p);
			}
			if (Time.time > s_saveAt)
			{
				s_saveAt = Time.time + 2f;
				Save();
			}
		}

		public static void Let(Player p)
		{
			//IL_0015: 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_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_003a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Value = 0f;
			Save();
			Plugin.GasFart(((Component)p).transform.position + ((Component)p).transform.up * 0.9f - ((Component)p).transform.forward * 0.22f, -((Component)p).transform.forward);
			Plugin.Log.LogInfo((object)"Fart");
		}
	}
	internal static class GasCloud
	{
		private static Material s_mat;

		public static void Spawn(Vector3 pos, Vector3 back)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0055: 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_0070: 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_00af: 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_00db: 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_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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			if (Plugin.FartCloud.Value)
			{
				if ((Object)(object)s_mat == (Object)null)
				{
					s_mat = new Material(Shader.Find("Sprites/Default"))
					{
						name = "caca_gas",
						mainTexture = (Texture)(object)PuffTexture()
					};
				}
				GameObject val = new GameObject("caca_gas");
				val.transform.position = pos;
				ParticleSystem val2 = val.AddComponent<ParticleSystem>();
				val2.Stop(true, (ParticleSystemStopBehavior)0);
				MainModule main = val2.main;
				((MainModule)(ref main)).duration = 0.3f;
				((MainModule)(ref main)).loop = false;
				((MainModule)(ref main)).playOnAwake = false;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(2.2f, 3.2f);
				((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.05f, 0.25f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.25f, 0.45f);
				((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, MathF.PI * 2f);
				float value = Plugin.FartCloudOpacity.Value;
				((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.72f, 0.74f, 0.42f, value), new Color(0.62f, 0.6f, 0.36f, value));
				((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.012f);
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				((MainModule)(ref main)).maxParticles = 24;
				EmissionModule emission = val2.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
				((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[2]
				{
					new Burst(0f, (short)7),
					new Burst(0.12f, (short)5)
				});
				ShapeModule shape = val2.shape;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
				((ShapeModule)(ref shape)).radius = 0.08f;
				VelocityOverLifetimeModule velocityOverLifetime = val2.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(back.x * 0.35f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.02f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(back.z * 0.35f);
				SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 0.6f),
					new Keyframe(1f, 2.4f)
				}));
				ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
				Gradient val3 = new Gradient();
				val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(Color.white, 0f),
					new GradientColorKey(Color.white, 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
				{
					new GradientAlphaKey(0f, 0f),
					new GradientAlphaKey(1f, 0.15f),
					new GradientAlphaKey(0.6f, 0.6f),
					new GradientAlphaKey(0f, 1f)
				});
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
				RotationOverLifetimeModule rotationOverLifetime = val2.rotationOverLifetime;
				((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
				((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = new MinMaxCurve(-0.4f, 0.4f);
				ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
				((Renderer)component).sharedMaterial = s_mat;
				((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)component).receiveShadows = false;
				val2.Play();
				Object.Destroy((Object)(object)val, 4f);
			}
		}

		private static Texture2D PuffTexture()
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, true)
			{
				name = "caca_puff",
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = ((float)j + 0.5f) / 64f * 2f - 1f;
					float num2 = ((float)i + 0.5f) / 64f * 2f - 1f;
					float num3 = Mathf.Atan2(num2, num);
					float num4 = Mathf.Sqrt(num * num + num2 * num2) / (0.85f + 0.1f * Mathf.Sin(num3 * 5f + 1f) + 0.05f * Mathf.Sin(num3 * 9f));
					float num5 = Mathf.Exp((0f - num4) * num4 * 3.2f) * Mathf.Clamp01((1f - num4) * 2.5f);
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num5));
				}
			}
			val.Apply();
			return val;
		}
	}
	internal static class Hold
	{
		private static GameObject s_lastItem;

		private static Transform s_lastNode;

		public static void FixPrefab(GameObject item)
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00c6: 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)
			Transform val = item.transform.Find("attach");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Poop: no attach node");
				return;
			}
			ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren<ParticleSystem>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)((Component)componentsInChildren[i]).gameObject);
			}
			Transform val2 = PoopNode(((Component)val).gameObject);
			if ((Object)(object)val2 != (Object)null)
			{
				Place(val2);
			}
			Transform val3 = val.Find("collider");
			if ((Object)(object)val3 != (Object)null)
			{
				Collider[] components = ((Component)val3).GetComponents<Collider>();
				for (int i = 0; i < components.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)components[i]);
				}
				val3.localPosition = Pos();
				val3.localRotation = Quaternion.Euler(Rot());
				val3.localScale = Vector3.one;
				CapsuleCollider obj = ((Component)val3).gameObject.AddComponent<CapsuleCollider>();
				obj.direction = 2;
				obj.radius = 0.038f;
				obj.height = 0.21f;
				obj.center = new Vector3(0f, 0.004f, 0f);
			}
			Plugin.Log.LogInfo((object)("Poop held at " + ((object)Pos()/*cast due to .constrained prefix*/).ToString() + " rot " + ((object)Rot()/*cast due to .constrained prefix*/).ToString()));
		}

		private static Vector3 Pos()
		{
			//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)
			return Body.Vec(Plugin.HeldPos.Value, new Vector3(0f, 0f, 0.03f));
		}

		private static Vector3 Rot()
		{
			//IL_000a: 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)
			return Body.Vec(Plugin.HeldRot.Value, Vector3.zero);
		}

		private static Transform PoopNode(GameObject root)
		{
			MeshFilter[] componentsInChildren = root.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if ((Object)(object)val.sharedMesh != (Object)null && ((Object)val.sharedMesh).name == "caca_mesh")
				{
					return ((Component)val).transform;
				}
			}
			return null;
		}

		private static void Place(Transform t)
		{
			//IL_0001: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			t.localPosition = Pos();
			t.localRotation = Quaternion.Euler(Rot());
			t.localScale = Vector3.one;
		}

		public static void Apply(Player p)
		{
			GameObject val = Body.RightItem(((Component)p).GetComponent<VisEquipment>());
			if ((Object)(object)val != (Object)(object)s_lastItem)
			{
				s_lastItem = val;
				s_lastNode = (((Object)(object)val != (Object)null) ? PoopNode(val) : null);
			}
			if ((Object)(object)s_lastNode != (Object)null)
			{
				Place(s_lastNode);
			}
		}
	}
	internal class HoldCommand : ConsoleCommand
	{
		public override string Name => "caca_hold";

		public override string Help => "caca_hold x y z [rx ry rz] - poop position/rotation in the hand (tests, saved)";

		public override void Run(string[] args)
		{
			if (args.Length >= 3)
			{
				Plugin.HeldPos.Value = args[0] + " " + args[1] + " " + args[2];
			}
			if (args.Length >= 6)
			{
				Plugin.HeldRot.Value = args[3] + " " + args[4] + " " + args[5];
			}
			Console.instance.Print("held " + Plugin.HeldPos.Value + " / " + Plugin.HeldRot.Value);
		}
	}
	internal static class Lab
	{
		private static float s_next;

		private static bool s_running;

		private static readonly FieldRef<Character, Quaternion> s_lookYaw = AccessTools.FieldRefAccess<Character, Quaternion>("m_lookYaw");

		public static bool CamOn;

		public static bool AimOn;

		public static Vector3 Aim = Vector3.forward;

		private static float s_az;

		private static float s_el;

		private static float s_dist;

		private static float s_height;

		private static float s_orbit;

		private static float s_camT0;

		private static string Dir => Path.Combine(Wav.PluginDir, "lab");

		public static void PlaceCamera(Transform cam)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0036: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_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)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (CamOn && !((Object)(object)localPlayer == (Object)null))
			{
				Vector3 val = ((Component)localPlayer).transform.position + Vector3.up * s_height;
				float num = s_az + s_orbit * (Time.time - s_camT0);
				Vector3 val2 = Quaternion.Euler(0f, ((Component)localPlayer).transform.eulerAngles.y, 0f) * (Quaternion.Euler(0f - s_el, num, 0f) * Vector3.forward);
				cam.position = val + val2 * s_dist;
				cam.LookAt(val);
			}
		}

		public static void Poll()
		{
			if (s_running || Time.unscaledTime < s_next)
			{
				return;
			}
			s_next = Time.unscaledTime + 0.5f;
			string text = Path.Combine(Dir, "request.txt");
			if (!File.Exists(text))
			{
				return;
			}
			string[] lines;
			try
			{
				lines = File.ReadAllLines(text);
				string text2 = text + ".done";
				if (File.Exists(text2))
				{
					File.Delete(text2);
				}
				File.Move(text, text2);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Lab: " + ex.Message));
				return;
			}
			((MonoBehaviour)Plugin.Instance).StartCoroutine(Run(lines));
		}

		private static IEnumerator Run(string[] lines)
		{
			s_running = true;
			RaycastHit val2 = default(RaycastHit);
			for (int i = 0; i < lines.Length; i++)
			{
				string text = lines[i].Trim();
				if (text.Length == 0 || text.StartsWith("#"))
				{
					continue;
				}
				Plugin.Log.LogInfo((object)("Lab: " + text));
				int num = text.IndexOf(' ');
				string text2 = ((num < 0) ? text : text.Substring(0, num));
				string text3 = ((num < 0) ? "" : text.Substring(num + 1).Trim());
				string[] a = text3.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
				switch (text2)
				{
				case "cmd":
					if ((Object)(object)Console.instance != (Object)null)
					{
						((Terminal)Console.instance).TryRunCommand(text3, false, false);
					}
					break;
				case "wait":
					yield return (object)new WaitForSeconds(F(a, 0, 1f));
					break;
				case "key":
				{
					Player localPlayer2 = Player.m_localPlayer;
					if ((Object)(object)localPlayer2 != (Object)null && text3 == "PeeKey")
					{
						Pee.TryOnCommand(localPlayer2);
					}
					else if ((Object)(object)localPlayer2 != (Object)null)
					{
						Need.TryOnCommand(localPlayer2);
					}
					break;
				}
				case "cam":
					s_az = F(a, 0, 0f);
					s_el = F(a, 1, 10f);
					s_dist = F(a, 2, 3f);
					s_height = F(a, 3, 1f);
					s_orbit = F(a, 4, 0f);
					s_camT0 = Time.time;
					CamOn = true;
					break;
				case "camoff":
					CamOn = false;
					break;
				case "aim":
					Aim = Quaternion.Euler(0f - F(a, 1, 10f), F(a, 0, 0f), 0f) * Vector3.forward;
					AimOn = true;
					break;
				case "aimoff":
					AimOn = false;
					break;
				case "turn":
				{
					Player localPlayer3 = Player.m_localPlayer;
					if ((Object)(object)localPlayer3 != (Object)null)
					{
						Quaternion val3 = s_lookYaw.Invoke((Character)(object)localPlayer3);
						s_lookYaw.Invoke((Character)(object)localPlayer3) = Quaternion.Euler(0f, F(a, 0, 0f), 0f) * val3;
						((Component)localPlayer3).transform.rotation = s_lookYaw.Invoke((Character)(object)localPlayer3);
					}
					break;
				}
				case "tp":
				{
					Player localPlayer = Player.m_localPlayer;
					if ((Object)(object)localPlayer != (Object)null)
					{
						Vector3 val = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * F(a, 0, 0f) + ((Component)localPlayer).transform.right * F(a, 1, 0f);
						if (Physics.Raycast(val + Vector3.up * 30f, Vector3.down, ref val2, 80f, LayerMask.GetMask(new string[4] { "terrain", "static_solid", "Default", "piece" })))
						{
							val.y = ((RaycastHit)(ref val2)).point.y + 0.05f;
						}
						((Character)localPlayer).TeleportTo(val, ((Component)localPlayer).transform.rotation, false);
					}
					break;
				}
				case "where":
				{
					Player localPlayer5 = Player.m_localPlayer;
					if ((Object)(object)localPlayer5 != (Object)null)
					{
						Plugin.Log.LogInfo((object)("Lab: at " + ((object)((Component)localPlayer5).transform.position/*cast due to .constrained prefix*/).ToString() + " yaw " + ((Component)localPlayer5).transform.eulerAngles.y.ToString("0")));
					}
					break;
				}
				case "equip":
				{
					Player localPlayer4 = Player.m_localPlayer;
					if ((Object)(object)localPlayer4 != (Object)null && a.Length != 0)
					{
						ItemData val4 = ((Humanoid)localPlayer4).GetInventory().AddItem(a[0], 1, (int)F(a, 1, 1f), 0, 0L, "", false, false);
						if (val4 != null)
						{
							((Humanoid)localPlayer4).EquipItem(val4, true);
						}
					}
					break;
				}
				case "hud":
					if ((Object)(object)Hud.instance != (Object)null)
					{
						Hud.instance.m_userHidden = F(a, 0, 1f) < 0.5f;
					}
					break;
				case "view":
					yield return (object)new WaitForEndOfFrame();
					View((a.Length != 0) ? a[0] : "view", F(a, 1, 0f), F(a, 2, 10f), F(a, 3, 2.5f), F(a, 4, 1f));
					break;
				}
			}
			s_running = false;
		}

		private static float F(string[] a, int i, float d)
		{
			if (a.Length <= i || !float.TryParse(a[i], NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return d;
			}
			return result;
		}

		private static void View(string name, float az, float el, float dist, float height)
		{
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_00a8: 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_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_00c0: 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_0109: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			Vector3 val = ((Component)localPlayer).transform.position + Vector3.up * height;
			Vector3 val2 = ((Component)localPlayer).transform.rotation * (Quaternion.Euler(0f - el, az, 0f) * Vector3.forward);
			GameObject val3 = new GameObject("caca_lab_cam");
			try
			{
				Camera val4 = val3.AddComponent<Camera>();
				Camera main = Camera.main;
				if ((Object)(object)main != (Object)null)
				{
					val4.CopyFrom(main);
				}
				((Behaviour)val4).enabled = false;
				val4.fieldOfView = 40f;
				val4.nearClipPlane = 0.05f;
				val3.transform.position = val + val2 * dist;
				val3.transform.LookAt(val);
				RenderTexture val5 = (val4.targetTexture = RenderTexture.GetTemporary(900, 900, 24, (RenderTextureFormat)0));
				val4.Render();
				RenderTexture active = RenderTexture.active;
				RenderTexture.active = val5;
				Texture2D val6 = new Texture2D(900, 900, (TextureFormat)3, false);
				val6.ReadPixels(new Rect(0f, 0f, 900f, 900f), 0, 0);
				val6.Apply();
				RenderTexture.active = active;
				val4.targetTexture = null;
				RenderTexture.ReleaseTemporary(val5);
				Directory.CreateDirectory(Dir);
				File.WriteAllBytes(Path.Combine(Dir, name + ".png"), ImageConversion.EncodeToPNG(val6));
				Object.Destroy((Object)(object)val6);
				Plugin.Log.LogInfo((object)("Lab: wrote " + name + ".png"));
			}
			finally
			{
				Object.Destroy((Object)(object)val3);
			}
		}
	}
	internal static class Need
	{
		private const string KeyNeed = "caca_need";

		private const string KeyPending = "caca_pending";

		public static float Value;

		public static float Pending;

		private static Player s_for;

		private static float s_saveAt;

		public static bool Busy;

		private static Texture2D s_white;

		public static void Load(Player p)
		{
			s_for = p;
			Value = Read(p, "caca_need");
			Pending = Read(p, "caca_pending");
		}

		private static float Read(Player p, string key)
		{
			if (!p.m_customData.TryGetValue(key, out var value) || !float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return 0f;
			}
			return result;
		}

		public static void Save()
		{
			if (!((Object)(object)s_for == (Object)null))
			{
				s_for.m_customData["caca_need"] = Value.ToString("0.###", CultureInfo.InvariantCulture);
				s_for.m_customData["caca_pending"] = Pending.ToString("0.###", CultureInfo.InvariantCulture);
			}
		}

		public static void AddMeal(ItemData food)
		{
			float num = Mathf.Clamp(food.m_shared.m_food * Plugin.NeedPerFoodHealth.Value, 4f, 35f);
			Pending += num;
			Save();
			Fart.AddMeal();
		}

		public static void Tick(Player p)
		{
			if ((Object)(object)p != (Object)(object)s_for)
			{
				Load(p);
			}
			float deltaTime = Time.deltaTime;
			if (Pending > 0f)
			{
				float num = Mathf.Min(Pending, Plugin.DigestPerMinute.Value / 60f * deltaTime);
				Pending -= num;
				Value = Mathf.Min(100f, Value + num);
			}
			if (Time.time > s_saveAt)
			{
				s_saveAt = Time.time + 2f;
				Save();
			}
			if (Value >= 100f && !Busy && !Pee.Active && CanGo(p))
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(Go(p, urgent: true));
			}
		}

		public static bool CanGo(Player p)
		{
			if ((Object)(object)p != (Object)null && !((Character)p).IsDead() && ((Character)p).IsOnGround() && !((Character)p).IsSwimming() && !((Character)p).InWater() && !((Character)p).IsAttached() && !((Character)p).IsTeleporting())
			{
				return !((Character)p).InPlaceMode();
			}
			return false;
		}

		public static void TryOnCommand(Player p, bool force = false)
		{
			if (!Busy && !Pee.Active)
			{
				if (!force && Value < Plugin.MinNeed.Value)
				{
					((Character)p).Message((MessageType)2, "$msg_caca_notyet", 0, (Sprite)null, false);
				}
				else if (!CanGo(p))
				{
					((Character)p).Message((MessageType)2, "$msg_caca_nothere", 0, (Sprite)null, false);
				}
				else
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(Go(p, urgent: false));
				}
			}
		}

		private static IEnumerator Go(Player p, bool urgent)
		{
			Busy = true;
			if (urgent)
			{
				((Character)p).Message((MessageType)2, "$msg_caca_urgent", 0, (Sprite)null, false);
			}
			p.StartEmote("kneel", false);
			yield return (object)new WaitForSeconds(0.8f);
			if ((Object)(object)p == (Object)null || ((Character)p).IsDead())
			{
				Busy = false;
				yield break;
			}
			Vector3 back = -((Component)p).transform.forward;
			Vector3 pos = ((Component)p).transform.position + back * 0.12f + Vector3.up * 0.25f;
			Plugin.FartSound(pos);
			yield return (object)new WaitForSeconds(0.45f);
			if ((Object)(object)Plugin.PoopPrefab != (Object)null)
			{
				GameObject obj = Object.Instantiate<GameObject>(Plugin.PoopPrefab, pos, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f));
				Plugin.Plop(pos);
				Rigidbody component = obj.GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.velocity = back * 0.15f + Vector3.down * 0.5f;
				}
			}
			Value = Mathf.Max(0f, Value - 100f);
			Save();
			Fart.Value = 0f;
			yield return (object)new WaitForSeconds(1.4f);
			if ((Object)(object)p != (Object)null)
			{
				Traverse.Create((object)p).Method("StopEmote", Array.Empty<object>()).GetValue();
				((Character)p).Message((MessageType)1, "$msg_caca_relief", 0, (Sprite)null, false);
			}
			Busy = false;
		}

		public static void DrawDebug()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Hud.instance == (Object)null) && !Hud.IsUserHidden() && Plugin.ShowBars.Value)
			{
				if ((Object)(object)s_white == (Object)null)
				{
					s_white = new Texture2D(1, 1);
					s_white.SetPixel(0, 0, Color.white);
					s_white.Apply();
				}
				float num = (float)Screen.height / 1080f;
				float x = 0.012f * (float)Screen.width;
				float num2 = 0.7f * (float)Screen.height;
				Bar(x, num2, num, Value, Pending, new Color(0.55f, 0.34f, 0.12f), "caca");
				Bar(x, num2 + 22f * num, num, Pee.Value, 0f, new Color(0.9f, 0.8f, 0.2f), "pipi" + (Pee.Active ? (" " + Pee.Power.ToString("0.00")) : ""));
				Bar(x, num2 + 44f * num, num, Fart.Value, 0f, new Color(0.6f, 0.65f, 0.35f), "pet");
			}
		}

		private static void Bar(float x, float y, float scale, float value, float pending, Color fill, string label)
		{
			//IL_0010: 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_004f: 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_0078: 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_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)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0134: 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_00a8: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			float num = 170f * scale;
			float num2 = 12f * scale;
			Color color = GUI.color;
			GUI.color = new Color(0f, 0f, 0f, 0.55f);
			GUI.DrawTexture(new Rect(x - 2f, y - 2f, num + 4f, num2 + 4f), (Texture)(object)s_white);
			float num3 = Mathf.Clamp01(value / 100f);
			GUI.color = fill;
			GUI.DrawTexture(new Rect(x, y, num * num3, num2), (Texture)(object)s_white);
			float num4 = Mathf.Clamp01((value + pending) / 100f) - num3;
			if (num4 > 0f)
			{
				GUI.color = new Color(fill.r, fill.g, fill.b, 0.35f);
				GUI.DrawTexture(new Rect(x + num * num3, y, num * num4, num2), (Texture)(object)s_white);
			}
			GUI.color = Color.white;
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = Mathf.RoundToInt(12f * scale),
				fontStyle = (FontStyle)1
			};
			GUI.Label(new Rect(x + num + 6f * scale, y - 4f * scale, 200f * scale, 22f * scale), label + " " + Mathf.RoundToInt(value) + "%", val);
			GUI.color = color;
		}
	}
	[HarmonyPatch(typeof(Player), "EatFood")]
	internal static class EatPatch
	{
		private static void Postfix(Player __instance, ItemData item, bool __result)
		{
			if (__result && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && item != null)
			{
				Need.AddMeal(item);
			}
		}
	}
	public enum PeePose
	{
		Auto,
		Standing,
		Squatting
	}
	internal static class Pee
	{
		public const string ZdoPower = "caca_pee";

		public const string ZdoHold = "caca_pee_hold";

		public const string ZdoAim = "caca_pee_aim";

		public const string ZdoSquat = "caca_pee_squat";

		private static readonly FieldRef<Player, bool> s_crouch = AccessTools.FieldRefAccess<Player, bool>("m_crouchToggled");

		private const string KeyNeed = "caca_pee_need";

		private const float Prepare = 0.45f;

		public static float Value;

		public static bool Active;

		public static bool Squat;

		private static bool s_crouchBefore;

		public static float Power;

		public static Vector3 AimLocal = Vector3.forward;

		private static float s_since;

		private static bool s_walkBefore;

		private static Player s_for;

		private static float s_saveAt;

		private static float s_published = -1f;

		private static bool s_holdPublished;

		private static Vector3 s_aimPublished = Vector3.down;

		public static void Load(Player p)
		{
			s_for = p;
			Value = ((p.m_customData.TryGetValue("caca_pee_need", out var value) && float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) ? result : 0f);
			Active = false;
			Power = 0f;
		}

		public static void Save()
		{
			if ((Object)(object)s_for != (Object)null)
			{
				s_for.m_customData["caca_pee_need"] = Value.ToString("0.###", CultureInfo.InvariantCulture);
			}
		}

		public static void Tick(Player p)
		{
			//IL_00d2: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)p != (Object)(object)s_for)
			{
				Load(p);
			}
			float deltaTime = Time.deltaTime;
			if (!Active)
			{
				if (!((Character)p).InBed() && !((Character)p).IsDead())
				{
					Value = Mathf.Min(100f, Value + Plugin.PeeFillPerMinute.Value / 60f * deltaTime);
				}
				if (Value >= 100f && !Need.Busy && CanGo(p))
				{
					Start(p, urgent: true);
				}
			}
			else
			{
				s_since += deltaTime;
				if (!CanKeepGoing(p))
				{
					Stop(p, emptied: false);
				}
				else
				{
					((Character)p).SetWalk(true);
					if (Squat)
					{
						s_crouch.Invoke(p) = true;
					}
					AimLocal = (Squat ? SquatAim(p) : Aim(p));
					if (s_since >= 0.45f)
					{
						Value = Mathf.Max(0f, Value - 100f / Mathf.Max(0.5f, Plugin.PeeDrainSeconds.Value) * deltaTime);
						float num = Mathf.Clamp01((s_since - 0.45f) / 0.25f);
						Power = Strength(Value) * num;
						if (Value <= 0f)
						{
							Stop(p, emptied: true);
						}
					}
				}
			}
			if (Time.time > s_saveAt)
			{
				s_saveAt = Time.time + 2f;
				Save();
			}
			Publish(p);
		}

		public static float Strength(float value)
		{
			return Mathf.Pow(Mathf.Clamp01(value / 100f), 0.55f);
		}

		public static bool CanGo(Player p)
		{
			if ((Object)(object)p != (Object)null && !((Character)p).IsDead() && !((Character)p).IsSwimming() && !((Character)p).IsAttached() && !((Character)p).InBed() && !((Character)p).IsTeleporting() && !((Character)p).InCutscene())
			{
				return !((Character)p).InEmote();
			}
			return false;
		}

		private static bool CanKeepGoing(Player p)
		{
			if ((Object)(object)p != (Object)null && !((Character)p).IsDead() && !((Character)p).IsSwimming() && !((Character)p).IsAttached() && !((Character)p).InBed() && !((Character)p).IsTeleporting())
			{
				return !((Character)p).InCutscene();
			}
			return false;
		}

		public static void TryOnCommand(Player p, bool force = false)
		{
			if (Active)
			{
				Stop(p, emptied: false);
			}
			else
			{
				if (Need.Busy)
				{
					return;
				}
				if (!force && Value < Plugin.PeeMinNeed.Value)
				{
					((Character)p).Message((MessageType)2, "$msg_pipi_notyet", 0, (Sprite)null, false);
					return;
				}
				if (!CanGo(p))
				{
					((Character)p).Message((MessageType)2, "$msg_caca_nothere", 0, (Sprite)null, false);
					return;
				}
				if (force && Value < 30f)
				{
					Value = 30f;
				}
				Start(p, urgent: false);
			}
		}

		private static void Start(Player p, bool urgent)
		{
			//IL_0051: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			Active = true;
			s_since = 0f;
			Power = 0f;
			s_walkBefore = ((Character)p).GetWalk();
			Squat = IsSquatter(p);
			s_crouchBefore = s_crouch.Invoke(p);
			AimLocal = (Squat ? SquatAim(p) : Aim(p));
			if (urgent)
			{
				((Character)p).Message((MessageType)2, "$msg_pipi_urgent", 0, (Sprite)null, false);
			}
			Plugin.Log.LogInfo((object)("Pee start at " + Value.ToString("0") + " % (" + (urgent ? "forced" : "on command") + (Squat ? ", squatting" : "") + ")"));
		}

		public static void Stop(Player p, bool emptied)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!Active)
			{
				return;
			}
			Active = false;
			Power = 0f;
			s_aimPublished = Vector3.down;
			if ((Object)(object)p != (Object)null)
			{
				((Character)p).SetWalk(s_walkBefore);
				if (Squat)
				{
					s_crouch.Invoke(p) = s_crouchBefore;
				}
				if (emptied)
				{
					((Character)p).Message((MessageType)1, "$msg_pipi_relief", 0, (Sprite)null, false);
				}
			}
			Save();
			Plugin.Log.LogInfo((object)("Pee stop at " + Value.ToString("0") + " %"));
		}

		public static bool IsSquatter(Player p)
		{
			switch (Plugin.Pose.Value)
			{
			case PeePose.Standing:
				return false;
			case PeePose.Squatting:
				return true;
			default:
			{
				VisEquipment component = ((Component)p).GetComponent<VisEquipment>();
				if ((Object)(object)component != (Object)null)
				{
					return component.GetModelIndex() == 1;
				}
				return false;
			}
			}
		}

		private static Vector3 SquatAim(Player p)
		{
			//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_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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Quaternion.Inverse(((Component)p).transform.rotation) * ((Character)p).GetLookDir();
			float num = Mathf.Clamp(Mathf.Atan2(val.x, val.z) * 57.29578f, -15f, 15f);
			return Quaternion.Euler(0f - Plugin.SquatPitch.Value, num, 0f) * Vector3.forward;
		}

		private static Vector3 Aim(Player p)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0052: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (Lab.AimOn)
			{
				return Lab.Aim;
			}
			Vector3 lookDir = ((Character)p).GetLookDir();
			Vector3 val = Quaternion.Inverse(((Component)p).transform.rotation) * lookDir;
			float num = Mathf.Clamp(Mathf.Atan2(val.x, val.z) * 57.29578f, -35f, 35f);
			return Quaternion.Euler(0f - Mathf.Clamp(Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f)) * 57.29578f + Plugin.PeeAimLift.Value, -70f, 45f), num, 0f) * Vector3.forward;
		}

		private static void Publish(Player p)
		{
			//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_00c4: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			ZNetView component = ((Component)p).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
			{
				ZDO zDO = component.GetZDO();
				bool active = Active;
				if (Mathf.Abs(Power - s_published) > 0.01f || active != s_holdPublished)
				{
					zDO.Set("caca_pee", Power);
					zDO.Set("caca_pee_hold", active ? 1f : 0f);
					zDO.Set("caca_pee_squat", Squat ? 1f : 0f);
					s_published = Power;
					s_holdPublished = active;
				}
				if (active && Vector3.Angle(AimLocal, s_aimPublished) > 1f)
				{
					zDO.Set("caca_pee_aim", AimLocal);
					s_aimPublished = AimLocal;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetControls")]
	internal static class PeeControlsPatch
	{
		private static void Prefix(Player __instance, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge)
		{
			if (Pee.Active && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				attack = (attackHold = (secondaryAttack = (secondaryAttackHold = false)));
				block = (blockHold = (jump = (crouch = (run = (autoRun = (dodge = false))))));
			}
		}
	}
	[HarmonyPatch(typeof(Player), "AlwaysRotateCamera")]
	internal static class PeeRotatePatch
	{
		private static void Postfix(Player __instance, ref bool __result)
		{
			if (Pee.Active && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "Awake")]
	internal static class PlayerAwakePatch
	{
		private static void Postfix(Player __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<PeeStream>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<PeeStream>();
			}
		}
	}
	internal static class PeeArt
	{
		private static Mesh s_quad;

		public static Mesh Quad()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_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_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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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)
			if ((Object)(object)s_quad != (Object)null)
			{
				return s_quad;
			}
			Mesh val = new Mesh();
			((Object)val).name = "caca_quad";
			val.vertices = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(-0.5f, 0f, -0.5f),
				new Vector3(-0.5f, 0f, 0.5f),
				new Vector3(0.5f, 0f, 0.5f),
				new Vector3(0.5f, 0f, -0.5f)
			};
			val.uv = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(0f, 1f),
				new Vector2(1f, 1f),
				new Vector2(1f, 0f)
			};
			val.triangles = new int[6] { 0, 1, 2, 0, 2, 3 };
			s_quad = val;
			s_quad.RecalculateNormals();
			s_quad.RecalculateBounds();
			return s_quad;
		}

		public static Texture2D JetTexture()
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00bc: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(4, 32, (TextureFormat)4, false)
			{
				name = "caca_jet",
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 32; i++)
			{
				float num = ((float)i + 0.5f) / 32f * 2f - 1f;
				float num2 = Mathf.Clamp01(1f - Mathf.Pow(Mathf.Abs(num), 3f));
				float num3 = Mathf.Exp(0f - Mathf.Pow((num - 0.35f) / 0.12f, 2f));
				Color val2 = Color.Lerp(new Color(0.85f, 0.85f, 0.85f), Color.white, num3);
				val2.a = num2 * (0.75f + 0.25f * num3);
				for (int j = 0; j < 4; j++)
				{
					val.SetPixel(j, i, val2);
				}
			}
			val.Apply();
			return val;
		}

		public static Texture2D DropTexture()
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(32, 32, (TextureFormat)4, true)
			{
				name = "caca_drop",
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					float num = ((float)j + 0.5f) / 32f * 2f - 1f;
					float num2 = ((float)i + 0.5f) / 32f * 2f - 1f;
					float num3 = Mathf.Sqrt(num * num + num2 * num2);
					float a = Mathf.Clamp01((1f - num3) * 3f);
					float num4 = Mathf.Exp((0f - ((num + 0.3f) * (num + 0.3f) + (num2 - 0.3f) * (num2 - 0.3f))) / 0.06f);
					Color val2 = Color.Lerp(new Color(0.85f, 0.85f, 0.85f), Color.white, num4);
					val2.a = a;
					val.SetPixel(j, i, val2);
				}
			}
			val.Apply();
			return val;
		}

		public static Texture2D WetTexture()
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, true)
			{
				name = "caca_wet",
				wrapMode = (TextureWrapMode)1
			};
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = ((float)j + 0.5f) / 64f * 2f - 1f;
					float num2 = ((float)i + 0.5f) / 64f * 2f - 1f;
					float num3 = Mathf.Atan2(num2, num);
					float num4 = 0.78f + 0.08f * Mathf.Sin(num3 * 3f + 0.7f) + 0.06f * Mathf.Sin(num3 * 7f + 2.1f) + 0.03f * Mathf.Sin(num3 * 13f);
					float num5 = Mathf.Sqrt(num * num + num2 * num2) / num4;
					float num6 = Mathf.Clamp01((1f - num5) * 4f) * (0.75f + 0.25f * Mathf.Clamp01(1f - num5));
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num6));
				}
			}
			val.Apply();
			return val;
		}
	}
	internal class PeeStream : MonoBehaviour
	{
		private struct Drop
		{
			public Vector3 Pos;

			public Vector3 Vel;

			public float Age;

			public float Size;
		}

		private class Patch
		{
			public Transform T;

			public Material M;

			public float Size;

			public float Born;

			public float Fed;
		}

		private class WetFade : MonoBehaviour
		{
			public Patch Patch;

			private void Update()
			{
				//IL_0079: 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_009b: 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)
				float num = Time.time - Patch.Fed;
				float num2 = 0.55f * Mathf.Clamp01(1f - (num - 20f) / 40f);
				if (num2 <= 0f)
				{
					s_patches.Remove(Patch);
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
				else
				{
					float num3 = Mathf.Clamp01((Time.time - Patch.Born) / 1.5f);
					((Component)this).transform.localScale = Vector3.one * Patch.Size * (0.4f + 0.6f * num3);
					Patch.M.color = new Color(0.22f, 0.18f, 0.06f, num2);
				}
			}
		}

		private static readonly Dictionary<Character, PeeStream> s_of = new Dictionary<Character, PeeStream>();

		private const float Rate = 70f;

		private const float MaxAge = 3f;

		private const float JetMin = 0.3f;

		private static int s_mask;

		private static Material s_lineMat;

		private static Material s_dropMat;

		private static Material s_wetMat;

		private static readonly Color PeeColor = new Color(1f, 0.84f, 0.18f, 0.85f);

		public float Power;

		public float HandWeight;

		private Vector3 m_handTip;

		private int m_handTipFrame;

		private bool m_hasHandTip;

		public Vector3 Dir = Vector3.forward;

		private Player m_player;

		private ZNetView m_nview;

		private readonly List<Drop> m_drops = new List<Drop>(400);

		private float m_emitAcc;

		private float m_time;

		private LineRenderer m_line;

		private ParticleSystem m_dropsPs;

		private ParticleSystem m_splashPs;

		private Particle[] m_buf = (Particle[])(object)new Particle[400];

		private AudioSource m_ground;

		private AudioSource m_water;

		private Vector3 m_soundAt;

		private float m_hitRate;

		private float m_waterShare;

		private bool m_built;

		private bool m_squat;

		private static readonly RaycastHit[] s_hits = (RaycastHit[])(object)new RaycastHit[8];

		private static readonly List<Vector3> s_pts = new List<Vector3>(64);

		private static readonly List<Patch> s_patches = new List<Patch>();

		private const int MaxPatches = 24;

		private GameObject m_hidden;

		private float BreakAge => Mathf.Lerp(0.06f, 0.24f, Power);

		public static PeeStream Of(Character c)
		{
			if (!((Object)(object)c != (Object)null) || !s_of.TryGetValue(c, out var value))
			{
				return null;
			}
			return value;
		}

		public void SetHandTip(Vector3 tip)
		{
			//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)
			m_handTip = tip;
			m_handTipFrame = Time.frameCount;
			m_hasHandTip = true;
		}

		private void Awake()
		{
			m_player = ((Component)this).GetComponent<Player>();
			m_nview = ((Component)this).GetComponent<ZNetView>();
			if ((Object)(object)m_player != (Object)null)
			{
				s_of[(Character)(object)m_player] = this;
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)m_player != (Object)null)
			{
				s_of.Remove((Character)(object)m_player);
			}
			if ((Object)(object)m_line != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)m_line).gameObject);
			}
			if ((Object)(object)m_dropsPs != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)m_dropsPs).gameObject);
			}
			if ((Object)(object)m_splashPs != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)m_splashPs).gameObject);
			}
			if ((Object)(object)m_ground != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)m_ground).gameObject);
			}
			if ((Object)(object)m_water != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)m_water).gameObject);
			}
		}

		private void ReadState(out float power, out bool hold, out Vector3 aimLocal)
		{
			//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_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_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)
			if ((Object)(object)m_player == (Object)(object)Player.m_localPlayer)
			{
				power = Pee.Power;
				hold = Pee.Active;
				aimLocal = Pee.AimLocal;
				m_squat = Pee.Squat;
				return;
			}
			power = 0f;
			hold = false;
			aimLocal = Vector3.forward;
			if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid())
			{
				ZDO zDO = m_nview.GetZDO();
				power = zDO.GetFloat("caca_pee", 0f);
				hold = zDO.GetFloat("caca_pee_hold", 0f) > 0.5f;
				aimLocal = zDO.GetVec3("caca_pee_aim", Vector3.forward);
				m_squat = zDO.GetFloat("caca_pee_squat", 0f) > 0.5f;
			}
		}

		private void LateUpdate()
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_player == (Object)null)
			{
				return;
			}
			ReadState(out var power, out var hold, out var aimLocal);
			if (m_drops.Count == 0 && !hold && HandWeight <= 0f && Power <= 0f)
			{
				if (m_built)
				{
					Idle();
				}
				return;
			}
			float num = Mathf.Min(Time.deltaTime, 0.05f);
			m_time += num;
			HandWeight = Mathf.MoveTowards(HandWeight, (!m_squat && (hold || power > 0f)) ? 1f : 0f, num * 4f);
			Power = ((power > Power) ? Mathf.MoveTowards(Power, power, num * 5f) : power);
			Vector3 val = ((Component)m_player).transform.rotation * aimLocal;
			Dir = ((Vector3)(ref val)).normalized;
			if (!m_built)
			{
				Build();
			}
			HideWeapon(HandWeight > 0f);
			Vector3 tip;
			if (m_squat)
			{
				Body.SquatTip((Character)(object)m_player, out tip);
			}
			else if (Time.frameCount - m_handTipFrame > 2 || !m_hasHandTip)
			{
				Body.Tip((Character)(object)m_player, out tip);
			}
			else
			{
				tip = m_handTip;
			}
			Emit(tip, num);
			Simulate(num, tip.y);
			Draw(tip);
			Sound(num);
		}

		private void Emit(Vector3 tip, float dt)
		{
			//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_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_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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_0138: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			if (Power <= 0.01f)
			{
				m_emitAcc = 0f;
				return;
			}
			m_emitAcc += dt * 70f;
			Vector3 velocity = ((Character)m_player).GetVelocity();
			float num = Mathf.Lerp(Plugin.PeeMinSpeed.Value, Plugin.PeeMaxSpeed.Value, Power);
			if (m_squat)
			{
				num *= Plugin.SquatSpeed.Value;
			}
			num *= 1f + 0.05f * Mathf.Sin(m_time * 2.3f) + 0.03f * Mathf.Sin(m_time * 13.7f + 1.3f);
			float num2 = Mathf.Lerp(0.18f, m_squat ? 0.05f : 0.015f, Power);
			int num3 = 0;
			while (m_emitAcc >= 1f)
			{
				m_emitAcc -= 1f;
				float num4 = m_emitAcc / 70f;
				Vector3 val = Dir + Random.insideUnitSphere * num2;
				Vector3 val2 = ((Vector3)(ref val)).normalized * num + velocity;
				val2 += Physics.gravity * num4;
				Drop item = new Drop
				{
					Pos = tip + val2 * num4,
					Vel = val2,
					Age = num4,
					Size = Random.Range(0.8f, 1.2f)
				};
				m_drops.Add(item);
				if (++num3 > 8)
				{
					m_emitAcc = 0f;
					break;
				}
			}
		}

		private void Simulate(float dt, float tipY)
		{
			//IL_0069: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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_0167: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: 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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			if (s_mask == 0)
			{
				s_mask = LayerMask.GetMask(new string[10] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle", "character", "character_net", "character_noenv", "hitbox" });
			}
			Vector3 gravity = Physics.gravity;
			int num = 0;
			int num2 = 0;
			Vector3 val = Vector3.zero;
			Vector3 val2 = default(Vector3);
			for (int num3 = m_drops.Count - 1; num3 >= 0; num3--)
			{
				Drop value = m_drops[num3];
				Vector3 pos = value.Pos;
				ref Vector3 vel = ref value.Vel;
				vel += gravity * dt;
				ref Vector3 vel2 = ref value.Vel;
				vel2 *= 1f - 0.12f * dt;
				ref Vector3 pos2 = ref value.Pos;
				pos2 += value.Vel * dt;
				value.Age += dt;
				Vector3 step = value.Pos - pos;
				bool flag = value.Age > 3f;
				if (!flag && FirstHit(pos, step, out var best))
				{
					Splash(((RaycastHit)(ref best)).point, ((RaycastHit)(ref best)).normal, value.Vel, water: false);
					Wet(((RaycastHit)(ref best)).point, ((RaycastHit)(ref best)).normal, ((RaycastHit)(ref best)).collider);
					val += ((RaycastHit)(ref best)).point;
					num++;
					flag = true;
				}
				else if (!flag && value.Vel.y < 0f && value.Pos.y < tipY - 0.4f)
				{
					float liquidLevel = Floating.GetLiquidLevel(value.Pos, 1f, (LiquidType)10);
					if (liquidLevel > -1000f && value.Pos.y < liquidLevel)
					{
						((Vector3)(ref val2))..ctor(value.Pos.x, liquidLevel, value.Pos.z);
						Splash(val2, Vector3.up, value.Vel, water: true);
						val += val2;
						num++;
						num2++;
						flag = true;
					}
				}
				if (flag)
				{
					m_drops.RemoveAt(num3);
				}
				else
				{
					m_drops[num3] = value;
				}
			}
			float num4 = (float)num / Mathf.Max(dt, 0.001f);
			m_hitRate = Mathf.Lerp(m_hitRate, num4, 1f - Mathf.Exp((0f - dt) * 6f));
			if (num > 0)
			{
				Vector3 val3 = val / (float)num;
				m_soundAt = ((m_soundAt == Vector3.zero) ? val3 : Vector3.Lerp(m_soundAt, val3, 1f - Mathf.Exp((0f - dt) * 8f)));
				m_waterShare = Mathf.Lerp(m_waterShare, (float)num2 / (float)num, 1f - Mathf.Exp((0f - dt) * 4f));
			}
		}

		private bool FirstHit(Vector3 from, Vector3 step, out RaycastHit best)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_008f: 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)
			best = default(RaycastHit);
			float magnitude = ((Vector3)(ref step)).magnitude;
			if (magnitude < 1E-05f)
			{
				return false;
			}
			int num = Physics.RaycastNonAlloc(from, step / magnitude, s_hits, magnitude, s_mask, (QueryTriggerInteraction)1);
			float num2 = float.MaxValue;
			for (int i = 0; i < num; i++)
			{
				RaycastHit val = s_hits[i];
				if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).transform.root == (Object)(object)((Component)m_player).transform) && ((RaycastHit)(ref val)).distance < num2)
				{
					num2 = ((RaycastHit)(ref val)).distance;
					best = val;
				}
			}
			return num2 < float.MaxValue;
		}

		private void Draw(Vector3 tip)
		{
			//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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or