Decompiled source of Timeline Colliders v1.7.0

Mods/TimelineColliders.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using AC130;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2CppInterop.Common;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Combat;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using TimelineClones;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.XR;
using Wiggles;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: MelonInfo(typeof(WigglesBW), "Timeline Colliders", "1.7.0", "adama", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonOptionalDependencies(new string[] { "Timeline" })]
[assembly: HarmonyDontPatchAll]
[assembly: InternalsVisibleTo("TimelineColliders.Timeline")]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("1.7.0.0")]
[module: UnverifiableCode]
namespace AC130
{
	internal static class PixelFont
	{
		internal const int GlyphW = 5;

		internal const int GlyphH = 7;

		private static readonly Dictionary<char, string> Glyphs = new Dictionary<char, string>
		{
			['A'] = "01110100011000111111100011000110001",
			['B'] = "11110100011000111110100011000111110",
			['C'] = "01110100011000010000100001000101110",
			['D'] = "11110100011000110001100011000111110",
			['E'] = "11111100001000011110100001000011111",
			['F'] = "11111100001000011110100001000010000",
			['G'] = "01110100011000010111100011000101111",
			['H'] = "10001100011000111111100011000110001",
			['I'] = "01110001000010000100001000010001110",
			['J'] = "00111000100001000010000101001001100",
			['K'] = "10001100101010011000101001001010001",
			['L'] = "10000100001000010000100001000011111",
			['M'] = "10001110111010110101100011000110001",
			['N'] = "10001100011100110101100111000110001",
			['O'] = "01110100011000110001100011000101110",
			['P'] = "11110100011000111110100001000010000",
			['Q'] = "01110100011000110001101011001001101",
			['R'] = "11110100011000111110101001001010001",
			['S'] = "01111100001000001110000010000111110",
			['T'] = "11111001000010000100001000010000100",
			['U'] = "10001100011000110001100011000101110",
			['V'] = "10001100011000110001100010101000100",
			['W'] = "10001100011000110101101011010101010",
			['X'] = "10001100010101000100010101000110001",
			['Y'] = "10001100010101000100001000010000100",
			['Z'] = "11111000010001000100010001000011111",
			['0'] = "01110100011001110101110011000101110",
			['1'] = "00100011000010000100001000010001110",
			['2'] = "01110100010000100010001000100011111",
			['3'] = "11111000100010000010000011000101110",
			['4'] = "00010001100101010010111110001000010",
			['5'] = "11111100001111000001000011000101110",
			['6'] = "00110010001000011110100011000101110",
			['7'] = "11111000010001000100010000100001000",
			['8'] = "01110100011000101110100011000101110",
			['9'] = "01110100011000101111000010001001100",
			[':'] = "00000011000110000000011000110000000",
			['.'] = "00000000000000000000000000110001100",
			['%'] = "11000110010001000100010001001100011",
			['/'] = "00000000010001000100010001000000000",
			['-'] = "00000000000000011111000000000000000",
			['+'] = "00000001000010011111001000010000000",
			['!'] = "00100001000010000100001000000000100",
			['>'] = "01000001000001000001000100010001000",
			['<'] = "00010001000100010000010000010000010",
			['['] = "01110010000100001000010000100001110",
			[']'] = "01110000100001000010000100001001110",
			['#'] = "01010010101111101010111110101001010",
			['='] = "00000000001111100000111110000000000",
			['*'] = "00000001001010101110101010010000000",
			['?'] = "01110100010000100010001000000000100",
			[','] = "00000000000000000000011000010001000",
			['_'] = "00000000000000000000000000000011111"
		};

		internal static int Measure(string text, int scale)
		{
			return text.Length * 6 * scale - scale;
		}

		internal static void Draw(Color32[] buf, int bw, int bh, string text, int x, int y, int scale, Color32 color, bool outline = true)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (outline)
			{
				Color32 color2 = default(Color32);
				((Color32)(ref color2))..ctor((byte)0, (byte)0, (byte)0, (byte)255);
				DrawRaw(buf, bw, bh, text, x + scale, y + scale, scale, color2);
			}
			DrawRaw(buf, bw, bh, text, x, y, scale, color);
		}

		internal static void DrawCentered(Color32[] buf, int bw, int bh, string text, int cy, int scale, Color32 color)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Draw(buf, bw, bh, text, (bw - Measure(text, scale)) / 2, cy, scale, color);
		}

		private static void DrawRaw(Color32[] buf, int bw, int bh, string text, int x, int y, int scale, Color32 color)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			int num = x;
			string text2 = default(string);
			for (int i = 0; i < text.Length; i++)
			{
				char c = char.ToUpperInvariant(text[i]);
				if (Glyphs.TryGetValue(c, ref text2))
				{
					for (int j = 0; j < 7; j++)
					{
						for (int k = 0; k < 5; k++)
						{
							if (text2[j * 5 + k] == '1')
							{
								FillRect(buf, bw, bh, num + k * scale, y + j * scale, scale, scale, color);
							}
						}
					}
				}
				num += 6 * scale;
			}
		}

		internal static void FillRect(Color32[] buf, int bw, int bh, int x, int y, int w, int h, Color32 color)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Max(0, x);
			int num2 = Mathf.Max(0, y);
			int num3 = Mathf.Min(bw, x + w);
			int num4 = Mathf.Min(bh, y + h);
			for (int i = num2; i < num4; i++)
			{
				int num5 = i * bw;
				for (int j = num; j < num3; j++)
				{
					buf[num5 + j] = color;
				}
			}
		}

		internal static void Rect(Color32[] buf, int bw, int bh, int x, int y, int w, int h, Color32 color)
		{
			//IL_0009: 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_002e: 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)
			FillRect(buf, bw, bh, x, y, w, 1, color);
			FillRect(buf, bw, bh, x, y + h - 1, w, 1, color);
			FillRect(buf, bw, bh, x, y, 1, h, color);
			FillRect(buf, bw, bh, x + w - 1, y, 1, h, color);
		}
	}
}
namespace Wiggles
{
	internal static class CrashGuard
	{
		private static MelonPreferences_Category _prefs;

		internal static MelonPreferences_Entry<bool> SafeMode;

		private static MelonPreferences_Entry<int> Crashes;

		private static MelonPreferences_Entry<string> TurnedOff;

		private static MelonPreferences_Entry<string> LastVersion;

		private static string _marker;

		private static bool _markedGood;

		private static float _inLevelFor;

		private static readonly HashSet<string> _off = new HashSet<string>();

		private static string _playMarker;

		private static string _lastDoing;

		private static string _level;

		private static float _nextDoing;

		private static readonly List<ValueTuple<string, Func<bool>>> _doing = new List<ValueTuple<string, Func<bool>>>();

		internal static bool AnyOff => _off.Count > 0;

		internal static void Track(string what, Func<bool> on)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			_doing.Add(new ValueTuple<string, Func<bool>>(what, on));
		}

		internal static void Start(string version)
		{
			_prefs = MelonPreferences.CreateCategory("WigglesBW");
			SafeMode = _prefs.CreateEntry<bool>("SafeMode", false, "Safe mode: all Timeline Colliders features off (turns on by itself after 2 crashes while loading)", (string)null, false, false, (ValueValidator)null, (string)null);
			Crashes = _prefs.CreateEntry<int>("CrashesWhileLoading", 0, "Launches in a row that crashed while loading (set by Timeline Colliders)", (string)null, false, false, (ValueValidator)null, (string)null);
			TurnedOff = _prefs.CreateEntry<string>("TurnedOffAfterCrash", "", "Parts turned off because the game crashed while they started (set by Timeline Colliders)", (string)null, false, false, (ValueValidator)null, (string)null);
			LastVersion = _prefs.CreateEntry<string>("LastVersion", "", "Version that ran last (set by Timeline Colliders)", (string)null, false, false, (ValueValidator)null, (string)null);
			if (LastVersion.Value != version)
			{
				if (SafeMode.Value || Crashes.Value != 0 || TurnedOff.Value.Length > 0)
				{
					WigglesBW.Log.Msg("Updated to " + version + ": safe mode and crash history cleared.");
				}
				SafeMode.Value = false;
				Crashes.Value = 0;
				TurnedOff.Value = "";
				LastVersion.Value = version;
			}
			SafeMode.Value = false;
			TurnedOff.Value = "";
			string text = null;
			try
			{
				string text2 = Path.Combine(MelonEnvironment.UserDataDirectory, "WigglesBW");
				Directory.CreateDirectory(text2);
				_marker = Path.Combine(text2, "loading.marker");
				_playMarker = Path.Combine(text2, "playing.marker");
				if (File.Exists(_playMarker))
				{
					string[] array = File.ReadAllLines(_playMarker);
					string text3 = ((array.Length > 1) ? array[1].Trim() : "");
					string text4 = ((array.Length != 0) ? array[0].Trim() : "");
					WigglesBW.Log.Warning("The last session ended without quitting normally (crash or closed from the headset menu) at " + text4 + ", while: " + ((text3.Length > 0) ? text3 : "playing"));
					Diagnostics.Report("Last Session", "The game closed without quitting normally last time (a crash, or closed from the headset menu) while: " + ((text3.Length > 0) ? text3 : "playing") + ". If it crashed, send the MelonLoader log of that session (MelonLoader/Logs) to the mod author.");
					File.Delete(_playMarker);
				}
				if (File.Exists(_marker))
				{
					string[] array2 = File.ReadAllLines(_marker);
					text = ((array2.Length > 1) ? array2[1].Trim() : "");
					WigglesBW.Log.Warning("The last launch didn't finish loading (crash?). It was at: " + (string.IsNullOrEmpty(text) ? "starting" : text));
				}
			}
			catch (global::System.Exception ex)
			{
				WigglesBW.Log.Warning("Crash protection unavailable: " + ex.Message);
			}
			string text5 = Blame(text);
			if (text5 != null)
			{
				Diagnostics.Report("Crash", $"The game crashed last time while {"Timeline Colliders"} was starting \"{Friendly(text5)}\". Please send the MelonLoader log to the mod author.");
			}
			else if (text != null)
			{
				MelonPreferences_Entry<int> crashes = Crashes;
				int value = crashes.Value;
				crashes.Value = value + 1;
				Diagnostics.Report("Crash", "The last launch crashed while loading. If it keeps happening, send the MelonLoader log to the mod author.");
			}
			if (_off.Count > 0)
			{
				WigglesBW.Log.Warning("Turned off after a crash: " + string.Join(", ", Enumerable.Select<string, string>((global::System.Collections.Generic.IEnumerable<string>)_off, (Func<string, string>)Friendly)));
			}
			Stage("starting");
			Save();
		}

		private static string Blame(string stage)
		{
			if (string.IsNullOrEmpty(stage))
			{
				return null;
			}
			if (stage.StartsWith("module:"))
			{
				return stage;
			}
			if (stage.StartsWith("hook:"))
			{
				return stage;
			}
			if (stage.StartsWith("after hook:"))
			{
				return "hook:" + stage.Substring("after hook:".Length);
			}
			return null;
		}

		private static string Friendly(string id)
		{
			if (!id.StartsWith("module:"))
			{
				if (!id.StartsWith("hook:"))
				{
					return id;
				}
				return "game hook " + id.Substring(5);
			}
			return id.Substring(7);
		}

		internal static bool IsOff(string id)
		{
			return _off.Contains(id);
		}

		internal static void Stage(string what)
		{
			if (_markedGood || _marker == null)
			{
				return;
			}
			try
			{
				File.WriteAllText(_marker, global::System.DateTime.Now.ToString("o") + "\n" + what + "\n");
			}
			catch
			{
			}
		}

		internal static void LateHookStart(string id)
		{
			if (_marker == null)
			{
				return;
			}
			try
			{
				File.WriteAllText(_marker, global::System.DateTime.Now.ToString("o") + "\nhook:" + id + "\n");
			}
			catch
			{
			}
		}

		internal static void LateHookDone()
		{
			if (!_markedGood)
			{
				Stage("playing");
				return;
			}
			try
			{
				if (_marker != null && File.Exists(_marker))
				{
					File.Delete(_marker);
				}
			}
			catch
			{
			}
		}

		internal static void NoteLevel(string what)
		{
			_level = what;
			_lastDoing = null;
			if (_playMarker == null)
			{
				return;
			}
			try
			{
				File.WriteAllText(_playMarker, global::System.DateTime.Now.ToString("o") + "\n" + what + "\n");
			}
			catch
			{
			}
		}

		internal static void Update()
		{
			if (_markedGood)
			{
				UpdateDoing();
				return;
			}
			if ((Object)(object)Player.Head == (Object)null)
			{
				_inLevelFor = 0f;
				return;
			}
			_inLevelFor += Time.unscaledDeltaTime;
			if (!(_inLevelFor < 20f) && !Patches.Pending)
			{
				MarkGood();
			}
		}

		internal static void CleanExit()
		{
			MarkGood();
			try
			{
				if (_playMarker != null && File.Exists(_playMarker))
				{
					File.Delete(_playMarker);
				}
			}
			catch
			{
			}
			_lastDoing = null;
		}

		private static void UpdateDoing()
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (_playMarker == null || Time.realtimeSinceStartup < _nextDoing)
			{
				return;
			}
			_nextDoing = Time.realtimeSinceStartup + 3f;
			List<string> val = new List<string>();
			Enumerator<ValueTuple<string, Func<bool>>> enumerator = _doing.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ValueTuple<string, Func<bool>> current = enumerator.Current;
					string item = current.Item1;
					Func<bool> item2 = current.Item2;
					try
					{
						if (item2.Invoke())
						{
							val.Add(item);
						}
					}
					catch
					{
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			string text = ((val.Count > 0) ? string.Join(", ", (global::System.Collections.Generic.IEnumerable<string>)val) : "playing");
			if (_level != null)
			{
				text = text + " (" + _level + ")";
			}
			if (text == _lastDoing)
			{
				return;
			}
			_lastDoing = text;
			try
			{
				File.WriteAllText(_playMarker, global::System.DateTime.Now.ToString("o") + "\n" + text + "\n");
			}
			catch
			{
			}
		}

		private static void MarkGood()
		{
			if (_markedGood)
			{
				return;
			}
			_markedGood = true;
			try
			{
				if (_marker != null && File.Exists(_marker))
				{
					File.Delete(_marker);
				}
			}
			catch
			{
			}
			if (Crashes != null && Crashes.Value != 0)
			{
				Crashes.Value = 0;
				Save();
			}
		}

		internal static void SetSafeMode(bool on)
		{
			SafeMode.Value = on;
			if (!on)
			{
				Crashes.Value = 0;
			}
			Save();
		}

		internal static void TurnEverythingBackOn()
		{
			_off.Clear();
			TurnedOff.Value = "";
			SafeMode.Value = false;
			Crashes.Value = 0;
			Save();
		}

