Decompiled source of NaughtyValuables v1.0.2

NaughtyValuables.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NaughtyValuables.Actions;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NaughtyValuables")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("NaughtyValuables")]
[assembly: AssemblyTitle("NaughtyValuables")]
[assembly: AssemblyVersion("1.0.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NaughtyValuables
{
	public class DebugSpawner : MonoBehaviour
	{
		private const float LeaveDistance = 6f;

		private const float SpawnInterval = 0.35f;

		private Level _doneLevel;

		private Level _trackedLevel;

		private Vector3 _startPos;

		private bool _hasStart;

		private readonly Queue<KeyValuePair<string, PrefabRef>> _queue = new Queue<KeyValuePair<string, PrefabRef>>();

		private float _timer;

		private int _nextIndex;

		private bool _errorLogged;

		private void Update()
		{
			try
			{
				Tick();
			}
			catch (Exception ex)
			{
				if (!_errorLogged)
				{
					_errorLogged = true;
					Plugin.Log.LogError((object)("[Debug] Spawner error (logged once): " + ex));
				}
			}
		}

		private void Tick()
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Plugin.DebugSpawnAll != null && Plugin.DebugSpawnAll.Value;
			bool flag2 = Plugin.DebugHotkeys != null && Plugin.DebugHotkeys.Value;
			if ((!flag && !flag2) || (Object)(object)RunManager.instance == (Object)null)
			{
				return;
			}
			if (!SemiFunc.LevelGenDone() || !SemiFunc.RunIsLevel() || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				_queue.Clear();
				_hasStart = false;
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Level levelCurrent = RunManager.instance.levelCurrent;
			if ((Object)(object)levelCurrent != (Object)(object)_trackedLevel)
			{
				_trackedLevel = levelCurrent;
				_hasStart = false;
				_queue.Clear();
			}
			if (!_hasStart)
			{
				_startPos = ((Component)val).transform.position;
				_hasStart = true;
				return;
			}
			if (flag2)
			{
				HandleHotkeys(val);
			}
			if (flag && (Object)(object)_doneLevel != (Object)(object)levelCurrent && _queue.Count == 0 && Vector3.Distance(((Component)val).transform.position, _startPos) > 6f)
			{
				_doneLevel = levelCurrent;
				EnqueueAll("level start");
			}
			if (_queue.Count != 0)
			{
				_timer -= Time.deltaTime;
				if (!(_timer > 0f))
				{
					_timer = 0.35f;
					KeyValuePair<string, PrefabRef> keyValuePair = _queue.Dequeue();
					Spawn(val, keyValuePair.Key, keyValuePair.Value);
				}
			}
		}

		private void HandleHotkeys(PlayerAvatar me)
		{
			Keyboard current = Keyboard.current;
			if (current != null && Plugin.PrefabRefs.Count != 0)
			{
				if (((ButtonControl)current.f8Key).wasPressedThisFrame)
				{
					List<KeyValuePair<string, PrefabRef>> list = Plugin.PrefabRefs.ToList();
					KeyValuePair<string, PrefabRef> keyValuePair = list[_nextIndex % list.Count];
					_nextIndex = (_nextIndex + 1) % list.Count;
					Plugin.Log.LogInfo((object)$"[Debug] F8: {keyValuePair.Key} ({_nextIndex}/{list.Count})");
					Spawn(me, keyValuePair.Key, keyValuePair.Value);
				}
				if (((ButtonControl)current.f9Key).wasPressedThisFrame)
				{
					EnqueueAll("F9");
				}
			}
		}

		private void EnqueueAll(string why)
		{
			foreach (KeyValuePair<string, PrefabRef> prefabRef in Plugin.PrefabRefs)
			{
				_queue.Enqueue(prefabRef);
			}
			_timer = 0f;
			Plugin.Log.LogInfo((object)$"[Debug] {why}: spawning {Plugin.PrefabRefs.Count} NaughtyValuables in front of the host.");
		}

		private static void Spawn(PlayerAvatar me, string id, PrefabRef pref)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = FreeSpotInFront(((Component)me).transform);
			if ((Object)(object)Valuables.SpawnValuable(pref, val, Quaternion.Euler(0f, ((Component)me).transform.eulerAngles.y + 180f, 0f)) == (Object)null)
			{
				Plugin.Log.LogWarning((object)("[Debug] Could not spawn " + id + "."));
			}
		}

		private static Vector3 FreeSpotInFront(Transform player)
		{
			//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_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = player.position + Vector3.up * 1.2f;
			Vector3 val2 = player.forward;
			val2.y = 0f;
			val2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : Vector3.forward);
			float num = 1.8f;
			int mask = LayerMask.GetMask(new string[1] { "Default" });
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val, val2, ref val3, num + 0.6f, mask, (QueryTriggerInteraction)1))
			{
				num = Mathf.Max(0.6f, ((RaycastHit)(ref val3)).distance - 0.6f);
			}
			Vector3 val4 = val + val2 * num;
			RaycastHit val5 = default(RaycastHit);
			if (Physics.Raycast(val4, Vector3.down, ref val5, 3f, mask, (QueryTriggerInteraction)1))
			{
				val4 = ((RaycastHit)(ref val5)).point + Vector3.up * 0.05f;
			}
			return val4;
		}
	}
	public class NvItemDef
	{
		public string Id;

		public string DisplayName;

		public Type Size;

		public float TargetSize;

		public float ValueFactor;

		public float MassFactor;

		public Type Action;

		public float FixedMass;

		public NvItemDef(string id, string displayName, Type size, float targetSize, Type action, float valueFactor = 1f, float massFactor = 1f, float fixedMass = 0f)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			FixedMass = fixedMass;
			Id = id;
			DisplayName = displayName;
			Size = size;
			TargetSize = targetSize;
			Action = action;
			ValueFactor = valueFactor;
			MassFactor = massFactor;
		}
	}
	public static class NvItems
	{
		private const Type Tiny = (Type)0;

		private const Type Small = (Type)1;

		private const Type Medium = (Type)2;

		private const Type Big = (Type)3;

		private const Type Wide = (Type)4;

		private const Type Tall = (Type)5;

		private const Type VeryTall = (Type)6;

		public static readonly NvItemDef[] All = new NvItemDef[26]
		{
			new NvItemDef("pink_dildo", "Pink Dildo", (Type)1, 0.42f, typeof(NvBoing)),
			new NvItemDef("the_monster", "The Monster", (Type)5, 2.1f, typeof(NvMonster), 1.3f, 1.2f, 3.8f),
			new NvItemDef("bullet_vibrator", "Bullet Vibrator", (Type)0, 0.21f, typeof(NvWanderer)),
			new NvItemDef("magic_wand", "Magic Wand", (Type)2, 0.85f, typeof(NvWand)),
			new NvItemDef("vibrating_egg", "Vibrating Egg", (Type)1, 0.42f, typeof(NvHopper)),
			new NvItemDef("pocket_stroker", "Pocket Stroker", (Type)2, 0.6f, typeof(NvFlashlight)),
			new NvItemDef("strap_on", "Strap-On", (Type)3, 1f, typeof(NvBoss)),
			new NvItemDef("butt_plug", "Jeweled Butt Plug", (Type)0, 0.21f, typeof(NvTreasure), 1.2f),
			new NvItemDef("fox_tail_plug", "Fox Tail Plug", (Type)4, 1.6f, typeof(NvTail), 1f, 0.35f),
			new NvItemDef("anal_beads", "Anal Beads", (Type)4, 1.3f, typeof(NvPopper)),
			new NvItemDef("cock_ring", "Cock Ring", (Type)0, 0.2f, typeof(NvRoller)),
			new NvItemDef("vacuum_pump", "Vacuum Pump", (Type)5, 1.1f, typeof(NvSucker)),
			new NvItemDef("lube_bottle", "Lube Bottle", (Type)1, 0.4f, typeof(NvSlippery)),
			new NvItemDef("fluffy_handcuffs", "Fluffy Handcuffs", (Type)2, 0.7f, typeof(NvCuffs)),
			new NvItemDef("spanking_paddle", "Spanking Paddle", (Type)2, 0.85f, typeof(NvPaddle)),
			new NvItemDef("whip", "Whip", (Type)4, 1.8f, typeof(NvWhip)),
			new NvItemDef("flogger", "Flogger", (Type)4, 1.6f, typeof(NvTickle)),
			new NvItemDef("ball_gag", "Ball Gag", (Type)2, 0.65f, typeof(NvGag)),
			new NvItemDef("leather_mask", "Leather Mask", (Type)2, 0.65f, typeof(NvMask)),
			new NvItemDef("bdsm_candle", "BDSM Candle", (Type)2, 0.6f, typeof(NvCandle)),
			new NvItemDef("inflatable_doll", "Inflatable Doll", (Type)6, 1.75f, typeof(NvDecoy), 1f, 0.6f, 3.4f),
			new NvItemDef("love_swing", "Love Swing", (Type)6, 1.8f, typeof(NvSwing), 1f, 1.6f, 3.8f),
			new NvItemDef("condom_box", "Condom Box", (Type)1, 0.42f, typeof(NvBalloons)),
			new NvItemDef("massage_oil", "Massage Oil", (Type)1, 0.42f, typeof(NvMassage)),
			new NvItemDef("feather_tickler", "Feather Tickler", (Type)5, 1.3f, typeof(NvFeather)),
			new NvItemDef("naughty_dice", "Naughty Dice", (Type)1, 0.42f, typeof(NvDice))
		};
	}
	public class ObjMaterial
	{
		public string Name;

		public Color Color = Color.white;

		public float Smoothness = 0.5f;

		public bool Metallic;

		public Color Emission = Color.black;
	}
	public class ObjModel
	{
		public Mesh Mesh;

		public List<ObjMaterial> Materials = new List<ObjMaterial>();
	}
	public static class ObjLoader
	{
		private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;

		public static ObjModel Load(string objPath)
		{
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//IL_0150: 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)
			List<Vector3> positions = new List<Vector3>();
			List<Vector3> normals = new List<Vector3>();
			List<Vector3> outVerts = new List<Vector3>();
			List<Vector3> outNormals = new List<Vector3>();
			Dictionary<long, int> cornerCache = new Dictionary<long, int>();
			List<List<int>> list = new List<List<int>>();
			List<string> list2 = new List<string>();
			int num = -1;
			Dictionary<string, ObjMaterial> dictionary = new Dictionary<string, ObjMaterial>();
			foreach (string item5 in File.ReadLines(objPath))
			{
				string text = item5.Trim();
				if (text.Length == 0 || text[0] == '#')
				{
					continue;
				}
				string[] array = text.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
				switch (array[0])
				{
				case "mtllib":
				{
					string path = Path.Combine(Path.GetDirectoryName(objPath) ?? "", text.Substring(7).Trim());
					if (File.Exists(path))
					{
						dictionary = LoadMtl(path);
					}
					break;
				}
				case "v":
					positions.Add(new Vector3(0f - F(array[1]), F(array[2]), F(array[3])));
					break;
				case "vn":
					normals.Add(new Vector3(0f - F(array[1]), F(array[2]), F(array[3])));
					break;
				case "usemtl":
				{
					string item4 = ((array.Length > 1) ? array[1] : "default");
					num = list2.IndexOf(item4);
					if (num < 0)
					{
						list2.Add(item4);
						list.Add(new List<int>());
						num = list2.Count - 1;
					}
					break;
				}
				case "f":
				{
					if (num < 0)
					{
						list2.Add("default");
						list.Add(new List<int>());
						num = 0;
					}
					int item = Corner(array[1]);
					for (int i = 2; i + 1 < array.Length; i++)
					{
						int item2 = Corner(array[i]);
						int item3 = Corner(array[i + 1]);
						list[num].Add(item);
						list[num].Add(item3);
						list[num].Add(item2);
					}
					break;
				}
				}
			}
			Mesh val = new Mesh
			{
				name = "NV " + Path.GetFileNameWithoutExtension(objPath),
				indexFormat = (IndexFormat)1,
				hideFlags = (HideFlags)32
			};
			val.SetVertices(outVerts);
			val.SetNormals(outNormals);
			val.subMeshCount = list.Count;
			for (int j = 0; j < list.Count; j++)
			{
				val.SetTriangles(list[j], j);
			}
			val.RecalculateBounds();
			if (normals.Count == 0)
			{
				val.RecalculateNormals();
			}
			ObjModel objModel = new ObjModel
			{
				Mesh = val
			};
			foreach (string item6 in list2)
			{
				objModel.Materials.Add(dictionary.TryGetValue(item6, out var value) ? value : new ObjMaterial
				{
					Name = item6
				});
			}
			return objModel;
			int Corner(string token)
			{
				//IL_0071: 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_0085: Unknown result type (might be due to invalid IL or missing references)
				string[] array2 = token.Split('/');
				int num2 = Idx(array2[0], positions.Count);
				int num3 = ((array2.Length > 2 && array2[2].Length > 0) ? Idx(array2[2], normals.Count) : (-1));
				long key = ((long)num2 << 32) | (uint)(num3 + 1);
				if (cornerCache.TryGetValue(key, out var value2))
				{
					return value2;
				}
				outVerts.Add(positions[num2]);
				outNormals.Add((num3 >= 0) ? normals[num3] : Vector3.up);
				cornerCache[key] = outVerts.Count - 1;
				return outVerts.Count - 1;
			}
		}

		private static Dictionary<string, ObjMaterial> LoadMtl(string path)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, ObjMaterial> dictionary = new Dictionary<string, ObjMaterial>();
			ObjMaterial objMaterial = null;
			foreach (string item in File.ReadLines(path))
			{
				string[] array = item.Trim().Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length != 0)
				{
					if (array[0] == "newmtl")
					{
						objMaterial = new ObjMaterial
						{
							Name = ((array.Length > 1) ? array[1] : "default")
						};
						dictionary[objMaterial.Name] = objMaterial;
					}
					else if (objMaterial != null && array[0] == "Kd" && array.Length >= 4)
					{
						objMaterial.Color = new Color(F(array[1]), F(array[2]), F(array[3]), objMaterial.Color.a);
					}
					else if (objMaterial != null && array[0] == "d" && array.Length >= 2)
					{
						Color color = objMaterial.Color;
						color.a = F(array[1]);
						objMaterial.Color = color;
					}
					else if (objMaterial != null && array[0] == "Ns" && array.Length >= 2)
					{
						objMaterial.Smoothness = Mathf.Clamp01(Mathf.Sqrt(Mathf.Max(0f, F(array[1])) / 1000f));
					}
					else if (objMaterial != null && array[0] == "Ke" && array.Length >= 4)
					{
						objMaterial.Emission = new Color(F(array[1]), F(array[2]), F(array[3]), 1f);
					}
					else if (objMaterial != null && array[0] == "illum" && array.Length >= 2)
					{
						objMaterial.Metallic = array[1] == "3";
					}
				}
			}
			return dictionary;
		}

		private static float F(string s)
		{
			return float.Parse(s, Inv);
		}

		private static int Idx(string s, int count)
		{
			int num = int.Parse(s, Inv);
			if (num >= 0)
			{
				return num - 1;
			}
			return count + num;
		}
	}
	[BepInPlugin("Luffi.NaughtyValuables", "NaughtyValuables", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(RunManager), "Awake")]
		internal static class RunManagerAwakePatch
		{
			private static bool _done;

			[HarmonyPostfix]
			[HarmonyPriority(400)]
			private static void Postfix(RunManager __instance)
			{
				if (_done)
				{
					return;
				}
				_done = true;
				try
				{
					RegisterAll(__instance);
				}
				catch (Exception ex)
				{
					Log.LogError((object)("Failed to create the valuables: " + ex));
				}
			}
		}

		public const string Guid = "Luffi.NaughtyValuables";

		public const string ModName = "NaughtyValuables";

		public const string ModVersion = "1.0.2";

		internal static Plugin Instance;

		internal static ManualLogSource Log;

		internal static string ModDir;

		internal static ConfigEntry<bool> EnableFunnyActions;

		internal static ConfigEntry<float> ValueMultiplier;

		internal static ConfigEntry<bool> DebugSpawnAll;

		internal static ConfigEntry<bool> DebugHotkeys;

		internal static ConfigEntry<bool> ShowPopupText;

		internal static ConfigEntry<float> MassMultiplier;

		internal static ConfigEntry<string> WearKey;

		internal static readonly Dictionary<string, ConfigEntry<bool>> ItemEnabled = new Dictionary<string, ConfigEntry<bool>>();

		internal static readonly Dictionary<string, ConfigEntry<bool>> ItemActions = new Dictionary<string, ConfigEntry<bool>>();

		internal static readonly Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>();

		internal static readonly Dictionary<string, PrefabRef> PrefabRefs = new Dictionary<string, PrefabRef>();

		private void Awake()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			ModDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
			EnableFunnyActions = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableFunnyActions", true, "Turns all funny item actions on/off (sounds, effects). Items still spawn as normal valuables when off.");
			ValueMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ValueMultiplier", 1f, new ConfigDescription("Multiplies the $ value of all NaughtyValuables items.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
			ShowPopupText = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowPopupText", false, "Shows floating text above items when an action happens (BOING!, CRACK!...). Off by default.");
			MassMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MassMultiplier", 0.85f, new ConfigDescription("Multiplies the weight of all NaughtyValuables items (1 = as heavy as vanilla items of the same size). Needs a game restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			WearKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "WearKey", "G", "Key to wear / take off the Strap-On (front) and the Fox Tail (back) while you hold it. Unity Input System key name (G, H, T, F1...).");
			NvItemDef[] all = NvItems.All;
			foreach (NvItemDef nvItemDef in all)
			{
				ItemEnabled[nvItemDef.Id] = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", nvItemDef.Id, true, "Spawn \"" + nvItemDef.DisplayName + "\" in levels.");
				ItemActions[nvItemDef.Id] = ((BaseUnityPlugin)this).Config.Bind<bool>("Actions", nvItemDef.Id, true, "Funny action of \"" + nvItemDef.DisplayName + "\".");
			}
			DebugSpawnAll = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "SpawnAllOnLevelStart", false, "TESTING ONLY: the host gets one of every NaughtyValuables item at the start of each level. Set back to false after testing.");
			if (DebugSpawnAll.Value)
			{
				Log.LogWarning((object)"Debug.SpawnAllOnLevelStart is ON (test mode).");
			}
			DebugHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "SpawnHotkeys", false, "TESTING ONLY (host): F8 spawns the next NaughtyValuables item in front of you, F9 spawns all of them. Set back to false after testing.");
			if (DebugHotkeys.Value)
			{
				Log.LogWarning((object)"Debug.SpawnHotkeys is ON (F8 = next item, F9 = all items).");
			}
			new Harmony("Luffi.NaughtyValuables").PatchAll(typeof(RunManagerAwakePatch));
			Net.Init();
			GameObject val = new GameObject("NaughtyValuables_Runner")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<DebugSpawner>();
			Log.LogInfo((object)("NaughtyValuables 1.0.2 loaded. Models folder: " + ModelsDir()));
		}

		internal static string ModelsDir()
		{
			string text = Path.Combine(ModDir, "models_game");
			if (Directory.Exists(text))
			{
				return text;
			}
			string text2 = Path.Combine(ModDir, "models");
			if (Directory.Exists(text2))
			{
				return text2;
			}
			return ModDir;
		}

		internal static bool ActionsOn(string id)
		{
			if (EnableFunnyActions.Value)
			{
				if (ItemActions.TryGetValue(id, out var value))
				{
					return value.Value;
				}
				return true;
			}
			return false;
		}

		private static void RegisterAll(RunManager run)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0113: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<Type, List<GameObject>> dictionary = ValuableFactory.CollectVanilla(run);
			foreach (KeyValuePair<Type, List<GameObject>> item in dictionary)
			{
				Log.LogInfo((object)$"Vanilla {item.Key}: {item.Value.Count} valuables, typical mass {ValuableFactory.TypicalMass(dictionary, item.Key):0.0}, typical value {ValuableFactory.TypicalValue(dictionary, item.Key)}.");
			}
			string path = ModelsDir();
			int num = 0;
			NvItemDef[] all = NvItems.All;
			foreach (NvItemDef nvItemDef in all)
			{
				if (!ItemEnabled[nvItemDef.Id].Value)
				{
					continue;
				}
				string text = Path.Combine(path, nvItemDef.Id + ".obj");
				if (!File.Exists(text))
				{
					Log.LogWarning((object)("Missing model: " + text));
					continue;
				}
				try
				{
					GameObject val = ValuableFactory.PickTemplate(dictionary, nvItemDef.Size);
					if ((Object)(object)val == (Object)null)
					{
						Log.LogError((object)$"No vanilla valuable found to clone for {nvItemDef.Id} ({nvItemDef.Size}).");
						continue;
					}
					ObjModel objModel = ObjLoader.Load(text);
					GameObject val2 = ValuableFactory.Build(nvItemDef, val, objModel, ValueMultiplier.Value, ValuableFactory.TypicalMass(dictionary, nvItemDef.Size), ValuableFactory.TypicalValue(dictionary, nvItemDef.Size));
					PrefabRef val3 = Valuables.RegisterValuable(val2, new List<string> { "Valuables - Generic" });
					if (val3 == null)
					{
						Log.LogError((object)("REPOLib could not register " + nvItemDef.Id + "."));
						continue;
					}
					Prefabs[nvItemDef.Id] = val2;
					PrefabRefs[nvItemDef.Id] = val3;
					num++;
					Log.LogInfo((object)$"{nvItemDef.DisplayName}: cloned from \"{((Object)val).name}\", {objModel.Mesh.vertexCount} verts, {objModel.Materials.Count} materials.");
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"Failed to build {nvItemDef.Id}: {arg}");
				}
			}
			Log.LogInfo((object)$"{num}/{NvItems.All.Length} NaughtyValuables registered.");
		}
	}
	public static class ValuableFactory
	{
		private const float EnvelopeFill = 0.92f;

		private static GameObject _holder;

		private static readonly HashSet<string> KnownCommon = new HashSet<string> { "ValuableObject", "PhysGrabObject", "PhysGrabObjectImpactDetector", "PhysGrabObjectCollider", "PhotonView", "PhotonTransformView", "RoomVolumeCheck", "NotValuableObject", "PhysGrabObjectGrabArea", "PhysGrabObjectBoxCollider" };

		private static readonly FieldInfo DebugMeshesField = AccessTools.Field(typeof(ValuableObject), "debugValuableMeshes");

		private static Shader _standard;

		private static bool _standardWarned;

		private static Transform Holder
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)_holder == (Object)null)
				{
					_holder = new GameObject("NaughtyValuables_Templates");
					_holder.SetActive(false);
					((Object)_holder).hideFlags = (HideFlags)61;
					Object.DontDestroyOnLoad((Object)(object)_holder);
				}
				return _holder.transform;
			}
		}

		public static Dictionary<Type, List<GameObject>> CollectVanilla(RunManager run)
		{
			Dictionary<Type, List<GameObject>> result = new Dictionary<Type, List<GameObject>>();
			HashSet<string> seen = new HashSet<string>();
			List<Level> list = new List<Level>();
			if (run.levels != null)
			{
				list.AddRange(run.levels);
			}
			if (run.levelArena != null)
			{
				list.AddRange(run.levelArena);
			}
			foreach (Level item in list)
			{
				if ((Object)(object)item == (Object)null || item.ValuablePresets == null)
				{
					continue;
				}
				foreach (LevelValuables valuablePreset in item.ValuablePresets)
				{
					if (!((Object)(object)valuablePreset == (Object)null))
					{
						Add(result, seen, (Type)0, valuablePreset.tiny);
						Add(result, seen, (Type)1, valuablePreset.small);
						Add(result, seen, (Type)2, valuablePreset.medium);
						Add(result, seen, (Type)3, valuablePreset.big);
						Add(result, seen, (Type)4, valuablePreset.wide);
						Add(result, seen, (Type)5, valuablePreset.tall);
						Add(result, seen, (Type)6, valuablePreset.veryTall);
					}
				}
			}
			return result;
		}

		private unsafe static void Add(Dictionary<Type, List<GameObject>> result, HashSet<string> seen, Type size, List<PrefabRef> refs)
		{
			//IL_00aa: 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)
			if (refs == null)
			{
				return;
			}
			foreach (PrefabRef @ref in refs)
			{
				if (@ref == null || !seen.Add(((object)(*(Type*)(&size))/*cast due to .constrained prefix*/).ToString() + "|" + ((PrefabRef<GameObject>)(object)@ref).ResourcePath))
				{
					continue;
				}
				GameObject val = null;
				try
				{
					val = ((PrefabRef<GameObject>)(object)@ref).Prefab;
				}
				catch
				{
				}
				if ((Object)(object)val == (Object)null && (Object)(object)((PrefabRef<GameObject>)(object)@ref).Bundle == (Object)null && !string.IsNullOrEmpty(((PrefabRef<GameObject>)(object)@ref).ResourcePath))
				{
					val = Resources.Load<GameObject>(((PrefabRef<GameObject>)(object)@ref).ResourcePath);
				}
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.GetComponent<ValuableObject>() == (Object)null) && !((Object)(object)val.GetComponent<PhysGrabObject>() == (Object)null))
				{
					if (!result.TryGetValue(size, out var value))
					{
						value = (result[size] = new List<GameObject>());
					}
					value.Add(val);
				}
			}
		}

		public static GameObject PickTemplate(Dictionary<Type, List<GameObject>> vanilla, Type size)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (!vanilla.TryGetValue(size, out var value) || value.Count == 0)
			{
				value = (from kv in vanilla
					where kv.Value.Count > 0
					orderby Mathf.Abs(kv.Key - size)
					select kv.Value).FirstOrDefault();
				if (value == null)
				{
					return null;
				}
			}
			return value.OrderBy(Complexity).ThenBy((GameObject p) => ((Object)p).name).First();
		}

		public static float TypicalMass(Dictionary<Type, List<GameObject>> vanilla, Type size)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (!vanilla.TryGetValue(size, out var value))
			{
				return 0f;
			}
			List<float> list = (from p in value
				select p.GetComponent<ValuableObject>() into v
				where (Object)(object)v != (Object)null && (Object)(object)v.physAttributePreset != (Object)null && v.physAttributePreset.mass > 0f
				select v.physAttributePreset.mass into m
				orderby m
				select m).ToList();
			if (list.Count != 0)
			{
				return list[list.Count / 2];
			}
			return 0f;
		}

		public static Vector2 TypicalValue(Dictionary<Type, List<GameObject>> vanilla, Type size)
		{
			//IL_0001: 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_008c: 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)
			if (!vanilla.TryGetValue(size, out var value))
			{
				return Vector2.zero;
			}
			List<Value> list = (from p in value
				select p.GetComponent<ValuableObject>() into v
				where (Object)(object)v != (Object)null && (Object)(object)v.valuePreset != (Object)null && v.valuePreset.valueMax > 0f
				select v.valuePreset).ToList();
			if (list.Count == 0)
			{
				return Vector2.zero;
			}
			List<float> list2 = (from p in list
				select p.valueMin into x
				orderby x
				select x).ToList();
			List<float> list3 = (from p in list
				select p.valueMax into x
				orderby x
				select x).ToList();
			return new Vector2(list2[list2.Count / 2], list3[list3.Count / 2]);
		}

		private static int Complexity(GameObject prefab)
		{
			int num = 0;
			MonoBehaviour[] componentsInChildren = prefab.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string name = ((object)val).GetType().Name;
					if (!KnownCommon.Contains(name))
					{
						num += ((!name.StartsWith("Valuable")) ? 1 : 10);
					}
				}
			}
			num += prefab.GetComponentsInChildren<Animator>(true).Length * 5;
			return num + prefab.GetComponentsInChildren<ParticleSystem>(true).Length;
		}

		private static Bounds Envelope(ValuableObject vo, Type type, out string source)
		{
			//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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected I4, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected I4, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Vector3 val = Vector3.zero;
			source = "game";
			try
			{
				object? obj = DebugMeshesField?.GetValue(vo);
				DebugValuableMeshes val2 = (DebugValuableMeshes)((obj is DebugValuableMeshes) ? obj : null);
				if ((Object)(object)val2 != (Object)null)
				{
					Mesh val3 = (Mesh)((int)type switch
					{
						0 => val2.tiny, 
						1 => val2.small, 
						2 => val2.medium, 
						3 => val2.big, 
						4 => val2.wide, 
						5 => val2.tall, 
						6 => val2.veryTall, 
						_ => null, 
					});
					if ((Object)(object)val3 != (Object)null)
					{
						Bounds bounds = val3.bounds;
						val = ((Bounds)(ref bounds)).size;
					}
				}
			}
			catch
			{
			}
			if (val.x < 0.05f || val.y < 0.05f || val.z < 0.05f)
			{
				source = "fallback";
				val = (Vector3)((int)type switch
				{
					0 => new Vector3(0.25f, 0.25f, 0.25f), 
					1 => new Vector3(0.5f, 0.5f, 0.5f), 
					2 => new Vector3(0.825f, 1f, 0.825f), 
					3 => new Vector3(1.25f, 1.5f, 1.25f), 
					4 => new Vector3(3f, 2.4f, 1.2f), 
					5 => new Vector3(2.4f, 3f, 1.2f), 
					_ => new Vector3(1.2f, 3.5f, 1.2f), 
				});
			}
			return new Bounds(new Vector3(0f, val.y / 2f + 0.01f, val.z / 2f), val);
		}

		public static GameObject Build(NvItemDef def, GameObject template, ObjModel model, float valueMultiplier, float typicalMass, Vector2 typicalValue)
		{
			//IL_0028: 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_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_01a0: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			//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_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: 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_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(template, Holder);
			((Object)val).name = "Valuable NV " + def.DisplayName;
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			ValuableObject component = val.GetComponent<ValuableObject>();
			component.volumeType = def.Size;
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				if (val2 is MeshRenderer || val2 is SkinnedMeshRenderer)
				{
					MeshFilter component2 = ((Component)val2).GetComponent<MeshFilter>();
					Object.DestroyImmediate((Object)(object)val2);
					if ((Object)(object)component2 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)component2);
					}
				}
			}
			LODGroup[] componentsInChildren2 = val.GetComponentsInChildren<LODGroup>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			string tag = "Phys Grab Object";
			int layer = LayerMask.NameToLayer("PhysGrabObject");
			PhysGrabObjectCollider componentInChildren = val.GetComponentInChildren<PhysGrabObjectCollider>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				tag = ((Component)componentInChildren).gameObject.tag;
				layer = ((Component)componentInChildren).gameObject.layer;
			}
			PhysGrabObjectBoxCollider[] componentsInChildren3 = val.GetComponentsInChildren<PhysGrabObjectBoxCollider>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
			}
			PhysGrabObjectCollider[] componentsInChildren4 = val.GetComponentsInChildren<PhysGrabObjectCollider>(true);
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren4[i]);
			}
			Collider[] componentsInChildren5 = val.GetComponentsInChildren<Collider>(true);
			foreach (Collider val3 in componentsInChildren5)
			{
				if (!val3.isTrigger)
				{
					Object.DestroyImmediate((Object)(object)val3);
				}
			}
			string source;
			Bounds env = Envelope(component, def.Size, out source);
			GameObject val4 = new GameObject("NV Model");
			val4.transform.SetParent(val.transform, false);
			float scale;
			bool rotated;
			Bounds val5 = PlaceModel(val4.transform, model.Mesh.bounds, env, def.TargetSize, out scale, out rotated);
			GameObject val6 = new GameObject("NV Visual");
			val6.transform.SetParent(val4.transform, false);
			val6.AddComponent<MeshFilter>().sharedMesh = model.Mesh;
			MeshRenderer obj = val6.AddComponent<MeshRenderer>();
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			Material[] source2 = (((Renderer)obj).sharedMaterials = model.Materials.Select(MakeMaterial).ToArray());
			int num = BuildColliders(val4.transform, model.Mesh, tag, layer);
			Transform val7 = val.transform.Find("Force Grab Point");
			if ((Object)(object)val7 != (Object)null)
			{
				val7.localPosition = ((Bounds)(ref val5)).center;
			}
			RoomVolumeCheck component3 = val.GetComponent<RoomVolumeCheck>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.CheckPosition = ((Bounds)(ref val5)).center;
				component3.currentSize = ((Bounds)(ref val5)).size + new Vector3(0.011f, 0.011f, 0.016f);
			}
			float num2 = 0f;
			Value val8 = null;
			if ((Object)(object)component.physAttributePreset != (Object)null)
			{
				PhysAttribute val9 = Object.Instantiate<PhysAttribute>(component.physAttributePreset);
				((Object)val9).name = "PhysAttribute - NV " + def.DisplayName;
				((Object)val9).hideFlags = (HideFlags)32;
				float num3 = ((typicalMass > 0f) ? typicalMass : val9.mass);
				float num4 = ((Plugin.MassMultiplier != null) ? Plugin.MassMultiplier.Value : 1f);
				val9.mass = ((def.FixedMass > 0f) ? def.FixedMass : Mathf.Max(0.05f, num3 * def.MassFactor * num4));
				component.physAttributePreset = val9;
				num2 = val9.mass;
			}
			if ((Object)(object)component.valuePreset != (Object)null)
			{
				Value val10 = ScriptableObject.CreateInstance<Value>();
				((Object)val10).name = "Value - NV " + def.DisplayName;
				((Object)val10).hideFlags = (HideFlags)32;
				float num5 = def.ValueFactor * valueMultiplier;
				float num6 = ((typicalValue.x > 0f) ? typicalValue.x : component.valuePreset.valueMin);
				float num7 = ((typicalValue.y > 0f) ? typicalValue.y : component.valuePreset.valueMax);
				val10.valueMin = num6 * num5;
				val10.valueMax = Mathf.Max(num7, num6) * num5;
				component.valuePreset = val10;
				val8 = val10;
			}
			if (def.Action != null)
			{
				((NvAction)(object)val.AddComponent(def.Action)).ItemId = def.Id;
			}
			string text = string.Join(", ", (from mb in val.GetComponentsInChildren<MonoBehaviour>(true)
				where (Object)(object)mb != (Object)null && !KnownCommon.Contains(((object)mb).GetType().Name) && !(mb is NvAction)
				select ((object)mb).GetType().Name).Distinct());
			ManualLogSource log = Plugin.Log;
			object[] obj2 = new object[5] { def.Id, def.Size, null, null, null };
			Vector3 size = ((Bounds)(ref env)).size;
			obj2[2] = ((Vector3)(ref size)).ToString("F2");
			obj2[3] = source;
			obj2[4] = scale;
			string text2 = string.Format("  {0}: {1} zone {2} ({3}), scale {4:0.00}", obj2);
			string arg = (rotated ? ", rotated 90°" : "");
			size = ((Bounds)(ref val5)).size;
			log.LogInfo((object)(text2 + string.Format("{0}, size {1} m, {2} box colliders, ", arg, ((Vector3)(ref size)).ToString("F2"), num) + string.Format("mass {0:0.0}, value ${1:0}-{2:0}, action {3}", num2, ((Object)(object)val8 != (Object)null) ? val8.valueMin : 0f, ((Object)(object)val8 != (Object)null) ? val8.valueMax : 0f, def.Action?.Name ?? "-") + ((text.Length > 0) ? (", other scripts: " + text) : "")));
			Plugin.Log.LogInfo((object)("    materials: " + string.Join(", ", source2.Select((Material m) => ((Object)m).name.Replace("NV ", "") + "=" + ((Object)m.shader).name + "#" + ColorUtility.ToHtmlStringRGB(m.color)))));
			return val;
		}

		private static Bounds PlaceModel(Transform t, Bounds ours, Bounds env, float target, out float scale, out bool rotated)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_003d: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00b9: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: 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)
			Vector3 size = ((Bounds)(ref ours)).size;
			float num = -1f;
			rotated = false;
			for (int i = 0; i < 2; i++)
			{
				Vector3 val = (Vector3)((i == 1) ? new Vector3(size.z, size.y, size.x) : size);
				float num2 = Mathf.Min(Mathf.Min(((Bounds)(ref env)).size.x * 0.92f / Mathf.Max(val.x, 0.001f), Mathf.Min(((Bounds)(ref env)).size.y * 0.92f / Mathf.Max(val.y, 0.001f), ((Bounds)(ref env)).size.z * 0.92f / Mathf.Max(val.z, 0.001f))), target / Mathf.Max(val.x, Mathf.Max(val.y, val.z)));
				if (num2 > num * 1.02f)
				{
					num = num2;
					rotated = i == 1;
				}
			}
			scale = num;
			Quaternion val2 = (t.localRotation = (rotated ? Quaternion.Euler(0f, 90f, 0f) : Quaternion.identity));
			t.localScale = Vector3.one * scale;
			Vector3 val4 = val2 * (((Bounds)(ref ours)).center * scale);
			Vector3 val5 = (rotated ? (new Vector3(size.z, size.y, size.x) * scale) : (size * scale));
			float y = ((Bounds)(ref env)).min.y;
			t.localPosition = new Vector3(((Bounds)(ref env)).center.x - val4.x, y - (val4.y - val5.y / 2f), ((Bounds)(ref env)).center.z - val4.z);
			return new Bounds(new Vector3(((Bounds)(ref env)).center.x, y + val5.y / 2f, ((Bounds)(ref env)).center.z), val5);
		}

		private static int BuildColliders(Transform parent, Mesh mesh, string tag, int layer)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0016: 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_0032: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_011e: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] vertices = mesh.vertices;
			Bounds bounds = mesh.bounds;
			Vector3 size = ((Bounds)(ref bounds)).size;
			int num = ((!(size.x >= size.y) || !(size.x >= size.z)) ? ((size.y >= size.z) ? 1 : 2) : 0);
			float num2 = ((Vector3)(ref size))[num];
			float num3 = Mathf.Max(0.0001f, num switch
			{
				1 => Mathf.Max(size.x, size.z), 
				0 => Mathf.Max(size.y, size.z), 
				_ => Mathf.Max(size.x, size.y), 
			});
			float num4 = num2 / num3;
			int num5 = ((num4 < 1.5f) ? 1 : Mathf.Clamp(Mathf.CeilToInt(num4 * 1.2f), 2, 6));
			float num6 = num2 * 0.04f;
			int num7 = 0;
			Vector3 min = ((Bounds)(ref bounds)).min;
			float num8 = ((Vector3)(ref min))[num];
			float num9 = num2 / (float)num5;
			for (int i = 0; i < num5; i++)
			{
				float num10 = num8 + num9 * (float)i - num9 * 0.05f;
				float num11 = num8 + num9 * (float)(i + 1) + num9 * 0.05f;
				bool flag = false;
				Bounds val = default(Bounds);
				Vector3[] array = vertices;
				for (int j = 0; j < array.Length; j++)
				{
					Vector3 val2 = array[j];
					float num12 = ((Vector3)(ref val2))[num];
					if (!(num12 < num10) && !(num12 > num11))
					{
						if (!flag)
						{
							((Bounds)(ref val))..ctor(val2, Vector3.zero);
							flag = true;
						}
						else
						{
							((Bounds)(ref val)).Encapsulate(val2);
						}
					}
				}
				if (flag)
				{
					Vector3 size2 = ((Bounds)(ref val)).size;
					for (int k = 0; k < 3; k++)
					{
						((Vector3)(ref size2))[k] = Mathf.Max(((Vector3)(ref size2))[k], num6);
					}
					GameObject val3 = new GameObject("NV Collider " + i);
					val3.transform.SetParent(parent, false);
					val3.tag = tag;
					val3.layer = layer;
					BoxCollider obj = val3.AddComponent<BoxCollider>();
					obj.center = ((Bounds)(ref val)).center;
					obj.size = size2;
					val3.AddComponent<PhysGrabObjectCollider>();
					num7++;
				}
			}
			return num7;
		}

		private static Material MakeMaterial(ObjMaterial src)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_standard == (Object)null)
			{
				_standard = Shader.Find("Standard");
			}
			if ((Object)(object)_standard == (Object)null && !_standardWarned)
			{
				_standardWarned = true;
				Plugin.Log.LogError((object)"Shader \"Standard\" not found - items will use the fallback shader.");
			}
			Material val = new Material(((Object)(object)_standard != (Object)null) ? _standard : Shader.Find("Legacy Shaders/Diffuse"));
			Color val2 = (((int)QualitySettings.activeColorSpace == 1) ? ((Color)(ref src.Color)).gamma : src.Color);
			val2.a = src.Color.a;
			string text = src.Name.ToLowerInvariant();
			float num = src.Smoothness;
			if (text.Contains("leather") || text.Contains("matte") || text.Contains("suede") || text.Contains("paper") || text.Contains("plush") || text.Contains("fur") || text.Contains("feather") || text.Contains("twine") || text.Contains("cord"))
			{
				num = Mathf.Min(num, 0.3f);
			}
			float num2 = (src.Metallic ? 0.65f : 0f);
			val.color = new Color(val2.r, val2.g, val2.b, 1f);
			val.SetFloat("_Glossiness", Mathf.Clamp(num, 0.05f, 0.9f));
			val.SetFloat("_Metallic", num2);
			val.DisableKeyword("_EMISSION");
			val.SetColor("_EmissionColor", Color.black);
			if (((Color)(ref src.Emission)).maxColorComponent > 0.01f)
			{
				Color val3 = src.Emission / Mathf.Max(1f, ((Color)(ref src.Emission)).maxColorComponent) * 2.2f;
				val.EnableKeyword("_EMISSION");
				val.SetColor("_EmissionColor", val3);
				val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
			}
			if (src.Color.a < 0.99f)
			{
				val.SetOverrideTag("RenderType", "Transparent");
				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.renderQueue = 3000;
				val.color = new Color(val2.r, val2.g, val2.b, Mathf.Max(src.Color.a, 0.25f));
			}
			((Object)val).name = "NV " + src.Name;
			((Object)val).hideFlags = (HideFlags)32;
			return val;
		}
	}
}
namespace NaughtyValuables.Actions
{
	public static class Fx
	{
		private class PopupMover : MonoBehaviour
		{
			private float _t;

