Decompiled source of DapUp v1.4.3

DapUp.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using DapUp;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using LabFusion.Network;
using LabFusion.Network.Serialization;
using LabFusion.SDK.Modules;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(DapUpMod), "DapUp", "1.4.0", "You", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DapUp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DapUp")]
[assembly: AssemblyTitle("DapUp")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DapUp
{
	public class DapUpMod : MelonMod
	{
		public enum ColorChoice
		{
			Blue,
			Cyan,
			Green,
			Yellow,
			Orange,
			Red,
			Pink,
			Purple,
			White,
			Rainbow
		}

		private class Approach
		{
			public float peak;

			public float mine;

			public float theirs;

			public float last;
		}

		private class Fx
		{
			public GameObject go;

			public Material mat;

			public int kind;

			public float t0;

			public float dur;

			public Vector3 pos;

			public Vector3 dir;

			public float dist;

			public float size;

			public float width;

			public float peak;

			public float gravity;

			public float angle;

			public float spin;

			public float aspect;

			public Color col;

			public Transform follow;
		}

		private const float PalmFacingDot = -0.35f;

		private const float FistBumpDot = 0.4f;

		private const float Cooldown = 1f;

		private const float HighFiveHeight = 0.25f;

		private const float ComboWindow = 4f;

		private const int KindHighFive = 0;

		private const int KindDap = 1;

		private const int KindBump = 2;

		private const int KindClap = 3;

		private const int KindKiss = 4;

		private readonly Dictionary<int, float> _lastClap = new Dictionary<int, float>();

		private Vector3 _prevLeft;

		private Vector3 _prevRight;

		private readonly Dictionary<(int, bool), Vector3> _prevRemote = new Dictionary<(int, bool), Vector3>();

		private RigManager[] _rigs = (RigManager[])(object)new RigManager[0];

		private RigManager _lastLocalRig;

		private float _nextRigScan;

		private float _nextDebugLog;

		private float _nextStatusLog;

		private float _nextErrorLog;

		private bool _warmed;

		private float _testPower = 0.5f;

		private readonly Dictionary<int, Approach> _approach = new Dictionary<int, Approach>();

		private readonly Dictionary<int, (int count, float time)> _combos = new Dictionary<int, (int, float)>();

		private readonly List<(float time, Vector3 pos)> _recentHits = new List<(float, Vector3)>();

		private MelonPreferences_Category _prefs;

		private MelonPreferences_Entry<bool> _enabled;

		private MelonPreferences_Entry<bool> _soundOn;

		private MelonPreferences_Entry<bool> _vfxOn;

		private MelonPreferences_Entry<bool> _hapticsOn;

		private MelonPreferences_Entry<bool> _debug;

		private MelonPreferences_Entry<bool> _speedScale;

		private MelonPreferences_Entry<bool> _selfClapOn;

		private MelonPreferences_Entry<bool> _hapticScale;

		private MelonPreferences_Entry<bool> _perfectOn;

		private MelonPreferences_Entry<bool> _comboOn;

		private MelonPreferences_Entry<bool> _glowOn;

		private MelonPreferences_Entry<bool> _syncOn;

		private MelonPreferences_Entry<bool> _pushOn;

		private MelonPreferences_Entry<bool> _hitStopOn;

		private MelonPreferences_Entry<bool> _firstRunDone;

		private MelonPreferences_Entry<float> _volume;

		private MelonPreferences_Entry<int> _vfxIntensity;

		private MelonPreferences_Entry<int> _touchCm;

		private MelonPreferences_Entry<int> _minSpeed;

		private MelonPreferences_Entry<int> _fullSpeed;

		private MelonPreferences_Entry<int> _colHigh;

		private MelonPreferences_Entry<int> _colDap;

		private MelonPreferences_Entry<int> _colBump;

		private MelonPreferences_Entry<int> _colClap;

		private MelonPreferences_Entry<int> _prefsVersion;

		private readonly Dictionary<int, float> _kissStart = new Dictionary<int, float>();

		private readonly Dictionary<int, float> _kissCool = new Dictionary<int, float>();

		private const float ClapMinSpeed = 0.25f;

		private float _clapPeak;

		private float _clapLast;

		private float _selfClapCooldown;

		private float _nextClapLog;

		private readonly Dictionary<int, (float amp, float dur)> _hapticBase = new Dictionary<int, (float, float)>();

		private readonly Dictionary<int, Action> _hapticUndo = new Dictionary<int, Action>();

		private readonly Dictionary<int, float> _hapticUndoAt = new Dictionary<int, float>();

		private const float HitStopScale = 0.15f;

		private float _hitStopPrevScale = -1f;

		private float _hitStopEnd;

		private readonly List<AudioClip> _highFiveClips = new List<AudioClip>();

		private readonly List<AudioClip> _dapClips = new List<AudioClip>();

		private readonly List<AudioClip> _fistClips = new List<AudioClip>();

		private readonly List<AudioClip> _perfectClips = new List<AudioClip>();

		private readonly List<AudioClip> _kissClips = new List<AudioClip>();

		private readonly Dictionary<List<AudioClip>, string[]> _clipNames = new Dictionary<List<AudioClip>, string[]>();

		private const int KRing = 0;

		private const int KFlash = 1;

		private const int KStreak = 2;

		private const int KRay = 3;

		private const int KStar = 4;

		private const int KText = 5;

		private const int KHeart = 6;

		private static readonly List<Fx> _fx = new List<Fx>();

		private static Mesh _quad;

		private static readonly Texture2D[] _texs = (Texture2D[])(object)new Texture2D[5];

		private static readonly Material[] _mats = (Material[])(object)new Material[5];

		private static readonly Dictionary<string, Texture2D> _textTex = new Dictionary<string, Texture2D>();

		private static readonly Dictionary<string, Material> _textMats = new Dictionary<string, Material>();

		private static bool _shaderLogged;

		private static readonly Dictionary<char, string[]> Glyphs = new Dictionary<char, string[]>
		{
			['0'] = new string[7] { ".###.", "#...#", "#..##", "#.#.#", "##..#", "#...#", ".###." },
			['1'] = new string[7] { "..#..", ".##..", "..#..", "..#..", "..#..", "..#..", ".###." },
			['2'] = new string[7] { ".###.", "#...#", "....#", "...#.", "..#..", ".#...", "#####" },
			['3'] = new string[7] { "####.", "....#", "....#", ".###.", "....#", "....#", "####." },
			['4'] = new string[7] { "...#.", "..##.", ".#.#.", "#..#.", "#####", "...#.", "...#." },
			['5'] = new string[7] { "#####", "#....", "####.", "....#", "....#", "#...#", ".###." },
			['6'] = new string[7] { ".###.", "#....", "#....", "####.", "#...#", "#...#", ".###." },
			['7'] = new string[7] { "#####", "....#", "...#.", "..#..", ".#...", ".#...", ".#..." },
			['8'] = new string[7] { ".###.", "#...#", "#...#", ".###.", "#...#", "#...#", ".###." },
			['9'] = new string[7] { ".###.", "#...#", "#...#", ".####", "....#", "....#", ".###." },
			['x'] = new string[7] { ".....", ".....", "#...#", ".#.#.", "..#..", ".#.#.", "#...#" },
			['P'] = new string[7] { "####.", "#...#", "#...#", "####.", "#....", "#....", "#...." },
			['E'] = new string[7] { "#####", "#....", "#....", "####.", "#....", "#....", "#####" },
			['R'] = new string[7] { "####.", "#...#", "#...#", "####.", "#.#..", "#..#.", "#...#" },
			['F'] = new string[7] { "#####", "#....", "#....", "####.", "#....", "#....", "#...." },
			['C'] = new string[7] { ".###.", "#...#", "#....", "#....", "#....", "#...#", ".###." },
			['T'] = new string[7] { "#####", "..#..", "..#..", "..#..", "..#..", "..#..", "..#.." },
			['!'] = new string[7] { "..#..", "..#..", "..#..", "..#..", "..#..", ".....", "..#.." }
		};

		private float MinClosingSpeed => (float)_minSpeed.Value / 10f;

		private float MaxPowerSpeed => (float)Mathf.Max(_fullSpeed.Value, _minSpeed.Value + 5) / 10f;

		public static DapUpMod Instance { get; private set; }

		private float Density => _vfxIntensity.Value switch
		{
			1 => 0.5f, 
			3 => 1.6f, 
			_ => 1f, 
		};

		private static Color ResolveColor(int index)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			return (Color)((ColorChoice)index switch
			{
				ColorChoice.Blue => new Color(0.25f, 0.6f, 1f), 
				ColorChoice.Cyan => new Color(0.2f, 0.9f, 1f), 
				ColorChoice.Green => new Color(0.3f, 1f, 0.4f), 
				ColorChoice.Yellow => new Color(1f, 0.9f, 0.15f), 
				ColorChoice.Orange => new Color(1f, 0.55f, 0.1f), 
				ColorChoice.Red => new Color(1f, 0.25f, 0.25f), 
				ColorChoice.Pink => new Color(1f, 0.45f, 0.8f), 
				ColorChoice.Purple => new Color(0.65f, 0.35f, 1f), 
				ColorChoice.Rainbow => Color.HSVToRGB(Random.value, 0.75f, 1f), 
				_ => Color.white, 
			});
		}

		private Color KindColor(int kind)
		{
			//IL_0023: 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_0056: 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)
			return (Color)(kind switch
			{
				0 => ResolveColor(_colHigh.Value), 
				1 => ResolveColor(_colDap.Value), 
				3 => ResolveColor(_colClap.Value), 
				_ => ResolveColor(_colBump.Value), 
			});
		}

		public override void OnInitializeMelon()
		{
			Instance = this;
			_prefs = MelonPreferences.CreateCategory("DapUp");
			_enabled = _prefs.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_soundOn = _prefs.CreateEntry<bool>("SoundEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_volume = _prefs.CreateEntry<float>("Volume", 0.8f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_vfxOn = _prefs.CreateEntry<bool>("VfxEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_vfxIntensity = _prefs.CreateEntry<int>("VfxIntensity", 2, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_hapticsOn = _prefs.CreateEntry<bool>("HapticsEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_touchCm = _prefs.CreateEntry<int>("TouchRangeCm", 14, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_debug = _prefs.CreateEntry<bool>("Debug", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_speedScale = _prefs.CreateEntry<bool>("SpeedScaling", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_minSpeed = _prefs.CreateEntry<int>("MinSwingSpeedTenths", 10, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_fullSpeed = _prefs.CreateEntry<int>("FullPowerSpeedTenths", 50, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_prefsVersion = _prefs.CreateEntry<int>("PrefsVersion", 0, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_selfClapOn = _prefs.CreateEntry<bool>("SelfClap", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_hapticScale = _prefs.CreateEntry<bool>("PowerHaptics", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_perfectOn = _prefs.CreateEntry<bool>("PerfectTiming", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_comboOn = _prefs.CreateEntry<bool>("ComboCounter", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_glowOn = _prefs.CreateEntry<bool>("HandGlow", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_syncOn = _prefs.CreateEntry<bool>("MultiplayerSync", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_pushOn = _prefs.CreateEntry<bool>("ShockwavePush", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_hitStopOn = _prefs.CreateEntry<bool>("HitStop", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_firstRunDone = _prefs.CreateEntry<bool>("FirstRunShown", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_colHigh = _prefs.CreateEntry<int>("ColorHighFive", 0, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_colDap = _prefs.CreateEntry<int>("ColorDap", 3, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_colBump = _prefs.CreateEntry<int>("ColorFistBump", 8, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_colClap = _prefs.CreateEntry<int>("ColorClap", 8, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			if (_prefsVersion.Value < 2)
			{
				_touchCm.Value = 18;
				_prefsVersion.Value = 2;
				_prefs.SaveToFile(false);
			}
			LoadClips(_highFiveClips, "clap1", "clap2", "clap3");
			LoadClips(_dapClips, "dap1", "dap2");
			LoadClips(_fistClips, "fist1", "fist2");
			LoadClips(_perfectClips, "perfect");
			LoadClips(_kissClips, "kiss", "kiss2");
			try
			{
				BuildMenu();
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Warning("BoneMenu page could not be created (" + ex.Message + "). Settings still work from UserData/MelonPreferences.cfg.");
			}
			DapUpNetwork.Init(((MelonBase)this).LoggerInstance);
			((MelonBase)this).LoggerInstance.Msg($"DapUp loaded ({_highFiveClips.Count + _dapClips.Count + _fistClips.Count + _perfectClips.Count} sounds). Go give somebody a high five.");
		}

		private void Set<T>(MelonPreferences_Entry<T> entry, T value)
		{
			entry.Value = value;
			_prefs.SaveToFile(false);
		}

		private void BuildMenu()
		{
			//IL_0015: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_015c: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: 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_02ba: 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_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			Page obj = Page.Root.CreatePage("DapUp", ResolveColor(_colDap.Value), 0, true);
			obj.CreateBool("Enabled", Color.green, _enabled.Value, (Action<bool>)delegate(bool v)
			{
				Set(_enabled, v);
			});
			obj.CreateBool("Sound", Color.white, _soundOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_soundOn, v);
			});
			obj.CreateFloat("Volume", Color.white, _volume.Value, 0.1f, 0f, 1f, (Action<float>)delegate(float v)
			{
				Set(_volume, Mathf.Round(v * 10f) / 10f);
			});
			obj.CreateBool("Effects", ResolveColor(_colHigh.Value), _vfxOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_vfxOn, v);
			});
			obj.CreateInt("Effect Amount (1-3)", ResolveColor(_colHigh.Value), _vfxIntensity.Value, 1, 1, 3, (Action<int>)delegate(int v)
			{
				Set(_vfxIntensity, v);
			});
			obj.CreateBool("Haptics", Color.white, _hapticsOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_hapticsOn, v);
			});
			Page obj2 = obj.CreatePage("Colors", Color.magenta, 0, true);
			obj2.CreateEnum("High Five Color", ResolveColor(_colHigh.Value), (Enum)(ColorChoice)_colHigh.Value, (Action<Enum>)delegate(Enum v)
			{
				Set(_colHigh, (int)(ColorChoice)(object)v);
			});
			obj2.CreateEnum("Dap Color", ResolveColor(_colDap.Value), (Enum)(ColorChoice)_colDap.Value, (Action<Enum>)delegate(Enum v)
			{
				Set(_colDap, (int)(ColorChoice)(object)v);
			});
			obj2.CreateEnum("Fist Bump Color", ResolveColor(_colBump.Value), (Enum)(ColorChoice)_colBump.Value, (Action<Enum>)delegate(Enum v)
			{
				Set(_colBump, (int)(ColorChoice)(object)v);
			});
			obj2.CreateEnum("Clap Color", ResolveColor(_colClap.Value), (Enum)(ColorChoice)_colClap.Value, (Action<Enum>)delegate(Enum v)
			{
				Set(_colClap, (int)(ColorChoice)(object)v);
			});
			Page obj3 = obj.CreatePage("Extras", Color.cyan, 0, true);
			obj3.CreateBool("Swing Speed Scaling", Color.white, _speedScale.Value, (Action<bool>)delegate(bool v)
			{
				Set(_speedScale, v);
			});
			obj3.CreateBool("Clap Your Own Hands", Color.white, _selfClapOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_selfClapOn, v);
			});
			obj3.CreateBool("Power Haptics", Color.white, _hapticScale.Value, (Action<bool>)delegate(bool v)
			{
				Set(_hapticScale, v);
			});
			obj3.CreateBool("Perfect Timing Bonus", Color.white, _perfectOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_perfectOn, v);
			});
			obj3.CreateBool("Combo Counter", Color.white, _comboOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_comboOn, v);
			});
			obj3.CreateBool("Hand Glow", Color.white, _glowOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_glowOn, v);
			});
			obj3.CreateBool("Multiplayer Sync", Color.white, _syncOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_syncOn, v);
			});
			obj3.CreateBool("Shockwave Push (nudges props)", Color.yellow, _pushOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_pushOn, v);
			});
			obj3.CreateBool("Hit-Stop (brief slow-mo)", Color.yellow, _hitStopOn.Value, (Action<bool>)delegate(bool v)
			{
				Set(_hitStopOn, v);
			});
			Page obj4 = obj.CreatePage("Advanced", Color.gray, 0, true);
			obj4.CreateInt("Touch Range (cm)", Color.white, _touchCm.Value, 2, 8, 30, (Action<int>)delegate(int v)
			{
				Set(_touchCm, v);
			});
			obj4.CreateInt("Min Swing Speed (x0.1 m/s)", Color.white, _minSpeed.Value, 2, 4, 30, (Action<int>)delegate(int v)
			{
				Set(_minSpeed, v);
			});
			obj4.CreateInt("Full Power Speed (x0.1 m/s)", Color.white, _fullSpeed.Value, 5, 20, 100, (Action<int>)delegate(int v)
			{
				Set(_fullSpeed, v);
			});
			obj4.CreateBool("Debug Log", Color.gray, _debug.Value, (Action<bool>)delegate(bool v)
			{
				Set(_debug, v);
			});
			Page obj5 = obj.CreatePage("Test Effects", Color.white, 0, true);
			obj5.CreateInt("Test Power (%)", Color.white, 50, 25, 0, 100, (Action<int>)delegate(int v)
			{
				_testPower = (float)v / 100f;
			});
			obj5.CreateFunction("Test High Five", ResolveColor(_colHigh.Value), (Action)delegate
			{
				TestEffect(0);
			});
			obj5.CreateFunction("Test Dap", ResolveColor(_colDap.Value), (Action)delegate
			{
				TestEffect(1);
			});
			obj5.CreateFunction("Test Fist Bump", ResolveColor(_colBump.Value), (Action)delegate
			{
				TestEffect(2);
			});
			obj5.CreateFunction("Test Clap", ResolveColor(_colClap.Value), (Action)delegate
			{
				//IL_000b: 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_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				DoHitFx(((Component)Camera.main).transform.position + ((Component)Camera.main).transform.forward * 0.8f + Vector3.down * 0.2f, 3, _testPower, perfect: false, 1);
			});
			obj5.CreateFunction("Test Perfect Hit", Color.yellow, (Action)delegate
			{
				TestEffect(3);
			});
			obj5.CreateFunction("Test Combo x4", Color.white, (Action)delegate
			{
				TestEffect(4);
			});
		}

		private void TestEffect(int type)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null))
			{
				Vector3 pos = ((Component)main).transform.position + ((Component)main).transform.forward * 1f + Vector3.down * 0.15f;
				float testPower = _testPower;
				switch (type)
				{
				case 0:
					DoHitFx(pos, 0, testPower, perfect: false, 1);
					break;
				case 1:
					DoHitFx(pos, 1, testPower, perfect: false, 1);
					break;
				case 2:
					DoHitFx(pos, 2, testPower, perfect: false, 1);
					break;
				case 3:
					DoHitFx(pos, 0, Mathf.Min(1f, testPower + 0.2f), perfect: true, 1);
					break;
				default:
					DoHitFx(pos, 0, testPower, perfect: false, 4);
					break;
				}
			}
		}

		public override void OnUpdate()
		{
			try
			{
				UpdateFx();
			}
			catch (Exception ex)
			{
				LogThrottled("effects: " + ex.Message);
			}
			try
			{
				UpdateTimers();
			}
			catch (Exception ex2)
			{
				LogThrottled("timers: " + ex2.Message);
			}
			if (!_enabled.Value)
			{
				return;
			}
			try
			{
				Detect();
			}
			catch (Exception ex3)
			{
				LogThrottled("detection: " + ex3.Message);
			}
		}

		private void LogThrottled(string msg)
		{
			if (!(Time.unscaledTime < _nextErrorLog))
			{
				_nextErrorLog = Time.unscaledTime + 5f;
				((MelonBase)this).LoggerInstance.Warning("DapUp error in " + msg);
			}
		}

		private void UpdateTimers()
		{
			//IL_0163: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			if (_hapticUndoAt.Count > 0)
			{
				List<int> list = null;
				foreach (KeyValuePair<int, float> item in _hapticUndoAt)
				{
					if (Time.unscaledTime >= item.Value)
					{
						(list ?? (list = new List<int>())).Add(item.Key);
					}
				}
				if (list != null)
				{
					foreach (int item2 in list)
					{
						if (_hapticUndo.TryGetValue(item2, out var value))
						{
							value();
						}
						_hapticUndo.Remove(item2);
						_hapticUndoAt.Remove(item2);
						_hapticBase.Remove(item2);
					}
				}
			}
			if (_hitStopPrevScale >= 0f && Time.unscaledTime >= _hitStopEnd)
			{
				if (Mathf.Abs(Time.timeScale - 0.15f) < 0.01f)
				{
					Time.timeScale = _hitStopPrevScale;
				}
				_hitStopPrevScale = -1f;
			}
			if (!_firstRunDone.Value && Time.time > 25f && (Object)(object)Player.RigManager != (Object)null)
			{
				_firstRunDone.Value = true;
				_prefs.SaveToFile(false);
				try
				{
					Notifier.Send(new Notification
					{
						Title = NotificationText.op_Implicit("DapUp"),
						Message = NotificationText.op_Implicit("DapUp is on. Open BoneMenu > DapUp to change settings or try the effects."),
						ShowTitleOnPopup = true,
						PopupLength = 5f,
						Type = (NotificationType)0
					});
				}
				catch (Exception ex)
				{
					((MelonBase)this).LoggerInstance.Warning("Could not show welcome message: " + ex.Message);
				}
			}
		}

		private void Detect()
		{
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: 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)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: 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_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time >= _nextRigScan)
			{
				_nextRigScan = Time.time + 0.5f;
				Il2CppArrayBase<RigManager> val = Object.FindObjectsOfType<RigManager>();
				_rigs = (RigManager[])(object)new RigManager[val.Length];
				for (int i = 0; i < val.Length; i++)
				{
					_rigs[i] = val[i];
				}
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			if (!_warmed)
			{
				_warmed = true;
				for (int j = 0; j < 4; j++)
				{
					GetBaseMaterial(j);
				}
			}
			if (_debug.Value && Time.unscaledTime >= _nextStatusLog)
			{
				_nextStatusLog = Time.unscaledTime + 3f;
				((MelonBase)this).LoggerInstance.Msg($"[debug] rigs in scene: {_rigs.Length} (other players: {Mathf.Max(0, _rigs.Length - 1)})");
			}
			RigManager val2 = Player.RigManager;
			RigManager[] rigs;
			if ((Object)(object)val2 == (Object)null || (Object)(object)val2.physicsRig == (Object)null || (Object)(object)((Rig)val2.physicsRig).m_head == (Object)null)
			{
				val2 = null;
				float num = float.MaxValue;
				rigs = _rigs;
				foreach (RigManager val3 in rigs)
				{
					if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.physicsRig == (Object)null) && !((Object)(object)((Rig)val3.physicsRig).m_head == (Object)null))
					{
						Vector3 val4 = ((Rig)val3.physicsRig).m_head.position - ((Component)main).transform.position;
						float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
						if (sqrMagnitude < num)
						{
							num = sqrMagnitude;
							val2 = val3;
						}
					}
				}
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			if ((Object)(object)val2 != (Object)(object)_lastLocalRig)
			{
				_lastLocalRig = val2;
				_prevLeft = ((Component)val2.physicsRig.leftHand).transform.position;
				_prevRight = ((Component)val2.physicsRig.rightHand).transform.position;
				_prevRemote.Clear();
				_approach.Clear();
				return;
			}
			Transform transform = ((Component)val2.physicsRig.leftHand).transform;
			Transform transform2 = ((Component)val2.physicsRig.rightHand).transform;
			float num2 = Mathf.Max(Time.deltaTime, 0.0001f);
			Vector3 val5 = (transform.position - _prevLeft) / num2;
			Vector3 val6 = (transform2.position - _prevRight) / num2;
			_prevLeft = transform.position;
			_prevRight = transform2.position;
			if (_selfClapOn.Value)
			{
				TestSelfClap(transform, transform2, val5, val6);
			}
			rigs = _rigs;
			foreach (RigManager val7 in rigs)
			{
				if (!((Object)(object)val7 == (Object)null) && !((Object)(object)val7 == (Object)(object)val2) && !((Object)(object)val7.physicsRig == (Object)null))
				{
					int instanceID = ((Object)val7).GetInstanceID();
					Transform transform3 = ((Component)val7.physicsRig.leftHand).transform;
					Transform transform4 = ((Component)val7.physicsRig.rightHand).transform;
					Vector3 theirVel = RemoteVelocity(instanceID, left: true, transform3.position);
					Vector3 theirVel2 = RemoteVelocity(instanceID, left: false, transform4.position);
					TestPair(instanceID, transform, val5, mineIsLeft: true, transform3, theirVel, theirsIsLeft: true, val2);
					TestPair(instanceID, transform, val5, mineIsLeft: true, transform4, theirVel2, theirsIsLeft: false, val2);
					TestPair(instanceID, transform2, val6, mineIsLeft: false, transform3, theirVel, theirsIsLeft: true, val2);
					TestPair(instanceID, transform2, val6, mineIsLeft: false, transform4, theirVel2, theirsIsLeft: false, val2);
					TestKiss(instanceID, val2, val7);
				}
			}
		}

		private void TestKiss(int id, RigManager mine, RigManager theirs)
		{
			//IL_002c: 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_003c: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			Transform head = ((Rig)mine.physicsRig).m_head;
			Transform head2 = ((Rig)theirs.physicsRig).m_head;
			if ((Object)(object)head == (Object)null || (Object)(object)head2 == (Object)null)
			{
				return;
			}
			Vector3 val = head2.position - head.position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			float value;
			float value2;
			if (!(magnitude > 0.03f) || !(magnitude < 0.27f) || !(Vector3.Dot(head.forward, head2.forward) < -0.4f) || !(Vector3.Dot(head.forward, val / magnitude) > 0.6f))
			{
				_kissStart.Remove(id);
			}
			else if (!_kissStart.TryGetValue(id, out value))
			{
				_kissStart[id] = Time.time;
			}
			else if (!(Time.time - value < 0.6f) && (!_kissCool.TryGetValue(id, out value2) || !(Time.time < value2)))
			{
				_kissCool[id] = Time.time + 8f;
				_kissStart.Remove(id);
				Vector3 val2 = (head.position + head2.position) * 0.5f + Vector3.up * 0.02f;
				DoHitFx(val2, 4, 1f, perfect: false, 1);
				RememberHit(val2);
				if (_syncOn.Value)
				{
					DapUpNetwork.BroadcastHit(val2, 4, byte.MaxValue, perfect: false, 1);
				}
			}
		}

		private void TestSelfClap(Transform l, Transform r, Vector3 lVel, Vector3 rVel)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = r.position - l.position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > 0.45f)
			{
				_clapPeak = 0f;
				return;
			}
			Vector3 val2 = val / Mathf.Max(magnitude, 0.0001f);
			float num = Vector3.Dot(lVel - rVel, val2);
			float num2 = 14f * Mathf.Max(0f, Time.time - _clapLast);
			_clapPeak = Mathf.Max(num, _clapPeak - num2);
			_clapLast = Time.time;
			if (_debug.Value && magnitude < 0.25f && Time.unscaledTime >= _nextClapLog)
			{
				_nextClapLog = Time.unscaledTime + 0.25f;
				((MelonBase)this).LoggerInstance.Msg($"[debug] own hands: dist={magnitude:F2} closing={num:F2} peak={_clapPeak:F2} facing={Vector3.Dot(l.forward, r.forward):F2}");
			}
			if (magnitude > Mathf.Max((float)_touchCm.Value / 100f, 0.22f))
			{
				return;
			}
			float num3 = Mathf.Max(num, _clapPeak);
			if (!(num3 < 0.25f) && !(Time.time < _selfClapCooldown))
			{
				_selfClapCooldown = Time.time + 0.25f;
				_clapPeak = 0f;
				float num4 = (_speedScale.Value ? Mathf.Clamp01((num3 - 0.25f) / 2.5f) : 0.5f);
				Vector3 val3 = (l.position + r.position) * 0.5f;
				if (_debug.Value)
				{
					((MelonBase)this).LoggerInstance.Msg($"[debug] CLAP power {num4 * 100f:F0}%");
				}
				Haptic(_lastLocalRig, left: true, num4 * 0.6f);
				Haptic(_lastLocalRig, left: false, num4 * 0.6f);
				DoHitFx(val3, 3, num4, perfect: false, 1);
				RememberHit(val3);
				if (_syncOn.Value)
				{
					DapUpNetwork.BroadcastHit(val3, 3, (byte)Mathf.Clamp(Mathf.RoundToInt(num4 * 255f), 0, 255), perfect: false, 1);
				}
			}
		}

		private Vector3 RemoteVelocity(int playerId, bool left, Vector3 pos)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			(int, bool) key = (playerId, left);
			Vector3 result = Vector3.zero;
			if (_prevRemote.TryGetValue(key, out var value))
			{
				result = (pos - value) / Mathf.Max(Time.deltaTime, 0.0001f);
			}
			_prevRemote[key] = pos;
			return result;
		}

		private void TestPair(int playerId, Transform mine, Vector3 myVel, bool mineIsLeft, Transform theirs, Vector3 theirVel, bool theirsIsLeft, RigManager localRig)
		{
			//IL_0015: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			int key = playerId * 4 + (mineIsLeft ? 2 : 0) + (theirsIsLeft ? 1 : 0);
			Vector3 val = theirs.position - mine.position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num = Vector3.Dot(myVel - theirVel, normalized);
			if (_debug.Value && magnitude < 0.25f && Time.unscaledTime >= _nextDebugLog)
			{
				_nextDebugLog = Time.unscaledTime + 0.25f;
				float value = Vector3.Dot(mine.forward, theirs.forward);
				float value2 = mine.position.y - ((Rig)localRig.physicsRig).m_head.position.y;
				((MelonBase)this).LoggerInstance.Msg($"[debug] dist={magnitude:F2} closing={num:F2} facing={value:F2} handAboveHead={value2:F2}");
			}
			Approach value3 = null;
			if (magnitude < 0.45f)
			{
				if (!_approach.TryGetValue(key, out value3))
				{
					value3 = new Approach();
					_approach[key] = value3;
				}
				float num2 = 14f * Mathf.Max(0f, Time.time - value3.last);
				value3.peak = Mathf.Max(num, value3.peak - num2);
				value3.mine = Mathf.Max(Vector3.Dot(myVel, normalized), value3.mine - num2);
				value3.theirs = Mathf.Max(Vector3.Dot(-theirVel, normalized), value3.theirs - num2);
				value3.last = Time.time;
			}
			if (magnitude > (float)_touchCm.Value / 100f)
			{
				return;
			}
			float num3 = ((value3 != null) ? Mathf.Max(num, value3.peak) : num);
			if (num3 < MinClosingSpeed)
			{
				return;
			}
			float num4 = (_speedScale.Value ? Mathf.Clamp01((num3 - MinClosingSpeed) / (MaxPowerSpeed - MinClosingSpeed)) : 0.5f);
			float num5 = Vector3.Dot(mine.forward, theirs.forward);
			bool flag = num5 < -0.35f;
			bool flag2 = num5 > 0.4f;
			if ((!flag && !flag2) || (_lastClap.TryGetValue(playerId, out var value4) && Time.time - value4 < 1f))
			{
				return;
			}
			_lastClap[playerId] = Time.time;
			Transform head = ((Rig)localRig.physicsRig).m_head;
			int kind = (flag2 ? 2 : ((!(mine.position.y > head.position.y - 0.25f)) ? 1 : 0));
			bool flag3 = false;
			if (_perfectOn.Value && value3 != null)
			{
				float num6 = Mathf.Min(value3.mine, value3.theirs);
				float num7 = Mathf.Max(value3.mine, value3.theirs);
				flag3 = num6 >= 0.9f && num7 > 0f && num6 / num7 >= 0.55f;
				if (flag3)
				{
					num4 = Mathf.Min(1f, num4 + 0.2f);
				}
			}
			OnHit(mine.position, mine, mineIsLeft, localRig, kind, num4, flag3, playerId);
		}

		private void OnHit(Vector3 pos, Transform hand, bool left, RigManager rig, int kind, float power, bool perfect, int playerId)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			int num = 1;
			if (_combos.TryGetValue(playerId, out (int, float) value) && Time.time - value.Item2 < 4f)
			{
				num = value.Item1 + 1;
			}
			_combos[playerId] = (num, Time.time);
			string value2 = kind switch
			{
				1 => "DAP!", 
				0 => "HIGH FIVE!", 
				_ => "FIST BUMP!", 
			};
			((MelonBase)this).LoggerInstance.Msg($"{value2}{(perfect ? " PERFECT!" : "")} (power {power * 100f:F0}%, combo x{num})");
			Haptic(rig, left, power);
			DoHitFx(pos, kind, power, perfect, num);
			if (_glowOn.Value && _vfxOn.Value)
			{
				Add(1, pos, 0.45f, 0.3f, KindColor(kind), 0f, 0f, default(Vector3), 0.6f, 0f, 0f, 0f, 0f, hand);
			}
			if (_pushOn.Value)
			{
				ShockwavePush(pos, power);
			}
			if (_hitStopOn.Value && power > 0.8f)
			{
				StartHitStop();
			}
			RememberHit(pos);
			if (_syncOn.Value)
			{
				DapUpNetwork.BroadcastHit(pos, (byte)kind, (byte)Mathf.Clamp(Mathf.RoundToInt(power * 255f), 0, 255), perfect, (byte)Mathf.Clamp(num, 0, 255));
			}
		}

		private void DoHitFx(Vector3 pos, int kind, float power, bool perfect, int combo)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			List<AudioClip> list;
			switch (kind)
			{
			case 4:
				PlayFrom(pos, _kissClips, 0.8f, 1f);
				if (_vfxOn.Value)
				{
					SpawnHearts(pos);
				}
				return;
			case 3:
				PlayFrom(pos, _highFiveClips, Mathf.Lerp(0.4f, 0.9f, power), Mathf.Lerp(1.1f, 0.98f, power));
				if (_vfxOn.Value)
				{
					SpawnClapEffect(pos, power);
				}
				return;
			default:
				list = _fistClips;
				break;
			case 1:
				list = _dapClips;
				break;
			case 0:
				list = _highFiveClips;
				break;
			}
			List<AudioClip> list2 = list;
			PlayFrom(pos, list2, Mathf.Lerp(0.8f, 1f, power), Mathf.Lerp(1.06f, 0.94f, power) * (1f + 0.04f * (float)Mathf.Min(combo - 1, 8)));
			if (perfect)
			{
				PlayFrom(pos, list2, 1f, 0.82f);
			}
			if (_vfxOn.Value)
			{
				if (kind == 2)
				{
					SpawnBumpEffect(pos, power);
				}
				else
				{
					SpawnEffect(pos, kind == 0, power);
				}
				if (perfect)
				{
					SpawnPerfect(pos);
				}
				if (combo >= 2 && _comboOn.Value)
				{
					AddText($"x{combo}", pos + Vector3.up * 0.16f, 0.07f + 0.004f * (float)Mathf.Min(combo, 10), KindColor(kind));
				}
			}
		}

		public static void OnRemoteHit(Vector3 pos, byte kind, float power, bool perfect, byte combo)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Instance?.HandleRemoteHit(pos, kind, power, perfect, combo);
		}

		private void HandleRemoteHit(Vector3 pos, byte kind, float power, bool perfect, byte combo)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (_enabled.Value && _syncOn.Value && !IsDuplicate(pos))
			{
				RememberHit(pos);
				DoHitFx(pos, Mathf.Clamp((int)kind, 0, 4), Mathf.Clamp01(power), perfect, combo);
			}
		}

		private void RememberHit(Vector3 pos)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			_recentHits.Add((Time.time, pos));
			if (_recentHits.Count > 20)
			{
				_recentHits.RemoveAt(0);
			}
		}

		private bool IsDuplicate(Vector3 pos)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			foreach (var recentHit in _recentHits)
			{
				if (Time.time - recentHit.time < 0.9f)
				{
					Vector3 val = recentHit.pos - pos;
					if (((Vector3)(ref val)).sqrMagnitude < 1f)
					{
						return true;
					}
				}
			}
			return false;
		}

		private void Haptic(RigManager rig, bool left, float power)
		{
			if (!_hapticsOn.Value)
			{
				return;
			}
			Hand val = (left ? rig.physicsRig.leftHand : rig.physicsRig.rightHand);
			BaseController controller = val.Controller;
			Haptor haptor = ((controller != null) ? controller.haptor : null);
			if ((Object)(object)haptor == (Object)null)
			{
				return;
			}
			if (_hapticScale.Value)
			{
				int instanceID = ((Object)haptor).GetInstanceID();
				if (!_hapticBase.TryGetValue(instanceID, out var b))
				{
					b = (amp: haptor.hap_tap_amplitude, dur: haptor.hap_tap_duration);
					_hapticBase[instanceID] = b;
				}
				haptor.hap_tap_amplitude = Mathf.Clamp(b.amp * Mathf.Lerp(0.35f, 1.6f, power), 0f, 1f);
				haptor.hap_tap_duration = b.dur * Mathf.Lerp(0.7f, 1.8f, power);
				_hapticUndo[instanceID] = delegate
				{
					haptor.hap_tap_amplitude = b.amp;
					haptor.hap_tap_duration = b.dur;
				};
				_hapticUndoAt[instanceID] = Time.unscaledTime + 0.4f;
			}
			haptor.Haptic_Tap();
		}

		private void StartHitStop()
		{
			if (!(_hitStopPrevScale >= 0f) && !(Time.timeScale < 0.5f))
			{
				_hitStopPrevScale = Time.timeScale;
				Time.timeScale = 0.15f;
				_hitStopEnd = Time.unscaledTime + 0.07f;
			}
		}

		private void ShockwavePush(Vector3 pos, float power)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Lerp(0.4f, 2f, power);
			Il2CppReferenceArray<Collider> val = Physics.OverlapSphere(pos, 1.3f);
			for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val).Length; i++)
			{
				Collider val2 = ((Il2CppArrayBase<Collider>)(object)val)[i];
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Rigidbody attachedRigidbody = val2.attachedRigidbody;
				if (!((Object)(object)attachedRigidbody == (Object)null) && !attachedRigidbody.isKinematic && !(attachedRigidbody.mass > 30f) && !((Object)(object)((Component)attachedRigidbody).GetComponentInParent<RigManager>() != (Object)null))
				{
					Vector3 val3 = attachedRigidbody.worldCenterOfMass - pos;
					if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f)
					{
						val3 = Vector3.up;
					}
					attachedRigidbody.AddForce(((Vector3)(ref val3)).normalized * num, (ForceMode)2);
				}
			}
		}

		private void LoadClips(List<AudioClip> into, params string[] names)
		{
			_clipNames[into] = names;
			into.Clear();
			foreach (string text in names)
			{
				try
				{
					AudioClip val = LoadEmbeddedWav(text);
					if ((Object)(object)val != (Object)null)
					{
						into.Add(val);
					}
				}
				catch (Exception ex)
				{
					((MelonBase)this).LoggerInstance.Warning("Could not load sound '" + text + "': " + ex.Message);
				}
			}
		}

		private AudioClip LoadEmbeddedWav(string name)
		{
			using Stream stream = typeof(DapUpMod).Assembly.GetManifestResourceStream("DapUp.Sounds." + name + ".wav");
			if (stream == null)
			{
				((MelonBase)this).LoggerInstance.Warning("Sound resource '" + name + "' not found in DLL");
				return null;
			}
			using BinaryReader binaryReader = new BinaryReader(stream);
			binaryReader.ReadBytes(12);
			int num = 1;
			int num2 = 44100;
			int num3 = 16;
			byte[] array = null;
			while (stream.Position + 8 <= stream.Length)
			{
				string text = new string(binaryReader.ReadChars(4));
				int num4 = binaryReader.ReadInt32();
				if (text == "fmt ")
				{
					binaryReader.ReadInt16();
					num = binaryReader.ReadInt16();
					num2 = binaryReader.ReadInt32();
					binaryReader.ReadInt32();
					binaryReader.ReadInt16();
					num3 = binaryReader.ReadInt16();
					if (num4 > 16)
					{
						binaryReader.ReadBytes(num4 - 16);
					}
				}
				else
				{
					if (text == "data")
					{
						array = binaryReader.ReadBytes(num4);
						break;
					}
					binaryReader.ReadBytes(num4);
				}
			}
			if (array == null || num3 != 16)
			{
				return null;
			}
			int num5 = array.Length / 2;
			float[] array2 = new float[num5];
			for (int i = 0; i < num5; i++)
			{
				float num6 = (float)BitConverter.ToInt16(array, i * 2) / 32768f * 2.5f;
				array2[i] = num6 / (1f + Mathf.Abs(num6) * 0.35f) * 1.25f;
				array2[i] = Mathf.Clamp(array2[i], -1f, 1f);
			}
			AudioClip obj = AudioClip.Create("DapUp_" + name, num5 / num, num, num2, false);
			obj.SetData(Il2CppStructArray<float>.op_Implicit(array2), 0);
			((Object)obj).hideFlags = (HideFlags)32;
			return obj;
		}

		private void PlayFrom(Vector3 pos, List<AudioClip> list, float volumeMult, float pitchMult)
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_019d: Expected O, but got Unknown
			if (!_soundOn.Value)
			{
				return;
			}
			if (list.Count == 0)
			{
				LogThrottled("audio: no clips loaded (check the 'loaded (N sounds)' line at startup)");
				return;
			}
			AudioClip val = list[Random.Range(0, list.Count)];
			if ((Object)(object)val == (Object)null)
			{
				if (_clipNames.TryGetValue(list, out var value))
				{
					LoadClips(list, value);
				}
				if (list.Count == 0)
				{
					return;
				}
				val = list[Random.Range(0, list.Count)];
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
			}
			if (_debug.Value)
			{
				((MelonBase)this).LoggerInstance.Msg($"[debug] playing {((Object)val).name} ({val.length:F2}s) vol={_volume.Value * volumeMult:F2}");
			}
			GameObject val2 = new GameObject("DapUpSfx");
			val2.transform.position = pos;
			AudioSource obj = val2.AddComponent<AudioSource>();
			obj.clip = val;
			obj.volume = Mathf.Clamp01(_volume.Value * volumeMult);
			obj.spatialBlend = 0.6f;
			obj.spatialize = false;
			obj.dopplerLevel = 0f;
			obj.minDistance = 4f;
			obj.maxDistance = 25f;
			obj.pitch = Random.Range(0.94f, 1.06f) * pitchMult;
			obj.Play();
			Object.Destroy((Object)val2, val.length + 0.3f);
		}

		private static int TextureFor(int kind)
		{
			return kind switch
			{
				0 => 0, 
				1 => 1, 
				4 => 3, 
				6 => 4, 
				_ => 2, 
			};
		}

		private int N(float baseCount)
		{
			return Mathf.Max(1, Mathf.RoundToInt(baseCount * Density));
		}

		private static Mesh GetQuad()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)_quad != (Object)null)
			{
				return _quad;
			}
			_quad = new Mesh();
			_quad.vertices = Il2CppStructArray<Vector3>.op_Implicit((Vector3[])(object)new Vector3[4]
			{
				new Vector3(-0.5f, -0.5f, 0f),
				new Vector3(0.5f, -0.5f, 0f),
				new Vector3(-0.5f, 0.5f, 0f),
				new Vector3(0.5f, 0.5f, 0f)
			});
			_quad.uv = Il2CppStructArray<Vector2>.op_Implicit((Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(0f, 1f),
				new Vector2(1f, 1f)
			});
			_quad.triangles = Il2CppStructArray<int>.op_Implicit(new int[6] { 0, 2, 1, 2, 3, 1 });
			_quad.RecalculateBounds();
			return _quad;
		}

		private static Texture2D MakeTexture(int texKind)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = ((float)j + 0.5f) / 128f * 2f - 1f;
					float num2 = ((float)i + 0.5f) / 128f * 2f - 1f;
					float num3 = Mathf.Abs(num);
					float num4 = Mathf.Abs(num2);
					float num5 = Mathf.Sqrt(num * num + num2 * num2);
					float num9;
					switch (texKind)
					{
					case 0:
						num9 = Mathf.Clamp01(1f - Mathf.Abs(num5 - 0.85f) / 0.12f);
						num9 *= num9;
						if (num5 > 1f)
						{
							num9 = 0f;
						}
						break;
					case 1:
					{
						float num13 = Mathf.Clamp01(1f - num5);
						num9 = num13 * num13 * num13;
						break;
					}
					case 2:
						num9 = Mathf.Pow(Mathf.Clamp01(1f - num3), 1.2f) * Mathf.Pow(Mathf.Clamp01(1f - num4), 2.5f);
						break;
					case 4:
					{
						float num10 = num * 1.3f;
						float num11 = num2 * 1.3f - 0.1f;
						float num12 = num10 * num10 + num11 * num11 - 1f;
						num9 = Mathf.Clamp01((0f - (num12 * num12 * num12 - num10 * num10 * num11 * num11 * num11)) * 12f);
						break;
					}
					default:
					{
						float num6 = Mathf.Pow(Mathf.Clamp01(1f - num3), 4f) * Mathf.Pow(Mathf.Clamp01(1f - num4 * 14f), 2f);
						float num7 = Mathf.Pow(Mathf.Clamp01(1f - num4), 4f) * Mathf.Pow(Mathf.Clamp01(1f - num3 * 14f), 2f);
						float num8 = Mathf.Pow(Mathf.Clamp01(1f - num5 * 3f), 2f);
						num9 = Mathf.Clamp01(num6 + num7 + num8);
						break;
					}
					}
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num9));
				}
			}
			val.Apply();
			return val;
		}

		private static Material MakeMaterial(Texture2D tex)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			string[] obj = new string[4] { "Sprites/Default", "Unlit/Transparent", "Universal Render Pipeline/Particles/Unlit", "Particles/Standard Unlit" };
			Shader val = null;
			string[] array = obj;
			foreach (string text in array)
			{
				val = Shader.Find(text);
				if ((Object)(object)val != (Object)null)
				{
					if (!_shaderLogged)
					{
						MelonLogger.Msg("DapUp VFX shader: " + text);
						_shaderLogged = true;
					}
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				if (!_shaderLogged)
				{
					MelonLogger.Warning("DapUp: no usable particle shader found, VFX will be invisible");
					_shaderLogged = true;
				}
				return null;
			}
			return new Material(val)
			{
				mainTexture = (Texture)(object)tex
			};
		}

		private static Material GetBaseMaterial(int texKind)
		{
			if ((Object)(object)_mats[texKind] != (Object)null)
			{
				return _mats[texKind];
			}
			if ((Object)(object)_texs[texKind] == (Object)null)
			{
				_texs[texKind] = MakeTexture(texKind);
			}
			((Object)_texs[texKind]).hideFlags = (HideFlags)32;
			_mats[texKind] = MakeMaterial(_texs[texKind]);
			if ((Object)(object)_mats[texKind] != (Object)null)
			{
				((Object)_mats[texKind]).hideFlags = (HideFlags)32;
			}
			return _mats[texKind];
		}

		private static Texture2D GetTextTexture(string s, out float aspect)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			int num = s.Length * 6 - 1 + 2;
			int num2 = 9;
			aspect = (float)num / (float)num2;
			if (_textTex.TryGetValue(s, out var value))
			{
				return value;
			}
			bool[,] array = new bool[num, num2];
			for (int i = 0; i < s.Length; i++)
			{
				if (!Glyphs.TryGetValue(s[i], out var value2))
				{
					continue;
				}
				for (int j = 0; j < 7; j++)
				{
					for (int k = 0; k < 5; k++)
					{
						if (value2[j][k] == '#')
						{
							array[1 + i * 6 + k, 1 + (6 - j)] = true;
						}
					}
				}
			}
			Texture2D val = new Texture2D(num * 4, num2 * 4, (TextureFormat)4, false);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)0;
			Color white = default(Color);
			for (int l = 0; l < num2 * 4; l++)
			{
				for (int m = 0; m < num * 4; m++)
				{
					int num3 = m / 4;
					int num4 = l / 4;
					((Color)(ref white))..ctor(0f, 0f, 0f, 0f);
					if (array[num3, num4])
					{
						white = Color.white;
					}
					else
					{
						bool flag = false;
						for (int n = -1; n <= 1; n++)
						{
							if (flag)
							{
								break;
							}
							for (int num5 = -1; num5 <= 1; num5++)
							{
								int num6 = num3 + n;
								int num7 = num4 + num5;
								if (num6 >= 0 && num7 >= 0 && num6 < num && num7 < num2 && array[num6, num7])
								{
									flag = true;
									break;
								}
							}
						}
						if (flag)
						{
							((Color)(ref white))..ctor(0f, 0f, 0f, 1f);
						}
					}
					val.SetPixel(m, l, white);
				}
			}
			val.Apply();
			_textTex[s] = val;
			return val;
		}

		private static Material GetTextMaterial(string s, out float aspect)
		{
			Texture2D textTexture = GetTextTexture(s, out aspect);
			if (_textMats.TryGetValue(s, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = MakeMaterial(textTexture);
			_textMats[s] = value;
			return value;
		}

		private static void Add(int kind, Vector3 pos, float dur, float size, Color col, float width = 0f, float dist = 0f, Vector3 dir = default(Vector3), float peak = 1f, float gravity = 0f, float angle = 0f, float spin = 0f, float delay = 0f, Transform follow = null, string text = null)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (_fx.Count <= 300)
			{
				float aspect = 1f;
				Material val = ((kind == 5) ? GetTextMaterial(text ?? "", out aspect) : GetBaseMaterial(TextureFor(kind)));
				if (!((Object)(object)val == (Object)null))
				{
					GameObject val2 = new GameObject("DapUpFx");
					val2.transform.position = pos;
					val2.transform.localScale = Vector3.zero;
					val2.AddComponent<MeshFilter>().sharedMesh = GetQuad();
					Material mat = (((Renderer)val2.AddComponent<MeshRenderer>()).material = new Material(val));
					_fx.Add(new Fx
					{
						go = val2,
						mat = mat,
						kind = kind,
						t0 = Time.time + delay,
						dur = dur,
						pos = pos,
						dir = dir,
						size = size,
						width = width,
						dist = dist,
						col = col,
						peak = peak,
						gravity = gravity,
						angle = angle,
						spin = spin,
						aspect = aspect,
						follow = follow
					});
				}
			}
		}

		private static void AddText(string text, Vector3 pos, float height, Color col, float dur = 0.9f)
		{
			//IL_0001: 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_0014: 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)
			Add(5, pos, dur, height, col, 0f, 0f, default(Vector3), 1f, 0f, 0f, 0f, 0f, null, text);
		}

		private void AddRays(Vector3 pos, int count, float len, float width, Color col, float dur)
		{
			//IL_0045: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			float num = Random.Range(0f, 360f);
			for (int i = 0; i < count; i++)
			{
				float num2 = num + 360f * (float)i / (float)count + Random.Range(-6f, 6f);
				float size = len * Random.Range(0.7f, 1.2f);
				float angle = num2;
				Add(3, pos, dur, size, col, width, 0f, default(Vector3), 0.9f, 0f, angle);
			}
		}

		private void AddSparks(Vector3 pos, int count, float speedScale, Color col, float gravity)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < count; i++)
			{
				Vector3 onUnitSphere = Random.onUnitSphere;
				float size = Random.Range(0.07f, 0.15f) * speedScale;
				float dist = Random.Range(0.3f, 0.7f) * speedScale;
				Add(2, pos, Random.Range(0.35f, 0.6f), size, col, 0.013f, dist, onUnitSphere, 1f, gravity);
			}
		}

		private void AddSparkles(Vector3 pos, int count, float scale, Color col)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003f: 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)
			for (int i = 0; i < count; i++)
			{
				Vector3 onUnitSphere = Random.onUnitSphere;
				Add(4, pos + onUnitSphere * 0.03f, Random.Range(0.35f, 0.6f), Random.Range(0.07f, 0.13f) * scale, col, 0f, Random.Range(0.12f, 0.28f) * scale, onUnitSphere, 1f, 0f, Random.Range(0f, 90f), Random.Range(-140f, 140f), Random.Range(0f, 0.08f));
			}
		}

		private void SpawnEffect(Vector3 pos, bool highFive, float power)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: 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_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: 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_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: 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_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			if (_vfxOn.Value)
			{
				Color val = KindColor((!highFive) ? 1 : 0);
				Color col = Color.Lerp(val, Color.white, 0.65f);
				float num = (highFive ? 1.2f : 1f) * Mathf.Lerp(0.8f, 1.45f, power);
				float num2 = Mathf.Lerp(0.5f, 1.8f, power);
				float size = 0.6f * num;
				float peak = Mathf.Lerp(0.2f, 0.45f, power);
				Add(1, pos, 0.3f, size, val, 0f, 0f, default(Vector3), peak);
				Add(1, pos, 0.12f, 0.26f * num, col);
				Add(0, pos, 0.32f, 0.6f * num, val);
				Add(0, pos, 0.4f, 0.95f * num, col, 0f, 0f, default(Vector3), 0.7f, 0f, 0f, 0f, 0.05f);
				if (power > 0.55f)
				{
					Add(0, pos, 0.5f, 1.35f * num, col, 0f, 0f, default(Vector3), 0.5f, 0f, 0f, 0f, 0.11f);
				}
				AddRays(pos, N((float)(highFive ? 10 : 8) * num2), 0.42f * num, 0.016f, col, 0.22f);
				AddSparks(pos, N((float)(highFive ? 26 : 18) * num2), num, col, 0.45f);
				AddSparkles(pos, N((float)(highFive ? 7 : 5) * num2), num, Color.Lerp(val, Color.white, 0.4f));
				if (power > 0.8f)
				{
					Add(1, pos, 0.2f, 1f * num, col, 0f, 0f, default(Vector3), 0.5f);
					AddSparks(pos, N(20f), 1.6f * num, Color.white, 0.3f);
					AddRays(pos, N(8f), 0.75f * num, 0.012f, Color.white, 0.28f);
				}
			}
		}

		private void SpawnBumpEffect(Vector3 pos, float power)
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_007b: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			if (_vfxOn.Value)
			{
				Color col = KindColor(2);
				float num = Mathf.Lerp(0.8f, 1.5f, power);
				float num2 = Mathf.Lerp(0.5f, 1.8f, power);
				Add(1, pos, 0.1f, 0.13f * num, col);
				Add(0, pos, 0.2f, 0.22f * num, col, 0f, 0f, default(Vector3), 0.8f);
				if (power > 0.7f)
				{
					Add(0, pos, 0.28f, 0.4f * num, col, 0f, 0f, default(Vector3), 0.5f, 0f, 0f, 0f, 0.04f);
				}
				AddSparks(pos, N(6f * num2), 0.35f * num, col, 0.2f);
				AddSparkles(pos, N(2f * num2), 0.5f * num, col);
			}
		}

		private void SpawnHearts(Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			int num = N(9f);
			for (int i = 0; i < num; i++)
			{
				Color col = Color.HSVToRGB(Random.Range(0.9f, 1f), Random.Range(0.45f, 0.85f), 1f);
				Vector3 pos2 = pos + new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.03f, 0.05f), Random.Range(-0.1f, 0.1f));
				float dur = Random.Range(1.3f, 1.9f);
				float size = Random.Range(0.07f, 0.14f);
				float dist = Random.Range(0.4f, 0.8f);
				float angle = Random.Range(0f, 6.28f);
				float spin = Random.Range(0.03f, 0.09f);
				float delay = Random.Range(0f, 0.45f);
				Add(6, pos2, dur, size, col, 0f, dist, default(Vector3), 1f, 0f, angle, spin, delay);
			}
			Add(1, pos, 0.4f, 0.4f, new Color(1f, 0.5f, 0.7f), 0f, 0f, default(Vector3), 0.5f);
		}

		private void SpawnClapEffect(Vector3 pos, float power)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0045: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			Color val = KindColor(3);
			Color col = Color.Lerp(val, Color.white, 0.5f);
			float num = Mathf.Lerp(0.8f, 1.5f, power);
			Add(1, pos, 0.12f, 0.2f * num, col);
			Add(0, pos, 0.26f, 0.38f * num, val, 0f, 0f, default(Vector3), 0.8f);
			AddRays(pos, N(Mathf.Lerp(6f, 12f, power)), 0.22f * num, 0.012f, col, 0.18f);
			AddSparkles(pos, N(Mathf.Lerp(2f, 5f, power)), 0.6f * num, val);
			if (power > 0.6f)
			{
				Add(0, pos, 0.34f, 0.65f * num, col, 0f, 0f, default(Vector3), 0.5f, 0f, 0f, 0f, 0.04f);
			}
		}

		private void SpawnPerfect(Vector3 pos)
		{
			//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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0073: 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_009b: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			Color col = default(Color);
			((Color)(ref col))..ctor(1f, 0.85f, 0.3f);
			Add(0, pos, 0.55f, 1.6f, col, 0f, 0f, default(Vector3), 0.8f, 0f, 0f, 0f, 0.02f);
			Add(1, pos, 0.35f, 0.9f, Color.white, 0f, 0f, default(Vector3), 0.6f);
			AddRays(pos, N(14f), 0.9f, 0.014f, col, 0.35f);
			AddSparkles(pos, N(12f), 1.4f, Color.white);
			AddText("PERFECT!", pos + Vector3.up * 0.34f, 0.1f, col, 1.1f);
		}

		private static void UpdateFx()
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			if (_fx.Count == 0)
			{
				return;
			}
			Camera main = Camera.main;
			for (int num = _fx.Count - 1; num >= 0; num--)
			{
				Fx fx = _fx[num];
				float num2 = (Time.time - fx.t0) / fx.dur;
				if (num2 >= 1f || (Object)(object)fx.go == (Object)null || (Object)(object)main == (Object)null)
				{
					if ((Object)(object)fx.go != (Object)null)
					{
						Object.Destroy((Object)(object)fx.go);
					}
					if ((Object)(object)fx.mat != (Object)null)
					{
						Object.Destroy((Object)(object)fx.mat);
					}
					_fx.RemoveAt(num);
				}
				else
				{
					Transform transform = fx.go.transform;
					if (num2 < 0f)
					{
						transform.localScale = Vector3.zero;
					}
					else
					{
						float num3 = 1f - (1f - num2) * (1f - num2);
						Quaternion rotation = ((Component)main).transform.rotation;
						float num5;
						if (fx.kind == 0)
						{
							float num4 = Mathf.Lerp(0.05f, fx.size, num3);
							transform.position = fx.pos;
							transform.rotation = rotation;
							transform.localScale = new Vector3(num4, num4, 1f);
							num5 = Mathf.Pow(1f - num2, 1.5f);
						}
						else if (fx.kind == 1)
						{
							float num6 = Mathf.Lerp(fx.size * 0.6f, fx.size, num3);
							transform.position = (((Object)(object)fx.follow != (Object)null) ? fx.follow.position : fx.pos);
							transform.rotation = rotation;
							transform.localScale = new Vector3(num6, num6, 1f);
							num5 = 1f - num2;
						}
						else if (fx.kind == 2)
						{
							transform.position = fx.pos + fx.dir * (fx.dist * num3) + Vector3.down * (fx.gravity * num2 * num2);
							Vector3 val = Quaternion.Inverse(rotation) * fx.dir;
							float num7 = Mathf.Atan2(val.y, val.x) * 57.29578f;
							transform.rotation = rotation * Quaternion.Euler(0f, 0f, num7);
							transform.localScale = new Vector3(Mathf.Lerp(fx.size, fx.size * 0.2f, num2), fx.width, 1f);
							num5 = 1f - num2;
						}
						else if (fx.kind == 3)
						{
							float num8 = Mathf.Lerp(fx.size * 0.4f, fx.size, num3);
							float num9 = fx.angle * ((float)Math.PI / 180f);
							Vector3 val2 = rotation * new Vector3(Mathf.Cos(num9), Mathf.Sin(num9), 0f) * (0.02f + num8 * 0.5f);
							transform.position = fx.pos + val2;
							transform.rotation = rotation * Quaternion.Euler(0f, 0f, fx.angle);
							transform.localScale = new Vector3(num8, fx.width * (1f - 0.5f * num2), 1f);
							num5 = (1f - num2) * (1f - num2);
						}
						else if (fx.kind == 6)
						{
							Vector3 val3 = rotation * Vector3.right;
							transform.position = fx.pos + Vector3.up * (fx.dist * num3) + val3 * (Mathf.Sin(fx.angle + num2 * 5f) * fx.spin);
							transform.rotation = rotation * Quaternion.Euler(0f, 0f, Mathf.Sin(fx.angle + num2 * 4f) * 12f);
							float num10 = Mathf.Min(1f, num2 * 7f) * (1f + 0.12f * Mathf.Sin(num2 * 14f));
							transform.localScale = new Vector3(fx.size * num10, fx.size * num10, 1f);
							num5 = Mathf.Clamp01((1f - num2) / 0.45f);
						}
						else if (fx.kind == 5)
						{
							float num11 = Mathf.Lerp(0.6f, 1f, Mathf.Clamp01(num2 * 6f));
							transform.position = fx.pos + Vector3.up * (0.22f * num3);
							transform.rotation = rotation;
							transform.localScale = new Vector3(fx.size * fx.aspect * num11, fx.size * num11, 1f);
							num5 = Mathf.Clamp01((1f - num2) / 0.4f);
						}
						else
						{
							transform.position = fx.pos + fx.dir * (fx.dist * num3);
							transform.rotation = rotation * Quaternion.Euler(0f, 0f, fx.angle + fx.spin * num2);
							float num12 = fx.size * Mathf.Sin(num2 * (float)Math.PI);
							transform.localScale = new Vector3(num12, num12, 1f);
							num5 = 1f - num2 * num2;
						}
						fx.mat.color = new Color(fx.col.r, fx.col.g, fx.col.b, num5 * fx.peak);
					}
				}
			}
		}
	}
	internal static class DapUpNetwork
	{
		private static bool _available;

		private static float _nextWarn;

		public static bool Available => _available;

		public static void Init(Instance log)
		{
			bool flag = false;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				if (assemblies[i].GetName().Name == "LabFusion")
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				log.Msg("Fusion not found, multiplayer sync is off (everything else works).");
				return;
			}
			try
			{
				RegisterWithFusion();
				_available = true;
				log.Msg("Fusion sync ready.");
			}
			catch (Exception ex)
			{
				log.Warning("Could not hook into Fusion (" + ex.Message + "). Multiplayer sync is off.");
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterWithFusion()
		{
			ModuleManager.RegisterModule<DapUpFusionModule>();
		}

		public static void BroadcastHit(Vector3 position, byte kind, byte power, bool perfect, byte combo)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (!_available)
			{
				return;
			}
			try
			{
				SendCore(position, kind, power, perfect, combo);
			}
			catch (Exception ex)
			{
				if (Time.unscaledTime >= _nextWarn)
				{
					_nextWarn = Time.unscaledTime + 10f;
					MelonLogger.Warning("DapUp: could not send hit to other players (" + ex.Message + ")");
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void SendCore(Vector3 position, byte kind, byte power, bool perfect, byte combo)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkInfo.HasServer)
			{
				MessageRelay.RelayModule<DapUpHitMessage, DapUpHitData>(new DapUpHitData
				{
					position = position,
					kind = kind,
					power = power,
					perfect = perfect,
					combo = combo
				}, CommonMessageRoutes.ReliableToOtherClients);
			}
		}
	}
	public class DapUpFusionModule : Module
	{
		public override string Name => "DapUp";

		public override string Author => "DapUp";

		public override Version Version => new Version(1, 4, 0);

		protected override void OnModuleRegistered()
		{
			ModuleMessageManager.RegisterHandler<DapUpHitMessage>();
		}
	}
	public class DapUpHitData : INetSerializable
	{
		public Vector3 position;

		public byte kind;

		public byte power;

		public bool perfect;

		public byte combo;

		public int? GetSize()
		{
			return 24;
		}

		public void Serialize(INetSerializer serializer)
		{
			NetSerializerUnityExtensions.SerializeValue(serializer, ref position);
			serializer.SerializeValue(ref kind);
			serializer.SerializeValue(ref power);
			serializer.SerializeValue(ref perfect);
			serializer.SerializeValue(ref combo);
		}
	}
	public class DapUpHitMessage : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			DapUpHitData dapUpHitData = ((ReceivedMessage)(ref received)).ReadData<DapUpHitData>();
			DapUpMod.OnRemoteHit(dapUpHitData.position, dapUpHitData.kind, (float)(int)dapUpHitData.power / 255f, dapUpHitData.perfect, dapUpHitData.combo);
		}
	}
}