Decompiled source of LobCorpItems v0.11.1

plugins/LobCorpItems.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LobCorpItems")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+dbbfa2a388f85e97f52b85e36ab3e52a8a33bedc")]
[assembly: AssemblyProduct("LobCorpItems")]
[assembly: AssemblyTitle("LobCorpItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[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 LobCorpItems
{
	internal class Aspiration : MonoBehaviour
	{
		internal enum Kind
		{
			Heart,
			Notes
		}

		internal class Ticker : MonoBehaviour
		{
			private static Ticker instance;

			private static readonly Dictionary<Aspiration, PhysGrabber> strength = new Dictionary<Aspiration, PhysGrabber>();

			private static float staminaGiven;

			private static readonly Dictionary<Aspiration, float> mineSince = new Dictionary<Aspiration, float>();

			private static readonly Dictionary<Aspiration, float> lastMine = new Dictionary<Aspiration, float>();

			private static Object level;

			private static float levelStart = -999f;

			private static float Bonus => 0.2f * (float)Plugin.HeartStrength.Value;

			internal static void Ensure()
			{
				//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)
				//IL_001d: Expected O, but got Unknown
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)instance))
				{
					GameObject val = new GameObject("LobCorpItems Aspiration");
					Object.DontDestroyOnLoad((Object)val);
					((Object)val).hideFlags = (HideFlags)61;
					instance = val.AddComponent<Ticker>();
				}
			}

			internal static void Forget(Aspiration a)
			{
				if (strength.TryGetValue(a, out var value) && Object.op_Implicit((Object)(object)value))
				{
					PhysGrabber obj = value;
					obj.grabStrength -= Bonus;
				}
				strength.Remove(a);
				mineSince.Remove(a);
				lastMine.Remove(a);
			}

			private void Update()
			{
				LevelGenerator val = LevelGenerator.Instance;
				if ((Object)(object)val != level && Object.op_Implicit((Object)(object)val) && val.Generated)
				{
					level = (Object)(object)val;
					levelStart = Time.time;
				}
				All.RemoveAll((Aspiration a) => !Object.op_Implicit((Object)(object)a));
				float num = 0f;
				foreach (Aspiration item in All)
				{
					PlayerAvatar owner = item.Owner;
					if (item.kind == Kind.Heart)
					{
						PhysGrabber val2 = ((Object.op_Implicit((Object)(object)owner) && !owner.deadSet) ? owner.physGrabber : null);
						strength.TryGetValue(item, out var value);
						if ((Object)(object)value != (Object)(object)val2)
						{
							if (Object.op_Implicit((Object)(object)value))
							{
								PhysGrabber obj = value;
								obj.grabStrength -= Bonus;
							}
							if (Object.op_Implicit((Object)(object)val2))
							{
								val2.grabStrength += Bonus;
							}
							if (Object.op_Implicit((Object)(object)val2))
							{
								strength[item] = val2;
							}
							else
							{
								strength.Remove(item);
							}
							if (Object.op_Implicit((Object)(object)val2) && owner.isLocal)
							{
								Tell.Local("Its heartbeat runs into your arms.");
							}
						}
					}
					else if (Object.op_Implicit((Object)(object)owner) && owner.isLocal && !owner.deadSet)
					{
						num += Plugin.NotesStamina.Value;
					}
					Judge(item);
				}
				PlayerController val3 = PlayerController.instance;
				if (Object.op_Implicit((Object)(object)val3) && !Mathf.Approximately(num, staminaGiven))
				{
					val3.EnergyStart += num - staminaGiven;
					if (num > staminaGiven)
					{
						Tell.Local("Your thoughts race. You could run forever.");
					}
					val3.EnergyCurrent = Mathf.Min(val3.EnergyCurrent, val3.EnergyStart);
					staminaGiven = num;
				}
				if (!Object.op_Implicit((Object)(object)val3))
				{
					staminaGiven = 0f;
				}
			}

			private static void Judge(Aspiration a)
			{
				PlayerAvatar val = PlayerAvatar.instance;
				if (!Object.op_Implicit((Object)(object)val) || val.deadSet || val.isDisabled)
				{
					mineSince.Remove(a);
					lastMine.Remove(a);
					return;
				}
				bool mineNow = a.MineNow;
				float time = Time.time;
				if (mineNow)
				{
					if (!mineSince.ContainsKey(a))
					{
						mineSince[a] = time;
						if (Object.op_Implicit((Object)(object)a.grab) && a.grab.grabbedLocal)
						{
							a.Grabbed();
						}
					}
					lastMine[a] = time;
					if (Object.op_Implicit((Object)(object)a.grab) && a.grab.grabbedLocal && Object.op_Implicit((Object)(object)ItemInfoUI.instance) && Tell.ShowingNow == null && SemiFunc.RunIsLevel())
					{
						float value = Plugin.AspirationSeconds.Value;
						float num = Mathf.Max(value - (time - mineSince[a]), value - (time - levelStart));
						if (num > 0f)
						{
							ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, $"Don't let go: {Mathf.CeilToInt(num)}", false);
						}
					}
				}
				else
				{
					if (!lastMine.TryGetValue(a, out var value2) || time - value2 < 0.75f)
					{
						return;
					}
					float value3;
					float num2 = (mineSince.TryGetValue(a, out value3) ? value3 : value2);
					mineSince.Remove(a);
					lastMine.Remove(a);
					if (SemiFunc.RunIsLevel())
					{
						float value4 = Plugin.AspirationSeconds.Value;
						if (value2 - num2 < value4 || value2 - levelStart < value4)
						{
							Tell.Local((a.kind == Kind.Heart) ? "Excessive aspiration brings about frenzy. Its beat stops yours." : "You put them down before your yearning for knowledge was fulfilled.", 5f);
							Died(val, a.kind);
							Plugin.Log.LogInfo((object)$"{Name(a.kind)}: let go {value2 - num2:0.0} s after taking it, {value2 - levelStart:0.0} s into the level; it kills.");
							val.PlayerDeath(-1);
						}
					}
				}
			}
		}

		internal const string HeartPrefab = "Item HeartOfAspiration";

		internal const string NotesPrefab = "Item CrazedResearcherNotes";

		internal const string HeartName = "The Heart of Aspiration";

		internal const string NotesName = "Notes from a Crazed Researcher";

		private const string HeartMesh = "heart";

		private const string ClumpMesh = "heart_clump";

		private const string CoreMesh = "heart_core";

		private const string NotesMesh = "notes";

		private const string BeatSound = "heart_beat";

		private const string PageSound = "notes_page";

		private const string DeathSound = "bracelet_death";

		private static readonly Color CoreGlow = new Color(1f, 0.16f, 0.14f);

		internal Kind kind;

		internal static readonly List<Aspiration> All = new List<Aspiration>();

		internal PhysGrabObject grab;

		internal ItemEquippable equip;

		private Transform model;

		private Transform coreT;

		private Material coreMat;

		private Light glow;

		private AudioSource beat;

		private float phase;

		internal bool Equipped
		{
			get
			{
				if (Object.op_Implicit((Object)(object)equip))
				{
					return equip.isEquipped;
				}
				return false;
			}
		}

		internal PlayerAvatar Owner
		{
			get
			{
				if (!Equipped)
				{
					return null;
				}
				return equip.GetOwnerPlayerAvatar();
			}
		}

		internal bool MineNow
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)grab) || !grab.grabbedLocal)
				{
					if (Equipped && Object.op_Implicit((Object)(object)Owner))
					{
						return Owner.isLocal;
					}
					return false;
				}
				return true;
			}
		}

		internal static void BuildAndRegister()
		{
			Build(Kind.Heart);
			Build(Kind.Notes);
			Ticker.Ensure();
		}

		private static void Build(Kind kind)
		{
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: 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_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			bool flag = kind == Kind.Heart;
			string name = (flag ? "Item HeartOfAspiration" : "Item CrazedResearcherNotes");
			string text = (flag ? "The Heart of Aspiration" : "Notes from a Crazed Researcher");
			GameObject obj = Resources.Load<GameObject>("Items/Item Health Pack Small");
			if (!Object.op_Implicit((Object)(object)obj))
			{
				throw new Exception("Base item \"Items/Item Health Pack Small\" not found. The game may have been updated.");
			}
			Item val = obj.GetComponent<ItemAttributes>()?.item;
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new Exception("\"Items/Item Health Pack Small\" has no Item asset.");
			}
			GameObject val2 = Object.Instantiate<GameObject>(obj, Loot.Holder(name).transform);
			((Object)val2).name = name;
			if (!Object.op_Implicit((Object)(object)val2.GetComponent<ItemEquippable>()))
			{
				Plugin.Log.LogWarning((object)(text + ": its base has no inventory slot support; the boost needs it in the inventory."));
			}
			Material val3 = null;
			ItemHealthPack component = val2.GetComponent<ItemHealthPack>();
			if (Object.op_Implicit((Object)(object)component))
			{
				if (Object.op_Implicit((Object)(object)component.mesh))
				{
					val3 = ((Renderer)component.mesh).sharedMaterial;
				}
				if (Object.op_Implicit((Object)(object)component.propLight) && Object.op_Implicit((Object)(object)component.propLight.lightComponent))
				{
					((Behaviour)component.propLight.lightComponent).enabled = false;
				}
				Object.DestroyImmediate((Object)(object)component);
			}
			Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val4 in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val3) && val4 is MeshRenderer)
				{
					val3 = val4.sharedMaterial;
				}
				val4.enabled = false;
			}
			Light[] componentsInChildren2 = val2.GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Behaviour)componentsInChildren2[i]).enabled = false;
			}
			ParticleSystem[] componentsInChildren3 = val2.GetComponentsInChildren<ParticleSystem>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				MainModule main = componentsInChildren3[i].main;
				((MainModule)(ref main)).playOnAwake = false;
			}
			GameObject val5 = new GameObject(text + " Model")
			{
				layer = val2.layer
			};
			val5.transform.SetParent(val2.transform, false);
			Bounds bounds;
			if (flag)
			{
				Part(val5.transform, "Core", "heart_core", CoreMaterial(text));
				Part(val5.transform, "Clump", "heart_clump", SeeThrough(text + " Clump", Assets.LoadPalette("heart_clump_albedo"), 0.8f, 3000, 0.1f));
				Part(val5.transform, "Heart", "heart", SeeThrough(text, Assets.LoadTexture("heart_albedo"), Plugin.HeartSkinOpacity.Value, 3001, 0.45f));
				Light obj2 = new GameObject("Glow").AddComponent<Light>();
				((Component)obj2).transform.SetParent(val5.transform, false);
				((Component)obj2).transform.localPosition = new Vector3(0f, -0.01f, -0.12f);
				obj2.type = (LightType)2;
				obj2.color = CoreGlow;
				obj2.range = 1.2f;
				obj2.intensity = 0.6f;
				obj2.shadows = (LightShadows)0;
				bounds = Assets.LoadMesh("heart").bounds;
			}
			else
			{
				Part(val5.transform, "Pad", "notes", Assets.MakeMaterial(val3, text, Assets.LoadTexture("notes_albedo"), 0.1f));
				bounds = Assets.LoadMesh("notes").bounds;
			}
			Transform val6 = val2.transform.Find("Semi Box Collider");
			if (Object.op_Implicit((Object)(object)val6))
			{
				Vector3 val7 = (Vector3)(flag ? ((Bounds)(ref bounds)).size : new Vector3(((Bounds)(ref bounds)).size.x, 0.025f, ((Bounds)(ref bounds)).size.z));
				Vector3 localPosition = (Vector3)(flag ? ((Bounds)(ref bounds)).center : new Vector3(((Bounds)(ref bounds)).center.x, 0.0125f, ((Bounds)(ref bounds)).center.z));
				val6.localPosition = localPosition;
				val6.localRotation = Quaternion.identity;
				val6.localScale = Vector3.Max(val7, Vector3.one * 0.05f);
			}
			Loot.FrameIcon(val2, bounds, flag ? 0f : 40f);
			Item val8 = Object.Instantiate<Item>(val);
			((Object)val8).name = name;
			val8.itemName = text;
			val8.itemNameLocalized = null;
			val8.description = (flag ? "A heart without an owner; it still beats. Keep it in your inventory and it lends you its strength. Never let it go too soon." : "Old notes in a mad researcher's hand. Keep them in your inventory and you'll never tire. Never put them down too soon.");
			val8.itemType = (itemType)8;
			Value val9 = ScriptableObject.CreateInstance<Value>();
			((Object)val9).name = "Value - " + text;
			int num = (flag ? Plugin.HeartPriceMin.Value : Plugin.NotesPriceMin.Value);
			int num2 = (flag ? Plugin.HeartPriceMax.Value : Plugin.NotesPriceMax.Value);
			val9.valueMin = (float)num / 4f;
			val9.valueMax = (float)Mathf.Max(num, num2) / 4f;
			val8.value = val9;
			Object.DontDestroyOnLoad((Object)(object)val8);
			Object.DontDestroyOnLoad((Object)(object)val9);
			val2.GetComponent<ItemAttributes>().item = val8;
			val2.AddComponent<Aspiration>().kind = kind;
			if (Items.RegisterItem(val2.GetComponent<ItemAttributes>()) == null)
			{
				throw new Exception("REPOLib refused to register it (see REPOLib errors above).");
			}
		}

		private static void Part(Transform parent, string name, string mesh, Material mat)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			GameObject val = new GameObject(name)
			{
				layer = ((Component)parent).gameObject.layer
			};
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = Assets.LoadMesh(mesh);
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat;
		}

		private static Material SeeThrough(string name, Texture2D tex, float alpha, int queue, float smooth)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_002e: 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_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_0061: 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_0078: 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_008e: 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_00ab: 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_00c3: Expected O, but got Unknown
			Material val = new Material(Shader.Find("Standard"))
			{
				name = name,
				mainTexture = (Texture)(object)tex,
				color = new Color(1f, 1f, 1f, alpha)
			};
			val.SetFloat("_Mode", 2f);
			val.SetInt("_SrcBlend", 5);
			val.SetInt("_DstBlend", 10);
			val.SetInt("_ZWrite", 0);
			val.DisableKeyword("_ALPHATEST_ON");
			val.EnableKeyword("_ALPHABLEND_ON");
			val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
			val.SetOverrideTag("RenderType", "Transparent");
			val.SetFloat("_Glossiness", smooth);
			val.SetFloat("_Metallic", 0f);
			val.renderQueue = queue;
			return val;
		}

		private static Material CoreMaterial(string display)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			Material val = new Material(Shader.Find("Standard"))
			{
				name = display + " Core",
				color = CoreGlow
			};
			val.EnableKeyword("_EMISSION");
			val.SetColor("_EmissionColor", CoreGlow * 3f);
			val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)0;
			return val;
		}

		private void Start()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			grab = ((Component)this).GetComponent<PhysGrabObject>();
			equip = ((Component)this).GetComponent<ItemEquippable>();
			NotValuableObject component = ((Component)this).GetComponent<NotValuableObject>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.hasHealth = false;
			}
			model = ((Component)this).transform.Find(((kind == Kind.Heart) ? "The Heart of Aspiration" : "Notes from a Crazed Researcher") + " Model");
			if (kind == Kind.Heart && Object.op_Implicit((Object)(object)model))
			{
				coreT = model.Find("Core");
				MeshRenderer val = (Object.op_Implicit((Object)(object)coreT) ? ((Component)coreT).GetComponent<MeshRenderer>() : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					coreMat = new Material(((Renderer)val).sharedMaterial);
					((Renderer)val).sharedMaterial = coreMat;
				}
				glow = ((Component)model).GetComponentInChildren<Light>(true);
				beat = Assets.Loop(Assets.LoadSound("heart_beat"), ((Component)this).transform, 0.35f * Plugin.AspirationVolume.Value, 5f);
			}
			if (!All.Contains(this))
			{
				All.Add(this);
			}
			Ticker.Ensure();
		}

		private void OnDestroy()
		{
			All.Remove(this);
			Ticker.Forget(this);
			if (Object.op_Implicit((Object)(object)coreMat))
			{
				Object.Destroy((Object)(object)coreMat);
			}
		}

		private void Update()
		{
			//IL_00c2: 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_00f6: 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)
			Tell.Tick();
			if (kind == Kind.Heart && Object.op_Implicit((Object)(object)model))
			{
				float num = (((Object.op_Implicit((Object)(object)grab) && grab.playerGrabbing.Count > 0) || Equipped) ? 2f : 1f);
				phase += Time.deltaTime * num / 1.34f;
				float num2 = phase % 1f;
				float num3 = Mathf.Exp(0f - Mathf.Pow((num2 - 0.05f) / 0.05f, 2f)) + 0.6f * Mathf.Exp(0f - Mathf.Pow((num2 - 0.22f) / 0.05f, 2f));
				model.localScale = Vector3.one * (1f + 0.05f * num3);
				if (Object.op_Implicit((Object)(object)coreMat))
				{
					coreMat.SetColor("_EmissionColor", CoreGlow * (2.2f + 3f * num3));
				}
				if (Object.op_Implicit((Object)(object)glow))
				{
					glow.intensity = 0.4f + 0.7f * num3;
				}
				if (Object.op_Implicit((Object)(object)beat))
				{
					beat.pitch = num;
					beat.mute = Equipped;
				}
			}
		}

		internal void Grabbed()
		{
			if (kind == Kind.Notes)
			{
				Assets.Play(Assets.LoadSound("notes_page"), ((Component)this).transform, 0.7f * Plugin.AspirationVolume.Value, 8f);
			}
		}

		internal static string Name(Kind k)
		{
			if (k != Kind.Heart)
			{
				return "Notes from a Crazed Researcher";
			}
			return "The Heart of Aspiration";
		}

		internal static void Died(PlayerAvatar me, Kind k)
		{
			Assets.Play(Assets.LoadSound("bracelet_death"), ((Component)me).transform, 0.8f * Plugin.AspirationVolume.Value, 20f);
		}
	}
	internal static class Assets
	{
		private const int SoundRate = 24000;

		private static readonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>();

		private static readonly Dictionary<string, AudioClip> sounds = new Dictionary<string, AudioClip>();

		private static readonly int[] AdpcmSteps = new int[89]
		{
			7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
			19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
			50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
			130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
			337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
			876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
			2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
			5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
			15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
		};

		private static readonly int[] AdpcmIndex = new int[8] { -1, -1, -1, -1, 2, 4, 6, 8 };

		private static AudioMixerGroup mixer;

		private static AudioMixerGroup Mixer
		{
			get
			{
				if (Object.op_Implicit((Object)(object)mixer) || !Object.op_Implicit((Object)(object)AudioManager.instance) || !Object.op_Implicit((Object)(object)AudioManager.instance.SoundMasterGroup))
				{
					return mixer;
				}
				AudioMixerGroup[] array = AudioManager.instance.SoundMasterGroup.audioMixer.FindMatchingGroups("Sound Effects");
				mixer = ((array.Length != 0) ? array[0] : AudioManager.instance.SoundMasterGroup);
				return mixer;
			}
		}

		internal static byte[] Bytes(string name)
		{
			using Stream stream = typeof(Assets).Assembly.GetManifestResourceStream("LobCorpItems." + name);
			if (stream == null)
			{
				throw new FileNotFoundException("Embedded asset missing: " + name);
			}
			byte[] array = new byte[stream.Length];
			for (int i = 0; i < array.Length; i += stream.Read(array, i, array.Length - i))
			{
			}
			return array;
		}

		internal static Mesh LoadMesh(string name)
		{
			//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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			if (meshes.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			byte[] array = Bytes(name + ".mesh");
			int num = BitConverter.ToInt32(array, 0);
			int num2 = BitConverter.ToInt32(array, 4);
			int num3 = 8;
			Vector3[] array2 = (Vector3[])(object)new Vector3[num];
			Vector3[] array3 = (Vector3[])(object)new Vector3[num];
			Vector2[] array4 = (Vector2[])(object)new Vector2[num];
			int[] array5 = new int[num2];
			int num4 = 0;
			while (num4 < num)
			{
				array2[num4] = new Vector3(F(array, num3), F(array, num3 + 4), F(array, num3 + 8));
				num4++;
				num3 += 12;
			}
			int num5 = 0;
			while (num5 < num)
			{
				array3[num5] = new Vector3(F(array, num3), F(array, num3 + 4), F(array, num3 + 8));
				num5++;
				num3 += 12;
			}
			int num6 = 0;
			while (num6 < num)
			{
				array4[num6] = new Vector2(F(array, num3), F(array, num3 + 4));
				num6++;
				num3 += 8;
			}
			int num7 = 0;
			while (num7 < num2)
			{
				array5[num7] = BitConverter.ToInt32(array, num3);
				num7++;
				num3 += 4;
			}
			Mesh val = new Mesh
			{
				name = name
			};
			if (num > 65535)
			{
				val.indexFormat = (IndexFormat)1;
			}
			val.vertices = array2;
			val.normals = array3;
			val.uv = array4;
			val.triangles = array5;
			val.RecalculateBounds();
			return meshes[name] = val;
		}

		private static float F(byte[] b, int o)
		{
			return BitConverter.ToSingle(b, o);
		}

		internal static Texture2D LoadTexture(string name)
		{
			//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_002d: Expected O, but got Unknown
			//IL_002f: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true)
			{
				name = name,
				wrapMode = (TextureWrapMode)1
			};
			ImageConversion.LoadImage(val, Bytes(name + ".png"));
			return val;
		}

		internal static Texture2D LoadPalette(string name)
		{
			//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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0036: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				name = name,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)0
			};
			ImageConversion.LoadImage(val, Bytes(name + ".png"));
			return val;
		}

		internal static AudioClip LoadSound(string name)
		{
			if (sounds.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			float[] array;
			if (Has(name + ".adpcm"))
			{
				array = Adpcm(Bytes(name + ".adpcm"));
			}
			else
			{
				byte[] array2 = Bytes(name + ".pcm");
				array = new float[array2.Length / 2];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = (float)BitConverter.ToInt16(array2, i * 2) / 32768f;
				}
			}
			value = AudioClip.Create(name, array.Length, 1, 24000, false);
			value.SetData(array, 0);
			return sounds[name] = value;
		}

		private static bool Has(string name)
		{
			return typeof(Assets).Assembly.GetManifestResourceInfo("LobCorpItems." + name) != null;
		}

		private static float[] Adpcm(byte[] b)
		{
			int num = BitConverter.ToInt32(b, 0);
			float[] array = new float[num];
			int num2 = 0;
			int num3 = 0;
			for (int i = 0; i < num; i++)
			{
				int num4 = (b[4 + (i >> 1)] >> (i & 1) * 4) & 0xF;
				int num5 = AdpcmSteps[num3];
				int num6 = num5 >> 3;
				if ((num4 & 4) != 0)
				{
					num6 += num5;
				}
				if ((num4 & 2) != 0)
				{
					num6 += num5 >> 1;
				}
				if ((num4 & 1) != 0)
				{
					num6 += num5 >> 2;
				}
				num2 = Mathf.Clamp(((num4 & 8) != 0) ? (num2 - num6) : (num2 + num6), -32768, 32767);
				num3 = Mathf.Clamp(num3 + AdpcmIndex[num4 & 7], 0, 88);
				array[i] = (float)num2 / 32768f;
			}
			return array;
		}

		private static AudioSource Source(string label, AudioClip clip, Transform parent, float volume, float maxDistance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("LobCorpItems " + label + " " + (Object.op_Implicit((Object)(object)clip) ? ((Object)clip).name : "?"));
			val.transform.SetParent(parent, false);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.clip = clip;
			obj.volume = volume;
			obj.spatialBlend = 1f;
			obj.rolloffMode = (AudioRolloffMode)1;
			obj.minDistance = 1.5f;
			obj.maxDistance = maxDistance;
			obj.dopplerLevel = 0f;
			obj.outputAudioMixerGroup = Mixer;
			return obj;
		}

		internal static void Play(AudioClip clip, Transform follow, float volume = 1f, float maxDistance = 15f)
		{
			if (Object.op_Implicit((Object)(object)clip))
			{
				AudioSource obj = Source("Sound", clip, follow, volume, maxDistance);
				obj.Play();
				Object.Destroy((Object)(object)((Component)obj).gameObject, clip.length + 0.2f);
			}
		}

		internal static AudioSource Loop(AudioClip clip, Transform follow, float volume = 1f, float maxDistance = 15f)
		{
			AudioSource val = Source("Loop", clip, follow, volume, maxDistance);
			val.loop = true;
			if (Object.op_Implicit((Object)(object)clip))
			{
				val.time = Random.Range(0f, clip.length);
				val.Play();
			}
			return val;
		}

		internal static Material MakeMaterial(Material baseMat, string name, Texture2D albedo, float smoothness = 0.15f)
		{
			//IL_001a: 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_0020: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			Material val = (Object.op_Implicit((Object)(object)baseMat) ? new Material(baseMat) : new Material(Shader.Find("Standard")));
			((Object)val).name = name;
			string[] array = new string[4] { "_BaseTexture", "_MainTex", "_BaseMap", "_AlbedoTexture" };
			foreach (string text in array)
			{
				if (val.HasProperty(text))
				{
					val.SetTexture(text, (Texture)(object)albedo);
				}
			}
			array = new string[2] { "_NormalTexture", "_BumpMap" };
			foreach (string text2 in array)
			{
				if (val.HasProperty(text2))
				{
					val.SetTexture(text2, (Texture)null);
				}
			}
			array = new string[3] { "_BaseColor", "_Color", "_AlbedoColor" };
			foreach (string text3 in array)
			{
				if (val.HasProperty(text3))
				{
					val.SetColor(text3, Color.white);
				}
			}
			array = new string[4] { "_MetallicTexture", "_SmoothnessTexture", "_MetallicGlossMap", "_SpecGlossMap" };
			foreach (string text4 in array)
			{
				if (val.HasProperty(text4))
				{
					val.SetTexture(text4, (Texture)null);
				}
			}
			val.DisableKeyword("_METALLICGLOSSMAP");
			val.DisableKeyword("_SPECGLOSSMAP");
			val.DisableKeyword("_NORMALMAP");
			if (val.HasProperty("_SmoothnessTextureChannel"))
			{
				val.SetFloat("_SmoothnessTextureChannel", 0f);
			}
			if (val.HasProperty("_GlossMapScale"))
			{
				val.SetFloat("_GlossMapScale", 1f);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0f);
			}
			array = new string[2] { "_Smoothness", "_Glossiness" };
			foreach (string text5 in array)
			{
				if (val.HasProperty(text5))
				{
					val.SetFloat(text5, smoothness);
				}
			}
			if (val.HasProperty("_EmissionColor"))
			{
				val.SetColor("_EmissionColor", Color.black);
			}
			if (val.HasProperty("_EmissionTexture"))
			{
				val.SetTexture("_EmissionTexture", (Texture)null);
			}
			if (val.HasProperty("_TilingX"))
			{
				val.SetFloat("_TilingX", 1f);
				val.SetFloat("_TilingY", 1f);
			}
			if (val.HasProperty("_OffsetX"))
			{
				val.SetFloat("_OffsetX", 0f);
				val.SetFloat("_OffsetY", 0f);
			}
			return val;
		}
	}
	internal class BackwardClock : MonoBehaviour
	{
		internal class Screen : MonoBehaviour
		{
			private static Screen instance;

			private RawImage streaks;

			private RawImage white;

			private float energy;

			private float flashAt = -1f;

			private static Screen Get()
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				//IL_0096: 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)
				if (Object.op_Implicit((Object)(object)instance))
				{
					return instance;
				}
				GameObject val = new GameObject("LobCorpItems Clock Screen");
				Canvas obj = val.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 29000;
				instance = val.AddComponent<Screen>();
				instance.streaks = Layer(val.transform, (Texture)(object)Assets.LoadTexture("clock_flash"));
				instance.white = Layer(val.transform, (Texture)(object)Texture2D.whiteTexture);
				((Graphic)instance.streaks).color = new Color(1f, 1f, 1f, 0f);
				((Graphic)instance.white).color = new Color(1f, 0.97f, 0.9f, 0f);
				return instance;
			}

			private static RawImage Layer(Transform parent, Texture tex)
			{
				//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_0032: 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_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_004e: 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)
				GameObject val = new GameObject(((Object)tex).name);
				val.transform.SetParent(parent, false);
				RawImage obj = val.AddComponent<RawImage>();
				obj.texture = tex;
				((Graphic)obj).raycastTarget = false;
				RectTransform rectTransform = ((Graphic)obj).rectTransform;
				rectTransform.anchorMin = Vector2.zero;
				rectTransform.anchorMax = Vector2.one;
				Vector2 offsetMin = (rectTransform.offsetMax = Vector2.zero);
				rectTransform.offsetMin = offsetMin;
				return obj;
			}

			internal static void Energy(float a)
			{
				Get().energy = a;
			}

			internal static void Flash()
			{
				Get().flashAt = Time.time;
			}

			private void Update()
			{
				//IL_007e: 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_00ae: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
				float num = energy;
				float num2 = 0f;
				if (flashAt >= 0f)
				{
					float num3 = Time.time - flashAt;
					num = Mathf.Clamp01(0.55f + num3 * 1.5f);
					num2 = Mathf.Clamp01((num3 - 0.3f) / 1.1f);
					if (Object.op_Implicit((Object)(object)PlayerController.instance))
					{
						PlayerController.instance.InputDisable(0.2f);
					}
				}
				((Graphic)streaks).color = new Color(1f, 1f, 1f, num);
				((Graphic)white).color = new Color(1f, 0.97f, 0.9f, num2);
				Rect uvRect = streaks.uvRect;
				((Rect)(ref uvRect)).x = ((Rect)(ref uvRect)).x - Time.deltaTime * (0.15f + num * 0.6f);
				((Rect)(ref uvRect)).y = ((Rect)(ref uvRect)).y + Time.deltaTime * 0.03f;
				streaks.uvRect = uvRect;
			}
		}

		internal class Fate : MonoBehaviour
		{
			private static Fate instance;

			private string steamId;

			private bool isMe;

			private int startScene;

			private bool arrived;

			private float arrivedAt;

			private bool done;

			private int levelScene;

			internal static bool ThisLevel
			{
				get
				{
					if (Object.op_Implicit((Object)(object)instance))
					{
						return instance.arrived;
					}
					return false;
				}
			}

			internal static void Begin(PlayerAvatar cranker, bool me)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)instance))
				{
					Object.Destroy((Object)(object)((Component)instance).gameObject);
				}
				GameObject val = new GameObject("LobCorpItems Clock Fate");
				Object.DontDestroyOnLoad((Object)val);
				instance = val.AddComponent<Fate>();
				instance.steamId = (Object.op_Implicit((Object)(object)cranker) ? cranker.steamID : null);
				instance.isMe = me;
				Fate fate = instance;
				Scene activeScene = SceneManager.GetActiveScene();
				fate.startScene = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle);
			}

			private void Update()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				Scene activeScene = SceneManager.GetActiveScene();
				int num = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle);
				if (!arrived)
				{
					if (num != startScene && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated)
					{
						if (!SemiFunc.RunIsLevel())
						{
							Object.Destroy((Object)(object)((Component)this).gameObject);
							return;
						}
						arrived = true;
						arrivedAt = Time.time;
						levelScene = num;
					}
					return;
				}
				if (num != levelScene)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
				PlayerAvatar val = PlayerAvatar.instance;
				if (isMe && !done && Object.op_Implicit((Object)(object)val) && val.spawned && Time.time - arrivedAt > 3f)
				{
					done = true;
					if (!val.deadSet)
					{
						Tell.Local("You stayed behind.", 5f);
						val.PlayerDeath(-1);
					}
				}
				if (!Object.op_Implicit((Object)(object)GameDirector.instance))
				{
					return;
				}
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (!Object.op_Implicit((Object)(object)player) || !player.deadSet || !Object.op_Implicit((Object)(object)player.playerDeathHead))
					{
						continue;
					}
					bool num2;
					if (!isMe)
					{
						if (string.IsNullOrEmpty(steamId))
						{
							continue;
						}
						num2 = player.steamID == steamId;
					}
					else
					{
						num2 = (Object)(object)player == (Object)(object)val;
					}
					if (num2 && ((Component)player.playerDeathHead).gameObject.activeSelf)
					{
						((Component)player.playerDeathHead).gameObject.SetActive(false);
					}
				}
			}

			private void OnDestroy()
			{
				if ((Object)(object)instance == (Object)(object)this)
				{
					instance = null;
				}
			}
		}

		internal const string LootName = "Valuable BackwardClock";

		internal const string DisplayName = "Backward Clock";

		private const string Mesh = "clock";

		private const string CrankMesh = "clock_crank";

		private const string TubeMesh = "clock_tube";

		private const string Tick = "clock_tick";

		private const string Light = "clock_light";

		private const string Start_ = "clock_start";

		private const string Loop = "clock_loop";

		private const string Rewind = "clock_rewind";

		private const string Finish = "clock_finish";

		private const string Streak = "clock_streak";

		private const string FlashTex = "clock_flash";

		private const int Cranks = 4;

		private static readonly float[] TubeX = new float[4] { 0.24f, 0.08f, -0.08f, -0.24f };

		private const float TubeFoot = 0.469f;

		private static readonly Vector3 Pivot = new Vector3(-0.434f, 0.27f, 0f);

		private static readonly Color Amber = new Color(1f, 0.62f, 0.2f);

		private const float Scale = 2.5f;

		private PhysGrabObject grab;

		private PhotonView view;

		private Transform crank;

		private MeshRenderer[] tubes = (MeshRenderer[])(object)new MeshRenderer[4];

		private MeshRenderer[] digits = (MeshRenderer[])(object)new MeshRenderer[4];

		private Light[] glows = (Light[])(object)new Light[4];

		private Material glassMat;

		private Material litMat;

		private AudioSource tick;

		private AudioSource hum;

		private int turned;

		private bool charging;

		private bool spent;

		private float crankSpin;

		private float lastCrank = -9f;

		private float chargeStart;

		private int counter;

		private float counterAt;

		private ParticleSystem energy;

		private Light roomGlow;

		private static Mesh quad;

		private static Transform CameraT
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)CameraUtils.Instance) || !Object.op_Implicit((Object)(object)CameraUtils.Instance.MainCamera))
				{
					if (!Object.op_Implicit((Object)(object)Camera.main))
					{
						return null;
					}
					return ((Component)Camera.main).transform;
				}
				return ((Component)CameraUtils.Instance.MainCamera).transform;
			}
		}

		internal static void BuildAndRegister()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_004e: 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_007e: 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_010b: 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_014c: 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_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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			Material baseMat;
			BoxCollider box;
			GameObject val = Loot.CloneValuable(Loot.Big, "Valuable BackwardClock", out baseMat, out box);
			Loot.Mass(val, 5f);
			GameObject val2 = new GameObject("Backward Clock Model")
			{
				layer = val.layer
			};
			val2.transform.SetParent(val.transform, false);
			val2.transform.localScale = Vector3.one * 2.5f;
			Part(val2.transform, "Cabinet", "clock", baseMat, val.layer, 0.35f, Vector3.zero);
			Part(val2.transform, "Crank", "clock_crank", baseMat, val.layer, 0.5f, Pivot);
			Material sharedMaterial = Assets.MakeMaterial(baseMat, "Backward Clock Glass", Assets.LoadPalette("clock_tube_albedo"), 0.85f);
			for (int i = 0; i < TubeX.Length; i++)
			{
				((Renderer)Part(val2.transform, "Tube " + i, "clock_tube", null, val.layer, 0f, new Vector3(TubeX[i], 0.469f, 0f)).GetComponent<MeshRenderer>()).sharedMaterial = sharedMaterial;
			}
			Loot.FitBox(box, new Bounds(new Vector3(0f, 0.22f, 0f) * 2.5f, new Vector3(0.9f, 0.44f, 0.43f) * 2.5f));
			Loot.AddBox(box, new Bounds(new Vector3(0f, 0.58f, 0f) * 2.5f, new Vector3(0.9f, 0.3f, 0.32f) * 2.5f));
			Loot.SetValue(val, (Type)6, Plugin.ClockValueMin.Value, Plugin.ClockValueMax.Value, "Backward Clock");
			val.AddComponent<BackwardClock>();
			Loot.Register(val, Plugin.ClockSpawns.Value);
		}

		private static GameObject Part(Transform parent, string name, string mesh, Material baseMat, int layer, float smooth, Vector3 at)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			GameObject val = new GameObject(name)
			{
				layer = layer
			};
			val.transform.SetParent(parent, false);
			val.transform.localPosition = at;
			val.AddComponent<MeshFilter>().sharedMesh = Assets.LoadMesh(mesh);
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			if (Object.op_Implicit((Object)(object)baseMat))
			{
				((Renderer)val2).sharedMaterial = Assets.MakeMaterial(baseMat, "Backward Clock " + name, Assets.LoadPalette(mesh + "_albedo"), smooth);
			}
			return val;
		}

		private void Start()
		{
			//IL_009c: 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_00db: 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_0151: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			grab = ((Component)this).GetComponent<PhysGrabObject>();
			view = ((Component)this).GetComponent<PhotonView>();
			Transform val = ((Component)this).transform.Find("Backward Clock Model");
			crank = (Object.op_Implicit((Object)(object)val) ? val.Find("Crank") : null);
			for (int i = 0; i < 4; i++)
			{
				Transform val2 = (Object.op_Implicit((Object)(object)val) ? val.Find("Tube " + i) : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					tubes[i] = ((Component)val2).GetComponent<MeshRenderer>();
					digits[i] = DigitQuad(val2);
					Light val3 = new GameObject("Glow").AddComponent<Light>();
					((Component)val3).transform.SetParent(val2, false);
					((Component)val3).transform.localPosition = new Vector3(0f, 0.09f, 0.08f);
					val3.type = (LightType)2;
					val3.color = Amber;
					val3.range = 1.75f;
					val3.intensity = 1.4f;
					((Behaviour)val3).enabled = false;
					glows[i] = val3;
				}
			}
			glassMat = (Object.op_Implicit((Object)(object)tubes[0]) ? ((Renderer)tubes[0]).sharedMaterial : null);
			if (Object.op_Implicit((Object)(object)glassMat))
			{
				Texture2D val4 = new Texture2D(4, 4);
				Color[] array = (Color[])(object)new Color[16];
				for (int j = 0; j < 16; j++)
				{
					array[j] = new Color(1f, 0.72f, 0.36f);
				}
				val4.SetPixels(array);
				val4.Apply();
				litMat = Assets.MakeMaterial(glassMat, "Backward Clock Lit Glass", val4, 0.9f);
			}
			tick = Assets.Loop(Assets.LoadSound("clock_tick"), ((Component)this).transform, Plugin.ClockVolume.Value * 0.6f, 8f);
			counter = Random.Range(1000, 10000);
			counterAt = Time.time;
			Show();
		}

		private MeshRenderer DigitQuad(Transform tube)
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0024: Expected O, but got Unknown
			//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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00c4: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)quad))
			{
				quad = new Mesh
				{
					name = "Clock Digit"
				};
				float num = 0.034f;
				float num2 = 0.046f;
				quad.vertices = (Vector3[])(object)new Vector3[4]
				{
					new Vector3(0f - num, 0f - num2),
					new Vector3(num, 0f - num2),
					new Vector3(num, num2),
					new Vector3(0f - num, num2)
				};
				quad.uv = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(1f, 0f),
					new Vector2(0f, 0f),
					new Vector2(0f, 1f),
					new Vector2(1f, 1f)
				};
				quad.triangles = new int[12]
				{
					0, 2, 1, 0, 3, 2, 0, 1, 2, 0,
					2, 3
				};
				quad.RecalculateNormals();
				quad.RecalculateBounds();
			}
			GameObject val = new GameObject("Digit")
			{
				layer = ((Component)tube).gameObject.layer
			};
			val.transform.SetParent(tube, false);
			val.transform.localPosition = new Vector3(0f, 0.08f, 0.05f);
			val.AddComponent<MeshFilter>().sharedMesh = quad;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).sharedMaterial = Fx.Mat("clock_d0");
			((Renderer)obj).enabled = false;
			return obj;
		}

		private static string Hint(int n)
		{
			if (n < 4)
			{
				return $"Crank ({n}/{4}) <color=#FFFFFF>[" + SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>") + "]</color>";
			}
			return "";
		}

		private void Update()
		{
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			Tell.Tick();
			Loot.HoldUpright(grab);
			bool flag = spent || Fate.ThisLevel;
			if (Object.op_Implicit((Object)(object)grab) && grab.grabbedLocal && Object.op_Implicit((Object)(object)ItemInfoUI.instance) && Tell.ShowingNow == null && !charging)
			{
				ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, flag ? "It has stopped." : Hint(turned), false);
			}
			if (!flag && !charging && SemiFunc.RunIsLevel() && Object.op_Implicit((Object)(object)grab) && grab.grabbedLocal && SemiFunc.InputDown((InputKey)2) && Object.op_Implicit((Object)(object)PlayerAvatar.instance) && !PlayerAvatar.instance.deadSet && Time.time - lastCrank > 1.2f)
			{
				lastCrank = Time.time;
				int num = (Object.op_Implicit((Object)(object)PlayerAvatar.instance.photonView) ? PlayerAvatar.instance.photonView.ViewID : (-1));
				if (SemiFunc.IsMultiplayer() && Object.op_Implicit((Object)(object)view))
				{
					view.RPC("CrankRPC", (RpcTarget)2, new object[1] { num });
				}
				else
				{
					CrankRPC(num);
				}
			}
			if (Object.op_Implicit((Object)(object)crank) && crankSpin > 0f)
			{
				float num2 = Mathf.Min(crankSpin, 400f * Time.deltaTime);
				crank.Rotate(Vector3.right, 0f - num2, (Space)1);
				crankSpin -= num2;
			}
			float num3 = (charging ? Mathf.Lerp(0.25f, 0.02f, (Time.time - chargeStart) / Plugin.ClockChargeSeconds.Value) : 1f);
			if (Time.time - counterAt > num3)
			{
				counterAt = Time.time;
				counter = ((counter <= 0) ? 9999 : (counter - 1));
				Show();
			}
			if (charging)
			{
				Charge();
			}
		}

		private void Show()
		{
			bool flag = spent || Fate.ThisLevel;
			for (int i = 0; i < 4; i++)
			{
				if (!Object.op_Implicit((Object)(object)tubes[i]))
				{
					continue;
				}
				bool flag2 = !flag && (i < turned || charging);
				((Renderer)tubes[i]).sharedMaterial = ((flag2 && Object.op_Implicit((Object)(object)litMat)) ? litMat : glassMat);
				if (Object.op_Implicit((Object)(object)glows[i]))
				{
					((Behaviour)glows[i]).enabled = flag2;
				}
				if (Object.op_Implicit((Object)(object)digits[i]))
				{
					((Renderer)digits[i]).enabled = flag2;
					int num = counter / (int)Mathf.Pow(10f, (float)(3 - i)) % 10;
					if (flag2)
					{
						((Renderer)digits[i]).sharedMaterial = Fx.Mat("clock_d" + num);
					}
				}
			}
		}

		[PunRPC]
		public void CrankRPC(int who)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && !spent && !charging && !Fate.ThisLevel && turned < 4)
			{
				int num = turned + 1;
				if (SemiFunc.IsMultiplayer() && Object.op_Implicit((Object)(object)view))
				{
					view.RPC("TurnedRPC", (RpcTarget)0, new object[2] { num, who });
				}
				else
				{
					TurnedRPC(num, who);
				}
			}
		}

		[PunRPC]
		public void TurnedRPC(int n, int who)
		{
			turned = n;
			crankSpin += 360f;
			Assets.Play(Assets.LoadSound("clock_light"), ((Component)this).transform, Plugin.ClockVolume.Value, 14f);
			Show();
			if (n >= 4)
			{
				((MonoBehaviour)this).StartCoroutine(Wind(who));
			}
		}

		private IEnumerator Wind(int who)
		{
			charging = true;
			chargeStart = Time.time;
			PlayerAvatar cranker = WhoIs(who);
			bool me = Object.op_Implicit((Object)(object)cranker) && (Object)(object)cranker == (Object)(object)PlayerAvatar.instance;
			if (me)
			{
				Tell.Local("The hands begin to turn backwards.", 4f);
			}
			Assets.Play(Assets.LoadSound("clock_start"), ((Component)this).transform, Plugin.ClockVolume.Value, 30f);
			if (Object.op_Implicit((Object)(object)tick))
			{
				tick.Stop();
			}
			hum = Assets.Loop(Assets.LoadSound("clock_loop"), ((Component)this).transform, Plugin.ClockVolume.Value, 30f);
			yield return (object)new WaitForSeconds(1.2f);
			Assets.Play(Assets.LoadSound("clock_rewind"), ((Component)this).transform, Plugin.ClockVolume.Value, 30f);
			Energy();
			float t = Plugin.ClockChargeSeconds.Value - 1.2f;
			yield return (object)new WaitForSeconds(Mathf.Max(t - 2.9f, 0.5f));
			Assets.Play(Assets.LoadSound("clock_rewind"), ((Component)this).transform, Plugin.ClockVolume.Value, 30f);
			yield return (object)new WaitForSeconds(Mathf.Min(2.9f, t));
			charging = false;
			spent = true;
			Fate.Begin(cranker, me);
			if (Object.op_Implicit((Object)(object)hum))
			{
				hum.Stop();
			}
			Assets.Play(Assets.LoadSound("clock_finish"), CameraT, Plugin.ClockVolume.Value, 10f);
			Screen.Flash();
			if (Object.op_Implicit((Object)(object)energy))
			{
				energy.Stop();
			}
			yield return (object)new WaitForSeconds(1.6f);
			if (SemiFunc.IsMasterClientOrSingleplayer() && Object.op_Implicit((Object)(object)RunManager.instance) && SemiFunc.RunIsLevel())
			{
				Plugin.Log.LogInfo((object)"Backward Clock: the level goes back to its start.");
				RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)0);
			}
		}

		private static PlayerAvatar WhoIs(int viewId)
		{
			if (viewId < 0)
			{
				return null;
			}
			PhotonView val = PhotonView.Find(viewId);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return ((Component)val).GetComponent<PlayerAvatar>();
		}

		private void Energy()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01bb: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: 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_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Backward Clock Energy");
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = new Vector3(0f, 1.5f, 0f);
			energy = val.AddComponent<ParticleSystem>();
			energy.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = energy.main;
			((MainModule)(ref main)).duration = 30f;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.4f, 2.6f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(0f, 0.3f);
			((MainModule)(ref main)).startSize3D = true;
			((MainModule)(ref main)).startSizeX = new MinMaxCurve(0.8f, 1.8f);
			((MainModule)(ref main)).startSizeY = new MinMaxCurve(0.15f, 0.35f);
			((MainModule)(ref main)).startSizeZ = MinMaxCurve.op_Implicit(1f);
			((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, MathF.PI * 2f);
			((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.85f, 0.55f, 0.9f), new Color(1f, 0.95f, 0.85f, 0.6f));
			((MainModule)(ref main)).maxParticles = 600;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			EmissionModule emission = energy.emission;
			((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(20f);
			ShapeModule shape = energy.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 4f;
			((ShapeModule)(ref shape)).radiusThickness = 0.4f;
			VelocityOverLifetimeModule velocityOverLifetime = energy.velocityOverLifetime;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalX = new MinMaxCurve(0f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalZ = new MinMaxCurve(0f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalY = new MinMaxCurve(1.2f, 2.2f);
			((VelocityOverLifetimeModule)(ref velocityOverLifetime)).radial = new MinMaxCurve(-1.2f, -0.4f);
			RotationOverLifetimeModule rotationOverLifetime = energy.rotationOverLifetime;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
			((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = new MinMaxCurve(-1.5f, 1.5f);
			ColorOverLifetimeModule colorOverLifetime = energy.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(1f, 0.25f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).sharedMaterial = Fx.Mat("clock_streak");
			energy.Play();
			roomGlow = new GameObject("Glow").AddComponent<Light>();
			((Component)roomGlow).transform.SetParent(val.transform, false);
			roomGlow.type = (LightType)2;
			roomGlow.color = new Color(1f, 0.8f, 0.5f);
			roomGlow.range = 9f;
			roomGlow.intensity = 0f;
		}

		private void Charge()
		{
			//IL_0030: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp01((Time.time - chargeStart) / Plugin.ClockChargeSeconds.Value);
			if (Object.op_Implicit((Object)(object)energy))
			{
				EmissionModule emission = energy.emission;
				((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(Mathf.Lerp(20f, 260f, num * num));
			}
			if (Object.op_Implicit((Object)(object)roomGlow))
			{
				roomGlow.intensity = Mathf.Lerp(0.5f, 6f, num) * (0.85f + 0.15f * Mathf.Sin(Time.time * 23f));
			}
			if (Object.op_Implicit((Object)(object)hum))
			{
				hum.pitch = 1f + num * 0.4f;
			}
			Transform cameraT = CameraT;
			float num2 = (Object.op_Implicit((Object)(object)cameraT) ? (1f - Mathf.Clamp01(Vector3.Distance(cameraT.position, ((Component)this).transform.position) / 12f)) : 0f);
			Screen.Energy(num * num2 * 0.55f);
			if (num > 0.6f && num2 > 0.3f && Object.op_Implicit((Object)(object)CameraGlitch.Instance) && Random.value < 0.01f)
			{
				CameraGlitch.Instance.PlayShort();
			}
		}
	}
	internal class Bald : MonoBehaviour
	{
		private enum Form
		{
			Bald,
			Balding,
			NotBald
		}

		private class Fade : MonoBehaviour
		{
			internal Light light;

			private float start;

			private float t0;

			private void Start()
			{
				t0 = Time.time;
				start = (Object.op_Implicit((Object)(object)light) ? light.intensity : 0f);
			}

			private void Update()
			{
				if (Object.op_Implicit((Object)(object)light))
				{
					light.intensity = start * Mathf.Clamp01(1f - (Time.time - t0) / 2f);
				}
			}
		}

		internal const string LootName = "Valuable Bald";

		internal const string DisplayName = "You're Bald...";

		private const string Mesh = "bald";

		private const string Sound = "bald_special";

		private const string Sparkle = "bald_sparkle";

		private const string Glow = "bald_glow";

		private static readonly string[] Faces = new string[3] { "bald_bald", "bald_balding", "bald_notbald" };

		private const float Radius = 0.17f;

		private const float Height = 0.34f;

		private static readonly CosmeticType[] HairTypes = (CosmeticType[])(object)new CosmeticType[3]
		{
			default(CosmeticType),
			(CosmeticType)5,
			(CosmeticType)24
		};

		private static Material[] faceMats;

		private PhysGrabObject grab;

		private Collider[] mine;

		private Transform model;

		private MeshRenderer face;

		private float bobPhase;

		private float working;

		private float spin;

		private bool started;

		private bool wasAllBald;

		private bool shavedSomeone;

		private readonly Dictionary<PlayerAvatar, bool> hadHair = new Dictionary<PlayerAvatar, bool>();

		private static string hint;

		private float calledUntil;

		private float nextCall;

		private Vector3 Middle
		{
			get
			{
				//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_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_0013: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)model))
				{
					return ((Component)this).transform.position;
				}
				return model.position + Vector3.up * 0.17f;
			}
		}

		private static string Hint => hint ?? (hint = "Bald is awesome! <color=#FFFFFF>[" + SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>") + "]</color>");

		private bool Held
		{
			get
			{
				if (Object.op_Implicit((Object)(object)grab))
				{
					return grab.playerGrabbing.Count > 0;
				}
				return false;
			}
		}

		private bool InCart
		{
			get
			{
				if (Object.op_Implicit((Object)(object)grab) && Object.op_Implicit((Object)(object)grab.impactDetector))
				{
					return grab.impactDetector.inCart;
				}
				return false;
			}
		}

		private static bool IsHair(CosmeticType t)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return Array.IndexOf(HairTypes, t) >= 0;
		}

		internal static void BuildAndRegister()
		{
			//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)
			//IL_00ae: 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_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_0105: 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)
			Material baseMat;
			BoxCollider box;
			GameObject val = Loot.CloneValuable(Loot.Small, "Valuable Bald", out baseMat, out box);
			Loot.LookLike(val, "Valuables/02 Small/Valuable Museum Car", ref baseMat);
			Loot.Feel(val, "Light", "Strong", null);
			faceMats = (Material[])(object)new Material[Faces.Length];
			for (int i = 0; i < Faces.Length; i++)
			{
				Texture2D val2 = Assets.LoadTexture(Faces[i]);
				((Texture)val2).filterMode = (FilterMode)2;
				((Texture)val2).anisoLevel = 4;
				faceMats[i] = Assets.MakeMaterial(baseMat, "You're Bald " + Faces[i], val2, 0.75f);
			}
			GameObject val3 = new GameObject("Bald Model")
			{
				layer = val.layer
			};
			val3.transform.SetParent(val.transform, false);
			val3.AddComponent<MeshFilter>().sharedMesh = Assets.LoadMesh("bald");
			((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = faceMats[2];
			Loot.FitBox(box, new Bounds(new Vector3(0f, 0.17f, 0f), Vector3.one * 0.34f * 0.9f));
			Loot.SetValue(val, (Type)1, Plugin.BaldValueMin.Value, Plugin.BaldValueMax.Value, "You're Bald...");
			val.AddComponent<Bald>();
			Loot.Register(val, Plugin.BaldSpawns.Value);
		}

		private void Start()
		{
			grab = ((Component)this).GetComponent<PhysGrabObject>();
			mine = ((Component)this).GetComponentsInChildren<Collider>(true);
			model = ((Component)this).transform.Find("Bald Model");
			face = (Object.op_Implicit((Object)(object)model) ? ((Component)model).GetComponent<MeshRenderer>() : null);
			bobPhase = Random.Range(0f, 10f);
		}

		private static bool HasHair(PlayerAvatar p)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (p.isLocal && Object.op_Implicit((Object)(object)MetaManager.instance))
			{
				return MyHair().Count > 0;
			}
			PlayerCosmetics playerCosmetics = p.playerCosmetics;
			if (!Object.op_Implicit((Object)(object)playerCosmetics) || playerCosmetics.cosmeticEquipped == null)
			{
				return false;
			}
			foreach (Cosmetic item in playerCosmetics.cosmeticEquipped)
			{
				if (Object.op_Implicit((Object)(object)item) && IsHair(item.type))
				{
					return true;
				}
			}
			return false;
		}

		private static List<CosmeticAsset> MyHair()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			List<CosmeticAsset> list = new List<CosmeticAsset>();
			MetaManager instance = MetaManager.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return list;
			}
			foreach (int item in instance.cosmeticEquipped)
			{
				if (item >= 0 && item < instance.cosmeticAssets.Count)
				{
					CosmeticAsset val = instance.cosmeticAssets[item];
					if (Object.op_Implicit((Object)(object)val) && IsHair(val.type))
					{
						list.Add(val);
					}
				}
			}
			return list;
		}

		private static void ShaveMe()
		{
			MetaManager instance = MetaManager.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return;
			}
			foreach (CosmeticAsset item in MyHair())
			{
				instance.CosmeticUnequip(item, false, true);
			}
			instance.Save();
			instance.CosmeticPlayerUpdateLocal(true, true);
			Tell.Local("You're bald!");
		}

		private bool Near(PlayerAvatar p)
		{
			//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)
			//IL_0017: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)p))
			{
				return false;
			}
			Vector3 position = ((Component)p).transform.position;
			Vector3 middle = Middle;
			Vector3 val = new Vector3(position.x, Mathf.Clamp(middle.y, position.y, position.y + 1.7f), position.z);
			float num = Plugin.BaldRange.Value + 0.17f;
			Vector3 val2 = val - middle;
			return ((Vector3)(ref val2)).sqrMagnitude < num * num;
		}

		private static bool Alive(PlayerAvatar p)
		{
			if (Object.op_Implicit((Object)(object)p) && !p.isDisabled)
			{
				return !p.deadSet;
			}
			return false;
		}

		private void Update()
		{
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			Tell.Tick();
			if (Object.op_Implicit((Object)(object)grab) && grab.grabbedLocal && Object.op_Implicit((Object)(object)ItemInfoUI.instance) && Tell.ShowingNow == null)
			{
				ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, Hint, false);
			}
			if (!SemiFunc.RunIsLevel())
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)grab) && grab.grabbedLocal && Time.time >= nextCall && Object.op_Implicit((Object)(object)PlayerController.instance) && PlayerController.instance.InputDisableTimer <= 0f && SemiFunc.InputDown((InputKey)2))
			{
				nextCall = Time.time + 3f;
				PhotonView component = ((Component)this).GetComponent<PhotonView>();
				if (SemiFunc.IsMultiplayer() && Object.op_Implicit((Object)(object)component))
				{
					component.RPC("EveryoneBaldRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					EveryoneBaldRPC();
				}
			}
			List<PlayerAvatar> list = SemiFunc.PlayerGetList();
			if (list == null)
			{
				return;
			}
			PlayerAvatar instance = PlayerAvatar.instance;
			bool flag = Alive(instance) && Near(instance) && HasHair(instance);
			working = (flag ? (working + Time.deltaTime) : Mathf.Max(0f, working - Time.deltaTime));
			if (flag && working >= Plugin.BaldSeconds.Value)
			{
				working = 0f;
				ShaveMe();
			}
			bool flag2 = false;
			bool flag3 = false;
			PlayerAvatar val = null;
			float num = float.MaxValue;
			bool value = default(bool);
			foreach (PlayerAvatar item in list)
			{
				if (!Object.op_Implicit((Object)(object)item))
				{
					continue;
				}
				bool flag4 = HasHair(item);
				if (started && hadHair.TryGetValue(item, out value) && value && !flag4 && (Near(item) || Time.time < calledUntil))
				{
					HeadShine(item, 1f);
					shavedSomeone = true;
					Assets.Play(Assets.LoadSound("bald_special"), ((Component)this).transform, Plugin.BaldVolume.Value);
				}
				hadHair[item] = flag4;
				if (!flag4)
				{
					continue;
				}
				flag2 = true;
				if (Alive(item))
				{
					Vector3 val2 = ((Component)item).transform.position - Middle;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (Near(item))
					{
						flag3 = true;
					}
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						val = item;
					}
				}
			}
			bool flag5 = !flag2 && list.Count > 0;
			if (started && flag5 && !wasAllBald)
			{
				Radiance(list);
			}
			wasAllBald = flag5;
			started = true;
			Form form = (flag3 ? Form.Balding : ((flag2 || !shavedSomeone) ? Form.NotBald : Form.Bald));
			if (Object.op_Implicit((Object)(object)face) && faceMats != null && (Object)(object)((Renderer)face).sharedMaterial != (Object)(object)faceMats[(int)form])
			{
				((Renderer)face).sharedMaterial = faceMats[(int)form];
			}
			if (Object.op_Implicit((Object)(object)model))
			{
				Quaternion val4;
				if (Object.op_Implicit((Object)(object)val))
				{
					Vector3 val3 = ((Component)val).transform.position - model.position;
					val3.y = 0f;
					val4 = ((((Vector3)(ref val3)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(((Vector3)(ref val3)).normalized, Vector3.up) : model.rotation);
					val4 = Quaternion.Inverse(((Component)this).transform.rotation) * val4;
					val4 = Quaternion.Euler(0f, ((Quaternion)(ref val4)).eulerAngles.y, 0f);
				}
				else
				{
					spin += 20f * Time.deltaTime;
					val4 = Quaternion.Euler(0f, spin, 0f);
				}
				model.localRotation = Quaternion.Slerp(model.localRotation, val4, 1f - Mathf.Exp(-3f * Time.deltaTime));
			}
		}

		[PunRPC]
		public void EveryoneBaldRPC()
		{
			//IL_001e: 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)
			calledUntil = Time.time + 5f;
			shavedSomeone = true;
			Burst(((Component)this).transform, Vector3.up * 0.17f, 0.5f, 10, 1.6f, 4f, 6f);
			if (MyHair().Count > 0)
			{
				ShaveMe();
			}
		}

		private static Transform Head(PlayerAvatar p)
		{
			PlayerAvatarVisuals val = (Object.op_Implicit((Object)(object)p) ? p.playerAvatarVisuals : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.attachPointTopHeadMiddle))
			{
				if (!Object.op_Implicit((Object)(object)p))
				{
					return null;
				}
				return ((Component)p).transform;
			}
			return val.attachPointTopHeadMiddle;
		}

		private static void HeadShine(PlayerAvatar p, float strength)
		{
			//IL_002f: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			Transform val = Head(p);
			if (Object.op_Implicit((Object)(object)val))
			{
				Vector3 local = (((Object)(object)val == (Object)(object)((Component)p).transform) ? (Vector3.up * 1.6f) : (Vector3.up * 0.05f));
				Burst(val, local, 0.35f * strength, 7, 0.9f * strength, 2.5f * strength, 2.5f);
			}
		}

		private void Radiance(List<PlayerAvatar> players)
		{
			//IL_0043: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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_00e7: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0157: Expected O, but got Unknown
			foreach (PlayerAvatar player in players)
			{
				if (Object.op_Implicit((Object)(object)player))
				{
					HeadShine(player, 1.4f);
				}
			}
			Burst(((Component)this).transform, Vector3.up * 0.17f, 1.6f, 26, 5f, 8f, 12f);
			Camera val = (Object.op_Implicit((Object)(object)CameraUtils.Instance) ? CameraUtils.Instance.MainCamera : Camera.main);
			if (Object.op_Implicit((Object)(object)val))
			{
				GameObject val2 = new GameObject("You're Bald Radiance");
				val2.transform.SetParent(((Component)val).transform, false);
				val2.transform.localPosition = Vector3.forward * 0.4f;
				Particles(val2, "bald_glow", 1, 0f, 2.6f, 2.2f);
				Particles(val2, "bald_sparkle", 14, 0.35f, 0.12f, 1.8f);
				Light val3 = val2.AddComponent<Light>();
				val3.type = (LightType)2;
				val3.color = new Color(1f, 0.95f, 0.75f);
				val3.range = 14f;
				val3.intensity = 4f;
				val2.AddComponent<Fade>().light = val3;
				Object.Destroy((Object)val2, 3f);
			}
			Assets.Play(Assets.LoadSound("bald_special"), ((Component)this).transform, Plugin.BaldVolume.Value, 30f);
			Tell.Local("Everyone is bald!");
		}

		private static void Burst(Transform parent, Vector3 local, float spread, int stars, float glowSize, float light, float lightRange)
		{
			//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_0017: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			GameObject val = new GameObject("You're Bald Shine");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = local;
			Particles(val, "bald_glow", 1, 0f, glowSize, 1.1f);
			Particles(val, "bald_sparkle", stars, spread, 0.18f + spread * 0.12f, 1.4f);
			Light val2 = val.AddComponent<Light>();
			val2.type = (LightType)2;
			val2.color = new Color(1f, 0.95f, 0.75f);
			val2.range = lightRange;
			val2.intensity = light;
			val.AddComponent<Fade>().light = val2;
			Object.Destroy((Object)val, 2.5f);
		}

		private static void Particles(GameObject g, string tex, int count, float spread, float size, float life)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//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)
			//IL_0057: 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_0070: 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_00a8: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0140: 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_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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(tex);
			val.transform.SetParent(g.transform, false);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).duration = 0.3f;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(life * 0.7f, life);
			((MainModule)(ref main)).startSpeed = ((spread > 0f) ? new MinMaxCurve(0.02f, 0.15f) : new MinMaxCurve(0f));
			((MainModule)(ref main)).startSize = new MinMaxCurve(size * 0.6f, size);
			((MainModule)(ref main)).startRotation = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white);
			((MainModule)(ref main)).maxParticles = count;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).enabled = true;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)((!(spread > 0f)) ? new Burst[1]
			{
				new Burst(0f, (short)count)
			} : new Burst[2]
			{
				new Burst(0f, (short)(count / 2)),
				new Burst(0.25f, (short)(count - count / 2))
			}));
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = spread > 0f;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = Mathf.Max(spread, 0.01f);
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0f),
				new Keyframe(0.2f, 1f),
				new Keyframe(1f, 0f)
			}));
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).sharedMaterial = Fx.Mat(tex);
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			component.maxParticleSize = 5f;
			val2.Play();
		}

		private void FixedUpdate()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_0186: 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_0197: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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_0169: 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)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel() || !Object.op_Implicit((Object)(object)grab) || !Object.op_Implicit((Object)(object)grab.rb))
			{
				return;
			}
			Rigidbody rb = grab.rb;
			if (Held)
			{
				grab.OverrideZeroGravity(0.2f);
			}
			else
			{
				if (rb.isKinematic || InCart)
				{
					return;
				}
				bool found;
				float num = Nearest(rb.position + Vector3.up * 0.2f, Vector3.down, 3.5f, out found);
				if (found)
				{
					bool found2;
					float num2 = Nearest(rb.position + Vector3.up * 0.34f, Vector3.up, 3f, out found2);
					float num3 = num + Plugin.BaldHover.Value;
					if (found2)
					{
						num3 = Mathf.Min(num3, num2 - 0.34f - 0.1f);
					}
					num3 = Mathf.Max(num3, num + 0.05f) + Mathf.Sin((Time.time + bobPhase) * 1.3f) * 0.06f;
					float num4 = num3 - rb.position.y;
					float y = rb.linearVelocity.y;
					Vector3 val = Vector3.up * (Mathf.Clamp(num4, -0.8f, 0.8f) * 30f - y * 7f);
					if (rb.useGravity)
					{
						val -= Physics.gravity;
					}
					rb.AddForce(val, (ForceMode)5);
					Vector3 linearVelocity = rb.linearVelocity;
					linearVelocity.y = 0f;
					rb.AddForce(-linearVelocity * 2.5f, (ForceMode)5);
					Vector3 val2 = Vector3.Cross(rb.rotation * Vector3.up, Vector3.up);
					rb.AddTorque(val2 * 25f - rb.angularVelocity * 4f, (ForceMode)5);
				}
			}
		}

		private float Nearest(Vector3 from, Vector3 dir, float range, out bool found)
		{
			//IL_000c: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			float result = 0f;
			float num = range;
			found = false;
			RaycastHit[] array = Physics.RaycastAll(from, dir, range, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (!(((RaycastHit)(ref val)).distance >= num) && Array.IndexOf(mine, ((RaycastHit)(ref val)).collider) < 0 && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PlayerAvatar>()) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PlayerController>()))
				{
					num = ((RaycastHit)(ref val)).distance;
					result = ((RaycastHit)(ref val)).point.y;
					found = true;
				}
			}
			return result;
		}
	}
	internal class DontTouchMe : MonoBehaviour
	{
		private enum Outcome
		{
			Crack,
			Die,
			Explode,
			Blast,
			Crash
		}

		internal class Overlay : MonoBehaviour
		{
			private static Overlay instance;

			private RawImage crack;

			private RawImage crash;

			private string crackLevel;

			internal static Overlay Instance
			{
				get
				{
					//IL_0017: Unknown result type (might be due to invalid IL or missing references)
					//IL_001c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0022: Expected O, but got Unknown
					//IL_0022: Unknown result type (might be due to invalid IL or missing references)
					if (Object.op_Implicit((Object)(object)instance))
					{
						return instance;
					}
					GameObject val = new GameObject("LobCorpItems Screen");
					Object.DontDestroyOnLoad((Object)val);
					Canvas obj = val.AddComponent<Canvas>();
					obj.renderMode = (RenderMode)0;
					obj.sortingOrder = 30000;
					return instance = val.AddComponent<Overlay>();
				}
			}

			private static string LevelName
			{
				get
				{
					if (!Object.op_Implicit((Object)(object)RunManager.instance) || !Object.op_Implicit((Object)(object)RunManager.instance.levelCurrent))
					{
						return "";
					}
					return ((Object)RunManager.instance.levelCurrent).name + RunManager.instance.levelsCompleted;
				}
			}

			private RawImage Layer(string tex)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: 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)
				GameObject val = new GameObject(tex);
				val.transform.SetParent(((Component)this).transform, false);
				RawImage obj = val.AddComponent<RawImage>();
				obj.texture = (Texture)(object)Assets.LoadTexture(tex);
				((Graphic)obj).raycastTarget = false;
				RectTransform rectTransform = ((Graphic)obj).rectTransform;
				rectTransform.anchorMin = Vector2.zero;
				rectTransform.anchorMax = Vector2.one;
				Vector2 offsetMin = (rectTransform.offsetMax = Vector2.zero);
				rectTransform.offsetMin = offsetMin;
				return obj;
			}

			internal static void Crack()
			{
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				Overlay overlay = Instance;
				if (!Object.op_Implicit((Obje