			private TextMesh _tm;

			private Color _c;

			private void Start()
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				_tm = ((Component)this).GetComponent<TextMesh>();
				_c = _tm.color;
			}

			private void Update()
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: 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_0037: 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_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: 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_0117: Unknown result type (might be due to invalid IL or missing references)
				_t += Time.deltaTime;
				Transform transform = ((Component)this).transform;
				transform.position += Vector3.up * Time.deltaTime * 0.45f;
				Camera main = Camera.main;
				if ((Object)(object)main != (Object)null)
				{
					((Component)this).transform.rotation = Quaternion.LookRotation(((Component)this).transform.position - ((Component)main).transform.position);
				}
				float num = Mathf.Clamp01(1.6f - _t);
				_tm.color = new Color(_c.r, _c.g, _c.b, num);
				float num2 = ((_t < 0.15f) ? Mathf.Lerp(0.4f, 1.15f, _t / 0.15f) : Mathf.Lerp(1.15f, 1f, (_t - 0.15f) * 4f));
				((Component)this).transform.localScale = Vector3.one * num2;
				if (_t > 1.6f)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		private class HintOverlay : MonoBehaviour
		{
			private static HintOverlay _inst;

			private string _text = "";

			private float _until;

			private GUIStyle _style;

			public static void Show(string text, float time)
			{
				//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)(object)_inst == (Object)null)
				{
					GameObject val = new GameObject("NV Hint Overlay");
					Object.DontDestroyOnLoad((Object)val);
					((Object)val).hideFlags = (HideFlags)61;
					_inst = val.AddComponent<HintOverlay>();
				}
				_inst._text = text;
				_inst._until = Mathf.Max(_inst._until, Time.time + time);
			}

			private void OnGUI()
			{
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: 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_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Expected O, but got Unknown
				if (!(Time.time > _until) && !string.IsNullOrEmpty(_text))
				{
					if (_style == null)
					{
						_style = new GUIStyle(GUI.skin.label)
						{
							alignment = (TextAnchor)4,
							fontSize = Mathf.Max(16, Screen.height / 40),
							fontStyle = (FontStyle)1
						};
					}
					float num = (float)Screen.width * 0.6f;
					float num2 = (float)_style.fontSize * 2f;
					Rect val = default(Rect);
					((Rect)(ref val))..ctor(((float)Screen.width - num) / 2f, (float)Screen.height * 0.78f, num, num2);
					Color color = GUI.color;
					GUI.color = new Color(0f, 0f, 0f, 0.75f);
					GUI.Label(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _text, _style);
					GUI.color = new Color(1f, 0.55f, 0.85f, 1f);
					GUI.Label(val, _text, _style);
					GUI.color = color;
				}
			}
		}