		private static void Save()
		{
			try
			{
				_prefs.SaveToFile(false);
			}
			catch
			{
			}
		}
	}
	internal static class CrateAsset
	{
		internal static bool Load(string barcode, Action<GameObject> done)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			AssetWarehouse instance = AssetWarehouse.Instance;
			Crate val = default(Crate);
			if (instance == null || !instance.TryGetCrate(new Barcode(barcode), ref val) || (Object)(object)val == (Object)null)
			{
				return false;
			}
			SpawnableCrate val2 = ((Il2CppObjectBase)val).TryCast<SpawnableCrate>();
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			Action<GameObject> val3 = delegate(GameObject go)
			{
				try
				{
					done.Invoke(go);
				}
				catch (global::System.Exception ex)
				{
					WigglesBW.Log.Warning("Loading " + barcode + " failed: " + ex.Message);
				}
			};
			((CrateT<GameObject>)(object)val2).LoadAsset(Action<GameObject>.op_Implicit(val3));
			return true;
		}
	}
	internal static class Diagnostics
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<MelonBase, bool> <>9__12_0;

			public static Func<ValueTuple<string, string>, bool> <>9__14_0;

			public static Func<ValueTuple<string, string>, string> <>9__15_0;

			public static Action <>9__21_0;

			public static Action <>9__21_2;

			public static Action <>9__21_1;

			internal bool <CheckStartup>b__12_0(MelonBase m)
			{
				return m.Info.Name == "BoneLib";
			}

			internal bool <OnLevelLoaded>b__14_0(ValueTuple<string, string> p)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return Severe(p.Item1, p.Item2);
			}

			internal string <Update>b__15_0(ValueTuple<string, string> p)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return p.Item2;
			}

			internal void <RefreshPage>b__21_0()
			{
			}

			internal void <RefreshPage>b__21_2()
			{
			}

			internal void <RefreshPage>b__21_1()
			{
				_shownThisLevel = false;
				_pendingShow = true;
			}
		}

		[CompilerGenerated]
		private sealed class <Wrap>d__19 : global::System.Collections.Generic.IEnumerable<string>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<string>, global::System.IDisposable, global::System.Collections.IEnumerator
		{
			private int <>1__state;

			private string <>2__current;

			private int <>l__initialThreadId;

			private string text;

			public string <>3__text;

			private int width;

			public int <>3__width;

			private string[] <>7__wrap1;

			private int <>7__wrap2;

			private string <w>5__4;

			string global::System.Collections.Generic.IEnumerator<string>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object global::System.Collections.IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Wrap>d__19(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void global::System.IDisposable.Dispose()
			{
			}

			private bool MoveNext()
			{
				string text;
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					string[] array = this.text.Split(' ', (StringSplitOptions)0);
					text = "";
					<>7__wrap1 = array;
					<>7__wrap2 = 0;
					goto IL_00d6;
				}
				case 1:
					<>1__state = -1;
					text = "";
					goto IL_009f;
				case 2:
					{
						<>1__state = -1;
						break;
					}
					IL_00d6:
					if (<>7__wrap2 < <>7__wrap1.Length)
					{
						<w>5__4 = <>7__wrap1[<>7__wrap2];
						if (text.Length + <w>5__4.Length + 1 > width && text.Length > 0)
						{
							<>2__current = text;
							<>1__state = 1;
							return true;
						}
						goto IL_009f;
					}
					<>7__wrap1 = null;
					if (text.Length > 0)
					{
						<>2__current = text;
						<>1__state = 2;
						return true;
					}
					break;
					IL_009f:
					text = ((text.Length == 0) ? <w>5__4 : (text + " " + <w>5__4));
					<w>5__4 = null;
					<>7__wrap2++;
					goto IL_00d6;
				}
				return false;
			}

			bool global::System.Collections.IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void global::System.Collections.IEnumerator.Reset()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			global::System.Collections.Generic.IEnumerator<string> global::System.Collections.Generic.IEnumerable<string>.GetEnumerator()
			{
				<Wrap>d__19 <Wrap>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Wrap>d__ = this;
				}
				else
				{
					<Wrap>d__ = new <Wrap>d__19(0);
				}
				<Wrap>d__.text = <>3__text;
				<Wrap>d__.width = <>3__width;
				return <Wrap>d__;
			}

			[DebuggerHidden]
			global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
			{
				return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<string>)this).GetEnumerator();
			}
		}

		internal static readonly Version MinBoneLib = new Version(3, 2, 0);

		private static readonly List<ValueTuple<string, string>> _problems = new List<ValueTuple<string, string>>();

		private static readonly HashSet<string> _seen = new HashSet<string>();

		private static bool _shownThisLevel;

		private static bool _pendingShow;

		private static float _hideAt;

		private static GameObject _panel;

		private static Texture2D _tex;

		private static Page _page;

		private const int W = 640;

		private const int H = 300;

		internal static int Count => _problems.Count;

		internal static void Report(string where, string what)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			string text = where + "|" + what;
			if (_seen.Add(text))
			{
				_problems.Add(new ValueTuple<string, string>(where, what));
				Instance log = WigglesBW.Log;
				if (log != null)
				{
					log.Warning("PROBLEM [" + where + "] " + what);
				}
				if (Severe(where, what))
				{
					_pendingShow = true;
				}
				RefreshPage();
			}
		}

		internal static void CheckStartup(MelonMod self)
		{
			try
			{
				MelonBase val = Enumerable.FirstOrDefault<MelonBase>((global::System.Collections.Generic.IEnumerable<MelonBase>)MelonBase.RegisteredMelons, (Func<MelonBase, bool>)((MelonBase m) => m.Info.Name == "BoneLib"));
				Version val2 = default(Version);
				if (val != null && Version.TryParse(val.Info.Version.Split('-', (StringSplitOptions)0)[0], ref val2) && val2 < MinBoneLib)
				{
					Report("BoneLib", $"BoneLib {val.Info.Version} is too old. Install BoneLib {MinBoneLib}+ (bonelib-BoneLib on Thunderstore).");
				}
			}
			catch
			{
			}
		}

		private static bool Severe(string where, string what)
		{
			if (!(where == "Safe Mode"))
			{
				return what.IndexOf("stays off", (StringComparison)5) >= 0;
			}
			return true;
		}

		internal static void OnLevelLoaded()
		{
			_shownThisLevel = false;
			if (Enumerable.Any<ValueTuple<string, string>>((global::System.Collections.Generic.IEnumerable<ValueTuple<string, string>>)_problems, (Func<ValueTuple<string, string>, bool>)((ValueTuple<string, string> p) => Severe(p.Item1, p.Item2))))
			{
				_pendingShow = true;
			}
		}

		internal static void Update()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00b8: 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_00db: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_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_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			if ((Object)(object)_panel != (Object)null)
			{
				Transform head = Player.Head;
				if ((Object)(object)head == (Object)null || Time.realtimeSinceStartup > _hideAt)
				{
					Object.Destroy((Object)(object)_panel);
					_panel = null;
				}
				else
				{
					Vector3 val = Vector3.ProjectOnPlane(head.forward, Vector3.up);
					Vector3 val2 = ((Vector3)(ref val)).normalized;
					if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
					{
						val2 = Vector3.forward;
					}
					Vector3 val3 = head.position + val2 * 1.3f;
					float num = Mathf.Min(1f, 4f * Time.unscaledDeltaTime);
					_panel.transform.position = Vector3.Lerp(_panel.transform.position, val3, num);
					_panel.transform.rotation = Quaternion.Slerp(_panel.transform.rotation, Quaternion.LookRotation(val2), num);
				}
			}
			if (!_pendingShow || _shownThisLevel || _problems.Count == 0)
			{
				return;
			}
			Transform head2 = Player.Head;
			if ((Object)(object)head2 == (Object)null)
			{
				return;
			}
			_pendingShow = false;
			_shownThisLevel = true;
			try
			{
				ShowPanel(head2);
			}
			catch (global::System.Exception ex)
			{
				Instance log = WigglesBW.Log;
				if (log != null)
				{
					log.Warning("Problem panel failed: " + ex.Message);
				}
			}
			try
			{
				Notifier.Send(new Notification
				{
					Title = NotificationText.op_Implicit("Timeline Colliders: problem found"),
					Message = NotificationText.op_Implicit(string.Join("\n", Enumerable.Select<ValueTuple<string, string>, string>(Enumerable.Take<ValueTuple<string, string>>((global::System.Collections.Generic.IEnumerable<ValueTuple<string, string>>)_problems, 3), (Func<ValueTuple<string, string>, string>)((ValueTuple<string, string> p) => p.Item2)))),
					PopupLength = 10f,
					ShowTitleOnPopup = true
				});
			}
			catch
			{
			}
		}

		private static void ShowPanel(Transform head)
		{
			//IL_006e: 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_0098: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_02cc: 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_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: 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_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Expected O, but got Unknown
			Color32[] array = (Color32[])(object)new Color32[192000];
			Color32 val = default(Color32);
			((Color32)(ref val))..ctor((byte)20, (byte)6, (byte)6, (byte)235);
			Color32 color = default(Color32);
			((Color32)(ref color))..ctor((byte)255, (byte)70, (byte)60, (byte)255);
			Color32 color2 = default(Color32);
			((Color32)(ref color2))..ctor((byte)240, (byte)240, (byte)240, (byte)255);
			Color32 color3 = default(Color32);
			((Color32)(ref color3))..ctor((byte)170, (byte)170, (byte)170, (byte)255);
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val;
			}
			PixelFont.Rect(array, 640, 300, 0, 0, 640, 300, color);
			PixelFont.Rect(array, 640, 300, 1, 1, 638, 298, color);
			PixelFont.DrawCentered(array, 640, 300, "Timeline Colliders".ToUpperInvariant() + " - PROBLEM FOUND", 10, 3, color);
			int num = 44;
			Enumerator<ValueTuple<string, string>> enumerator = _problems.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ValueTuple<string, string> current = enumerator.Current;
					string item = current.Item1;
					string item2 = current.Item2;
					global::System.Collections.Generic.IEnumerator<string> enumerator2 = Wrap("[" + item.ToUpperInvariant() + "] " + item2.ToUpperInvariant(), 50).GetEnumerator();
					try
					{
						while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
						{
							string current2 = enumerator2.Current;
							if (num > 270)
							{
								break;
							}
							PixelFont.Draw(array, 640, 300, current2, 12, num, 2, color2);
							num += 18;
						}
					}
					finally
					{
						((global::System.IDisposable)enumerator2)?.Dispose();
					}
					num += 6;
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			PixelFont.DrawCentered(array, 640, 300, "FULL LIST: BONEMENU > " + "Timeline Colliders".ToUpperInvariant() + " > PROBLEMS", 282, 1, color3);
			Color32[] array2 = (Color32[])(object)new Color32[array.Length];
			for (int j = 0; j < 300; j++)
			{
				global::System.Array.Copy((global::System.Array)array, j * 640, (global::System.Array)array2, (299 - j) * 640, 640);
			}
			if ((Object)(object)_tex == (Object)null)
			{
				_tex = new Texture2D(640, 300, (TextureFormat)4, false)
				{
					filterMode = (FilterMode)0,
					hideFlags = (HideFlags)32
				};
			}
			_tex.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array2));
			_tex.Apply(false, false);
			if ((Object)(object)_panel != (Object)null)
			{
				Object.Destroy((Object)(object)_panel);
			}
			_panel = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)_panel).name = "WigglesBW_Problems";
			Object.Destroy((Object)(object)_panel.GetComponent<Collider>());
			Object.DontDestroyOnLoad((Object)(object)_panel);
			_panel.transform.localScale = new Vector3(1.2f, 0.5625f, 1f);
			Vector3 val2 = Vector3.ProjectOnPlane(head.forward, Vector3.up);
			Vector3 val3 = ((Vector3)(ref val2)).normalized;
			if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
			{
				val3 = Vector3.forward;
			}
			_panel.transform.SetPositionAndRotation(head.position + val3 * 1.3f, Quaternion.LookRotation(val3));
			Material val4 = new Material(Shader.Find("UI/Default") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Universal Render Pipeline/Unlit"))
			{
				renderQueue = 4000
			};
			if (val4.HasProperty("_MainTex"))
			{
				val4.SetTexture("_MainTex", (Texture)(object)_tex);
			}
			if (val4.HasProperty("_BaseMap"))
			{
				val4.SetTexture("_BaseMap", (Texture)(object)_tex);
			}
			MeshRenderer component = _panel.GetComponent<MeshRenderer>();
			((Renderer)component).sharedMaterial = val4;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			_hideAt = Time.realtimeSinceStartup + 20f;
		}

		[IteratorStateMachine(typeof(<Wrap>d__19))]
		private static global::System.Collections.Generic.IEnumerable<string> Wrap(string text, int width)
		{
			string[] array = text.Split(' ', (StringSplitOptions)0);
			string text2 = "";
			string[] array2 = array;
			foreach (string w in array2)
			{
				if (text2.Length + w.Length + 1 > width && text2.Length > 0)
				{
					yield return text2;
					text2 = "";
				}
				text2 = ((text2.Length == 0) ? w : (text2 + " " + w));
			}
			if (text2.Length > 0)
			{
				yield return text2;
			}
		}

		internal static void CreatePage(Page parent)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_page = parent.CreatePage("Problems", new Color(1f, 0.3f, 0.3f), 0, true);
				RefreshPage();
			}
			catch
			{
			}
		}

		private static void RefreshPage()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00eb: 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_010f: Expected O, but got Unknown
			if (_page == null)
			{
				return;
			}
			try
			{
				_page.RemoveAll();
				if (_problems.Count == 0)
				{
					Page page = _page;
					Color green = Color.green;
					object obj = <>c.<>9__21_0;
					if (obj == null)
					{
						Action val = delegate
						{
						};
						<>c.<>9__21_0 = val;
						obj = (object)val;
					}
					page.CreateFunction("No problems found", green, (Action)obj);
					return;
				}
				Enumerator<ValueTuple<string, string>> enumerator = _problems.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						ValueTuple<string, string> current = enumerator.Current;
						string item = current.Item1;
						string item2 = current.Item2;
						Page page2 = _page;
						string text = "[" + item + "] " + item2;
						Color val2 = new Color(1f, 0.6f, 0.6f);
						object obj2 = <>c.<>9__21_2;
						if (obj2 == null)
						{
							Action val3 = delegate
							{
							};
							<>c.<>9__21_2 = val3;
							obj2 = (object)val3;
						}
						page2.CreateFunction(text, val2, (Action)obj2);
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
				Page page3 = _page;
				Color yellow = Color.yellow;
				object obj3 = <>c.<>9__21_1;
				if (obj3 == null)
				{
					Action val4 = delegate
					{
						_shownThisLevel = false;
						_pendingShow = true;
					};
					<>c.<>9__21_1 = val4;
					obj3 = (object)val4;
				}
				page3.CreateFunction("Show problem panel again", yellow, (Action)obj3);
			}
			catch
			{
			}
		}
	}
	internal static class Patches
	{
		private static Harmony _harmony;

		private const float FirstWait = 8f;

		private const float MaxCalmWait = 40f;

		private const float HitchSeconds = 0.12f;

		private static readonly List<ValueTuple<string, Action<Harmony>>> _queue = new List<ValueTuple<string, Action<Harmony>>>();

		private static readonly List<ValueTuple<string, Func<bool>, Action<Harmony>>> _later = new List<ValueTuple<string, Func<bool>, Action<Harmony>>>();

		private static readonly List<Func<bool>> _fireWanted = new List<Func<bool>>();

		private static readonly List<Func<bool>> _walkBlockers = new List<Func<bool>>();

		private static readonly List<Func<Gun, bool>> _fireFilters = new List<Func<Gun, bool>>();

		private static bool _walkQueued;

		private static bool _fireQueued;

		private static bool _crouchQueued;

		private static readonly List<Func<bool>> _crouchFreezers = new List<Func<bool>>();

		private static float _nextAt = -1f;

		private static float _inLevelSince;

		internal static bool Pending => _queue.Count > 0;

		internal static void Init(Harmony harmony)
		{
			_harmony = harmony;
		}

		internal static void Add(string id, Action<Harmony> apply)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (CrashGuard.IsOff("hook:" + id))
			{
				WigglesBW.Log.Warning("Hook \"" + id + "\" is off (it crashed the game before).");
			}
			else
			{
				_queue.Add(new ValueTuple<string, Action<Harmony>>(id, apply));
			}
		}

		internal static void AddWhen(string id, Func<bool> when, Action<Harmony> apply)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (CrashGuard.IsOff("hook:" + id))
			{
				WigglesBW.Log.Warning("Hook \"" + id + "\" is off (it crashed the game before).");
			}
			else
			{
				_later.Add(new ValueTuple<string, Func<bool>, Action<Harmony>>(id, when, apply));
			}
		}

		private static bool Any(List<Func<bool>> list)
		{
			for (int i = 0; i < list.Count; i++)
			{
				try
				{
					if (list[i].Invoke())
					{
						return true;
					}
				}
				catch
				{
				}
			}
			return false;
		}

		internal static void BlockWalkingWhile(Func<bool> blockWhen)
		{
			_walkBlockers.Add(blockWhen);
			if (!_walkQueued)
			{
				_walkQueued = true;
				AddWhen("walk-block", () => Any(_walkBlockers), delegate(Harmony h)
				{
					PatchPrefix(h, (MethodBase)(object)AccessTools.Method(typeof(ControllerRig), "GetPrimaryAxis", (global::System.Type[])null, (global::System.Type[])null), "WalkPrefix");
				});
			}
		}

		internal static void FreezeCrouchInputWhile(Func<bool> freezeWhen)
		{
			_crouchFreezers.Add(freezeWhen);
			if (!_crouchQueued)
			{
				_crouchQueued = true;
				AddWhen("crouch-input", () => Any(_crouchFreezers), delegate(Harmony h)
				{
					PatchPrefix(h, (MethodBase)(object)AccessTools.Method(typeof(RemapRig), "CrouchHold", (global::System.Type[])null, (global::System.Type[])null), "CrouchHoldPrefix");
				});
			}
		}

		private static void CrouchHoldPrefix(ref float crouchRate, ref bool crouchInput)
		{
			for (int i = 0; i < _crouchFreezers.Count; i++)
			{
				bool flag = false;
				try
				{
					flag = _crouchFreezers[i].Invoke();
				}
				catch
				{
				}
				if (flag)
				{
					crouchRate = 0f;
					crouchInput = false;
					break;
				}
			}
		}

		internal static void BeforeGunFire(Func<Gun, bool> allow, Func<bool> neededWhen)
		{
			_fireFilters.Add(allow);
			_fireWanted.Add(neededWhen);
			if (!_fireQueued)
			{
				_fireQueued = true;
				AddWhen("gun-fire", () => Any(_fireWanted), delegate(Harmony h)
				{
					PatchPrefix(h, (MethodBase)(object)AccessTools.Method(typeof(Gun), "Fire", (global::System.Type[])null, (global::System.Type[])null), "FirePrefix");
				});
			}
		}

		internal static void Prefix(string id, MethodBase target, global::System.Type holder, string method, Func<bool> when = null)
		{
			Action<Harmony> apply = delegate(Harmony h)
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Expected O, but got Unknown
				if (target != (MethodBase)null && !Refused(target))
				{
					h.Patch(target, new HarmonyMethod(holder.GetMethod(method, (BindingFlags)56)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			};
			if (when != null)
			{
				AddWhen(id, when, apply);
			}
			else
			{
				Add(id, apply);
			}
		}

		internal static void Postfix(string id, MethodBase target, global::System.Type holder, string method, Func<bool> when = null)
		{
			Action<Harmony> apply = delegate(Harmony h)
			{
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Expected O, but got Unknown
				if (target != (MethodBase)null && !Refused(target))
				{
					h.Patch(target, (HarmonyMethod)null, new HarmonyMethod(holder.GetMethod(method, (BindingFlags)56)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			};
			if (when != null)
			{
				AddWhen(id, when, apply);
			}
			else
			{
				Add(id, apply);
			}
		}

		private static HarmonyMethod Hook(string name)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return new HarmonyMethod(typeof(Patches).GetMethod(name, (BindingFlags)40));
		}

		private static void PatchPrefix(Harmony h, MethodBase target, string prefix)
		{
			if (target != (MethodBase)null && !Refused(target))
			{
				h.Patch(target, Hook(prefix), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		private static bool Refused(MethodBase target)
		{
			if (!TooSmallToHook(target))
			{
				return false;
			}
			global::System.Type declaringType = ((MemberInfo)target).DeclaringType;
			string text = ((declaringType != null) ? ((MemberInfo)declaringType).Name : null) + "." + ((MemberInfo)target).Name;
			WigglesBW.Log.Warning("Not hooking " + text + ": it's too small to hook safely on Quest.");
			Diagnostics.Report("Hooks", text + " is too small to hook safely, so the feature using it may not work. Everything else is fine.");
			return true;
		}

		private static bool TooSmallToHook(MethodBase target)
		{
			try
			{
				if (!HelperMethods.IsAndroid())
				{
					return false;
				}
				return EndsWithin12Bytes(target);
			}
			catch
			{
				return false;
			}
		}

		[MethodImpl((MethodImplOptions)8)]
		private static bool EndsWithin12Bytes(MethodBase target)
		{
			FieldInfo il2CppMethodInfoPointerFieldForGeneratedMethod = Il2CppInteropUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(target);
			if (il2CppMethodInfoPointerFieldForGeneratedMethod == (FieldInfo)null)
			{
				return false;
			}
			global::System.IntPtr intPtr = (global::System.IntPtr)il2CppMethodInfoPointerFieldForGeneratedMethod.GetValue((object)null);
			if (intPtr == global::System.IntPtr.Zero)
			{
				return false;
			}
			global::System.IntPtr intPtr2 = Marshal.ReadIntPtr(intPtr);
			if (intPtr2 == global::System.IntPtr.Zero)
			{
				return false;
			}
			for (int i = 0; i < 3; i++)
			{
				uint num = (uint)Marshal.ReadInt32(intPtr2, i * 4);
				if ((num & 0xFC000000u) == 335544320)
				{
					return true;
				}
				if ((num & 0xFFFFFC1Fu) == 3592355840u)
				{
					return true;
				}
				if ((num & 0xFFFFFC1Fu) == 3596550144u)
				{
					return true;
				}
			}
			return false;
		}

		private static bool WalkPrefix()
		{
			for (int i = 0; i < _walkBlockers.Count; i++)
			{
				try
				{
					if (_walkBlockers[i].Invoke())
					{
						return false;
					}
				}
				catch
				{
				}
			}
			return true;
		}

		private static bool FirePrefix(Gun __instance)
		{
			for (int i = 0; i < _fireFilters.Count; i++)
			{
				try
				{
					if (!_fireFilters[i].Invoke(__instance))
					{
						return false;
					}
				}
				catch
				{
				}
			}
			return true;
		}

		internal static void Update()
		{
			//IL_0102: 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_010f: 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)
			if ((_queue.Count == 0 && _later.Count == 0) || _harmony == null)
			{
				return;
			}
			if ((Object)(object)Player.Head == (Object)null)
			{
				_nextAt = -1f;
				return;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (_nextAt < 0f)
			{
				_nextAt = realtimeSinceStartup + 8f;
				_inLevelSince = realtimeSinceStartup;
			}
			else
			{
				if (realtimeSinceStartup < _nextAt)
				{
					return;
				}
				_nextAt = realtimeSinceStartup + 0.5f;
				if (Time.unscaledDeltaTime > 0.12f && realtimeSinceStartup - _inLevelSince < 40f)
				{
					return;
				}
				if (_queue.Count > 0)
				{
					ValueTuple<string, Action<Harmony>> val = _queue[0];
					string item = val.Item1;
					Action<Harmony> item2 = val.Item2;
					_queue.RemoveAt(0);
					CrashGuard.Stage("hook:" + item);
					Apply(item, item2);
					CrashGuard.Stage((_queue.Count == 0) ? "playing" : ("after hook:" + item));
					return;
				}
				for (int i = 0; i < _later.Count; i++)
				{
					ValueTuple<string, Func<bool>, Action<Harmony>> val2 = _later[i];
					string item3 = val2.Item1;
					Func<bool> item4 = val2.Item2;
					Action<Harmony> item5 = val2.Item3;
					bool flag = false;
					try
					{
						flag = item4.Invoke();
					}
					catch
					{
					}
					if (flag)
					{
						_later.RemoveAt(i);
						CrashGuard.LateHookStart(item3);
						Apply(item3, item5);
						CrashGuard.LateHookDone();
						break;
					}
				}
			}
		}

		private static void Apply(string id, Action<Harmony> apply)
		{
			WigglesBW.Step("hook " + id);
			try
			{
				apply.Invoke(_harmony);
				WigglesBW.Log.Msg("Hook ready: " + id);
			}
			catch (global::System.Exception ex)
			{
				WigglesBW.Log.Warning("Hook " + id + " failed: " + ex.Message);
				Diagnostics.Report("Hooks", $"\"{id}\" couldn't start ({((MemberInfo)ex.GetType()).Name}). That feature may not work; everything else is fine.");
			}
		}
	}
	internal static class Safe
	{
		internal static bool Finite(float f)
		{
			if (!float.IsNaN(f))
			{
				return !float.IsInfinity(f);
			}
			return false;
		}

		internal static bool Finite(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Finite(v.x) && Finite(v.y) && Finite(v.z))
			{
				return ((Vector3)(ref v)).sqrMagnitude < 1E+10f;
			}
			return false;
		}

		internal static void Prepare(params global::System.Type[] types)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			foreach (global::System.Type type in types)
			{
				MethodInfo[] methods = type.GetMethods((BindingFlags)62);
				foreach (MethodInfo val in methods)
				{
					if (!((MethodBase)val).IsAbstract && !((MethodBase)val).ContainsGenericParameters)
					{
						try
						{
							RuntimeHelpers.PrepareMethod(((MethodBase)val).MethodHandle);
						}
						catch
						{
						}
					}
				}
				Prepare(type.GetNestedTypes((BindingFlags)62));
			}
		}
	}
	public abstract class WigglesModule
	{
		public abstract string Name { get; }

		[field: CompilerGenerated]
		public Instance LoggerInstance
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			internal set;
		}

		[field: CompilerGenerated]
		public Harmony HarmonyInstance
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			internal set;
		}

		public static global::System.Collections.Generic.IReadOnlyList<MelonBase> RegisteredMelons => (global::System.Collections.Generic.IReadOnlyList<MelonBase>)MelonBase.RegisteredMelons;

		public virtual void OnInitializeMelon()
		{
		}

		public virtual void OnLateInitializeMelon()
		{
		}

		public virtual void OnUpdate()
		{
		}

		public virtual void OnFixedUpdate()
		{
		}

		public virtual void OnLateUpdate()
		{
		}
	}
	public class WigglesBW : MelonMod
	{
		internal static Instance Log;

		internal const string Title = "Timeline Colliders";

		internal const string Version = "1.7.0";

		private static Page _menu;

		private WigglesModule _clones;

		private bool _off;

		private bool _warned;

		internal static Page Menu => _menu ?? Page.Root;

		internal static void Step(string what)
		{
			try
			{
				Instance log = Log;
				if (log != null)
				{
					log.Msg("[startup] " + what);
				}
			}
			catch
			{
			}
		}

		public override void OnInitializeMelon()
		{
			Log = ((MelonBase)this).LoggerInstance;
			if (PackInstalled())
			{
				_off = true;
				Log.Warning("Wiggles BW is installed and already has this feature: Timeline Colliders stays off. You can delete TimelineColliders.dll.");
				return;
			}
			CrashGuard.Start(((MelonBase)this).Info.Version);
			Patches.Init(((MelonBase)this).HarmonyInstance);
			Diagnostics.CheckStartup((MelonMod)(object)this);
			try
			{
				Hooking.OnLevelLoading += delegate(LevelInfo info)
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					CrashGuard.NoteLevel("loading map " + info.title);
				};
				Hooking.OnLevelLoaded += delegate(LevelInfo info)
				{
					//IL_0005: Unknown result type (might be due to invalid IL or missing references)
					CrashGuard.NoteLevel("in map " + info.title);
					Diagnostics.OnLevelLoaded();
				};
			}
			catch (global::System.Exception ex)
			{
				Diagnostics.Report("BoneLib", "Couldn't hook level loading (BoneLib version?): " + ex.Message);
			}
			if (!CrashGuard.SafeMode.Value && !CrashGuard.IsOff("module:Timeline Clones"))
			{
				try
				{
					CrashGuard.Stage("module:Timeline Clones");
					_clones = new ClonesMod
					{
						LoggerInstance = ((MelonBase)this).LoggerInstance,
						HarmonyInstance = ((MelonBase)this).HarmonyInstance
					};
					_clones.OnInitializeMelon();
				}
				catch (global::System.Exception ex2)
				{
					_clones = null;
					Log.Error("Couldn't start: " + (object)ex2);
					Diagnostics.Report("Timeline Colliders", "Couldn't start: " + ex2.Message);
				}
				CrashGuard.Stage("starting");
			}
		}

		private bool PackInstalled()
		{
			try
			{
				if (Enumerable.Any<MelonMod>((global::System.Collections.Generic.IEnumerable<MelonMod>)MelonTypeBase<MelonMod>.RegisteredMelons, (Func<MelonMod, bool>)((MelonMod m) => ((MelonBase)m).Info.Name == "Wiggles BW")))
				{
					return true;
				}
				global::System.Collections.Generic.IEnumerator<MelonAssembly> enumerator = MelonAssembly.LoadedAssemblies.GetEnumerator();
				try
				{
					while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
					{
						global::System.Collections.Generic.IEnumerator<MelonBase> enumerator2 = enumerator.Current.LoadedMelons.GetEnumerator();
						try
						{
							while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
							{
								if (enumerator2.Current.Info.Name == "Wiggles BW")
								{
									return true;
								}
							}
						}
						finally
						{
							((global::System.IDisposable)enumerator2)?.Dispose();
						}
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator)?.Dispose();
				}
			}
			catch
			{
			}
			return false;
		}

		public override void OnLateInitializeMelon()
		{
			//IL_0023: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			if (_off)
			{
				return;
			}
			try
			{
				_menu = Page.Root.CreatePage("Timeline Colliders", new Color(0.9f, 0.25f, 0.2f), 0, true);
			}
			catch (global::System.Exception ex)
			{
				Log.Warning("Menu button failed, the pages go on the main menu: " + ex.Message);
			}
			try
			{
				_clones?.OnLateInitializeMelon();
			}
			catch (global::System.Exception ex2)
			{
				Log.Error("Couldn't finish starting: " + (object)ex2);
				Diagnostics.Report("Timeline Colliders", "Couldn't finish starting: " + ex2.Message);
			}
			CrashGuard.Stage("loading");
			Diagnostics.CreatePage(Menu);
			try
			{
				Menu.CreateBool("Safe Mode (next launch)", new Color(1f, 0.5f, 0.3f), CrashGuard.SafeMode.Value, (Action<bool>)CrashGuard.SetSafeMode);
				if (CrashGuard.AnyOff || CrashGuard.SafeMode.Value)
				{
					Menu.CreateFunction("Turn Everything Back On (next launch)", new Color(0.5f, 1f, 0.5f), new Action(CrashGuard.TurnEverythingBackOn));
				}
			}
			catch
			{
			}
		}

		private void Call(Action<WigglesModule> call)
		{
			if (_clones == null)
			{
				return;
			}
			try
			{
				call.Invoke(_clones);
			}
			catch (global::System.Exception ex)
			{
				if (!_warned)
				{
					_warned = true;
					Log.Error("Error while playing: " + (object)ex);
					Diagnostics.Report("Timeline Colliders", "Error while playing: " + ((MemberInfo)ex.GetType()).Name + ": " + ex.Message);
				}
			}
		}

		public override void OnUpdate()
		{
			if (_off)
			{
				return;
			}
			Call(delegate(WigglesModule m)
			{
				m.OnUpdate();
			});
			try
			{
				Patches.Update();
			}
			catch
			{
			}
			try
			{
				Diagnostics.Update();
			}
			catch
			{
			}
			try
			{
				CrashGuard.Update();
			}
			catch
			{
			}
		}

		public override void OnFixedUpdate()
		{
			if (!_off)
			{
				Call(delegate(WigglesModule m)
				{
					m.OnFixedUpdate();
				});
			}
		}

		public override void OnLateUpdate()
		{
			if (!_off)
			{
				Call(delegate(WigglesModule m)
				{
					m.OnLateUpdate();
				});
			}
		}

		public override void OnApplicationQuit()
		{
			try
			{
				if (!_off)
				{
					CrashGuard.CleanExit();
				}
			}
			catch
			{
			}
		}
	}
}
namespace TimelineClones
{
	internal static class BloodFx
	{
		private const int PoolSize = 64;

		private static Transform _root;

		private static ParticleSystem _drops;

		private static ParticleSystem _mist;

		private static Transform[] _pool;

		private static MeshRenderer[] _poolRenderers;

		private static int _next;

		private static Material[] _splatMats;

		private static Il2CppStructArray<RaycastHit> _hits;

		private static readonly Color Arterial = new Color(0.3f, 0.012f, 0.012f, 1f);

		private static readonly Color Venous = new Color(0.12f, 0.004f, 0.006f, 1f);

		internal static bool Replaying;

		internal static void EnsureBuilt()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0076: Expected O, but got Unknown
			//IL_0076: Expected O, but got Unknown
			//IL_008c: 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_00b9: 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_00ee: Expected O, but got Unknown
			//IL_00ee: Expected O, but got Unknown
			//IL_00ee: Expected O, but got Unknown
			if (!((Object)(object)_drops != (Object)null))
			{
				GameObject val = new GameObject("TimelineClones_Blood");
				Object.DontDestroyOnLoad((Object)val);
				_root = val.transform;
				_drops = MakeParticles("Droplets", 800, new MinMaxCurve(0.6f, 1.3f), new MinMaxCurve(0.006f, 0.022f), 1.6f, new MinMaxGradient(Venous, Arterial), Dot(16, 0.9f), stretch: true);
				_mist = MakeParticles("Mist", 120, new MinMaxCurve(0.12f, 0.3f), new MinMaxCurve(0.05f, 0.14f), 0.05f, new MinMaxGradient(new Color(0.28f, 0.02f, 0.02f, 0.35f), new Color(0.16f, 0.01f, 0.01f, 0.2f)), Dot(32, 0.5f), stretch: false);
				_splatMats = (Material[])(object)new Material[4];
				for (int i = 0; i < _splatMats.Length; i++)
				{
					_splatMats[i] = Unlit(SplatTexture(128, i), 3040);
				}
				_pool = (Transform[])(object)new Transform[64];
				_poolRenderers = (MeshRenderer[])(object)new MeshRenderer[64];
				for (int j = 0; j < 64; j++)
				{
					GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)5);
					((Object)val2).name = "BloodSplat";
					Object.Destroy((Object)(object)val2.GetComponent<Collider>());
					MeshRenderer component = val2.GetComponent<MeshRenderer>();
					((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
					((Renderer)component).receiveShadows = false;
					val2.transform.SetParent(_root, false);
					val2.SetActive(false);
					_pool[j] = val2.transform;
					_poolRenderers[j] = component;
				}
			}
		}

		internal static void Warm(Vector3 at)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00a6: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			EnsureBuilt();
			EmitParams val = default(EmitParams);
			((EmitParams)(ref val)).applyShapeToPosition = false;
			((EmitParams)(ref val)).position = at;
			((EmitParams)(ref val)).velocity = Vector3.zero;
			((EmitParams)(ref val)).startSize = 0.0005f;
			((EmitParams)(ref val)).startLifetime = 0.1f;
			EmitParams val2 = val;
			_drops.Emit(val2, 1);
			_mist.Emit(val2, 1);
			Material[] splatMats = _splatMats;
			foreach (Material sharedMaterial in splatMats)
			{
				GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5);
				Object.Destroy((Object)(object)obj.GetComponent<Collider>());
				((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = sharedMaterial;
				obj.transform.position = at;
				obj.transform.localScale = Vector3.one * 0.0005f;
				Object.Destroy((Object)(object)obj, 0.3f);
			}
			Replaying = true;
			try
			{
				Vector3 point = at + Vector3.down * 3000f;
				Hit(point, Vector3.down, Vector3.up, 1f);
				Stream(point, Vector3.down, 0.5f);
			}
			finally
			{
				Replaying = false;
			}
			if (CastSurface(at, Vector3.down, 5f, out var best))
			{
				PlaceSplat(best, Vector3.down, 0.0005f, 0);
				((Component)_pool[(_next + 64 - 1) % 64]).gameObject.SetActive(false);
			}
		}

		internal static void Stream(Vector3 point, Vector3 dir, float pressure)
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (ClonesMod.Blood.Value && !(pressure <= 0f))
			{
				if (!Replaying)
				{
					ClonesMod.OnBlood(point, dir, Vector3.up, 0f - pressure);
				}
				EmitStream(point, dir, pressure);
			}
		}

		private static void EmitStream(Vector3 point, Vector3 dir, float pressure)
		{
			//IL_0024: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			EnsureBuilt();
			pressure = Mathf.Clamp01(pressure);
			dir = ((((Vector3)(ref dir)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref dir)).normalized : Vector3.down);
			EmitParams val = default(EmitParams);
			((EmitParams)(ref val)).applyShapeToPosition = false;
			EmitParams val2 = val;
			int num = Mathf.Clamp(Mathf.RoundToInt((2f + 10f * pressure) * ClonesMod.BloodAmount.Value), 1, 24);
			float num2 = Mathf.Lerp(0.3f, 0.07f, pressure);
			for (int i = 0; i < num; i++)
			{
				((EmitParams)(ref val2)).position = point + Random.insideUnitSphere * 0.008f;
				Vector3 val3 = dir + Random.insideUnitSphere * num2;
				((EmitParams)(ref val2)).velocity = ((Vector3)(ref val3)).normalized * (Random.Range(2.6f, 4.2f) * pressure + 0.15f);
				((EmitParams)(ref val2)).startSize = Random.Range(0.007f, 0.02f) * (0.7f + pressure * 0.5f);
				_drops.Emit(val2, 1);
			}
			if (!(Random.value > 0.3f + pressure * 0.2f))
			{
				Vector3 val4 = Vector3.ProjectOnPlane(dir, Vector3.up) * (pressure * 1.1f);
				if (CastSurface(point + val4 + new Vector3(Random.Range(-0.06f, 0.06f), 0f, Random.Range(-0.06f, 0.06f)) + Vector3.up * 0.2f, Vector3.down, 3f, out var best))
				{
					PlaceSplat(best, Vector3.down, Random.Range(0.08f, 0.2f), (!(Random.value < 0.6f)) ? 3 : 0);
				}
			}
		}

		internal static void Hit(Vector3 point, Vector3 dir, Vector3 surfaceNormal, float amount)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_00db: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: 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_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)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: 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)
			if (amount > 0f)
			{
				try
				{
					Scars.Add(point, dir, surfaceNormal, amount);
				}
				catch
				{
				}
			}
			if (!ClonesMod.Blood.Value)
			{
				return;
			}
			if (amount < 0f)
			{
				EmitStream(point, dir, 0f - amount);
				return;
			}
			if (!Replaying)
			{
				ClonesMod.OnBlood(point, dir, surfaceNormal, amount);
			}
			EnsureBuilt();
			amount = Mathf.Clamp(amount * ClonesMod.BloodAmount.Value, 0.2f, 3f);
			dir = ((((Vector3)(ref dir)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref dir)).normalized : Vector3.down);
			Vector3 val = ((((Vector3)(ref surfaceNormal)).sqrMagnitude > 0.01f) ? ((Vector3)(ref surfaceNormal)).normalized : (-dir));
			EmitParams val2 = default(EmitParams);
			((EmitParams)(ref val2)).applyShapeToPosition = false;
			EmitParams val3 = val2;
			int num = Mathf.RoundToInt(22f * amount);
			Vector3 val4;
			for (int i = 0; i < num; i++)
			{
				bool flag = i % 4 == 0;
				val4 = (flag ? val : dir) + Random.insideUnitSphere * (flag ? 0.5f : 0.35f);
				Vector3 velocity = ((Vector3)(ref val4)).normalized * Random.Range(1.5f, flag ? 3f : 6f);
				((EmitParams)(ref val3)).position = point + Random.insideUnitSphere * 0.015f;
				((EmitParams)(ref val3)).velocity = velocity;
				((EmitParams)(ref val3)).startSize = Random.Range(0.006f, 0.022f) * (flag ? 0.8f : 1f);
				_drops.Emit(val3, 1);
			}
			val2 = default(EmitParams);
			((EmitParams)(ref val2)).applyShapeToPosition = false;
			EmitParams val5 = val2;
			int num2 = Mathf.RoundToInt(5f * amount);
			for (int j = 0; j < num2; j++)
			{
				((EmitParams)(ref val5)).position = point;
				((EmitParams)(ref val5)).velocity = (val * 0.6f + dir * 0.4f + Random.insideUnitSphere * 0.5f) * Random.Range(0.3f, 1.2f);
				_mist.Emit(val5, 1);
			}
			int num3 = Mathf.Clamp(Mathf.RoundToInt(3f * amount), 1, 6);
			for (int k = 0; k < num3; k++)
			{
				val4 = dir + Random.insideUnitSphere * ((k == 0) ? 0.05f : 0.3f);
				Vector3 normalized = ((Vector3)(ref val4)).normalized;
				if (CastSurface(point + normalized * 0.1f, normalized, 3f, out var best))
				{
					float size = ((k == 0) ? Random.Range(0.18f, 0.32f) : Random.Range(0.06f, 0.16f)) * Mathf.Sqrt(amount);
					PlaceSplat(best, normalized, size, (k != 0) ? 1 : Random.Range(0, 2));
				}
			}
			int num4 = Mathf.Clamp(Mathf.RoundToInt(2f * amount), 1, 4);
			for (int l = 0; l < num4; l++)
			{
				if (CastSurface(point + new Vector3(Random.Range(-0.25f, 0.25f), 0f, Random.Range(-0.25f, 0.25f)), Vector3.down, 3f, out var best2))
				{
					PlaceSplat(best2, Vector3.down, Random.Range(0.04f, 0.1f), 3);
				}
			}
		}

		internal static void Clear()
		{
			if (_pool == null)
			{
				return;
			}
			Transform[] pool = _pool;
			foreach (Transform val in pool)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
			if ((Object)(object)_drops != (Object)null)
			{
				_drops.Clear();
			}
			if ((Object)(object)_mist != (Object)null)
			{
				_mist.Clear();
			}
		}

		private static void PlaceSplat(RaycastHit hit, Vector3 travel, float size, int variant)
		{
			//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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_0151: 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_0157: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			int next = _next;
			_next = (_next + 1) % 64;
			Transform val = _pool[next];
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)5);
				((Object)val2).name = "BloodSplat";
				Object.Destroy((Object)(object)val2.GetComponent<Collider>());
				_poolRenderers[next] = val2.GetComponent<MeshRenderer>();
				((Renderer)_poolRenderers[next]).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)_poolRenderers[next]).receiveShadows = false;
				val = (_pool[next] = val2.transform);
			}
			Vector3 normal = ((RaycastHit)(ref hit)).normal;
			Vector3 val3 = Vector3.ProjectOnPlane(travel, normal);
			float magnitude = ((Vector3)(ref val3)).magnitude;
			bool flag = magnitude > 0.55f;
			if (flag)
			{
				variant = 2;
			}
			Rigidbody attachedRigidbody = ((RaycastHit)(ref hit)).collider.attachedRigidbody;
			val.SetParent(((Object)(object)attachedRigidbody != (Object)null) ? ((Component)((RaycastHit)(ref hit)).collider).transform : _root, true);
			((Component)val).gameObject.SetActive(true);
			((Renderer)_poolRenderers[next]).sharedMaterial = _splatMats[variant];
			val.position = ((RaycastHit)(ref hit)).point + normal * 0.004f;
			Vector3 val4;
			Vector3 normalized;
			if (!(magnitude > 0.05f))
			{
				val4 = Vector3.ProjectOnPlane(Random.onUnitSphere, normal);
				normalized = ((Vector3)(ref val4)).normalized;
			}
			else
			{
				normalized = ((Vector3)(ref val3)).normalized;
			}
			Vector3 val5 = normalized;
			if (((Vector3)(ref val5)).sqrMagnitude < 0.01f)
			{
				val4 = Vector3.ProjectOnPlane(Vector3.up, normal);
				val5 = ((Vector3)(ref val4)).normalized;
			}
			if (((Vector3)(ref val5)).sqrMagnitude < 0.01f)
			{
				val5 = Vector3.forward;
			}
			val.rotation = Quaternion.LookRotation(-normal, val5);
			float num = (flag ? Mathf.Lerp(1.6f, 3f, magnitude) : 1f);
			Vector3 val6 = (((Object)(object)val.parent != (Object)null) ? val.parent.lossyScale : Vector3.one);
			float num2 = 1f / Mathf.Max(Mathf.Abs(val6.x), 0.0001f);
			val.localScale = new Vector3(size * (flag ? 0.6f : 1f), size * num, 1f) * num2;
		}

		private static bool CastSurface(Vector3 origin, Vector3 dir, float dist, out RaycastHit best)
		{
			//IL_0001: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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)
			best = default(RaycastHit);
			if (_hits == null)
			{
				_hits = new Il2CppStructArray<RaycastHit>(12L);
			}
			int num = Physics.RaycastNonAlloc(origin, dir, _hits, dist, -5, (QueryTriggerInteraction)1);
			float num2 = 3.4028235E+38f;
			bool result = false;
			RigManager rigManager = Player.RigManager;
			for (int i = 0; i < num; i++)
			{
				RaycastHit val = ((Il2CppArrayBase<RaycastHit>)(object)_hits)[i];
				Collider collider = ((RaycastHit)(ref val)).collider;
				if (!((Object)(object)collider == (Object)null) && !(((RaycastHit)(ref val)).distance >= num2) && ((Component)collider).gameObject.layer != 12 && (!((Object)(object)rigManager != (Object)null) || !((Object)(object)((Component)collider).GetComponentInParent<RigManager>() == (Object)(object)rigManager)))
				{
					num2 = ((RaycastHit)(ref val)).distance;
					best = val;
					result = true;
				}
			}
			return result;
		}

		private static ParticleSystem MakeParticles(string name, int max, MinMaxCurve life, MinMaxCurve size, float gravity, MinMaxGradient color, Texture2D tex, bool stretch)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.transform.SetParent(_root, false);
			ParticleSystem obj = val.AddComponent<ParticleSystem>();
			obj.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = obj.main;
			main.loop = false;
			main.playOnAwake = false;
			main.maxParticles = max;
			main.simulationSpace = (ParticleSystemSimulationSpace)1;
			main.startLifetime = life;
			main.startSize = size;
			main.startSpeed = new MinMaxCurve(0f);
			main.gravityModifier = new MinMaxCurve(gravity);
			main.startColor = color;
			obj.emission.enabled = false;
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = Unlit(tex, 3050);
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			if (stretch)
			{
				component.renderMode = (ParticleSystemRenderMode)1;
				component.velocityScale = 0.035f;
				component.lengthScale = 1.2f;
			}
			return obj;
		}

		private static Material Unlit(Texture2D tex, int queue)
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(Shader.Find("UI/Default") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Universal Render Pipeline/Unlit"))
			{
				hideFlags = (HideFlags)32,
				renderQueue = queue
			};
			if (val.HasProperty("_MainTex"))
			{
				val.SetTexture("_MainTex", (Texture)(object)tex);
			}
			if (val.HasProperty("_BaseMap"))
			{
				val.SetTexture("_BaseMap", (Texture)(object)tex);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", Color.white);
			}
			return val;
		}

		private static Texture2D Dot(int size, float hardness)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			Color32[] array = (Color32[])(object)new Color32[size * size];
			float num = (float)(size - 1) * 0.5f;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num2 = Mathf.Sqrt(((float)j - num) * ((float)j - num) + ((float)i - num) * ((float)i - num)) / num;
					float num3 = Mathf.Clamp01((1f - num2) / Mathf.Max(1f - hardness, 0.05f));
					array[i * size + j] = new Color32((byte)255, (byte)255, (byte)255, (byte)(num3 * 255f));
				}
			}
			return Upload(array, size);
		}

		private static Texture2D SplatTexture(int size, int variant)
		{
			//IL_0115: 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_011a: 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_0127: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			Color32[] array = (Color32[])(object)new Color32[size * size];
			float num = (float)(size - 1) * 0.5f;
			uint seed = (uint)(9000 + variant * 7919);
			float[] array2 = new float[8];
			float[] array3 = new float[8];
			for (int i = 0; i < 8; i++)
			{
				array2[i] = (0.05f + Rand() * 0.07f) / (1f + (float)i * 0.6f);
				array3[i] = Rand() * (float)Math.PI * 2f;
			}
			Vector3[] array4 = (Vector3[])(object)new Vector3[variant switch
			{
				2 => 10, 
				1 => 18, 
				_ => 0, 
			}];
			for (int j = 0; j < array4.Length; j++)
			{
				float num2 = Rand() * (float)Math.PI * 2f;
				float num3 = 0.55f + Rand() * 0.4f;
				Vector2 val = ((variant == 2) ? new Vector2((Rand() - 0.5f) * 0.2f, 0.62f + Rand() * 0.33f) : new Vector2(Mathf.Cos(num2) * num3, Mathf.Sin(num2) * num3));
				array4[j] = new Vector3(val.x, val.y, 0.025f + Rand() * ((variant == 2) ? 0.05f : 0.06f));
			}
			for (int k = 0; k < size; k++)
			{
				for (int l = 0; l < size; l++)
				{
					float num4 = ((float)l - num) / num;
					float num5 = ((float)k - num) / num;
					float num13;
					if (variant == 2)
					{
						float num6 = Mathf.Atan2(num5 + 0.35f, num4);
						float num7 = 0.38f + 0.04f * Mathf.Sin(num6 * 3f + array3[0]) + 0.025f * Mathf.Sin(num6 * 7f + array3[1]);
						float num8 = Mathf.Sqrt(num4 * num4 + (num5 + 0.35f) * (num5 + 0.35f)) / num7;
						float num9 = Mathf.InverseLerp(-0.35f, 0.6f, num5);
						float num10 = Mathf.Lerp(0.3f, 0.015f, Mathf.Sqrt(num9));
						float num11 = 0.02f * Mathf.Sin(num5 * 9f + array3[2]);
						float num12 = ((num5 > -0.35f && num5 < 0.6f) ? (Mathf.Abs(num4 - num11) / num10) : 9f);
						num13 = Mathf.Clamp01((1f - Mathf.Min(num8, num12)) * 5f);
					}
					else
					{
						float num14 = Mathf.Sqrt(num4 * num4 + num5 * num5);
						float num15 = Mathf.Atan2(num5, num4);
						float num16 = variant switch
						{
							1 => 0.36f, 
							3 => 0.42f, 
							_ => 0.6f, 
						};
						for (int m = 0; m < 8; m++)
						{
							num16 += array2[m] * Mathf.Sin(num15 * (float)(m + 2) + array3[m]);
						}
						if (variant == 1)
						{
							num16 += 0.18f * Mathf.Pow(Mathf.Max(0f, Mathf.Sin(num15 * 3f + array3[3]) * Mathf.Sin(num15 * 5f + array3[4])), 6f);
						}
						num13 = Mathf.Clamp01((num16 - num14) * 12f);
					}
					Vector3[] array5 = array4;
					foreach (Vector3 val2 in array5)
					{
						float num17 = Mathf.Sqrt((num4 - val2.x) * (num4 - val2.x) + (num5 - val2.y) * (num5 - val2.y));
						num13 = Mathf.Max(num13, Mathf.Clamp01((val2.z - num17) * 60f));
					}
					float num18 = Mathf.Sqrt(num4 * num4 + num5 * num5);
					float num19 = Mathf.Clamp01(1f - num18 * 1.3f);
					float num20 = Mathf.PerlinNoise((float)l * 0.09f + (float)variant * 3f, (float)k * 0.09f);
					float num21 = Mathf.Lerp(34f, 80f, num19 * 0.7f + num20 * 0.3f);
					array[k * size + l] = new Color32((byte)num21, (byte)(num21 * 0.04f), (byte)(num21 * 0.04f), (byte)(num13 * 240f));
				}
			}
			return Upload(array, size);
			[CompilerGenerated]
			float Rand()
			{
				seed = seed * 1664525 + 1013904223;
				return (float)(seed >> 8) / 16777216f;
			}
		}

		private static Texture2D Upload(Color32[] px, int size)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, true)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1,
				hideFlags = (HideFlags)32
			};
			val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(px), 0);
			val.Apply(true, true);
			return val;
		}
	}
	public enum BonePart
	{
		LeftArm,
		RightArm,
		LeftLeg,
		RightLeg
	}
	internal static class BrokenBones
	{
		private class Entry
		{
			public Animator Anim;

			public int Part;

			public float Until;

			public float IgnoreUntil;

			public Transform Upper;

			public Vector3 JointLocal;

			public GoreKit.Cut Cut;

			public Rigidbody Anchor;

			public GameObject Shard;

			public Action<Collider> Ignore;
		}

		internal const int NetFlag = 32;

		private const float IgnoreFor = 2f;

		private const float TwistLimit = 60f;

		private const float SwingLimit = 150f;

		private static readonly List<Entry> _all = new List<Entry>();

		private static int _frame = -1;

		private static float _fixedAt = -1f;

		private static Mesh _shardMesh;

		private static Material _shardMat;

		internal static int PartOf(BonePart p)
		{
			return p switch
			{
				BonePart.LeftArm => 4, 
				BonePart.RightArm => 6, 
				BonePart.LeftLeg => 8, 
				_ => 10, 
			};
		}

		internal static int Lower(int part)
		{
			if (part % 2 != 1)
			{
				return part;
			}
			return part + 1;
		}

		internal static bool Has(Animator anim, int part)
		{
			//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)
			Enumerator<Entry> enumerator = _all.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Entry current = enumerator.Current;
					if ((Object)(object)current.Anim == (Object)(object)anim && current.Part == part)
					{
						return true;
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			return false;
		}

		internal static Action<Collider> IgnoreAll(Component root)
		{
			return delegate(Collider col)
			{
				if ((Object)(object)root == (Object)null || (Object)(object)col == (Object)null)
				{
					return;
				}
				global::System.Collections.Generic.IEnumerator<Collider> enumerator = root.GetComponentsInChildren<Collider>(false).GetEnumerator();
				try
				{
					while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
					{
						Collider current = enumerator.Current;
						if ((Object)(object)current != (Object)null)
						{
							Physics.IgnoreCollision(col, current, true);
						}
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator)?.Dispose();
				}
			};
		}

		private static HumanBodyBones EndOf(int part)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			return (HumanBodyBones)(part switch
			{
				4 => 17, 
				6 => 18, 
				8 => 5, 
				_ => 6, 
			});
		}

		internal static void Bend(Avatar avatar, int part, float seconds, ushort owner = 0, Action<Collider> ignore = null)
		{
			//IL_0061: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_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_00ea: 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_0112: 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_0140: 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_0129: 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_0137: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01a1: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: 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_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			Animator val = (((Object)(object)avatar != (Object)null) ? avatar.animator : null);
			if ((Object)(object)val == (Object)null || !val.isHuman || Has(val, part))
			{
				return;
			}
			Transform boneTransform = val.GetBoneTransform(RagdollDrag.Bones[part - 1]);
			Transform boneTransform2 = val.GetBoneTransform(RagdollDrag.Bones[part]);
			if ((Object)(object)boneTransform == (Object)null || (Object)(object)boneTransform2 == (Object)null)
			{
				return;
			}
			Transform boneTransform3 = val.GetBoneTransform(EndOf(part));
			Vector3 val2 = (((Object)(object)boneTransform3 != (Object)null) ? boneTransform3.position : (boneTransform2.position + (boneTransform2.position - boneTransform.position))) - boneTransform2.position;
			Vector3 val3;
			Vector3 normalized;
			if (!(((Vector3)(ref val2)).sqrMagnitude > 1E-08f))
			{
				val3 = boneTransform2.position - boneTransform.position;
				normalized = ((Vector3)(ref val3)).normalized;
			}
			else
			{
				normalized = ((Vector3)(ref val2)).normalized;
			}
			Vector3 val4 = normalized;
			val3 = boneTransform2.position - boneTransform.position;
			float num = Mathf.Clamp(((Vector3)(ref val3)).magnitude / 0.28f, 0.3f, 4f);
			Vector3 val5 = Vector3.ProjectOnPlane(Front(val), val4);
			Vector3 normalized2;
			if (!(((Vector3)(ref val5)).sqrMagnitude > 1E-08f))
			{
				val3 = Vector3.Cross(val4, Vector3.up);
				normalized2 = ((Vector3)(ref val3)).normalized;
			}
			else
			{
				normalized2 = ((Vector3)(ref val5)).normalized;
			}
			val5 = normalized2;
			Vector3 at = boneTransform2.position + val2 * 0.22f + val5 * (0.03f * num);
			val3 = val5 * 0.85f + val4 * 0.5f;
			Quaternion rotation = Quaternion.LookRotation(((Vector3)(ref val3)).normalized, val4);
			Entry entry

UserLibs/TimelineColliders.Timeline.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BoneLib;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Timeline;
using Timeline.Serialization.Binary;
using Timeline.Serialization.Registry;
using Timeline.WorldRecording;
using Timeline.WorldRecording.Extras.Visual;
using Timeline.WorldRecording.Recorders;
using Timeline.WorldRecording.Utils;
using UnityEngine;
using Wiggles;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: InternalsVisibleTo("TimelineColliders.Pack")]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("1.7.0.0")]
[module: UnverifiableCode]
namespace TimelineClones;

