Decompiled source of TimeStop v0.1.0

TimeStop.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using Il2Cpp;
using Il2CppActiveRagdoll;
using Il2CppHurricaneVR.Framework.Core;
using Il2CppHurricaneVR.Framework.Core.Grabbers;
using Il2CppHurricaneVR.Framework.Shared;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TimeStop;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "TimeStop", "0.1.0", "coope", null)]
[assembly: MelonGame("Kubunautilus", "BrutalistickVR")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TimeStop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TimeStop")]
[assembly: AssemblyTitle("TimeStop")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TimeStop
{
	internal static class Mci
	{
		public static string LastError;

		[DllImport("winmm.dll", CharSet = CharSet.Ansi, EntryPoint = "mciSendStringA")]
		private static extern int mciSendString(string cmd, StringBuilder buf, int bufSize, IntPtr cb);

		private static int Send(string cmd)
		{
			try
			{
				StringBuilder stringBuilder = new StringBuilder(256);
				int num = mciSendString(cmd, stringBuilder, stringBuilder.Capacity, IntPtr.Zero);
				if (num != 0)
				{
					LastError = cmd + " -> " + num;
				}
				return num;
			}
			catch (Exception ex)
			{
				LastError = ex.Message;
				return -1;
			}
		}

		public static bool Open(string alias, string path, float volume)
		{
			Send("close " + alias);
			if (Send("open \"" + path + "\" type waveaudio alias " + alias) != 0)
			{
				return false;
			}
			float num = volume;
			if (num < 0f)
			{
				num = 0f;
			}
			if (num > 1f)
			{
				num = 1f;
			}
			Send("setaudio " + alias + " volume to " + (int)Math.Round(num * 1000f));
			return true;
		}

		public static bool Play(string alias)
		{
			if (Send("seek " + alias + " to start") != 0)
			{
				return false;
			}
			return Send("play " + alias) == 0;
		}

		public static void Close(string alias)
		{
			Send("close " + alias);
		}
	}
	public class Core : MelonMod
	{
		private struct Saved
		{
			public bool kinematic;

			public bool gravity;

			public Vector3 velocity;

			public Vector3 angular;
		}

		private sealed class FrozenBody
		{
			public Rigidbody rb;

			public Transform root;

			public Saved state;

			public Vector3 startPos;
		}

		private sealed class FlowParticle
		{
			public Transform tr;

			public Material mat;

			public Vector3 vel;

			public float life;
		}

		private sealed class Wave
		{
			public Transform tr;

			public Material mat;

			public float age;
		}

		private sealed class FrozenProjectile
		{
			public Rigidbody rb;

			public bool kinematic;

			public bool slowed;

			public bool dragSaved;

			public float drag;

			public float angularDrag;

			public float sleep;

			public Vector3 realVelocity;

			public Vector3 lastScaledVelocity;

			public Vector3 realAngular;

			public Vector3 lastScaledAngular;

			public Vector3 lastScriptPos;

			public Vector3 lastScaledPos;

			public float lastSeen;
		}

		private const string LogPath = "D:\\BrutalistickVrWork\\Probe\\timestop.log";

		private HVRHexaBodyInputs _inputs;

		private bool _wasB;

		private bool _frozen;

		private bool _soundReady;

		private bool _audioPausedPrev;

		private float _updateMs;

		private float _fixedMs;

		private float _msNew;

		private float _msGrab;

		private float _msProj;

		private float _msFx;

		private int _perfFrames;

		private int _perfFixedFrames;

		private readonly List<KeyValuePair<Behaviour, bool>> _savedScripts = new List<KeyValuePair<Behaviour, bool>>();

		private readonly List<KeyValuePair<StickGunManager, bool>> _savedGunFlags = new List<KeyValuePair<StickGunManager, bool>>();

		private Camera _cam;

		private readonly List<FrozenBody> _saved = new List<FrozenBody>();

		private readonly List<KeyValuePair<Animator, float>> _savedAnimators = new List<KeyValuePair<Animator, float>>();

		private Material _flowPurple;

		private Material _flowBlue;

		private GameObject _grayGo;

		private Volume _grayVolume;

		private VolumeProfile _grayProfile;

		private ColorAdjustments _grayAdjust;

		private readonly List<FlowParticle> _flow = new List<FlowParticle>();

		private readonly List<HVRGrabbable> _held = new List<HVRGrabbable>();

		private HVRHandGrabber[] _hands;

		private readonly HashSet<IntPtr> _moving = new HashSet<IntPtr>();

		private readonly HashSet<IntPtr> _grabbedIds = new HashSet<IntPtr>();

		private readonly HashSet<Transform> _grabbedRoots = new HashSet<Transform>();

		private readonly HashSet<Transform> _knownRoots = new HashSet<Transform>();

		private readonly HashSet<IntPtr> _prevHeldRb = new HashSet<IntPtr>();

		private readonly HashSet<IntPtr> _curHeldRb = new HashSet<IntPtr>();

		private readonly Dictionary<IntPtr, Rigidbody> _rbById = new Dictionary<IntPtr, Rigidbody>();

		private int _camSearchFrames;

		private float _grabScanTimer;

		private bool _grabDirty;

		private float _newComerTimer;

		private readonly List<Wave> _waves = new List<Wave>();

		private readonly Dictionary<int, FrozenProjectile> _projectiles = new Dictionary<int, FrozenProjectile>();

		private readonly List<int> _projPrune = new List<int>();

		private float _projScanTimer;

		private void SetGray(bool on)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			try
			{
				if (on)
				{
					if ((Object)(object)_grayGo == (Object)null)
					{
						_grayGo = new GameObject("TimeStopGray");
						_grayVolume = _grayGo.AddComponent<Volume>();
						_grayVolume.isGlobal = true;
						_grayVolume.priority = 100f;
						_grayProfile = ScriptableObject.CreateInstance<VolumeProfile>();
						_grayAdjust = _grayProfile.Add<ColorAdjustments>(true);
						_grayVolume.sharedProfile = _grayProfile;
					}
					((VolumeParameter)_grayAdjust.saturation).SetValue((VolumeParameter)new ClampedFloatParameter(-100f, -100f, 100f, true));
					_grayGo.SetActive(true);
				}
				else if ((Object)(object)_grayGo != (Object)null)
				{
					_grayGo.SetActive(false);
				}
			}
			catch (Exception ex)
			{
				Write("gray failed " + ex.Message);
			}
		}

		private void SpawnWave()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Shader val = Shader.Find("Sprites/Default");
				if (!((Object)(object)val == (Object)null) && !((Object)(object)_cam == (Object)null))
				{
					GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
					Object.Destroy((Object)(object)val2.GetComponent<Collider>());
					((Object)val2).name = "TimeStopWave";
					Material val3 = new Material(val);
					val3.color = new Color(0.65f, 0.55f, 1f, 0.16f);
					val2.GetComponent<Renderer>().material = val3;
					Vector3 position = ((Component)_cam).transform.position;
					position.y -= 0.9f;
					val2.transform.position = position;
					val2.transform.localScale = Vector3.one * 0.2f;
					_waves.Add(new Wave
					{
						tr = val2.transform,
						mat = val3,
						age = 0f
					});
				}
			}
			catch (Exception ex)
			{
				Write("wave failed " + ex.Message);
			}
		}

		private void UpdateWaves(float dt)
		{
			//IL_0068: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			for (int num = _waves.Count - 1; num >= 0; num--)
			{
				Wave wave = _waves[num];
				if (wave == null || (Object)(object)wave.tr == (Object)null)
				{
					_waves.RemoveAt(num);
				}
				else
				{
					wave.age += dt;
					float num2 = Mathf.Clamp01(wave.age / 0.95f);
					wave.tr.localScale = Vector3.one * Mathf.Lerp(0.2f, 9f, num2);
					if ((Object)(object)wave.mat != (Object)null)
					{
						wave.mat.color = new Color(0.65f, 0.55f, 1f, 0.16f * (1f - num2));
					}
					if (num2 >= 1f)
					{
						Object.Destroy((Object)(object)((Component)wave.tr).gameObject);
						_waves.RemoveAt(num);
					}
				}
			}
		}

		private void ClearWaves()
		{
			for (int i = 0; i < _waves.Count; i++)
			{
				if (_waves[i] != null && (Object)(object)_waves[i].tr != (Object)null)
				{
					try
					{
						Object.Destroy((Object)(object)((Component)_waves[i].tr).gameObject);
					}
					catch
					{
					}
				}
			}
			_waves.Clear();
		}

		public override void OnInitializeMelon()
		{
			string text = Path.Combine(Application.dataPath, "..", "Mods", "TimeStop");
			Directory.CreateDirectory(text);
			string path = Path.Combine(text, "timestop.wav");
			_soundReady = File.Exists(path) && Mci.Open("timestop", path, 0.9f);
			Write("init sound=" + _soundReady);
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			_cam = null;
			_camSearchFrames = 0;
			_hands = null;
			if (_frozen)
			{
				Unfreeze();
			}
		}

		public override void OnApplicationQuit()
		{
			if (_frozen)
			{
				Unfreeze();
			}
			Mci.Close("timestop");
		}

		public override void OnUpdate()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Invalid comparison between Unknown and I4
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if ((Object)(object)_inputs == (Object)null)
			{
				try
				{
					_inputs = PlayerStaticReferences.hexaInputs;
				}
				catch
				{
				}
			}
			if ((Object)(object)_inputs == (Object)null)
			{
				return;
			}
			if ((Object)(object)_cam == (Object)null && _camSearchFrames < 120)
			{
				_camSearchFrames++;
				Il2CppReferenceArray<Camera> allCameras = Camera.allCameras;
				if (allCameras != null)
				{
					for (int i = 0; i < ((Il2CppArrayBase<Camera>)(object)allCameras).Length; i++)
					{
						if ((Object)(object)((Il2CppArrayBase<Camera>)(object)allCameras)[i] != (Object)null && (int)((Il2CppArrayBase<Camera>)(object)allCameras)[i].stereoTargetEye == 3)
						{
							_cam = ((Il2CppArrayBase<Camera>)(object)allCameras)[i];
							break;
						}
					}
				}
			}
			bool flag = (!HandBusy(_inputs.LeftController) && BDown(_inputs.LeftController)) || (!HandBusy(_inputs.RightController) && BDown(_inputs.RightController));
			if (flag && !_wasB)
			{
				if (_frozen)
				{
					Unfreeze();
				}
				else
				{
					Freeze();
				}
			}
			_wasB = flag;
			if (_frozen)
			{
				float realtimeSinceStartup2 = Time.realtimeSinceStartup;
				FreezeNewComers();
				float realtimeSinceStartup3 = Time.realtimeSinceStartup;
				UpdateGrabbed();
				float realtimeSinceStartup4 = Time.realtimeSinceStartup;
				UpdateProjectileScan();
				float realtimeSinceStartup5 = Time.realtimeSinceStartup;
				UpdateFlow(Time.unscaledDeltaTime);
				UpdateWaves(Time.unscaledDeltaTime);
				_msNew += (realtimeSinceStartup3 - realtimeSinceStartup2) * 1000f;
				_msGrab += (realtimeSinceStartup4 - realtimeSinceStartup3) * 1000f;
				_msProj += (realtimeSinceStartup5 - realtimeSinceStartup4) * 1000f;
				_msFx += (Time.realtimeSinceStartup - realtimeSinceStartup5) * 1000f;
			}
			_updateMs += (Time.realtimeSinceStartup - realtimeSinceStartup) * 1000f;
			_perfFrames++;
			if (_perfFrames >= 300)
			{
				Write("perf update=" + (_updateMs / (float)_perfFrames).ToString("F2") + " new=" + (_msNew / (float)_perfFrames).ToString("F2") + " grab=" + (_msGrab / (float)_perfFrames).ToString("F2") + " proj=" + (_msProj / (float)_perfFrames).ToString("F2") + " fx=" + (_msFx / (float)_perfFrames).ToString("F2") + " fixed=" + ((_perfFixedFrames > 0) ? (_fixedMs / (float)_perfFixedFrames).ToString("F2") : "0") + " bodies=" + _saved.Count + " projs=" + _projectiles.Count);
				_updateMs = 0f;
				_fixedMs = 0f;
				_msNew = 0f;
				_msGrab = 0f;
				_msProj = 0f;
				_msFx = 0f;
				_perfFrames = 0;
				_perfFixedFrames = 0;
			}
		}

		public override void OnFixedUpdate()
		{
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (_frozen)
			{
				UpdateProjectiles();
			}
			_fixedMs += (Time.realtimeSinceStartup - realtimeSinceStartup) * 1000f;
			_perfFixedFrames++;
		}

		private bool HandBusy(HVRController c)
		{
			//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_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)
			if ((Object)(object)c == (Object)null)
			{
				return false;
			}
			HVRHandSide side;
			try
			{
				side = c.Side;
			}
			catch
			{
				return false;
			}
			HVRHandGrabber[] array = _hands;
			if (array == null)
			{
				array = (_hands = Il2CppArrayBase<HVRHandGrabber>.op_Implicit(Object.FindObjectsOfType<HVRHandGrabber>()));
			}
			if (array == null)
			{
				return false;
			}
			foreach (HVRHandGrabber val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				try
				{
					if (val.HandSide != side)
					{
						continue;
					}
				}
				catch
				{
					continue;
				}
				try
				{
					if ((Object)(object)((HVRGrabberBase)val).HeldObject != (Object)null && ((HVRGrabberBase)val).HeldObject.IsBeingHeld)
					{
						return true;
					}
				}
				catch
				{
				}
				try
				{
					if ((Object)(object)((HVRGrabberBase)val).GrabbedTarget != (Object)null && ((HVRGrabberBase)val).GrabbedTarget.IsBeingHeld)
					{
						return true;
					}
				}
				catch
				{
				}
			}
			return false;
		}

		private static bool BDown(HVRController c)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c == (Object)null)
			{
				return false;
			}
			try
			{
				if ((int)c.ControllerType == 3)
				{
					return c.TrackpadButtonState.Active || c.MenuButtonState.Active;
				}
			}
			catch
			{
			}
			try
			{
				return c.SecondaryButtonState.Active;
			}
			catch
			{
				return false;
			}
		}

		private static bool IsPlayer(Transform t)
		{
			Transform val = (((Object)(object)t == (Object)null) ? null : t.root);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			try
			{
				GameObject playerHeadStatic = PlayerStaticReferences.playerHeadStatic;
				GameObject playerUpperChestStatic = PlayerStaticReferences.playerUpperChestStatic;
				GameObject playerHexaPelvisStatic = PlayerStaticReferences.playerHexaPelvisStatic;
				if ((Object)(object)playerHeadStatic != (Object)null && (Object)(object)playerHeadStatic.transform.root == (Object)(object)val)
				{
					return true;
				}
				if ((Object)(object)playerUpperChestStatic != (Object)null && (Object)(object)playerUpperChestStatic.transform.root == (Object)(object)val)
				{
					return true;
				}
				if ((Object)(object)playerHexaPelvisStatic != (Object)null && (Object)(object)playerHexaPelvisStatic.transform.root == (Object)(object)val)
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}

		private static bool Under(Transform t, Transform root)
		{
			int num = 0;
			while (num < 12 && (Object)(object)t != (Object)null)
			{
				if ((Object)(object)t == (Object)(object)root)
				{
					return true;
				}
				num++;
				t = t.parent;
			}
			return false;
		}

		private void DisableBehaviour(Behaviour b)
		{
			if (!((Object)(object)b == (Object)null) && b.enabled)
			{
				_savedScripts.Add(new KeyValuePair<Behaviour, bool>(b, value: true));
				b.enabled = false;
			}
		}

		private void DisableAttacksFor(Transform root)
		{
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			Il2CppArrayBase<StickGunManager> componentsInChildren = ((Component)root).GetComponentsInChildren<StickGunManager>(true);
			if (componentsInChildren != null)
			{
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					StickGunManager val = componentsInChildren[i];
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					try
					{
						if (!val.isTimeStopped)
						{
							_savedGunFlags.Add(new KeyValuePair<StickGunManager, bool>(val, value: false));
							val.isTimeStopped = true;
						}
					}
					catch
					{
					}
					DisableBehaviour((Behaviour)(object)val);
				}
			}
			Il2CppArrayBase<EnemyMeleeManager> componentsInChildren2 = ((Component)root).GetComponentsInChildren<EnemyMeleeManager>(true);
			if (componentsInChildren2 != null)
			{
				for (int j = 0; j < componentsInChildren2.Length; j++)
				{
					DisableBehaviour((Behaviour)(object)componentsInChildren2[j]);
				}
			}
			Il2CppArrayBase<ZombieSwipeAttackManager> componentsInChildren3 = ((Component)root).GetComponentsInChildren<ZombieSwipeAttackManager>(true);
			if (componentsInChildren3 != null)
			{
				for (int k = 0; k < componentsInChildren3.Length; k++)
				{
					DisableBehaviour((Behaviour)(object)componentsInChildren3[k]);
				}
			}
			Il2CppArrayBase<ZombieAttackingManager> componentsInChildren4 = ((Component)root).GetComponentsInChildren<ZombieAttackingManager>(true);
			if (componentsInChildren4 != null)
			{
				for (int l = 0; l < componentsInChildren4.Length; l++)
				{
					DisableBehaviour((Behaviour)(object)componentsInChildren4[l]);
				}
			}
		}

		private void DisableEnemyAttacks()
		{
			Il2CppArrayBase<StickGunManager> val = Object.FindObjectsOfType<StickGunManager>();
			if (val != null)
			{
				for (int i = 0; i < val.Length; i++)
				{
					StickGunManager val2 = val[i];
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					try
					{
						if (!val2.isTimeStopped)
						{
							_savedGunFlags.Add(new KeyValuePair<StickGunManager, bool>(val2, value: false));
							val2.isTimeStopped = true;
						}
					}
					catch
					{
					}
					DisableBehaviour((Behaviour)(object)val2);
				}
			}
			Il2CppArrayBase<EnemyMeleeManager> val3 = Object.FindObjectsOfType<EnemyMeleeManager>();
			if (val3 != null)
			{
				for (int j = 0; j < val3.Length; j++)
				{
					DisableBehaviour((Behaviour)(object)val3[j]);
				}
			}
			Il2CppArrayBase<ZombieSwipeAttackManager> val4 = Object.FindObjectsOfType<ZombieSwipeAttackManager>();
			if (val4 != null)
			{
				for (int k = 0; k < val4.Length; k++)
				{
					DisableBehaviour((Behaviour)(object)val4[k]);
				}
			}
			Il2CppArrayBase<ZombieAttackingManager> val5 = Object.FindObjectsOfType<ZombieAttackingManager>();
			if (val5 != null)
			{
				for (int l = 0; l < val5.Length; l++)
				{
					DisableBehaviour((Behaviour)(object)val5[l]);
				}
			}
		}

		private void FreezeNewComers()
		{
			//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_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			_newComerTimer -= Time.unscaledDeltaTime;
			if (_newComerTimer > 0f)
			{
				return;
			}
			_newComerTimer = 1f;
			Il2CppArrayBase<StickHealth> val = Object.FindObjectsOfType<StickHealth>();
			if (val != null)
			{
				_knownRoots.Clear();
				for (int i = 0; i < _saved.Count; i++)
				{
					if (_saved[i] != null && (Object)(object)_saved[i].root != (Object)null)
					{
						_knownRoots.Add(_saved[i].root);
					}
				}
				for (int j = 0; j < val.Length; j++)
				{
					StickHealth val2 = val[j];
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					Transform transform = ((Component)val2).gameObject.transform;
					if (_knownRoots.Contains(transform))
					{
						continue;
					}
					Il2CppArrayBase<Rigidbody> componentsInChildren = ((Component)transform).GetComponentsInChildren<Rigidbody>(true);
					if (componentsInChildren != null)
					{
						for (int k = 0; k < componentsInChildren.Length; k++)
						{
							Rigidbody val3 = componentsInChildren[k];
							if (!((Object)(object)val3 == (Object)null) && !IsPlayer(((Component)val3).transform))
							{
								_saved.Add(new FrozenBody
								{
									rb = val3,
									root = transform,
									startPos = val3.position,
									state = new Saved
									{
										kinematic = val3.isKinematic,
										gravity = val3.useGravity,
										velocity = val3.velocity,
										angular = val3.angularVelocity
									}
								});
								val3.velocity = Vector3.zero;
								val3.angularVelocity = Vector3.zero;
								val3.useGravity = false;
								val3.isKinematic = true;
							}
						}
					}
					_knownRoots.Add(transform);
					DisableAttacksFor(transform);
					Il2CppArrayBase<Animator> componentsInChildren2 = ((Component)transform).GetComponentsInChildren<Animator>(true);
					if (componentsInChildren2 == null)
					{
						continue;
					}
					for (int l = 0; l < componentsInChildren2.Length; l++)
					{
						if (!((Object)(object)componentsInChildren2[l] == (Object)null))
						{
							_savedAnimators.Add(new KeyValuePair<Animator, float>(componentsInChildren2[l], componentsInChildren2[l].speed));
							componentsInChildren2[l].speed = 0f;
						}
					}
				}
			}
			Il2CppArrayBase<BulletManager> val4 = Object.FindObjectsOfType<BulletManager>();
			if (val4 != null)
			{
				for (int m = 0; m < val4.Length; m++)
				{
					BulletManager val5 = val4[m];
					if (!((Object)(object)val5 == (Object)null) && ((Behaviour)val5).enabled)
					{
						_savedScripts.Add(new KeyValuePair<Behaviour, bool>((Behaviour)(object)val5, value: true));
						((Behaviour)val5).enabled = false;
					}
				}
			}
			Il2CppArrayBase<BulletManagerEnemy> val6 = Object.FindObjectsOfType<BulletManagerEnemy>();
			if (val6 == null)
			{
				return;
			}
			for (int n = 0; n < val6.Length; n++)
			{
				BulletManagerEnemy val7 = val6[n];
				if (!((Object)(object)val7 == (Object)null) && ((Behaviour)val7).enabled)
				{
					_savedScripts.Add(new KeyValuePair<Behaviour, bool>((Behaviour)(object)val7, value: true));
					((Behaviour)val7).enabled = false;
				}
			}
		}

		private static bool IsProjectile(Rigidbody rb)
		{
			//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)
			if ((Object)(object)rb == (Object)null)
			{
				return false;
			}
			try
			{
				string name = ((Object)((Component)rb).gameObject).name;
				if (!string.IsNullOrEmpty(name) && (name.IndexOf("bullet", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("projectile", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("shot", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("pellet", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("slug", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("ammo", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("round", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("bolt", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("dart", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("rocket", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("grenade", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("arrow", StringComparison.OrdinalIgnoreCase) >= 0))
				{
					return true;
				}
			}
			catch
			{
			}
			try
			{
				Vector3 velocity = rb.velocity;
				float sqrMagnitude = ((Vector3)(ref velocity)).sqrMagnitude;
				if (sqrMagnitude > 3.24f)
				{
					return true;
				}
				if (!rb.useGravity && sqrMagnitude > 2.25f)
				{
					return true;
				}
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)((Component)rb).GetComponentInParent<BulletManager>() != (Object)null)
				{
					return true;
				}
				if ((Object)(object)((Component)rb).GetComponentInParent<BulletManagerEnemy>() != (Object)null)
				{
					return true;
				}
				if ((Object)(object)((Component)rb).GetComponentInParent<PelletManager>() != (Object)null)
				{
					return true;
				}
				if ((Object)(object)((Component)rb).GetComponentInParent<GrenadeScript>() != (Object)null)
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}

		private static void InitProjectile(FrozenProjectile p)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//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)
			Rigidbody rb = p.rb;
			p.kinematic = rb.isKinematic;
			p.realVelocity = rb.velocity;
			p.lastScaledVelocity = rb.velocity;
			p.realAngular = rb.angularVelocity;
			p.lastScaledAngular = rb.angularVelocity;
			p.lastScriptPos = rb.position;
			p.lastScaledPos = rb.position;
			p.slowed = false;
			p.dragSaved = false;
		}

		private static void RestoreProjectile(FrozenProjectile p)
		{
			//IL_002b: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (p == null || (Object)(object)p.rb == (Object)null || !p.slowed)
			{
				return;
			}
			Rigidbody rb = p.rb;
			try
			{
				if (!p.kinematic)
				{
					rb.velocity = p.realVelocity;
					rb.angularVelocity = p.realAngular;
					rb.WakeUp();
				}
				if (p.dragSaved)
				{
					rb.drag = p.drag;
					rb.angularDrag = p.angularDrag;
					rb.sleepThreshold = p.sleep;
				}
				p.lastScaledVelocity = (p.realVelocity = rb.velocity);
				p.lastScaledAngular = (p.realAngular = rb.angularVelocity);
				p.lastScaledPos = (p.lastScriptPos = rb.position);
			}
			catch
			{
			}
			p.slowed = false;
			p.dragSaved = false;
		}

		private void RestoreProjectiles()
		{
			foreach (KeyValuePair<int, FrozenProjectile> projectile in _projectiles)
			{
				RestoreProjectile(projectile.Value);
			}
			_projectiles.Clear();
		}

		private void UpdateProjectileScan()
		{
			_projScanTimer -= Time.unscaledDeltaTime;
			if (_projScanTimer > 0f)
			{
				return;
			}
			_projScanTimer = 0.04f;
			Il2CppArrayBase<Rigidbody> val = Object.FindObjectsOfType<Rigidbody>();
			if (val == null)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			for (int i = 0; i < val.Length; i++)
			{
				Rigidbody val2 = val[i];
				if ((Object)(object)val2 == (Object)null || IsPlayer(((Component)val2).transform) || (Object)(object)((Component)val2).GetComponentInParent<HVRGrabbable>() != (Object)null || _grabbedIds.Contains(((Il2CppObjectBase)val2).Pointer) || !IsProjectile(val2))
				{
					continue;
				}
				int instanceID = ((Object)val2).GetInstanceID();
				if (!_projectiles.ContainsKey(instanceID) && _projectiles.Count < 200)
				{
					if (!_projectiles.TryGetValue(instanceID, out var value))
					{
						value = new FrozenProjectile
						{
							rb = val2
						};
						InitProjectile(value);
						_projectiles[instanceID] = value;
					}
					value.lastSeen = unscaledTime;
				}
			}
			_projPrune.Clear();
			foreach (KeyValuePair<int, FrozenProjectile> projectile in _projectiles)
			{
				FrozenProjectile value2 = projectile.Value;
				if (value2 == null || (Object)(object)value2.rb == (Object)null || _grabbedIds.Contains(((Il2CppObjectBase)value2.rb).Pointer))
				{
					_projPrune.Add(projectile.Key);
				}
			}
			for (int j = 0; j < _projPrune.Count; j++)
			{
				int key = _projPrune[j];
				RestoreProjectile(_projectiles[key]);
				_projectiles.Remove(key);
			}
		}

		private void UpdateProjectiles()
		{
			//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_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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_017c: 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_016a: 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_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_01ae: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
			if (_projectiles.Count == 0)
			{
				return;
			}
			foreach (KeyValuePair<int, FrozenProjectile> projectile in _projectiles)
			{
				FrozenProjectile value = projectile.Value;
				if (value == null || (Object)(object)value.rb == (Object)null)
				{
					continue;
				}
				Rigidbody rb = value.rb;
				try
				{
					if (rb.isKinematic != value.kinematic)
					{
						RestoreProjectile(value);
						InitProjectile(value);
					}
					Vector3 position = rb.position;
					if (!value.slowed)
					{
						value.slowed = true;
						value.dragSaved = false;
						value.realVelocity = rb.velocity;
						value.lastScaledVelocity = rb.velocity;
						value.realAngular = rb.angularVelocity;
						value.lastScaledAngular = rb.angularVelocity;
						value.lastScriptPos = position;
						value.lastScaledPos = position;
					}
					if (!value.kinematic && !value.dragSaved)
					{
						value.drag = rb.drag;
						value.angularDrag = rb.angularDrag;
						value.sleep = rb.sleepThreshold;
						rb.drag = 0f;
						rb.angularDrag = 0f;
						rb.sleepThreshold = 0f;
						value.dragSaved = true;
					}
					if (!value.kinematic)
					{
						if (((Vector3)(ref value.realVelocity)).sqrMagnitude > 0.01f)
						{
							rb.WakeUp();
						}
						Vector3 velocity = rb.velocity;
						Vector3 val = velocity - value.lastScaledVelocity;
						if (((Vector3)(ref val)).magnitude > 60f)
						{
							value.realVelocity = velocity;
						}
						else
						{
							value.realVelocity += val;
						}
						rb.velocity = Vector3.zero;
						value.lastScaledVelocity = Vector3.zero;
						Vector3 angularVelocity = rb.angularVelocity;
						value.realAngular += angularVelocity - value.lastScaledAngular;
						if (((Vector3)(ref value.realAngular)).magnitude > 80f)
						{
							value.realAngular = ((Vector3)(ref value.realAngular)).normalized * 80f;
						}
						rb.angularVelocity = Vector3.zero;
						value.lastScaledAngular = Vector3.zero;
					}
					else
					{
						Vector3 val2 = position - value.lastScriptPos;
						if (((Vector3)(ref val2)).magnitude > 6f)
						{
							value.lastScriptPos = position;
							value.lastScaledPos = position;
						}
						else
						{
							rb.MovePosition(value.lastScaledPos);
							value.lastScriptPos = position;
						}
					}
				}
				catch
				{
				}
			}
		}

		private void FreezeReleased(Rigidbody rb)
		{
			//IL_0054: 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)
			if (!((Object)(object)rb == (Object)null))
			{
				int instanceID = ((Object)rb).GetInstanceID();
				if (!_projectiles.ContainsKey(instanceID) && _projectiles.Count < 200)
				{
					FrozenProjectile frozenProjectile = new FrozenProjectile
					{
						rb = rb
					};
					InitProjectile(frozenProjectile);
					_projectiles[instanceID] = frozenProjectile;
					rb.velocity = Vector3.zero;
					rb.angularVelocity = Vector3.zero;
				}
			}
		}

		private void SetRootAnimators(Transform root, bool on)
		{
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			for (int i = 0; i < _savedAnimators.Count; i++)
			{
				Animator key = _savedAnimators[i].Key;
				if (!((Object)(object)key == (Object)null) && Under(((Component)key).transform, root))
				{
					key.speed = (on ? _savedAnimators[i].Value : 0f);
				}
			}
		}

		private void UpdateGrabbed()
		{
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			_grabScanTimer -= Time.unscaledDeltaTime;
			if (_grabScanTimer <= 0f)
			{
				_grabScanTimer = 0.15f;
				_held.Clear();
				if (_hands == null)
				{
					_hands = Il2CppArrayBase<HVRHandGrabber>.op_Implicit(Object.FindObjectsOfType<HVRHandGrabber>());
				}
				HVRHandGrabber[] hands = _hands;
				if (hands != null)
				{
					foreach (HVRHandGrabber val in hands)
					{
						if (!((Object)(object)val == (Object)null))
						{
							HVRGrabbable heldObject = ((HVRGrabberBase)val).HeldObject;
							if ((Object)(object)heldObject != (Object)null && heldObject.IsBeingHeld && !_held.Contains(heldObject))
							{
								_held.Add(heldObject);
							}
							HVRGrabbable grabbedTarget = ((HVRGrabberBase)val).GrabbedTarget;
							if ((Object)(object)grabbedTarget != (Object)null && grabbedTarget.IsBeingHeld && !_held.Contains(grabbedTarget))
							{
								_held.Add(grabbedTarget);
							}
						}
					}
				}
				_grabbedIds.Clear();
				_curHeldRb.Clear();
				for (int j = 0; j < _held.Count; j++)
				{
					HVRGrabbable val2 = _held[j];
					if (!((Object)(object)val2 == (Object)null))
					{
						Rigidbody component = ((Component)val2).GetComponent<Rigidbody>();
						if ((Object)(object)component != (Object)null)
						{
							_grabbedIds.Add(((Il2CppObjectBase)component).Pointer);
							_curHeldRb.Add(((Il2CppObjectBase)component).Pointer);
							_rbById[((Il2CppObjectBase)component).Pointer] = component;
						}
						Rigidbody componentInParent = ((Component)val2).GetComponentInParent<Rigidbody>();
						if ((Object)(object)componentInParent != (Object)null)
						{
							_grabbedIds.Add(((Il2CppObjectBase)componentInParent).Pointer);
							_curHeldRb.Add(((Il2CppObjectBase)componentInParent).Pointer);
							_rbById[((Il2CppObjectBase)componentInParent).Pointer] = componentInParent;
						}
					}
				}
				_grabbedRoots.Clear();
				for (int k = 0; k < _saved.Count; k++)
				{
					FrozenBody frozenBody = _saved[k];
					if (frozenBody != null && !((Object)(object)frozenBody.rb == (Object)null) && _grabbedIds.Contains(((Il2CppObjectBase)frozenBody.rb).Pointer) && (Object)(object)frozenBody.root != (Object)null)
					{
						_grabbedRoots.Add(frozenBody.root);
					}
				}
				foreach (IntPtr item in _prevHeldRb)
				{
					if (!_curHeldRb.Contains(item) && _rbById.TryGetValue(item, out var value))
					{
						FreezeReleased(value);
					}
				}
				_prevHeldRb.Clear();
				foreach (IntPtr item2 in _curHeldRb)
				{
					_prevHeldRb.Add(item2);
				}
				_grabDirty = true;
			}
			if (!_grabDirty)
			{
				return;
			}
			_grabDirty = false;
			if (_grabbedRoots.Count == 0 && _moving.Count == 0)
			{
				return;
			}
			for (int l = 0; l < _saved.Count; l++)
			{
				FrozenBody frozenBody2 = _saved[l];
				Rigidbody val3 = frozenBody2?.rb;
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				if ((Object)(object)frozenBody2.root != (Object)null && _grabbedRoots.Contains(frozenBody2.root))
				{
					if (!_moving.Contains(((Il2CppObjectBase)val3).Pointer))
					{
						SetRootAnimators(frozenBody2.root, on: true);
					}
					if (val3.isKinematic)
					{
						val3.isKinematic = false;
					}
					val3.useGravity = false;
					_moving.Add(((Il2CppObjectBase)val3).Pointer);
				}
				else if (_moving.Contains(((Il2CppObjectBase)val3).Pointer) || !val3.isKinematic)
				{
					if (_moving.Contains(((Il2CppObjectBase)val3).Pointer))
					{
						SetRootAnimators(frozenBody2.root, on: false);
					}
					val3.isKinematic = true;
					val3.velocity = Vector3.zero;
					val3.angularVelocity = Vector3.zero;
					_moving.Remove(((Il2CppObjectBase)val3).Pointer);
				}
			}
		}

		private void SpawnFlow()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_004d: 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_0071: Expected O, but got Unknown
			//IL_008b: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0152: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Shader val = Shader.Find("Sprites/Default");
				if (!((Object)(object)val == (Object)null))
				{
					if ((Object)(object)_flowPurple == (Object)null)
					{
						_flowPurple = new Material(val);
						_flowPurple.color = new Color(0.5f, 0.25f, 1f, 0.55f);
					}
					if ((Object)(object)_flowBlue == (Object)null)
					{
						_flowBlue = new Material(val);
						_flowBlue.color = new Color(0.75f, 0.75f, 1f, 0.5f);
					}
					Vector3 val2 = (((Object)(object)_cam != (Object)null) ? ((Component)_cam).transform.position : Vector3.zero);
					for (int i = 0; i < 28; i++)
					{
						GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
						Object.Destroy((Object)(object)val3.GetComponent<Collider>());
						((Object)val3).name = "TimeStopFlow";
						float num = (float)i * 0.79f;
						Vector3 val4 = new Vector3(Mathf.Cos(num), Random.Range(-0.15f, 0.85f), Mathf.Sin(num));
						Vector3 normalized = ((Vector3)(ref val4)).normalized;
						val3.transform.position = val2 + normalized * 0.25f;
						val3.transform.localScale = new Vector3(0.02f, Random.Range(0.09f, 0.2f), 0.02f);
						val3.transform.rotation = Quaternion.LookRotation(normalized);
						val3.GetComponent<Renderer>().sharedMaterial = ((i % 2 == 0) ? _flowPurple : _flowBlue);
						_flow.Add(new FlowParticle
						{
							tr = val3.transform,
							mat = ((i % 2 == 0) ? _flowPurple : _flowBlue),
							vel = normalized * Random.Range(1.2f, 3f),
							life = Random.Range(0.8f, 1.4f)
						});
					}
				}
			}
			catch (Exception ex)
			{
				Write("flow failed " + ex.Message);
			}
		}

		private void UpdateFlow(float dt)
		{
			//IL_0082: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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)
			for (int num = _flow.Count - 1; num >= 0; num--)
			{
				FlowParticle flowParticle = _flow[num];
				if (flowParticle == null || (Object)(object)flowParticle.tr == (Object)null)
				{
					_flow.RemoveAt(num);
				}
				else
				{
					flowParticle.life -= dt;
					if (flowParticle.life <= 0f)
					{
						Object.Destroy((Object)(object)((Component)flowParticle.tr).gameObject);
						_flow.RemoveAt(num);
					}
					else
					{
						Transform tr = flowParticle.tr;
						tr.position += flowParticle.vel * dt;
						flowParticle.tr.localScale = new Vector3(flowParticle.tr.localScale.x * 0.98f, flowParticle.tr.localScale.y * 0.985f, flowParticle.tr.localScale.z * 0.98f);
					}
				}
			}
		}

		private void ClearFlow()
		{
			for (int i = 0; i < _flow.Count; i++)
			{
				if (_flow[i] != null && (Object)(object)_flow[i].tr != (Object)null)
				{
					try
					{
						Object.Destroy((Object)(object)((Component)_flow[i].tr).gameObject);
					}
					catch
					{
					}
				}
			}
			_flow.Clear();
		}

		private void Freeze()
		{
			//IL_010d: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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)
			_saved.Clear();
			_moving.Clear();
			_grabDirty = false;
			_prevHeldRb.Clear();
			_curHeldRb.Clear();
			_rbById.Clear();
			_savedGunFlags.Clear();
			_newComerTimer = 0f;
			_projScanTimer = 0f;
			_projectiles.Clear();
			Il2CppArrayBase<StickHealth> val = Object.FindObjectsOfType<StickHealth>();
			if (val == null)
			{
				return;
			}
			int num = 0;
			for (int i = 0; i < val.Length; i++)
			{
				StickHealth val2 = val[i];
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Transform transform = ((Component)val2).gameObject.transform;
				Il2CppArrayBase<Rigidbody> componentsInChildren = ((Component)transform).GetComponentsInChildren<Rigidbody>(true);
				if (componentsInChildren == null)
				{
					continue;
				}
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					Rigidbody val3 = componentsInChildren[j];
					if (!((Object)(object)val3 == (Object)null) && !IsPlayer(((Component)val3).transform))
					{
						Saved state = new Saved
						{
							kinematic = val3.isKinematic,
							gravity = val3.useGravity,
							velocity = val3.velocity,
							angular = val3.angularVelocity
						};
						_saved.Add(new FrozenBody
						{
							rb = val3,
							root = transform,
							state = state,
							startPos = val3.position
						});
						val3.velocity = Vector3.zero;
						val3.angularVelocity = Vector3.zero;
						val3.useGravity = false;
						val3.isKinematic = true;
						num++;
					}
				}
			}
			_savedScripts.Clear();
			Il2CppArrayBase<BulletManager> val4 = Object.FindObjectsOfType<BulletManager>();
			if (val4 != null)
			{
				for (int k = 0; k < val4.Length; k++)
				{
					BulletManager val5 = val4[k];
					if (!((Object)(object)val5 == (Object)null))
					{
						_savedScripts.Add(new KeyValuePair<Behaviour, bool>((Behaviour)(object)val5, ((Behaviour)val5).enabled));
						((Behaviour)val5).enabled = false;
					}
				}
			}
			Il2CppArrayBase<BulletManagerEnemy> val6 = Object.FindObjectsOfType<BulletManagerEnemy>();
			if (val6 != null)
			{
				for (int l = 0; l < val6.Length; l++)
				{
					BulletManagerEnemy val7 = val6[l];
					if (!((Object)(object)val7 == (Object)null))
					{
						_savedScripts.Add(new KeyValuePair<Behaviour, bool>((Behaviour)(object)val7, ((Behaviour)val7).enabled));
						((Behaviour)val7).enabled = false;
					}
				}
			}
			DisableEnemyAttacks();
			_savedAnimators.Clear();
			for (int m = 0; m < val.Length; m++)
			{
				StickHealth val8 = val[m];
				if ((Object)(object)val8 == (Object)null)
				{
					continue;
				}
				Il2CppArrayBase<Animator> componentsInChildren2 = ((Component)val8).GetComponentsInChildren<Animator>(true);
				if (componentsInChildren2 == null)
				{
					continue;
				}
				for (int n = 0; n < componentsInChildren2.Length; n++)
				{
					Animator val9 = componentsInChildren2[n];
					if (!((Object)(object)val9 == (Object)null))
					{
						_savedAnimators.Add(new KeyValuePair<Animator, float>(val9, val9.speed));
						val9.speed = 0f;
					}
				}
			}
			_frozen = true;
			_audioPausedPrev = AudioListener.pause;
			AudioListener.pause = true;
			SetGray(on: true);
			SpawnFlow();
			SpawnWave();
			if (_soundReady)
			{
				Mci.Play("timestop");
			}
			Write("frozen bodies=" + num);
		}

		private void Unfreeze()
		{
			//IL_0084: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < _saved.Count; i++)
			{
				FrozenBody frozenBody = _saved[i];
				Rigidbody val = frozenBody?.rb;
				if (!((Object)(object)val == (Object)null))
				{
					Saved state = frozenBody.state;
					if (_moving.Contains(((Il2CppObjectBase)val).Pointer))
					{
						val.isKinematic = false;
						val.useGravity = true;
						val.velocity = Vector3.zero;
						val.angularVelocity = Vector3.zero;
					}
					else
					{
						val.isKinematic = state.kinematic;
						val.useGravity = state.gravity;
						val.velocity = state.velocity;
						val.angularVelocity = state.angular;
					}
				}
			}
			_saved.Clear();
			_moving.Clear();
			_grabDirty = false;
			_prevHeldRb.Clear();
			_curHeldRb.Clear();
			_rbById.Clear();
			for (int j = 0; j < _savedScripts.Count; j++)
			{
				Behaviour key = _savedScripts[j].Key;
				if ((Object)(object)key != (Object)null)
				{
					key.enabled = _savedScripts[j].Value;
				}
			}
			_savedScripts.Clear();
			for (int k = 0; k < _savedGunFlags.Count; k++)
			{
				StickGunManager key2 = _savedGunFlags[k].Key;
				if ((Object)(object)key2 != (Object)null)
				{
					key2.isTimeStopped = _savedGunFlags[k].Value;
				}
			}
			_savedGunFlags.Clear();
			for (int l = 0; l < _savedAnimators.Count; l++)
			{
				Animator key3 = _savedAnimators[l].Key;
				if ((Object)(object)key3 != (Object)null)
				{
					key3.speed = _savedAnimators[l].Value;
				}
			}
			_savedAnimators.Clear();
			RestoreProjectiles();
			_frozen = false;
			AudioListener.pause = _audioPausedPrev;
			SetGray(on: false);
			ClearFlow();
			ClearWaves();
			Write("unfrozen");
		}

		private static void Write(string s)
		{
			try
			{
				File.AppendAllText("D:\\BrutalistickVrWork\\Probe\\timestop.log", "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + s + "\n");
			}
			catch
			{
			}
		}
	}
}