		private class MaskOverlay : MonoBehaviour
		{
			private static MaskOverlay _inst;

			private static Texture2D _tex;

			private float _until;

			private float _alpha;

			public static void Show(float time)
			{
				//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)(object)_inst == (Object)null)
				{
					GameObject val = new GameObject("NV Mask Overlay");
					Object.DontDestroyOnLoad((Object)val);
					((Object)val).hideFlags = (HideFlags)61;
					_inst = val.AddComponent<MaskOverlay>();
				}
				_inst._until = Mathf.Max(_inst._until, Time.time + time);
			}

			private static Texture2D Tex()
			{
				//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_0030: Expected O, but got Unknown
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_tex != (Object)null)
				{
					return _tex;
				}
				_tex = new Texture2D(256, 256, (TextureFormat)4, false)
				{
					wrapMode = (TextureWrapMode)1
				};
				Color32[] array = (Color32[])(object)new Color32[65536];
				for (int i = 0; i < 256; i++)
				{
					for (int j = 0; j < 256; j++)
					{
						float num = (float)j / 256f;
						float num2 = (float)i / 256f;
						float num3 = Mathf.Sqrt(Mathf.Pow((num - 0.32f) / 0.2f, 2f) + Mathf.Pow((num2 - 0.5f) / 0.28f, 2f));
						float num4 = Mathf.Sqrt(Mathf.Pow((num - 0.68f) / 0.2f, 2f) + Mathf.Pow((num2 - 0.5f) / 0.28f, 2f));
						float num5 = Mathf.Clamp01((Mathf.Min(num3, num4) - 0.75f) * 3f);
						array[i * 256 + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)(num5 * 255f));
					}
				}
				_tex.SetPixels32(array);
				_tex.Apply();
				return _tex;
			}