internal static class RagdollTimeline
{
	internal const byte RecorderId = 234;

	private static bool _wasRecording;

	private static RagdollRecorder _current;

	internal static readonly List<RagdollRecorder> Playing = new List<RagdollRecorder>();

	private static FieldInfo _voiceField;

	private static readonly Dictionary<ushort, float> LiveStarts = new Dictionary<ushort, float>();

	internal static float PlayHead => WorldPlayer.playHead;

	internal static void Install(Harmony harmony)
	{
		FieldInfo field = typeof(SerializableRegistry).GetField("recorderTypeRegistry", (BindingFlags)40);
		if (((field != null) ? field.GetValue((object)null) : null) is Dictionary<byte, global::System.Type> val)
		{
			val[(byte)234] = typeof(RagdollRecorder);
		}
		MethodInfo val2 = AccessTools.Method(typeof(RigmanagerRecorder), "Playback", (global::System.Type[])null, (global::System.Type[])null);
		Patches.Prefix("clones-ragdoll-playback", (MethodBase)(object)val2, typeof(RagdollTimeline), "PlaybackPrefix", (Func<bool>)null);
		CloneGuns.Install(harmony);
	}

	private static bool PlaybackPrefix(RigmanagerRecorder __instance)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			ushort recorderID = ((ObjectRecorder)__instance).recorderID;
			if (RagdollDrag.IsLive(recorderID))
			{
				return false;
			}
			float playHead = WorldPlayer.playHead;
			Enumerator<RagdollRecorder> enumerator = Playing.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					if (enumerator.Current.Owns(recorderID, playHead))
					{
						return false;
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
		}
		catch
		{
		}
		return true;
	}

	internal static void SetVoiceMuted(ushort id, bool muted)
	{
		WorldPlayer instance = WorldPlayer.Instance;
		if (instance == null)
		{
			return;
		}
		ObjectRecorder objectRecorder = instance.GetObjectRecorder(id);
		RigmanagerRecorder val = (RigmanagerRecorder)(object)((objectRecorder is RigmanagerRecorder) ? objectRecorder : null);
		if (val != null)
		{
			if (_voiceField == null)
			{
				_voiceField = typeof(RigmanagerRecorder).GetField("voiceSource", (BindingFlags)52);
			}
			FieldInfo voiceField = _voiceField;
			object obj = ((voiceField != null) ? voiceField.GetValue((object)val) : null);
			AudioSource val2 = (AudioSource)((obj is AudioSource) ? obj : null);
			if ((Object)(object)val2 != (Object)null && val2.mute != muted)
			{
				val2.mute = muted;
			}
		}
	}

	internal static bool IsRagdolled(ushort id)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		if (RagdollDrag.IsLive(id))
		{
			return true;
		}
		float playHead = WorldPlayer.playHead;
		Enumerator<RagdollRecorder> enumerator = Playing.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				if (enumerator.Current.Owns(id, playHead))
				{
					return true;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		return false;
	}

	internal static bool DeadInReplay(ushort id)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		float playHead = WorldPlayer.playHead;
		Enumerator<RagdollRecorder> enumerator = Playing.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				if (enumerator.Current.DeadBy(id, playHead))
				{
					return true;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		return false;
	}

	internal static void Tick()
	{
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		if (!WorldPlayer.recording)
		{
			_current = null;
			_wasRecording = false;
		}
		else
		{
			if (!_wasRecording)
			{
				_current = null;
			}
			_wasRecording = true;
			if (_current == null && RagdollDrag.LiveById.Count > 0)
			{
				WorldPlayer val = ((TimelineMainClass.timelineHolder != null) ? TimelineMainClass.timelineHolder.worldPlayer : WorldPlayer.Instance);
				if (val != null)
				{
					RagdollRecorder ragdollRecorder = new RagdollRecorder();
					((ObjectRecorder)ragdollRecorder).OnInitializedRecording((Object)null);
					((ObjectRecorder)ragdollRecorder).recording = true;
					((ObjectRecorder)ragdollRecorder).initTime = WorldPlayer.playHead;
					val.AddRecorderToRecord((ObjectRecorder)(object)ragdollRecorder);
					_current = ragdollRecorder;
				}
			}
		}
		if (LiveStarts.Count == 0 && RagdollDrag.LiveById.Count == 0)
		{
			return;
		}
		Enumerator<KeyValuePair<ushort, float>> enumerator = new List<KeyValuePair<ushort, float>>((global::System.Collections.Generic.IEnumerable<KeyValuePair<ushort, float>>)LiveStarts).GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				KeyValuePair<ushort, float> current = enumerator.Current;
				if (WorldPlayer.playHead < current.Value - 0.1f)
				{
					RagdollDrag.Revert(current.Key);
					LiveStarts.Remove(current.Key);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		Enumerator<ushort, Live> enumerator2 = RagdollDrag.LiveById.Keys.GetEnumerator();
		try
		{
			while (enumerator2.MoveNext())
			{
				ushort current2 = enumerator2.Current;
				if (!LiveStarts.ContainsKey(current2))
				{
					LiveStarts[current2] = WorldPlayer.playHead;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
		}
	}

	internal static void Clear()
	{
		LiveStarts.Clear();
	}
}
public class RagdollRecorder : ObjectRecorder
{
	private class Track
	{
		public readonly List<float> Times = new List<float>();

		public readonly List<Vector3> HipPos = new List<Vector3>();

		public readonly List<Quaternion> Rots = new List<Quaternion>();

		public float DeadAt = -1f;
	}

	private const int B = 11;

	private readonly Dictionary<ushort, Track> _tracks = new Dictionary<ushort, Track>();

	private float _lastCapture = -3.4028235E+38f;

	private readonly Transform[] _bones = (Transform[])(object)new Transform[11];

	public override byte SerializeableID => 234;

	public override string GetName()
	{
		return "Ragdoll Drags";
	}

	internal bool DeadBy(ushort id, float t)
	{
		Track track = default(Track);
		if (_tracks.TryGetValue(id, ref track) && track.DeadAt >= 0f)
		{
			return t >= track.DeadAt;
		}
		return false;
	}

	internal bool Owns(ushort id, float t)
	{
		Track track = default(Track);
		if (_tracks.TryGetValue(id, ref track) && track.Times.Count > 0)
		{
			return t >= track.Times[0];
		}
		return false;
	}

	public override void OnInitializedRecording(Object obj)
	{
		_tracks.Clear();
	}

	public override void Capture(float time)
	{
		//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_00c9: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		if (time - _lastCapture < 1f / 30f)
		{
			return;
		}
		_lastCapture = time;
		Enumerator<ushort, Live> enumerator = RagdollDrag.LiveById.Values.GetEnumerator();
		try
		{
			Track track = default(Track);
			while (enumerator.MoveNext())
			{
				Live current = enumerator.Current;
				if (!((Object)(object)current.T[0] == (Object)null))
				{
					if (!_tracks.TryGetValue(current.Id, ref track))
					{
						track = (_tracks[current.Id] = new Track());
					}
					if (track.DeadAt < 0f && current.Body != null && current.Body.Dead && current.Body.Hp <= 0.5f)
					{
						track.DeadAt = time;
					}
					track.Times.Add(time);
					track.HipPos.Add(current.T[0].position);
					track.Rots.Add(current.T[0].rotation);
					for (int i = 1; i < 11; i++)
					{
						track.Rots.Add(((Object)(object)current.T[i] != (Object)null) ? current.T[i].localRotation : Quaternion.identity);
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void OnRecordingCompleted()
	{
	}

	public override void OnInitializedPlayback()
	{
		if (!RagdollTimeline.Playing.Contains(this))
		{
			RagdollTimeline.Playing.Add(this);
		}
	}

	public override void Playback(float time)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		if (!RagdollTimeline.Playing.Contains(this))
		{
			RagdollTimeline.Playing.Add(this);
		}
		WorldPlayer instance = WorldPlayer.Instance;
		if (instance == null)
		{
			return;
		}
		Enumerator<ushort, Track> enumerator = _tracks.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				KeyValuePair<ushort, Track> current = enumerator.Current;
				Track value = current.Value;
				if (value.Times.Count == 0 || time < value.Times[0] || RagdollDrag.IsLive(current.Key))
				{
					continue;
				}
				ObjectRecorder objectRecorder = instance.GetObjectRecorder(current.Key);
				Avatar val = ((RigmanagerRecorder)(((objectRecorder is RigmanagerRecorder) ? objectRecorder : null)?)).currentPlaybackAvatar;
				Animator val2 = (((Object)(object)val != (Object)null) ? val.animator : null);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				for (int i = 0; i < 11; i++)
				{
					_bones[i] = val2.GetBoneTransform(RagdollDrag.Bones[i]);
				}
				if ((Object)(object)_bones[1] == (Object)null)
				{
					_bones[1] = val2.GetBoneTransform((HumanBodyBones)7);
				}
				if ((Object)(object)_bones[0] == (Object)null)
				{
					continue;
				}
				int num = 0;
				int num2 = value.Times.Count - 1;
				while (num < num2)
				{
					int num3 = (num + num2 + 1) / 2;
					if (value.Times[num3] <= time)
					{
						num = num3;
					}
					else
					{
						num2 = num3 - 1;
					}
				}
				int num4 = Mathf.Min(num + 1, value.Times.Count - 1);
				float num5 = ((num4 == num) ? 0f : Mathf.InverseLerp(value.Times[num], value.Times[num4], time));
				_bones[0].SetPositionAndRotation(Vector3.Lerp(value.HipPos[num], value.HipPos[num4], num5), Quaternion.Slerp(value.Rots[num * 11], value.Rots[num4 * 11], num5));
				for (int j = 1; j < 11; j++)
				{
					if ((Object)(object)_bones[j] != (Object)null)
					{
						_bones[j].localRotation = Quaternion.Slerp(value.Rots[num * 11 + j], value.Rots[num4 * 11 + j], num5);
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void OnPlaybackCompleted()
	{
		RagdollTimeline.Playing.Remove(this);
	}

	public override void OnHide(bool hide)
	{
	}

	public override int GetSize()
	{
		//IL_0014: 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)
		int num = ((ObjectRecorder)this).GetSize() + 4;
		Enumerator<ushort, Track> enumerator = _tracks.Values.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Track current = enumerator.Current;
				num += 10 + current.Times.Count * 192;
			}
			return num;
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void WriteToStream(BinaryStream s)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0084: 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)
		((ObjectRecorder)this).WriteToStream(s);
		s.WriteInt32(_tracks.Count);
		Enumerator<ushort, Track> enumerator = _tracks.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				KeyValuePair<ushort, Track> current = enumerator.Current;
				Track value = current.Value;
				s.WriteUInt16(current.Key);
				s.WriteInt32(-value.Times.Count - 1);
				s.WriteSingle(value.DeadAt);
				for (int i = 0; i < value.Times.Count; i++)
				{
					s.WriteSingle(value.Times[i]);
					s.WriteVector3(value.HipPos[i]);
					for (int j = 0; j < 11; j++)
					{
						s.WriteQuaternion(value.Rots[i * 11 + j]);
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void ReadFromStream(BinaryStream s)
	{
		//IL_0073: 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)
		((ObjectRecorder)this).ReadFromStream(s);
		_tracks.Clear();
		int num = s.ReadInt32();
		for (int i = 0; i < num; i++)
		{
			ushort num2 = s.ReadUInt16();
			Track track = new Track();
			int num3 = s.ReadInt32();
			bool flag = num3 >= 0;
			if (!flag)
			{
				num3 = -num3 - 1;
				track.DeadAt = s.ReadSingle();
			}
			for (int j = 0; j < num3; j++)
			{
				track.Times.Add(s.ReadSingle());
				track.HipPos.Add(s.ReadVector3());
				for (int k = 0; k < 11; k++)
				{
					track.Rots.Add(s.ReadQuaternion());
				}
			}
			if (flag && track.Times.Count > 0)
			{
				track.DeadAt = track.Times[0];
			}
			_tracks[num2] = track;
		}
	}
}
internal static class BloodTimeline
{
	internal const byte RecorderId = 238;

	private static bool _wasRecording;

	private static BloodRecorder _current;

	internal static void Register()
	{
		FieldInfo field = typeof(SerializableRegistry).GetField("recorderTypeRegistry", (BindingFlags)40);
		if (((field != null) ? field.GetValue((object)null) : null) is Dictionary<byte, global::System.Type> val)
		{
			val[(byte)238] = typeof(BloodRecorder);
		}
	}

	internal static void Tick()
	{
		if (!WorldPlayer.recording)
		{
			_current = null;
			_wasRecording = false;
			return;
		}
		if (!_wasRecording)
		{
			_current = null;
		}
		_wasRecording = true;
	}

	internal static void Record(Vector3 point, Vector3 dir, Vector3 normal, float amount)
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		if (!WorldPlayer.recording)
		{
			return;
		}
		if (_current == null)
		{
			WorldPlayer val = ((TimelineMainClass.timelineHolder != null) ? TimelineMainClass.timelineHolder.worldPlayer : WorldPlayer.Instance);
			if (val == null)
			{
				return;
			}
			Register();
			_current = new BloodRecorder();
			((ObjectRecorder)_current).OnInitializedRecording((Object)null);
			((ObjectRecorder)_current).recording = true;
			((ObjectRecorder)_current).initTime = WorldPlayer.playHead;
			val.AddRecorderToRecord((ObjectRecorder)(object)_current);
		}
		_current.Add(WorldPlayer.playHead, point, dir, normal, amount);
	}
}
public class BloodRecorder : ObjectRecorder
{
	private struct Hit
	{
		public float Time;

		public float Amount;

		public Vector3 Point;

		public Vector3 Dir;

		public Vector3 Normal;
	}

	private readonly List<Hit> _hits = new List<Hit>();

	private float _last = -3.4028235E+38f;

	private int _next;

	private const int MaxPerFrame = 4;

	public override byte SerializeableID => 238;

	public override string GetName()
	{
		return "Clone Blood";
	}

	internal void Add(float time, Vector3 p, Vector3 d, Vector3 n, float a)
	{
		//IL_00cc: 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_00d5: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		int num = _hits.Count - 1;
		if (a > 0f && num >= 0 && _hits[num].Amount > 0f && time - _hits[num].Time < 0.06f)
		{
			Vector3 val = _hits[num].Point - p;
			if (((Vector3)(ref val)).sqrMagnitude < 0.003f)
			{
				Hit hit = _hits[num];
				hit.Amount = Mathf.Min(hit.Amount + a * 0.5f, 3f);
				_hits[num] = hit;
				return;
			}
		}
		_hits.Add(new Hit
		{
			Time = time,
			Point = p,
			Dir = d,
			Normal = n,
			Amount = a
		});
	}

	public override void OnInitializedRecording(Object obj)
	{
		_hits.Clear();
	}

	public override void Capture(float time)
	{
	}

	public override void OnRecordingCompleted()
	{
		_hits.Sort((Comparison<Hit>)((Hit a, Hit b) => a.Time.CompareTo(b.Time)));
	}

	public override void OnInitializedPlayback()
	{
		_last = -3.4028235E+38f;
		_next = 0;
	}

	public override void Playback(float time)
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		if (_last == -3.4028235E+38f || time < _last || time - _last > 1f)
		{
			_last = time;
			_next = 0;
			while (_next < _hits.Count && _hits[_next].Time <= time)
			{
				_next++;
			}
			return;
		}
		int num = 0;
		while (_next < _hits.Count && _hits[_next].Time <= time)
		{
			Hit hit = _hits[_next++];
			if (!(hit.Time <= _last) && (!(hit.Amount > 0f) || num < 4))
			{
				num++;
				BloodFx.Replaying = true;
				try
				{
					BloodFx.Hit(hit.Point, hit.Dir, hit.Normal, hit.Amount);
				}
				finally
				{
					BloodFx.Replaying = false;
				}
			}
		}
		_last = time;
	}

	public override void OnPlaybackCompleted()
	{
		_last = -3.4028235E+38f;
	}

	public override void OnHide(bool hide)
	{
		if (hide)
		{
			_last = -3.4028235E+38f;
		}
	}

	public override int GetSize()
	{
		return ((ObjectRecorder)this).GetSize() + 4 + _hits.Count * 44;
	}

	public override void WriteToStream(BinaryStream s)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		((ObjectRecorder)this).WriteToStream(s);
		s.WriteInt32(_hits.Count);
		Enumerator<Hit> enumerator = _hits.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Hit current = enumerator.Current;
				s.WriteSingle(current.Time);
				s.WriteVector3(current.Point);
				s.WriteVector3(current.Dir);
				s.WriteVector3(current.Normal);
				s.WriteSingle(current.Amount);
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void ReadFromStream(BinaryStream s)
	{
		//IL_003b: 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_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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		((ObjectRecorder)this).ReadFromStream(s);
		_hits.Clear();
		int num = s.ReadInt32();
		for (int i = 0; i < num; i++)
		{
			_hits.Add(new Hit
			{
				Time = s.ReadSingle(),
				Point = s.ReadVector3(),
				Dir = s.ReadVector3(),
				Normal = s.ReadVector3(),
				Amount = s.ReadSingle()
			});
		}
		_hits.Sort((Comparison<Hit>)((Hit a, Hit b) => a.Time.CompareTo(b.Time)));
	}
}
internal static class VoiceTimeline
{
	internal const byte RecorderId = 243;

	private static bool _wasRecording;

	private static VoiceRecorder _current;

	internal static void Register()
	{
		FieldInfo field = typeof(SerializableRegistry).GetField("recorderTypeRegistry", (BindingFlags)40);
		if (((field != null) ? field.GetValue((object)null) : null) is Dictionary<byte, global::System.Type> val)
		{
			val[(byte)243] = typeof(VoiceRecorder);
		}
	}

	internal static void Tick()
	{
		if (!WorldPlayer.recording)
		{
			_current = null;
			_wasRecording = false;
			return;
		}
		if (!_wasRecording)
		{
			_current = null;
		}
		_wasRecording = true;
	}

	internal static void Record(Vector3 at, int clip, float pitch)
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		if (!WorldPlayer.recording)
		{
			return;
		}
		if (_current == null)
		{
			WorldPlayer val = ((TimelineMainClass.timelineHolder != null) ? TimelineMainClass.timelineHolder.worldPlayer : WorldPlayer.Instance);
			if (val == null)
			{
				return;
			}
			Register();
			_current = new VoiceRecorder();
			((ObjectRecorder)_current).OnInitializedRecording((Object)null);
			((ObjectRecorder)_current).recording = true;
			((ObjectRecorder)_current).initTime = WorldPlayer.playHead;
			val.AddRecorderToRecord((ObjectRecorder)(object)_current);
		}
		_current.Add(WorldPlayer.playHead, at, clip, pitch);
	}
}
public class VoiceRecorder : ObjectRecorder
{
	private struct Say
	{
		public float Time;

		public float Pitch;

		public int Clip;

		public Vector3 At;
	}

	private readonly List<Say> _says = new List<Say>();

	private float _last = -3.4028235E+38f;

	private int _next;

	public override byte SerializeableID => 243;

	public override string GetName()
	{
		return "Clone Voices";
	}

	internal void Add(float time, Vector3 at, int clip, float pitch)
	{
		//IL_0018: 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)
		_says.Add(new Say
		{
			Time = time,
			At = at,
			Clip = clip,
			Pitch = pitch
		});
	}

	public override void OnInitializedRecording(Object obj)
	{
		_says.Clear();
	}

	public override void Capture(float time)
	{
	}

	public override void OnRecordingCompleted()
	{
		_says.Sort((Comparison<Say>)((Say a, Say b) => a.Time.CompareTo(b.Time)));
	}

	public override void OnInitializedPlayback()
	{
		_last = -3.4028235E+38f;
		_next = 0;
	}

	public override void Playback(float time)
	{
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		if (_last == -3.4028235E+38f || time < _last || time - _last > 1f)
		{
			_last = time;
			_next = 0;
			while (_next < _says.Count && _says[_next].Time <= time)
			{
				_next++;
			}
			return;
		}
		while (_next < _says.Count && _says[_next].Time <= time)
		{
			Say say = _says[_next++];
			if (say.Time > _last)
			{
				GoreAudio.Replay(say.At, say.Clip, say.Pitch);
			}
		}
		_last = time;
	}

	public override void OnPlaybackCompleted()
	{
		_last = -3.4028235E+38f;
	}

	public override void OnHide(bool hide)
	{
		if (hide)
		{
			_last = -3.4028235E+38f;
		}
	}

	public override int GetSize()
	{
		return ((ObjectRecorder)this).GetSize() + 4 + _says.Count * 24;
	}

	public override void WriteToStream(BinaryStream s)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		((ObjectRecorder)this).WriteToStream(s);
		s.WriteInt32(_says.Count);
		Enumerator<Say> enumerator = _says.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Say current = enumerator.Current;
				s.WriteSingle(current.Time);
				s.WriteVector3(current.At);
				s.WriteInt32(current.Clip);
				s.WriteSingle(current.Pitch);
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void ReadFromStream(BinaryStream s)
	{
		//IL_003b: 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)
		((ObjectRecorder)this).ReadFromStream(s);
		_says.Clear();
		int num = s.ReadInt32();
		for (int i = 0; i < num; i++)
		{
			_says.Add(new Say
			{
				Time = s.ReadSingle(),
				At = s.ReadVector3(),
				Clip = s.ReadInt32(),
				Pitch = s.ReadSingle()
			});
		}
		_says.Sort((Comparison<Say>)((Say a, Say b) => a.Time.CompareTo(b.Time)));
	}
}
internal static class GoreTimeline
{
	internal const byte RecorderId = 242;

	private static bool _wasRecording;

	private static GoreRecorder _current;

	internal static void Register()
	{
		FieldInfo field = typeof(SerializableRegistry).GetField("recorderTypeRegistry", (BindingFlags)40);
		if (((field != null) ? field.GetValue((object)null) : null) is Dictionary<byte, global::System.Type> val)
		{
			val[(byte)242] = typeof(GoreRecorder);
		}
	}

	internal static void Tick()
	{
		if (!WorldPlayer.recording)
		{
			_current = null;
			_wasRecording = false;
			return;
		}
		if (!_wasRecording)
		{
			_current = null;
		}
		_wasRecording = true;
	}

	internal static void Record(ushort rig, int part, Vector3 velocity, Gib gib)
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		if (!WorldPlayer.recording)
		{
			return;
		}
		if (_current == null)
		{
			WorldPlayer val = ((TimelineMainClass.timelineHolder != null) ? TimelineMainClass.timelineHolder.worldPlayer : WorldPlayer.Instance);
			if (val == null)
			{
				return;
			}
			Register();
			_current = new GoreRecorder();
			((ObjectRecorder)_current).OnInitializedRecording((Object)null);
			((ObjectRecorder)_current).recording = true;
			((ObjectRecorder)_current).initTime = WorldPlayer.playHead;
			val.AddRecorderToRecord((ObjectRecorder)(object)_current);
		}
		_current.Add(WorldPlayer.playHead, rig, part, velocity, gib);
	}
}
public class GoreRecorder : ObjectRecorder
{
	private class Evt
	{
		public float Time;

		public ushort Rig;

		public byte Part;

		public Vector3 Velocity;

		public readonly List<float> T = new List<float>();

		public readonly List<Vector3> P = new List<Vector3>();

		public readonly List<Quaternion> R = new List<Quaternion>();

		public readonly List<Quaternion> Bend = new List<Quaternion>();

		public Gib Source;
	}

	private readonly List<Evt> _events = new List<Evt>();

	private bool _hidden;

	public override byte SerializeableID => 242;

	public override string GetName()
	{
		return "Clone Gore";
	}

	internal void Add(float time, ushort rig, int part, Vector3 velocity, Gib gib)
	{
		//IL_0022: 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)
		_events.Add(new Evt
		{
			Time = time,
			Rig = rig,
			Part = (byte)part,
			Velocity = velocity,
			Source = gib
		});
	}

	public override void OnInitializedRecording(Object obj)
	{
		_events.Clear();
	}

	public override void Capture(float time)
	{
		//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_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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)
		Enumerator<Evt> enumerator = _events.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Evt current = enumerator.Current;
				Gib source = current.Source;
				if (source != null && !((Object)(object)source.Go == (Object)null) && (!source.Rb.IsSleeping() || current.T.Count <= 0))
				{
					current.T.Add(time);
					current.P.Add(source.Root.position);
					current.R.Add(source.Root.rotation);
					current.Bend.Add(((Object)(object)source.Child != (Object)null) ? source.Child.rotation : Quaternion.identity);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void OnRecordingCompleted()
	{
		//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)
		Enumerator<Evt> enumerator = _events.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				enumerator.Current.Source = null;
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void OnInitializedPlayback()
	{
	}

	public override void Playback(float time)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		if (_hidden)
		{
			return;
		}
		Enumerator<Evt> enumerator = _events.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Evt current = enumerator.Current;
				if (current.Time > time)
				{
					continue;
				}
				CloneBody val = ClonesMod.BodyOf(current.Rig);
				if (val == null)
				{
					continue;
				}
				if (current.Part >= 32)
				{
					CloneBreak.Replay(val, current.Part - 32);
					continue;
				}
				Cut val2 = CloneGore.Find(val, (int)current.Part);
				if (val2 == null)
				{
					if (CloneGore.IsCut(val, (int)current.Part))
					{
						continue;
					}
					val2 = CloneGore.Replay(val, (int)current.Part, current.Velocity, current.Time, current.T.Count > 0, (object)current);
					if (val2 == null)
					{
						continue;
					}
				}
				if (val2.Owner == current && val2.Gib != null && (Object)(object)val2.Gib.Go != (Object)null && val2.Gib.Follows)
				{
					Follow(current, val2.Gib, time);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	private static void Follow(Evt e, Gib piece, float time)
	{
		//IL_0086: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: 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_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		int num = 0;
		int num2 = e.T.Count - 1;
		while (num < num2)
		{
			int num3 = (num + num2 + 1) / 2;
			if (e.T[num3] <= time)
			{
				num = num3;
			}
			else
			{
				num2 = num3 - 1;
			}
		}
		int num4 = Mathf.Min(num + 1, e.T.Count - 1);
		float num5 = ((num4 == num) ? 0f : Mathf.InverseLerp(e.T[num], e.T[num4], time));
		piece.Root.SetPositionAndRotation(Vector3.Lerp(e.P[num], e.P[num4], num5), Quaternion.Slerp(e.R[num], e.R[num4], num5));
		if ((Object)(object)piece.Child != (Object)null && e.Bend.Count > num4 && e.Bend[num].w != 1f)
		{
			piece.Child.rotation = Quaternion.Slerp(e.Bend[num], e.Bend[num4], num5);
		}
	}

	public override void OnPlaybackCompleted()
	{
	}

	public override void OnHide(bool hide)
	{
		//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)
		_hidden = hide;
		if (!hide)
		{
			return;
		}
		Enumerator<Evt> enumerator = _events.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				CloneGore.RestoreOwned((object)enumerator.Current);
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override int GetSize()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		int num = ((ObjectRecorder)this).GetSize() + 4;
		Enumerator<Evt> enumerator = _events.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Evt current = enumerator.Current;
				num += 23 + current.T.Count * 48;
			}
			return num;
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void WriteToStream(BinaryStream s)
	{
		//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_0058: 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_00a3: 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)
		((ObjectRecorder)this).WriteToStream(s);
		s.WriteInt32(-_events.Count);
		Enumerator<Evt> enumerator = _events.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Evt current = enumerator.Current;
				s.WriteSingle(current.Time);
				s.WriteUInt16(current.Rig);
				s.WriteByte(current.Part);
				s.WriteVector3(current.Velocity);
				s.WriteInt32(current.T.Count);
				for (int i = 0; i < current.T.Count; i++)
				{
					s.WriteSingle(current.T[i]);
					s.WriteVector3(current.P[i]);
					s.WriteQuaternion(current.R[i]);
					s.WriteQuaternion(current.Bend[i]);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	public override void ReadFromStream(BinaryStream s)
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: 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_00b2: 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)
		((ObjectRecorder)this).ReadFromStream(s);
		_events.Clear();
		int num = s.ReadInt32();
		bool flag = num < 0;
		if (flag)
		{
			num = -num;
		}
		for (int i = 0; i < num; i++)
		{
			Evt evt = new Evt
			{
				Time = s.ReadSingle(),
				Rig = s.ReadUInt16(),
				Part = s.ReadByte(),
				Velocity = s.ReadVector3()
			};
			int num2 = s.ReadInt32();
			for (int j = 0; j < num2; j++)
			{
				evt.T.Add(s.ReadSingle());
				evt.P.Add(s.ReadVector3());
				evt.R.Add(s.ReadQuaternion());
				evt.Bend.Add(flag ? s.ReadQuaternion() : Quaternion.identity);
			}
			_events.Add(evt);
		}
	}
}
internal static class CloneGuns
{
	private class Dropped
	{
		public MarrowEntityRecorder Rec;

		public GameObject Obj;

		public ushort Clone;

		public float Time;

		public bool Inner;

		public Transform Parent;

		public Vector3 LocalPos;

		public Quaternion LocalRot;

		public readonly List<MarrowBody> Created = new List<MarrowBody>();

		public readonly List<ValueTuple<Rigidbody, bool, bool>> Rbs = new List<ValueTuple<Rigidbody, bool, bool>>();

		public float FallSpeed;

		public float LastY;
	}

	private class Silenced
	{
		public ushort Clone;

		public Vector3 Pos;

		public float Time;

		public float From;
	}

	private class Loose
	{
		public GameObject Obj;

		public readonly List<Rigidbody> Rbs = new List<Rigidbody>();

		public float Until;

		public float FallSpeed;

		public float LastY;
	}

	private class Extra
	{
		public ushort Clone;

		public Transform T;

		public Transform Bone;

		public Vector3 Pos;

		public Quaternion Rot;
	}

	private static readonly List<Extra> _extras = new List<Extra>();

	private static FieldInfo _extrasField;

	private static readonly List<Dropped> _drops = new List<Dropped>();

	private static readonly HashSet<MarrowEntityRecorder> _dropped = new HashSet<MarrowEntityRecorder>();

	private static readonly HashSet<MarrowEntityRecorder> _suppressed = new HashSet<MarrowEntityRecorder>();

	private static readonly List<Silenced> _silenced = new List<Silenced>();

	private static readonly List<Loose> _loose = new List<Loose>();

	private static readonly HashSet<string> _seenSpawns = new HashSet<string>();

	private static Il2CppStructArray<RaycastHit> _hits;

	private static float _nextSweep;

	private static FieldInfo _playbackGun;

	private static bool _shotWarned;

	private static readonly List<CloneBody> _bodiesTmp = new List<CloneBody>();

	private static readonly Dictionary<int, bool> _isWeapon = new Dictionary<int, bool>();

	private const float LooseReach = 0.35f;

	internal static void Install(Harmony harmony)
	{
		global::System.Type typeFromHandle = typeof(CloneGuns);
		Prefix(AccessTools.Method(typeof(MarrowEntityRecorder), "Playback", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "SkipPlayback");
		MethodInfo val = AccessTools.Method(typeof(GunRecorder), "Playback", (global::System.Type[])null, (global::System.Type[])null);
		if (val != (MethodInfo)null && ((MemberInfo)val).DeclaringType == typeof(GunRecorder))
		{
			Prefix(val, typeFromHandle, "SkipPlayback");
		}
		Prefix(AccessTools.Method(typeof(ObjectRecorder), "CheckAndRunEvents", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "SkipEvents");
		Prefix(AccessTools.Method(typeof(MarrowEntityRecorder), "SetAllCaptureAnchors", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "SkipAnchor");
		Prefix(AccessTools.Method(typeof(SimpleSpawnRecorder), "OnInitializedPlayback", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "SkipSpawn");
		Prefix(AccessTools.Method(typeof(MarrowEntityRecorder), "OnInitializedPlayback", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "SkipEntitySpawn");
		Patches.Postfix("clones-spawn-physics", (MethodBase)(object)AccessTools.Method(typeof(SimpleSpawnRecorder), "AttemptModifyParticleSystem", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "SpawnPhysics", (Func<bool>)null);
		Patches.BeforeGunFire((Func<Gun, bool>)SkipFire, (Func<bool>)(() => _dropped.Count > 0));
		Patches.Postfix("clones-gun-shot", (MethodBase)(object)AccessTools.Method(typeof(GunRecorder), "PlayGunSFX", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "AfterShot", (Func<bool>)null);
	}

	private static void AfterShot(GunRecorder __instance)
	{
		try
		{
			if (_playbackGun == null)
			{
				_playbackGun = AccessTools.Field(typeof(GunRecorder), "playbackGun");
			}
			FieldInfo playbackGun = _playbackGun;
			object obj = ((playbackGun != null) ? playbackGun.GetValue((object)__instance) : null);
			Gun val = (Gun)((obj is Gun) ? obj : null);
			if (val != null)
			{
				CloneAttack.CloneFired(val);
			}
		}
		catch (global::System.Exception ex)
		{
			if (!_shotWarned)
			{
				_shotWarned = true;
				ClonesMod.Log.Warning("Clone shot: " + ex.Message);
			}
		}
	}

	private static void Prefix(MethodInfo target, global::System.Type holder, string method)
	{
		if (target == (MethodInfo)null)
		{
			ClonesMod.Log.Warning("Clone guns: missing " + method);
			return;
		}
		global::System.Type declaringType = ((MemberInfo)target).DeclaringType;
		Patches.Prefix("clones-" + ((declaringType != null) ? ((MemberInfo)declaringType).Name : null) + "." + ((MemberInfo)target).Name, (MethodBase)(object)target, holder, method, (Func<bool>)null);
	}

	private static bool IsDropped(ObjectRecorder r)
	{
		MarrowEntityRecorder val = (MarrowEntityRecorder)(object)((r is MarrowEntityRecorder) ? r : null);
		if (val != null)
		{
			if (!_dropped.Contains(val))
			{
				return _suppressed.Contains(val);
			}
			return true;
		}
		return false;
	}

	private static bool SkipPlayback(MarrowEntityRecorder __instance)
	{
		return !IsDropped((ObjectRecorder)(object)__instance);
	}

	private static bool SkipEvents(ObjectRecorder __instance)
	{
		return !IsDropped(__instance);
	}

	private static bool SkipAnchor(MarrowEntityRecorder __instance, Transform transform)
	{
		if (!((Object)(object)transform == (Object)null))
		{
			return !IsDropped((ObjectRecorder)(object)__instance);
		}
		return true;
	}

	private static bool Near(Vector3 p, Transform t, float r)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)t != (Object)null)
		{
			Vector3 val = p - t.position;
			return ((Vector3)(ref val)).sqrMagnitude < r * r;
		}
		return false;
	}

	private static bool SkipFire(Gun __instance)
	{
		if (_dropped.Count == 0 || (Object)(object)__instance == (Object)null)
		{
			return true;
		}
		try
		{
			GunRecorder r = default(GunRecorder);
			if (GunRecorder.TryGetRecorderFromCache(__instance, ref r) && IsDropped((ObjectRecorder)(object)r))
			{
				return false;
			}
		}
		catch
		{
		}
		return true;
	}

	private static bool FromDeadClone(ObjectRecorder rec)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		WorldPlayer instance = WorldPlayer.Instance;
		if (rec == null || instance == null)
		{
			return false;
		}
		float playHead = WorldPlayer.playHead;
		ClonesMod.CollectBodies(_bodiesTmp);
		Enumerator<CloneBody> enumerator = _bodiesTmp.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				CloneBody current = enumerator.Current;
				if (!current.GunsDown && !current.Dead && !RagdollTimeline.IsRagdolled(current.RecorderId))
				{
					continue;
				}
				float num = (current.GunsDown ? current.DownTime : playHead);
				if (!(rec.initTime < num - 0.05f))
				{
					if (rec.associatedRecorders != null && rec.associatedRecorders.Contains(current.RecorderId))
					{
						return true;
					}
					ObjectRecorder objectRecorder = instance.GetObjectRecorder(current.RecorderId);
					if (objectRecorder != null && objectRecorder.associatedRecorders != null && objectRecorder.associatedRecorders.Contains(rec.recorderID))
					{
						return true;
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		return false;
	}

	private static bool SkipEntitySpawn(MarrowEntityRecorder __instance)
	{
		try
		{
			if (__instance is GunRecorder || !FromDeadClone((ObjectRecorder)(object)__instance))
			{
				return true;
			}
			_suppressed.Add(__instance);
			return false;
		}
		catch
		{
			return true;
		}
	}

	private static bool SkipSpawn(SimpleSpawnRecorder __instance)
	{
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//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_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_00ec: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		if (__instance == null)
		{
			return true;
		}
		try
		{
			if (FromDeadClone((ObjectRecorder)(object)__instance))
			{
				return false;
			}
			string text = (((object)__instance.barcode)?.ToString() ?? "").ToLowerInvariant();
			if (text.Contains("blood") || text.Contains("gore") || text.Contains("wound") || text.Contains("decal") || text.Contains("splat") || text.Contains("impact") || text.Contains("flesh"))
			{
				return true;
			}
			float playHead = WorldPlayer.playHead;
			Vector3 position = __instance.position;
			ClonesMod.CollectBodies(_bodiesTmp);
			Enumerator<CloneBody> enumerator = _bodiesTmp.GetEnumerator();
			Vector3 val;
			try
			{
				while (enumerator.MoveNext())
				{
					CloneBody current = enumerator.Current;
					if (!current.GunsDown && !current.Dead && !RagdollTimeline.IsRagdolled(current.RecorderId))
					{
						continue;
					}
					if (!Near(position, current.HipsBone, 2f) && !Near(position, current.LeftHand, 1.2f) && !Near(position, current.RightHand, 1.2f))
					{
						if (!current.GunsDown)
						{
							continue;
						}
						val = position - current.DeathSpot;
						if (!(((Vector3)(ref val)).sqrMagnitude < 4f))
						{
							continue;
						}
					}
					return false;
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			if (_silenced.Count == 0)
			{
				return true;
			}
			Enumerator<Silenced> enumerator2 = _silenced.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					Silenced current2 = enumerator2.Current;
					if (!(playHead < current2.From - 0.05f))
					{
						float num = Mathf.Min(1.5f + 2.5f * Mathf.Max(0f, playHead - current2.Time), 6f);
						val = position - current2.Pos;
						if (!(((Vector3)(ref val)).sqrMagnitude > num * num))
						{
							current2.Pos = position;
							current2.Time = playHead;
							return false;
						}
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
			}
		}
		catch
		{
		}
		return true;
	}

	private static bool IsCasingLike(string id)
	{
		id = id.ToLowerInvariant();
		if (!id.Contains("casing") && !id.Contains("shell") && !id.Contains("brass") && !id.Contains("cartridge"))
		{
			return id.Contains("mag");
		}
		return true;
	}

	private static void SpawnPhysics(SimpleSpawnRecorder __instance, GameObject root)
	{
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: 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_010c: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)root == (Object)null)
		{
			return;
		}
		try
		{
			string text = ((__instance == null) ? "" : ((object)__instance.barcode)?.ToString()) + " " + ((Object)root).name;
			bool flag = IsCasingLike(text);
			if (_seenSpawns.Add(text))
			{
				ClonesMod.Log.Msg("Timeline replayed spawn: " + text + " -> " + (flag ? "falls" : "left as is"));
			}
			if (!flag)
			{
				return;
			}
			Loose loose = new Loose
			{
				Obj = root,
				Until = Time.time + 10f,
				LastY = root.transform.position.y
			};
			MakePhysical(root, null, loose.Rbs);
			Transform transform = root.transform;
			Vector3 velocity = transform.right * Random.Range(1.2f, 2f) + transform.up * Random.Range(0.6f, 1.2f);
			Enumerator<Rigidbody> enumerator = loose.Rbs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Rigidbody current = enumerator.Current;
					current.velocity = velocity;
					current.angularVelocity = Random.insideUnitSphere * 8f;
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			_loose.Add(loose);
		}
		catch
		{
		}
	}

	internal static void OnDeath(CloneBody body, global::System.Collections.Generic.IEnumerable<CloneBody> everyone)
	{
		//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_003c: 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_0041: Unknown result type (might be due to invalid IL or missing references)
		WorldPlayer instance = WorldPlayer.Instance;
		if (body == null || instance == null || instance.playbackRecorders == null)
		{
			return;
		}
		body.DeathSpot = (((Object)(object)body.HipsBone != (Object)null) ? body.HipsBone.position : ((Component)body.Avatar).transform.position);
		try
		{
			KeepExtrasOn(body, instance);
		}
		catch (global::System.Exception ex)
		{
			ClonesMod.Log.Warning("Holsters on a dead clone: " + ex.Message);
		}
		Transform[] hands = (Transform[])(object)new Transform[2] { body.LeftHand, body.RightHand };
		int num = 0;
		Enumerator<ObjectRecorder> enumerator = instance.playbackRecorders.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				ObjectRecorder current = enumerator.Current;
				MarrowEntityRecorder val = (MarrowEntityRecorder)(object)((current is MarrowEntityRecorder) ? current : null);
				if (val != null && !(current is ATVRecorder) && !IsDropped((ObjectRecorder)(object)val))
				{
					GameObject playbackObject = val.playbackObject;
					if (!((Object)(object)playbackObject == (Object)null) && playbackObject.activeInHierarchy && !((Object)(object)HeldBy(playbackObject, hands, body, everyone) == (Object)null))
					{
						num += Drop(val, playbackObject, body);
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		ClonesMod.Log.Msg($"Clone {body.RecorderId} went down: dropped {num} item(s)");
	}

	private static void KeepExtrasOn(CloneBody body, WorldPlayer player)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: 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_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		_extras.RemoveAll((Predicate<Extra>)((Extra e) => e.Clone == body.RecorderId));
		ObjectRecorder objectRecorder = player.GetObjectRecorder(body.RecorderId);
		RigmanagerExtrasTracker val = ((RigmanagerRecorder)(((objectRecorder is RigmanagerRecorder) ? objectRecorder : null)?)).rigmanagerExtrasTracker;
		if (val == null)
		{
			return;
		}
		if (_extrasField == null)
		{
			_extrasField = ((object)val).GetType().GetField("spawnedObjects", (BindingFlags)52);
		}
		FieldInfo extrasField = _extrasField;
		if (!(((extrasField != null) ? extrasField.GetValue((object)val) : null) is List<GameObject> val2))
		{
			return;
		}
		Enumerator<GameObject> enumerator = val2.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				GameObject current = enumerator.Current;
				if ((Object)(object)current == (Object)null)
				{
					continue;
				}
				Transform transform = current.transform;
				Transform hipsBone = body.HipsBone;
				Transform chestBone = body.ChestBone;
				object obj;
				if (!((Object)(object)hipsBone == (Object)null))
				{
					if (!((Object)(object)chestBone == (Object)null))
					{
						Vector3 val3 = transform.position - hipsBone.position;
						float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
						val3 = transform.position - chestBone.position;
						obj = ((sqrMagnitude <= ((Vector3)(ref val3)).sqrMagnitude) ? hipsBone : chestBone);
					}
					else
					{
						obj = hipsBone;
					}
				}
				else
				{
					obj = chestBone;
				}
				Transform val4 = (Transform)obj;
				if (!((Object)(object)val4 == (Object)null))
				{
					_extras.Add(new Extra
					{
						Clone = body.RecorderId,
						T = transform,
						Bone = val4,
						Pos = val4.InverseTransformPoint(transform.position),
						Rot = Quaternion.Inverse(val4.rotation) * transform.rotation
					});
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	internal static void LateTick()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: 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)
		for (int num = _extras.Count - 1; num >= 0; num--)
		{
			Extra extra = _extras[num];
			if ((Object)(object)extra.T == (Object)null || (Object)(object)extra.Bone == (Object)null)
			{
				_extras.RemoveAt(num);
			}
			else
			{
				extra.T.SetPositionAndRotation(extra.Bone.TransformPoint(extra.Pos), extra.Bone.rotation * extra.Rot);
			}
		}
	}

	internal static void Sweep(global::System.Collections.Generic.IEnumerable<CloneBody> everyone)
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: 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_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)
		if (Time.unscaledTime < _nextSweep)
		{
			return;
		}
		_nextSweep = Time.unscaledTime + 0.25f;
		WorldPlayer instance = WorldPlayer.Instance;
		if (instance == null || instance.playbackRecorders == null)
		{
			return;
		}
		float playHead = WorldPlayer.playHead;
		global::System.Collections.Generic.IEnumerator<CloneBody> enumerator = everyone.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				CloneBody current = enumerator.Current;
				if (current == null || !current.GunsDown || playHead - current.DownTime > 3f || playHead < current.DownTime - 0.1f)
				{
					continue;
				}
				Enumerator<ObjectRecorder> enumerator2 = instance.playbackRecorders.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						ObjectRecorder current2 = enumerator2.Current;
						MarrowEntityRecorder val = (MarrowEntityRecorder)(object)((current2 is MarrowEntityRecorder) ? current2 : null);
						if (val == null || current2 is ATVRecorder || IsDropped((ObjectRecorder)(object)val))
						{
							continue;
						}
						GameObject playbackObject = val.playbackObject;
						if (!((Object)(object)playbackObject == (Object)null) && playbackObject.activeInHierarchy && !((Object)(object)playbackObject.transform.parent != (Object)null) && IsWeapon(playbackObject))
						{
							Vector3 val2 = playbackObject.transform.position - current.DeathSpot;
							if (!(((Vector3)(ref val2)).sqrMagnitude > 9f) && !NearLivingHand(playbackObject, everyone, 0.6f) && Drop(val, playbackObject, current) > 0)
							{
								ClonesMod.Log.Msg($"Clone {current.RecorderId}: dropped a loose {((Object)playbackObject).name} near its body");
							}
						}
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}

	private static bool IsWeapon(GameObject obj)
	{
		int instanceID = ((Object)obj).GetInstanceID();
		bool result = default(bool);
		if (_isWeapon.TryGetValue(instanceID, ref result))
		{
			return result;
		}
		result = (Object)(object)obj.GetComponentInChildren<Gun>() != (Object)null || (Object)(object)obj.GetComponentInChildren<Magazine>() != (Object)null;
		if (_isWeapon.Count > 2048)
		{
			_isWeapon.Clear();
		}
		_isWeapon[instanceID] = result;
		return result;
	}

	private static int Drop(MarrowEntityRecorder rec, GameObject obj, CloneBody body)
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_01a2: 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_0237: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = obj.transform;
		Dropped dropped = new Dropped
		{
			Rec = rec,
			Obj = obj,
			Clone = body.RecorderId,
			Time = WorldPlayer.playHead,
			Parent = transform.parent,
			LocalPos = transform.localPosition,
			LocalRot = transform.localRotation,
			LastY = transform.position.y
		};
		transform.SetParent((Transform)null, true);
		MakePhysical(obj, dropped.Created, null, dropped.Rbs);
		_drops.Add(dropped);
		_dropped.Add(rec);
		Gun componentInChildren = obj.GetComponentInChildren<Gun>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			Transform val = (((Object)(object)componentInChildren.firePointTransform != (Object)null) ? componentInChildren.firePointTransform : transform);
			_silenced.Add(new Silenced
			{
				Clone = body.RecorderId,
				Pos = val.position,
				Time = dropped.Time,
				From = dropped.Time
			});
		}
		ClonesMod.Log.Msg($"  dropped {((Object)obj).name} ({dropped.Rbs.Count} body/bodies, {dropped.Created.Count} woken up)");
		int num = 1;
		WorldPlayer instance = WorldPlayer.Instance;
		if (instance == null || instance.playbackRecorders == null)
		{
			return num;
		}
		Enumerator<ObjectRecorder> enumerator = instance.playbackRecorders.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				ObjectRecorder current = enumerator.Current;
				MarrowEntityRecorder val2 = (MarrowEntityRecorder)(object)((current is MarrowEntityRecorder) ? current : null);
				if (val2 != null && !IsDropped((ObjectRecorder)(object)val2))
				{
					GameObject playbackObject = val2.playbackObject;
					if (!((Object)(object)playbackObject == (Object)null) && !((Object)(object)playbackObject == (Object)(object)obj) && playbackObject.transform.IsChildOf(transform))
					{
						_drops.Add(new Dropped
						{
							Rec = val2,
							Obj = playbackObject,
							Clone = body.RecorderId,
							Time = dropped.Time,
							Inner = true,
							LastY = playbackObject.transform.position.y
						});
						_dropped.Add(val2);
						num++;
					}
				}
			}
			return num;
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	private static void MakePhysical(GameObject obj, List<MarrowBody> created, List<Rigidbody> rbsOut, List<ValueTuple<Rigidbody, bool, bool>> states = null)
	{
		//IL_00cc: 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_010f: 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)
		HashSet<int> val = new HashSet<int>();
		MarrowEntity val2 = obj.GetComponentInChildren<MarrowEntity>() ?? obj.GetComponentInParent<MarrowEntity>();
		if ((Object)(object)val2 != (Object)null)
		{
			Il2CppReferenceArray<MarrowBody> val3 = null;
			try
			{
				val3 = val2.Bodies;
			}
			catch
			{
			}
			if (val3 != null)
			{
				global::System.Collections.Generic.IEnumerator<MarrowBody> enumerator = ((Il2CppArrayBase<MarrowBody>)(object)val3).GetEnumerator();
				try
				{
					while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
					{
						MarrowBody current = enumerator.Current;
						if ((Object)(object)current == (Object)null)
						{
							continue;
						}
						try
						{
							if (!current.HasRigidbody)
							{
								current.CreateRigidbody();
								created?.Add(current);
							}
						}
						catch
						{
						}
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator)?.Dispose();
				}
			}
		}
		global::System.Collections.Generic.IEnumerator<Rigidbody> enumerator2 = obj.GetComponentsInChildren<Rigidbody>().GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
			{
				Rigidbody current2 = enumerator2.Current;
				if (!((Object)(object)current2 == (Object)null) && val.Add(((Object)current2).GetInstanceID()))
				{
					states?.Add(new ValueTuple<Rigidbody, bool, bool>(current2, current2.isKinematic, current2.useGravity));
					rbsOut?.Add(current2);
					current2.isKinematic = false;
					current2.useGravity = true;
					current2.constraints = (RigidbodyConstraints)0;
					current2.detectCollisions = true;
					current2.velocity = Vector3.zero;
					current2.angularVelocity = Random.insideUnitSphere * 1.5f;
					current2.WakeUp();
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator2)?.Dispose();
		}
	}

	internal static void Maintain()
	{
		if (_drops.Count == 0 && _suppressed.Count == 0 && _silenced.Count == 0)
		{
			return;
		}
		float now = WorldPlayer.playHead;
		for (int num = _drops.Count - 1; num >= 0; num--)
		{
			Dropped dropped = _drops[num];
			if (dropped.Rec == null || (Object)(object)dropped.Obj == (Object)null || (Object)(object)dropped.Rec.playbackObject != (Object)(object)dropped.Obj || now < dropped.Time - 0.05f)
			{
				Undrop(dropped);
				_drops.RemoveAt(num);
			}
			else if (!dropped.Inner && (Object)(object)dropped.Obj.transform.parent != (Object)null)
			{
				dropped.Obj.transform.SetParent((Transform)null, true);
			}
		}
		_suppressed.RemoveWhere((Predicate<MarrowEntityRecorder>)((MarrowEntityRecorder r) => r == null || now < ((ObjectRecorder)r).initTime - 0.02f));
		if (now < 0.05f)
		{
			_silenced.Clear();
			return;
		}
		_silenced.RemoveAll((Predicate<Silenced>)((Silenced s) => now < s.From - 0.05f));
	}

	internal static void FixedTick(float dt)
	{
		//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_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		Enumerator<Dropped> enumerator = _drops.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Dropped current = enumerator.Current;
				if (current.Inner || (Object)(object)current.Obj == (Object)null)
				{
					continue;
				}
				Enumerator<ValueTuple<Rigidbody, bool, bool>> enumerator2 = current.Rbs.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						Rigidbody item = enumerator2.Current.Item1;
						if ((Object)(object)item != (Object)null && item.isKinematic)
						{
							item.isKinematic = false;
							item.useGravity = true;
							item.WakeUp();
						}
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
				}
				Settle(current.Obj, current.Rbs, ref current.FallSpeed, ref current.LastY, dt);
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		for (int num = _loose.Count - 1; num >= 0; num--)
		{
			Loose loose = _loose[num];
			if ((Object)(object)loose.Obj == (Object)null || Time.time > loose.Until)
			{
				_loose.RemoveAt(num);
			}
			else
			{
				Settle(loose.Obj, loose.Rbs, ref loose.FallSpeed, ref loose.LastY, dt);
			}
		}
	}

	private static void Settle(GameObject obj, List<ValueTuple<Rigidbody, bool, bool>> rbs, ref float speed, ref float lastY, float dt)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		List<Rigidbody> val = new List<Rigidbody>(rbs.Count);
		Enumerator<ValueTuple<Rigidbody, bool, bool>> enumerator = rbs.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Rigidbody item = enumerator.Current.Item1;
				if ((Object)(object)item != (Object)null)
				{
					val.Add(item);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		Settle(obj, val, ref speed, ref lastY, dt);
	}

	private static void Settle(GameObject obj, List<Rigidbody> rbs, ref float speed, ref float lastY, float dt)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: 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_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: 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_00a5: 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_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		Rigidbody val = null;
		Enumerator<Rigidbody> enumerator = rbs.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Rigidbody current = enumerator.Current;
				if ((Object)(object)current != (Object)null)
				{
					val = current;
					break;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		float num = (((Object)(object)val != (Object)null) ? val.position.y : obj.transform.position.y);
		bool num2 = lastY - num > 0.002f;
		lastY = num;
		if (num2)
		{
			speed = 0f;
			return;
		}
		float num3 = GapBelow(obj);
		if (num3 <= 0.01f)
		{
			speed = 0f;
		}
		else
		{
			if ((Object)(object)val != (Object)null && !val.isKinematic && val.velocity.y < -0.05f)
			{
				return;
			}
			speed = Mathf.Min(speed + 9.81f * dt, 20f);
			Vector3 val2 = Vector3.down * Mathf.Min(speed * dt, num3);
			if ((Object)(object)val != (Object)null)
			{
				enumerator = rbs.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						Rigidbody current2 = enumerator.Current;
						if (!((Object)(object)current2 == (Object)null))
						{
							if (current2.isKinematic)
							{
								current2.MovePosition(current2.position + val2);
							}
							else
							{
								current2.position += val2;
							}
						}
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
				lastY = val.position.y;
			}
			else
			{
				Transform transform = obj.transform;
				transform.position += val2;
				lastY = obj.transform.position.y;
			}
		}
	}

	private static float GapBelow(GameObject obj)
	{
		//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_004d: 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_0101: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = obj.transform;
		float num = 3.4028235E+38f;
		global::System.Collections.Generic.IEnumerator<Collider> enumerator = obj.GetComponentsInChildren<Collider>().GetEnumerator();
		Bounds bounds;
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Collider current = enumerator.Current;
				if ((Object)(object)current != (Object)null && current.enabled && !current.isTrigger)
				{
					float num2 = num;
					bounds = current.bounds;
					num = Mathf.Min(num2, ((Bounds)(ref bounds)).min.y);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
		if (num == 3.4028235E+38f)
		{
			global::System.Collections.Generic.IEnumerator<Renderer> enumerator2 = obj.GetComponentsInChildren<Renderer>().GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
				{
					Renderer current2 = enumerator2.Current;
					if ((Object)(object)current2 != (Object)null && current2.enabled)
					{
						float num3 = num;
						bounds = current2.bounds;
						num = Mathf.Min(num3, ((Bounds)(ref bounds)).min.y);
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator2)?.Dispose();
			}
		}
		if (num == 3.4028235E+38f)
		{
			num = transform.position.y;
		}
		Vector3 val = new Vector3(transform.position.x, num + 0.05f, transform.position.z);
		if (_hits == null)
		{
			_hits = new Il2CppStructArray<RaycastHit>(16L);
		}
		int num4 = Physics.RaycastNonAlloc(val, Vector3.down, _hits, 60f, -5, (QueryTriggerInteraction)1);
		float num5 = 60f;
		for (int i = 0; i < num4; i++)
		{
			RaycastHit val2 = ((Il2CppArrayBase<RaycastHit>)(object)_hits)[i];
			if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(transform))
			{
				Rigidbody attachedRigidbody = ((RaycastHit)(ref val2)).collider.attachedRigidbody;
				if (!((Object)(object)attachedRigidbody != (Object)null) || !((Component)attachedRigidbody).transform.IsChildOf(transform))
				{
					num5 = Mathf.Min(num5, ((RaycastHit)(ref val2)).distance);
				}
			}
		}
		if (!(num5 >= 60f))
		{
			return Mathf.Max(0f, num5 - 0.05f);
		}
		return 0f;
	}

	private static void Undrop(Dropped d)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_0136: 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_0066: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
		if (d.Rec != null)
		{
			_dropped.Remove(d.Rec);
		}
		if ((Object)(object)d.Obj == (Object)null)
		{
			return;
		}
		Enumerator<ValueTuple<Rigidbody, bool, bool>> enumerator = d.Rbs.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				ValueTuple<Rigidbody, bool, bool> current = enumerator.Current;
				Rigidbody item = current.Item1;
				bool item2 = current.Item2;
				bool item3 = current.Item3;
				if (!((Object)(object)item == (Object)null))
				{
					item.velocity = Vector3.zero;
					item.angularVelocity = Vector3.zero;
					item.isKinematic = item2;
					item.useGravity = item3;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		Enumerator<MarrowBody> enumerator2 = d.Created.GetEnumerator();
		try
		{
			while (enumerator2.MoveNext())
			{
				MarrowBody current2 = enumerator2.Current;
				try
				{
					if ((Object)(object)current2 != (Object)null && current2.HasRigidbody)
					{
						current2.DestroyRigidbody();
					}
				}
				catch
				{
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
		}
		if ((Object)(object)d.Parent != (Object)null && !d.Inner)
		{
			d.Obj.transform.SetParent(d.Parent, false);
			d.Obj.transform.localPosition = d.LocalPos;
			d.Obj.transform.localRotation = d.LocalRot;
		}
	}

	internal static bool WasDropped(GameObject obj)
	{
		//IL_0010: 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)
		if ((Object)(object)obj == (Object)null)
		{
			return false;
		}
		Enumerator<Dropped> enumerator = _drops.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Dropped current = enumerator.Current;
				if (!current.Inner && (Object)(object)current.Obj != (Object)null && (Object)(object)current.Obj == (Object)(object)obj)
				{
					return true;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		return false;
	}

	internal static void OnRevive(CloneBody body)
	{
		if (body == null)
		{
			return;
		}
		_extras.RemoveAll((Predicate<Extra>)((Extra e) => e.Clone == body.RecorderId));
		for (int num = _drops.Count - 1; num >= 0; num--)
		{
			if (_drops[num].Clone == body.RecorderId)
			{
				Undrop(_drops[num]);
				_drops.RemoveAt(num);
			}
		}
		_silenced.RemoveAll((Predicate<Silenced>)((Silenced s) => s.Clone == body.RecorderId));
	}

	internal static void Clear()
	{
		//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)
		Enumerator<Dropped> enumerator = _drops.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Undrop(enumerator.Current);
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		_drops.Clear();
		_dropped.Clear();
		_suppressed.Clear();
		_silenced.Clear();
		_loose.Clear();
		_extras.Clear();
	}

	private static Transform HeldBy(GameObject obj, Transform[] hands, CloneBody body, global::System.Collections.Generic.IEnumerable<CloneBody> everyone)
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = obj.transform;
		Transform[] array = hands;
		foreach (Transform val in array)
		{
			if ((Object)(object)val != (Object)null && (Object)(object)transform.parent != (Object)null && transform.IsChildOf(val))
			{
				return val;
			}
		}
		if ((Object)(object)transform.parent != (Object)null)
		{
			return null;
		}
		Transform val2 = null;
		float num = 0.35f;
		array = hands;
		foreach (Transform val3 in array)
		{
			if (!((Object)(object)val3 == (Object)null))
			{
				float num2 = DistanceTo(obj, val3.position);
				if (num2 < num)
				{
					num = num2;
					val2 = val3;
				}
			}
		}
		if ((Object)(object)val2 == (Object)null)
		{
			return null;
		}
		global::System.Collections.Generic.IEnumerator<CloneBody> enumerator = everyone.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				CloneBody current = enumerator.Current;
				if (current == null || current == body || current.GunsDown)
				{
					continue;
				}
				array = (Transform[])(object)new Transform[2] { current.LeftHand, current.RightHand };
				foreach (Transform val4 in array)
				{
					if ((Object)(object)val4 != (Object)null && DistanceTo(obj, val4.position) < num)
					{
						return null;
					}
				}
			}
			return val2;
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}

	private static bool NearLivingHand(GameObject obj, global::System.Collections.Generic.IEnumerable<CloneBody> everyone, float reach)
	{
		//IL_0030: 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)
		global::System.Collections.Generic.IEnumerator<CloneBody> enumerator = everyone.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				CloneBody current = enumerator.Current;
				if (current != null && !current.GunsDown)
				{
					if ((Object)(object)current.LeftHand != (Object)null && DistanceTo(obj, current.LeftHand.position) < reach)
					{
						return true;
					}
					if ((Object)(object)current.RightHand != (Object)null && DistanceTo(obj, current.RightHand.position) < reach)
					{
						return true;
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
		return false;
	}

	private static float DistanceTo(GameObject obj, Vector3 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_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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		float num = Vector3.Distance(obj.transform.position, p);
		global::System.Collections.Generic.IEnumerator<Collider> enumerator = obj.GetComponentsInChildren<Collider>().GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Collider current = enumerator.Current;
				if (!((Object)(object)current == (Object)null) && current.enabled && !current.isTrigger)
				{
					float num2 = num;
					Bounds bounds = current.bounds;
					num = Mathf.Min(num2, Vector3.Distance(((Bounds)(ref bounds)).ClosestPoint(p), p));
				}
			}
			return num;
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}
}
internal static class TimelineAccess
{
	internal static void CollectPlaybackObjects(List<GameObject> into)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		into.Clear();
		WorldPlayer instance = WorldPlayer.Instance;
		if (instance == null || instance.playbackRecorders == null)
		{
			return;
		}
		Enumerator<ObjectRecorder> enumerator = instance.playbackRecorders.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				ObjectRecorder current = enumerator.Current;
				MarrowEntityRecorder val = (MarrowEntityRecorder)(object)((current is MarrowEntityRecorder) ? current : null);
				if (val != null && (Object)(object)val.playbackObject != (Object)null)
				{
					into.Add(val.playbackObject);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	internal static void CollectCloneAvatars(List<Avatar> into, List<ushort> ids)
	{
		//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)
		into.Clear();
		ids.Clear();
		WorldPlayer instance = WorldPlayer.Instance;
		if (instance == null || instance.playbackRecorders == null)
		{
			return;
		}
		Enumerator<ObjectRecorder> enumerator = instance.playbackRecorders.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				ObjectRecorder current = enumerator.Current;
				RigmanagerRecorder val = (RigmanagerRecorder)(object)((current is RigmanagerRecorder) ? current : null);
				if (val != null && (Object)(object)val.currentPlaybackAvatar != (Object)null && ((Component)val.currentPlaybackAvatar).gameObject.activeInHierarchy)
				{
					into.Add(val.currentPlaybackAvatar);
					ids.Add(((ObjectRecorder)val).recorderID);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}
}
internal static class CarTimeline
{
	internal const byte RecorderId = 239;

	private const float SearchRadius = 12f;

	private const int MaxParts = 24;

	private static Seat _lastSeat;

	private static readonly HashSet<int> _recordedThisTake = new HashSet<int>();

	private static readonly Dictionary<RigmanagerRecorder, MarrowEntityRecorder> _lateAnchors = new Dictionary<RigmanagerRecorder, MarrowEntityRecorder>();

	private static readonly List<RigmanagerRecorder> _tmp = new List<RigmanagerRecorder>();

	private static float _lastHead;

	internal static void Install()
	{
		FieldInfo field = typeof(SerializableRegistry).GetField("recorderTypeRegistry", (BindingFlags)40);
		if (((field != null) ? field.GetValue((object)null) : null) is Dictionary<byte, global::System.Type> val)
		{
			val[(byte)239] = typeof(CarRecorder);
		}
		global::System.Type typeFromHandle = typeof(CarTimeline);
		Patches.Postfix("clones-car-anchor", (MethodBase)(object)AccessTools.Method(typeof(RigmanagerRecorder), "SetMarrowRecorderAnchor", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "AfterMarrowAnchor", (Func<bool>)null);
		Patches.Postfix("clones-car-unanchor", (MethodBase)(object)AccessTools.Method(typeof(RigmanagerRecorder), "SetPositionalAnchor", (global::System.Type[])null, (global::System.Type[])null), typeFromHandle, "AfterPositionalAnchor", (Func<bool>)null);
	}

	internal static void Clear()
	{
		_lastSeat = null;
		_recordedThisTake.Clear();
		_lateAnchors.Clear();
	}

	private static void AfterMarrowAnchor(RigmanagerRecorder __instance, MarrowEntityRecorder __0)
	{
		if (__instance != null && __0 != null)
		{
			if ((Object)(object)((ObjectRecorder)__0).targetObject == (Object)null)
			{
				_lateAnchors[__instance] = __0;
			}
			else
			{
				_lateAnchors.Remove(__instance);
			}
		}
	}

	private static void AfterPositionalAnchor(RigmanagerRecorder __instance, GameObject __0)
	{
		if ((Object)(object)__0 == (Object)null)
		{
			_lateAnchors.Remove(__instance);
		}
	}

	private static void TickAnchors()
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		float playHead = WorldPlayer.playHead;
		bool flag = playHead < _lastHead - 0.05f;
		_lastHead = playHead;
		if (_lateAnchors.Count == 0)
		{
			return;
		}
		if (flag || (!WorldPlayer.playing && !WorldPlayer.paused))
		{
			_lateAnchors.Clear();
			return;
		}
		_tmp.Clear();
		_tmp.AddRange((global::System.Collections.Generic.IEnumerable<RigmanagerRecorder>)_lateAnchors.Keys);
		Enumerator<RigmanagerRecorder> enumerator = _tmp.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				RigmanagerRecorder current = enumerator.Current;
				MarrowEntityRecorder val = _lateAnchors[current];
				if (val == null)
				{
					_lateAnchors.Remove(current);
				}
				else if (!((Object)(object)((ObjectRecorder)val).targetObject == (Object)null))
				{
					_lateAnchors.Remove(current);
					try
					{
						current.SetMarrowRecorderAnchor(val);
						ClonesMod.Log.Msg("Timeline: a clone got in before " + ((Object)((ObjectRecorder)val).targetObject).name + " had loaded; it's attached now");
					}
					catch (global::System.Exception ex)
					{
						ClonesMod.Log.Warning("Timeline: couldn't attach a clone to its car: " + ex.Message);
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	internal static void Tick()
	{
		TickAnchors();
		if (!WorldPlayer.recording)
		{
			_lastSeat = null;
			_recordedThisTake.Clear();
		}
		else
		{
			if (WorldPlayer.paused)
			{
				return;
			}
			RigManager rigManager = Player.RigManager;
			Seat val = (((Object)(object)rigManager != (Object)null) ? rigManager.activeSeat : null);
			if ((Object)(object)val == (Object)null)
			{
				_lastSeat = null;
			}
			else if (!((Object)(object)_lastSeat != (Object)null) || !((Object)(object)val == (Object)(object)_lastSeat))
			{
				_lastSeat = val;
				try
				{
					OnSatDown(val);
				}
				catch (global::System.Exception ex)
				{
					ClonesMod.Log.Warning("Timeline: couldn't look at that car: " + ex.Message);
				}
			}
		}
	}

	private static void OnSatDown(Seat seat)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		Rigidbody componentInParent = ((Component)seat).GetComponentInParent<Rigidbody>();
		if ((Object)(object)componentInParent == (Object)null)
		{
			ClonesMod.Log.Msg("Timeline: you sat in " + ((Object)seat).name + ", which doesn't move (nothing to record)");
			return;
		}
		List<Rigidbody> val = Cluster(componentInParent);
		HashSet<int> val2 = new HashSet<int>();
		List<string> val3 = new List<string>();
		List<Rigidbody> val4 = new List<Rigidbody>();
		Enumerator<Rigidbody> enumerator = val.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Rigidbody current = enumerator.Current;
				MarrowEntity componentInParent2 = ((Component)current).GetComponentInParent<MarrowEntity>(true);
				if ((Object)(object)componentInParent2 == (Object)null)
				{
					if (_recordedThisTake.Add(((Object)current).GetInstanceID()))
					{
						val4.Add(current);
					}
				}
				else if (val2.Add(((Object)componentInParent2).GetInstanceID()))
				{
					val3.Add(((Object)componentInParent2).name);
					RecordingUtils.GetMarrowEntityRecorderFromGameObject<MarrowEntityRecorder>(((Component)current).gameObject, true);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		ClonesMod.Log.Msg($"Timeline: you sat in {((Object)componentInParent).name}: {val.Count} moving part(s), recorded by Timeline: {((val3.Count > 0) ? string.Join(", ", (global::System.Collections.Generic.IEnumerable<string>)val3) : "nothing")}; no entity (recorded by Wiggles BW): {val4.Count}");
		if (val4.Count != 0)
		{
			WorldPlayer val5 = ((TimelineMainClass.timelineHolder != null) ? TimelineMainClass.timelineHolder.worldPlayer : WorldPlayer.Instance);
			if (val5 != null)
			{
				CarRecorder carRecorder = new CarRecorder();
				((ObjectRecorder)carRecorder).OnInitializedRecording((Object)null);
				carRecorder.Begin(val4, ((Component)componentInParent).GetComponentInParent<Poolee>());
				((ObjectRecorder)carRecorder).recording = true;
				((ObjectRecorder)carRecorder).initTime = WorldPlayer.playHead;
				val5.AddRecorderToRecord((ObjectRecorder)(object)carRecorder);
			}
		}
	}

	private static List<Rigidbody> Cluster(Rigidbody first)
	{
		//IL_009f: 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)
		List<ValueTuple<Rigidbody, Rigidbody>> links = new List<ValueTuple<Rigidbody, Rigidbody>>();
		HashSet<int> looked = new HashSet<int>();
		List<Rigidbody> obj = new List<Rigidbody>();
		obj.Add(first);
		List<Rigidbody> val = obj;
		HashSet<int> obj2 = new HashSet<int>();
		obj2.Add(((Object)first).GetInstanceID());
		HashSet<int> val2 = obj2;
		Look(first);
		global::System.Collections.Generic.IEnumerator<Rigidbody> enumerator = ((Component)first).GetComponentsInChildren<Rigidbody>(true).GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Rigidbody current = enumerator.Current;
				if (!((Object)(object)current == (Object)null) && !Skip(current))
				{
					Look(current);
					if (val2.Add(((Object)current).GetInstanceID()))
					{
						val.Add(current);
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
		global::System.Collections.Generic.IEnumerator<Collider> enumerator2 = ((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(first.worldCenterOfMass, 12f, -1, (QueryTriggerInteraction)1)).GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
			{
				Collider current2 = enumerator2.Current;
				Rigidbody val3 = (((Object)(object)current2 != (Object)null) ? current2.attachedRigidbody : null);
				if ((Object)(object)val3 != (Object)null)
				{
					Look(val3);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator2)?.Dispose();
		}
		for (int i = 0; i < val.Count; i++)
		{
			if (val.Count >= 24)
			{
				break;
			}
			Enumerator<ValueTuple<Rigidbody, Rigidbody>> enumerator3 = links.GetEnumerator();
			try
			{
				while (enumerator3.MoveNext())
				{
					ValueTuple<Rigidbody, Rigidbody> current3 = enumerator3.Current;
					Rigidbody item = current3.Item1;
					Rigidbody item2 = current3.Item2;
					Rigidbody val4 = (((Object)(object)item == (Object)(object)val[i]) ? item2 : (((Object)(object)item2 == (Object)(object)val[i]) ? item : null));
					if (!((Object)(object)val4 == (Object)null) && !Skip(val4) && val2.Add(((Object)val4).GetInstanceID()))
					{
						val.Add(val4);
						if (val.Count >= 24)
						{
							break;
						}
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose();
			}
		}
		return val;
		[CompilerGenerated]
		void Look(Rigidbody rb)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rb == (Object)null || !looked.Add(((Object)rb).GetInstanceID()))
			{
				return;
			}
			global::System.Collections.Generic.IEnumerator<Joint> enumerator4 = ((Component)rb).GetComponents<Joint>().GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator4).MoveNext())
				{
					Joint current4 = enumerator4.Current;
					if ((Object)(object)current4 != (Object)null && (Object)(object)current4.connectedBody != (Object)null)
					{
						links.Add(new ValueTuple<Rigidbody, Rigidbody>(rb, current4.connectedBody));
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator4)?.Dispose();
			}
		}
	}

	private static bool Skip(Rigidbody rb)
	{
		if (((Component)rb).gameObject.layer != 12)
		{
			return (Object)(object)((Component)rb).GetComponentInParent<RigManager>() != (Object)null;
		}
		return true;
	}
}
public class CarRecorder : ObjectRecorder
{
	private string _barcode = "";

	private readonly List<string> _paths = new List<string>();

	private readonly List<float> _times = new List<float>();

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

	private readonly List<Quaternion> _rot = new List<Quaternion>();

	private Transform _root;

	private Transform[] _parts;

	private Rigidbody[] _rbs;

	private ValueTuple<bool, RigidbodyInterpolation>[] _was;

	private GameObject _copy;

	private bool _took;

	private bool _wantCopy;

	public override byte SerializeableID => 239;

	public override string GetName()
	{
		return "Car (no entity)";
	}

	public override void OnInitializedRecording(Object obj)
	{
	}

	internal void Begin(List<Rigidbody> bodies, Poolee poolee)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		_root = (((Object)(object)poolee != (Object)null) ? ((Component)poolee).transform : null);
		try
		{
			if ((Object)(object)poolee != (Object)null && (Object)(object)poolee.SpawnableCrate != (Object)null)
			{
				_barcode = ((Scannable)poolee.SpawnableCrate).Barcode.ID;
			}
		}
		catch
		{
		}
		if (_barcode.Length == 0)
		{
			_root = null;
		}
		List<Transform> val = new List<Transform>();
		Enumerator<Rigidbody> enumerator = bodies.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Rigidbody current = enumerator.Current;
				if ((Object)(object)current != (Object)null)
				{
					val.Add(((Component)current).transform);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
		if ((Object)(object)_root != (Object)null && !Enumerable.Any<Transform>((global::System.Collections.Generic.IEnumerable<Transform>)val, (Func<Transform, bool>)([CompilerGenerated] (Transform t) => (Object)(object)t == (Object)(object)_root)))
		{
			val.Add(_root);
		}
		val = Enumerable.ToList<Transform>((global::System.Collections.Generic.IEnumerable<Transform>)Enumerable.OrderBy<Transform, int>((global::System.Collections.Generic.IEnumerable<Transform>)val, (Func<Transform, int>)Depth));
		int count = val.Count;
		_parts = val.ToArray();
		_rbs = (Rigidbody[])(object)new Rigidbody[count];
		for (int num = 0; num < count; num++)
		{
			_rbs[num] = ((Component)_parts[num]).GetComponent<Rigidbody>();
			_paths.Add(PathOf(_parts[num], _root));
		}
	}

	private static int Depth(Transform t)
	{
		int num = 0;
		Transform parent = t.parent;
		while ((Object)(object)parent != (Object)null)
		{
			num++;
			parent = parent.parent;
		}
		return num;
	}

	private static string PathOf(Transform t, Transform root)
	{
		List<string> val = new List<string>();
		Transform val2 = t;
		while ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)root)
		{
			val.Add(((Object)val2).name);
			val2 = val2.parent;
		}
		val.Reverse();
		return string.Join("/", (global::System.Collections.Generic.IEnumerable<string>)val);
	}

	public override void Capture(float time)
	{
		//IL_006a: 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)
		//