			private void Update()
			{
				float num = ((Time.time < _until) ? 0.93f : 0f);
				_alpha = Mathf.MoveTowards(_alpha, num, Time.deltaTime * 3f);
			}

			private void OnGUI()
			{
				//IL_000e: 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_0048: Unknown result type (might be due to invalid IL or missing references)
				if (!(_alpha <= 0.01f))
				{
					Color color = GUI.color;
					GUI.color = new Color(1f, 1f, 1f, _alpha);
					GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Tex(), (ScaleMode)0, true);
					GUI.color = color;
				}
			}
		}

		private static readonly FieldRef<PlayerAvatar, PlayerTumble> TumbleRef = Ref<PlayerAvatar, PlayerTumble>("tumble");

		private static readonly FieldRef<PlayerAvatar, PlayerVoiceChat> VoiceRef = Ref<PlayerAvatar, PlayerVoiceChat>("voiceChat");

		private static readonly FieldRef<PlayerAvatar, bool> DeadRef = Ref<PlayerAvatar, bool>("deadSet");

		private static readonly FieldRef<PlayerAvatar, bool> DisabledRef = Ref<PlayerAvatar, bool>("isDisabled");

		private static readonly FieldRef<ValuableObject, float> ValueRef = Ref<ValuableObject, float>("dollarValueCurrent");

		private static readonly FieldRef<RoomVolumeCheck, bool> InExtractionRef = Ref<RoomVolumeCheck, bool>("inExtractionPoint");

		private static readonly FieldRef<RoomVolumeCheck, bool> InTruckRef = Ref<RoomVolumeCheck, bool>("inTruck");

		private static PhysicsMaterial _slippery;

		private static Font _font;

		private static bool _fontTried;

		public static PhysicsMaterial Slippery
		{
			get
			{
				//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_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Expected O, but got Unknown
				if ((Object)(object)_slippery == (Object)null)
				{
					_slippery = new PhysicsMaterial("NV Slippery")
					{
						dynamicFriction = 0.01f,
						staticFriction = 0.01f,
						bounciness = 0.05f,
						frictionCombine = (PhysicsMaterialCombine)2,
						bounceCombine = (PhysicsMaterialCombine)2
					};
					((Object)_slippery).hideFlags = (HideFlags)32;
				}
				return _slippery;
			}
		}

		public static bool AtExtraction(GameObject go)
		{
			RoomVolumeCheck val = (((Object)(object)go != (Object)null) ? go.GetComponent<RoomVolumeCheck>() : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			if (InExtractionRef == null || !InExtractionRef.Invoke(val))
			{
				if (InTruckRef != null)
				{
					return InTruckRef.Invoke(val);
				}
				return false;
			}
			return true;
		}

		public static int Shockwave(Vector3 center, float radius, float strength, PhysGrabObject except)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			HashSet<PhysGrabObject> hashSet = new HashSet<PhysGrabObject>();
			Collider[] array = Physics.OverlapSphere(center, radius, LayerMask.GetMask(new string[1] { "PhysGrabObject" }), (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				PhysGrabObject componentInParent = ((Component)array[i]).GetComponentInParent<PhysGrabObject>();
				if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent == (Object)(object)except) && hashSet.Add(componentInParent) && !((Object)(object)componentInParent.rb == (Object)null) && !componentInParent.rb.isKinematic)
				{
					Vector3 val = componentInParent.rb.worldCenterOfMass - center;
					float num2 = 1f - Mathf.Clamp01(((Vector3)(ref val)).magnitude / radius);
					Rigidbody rb = componentInParent.rb;
					Vector3 val2 = ((Vector3)(ref val)).normalized + Vector3.up * 0.6f;
					rb.AddForce(((Vector3)(ref val2)).normalized * strength * num2, (ForceMode)2);
					num++;
				}
			}
			return num;
		}

		private static FieldRef<T, F> Ref<T, F>(string field)
		{
			try
			{
				return AccessTools.FieldRefAccess<T, F>(field);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[Action] game field " + typeof(T).Name + "." + field + " not found: " + ex.Message));
				return null;
			}
		}

		public static PlayerTumble Tumble(PlayerAvatar a)
		{
			if (!((Object)(object)a != (Object)null) || TumbleRef == null)
			{
				return null;
			}
			return TumbleRef.Invoke(a);
		}

		public static PlayerVoiceChat Voice(PlayerAvatar a)
		{
			if (!((Object)(object)a != (Object)null) || VoiceRef == null)
			{
				return null;
			}
			return VoiceRef.Invoke(a);
		}

		public static bool Alive(PlayerAvatar a)
		{
			if ((Object)(object)a != (Object)null && (DeadRef == null || !DeadRef.Invoke(a)))
			{
				if (DisabledRef != null)
				{
					return !DisabledRef.Invoke(a);
				}
				return true;
			}
			return false;
		}

		public static int ViewId(PlayerAvatar a)
		{
			if (!((Object)(object)a != (Object)null) || !((Object)(object)a.photonView != (Object)null))
			{
				return -1;
			}
			return a.photonView.ViewID;
		}

		public static Vector3 Chest(PlayerAvatar a)
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)a).transform.position + Vector3.up * 0.9f;
		}

		public static bool IsLocal(int playerViewId)
		{
			PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
			if ((Object)(object)val != (Object)null)
			{
				if (playerViewId >= 0 && SemiFunc.IsMultiplayer())
				{
					return ViewId(val) == playerViewId;
				}
				return true;
			}
			return false;
		}

		public static List<PlayerAvatar> PlayersNear(Vector3 pos, float radius)
		{
			//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)
			List<PlayerAvatar> list = new List<PlayerAvatar>();
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (Alive(item) && Vector3.Distance(Chest(item), pos) <= radius)
				{
					list.Add(item);
				}
			}
			return list;
		}

		public static List<Enemy> EnemiesNear(Vector3 pos, float radius)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			List<Enemy> list = new List<Enemy>();
			if ((Object)(object)EnemyDirector.instance == (Object)null || EnemyDirector.instance.enemiesSpawned == null)
			{
				return list;
			}
			foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned)
			{
				if (!((Object)(object)item == (Object)null) && ((Component)item).gameObject.activeInHierarchy)
				{
					Enemy componentInChildren = ((Component)item).GetComponentInChildren<Enemy>();
					if (!((Object)(object)componentInChildren == (Object)null) && ((Component)componentInChildren).gameObject.activeInHierarchy && Vector3.Distance(((Object)(object)componentInChildren.CenterTransform != (Object)null) ? componentInChildren.CenterTransform.position : ((Component)componentInChildren).transform.position, pos) <= radius)
					{
						list.Add(componentInChildren);
					}
				}
			}
			return list;
		}

		public static void Stun(Enemy e, float time)
		{
			EnemyStateStunned component = ((Component)e).GetComponent<EnemyStateStunned>();
			if ((Object)(object)component != (Object)null)
			{
				component.Set(time);
			}
			else
			{
				e.Freeze(time);
			}
		}

		public static void TumblePlayer(PlayerAvatar a, float time)
		{
			PlayerTumble val = Tumble(a);
			if (!((Object)(object)val == (Object)null))
			{
				val.TumbleSet(true, false, false);
				val.TumbleOverrideTime(time);
			}
		}

		public static float ValueOf(ValuableObject v)
		{
			if (!((Object)(object)v != (Object)null) || ValueRef == null)
			{
				return 0f;
			}
			return ValueRef.Invoke(v);
		}

		public static void SetValue(ValuableObject v, float value)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)v == (Object)null)
			{
				return;
			}
			if (SemiFunc.IsMultiplayer())
			{
				PhotonView component = ((Component)v).GetComponent<PhotonView>();
				if (component != null)
				{
					component.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { value });
				}
			}
			else
			{
				v.DollarValueSetRPC(value, default(PhotonMessageInfo));
			}
		}

		public static void Popup(string text, Vector3 pos, Color color, float size = 1f)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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)
			if (Plugin.ShowPopupText == null || !Plugin.ShowPopupText.Value)
			{
				return;
			}
			if ((Object)(object)_font == (Object)null && !_fontTried)
			{
				_fontTried = true;
				string[] array = new string[2] { "LegacyRuntime.ttf", "Arial.ttf" };
				foreach (string text2 in array)
				{
					try
					{
						_font = Resources.GetBuiltinResource<Font>(text2);
					}
					catch
					{
					}
					if ((Object)(object)_font != (Object)null)
					{
						break;
					}
				}
				if ((Object)(object)_font == (Object)null)
				{
					_font = Resources.FindObjectsOfTypeAll<Font>().FirstOrDefault();
				}
				if ((Object)(object)_font == (Object)null)
				{
					Plugin.Log.LogWarning((object)"[Action] no font found: popup texts disabled.");
				}
			}
			if (!((Object)(object)_font == (Object)null))
			{
				GameObject val = new GameObject("NV Popup");
				val.transform.position = pos;
				TextMesh obj2 = val.AddComponent<TextMesh>();
				obj2.text = text;
				obj2.font = _font;
				obj2.fontSize = 64;
				obj2.characterSize = 0.012f * size;
				obj2.anchor = (TextAnchor)4;
				obj2.alignment = (TextAlignment)1;
				obj2.fontStyle = (FontStyle)1;
				obj2.color = color;
				((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = _font.material;
				val.AddComponent<PopupMover>();
			}
		}

		public static void Hint(string text, float time)
		{
			HintOverlay.Show(text, time);
		}

		public static void MaskVignette(float time)
		{
			MaskOverlay.Show(time);
		}

		public static IEnumerator SquashRoutine(Transform t, float amount, float time)
		{
			Vector3 baseScale = t.localScale;
			float el = 0f;
			while (el < time && (Object)(object)t != (Object)null)
			{
				el += Time.deltaTime;
				float num = el / time;
				float num2 = Mathf.Sin(num * MathF.PI * 4f) * (1f - num) * amount;
				t.localScale = new Vector3(baseScale.x * (1f + num2 * 0.6f), baseScale.y * (1f - num2), baseScale.z * (1f + num2 * 0.6f));
				yield return null;
			}
			if ((Object)(object)t != (Object)null)
			{
				t.localScale = baseScale;
			}
		}

		public static Light AddLight(Transform parent, Vector3 localPos, Color color, float range, float intensity)
		{
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("NV Light");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = color;
			obj.range = range;
			obj.intensity = intensity;
			obj.shadows = (LightShadows)0;
			return obj;
		}

		public static GameObject Blob(Vector3 pos, Vector3 scale, Color color, bool sphere = true)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)((!sphere) ? 2 : 0));
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			val.transform.position = pos;
			val.transform.localScale = scale;
			Shader val2 = Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				Material val3 = new Material(val2)
				{
					color = color
				};
				val3.SetFloat("_Glossiness", 0.85f);
				((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = val3;
			}
			return val;
		}
	}
	public class NvPopper : NvAction
	{
		private float _cd;

		protected override void Tick(float dt)
		{
			_cd -= dt;
		}

		protected override void OnShake()
		{
			Trigger("shaken");
		}

		protected override void OnRelease()
		{
			if (base.ReleaseSpeed > 3f)
			{
				Trigger("thrown");
			}
		}

		protected override void OnImpact(int level)
		{
			if (level == 3)
			{
				Trigger("slammed");
			}
		}

		private void Trigger(string why)
		{
			if (!(_cd > 0f))
			{
				_cd = 2.5f;
				((MonoBehaviour)this).StartCoroutine(Pops());
				Log("pop-pop-pop (" + why + ")");
			}
		}

		private IEnumerator Pops()
		{
			for (int i = 0; i < 6; i++)
			{
				Play("pop", 0.9f, 1f + (float)i * 0.08f);
				Squash(0.15f, 0.12f);
				if (NvAction.IsHost && !base.Held)
				{
					Push(Vector3.up * 0.9f + Random.insideUnitSphere * 0.4f);
				}
				yield return (object)new WaitForSeconds(0.1f);
			}
			Play("giggle", 0.8f, 1.1f);
		}
	}
	public class NvRoller : NvAction
	{
		private float _cd;

		private float _roll;

		private Vector3 _dir;

		private Vector3 _spinAxis;

		private Vector3 _visPos;

		private Quaternion _visRot;

		private bool _spinning;

		protected override void Tick(float dt)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			_cd -= dt;
			if (_roll > 0f)
			{
				_roll -= dt;
				if ((Object)(object)Visual != (Object)null)
				{
					if (!_spinning)
					{
						_visPos = Visual.localPosition;
						_visRot = Visual.localRotation;
						_spinning = true;
					}
					Visual.RotateAround(base.VisualCenter, _spinAxis, 900f * dt);
				}
				if (NvAction.IsHost && !base.Held && (Object)(object)Rb != (Object)null && !Rb.isKinematic)
				{
					Vector3 linearVelocity = Rb.linearVelocity;
					Vector3 val = _dir * 3.2f;
					Rb.AddForce(new Vector3(val.x - linearVelocity.x, 0f, val.z - linearVelocity.z) * 6f, (ForceMode)5);
				}
				if (base.Held)
				{
					_roll = 0f;
				}
			}
			if (_roll <= 0f && _spinning && (Object)(object)Visual != (Object)null)
			{
				Visual.localPosition = _visPos;
				Visual.localRotation = _visRot;
				_spinning = false;
			}
		}

		protected override void OnRelease()
		{
			if (NvAction.IsHost && !(_cd > 0f))
			{
				_cd = 5f;
				((MonoBehaviour)this).StartCoroutine(StartRoll());
			}
		}

		private IEnumerator StartRoll()
		{
			yield return (object)new WaitForSeconds(0.3f);
			if (!base.Held)
			{
				Vector3 val = (((Object)(object)base.LastHolder != (Object)null) ? ((Component)base.LastHolder).transform.forward : Random.onUnitSphere);
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
				{
					val = Vector3.forward;
				}
				Send(1, Mathf.Atan2(val.x, val.z) * 57.29578f);
			}
		}

		public override void OnNet(byte code, float arg, int target)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			_dir = Quaternion.Euler(0f, arg, 0f) * Vector3.forward;
			Vector3 val = Vector3.Cross(Vector3.up, _dir);
			_spinAxis = ((Vector3)(ref val)).normalized;
			_roll = 2.5f;
			Push(_dir * 2.5f + Vector3.up * 0.5f);
			Play("weee", 0.9f);
			Log("rolls away like a wheel");
		}
	}
	public class NvSucker : NvAction
	{
		private float _cd = 2f;

		private float _pull;

		private readonly List<Rigidbody> _targets = new List<Rigidbody>();

		private float _sound;

		protected override void Tick(float dt)
		{
			_cd -= dt;
			if (NvAction.IsHost && base.Held && _cd <= 0f && base.HeldTime > 1f)
			{
				Suck("auto");
			}
		}

		protected override void OnShake()
		{
			if (NvAction.IsHost && _cd <= 2.5f)
			{
				Suck("shaken");
			}
		}

		private void Suck(string why)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			_cd = 7f;
			_targets.Clear();
			Collider[] array = Physics.OverlapSphere(base.Center, 2.5f, LayerMask.GetMask(new string[1] { "PhysGrabObject" }), (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				PhysGrabObject componentInParent = ((Component)array[i]).GetComponentInParent<PhysGrabObject>();
				if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent == (Object)(object)Pgo) && !((Object)(object)componentInParent.rb == (Object)null) && !componentInParent.rb.isKinematic && !(componentInParent.rb.mass > 2.5f) && componentInParent.playerGrabbing.Count <= 0 && !_targets.Contains(componentInParent.rb) && !((Object)(object)((Component)componentInParent).GetComponent<PlayerTumble>() != (Object)null) && !((Object)(object)((Component)componentInParent).GetComponentInParent<PlayerAvatar>() != (Object)null))
				{
					_targets.Add(componentInParent.rb);
				}
			}
			_pull = 1.2f;
			Send(1, _targets.Count);
			Log($"sucks in {_targets.Count} small objects ({why})");
		}

		private void FixedUpdate()
		{
			//IL_0047: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (!NvAction.IsHost || _pull <= 0f)
			{
				return;
			}
			_pull -= Time.fixedDeltaTime;
			foreach (Rigidbody target in _targets)
			{
				if (!((Object)(object)target == (Object)null))
				{
					Vector3 val = base.Center - target.worldCenterOfMass;
					if (((Vector3)(ref val)).magnitude > 0.4f)
					{
						target.AddForce(((Vector3)(ref val)).normalized * 11f + Vector3.up * 2f, (ForceMode)5);
					}
				}
			}
		}

		protected override void OnGrabStart()
		{
			Play("squeak", 0.7f);
		}

		private void LateUpdate()
		{
			if (!(_sound <= 0f))
			{
				_sound -= Time.deltaTime;
				if (_sound <= 0f)
				{
					StopLoop();
				}
			}
		}

		public override void OnNet(byte code, float arg, int target)
		{
			Loop("suck", 1f);
			_sound = 1.3f;
			Play("squeak", 0.9f, 1.2f);
			Squash(0.12f);
			Log("suction sound");
		}
	}
	public class NvSlippery : NvAction
	{
		private class LubePuddle : MonoBehaviour
		{
			public float Life = 10f;

			public float Radius = 1.05f;

			private float _t;

			private float _slipCd;

			private AudioSource _src;

			private void Update()
			{
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: 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_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				_t += Time.deltaTime;
				_slipCd -= Time.deltaTime;
				if (_t > Life)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
				PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
				if ((Object)(object)val == (Object)null || _slipCd > 0f || !Fx.Alive(val))
				{
					return;
				}
				Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
				if (!(Mathf.Abs(val2.y) < 0.6f))
				{
					return;
				}
				Vector2 val3 = new Vector2(val2.x, val2.z);
				if (((Vector2)(ref val3)).magnitude < Radius)
				{
					_slipCd = 3f;
					PlayerTumble val4 = Fx.Tumble(val);
					if ((Object)(object)val4 != (Object)null)
					{
						val4.TumbleRequest(true, false);
						val4.TumbleOverrideTime(1.5f);
					}
					if ((Object)(object)_src == (Object)null)
					{
						_src = ((Component)this).gameObject.AddComponent<AudioSource>();
						_src.spatialBlend = 0f;
					}
					AudioClip val5 = Synth.Get("splash");
					if ((Object)(object)val5 != (Object)null)
					{
						_src.PlayOneShot(val5, 0.8f);
					}
					Plugin.Log.LogInfo((object)"[Action] lube_bottle: local player slipped");
				}
			}
		}

		private float _cd;

		protected override void Tick(float dt)
		{
			_cd -= dt;
			if (NvAction.IsHost && (Object)(object)Pgo != (Object)null && !base.Held)
			{
				Pgo.OverrideMaterial(Fx.Slippery, 0.2f);
			}
		}

		protected override void OnBreak()
		{
			if (!(_cd > 0f))
			{
				_cd = 3f;
				Play("splash", 0.6f, 1.2f);
				Puddle(1.2f, 5f);
				Log("leaks: small lube puddle for 5 s");
			}
		}

		protected override void OnDestroyed()
		{
			Puddle(2.4f, 10f);
			Log("bottle broke: big lube puddle for 10 s");
		}

		private void Puddle(float size, float life)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = base.Center;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val + Vector3.up * 0.3f, Vector3.down, ref val2, 3f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1))
			{
				val = ((RaycastHit)(ref val2)).point;
			}
			GameObject obj = Fx.Blob(val + Vector3.up * 0.01f, new Vector3(size, 0.004f, size), new Color(1f, 0.55f, 0.85f, 1f), sphere: false);
			((Object)obj).name = "NV Lube Puddle";
			LubePuddle lubePuddle = obj.AddComponent<LubePuddle>();
			lubePuddle.Life = life;
			lubePuddle.Radius = size * 0.48f;
		}
	}
	public class NvCuffs : NvAction
	{
		private float _cuffed;

		private float _cd;

		private float _hitCd;

		private PlayerAvatar _a;

		private PlayerAvatar _b;

		protected override void Tick(float dt)
		{
			//IL_0140: 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)
			_cd -= dt;
			_hitCd -= dt;
			if (_cuffed <= 0f && _cd <= 0f && Holders.Count >= 2)
			{
				_a = Holders[0];
				_b = Holders[1];
				_cuffed = 15f;
				_cd = 30f;
				Play("cuff");
				Log(((Object)_a).name + " and " + ((Object)_b).name + " are cuffed together for 15 s");
			}
			if (_cuffed <= 0f)
			{
				return;
			}
			_cuffed -= dt;
			PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
			if (!((Object)(object)val == (Object)null) && (!((Object)(object)val != (Object)(object)_a) || !((Object)(object)val != (Object)(object)_b)) && !((Object)(object)_a == (Object)null) && !((Object)(object)_b == (Object)null) && !((Object)(object)PlayerController.instance == (Object)null))
			{
				float num = Vector3.Distance(((Component)_a).transform.position, ((Component)_b).transform.position);
				PlayerController.instance.OverrideSpeed((num > 2.5f) ? 0.35f : 0.65f, 0.2f, -1f);
				if (_cuffed <= 0f)
				{
					Play("cuff", 0.7f, 1.3f);
				}
			}
		}

		protected override void OnImpact(int level)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (!NvAction.IsHost || _hitCd > 0f || level < 2)
			{
				return;
			}
			using (List<Enemy>.Enumerator enumerator = Fx.EnemiesNear(base.Center, 1.8f).GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					enumerator.Current.Freeze(3f);
					_hitCd = 4f;
					Send(1);
					return;
				}
			}
			foreach (PlayerAvatar item in Fx.PlayersNear(base.Center, 1.5f))
			{
				if (!Holders.Contains(item) && !((Object)(object)item == (Object)(object)base.LastHolder))
				{
					_hitCd = 4f;
					Send(2, 0f, Fx.ViewId(item));
					break;
				}
			}
		}

		public override void OnNet(byte code, float arg, int target)
		{
			Play("cuff");
			if (code == 1)
			{
				Log("cuffed an enemy (frozen 3 s)");
				return;
			}
			if (Fx.IsLocal(target) && (Object)(object)PlayerController.instance != (Object)null)
			{
				PlayerController.instance.OverrideSpeed(0.5f, 8f, -1f);
			}
			Log("cuffed a teammate (slow for 8 s)");
		}
	}
	public class NvPaddle : NvAction
	{
		private float _cd;

		protected override void Tick(float dt)
		{
			_cd -= dt;
		}

		protected override void OnImpact(int level)
		{
			//IL_0033: 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)
			if (level >= 2)
			{
				Play("smack", 0.5f, 1.1f);
			}
			if (!NvAction.IsHost || level < 2 || _cd > 0f)
			{
				return;
			}
			using (List<Enemy>.Enumerator enumerator = Fx.EnemiesNear(base.Center, 1.8f).GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					Fx.Stun(enumerator.Current, 2f);
					_cd = 1f;
					Send(1);
					return;
				}
			}
			foreach (PlayerAvatar item in Fx.PlayersNear(base.Center, 1.5f))
			{
				if (!Holders.Contains(item))
				{
					_cd = 1.5f;
					Fx.TumblePlayer(item, 0.8f);
					Send(2, 0f, Fx.ViewId(item));
					break;
				}
			}
		}

		public override void OnNet(byte code, float arg, int target)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Play("smack");
			if (code == 2)
			{
				Play("ding", 0.8f);
			}
			if (Fx.IsLocal(target) || code == 1)
			{
				SemiFunc.CameraShakeDistance(base.Center, 2.5f, 0.2f, 1f, 5f);
			}
			Log((code == 1) ? "smacked an enemy (stunned 2 s)" : "spanked a teammate (falls 0.8 s)");
		}
	}
	public class NvWhip : NvAction
	{
		private float _cd;

		protected override float ShakeThreshold => 2.5f;

		protected override void Tick(float dt)
		{
			_cd -= dt;
		}

		protected override void OnShake()
		{
			Crack();
		}

		protected override void OnRelease()
		{
			if (base.ReleaseSpeed > 3.5f)
			{
				Crack();
			}
		}

		private void Crack()
		{
			//IL_0023: 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)
			if (!NvAction.IsHost || _cd > 0f)
			{
				return;
			}
			_cd = 4f;
			int num = 0;
			foreach (Enemy item in Fx.EnemiesNear(base.Center, 6f))
			{
				item.DisableChase(3f);
				if (Vector3.Distance(((Component)item).transform.position, base.Center) < 3f)
				{
					Fx.Stun(item, 1.5f);
				}
				num++;
			}
			Send(1, num);
		}

		public override void OnNet(byte code, float arg, int target)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Play("crack");
			SemiFunc.CameraShakeDistance(base.Center, 2.5f, 0.15f, 1f, 6f);
			Log($"crack!