Decompiled source of MuzikaGromche v13.37.911

MuzikaGromche.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using CSync.Extensions;
using CSync.Lib;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.sigurd.csync")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("MuzikaGromche")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Opa che tut u nas")]
[assembly: AssemblyFileVersion("13.37.911.0")]
[assembly: AssemblyInformationalVersion("13.37.911+1cdbdf2f095930c9d7c5447824b3e16c9d98a6ae")]
[assembly: AssemblyProduct("MuzikaGromche")]
[assembly: AssemblyTitle("MuzikaGromche")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("13.37.911.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 MuzikaGromche
{
	public class DiscoBallManager : MonoBehaviour
	{
		public readonly record struct Data(string TileName, GameObject DiscoBallContainer)
		{
			public readonly string TileCloneName = TileName + "(Clone)";
		}

		public static readonly List<Data> Containers = new List<Data>();

		private static readonly List<GameObject> InstantiatedContainers = new List<GameObject>();

		private static readonly string[] animatorNames = new string[6] { "DiscoBallProp/AnimContainer", "DiscoBallProp1/AnimContainer", "DiscoBallProp2/AnimContainer", "DiscoBallProp3/AnimContainer", "DiscoBallProp4/AnimContainer", "DiscoBallProp5/AnimContainer" };

		public static void Initialize()
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "muzikagromche"));
			(string, string)[] array = new(string, string)[6]
			{
				("Assets/LethalCompany/Mods/MuzikaGromche/DiscoBallContainerManor.prefab", "ManorStartRoomSmall"),
				("Assets/LethalCompany/Mods/MuzikaGromche/DiscoBallContainerManorOLD.prefab", "ManorStartRoom"),
				("Assets/LethalCompany/Mods/MuzikaGromche/DiscoBallContainerFactory.prefab", "StartRoom"),
				("Assets/LethalCompany/Mods/MuzikaGromche/DiscoBallContainerMineShaft.prefab", "MineshaftStartTile"),
				("Assets/LethalCompany/Mods/MuzikaGromche/DiscoBallContainerLargeForkTileB.prefab", "LargeForkTileB"),
				("Assets/LethalCompany/Mods/MuzikaGromche/DiscoBallContainerBirthdayRoomTile.prefab", "BirthdayRoomTile")
			};
			for (int i = 0; i < array.Length; i++)
			{
				(string, string) tuple = array[i];
				string item = tuple.Item1;
				string item2 = tuple.Item2;
				GameObject discoBallContainer = val.LoadAsset<GameObject>(item);
				Containers.Add(new Data(item2, discoBallContainer));
			}
		}

		public static void Enable()
		{
			Disable();
			foreach (var (tile2, container2) in from tile in Resources.FindObjectsOfTypeAll<Tile>()
				join container in Containers on ((Object)((Component)tile).gameObject).name equals container.TileCloneName
				select (tile, container))
			{
				Enable(tile2, container2);
			}
		}

		private static void Enable(Tile tile, Data container)
		{
			Debug.Log((object)("MuzikaGromche DiscoBallManager Enabling at '" + ((Object)((Component)tile).gameObject).name + "'"));
			GameObject val = Object.Instantiate<GameObject>(container.DiscoBallContainer, ((Component)tile).transform);
			InstantiatedContainers.Add(val);
			string[] array = animatorNames;
			foreach (string text in array)
			{
				Transform obj = val.transform.Find(text);
				GameObject val2 = ((obj != null) ? ((Component)obj).gameObject : null);
				if (val2 != null)
				{
					val2.GetComponent<Animator>().SetBool("on", true);
				}
			}
		}

		public static void Disable()
		{
			foreach (GameObject instantiatedContainer in InstantiatedContainers)
			{
				Debug.Log((object)("MuzikaGromche DiscoBallManager: Disabling " + ((Object)instantiatedContainer).name));
				Object.Destroy((Object)(object)instantiatedContainer);
			}
			InstantiatedContainers.Clear();
		}
	}
	[BepInPlugin("MuzikaGromche", "MuzikaGromche", "13.37.911")]
	[BepInDependency("com.sigurd.csync", "5.0.1")]
	[BepInDependency("ainavt.lc.lethalconfig", "1.4.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private static readonly string[] PwnLyricsVariants;

		public static Track[] Tracks;

		public static Track CurrentTrack;

		public static BeatTimeState BeatTimeState;

		internal static Config Config { get; private set; } = null;


		public static Track ChooseTrack()
		{
			int chosenSeed = RoundManager.Instance.dungeonGenerator.Generator.ChosenSeed;
			Track[] array = (Config.SkipExplicitTracks.Value ? Tracks.Where((Track track) => !track.IsExplicit).ToArray() : Tracks);
			int[] weights = array.Select((Track track) => track.Weight.Value).ToArray();
			RandomWeightedIndex randomWeightedIndex = new RandomWeightedIndex(weights);
			int randomWeightedIndex2 = randomWeightedIndex.GetRandomWeightedIndex(chosenSeed);
			Track track2 = array[randomWeightedIndex2];
			Debug.Log((object)$"Seed is {chosenSeed}, chosen track is \"{track2.Name}\", #{randomWeightedIndex2} of {randomWeightedIndex}");
			return array[randomWeightedIndex2];
		}

		public static void SetLightColor(Color color)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			foreach (Light allPoweredLight in RoundManager.Instance.allPoweredLights)
			{
				allPoweredLight.color = color;
			}
		}

		public static void ResetLightColor()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			SetLightColor(Color.white);
		}

		public static bool LocalPlayerCanHearMusic(EnemyAI jester)
		{
			//IL_0024: 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)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null || !localPlayerController.isInsideFactory)
			{
				return false;
			}
			return Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)jester).transform.position) < jester.creatureVoice.maxDistance;
		}

		private void Awake()
		{
			//IL_004c: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			string text = ((BaseUnityPlugin)this).Info.Location.TrimEnd("MuzikaGromche.dll".ToCharArray());
			UnityWebRequest[] array = (UnityWebRequest[])(object)new UnityWebRequest[Tracks.Length * 2];
			for (int i = 0; i < Tracks.Length; i++)
			{
				Track track = Tracks[i];
				array[i * 2] = UnityWebRequestMultimedia.GetAudioClip("File://" + text + track.FileNameStart, track.AudioType);
				array[i * 2 + 1] = UnityWebRequestMultimedia.GetAudioClip("File://" + text + track.FileNameLoop, track.AudioType);
				array[i * 2].SendWebRequest();
				array[i * 2 + 1].SendWebRequest();
			}
			while (!array.All((UnityWebRequest request) => request.isDone))
			{
			}
			if (array.All((UnityWebRequest request) => (int)request.result == 1))
			{
				for (int j = 0; j < Tracks.Length; j++)
				{
					Track obj = Tracks[j];
					obj.LoadedStart = DownloadHandlerAudioClip.GetContent(array[j * 2]);
					obj.LoadedLoop = DownloadHandlerAudioClip.GetContent(array[j * 2 + 1]);
				}
				Config = new Config(((BaseUnityPlugin)this).Config);
				DiscoBallManager.Initialize();
				Harmony val = new Harmony("MuzikaGromche");
				val.PatchAll(typeof(JesterPatch));
				val.PatchAll(typeof(EnemyAIPatch));
			}
			else
			{
				IEnumerable<string> values = from request in array
					where (int)request.result != 1
					select request.GetUrl();
				((BaseUnityPlugin)this).Logger.LogError((object)("Could not load audio file" + string.Join(", ", values)));
			}
		}

		static Plugin()
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fde: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_11cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_12c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_13bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_14fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a8b: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			list.Add("");
			list.Add("");
			list.Add("");
			list.AddRange(from a in (from n in NetworkInterface.GetAllNetworkInterfaces()
					where n.OperationalStatus == OperationalStatus.Up
					select n).SelectMany((NetworkInterface n) => n.GetIPProperties().UnicastAddresses)
				where a.Address.AddressFamily == AddressFamily.InterNetwork
				select a.Address.ToString() into a
				select " Trying... " + a);
			PwnLyricsVariants = list.ToArray();
			Tracks = new Track[15]
			{
				new Track
				{
					Name = "MuzikaGromche",
					AudioType = (AudioType)14,
					Language = Language.RUSSIAN,
					WindUpTimer = 46.3f,
					Bars = 16,
					BeatsOffset = 0f,
					FadeOutBeat = -3f,
					FadeOutDuration = 3f,
					ColorTransitionIn = 0.25f,
					ColorTransitionOut = 0.25f,
					ColorTransitionEasing = Easing.OutExpo,
					FlickerLightsTimeSeries = new float[3] { -5f, 29f, 61f },
					Palette = Palette.Parse(new string[6] { "#B300FF", "#FFF100", "#00FF51", "#474747", "#FF00B3", "#0070FF" }),
					Lyrics = new(float, string)[22]
					{
						(-68f, "Devchata pljashut pod spidami"),
						(-60f, "A ty stoish', kak vkopannyj"),
						(-52f, "Krossovkami lomajut pol"),
						(-44f, "A ty stoish', kak vkopannyj"),
						(-36f, "Ja-ja-ja znaju, chto ty hochesh',"),
						(-32f, "Ja-ja-ja znaju, chto ty hochesh',\nTy hochesh' tancevat'"),
						(-28f, "Nu-nu zhe, nu davaj zhe,"),
						(-24f, "Nu-nu zhe, nu davaj zhe,\nNu-nu zhe, nu davaj zhe"),
						(-20f, "Ja znaju, chto ty znaesh'\nJetot trek, gotov'sja podpevat'"),
						(-12f, "1) RAZ"),
						(-10f, "raz, DVA"),
						(-8f, "raz, 2wo,\nTRI"),
						(-6f, "ras, dva,\n7ri, 4ETYRE"),
						(-1f, "Muzyka Gromche\nGlaza zakryty >_<"),
						(6f, "This is NON-STOP,\nNoch'ju otkrytij"),
						(12f, "Delaj chto hochesh', ja zabyvajus'"),
						(22f, "This is NON-STOP,\nne prekrashhajas'"),
						(31f, "Muzyka Gromche\nGlaza zakryty -.-"),
						(38f, "This is NON-STOP,\nNoch'ju otkrytij"),
						(46f, "Budu s toboju,\nsamoj primernoju"),
						(54f, "Utro v okne\nyi my budem pervye"),
						(63f, "Muzyka Gromche\nGlaza zakryty >_<")
					}
				},
				new Track
				{
					Name = "VseVZale",
					AudioType = (AudioType)14,
					Language = Language.RUSSIAN,
					WindUpTimer = 38.28f,
					Bars = 16,
					LoopOffset = 0,
					BeatsOffset = 0.25f,
					FadeOutBeat = -3f,
					FadeOutDuration = 2.5f,
					ColorTransitionIn = 0.25f,
					ColorTransitionOut = 0.25f,
					ColorTransitionEasing = Easing.OutExpo,
					FlickerLightsTimeSeries = new float[3] { -5f, 29f, 59f },
					Palette = Palette.Parse(new string[6] { "#FF7F00", "#FFB600", "#FFED00", "#00D1FF", "#6696FB", "#704DF8" }).Use((Palette palette) => palette * 5 + new Palette(palette.Colors[0..2]) + (new Palette(palette.Colors[2..]) + palette * 2).Stretch(2)),
					Lyrics = new(float, string)[12]
					{
						(-30f, "VSE V ZALE\nDvigajtes' s nami"),
						(-24f, "Chtob sotrjasalis'\nSami my, steny i pol!"),
						(-14f, "Vse znaem - jeto examen na dom nam zadan"),
						(-4f, "HIP-HOP, HOUSE & ROCK-N-ROLL"),
						(2f, "VSE V ZALE\nDvigajtes' s nami"),
						(8f, "Chtob sotrjasalis'\nSami my, steny i pol!"),
						(18f, "Vse znaem - jeto examen na dom nam zadan"),
						(28f, "HIP-HOP, HOUSE & ROCK-N-ROLL"),
						(32f, "O-o-o-o! Zdes' startuet hip-hop party"),
						(44f, "Tolstyj paren', nam igraj!"),
						(48f, "O-o-o-o! Pesen i devchonok hvatit!"),
						(60f, "Everybody shake your body")
					}
				},
				new Track
				{
					Name = "DeployDestroy",
					AudioType = (AudioType)14,
					Language = Language.RUSSIAN,
					WindUpTimer = 40.68f,
					Bars = 8,
					LoopOffset = 32,
					BeatsOffset = 0.2f,
					FadeOutBeat = -6f,
					FadeOutDuration = 4f,
					ColorTransitionIn = 0.25f,
					ColorTransitionOut = 0.25f,
					ColorTransitionEasing = Easing.OutExpo,
					FlickerLightsTimeSeries = new float[7] { -101f, -93f, -77f, -61f, -37f, -5f, 27f },
					Palette = Palette.Parse(new string[5] { "#217F87", "#BAFF00", "#73BE25", "#78AB4E", "#FFFF00" }),
					Lyrics = new(float, string)[24]
					{
						(-79f, "Deploy Destroy, porjadok eto otstoj"),
						(-71f, "Krushi, lomaj, trjasi bashkoju pustoj"),
						(-63f, "Dopej, razbej i novuju otkryvaj"),
						(-55f, "Davaj-davaj!"),
						(-47f, "Chestnoe slovo ja nevinoven"),
						(-43f, "Ja ne pomnju, otkuda stol'ko krovi"),
						(-39f, "Na moih ladonjah\nyi moej odezhde"),
						(-35f, "Ja nikogda nikogo\nne bil prezhde"),
						(-31f, "Ja nikogda nichego\nne pil prezhde"),
						(-27f, "Byl tih, spokoen,\nso vsemi vezhliv"),
						(-23f, "Vsegda tol'ko v urnu\nbrosal musor"),
						(-19f, "Obhodil storonoj shumnye tusy"),
						(-15f, "Zapreshhjonnyh veshhestv nikakih ne juzal"),
						(-11f, "Byl polozhitel'nej samogo pljusa"),
						(-7f, "A potom kak-to raz\njetu pesnju uslyshal"),
						(-3f, "I vsjo proshhaj, moja krysha"),
						(1f, "Deploy Destroy, porjadok eto otstoj"),
						(9f, "Krushi, lomaj, trjasi bashkoju pustoj"),
						(17f, "Dopej, razbej i novuju otkryvaj"),
						(25f, "Davaj-davaj!"),
						(33f, "Deploy Destroy, porjadok eto otstoj"),
						(41f, "Krushi, lomaj, trjasi bashkoju pustoj"),
						(49f, "Dopej, razbej i novuju otkryvaj"),
						(57f, "Davaj-davaj!")
					}
				},
				new Track
				{
					Name = "MoyaZhittya",
					AudioType = (AudioType)14,
					Language = Language.ENGLISH,
					WindUpTimer = 34.53f,
					Bars = 8,
					LoopOffset = 32,
					BeatsOffset = 0f,
					FadeOutBeat = -35f,
					FadeOutDuration = 3.3f,
					ColorTransitionIn = 0.25f,
					ColorTransitionOut = 0.25f,
					ColorTransitionEasing = Easing.OutExpo,
					Palette = Palette.Parse(new string[8] { "#A3A3A3", "#BE3D39", "#5CBC69", "#BE3D39", "#BABC5C", "#BE3D39", "#5C96BC", "#BE3D39" }),
					FlickerLightsTimeSeries = new float[14]
					{
						-100.5f, -99.5f, -92.5f, -91.5f, -76.5f, -75.5f, -60.5f, -59.5f, -37f, -36f,
						-4.5f, -3.5f, 27.5f, 28.5f
					},
					Lyrics = new(float, string)[28]
					{
						(-84f, "This ain't a song for the broken-hearted"),
						(-68f, "No silent prayer for the faith-departed"),
						(-52f, "I ain't gonna be"),
						(-48f, "I ain't gonna be\njust a face in the crowd"),
						(-45f, "YOU'RE"),
						(-44f, "you're GONNA"),
						(-43.5f, "you're gonna HEAR"),
						(-43f, "you're gonna hear\nMY"),
						(-42f, "you're gonna hear\nmy VOICE"),
						(-41f, "WHEN I"),
						(-40f, "When I SHOUT IT"),
						(-39f, "When I shout it\nOUT LOUD"),
						(-34f, "IT'S MY"),
						(-32f, "IT'S MY\nLIIIIIFE"),
						(-28f, "And it's now or never"),
						(-22f, "I ain't gonna"),
						(-20f, "I ain't gonna\nlive forever"),
						(-14f, "I just want to live"),
						(-10f, "I just want to live\nwhile I'm alive"),
						(-2f, "IT'S MY"),
						(0f, "IT'S MY\nLIIIIIFE"),
						(2f, "My heart is like"),
						(4f, "My heart is like\nan open highway"),
						(10f, "Like Frankie said,"),
						(12f, "Like Frankie said,\n\"I did it my way\""),
						(18f, "I just want to live"),
						(22f, "I just want to live\nwhile I'm alive"),
						(30f, "IT'S MY")
					}
				},
				new Track
				{
					Name = "Gorgorod",
					AudioType = (AudioType)14,
					Language = Language.RUSSIAN,
					WindUpTimer = 43.2f,
					Bars = 6,
					BeatsOffset = 0f,
					ColorTransitionIn = 0.25f,
					ColorTransitionOut = 0.25f,
					ColorTransitionEasing = Easing.InExpo,
					Palette = Palette.Parse(new string[8] { "#42367E", "#FF9400", "#932A04", "#FF9400", "#932A04", "#42367E", "#FF9400", "#932A04" }),
					LoopOffset = 0,
					FadeOutBeat = -2f,
					FadeOutDuration = 2f,
					FlickerLightsTimeSeries = new float[1] { 20f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "Durochka",
					AudioType = (AudioType)14,
					Language = Language.RUSSIAN,
					WindUpTimer = 37f,
					Bars = 10,
					BeatsOffset = 0f,
					ColorTransitionIn = 0.25f,
					ColorTransitionOut = 0.3f,
					ColorTransitionEasing = Easing.OutExpo,
					Palette = Palette.Parse(new string[8] { "#5986FE", "#FEFEDC", "#FF4FDF", "#FEFEDC", "#FFAA23", "#FEFEDC", "#F95A5A", "#FEFEDC" }),
					LoopOffset = 0,
					FadeOutBeat = -7f,
					FadeOutDuration = 7f,
					FlickerLightsTimeSeries = new float[1] { -9f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "ZmeiGorynich",
					AudioType = (AudioType)14,
					Language = Language.KOREAN,
					WindUpTimer = 46.13f,
					Bars = 8,
					BeatsOffset = 0.1f,
					ColorTransitionIn = 0.4f,
					ColorTransitionOut = 0.4f,
					ColorTransitionEasing = Easing.OutExpo,
					Palette = Palette.Parse(new string[6] { "#4C8AC5", "#AF326A", "#0B1666", "#AFD2FC", "#C55297", "#540070" }),
					LoopOffset = 0,
					FadeOutBeat = -4f,
					FadeOutDuration = 4f,
					FlickerLightsTimeSeries = new float[2] { -5f, 31f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "GodMode",
					AudioType = (AudioType)14,
					Language = Language.ENGLISH,
					WindUpTimer = 40.38f,
					Bars = 16,
					BeatsOffset = 0.1f,
					ColorTransitionIn = 0.5f,
					ColorTransitionOut = 0.5f,
					ColorTransitionEasing = Easing.OutCubic,
					Palette = Palette.Parse(new string[8] { "#FBDBDB", "#4B81FF", "#564242", "#C90AE2", "#FBDBDB", "#61CBE3", "#564242", "#ED3131" }),
					LoopOffset = 0,
					FadeOutBeat = -4f,
					FadeOutDuration = 4f,
					FlickerLightsTimeSeries = new float[1] { -5f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "RiseAndShine",
					AudioType = (AudioType)14,
					Language = Language.ENGLISH,
					WindUpTimer = 59.87f,
					Bars = 16,
					BeatsOffset = 0.1f,
					ColorTransitionIn = 0.5f,
					ColorTransitionOut = 0.5f,
					ColorTransitionEasing = Easing.OutCubic,
					Palette = Palette.Parse(new string[8] { "#FC6F3C", "#3CB0FC", "#FCD489", "#564242", "#FC6F3C", "#3CB0FC", "#63E98C", "#866868" }),
					LoopOffset = 0,
					FadeOutBeat = -4.5f,
					FadeOutDuration = 4f,
					FlickerLightsTimeSeries = new float[3] { -5.5f, 31f, 63.9f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "Song2",
					AudioType = (AudioType)14,
					Language = Language.RUSSIAN,
					WindUpTimer = 38.63f,
					Beats = 34,
					BeatsOffset = 0.1f,
					ColorTransitionIn = 0.3f,
					ColorTransitionOut = 0.3f,
					ColorTransitionEasing = Easing.InCubic,
					Palette = Palette.Parse(new string[8] { "#FFD3E3", "#78A0FF", "#FFD3E3", "#74A392", "#FFD3E3", "#E4B082", "#FFD3E3", "#E277AA" }),
					LoopOffset = 0,
					FadeOutBeat = -2f,
					FadeOutDuration = 2f,
					FlickerLightsTimeSeries = new float[1] { 2.5f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "Peretasovka",
					AudioType = (AudioType)14,
					Language = Language.ENGLISH,
					WindUpTimer = 59.07f,
					Bars = 8,
					BeatsOffset = 0.3f,
					ColorTransitionIn = 0.4f,
					ColorTransitionOut = 0.4f,
					ColorTransitionEasing = Easing.OutExpo,
					Palette = Palette.Parse(new string[8] { "#65C7FA", "#FCEB3C", "#89FC8F", "#FEE9E9", "#FC3C9D", "#FCEB3C", "#89FC8F", "#FC3C9D" }),
					LoopOffset = 0,
					FadeOutBeat = -6f,
					FadeOutDuration = 4f,
					FlickerLightsTimeSeries = new float[2] { -8f, 31f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "Yalgaar",
					AudioType = (AudioType)14,
					Language = Language.HINDI,
					WindUpTimer = 52.17f,
					Bars = 8,
					BeatsOffset = 0f,
					ColorTransitionIn = 0.1f,
					ColorTransitionOut = 0.35f,
					ColorTransitionEasing = Easing.OutExpo,
					Palette = Palette.Parse(new string[8] { "#C0402D", "#906F0B", "#DC8044", "#70190A", "#929FAF", "#4248A2", "#AE2727", "#2D2D42" }),
					LoopOffset = 0,
					FadeOutBeat = -4f,
					FadeOutDuration = 4f,
					FlickerLightsTimeSeries = new float[1] { -5f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "Chereshnya",
					AudioType = (AudioType)14,
					Language = Language.RUSSIAN,
					WindUpTimer = 45.58f,
					Bars = 16,
					BeatsOffset = 0f,
					ColorTransitionIn = 0.3f,
					ColorTransitionOut = 0.35f,
					ColorTransitionEasing = Easing.InOutCubic,
					Palette = Palette.Parse(new string[16]
					{
						"#A01471", "#CB2243", "#4CAF50", "#F01D7A", "#AF005A", "#EF355F", "#FFD85D", "#FF66B2", "#A01471", "#4CAF50",
						"#CB2243", "#F01D7A", "#AF005A", "#FFD85D", "#EF355F", "#FF66B2"
					}),
					LoopOffset = 0,
					FadeOutBeat = -4f,
					FadeOutDuration = 4f,
					FlickerLightsTimeSeries = new float[5] { -5f, 27f, 29f, 59f, 61f },
					Lyrics = Array.Empty<(float, string)>()
				},
				new Track
				{
					Name = "PWNED",
					AudioType = (AudioType)14,
					Language = Language.ENGLISH,
					IsExplicit = true,
					WindUpTimer = 39.73f,
					Bars = 32,
					BeatsOffset = -0.2f,
					ColorTransitionIn = 0.5f,
					ColorTransitionOut = 0.3f,
					ColorTransitionEasing = Easing.InExpo,
					Palette = Palette.Parse(new string[8] { "#9E9E9E", "#383838", "#5E5E5E", "#2E2E2E", "#666666", "#4B4B4B", "#8E8E8E", "#1D1D1D" }).Use(delegate(Palette gray8)
					{
						Palette palette2 = Palette.Parse(new string[4] { "#FFFFFF", "#0032A0", "#DA291C", "#000000" });
						Palette palette3 = new Palette(gray8.Colors[0..6]);
						Palette palette4 = gray8 + palette3;
						Palette palette5 = palette2 + palette4.Stretch(2);
						Palette palette6 = gray8.Stretch(4);
						return palette5 * 2 + palette6 * 2;
					}),
					LoopOffset = 0,
					FadeOutBeat = -8f,
					FadeOutDuration = 6f,
					FlickerLightsTimeSeries = new float[4] { -136f, -72f, -12f, 88f },
					Lyrics = new(float, string)[44]
					{
						(-190f, "These Russian hackers have been"),
						(-184f, "in these US governments\nsince March"),
						(-172f, "and it is an extraordinary invasion of our cyberspace"),
						(-152f, "Russian hackers got access to sensitive"),
						(-142f, "parts of the White House email system..."),
						(-134f, "[They began to recognize...]"),
						(-126f, "<Russian hackers/>"),
						(-118f, "<Russian hackers/>\n X__X"),
						(-110f, "Gonna crack your"),
						(-102f, "Gonna crack your\nStrongest pa$$words%123"),
						(-94f, "You popped online"),
						(-86f, "You popped online\nTo look for sneakers"),
						(-78f, "My hand just popped"),
						(-70f, "My hand just popped\nRight in your knickers >_< "),
						(-62f, "Keystrokes like Uzi"),
						(-54f, "Keystrokes like Uzi\nWill make you go all goosey"),
						(-46f, "Kicking down your backdoor"),
						(-38f, "Kicking down your backdoor\nCount down before you lose it"),
						(-30f, "Keystrokes like Uzi"),
						(-22f, "Keystrokes like Uzi\nWill make you go all goosey"),
						(-14f, "Kicking down your backdoor"),
						(-6f, "Kicking down your backdoor\nCount down before you lose it"),
						(0f, "C:\\> $Ru55ian hack3rs"),
						(4f, "C:\\> $Ru55ian hack3rs\n O__o"),
						(8f, "Infamous White House attackers"),
						(16f, "Stealing your cookies\nto this beat"),
						(24f, "Counting crypto to\nembarrass Wall Street"),
						(32f, "Russi?n ^hackers\tЯushan h@ckers###"),
						(34f, "\tЯushan h@ckers###\n   X_X"),
						(36f, "Russi?n ^hackers\n--.--\tЯushan h@ckers###\n  X___X"),
						(38f, "\tЯushan h@ckers###\n X_____X"),
						(40f, "Infamous White House attackers"),
						(48f, "Stealing your cookies\nto this beat"),
						(56f, "Counting crypto to\nembarrass Wall Street"),
						(80f, "Instling min3r.exe\t\t\tresolving ur private IP\n/"),
						(82f, "Instling min3r.exe\n00% [8=D            ]\tHenllo ${username = \"" + Environment.UserName + "\"}\t\tresolving ur private IP\n-" + PwnLyricsVariants[^3]),
						(84f, "Instling min3r.exe\n33% [8====D         ]\t\t\tresolving ur private IP\n\\" + PwnLyricsVariants[^3]),
						(86f, "Instling min3r.exe\n66% [8=========D    ]\t\t\tresolving ur private IP\n|" + PwnLyricsVariants[^2]),
						(88f, "Instling min3r.exe\n95% [8============D ]\t\tWhere did you download\nthis < mod / dll > from?\tresolving ur private IP\n" + PwnLyricsVariants[^2] + "/"),
						(90f, "Instling min3r.exe\n99% [8=============D]\t\t\tresolving ur private IP\n-" + PwnLyricsVariants[^2]),
						(92f, "Encrpt1ng f!les.. \n99% [8=============D]\t\t\tresolving ur private IP\n\\" + PwnLyricsVariants[^1]),
						(94f, "Encrpt1ng f!les...\n100% enj0y \\o/\t\t\tresolving ur private IP\n|" + PwnLyricsVariants[^1]),
						(96f, "\t\t\tresolving ur private IP\n/" + PwnLyricsVariants[^1]),
						(98f, "\t\t\tresolving ur private IP\nP_WNED")
					}
				},
				new Track
				{
					Name = "Kach",
					AudioType = (AudioType)14,
					Language = Language.ENGLISH,
					WindUpTimer = 48.3f,
					Bars = 12,
					BeatsOffset = 0.4f,
					ColorTransitionIn = 0.8f,
					ColorTransitionOut = 0.4f,
					ColorTransitionEasing = Easing.OutExpo,
					Palette = Palette.Parse(new string[12]
					{
						"#7774DE", "#1EA59A", "#3BC457", "#3BC457", "#CA6935", "#A82615", "#A7AA43", "#A7AA43", "#4C2B81", "#2E802B",
						"#C952E7", "#C952E7"
					}),
					LoopOffset = 0,
					FadeOutBeat = -6f,
					FadeOutDuration = 6f,
					FlickerLightsTimeSeries = new float[3] { -8f, 44f, 45f },
					Lyrics = Array.Empty<(float, string)>()
				}
			};
		}
	}
	public record Language(string Short, string Full)
	{
		public static readonly Language ENGLISH = new Language("EN", "English");

		public static readonly Language RUSSIAN = new Language("RU", "Russian");

		public static readonly Language KOREAN = new Language("KO", "Korean");

		public static readonly Language HINDI = new Language("HI", "Hindi");

		[CompilerGenerated]
		protected Language(Language original)
		{
			Short = original.Short;
			Full = original.Full;
		}
	}
	public readonly record struct Easing(string Name, Func<float, float> Eval)
	{
		public static string[] AllNames => All.Select((Easing easing) => easing.Name).ToArray();

		public static Easing Linear = new Easing("Linear", (float x) => x);

		public static Easing OutCubic = new Easing("OutCubic", (float x) => 1f - Mathf.Pow(1f - x, 3f));

		public static Easing InCubic = new Easing("InCubic", (float x) => x * x * x);

		public static Easing InOutCubic = new Easing("InOutCubic", (float x) => (!(x < 0.5f)) ? (1f - Mathf.Pow(-2f * x + 2f, 3f) / 2f) : (4f * x * x * x));

		public static Easing InExpo = new Easing("InExpo", (float x) => (x != 0f) ? Mathf.Pow(2f, 10f * x - 10f) : 0f);

		public static Easing OutExpo = new Easing("OutExpo", (float x) => (x != 1f) ? (1f - Mathf.Pow(2f, -10f * x)) : 1f);

		public static Easing InOutExpo = new Easing("InOutExpo", (float x) => (x != 0f) ? ((x != 1f) ? ((!(x < 0.5f)) ? ((2f - Mathf.Pow(2f, -20f * x + 10f)) / 2f) : (Mathf.Pow(2f, 20f * x - 10f) / 2f)) : 1f) : 0f);

		public static Easing[] All = new Easing[7] { Linear, InCubic, OutCubic, InOutCubic, InExpo, OutExpo, InOutExpo };

		public static Easing FindByName(string Name)
		{
			return All.Where((Easing easing) => easing.Name == Name).DefaultIfEmpty(Linear).First();
		}
	}
	public record Palette(Color[] Colors)
	{
		public static Palette DEFAULT = new Palette((Color[])(object)new Color[4]
		{
			Color.magenta,
			Color.cyan,
			Color.green,
			Color.yellow
		});

		public static Palette Parse(string[] hexColors)
		{
			Color[] array = (Color[])(object)new Color[hexColors.Length];
			for (int i = 0; i < hexColors.Length; i++)
			{
				if (!ColorUtility.TryParseHtmlString(hexColors[i], ref array[i]))
				{
					throw new ArgumentException($"Unable to parse color #{i}: {hexColors}");
				}
			}
			return new Palette(array);
		}

		public static Palette operator +(Palette before, Palette after)
		{
			Color[] colors = before.Colors;
			Color[] colors2 = after.Colors;
			int num = 0;
			Color[] array = (Color[])(object)new Color[colors.Length + colors2.Length];
			ReadOnlySpan<Color> readOnlySpan = new ReadOnlySpan<Color>(colors);
			readOnlySpan.CopyTo(new Span<Color>(array).Slice(num, readOnlySpan.Length));
			num += readOnlySpan.Length;
			ReadOnlySpan<Color> readOnlySpan2 = new ReadOnlySpan<Color>(colors2);
			readOnlySpan2.CopyTo(new Span<Color>(array).Slice(num, readOnlySpan2.Length));
			num += readOnlySpan2.Length;
			return new Palette(array);
		}

		public static Palette operator *(Palette palette, int repeat)
		{
			return new Palette(Enumerable.Repeat(palette.Colors, repeat).SelectMany((Color[] x) => x).ToArray());
		}

		public Palette Stretch(int times)
		{
			return new Palette(Colors.SelectMany((Color color) => Enumerable.Repeat<Color>(color, times)).ToArray());
		}

		public Palette Use(Func<Palette, Palette> op)
		{
			return op(this);
		}

		[CompilerGenerated]
		protected Palette(Palette original)
		{
			Colors = original.Colors;
		}
	}
	public class Track
	{
		public string Name;

		public Language Language;

		public bool IsExplicit;

		public float WindUpTimer;

		public int Beats;

		public int LoopOffset;

		public AudioType AudioType = (AudioType)13;

		public AudioClip LoadedStart;

		public AudioClip LoadedLoop;

		public SyncedEntry<int> Weight;

		public float _BeatsOffset;

		public float _FadeOutBeat = float.NaN;

		public float _FadeOutDuration = 2f;

		public float _ColorTransitionIn = 0.25f;

		public float _ColorTransitionOut = 0.25f;

		public Easing _ColorTransitionEasing = Easing.OutExpo;

		public float[] _FlickerLightsTimeSeries = Array.Empty<float>();

		public float[] _LyricsTimeSeries = Array.Empty<float>();

		public Palette _Palette = Palette.DEFAULT;

		public float Bpm => 60f / (LoadedLoop.length / (float)Beats);

		public float LoopOffsetInSeconds => (float)(LoopOffset / Beats) * LoadedLoop.length;

		public int Bars
		{
			set
			{
				Beats = value * 4;
			}
		}

		public string FileNameStart => Name + "Start." + Ext;

		public string FileNameLoop => Name + "Loop." + Ext;

		private string Ext
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Invalid comparison between Unknown and I4
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Invalid comparison between Unknown and I4
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Invalid comparison between Unknown and I4
				AudioType audioType = AudioType;
				if ((int)audioType != 13)
				{
					if ((int)audioType != 14)
					{
						if ((int)audioType == 20)
						{
							return "wav";
						}
						return "";
					}
					return "ogg";
				}
				return "mp3";
			}
		}

		public float BeatsOffset
		{
			get
			{
				return Config.BeatsOffsetOverride ?? _BeatsOffset;
			}
			set
			{
				_BeatsOffset = value;
			}
		}

		public float BeatsOffsetInSeconds => BeatsOffset / (float)Beats * LoadedLoop.length;

		public float FadeOutBeat
		{
			get
			{
				return Config.FadeOutBeatOverride ?? _FadeOutBeat;
			}
			set
			{
				_FadeOutBeat = value;
			}
		}

		public float FadeOutDuration
		{
			get
			{
				return Config.FadeOutDurationOverride ?? _FadeOutDuration;
			}
			set
			{
				_FadeOutDuration = value;
			}
		}

		public float ColorTransitionIn
		{
			get
			{
				return Config.ColorTransitionInOverride ?? _ColorTransitionIn;
			}
			set
			{
				_ColorTransitionIn = value;
			}
		}

		public float ColorTransitionOut
		{
			get
			{
				return Config.ColorTransitionOutOverride ?? _ColorTransitionOut;
			}
			set
			{
				_ColorTransitionOut = value;
			}
		}

		public Easing ColorTransitionEasing
		{
			get
			{
				if (Config.ColorTransitionEasingOverride == null)
				{
					return _ColorTransitionEasing;
				}
				return Easing.FindByName(Config.ColorTransitionEasingOverride);
			}
			set
			{
				_ColorTransitionEasing = value;
			}
		}

		public float[] FlickerLightsTimeSeries
		{
			get
			{
				return Config.FlickerLightsTimeSeriesOverride ?? _FlickerLightsTimeSeries;
			}
			set
			{
				Array.Sort(value);
				_FlickerLightsTimeSeries = value;
			}
		}

		public float[] LyricsTimeSeries
		{
			get
			{
				return Config.LyricsTimeSeriesOverride ?? _LyricsTimeSeries;
			}
			private set
			{
				_LyricsTimeSeries = value;
			}
		}

		public string[] LyricsLines { get; private set; }

		public (float, string)[] Lyrics
		{
			set
			{
				SortedDictionary<float, string> sortedDictionary = new SortedDictionary<float, string>();
				for (int i = 0; i < value.Length; i++)
				{
					var (key, value2) = value[i];
					sortedDictionary.Add(key, value2);
				}
				LyricsTimeSeries = sortedDictionary.Keys.ToArray();
				LyricsLines = sortedDictionary.Values.ToArray();
			}
		}

		public Palette Palette
		{
			get
			{
				return Config.PaletteOverride ?? _Palette;
			}
			set
			{
				_Palette = value;
			}
		}
	}
	public readonly record struct BeatTimestamp
	{
		public float HalfLoopBeats => (float)LoopBeats / 2f;

		public readonly int LoopBeats;

		public readonly bool IsLooping;

		public readonly float Beat;

		public BeatTimestamp(int loopBeats, bool isLooping, float beat)
		{
			IsLooping = false;
			Beat = 0f;
			LoopBeats = loopBeats;
			IsLooping = isLooping || beat >= HalfLoopBeats;
			Beat = ((isLooping || beat >= (float)LoopBeats) ? Mod.Positive(beat, LoopBeats) : beat);
		}

		public static BeatTimestamp operator +(BeatTimestamp self, float delta)
		{
			if (delta < 0f - self.HalfLoopBeats && self.Beat > self.HalfLoopBeats)
			{
				_ = self.IsLooping;
			}
			return new BeatTimestamp(self.LoopBeats, self.IsLooping, self.Beat + delta);
		}

		public static BeatTimestamp operator -(BeatTimestamp self, float delta)
		{
			return self + (0f - delta);
		}

		public BeatTimestamp Floor()
		{
			float beat = Mathf.Floor(Beat);
			return new BeatTimestamp(LoopBeats, IsLooping, beat);
		}

		public override string ToString()
		{
			return string.Format("{0}({1} {2:N4}/{3})", "BeatTimestamp", IsLooping ? 'Y' : 'n', Beat, LoopBeats);
		}

		[CompilerGenerated]
		private bool PrintMembers(StringBuilder builder)
		{
			builder.Append("LoopBeats = ");
			builder.Append(LoopBeats.ToString());
			builder.Append(", HalfLoopBeats = ");
			builder.Append(HalfLoopBeats.ToString());
			builder.Append(", IsLooping = ");
			builder.Append(IsLooping.ToString());
			builder.Append(", Beat = ");
			builder.Append(Beat.ToString());
			return true;
		}
	}
	public readonly record struct BeatTimeSpan
	{
		public float HalfLoopBeats => (float)LoopBeats / 2f;

		public readonly int LoopBeats;

		public readonly bool IsLooping;

		public readonly float BeatFromExclusive;

		public readonly float BeatToInclusive;

		public static BeatTimeSpan Empty;

		public BeatTimeSpan(int loopBeats, bool isLooping, float beatFromExclusive, float beatToInclusive)
		{
			IsLooping = false;
			BeatFromExclusive = 0f;
			BeatToInclusive = 0f;
			LoopBeats = loopBeats;
			IsLooping = isLooping || beatToInclusive >= HalfLoopBeats;
			BeatFromExclusive = wrap(beatFromExclusive);
			BeatToInclusive = wrap(beatToInclusive);
			float wrap(float beat)
			{
				if (!isLooping && !(beat >= (float)loopBeats))
				{
					return beat;
				}
				return Mod.Positive(beat, loopBeats);
			}
		}

		public static BeatTimeSpan Between(BeatTimestamp timestampFromExclusive, BeatTimestamp timestampToInclusive)
		{
			return new BeatTimeSpan(timestampToInclusive.LoopBeats, timestampToInclusive.IsLooping, timestampFromExclusive.Beat, timestampToInclusive.Beat);
		}

		public static BeatTimeSpan Between(float beatFromExclusive, BeatTimestamp timestampToInclusive)
		{
			return new BeatTimeSpan(timestampToInclusive.LoopBeats, timestampToInclusive.IsLooping, beatFromExclusive, timestampToInclusive.Beat);
		}

		public BeatTimestamp ToTimestamp()
		{
			return new BeatTimestamp(LoopBeats, IsLooping, BeatToInclusive);
		}

		public bool ContainsExact(float beat)
		{
			if (BeatFromExclusive < beat)
			{
				return beat <= BeatToInclusive;
			}
			return false;
		}

		public int? GetLastIndex(float[] timeSeries)
		{
			if (IsEmpty() || timeSeries == null || timeSeries.Length == 0)
			{
				return null;
			}
			if (IsWrapped())
			{
				int? lastIndex = new BeatTimeSpan(LoopBeats, isLooping: false, -0.001f, BeatToInclusive).GetLastIndex(timeSeries);
				if (lastIndex.HasValue)
				{
					return lastIndex;
				}
				int num = timeSeries.Length - 1;
				if (timeSeries[num] > BeatFromExclusive)
				{
					return num;
				}
			}
			else
			{
				int num2 = Array.BinarySearch(timeSeries, BeatToInclusive);
				if (num2 > 0 && num2 < timeSeries.Length && timeSeries[num2] > BeatFromExclusive)
				{
					return num2;
				}
				num2 = ~num2;
				num2--;
				if (num2 >= 0 && timeSeries[num2] > BeatFromExclusive && timeSeries[num2] <= BeatToInclusive)
				{
					return num2;
				}
			}
			return null;
		}

		public float Duration()
		{
			return Split().Sum((BeatTimeSpan span) => span.BeatToInclusive - span.BeatFromExclusive);
		}

		public BeatTimeSpan[] Split()
		{
			if (IsEmpty())
			{
				return Array.Empty<BeatTimeSpan>();
			}
			if (!IsWrapped())
			{
				return new BeatTimeSpan[1] { this };
			}
			return new BeatTimeSpan[2]
			{
				new BeatTimeSpan(LoopBeats, isLooping: false, -0.001f, BeatToInclusive),
				new BeatTimeSpan(LoopBeats, isLooping: false, BeatFromExclusive, LoopBeats)
			};
		}

		public bool IsEmpty()
		{
			if (IsLooping)
			{
				float num = BeatToInclusive;
				if (BeatToInclusive < BeatFromExclusive)
				{
					num = BeatToInclusive + (float)LoopBeats;
				}
				return num - BeatFromExclusive > HalfLoopBeats;
			}
			return BeatFromExclusive > BeatToInclusive;
		}

		public bool IsWrapped()
		{
			if (IsLooping && !IsEmpty())
			{
				return BeatToInclusive < BeatFromExclusive;
			}
			return false;
		}

		public override string ToString()
		{
			return string.Format("{0}({1}, {2:N4}..{3:N4}/{4}{5})", "BeatTimeSpan", IsLooping ? 'Y' : 'n', BeatFromExclusive, BeatToInclusive, LoopBeats, IsEmpty() ? " Empty!" : "");
		}

		[CompilerGenerated]
		private bool PrintMembers(StringBuilder builder)
		{
			builder.Append("LoopBeats = ");
			builder.Append(LoopBeats.ToString());
			builder.Append(", HalfLoopBeats = ");
			builder.Append(HalfLoopBeats.ToString());
			builder.Append(", IsLooping = ");
			builder.Append(IsLooping.ToString());
			builder.Append(", BeatFromExclusive = ");
			builder.Append(BeatFromExclusive.ToString());
			builder.Append(", BeatToInclusive = ");
			builder.Append(BeatToInclusive.ToString());
			return true;
		}
	}
	public class BeatTimeState
	{
		private bool hasStarted;

		private bool windUpOffsetIsLooping;

		private bool loopOffsetIsLooping;

		private bool windUpZeroBeatEventTriggered;

		private readonly Track track;

		private float loopOffsetBeat = float.NegativeInfinity;

		private static Random lyricsRandom;

		private int lyricsRandomPerLoop;

		public BeatTimeState(Track track)
		{
			if (lyricsRandom == null)
			{
				lyricsRandom = new Random(RoundManager.Instance.playersManager.randomMapSeed + 1337);
				lyricsRandomPerLoop = lyricsRandom.Next();
			}
			this.track = track;
		}

		public List<BaseEvent> Update(AudioSource start, AudioSource loop)
		{
			hasStarted |= start.time != 0f;
			if (hasStarted)
			{
				BeatTimestamp timestampToInclusive = UpdateStateForLoopOffset(start, loop);
				BeatTimeSpan loopOffsetSpan = BeatTimeSpan.Between(loopOffsetBeat, timestampToInclusive);
				if (!loopOffsetSpan.IsEmpty())
				{
					if (loopOffsetSpan.BeatFromExclusive > loopOffsetSpan.BeatToInclusive)
					{
						lyricsRandomPerLoop = lyricsRandom.Next();
					}
					BeatTimestamp windUpOffsetTimestamp = UpdateStateForWindUpOffset(start, loop);
					loopOffsetBeat = timestampToInclusive.Beat;
					return GetEvents(loopOffsetSpan, windUpOffsetTimestamp);
				}
			}
			return new List<BaseEvent>();
		}

		private BeatTimestamp UpdateStateForLoopOffset(AudioSource start, AudioSource loop)
		{
			float offset = BaseOffset() + track.LoopOffsetInSeconds;
			BeatTimestamp timestampRelativeToGivenOffset = GetTimestampRelativeToGivenOffset(start, loop, offset, loopOffsetIsLooping);
			loopOffsetIsLooping |= timestampRelativeToGivenOffset.IsLooping;
			return timestampRelativeToGivenOffset;
		}

		private BeatTimestamp UpdateStateForWindUpOffset(AudioSource start, AudioSource loop)
		{
			float offset = BaseOffset();
			BeatTimestamp timestampRelativeToGivenOffset = GetTimestampRelativeToGivenOffset(start, loop, offset, windUpOffsetIsLooping);
			windUpOffsetIsLooping |= timestampRelativeToGivenOffset.IsLooping;
			return timestampRelativeToGivenOffset;
		}

		private float BaseOffset()
		{
			return Config.AudioOffset.Value + track.BeatsOffsetInSeconds + track.WindUpTimer;
		}

		private BeatTimestamp GetTimestampRelativeToGivenOffset(AudioSource start, AudioSource loop, float offset, bool isLooping)
		{
			float beat = (((start.isPlaying && start.time != 0f) ? start.time : (track.LoadedStart.length + loop.time)) - offset) / track.LoadedLoop.length * (float)track.Beats;
			return new BeatTimestamp(track.Beats, isLooping, beat);
		}

		private List<BaseEvent> GetEvents(BeatTimeSpan loopOffsetSpan, BeatTimestamp windUpOffsetTimestamp)
		{
			List<BaseEvent> list = new List<BaseEvent>();
			if (windUpOffsetTimestamp.Beat >= 0f && !windUpZeroBeatEventTriggered)
			{
				list.Add(new WindUpZeroBeatEvent());
				windUpZeroBeatEventTriggered = true;
			}
			SetLightsColorEvent colorEvent = GetColorEvent(loopOffsetSpan, windUpOffsetTimestamp);
			if (colorEvent != null)
			{
				list.Add(colorEvent);
			}
			if (loopOffsetSpan.GetLastIndex(track.FlickerLightsTimeSeries).HasValue)
			{
				list.Add(new FlickerLightsEvent());
			}
			if (Config.DisplayLyrics.Value)
			{
				int? lastIndex = loopOffsetSpan.GetLastIndex(track.LyricsTimeSeries);
				if (lastIndex.HasValue)
				{
					int valueOrDefault = lastIndex.GetValueOrDefault();
					if (valueOrDefault < track.LyricsLines.Length)
					{
						string[] array = track.LyricsLines[valueOrDefault].Split('\t');
						int num = lyricsRandomPerLoop % array.Length;
						string text = array[num];
						if (text != "")
						{
							list.Add(new LyricsEvent(text));
						}
					}
				}
			}
			return list;
		}

		private SetLightsColorEvent GetColorEvent(BeatTimeSpan loopOffsetSpan, BeatTimestamp windUpOffsetTimestamp)
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			Color? val = FadeOut(loopOffsetSpan);
			if (val.HasValue)
			{
				Color valueOrDefault = val.GetValueOrDefault();
				return new SetLightsColorEvent(valueOrDefault);
			}
			val = ColorFromPaletteAtTimestamp(windUpOffsetTimestamp);
			if (val.HasValue)
			{
				Color valueOrDefault2 = val.GetValueOrDefault();
				return new SetLightsColorEvent(valueOrDefault2);
			}
			return null;
		}

		private Color? FadeOut(BeatTimeSpan loopOffsetSpan)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			float beatToInclusive = loopOffsetSpan.BeatToInclusive;
			float num = track.FadeOutBeat + track.FadeOutDuration;
			if (track.FadeOutBeat < beatToInclusive && beatToInclusive <= num)
			{
				float arg = (beatToInclusive - track.FadeOutBeat) / track.FadeOutDuration;
				float num2 = Mathf.Clamp(Easing.Linear.Eval(arg), 0f, 1f);
				return Color.Lerp(Color.white, Color.black, num2);
			}
			return null;
		}

		public Color? ColorFromPaletteAtTimestamp(BeatTimestamp timestamp)
		{
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			if (timestamp.Beat <= 0f - track.ColorTransitionIn)
			{
				return null;
			}
			BeatTimestamp beatTimestamp = timestamp.Floor();
			BeatTimestamp beatTimestamp2 = beatTimestamp + 1f;
			float transitionLength = track.ColorTransitionIn + track.ColorTransitionOut;
			if (Config.EnableColorAnimations.Value && (double)transitionLength > 0.01)
			{
				if (BeatTimeSpan.Between(beatTimestamp, timestamp).Duration() < track.ColorTransitionOut)
				{
					return ColorTransition(beatTimestamp);
				}
				if (BeatTimeSpan.Between(timestamp, beatTimestamp2).Duration() < track.ColorTransitionIn)
				{
					return ColorTransition(beatTimestamp2);
				}
			}
			return ColorAtWholeBeat(timestamp);
			Color ColorAtWholeBeat(BeatTimestamp timestamp)
			{
				//IL_002a: 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_0042: Unknown result type (might be due to invalid IL or missing references)
				if (timestamp.Beat >= 0f)
				{
					int index = Mathf.FloorToInt(timestamp.Beat);
					return Mod.Index(track.Palette.Colors, index);
				}
				if (!float.IsNaN(track.FadeOutBeat))
				{
					return Color.white;
				}
				return Color.black;
			}
			Color ColorTransition(BeatTimestamp clipsBoundary)
			{
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				BeatTimestamp beatTimestamp3 = clipsBoundary - track.ColorTransitionIn;
				BeatTimestamp timestamp2 = clipsBoundary + track.ColorTransitionOut;
				float arg = BeatTimeSpan.Between(beatTimestamp3, timestamp).Duration() / transitionLength;
				float num = Mathf.Clamp(track.ColorTransitionEasing.Eval(arg), 0f, 1f);
				if (track.ColorTransitionIn == 0f)
				{
					beatTimestamp3 -= 0.01f;
				}
				return Color.Lerp(ColorAtWholeBeat(beatTimestamp3), ColorAtWholeBeat(timestamp2), num);
			}
		}
	}
	public class BaseEvent
	{
	}
	public class SetLightsColorEvent : BaseEvent
	{
		public readonly Color Color;

		public SetLightsColorEvent(Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			Color = color;
			base..ctor();
		}

		public override string ToString()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return "Color(#" + ColorUtility.ToHtmlStringRGB(Color) + ")";
		}
	}
	public class FlickerLightsEvent : BaseEvent
	{
		public override string ToString()
		{
			return "Flicker";
		}
	}
	public class LyricsEvent : BaseEvent
	{
		public readonly string Text;

		public LyricsEvent(string text)
		{
			Text = text;
			base..ctor();
		}

		public override string ToString()
		{
			return "Lyrics(" + Text.Replace("\n", "\\n") + ")";
		}
	}
	public class WindUpZeroBeatEvent : BaseEvent
	{
		public override string ToString()
		{
			return "WindUp";
		}
	}
	public static class Mod
	{
		public static int Positive(int x, int m)
		{
			int num = x % m;
			if (num >= 0)
			{
				return num;
			}
			return num + m;
		}

		public static float Positive(float x, float m)
		{
			float num = x % m;
			if (!(num < 0f))
			{
				return num;
			}
			return num + m;
		}

		public static T Index<T>(IList<T> array, int index)
		{
			return array[Positive(index, array.Count)];
		}
	}
	public readonly struct RandomWeightedIndex
	{
		private readonly int[] Weights;

		public int TotalWeights { get; }

		public RandomWeightedIndex(int[] weights)
		{
			Weights = weights;
			TotalWeights = Weights.Sum();
			if (TotalWeights == 0)
			{
				Weights = Weights.Select((int _) => 1).ToArray();
				TotalWeights = Weights.Length;
			}
		}

		private byte[] GetHash(int seed)
		{
			byte[] array = new byte[4 * (1 + Weights.Length)];
			int num = 0;
			Buffer.BlockCopy(BitConverter.GetBytes(seed), 0, array, num, 4);
			int[] weights = Weights;
			foreach (int value in weights)
			{
				num += 4;
				Buffer.BlockCopy(BitConverter.GetBytes(value), 0, array, num, 4);
			}
			return SHA256.Create().ComputeHash(array);
		}

		private int GetRawIndex(byte[] hash)
		{
			if (TotalWeights == 0)
			{
				return -1;
			}
			int num = 0;
			foreach (byte b in hash)
			{
				num *= 256 % TotalWeights;
				num %= TotalWeights;
				num += b % TotalWeights;
				num %= TotalWeights;
			}
			return num;
		}

		private int GetWeightedIndex(int rawIndex)
		{
			if (rawIndex < 0 || rawIndex >= TotalWeights)
			{
				return -1;
			}
			int num = 0;
			foreach (var item3 in Weights.Select((int x, int i) => (x, i)))
			{
				int item = item3.Item1;
				int item2 = item3.Item2;
				num += item;
				if (rawIndex < num)
				{
					return item2;
				}
			}
			return -1;
		}

		public int GetRandomWeightedIndex(int seed)
		{
			byte[] hash = GetHash(seed);
			int rawIndex = GetRawIndex(hash);
			return GetWeightedIndex(rawIndex);
		}

		public override string ToString()
		{
			return $"Weighted(Total={TotalWeights}, Weights=[{string.Join(',', Weights)}])";
		}
	}
	public static class SyncedEntryExtensions
	{
		public static void SyncHostToLocal<T>(this SyncedEntry<T> entry)
		{
			entry.Changed += delegate(object sender, SyncedSettingChangedEventArgs<T> args)
			{
				args.ChangedEntry.LocalValue = args.NewValue;
			};
		}
	}
	public class Config : SyncedConfig2<Config>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static CanModifyDelegate <0>__CanModifyWeightsNow;

			public static CanModifyDelegate <1>__CanModifyIfHost;

			public static Func<string, float> <2>__Parse;
		}

		public static ConfigEntry<bool> EnableColorAnimations { get; private set; }

		public static ConfigEntry<bool> DisplayLyrics { get; private set; }

		public static ConfigEntry<float> AudioOffset { get; private set; }

		public static ConfigEntry<bool> SkipExplicitTracks { get; private set; }

		public static bool ShouldSkipWindingPhase { get; private set; }

		public static Palette PaletteOverride { get; private set; }

		public static float? FadeOutBeatOverride { get; private set; }

		public static float? FadeOutDurationOverride { get; private set; }

		public static float[] FlickerLightsTimeSeriesOverride { get; private set; }

		public static float[] LyricsTimeSeriesOverride { get; private set; }

		public static float? BeatsOffsetOverride { get; private set; }

		public static float? ColorTransitionInOverride { get; private set; }

		public static float? ColorTransitionOutOverride { get; private set; }

		public static string ColorTransitionEasingOverride { get; private set; }

		public Config(ConfigFile configFile)
			: base("MuzikaGromche")
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Expected O, but got Unknown
			//IL_024b: Expected O, but got Unknown
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Expected O, but got Unknown
			EnableColorAnimations = configFile.Bind<bool>("General", "Enable Color Animations", true, new ConfigDescription("Smooth light color transitions are known to cause performance issues on some setups.\n\nTurn them off if you experience lag spikes.", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(EnableColorAnimations, false));
			DisplayLyrics = configFile.Bind<bool>("General", "Display Lyrics", true, new ConfigDescription("Display lyrics in the HUD tooltip when you hear the music.", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(DisplayLyrics, false));
			AudioOffset = configFile.Bind<float>("General", "Audio Offset", 0f, new ConfigDescription("Adjust audio offset (in seconds).\n\nIf you are playing with Bluetooth headphones and experiencing a visual desync, try setting this to about negative 0.2.\n\nIf your video output has high latency (like a long HDMI cable etc.), try positive values instead.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 0.5f), Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(AudioOffset, false));
			SkipExplicitTracks = configFile.Bind<bool>("General", "Skip Explicit Tracks", false, new ConfigDescription("When choosing tracks at random, skip the ones with Explicit Content/Lyrics.", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(SkipExplicitTracks, false));
			AcceptableValueRange<int> val = new AcceptableValueRange<int>(0, 100);
			HashSet<Language> hashSet = new HashSet<Language>();
			Track[] tracks = Plugin.Tracks;
			foreach (Track track in tracks)
			{
				Language language = track.Language;
				string text = "Tracks." + language.Short;
				if (!hashSet.Contains(language))
				{
					hashSet.Add(language);
					string text2 = "Toggle all " + language.Full + " tracks";
					string text3 = "Toggle all tracks in this section ON or OFF. Effective immediately.";
					string text4 = "Toggle";
					GenericButtonConfigItem val2 = new GenericButtonConfigItem(text, text2, text3, text4, (GenericButtonHandler)delegate
					{
						//IL_0000: Unknown result type (might be due to invalid IL or missing references)
						if (CanModifyResult.op_Implicit(CanModifyWeightsNow()))
						{
							List<Track> list = Plugin.Tracks.Where((Track t) => t.Language.Equals(language)).ToList();
							int localValue = (list.All((Track t) => t.Weight.LocalValue == 0) ? 50 : 0);
							foreach (Track item in list)
							{
								item.Weight.LocalValue = localValue;
							}
						}
					});
					GenericButtonOptions buttonOptions = val2.ButtonOptions;
					object obj = <>O.<0>__CanModifyWeightsNow;
					if (obj == null)
					{
						CanModifyDelegate val3 = CanModifyWeightsNow;
						<>O.<0>__CanModifyWeightsNow = val3;
						obj = (object)val3;
					}
					((BaseOptions)buttonOptions).CanModifyCallback = (CanModifyDelegate)obj;
					LethalConfigManager.AddConfigItem((BaseConfigItem)val2);
				}
				string text5 = (track.IsExplicit ? "Explicit Content/Lyrics!\n\n" : "");
				string text6 = "Language: " + language.Full + "\n\n" + text5 + "Random (relative) chance of selecting this track.\n\nSet to zero to effectively disable the track.";
				track.Weight = SyncedBindingExtensions.BindSyncedEntry<int>(configFile, new ConfigDefinition(text, track.Name), 50, new ConfigDescription(text6, (AcceptableValueBase)(object)val, new object[1] { track }));
				LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(track.Weight.Entry, Default<IntSliderOptions>(new IntSliderOptions())));
				CSyncHackAddSyncedEntry((SyncedEntryBase)(object)track.Weight);
			}
			ConfigManager.Register<Config>((SyncedConfig2<Config>)this);
		}

		private void CSyncHackAddSyncedEntry(SyncedEntryBase entryBase)
		{
			((IDictionary<(string, SyncedConfigDefinition), SyncedEntryBase>)base.EntryContainer).Add(ConfigEntryExtensions.ToSyncedEntryIdentifier(entryBase.BoxedEntry), entryBase);
		}

		public static CanModifyResult CanModifyIfHost()
		{
			//IL_000e: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return CanModifyResult.True();
			}
			if (!((NetworkBehaviour)instance).IsHost)
			{
				return CanModifyResult.False("Only for host");
			}
			return CanModifyResult.True();
		}

		public static CanModifyResult CanModifyWeightsNow()
		{
			//IL_000e: 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_003a: 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)
			StartOfRound instance = StartOfRound.Instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return CanModifyResult.True();
			}
			if (!((NetworkBehaviour)instance).IsHost)
			{
				return CanModifyResult.False("Only for host");
			}
			if (!instance.inShipPhase)
			{
				return CanModifyResult.False("Only while orbiting");
			}
			return CanModifyResult.True();
		}

		private void SetupEntriesToSkipWinding(ConfigFile configFile)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			SyncedEntry<bool> syncedEntry = SyncedBindingExtensions.BindSyncedEntry<bool>(configFile, "General", "Skip Winding Phase", false, new ConfigDescription("Skip most of the wind-up/intro/start music.\n\nUse this option to test your Loop audio segment.", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(syncedEntry.Entry, Default<BoolCheckBoxOptions>(new BoolCheckBoxOptions())));
			CSyncHackAddSyncedEntry((SyncedEntryBase)(object)syncedEntry);
			syncedEntry.Changed += delegate
			{
				apply();
			};
			syncedEntry.SyncHostToLocal<bool>();
			apply();
			void apply()
			{
				ShouldSkipWindingPhase = syncedEntry.Value;
			}
		}

		private void SetupEntriesForPaletteOverride(ConfigFile configFile)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0069: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//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_005f: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			SyncedEntry<int> customPaletteSizeSyncedEntry = null;
			SyncedEntry<string>[] customPaletteSyncedEntries = new SyncedEntry<string>[8];
			GenericButtonConfigItem val = new GenericButtonConfigItem("Palette", "Load Palette from the Current Track", "Override custom palette with the built-in palette of the current track.", "Load", new GenericButtonHandler(load));
			GenericButtonOptions buttonOptions = val.ButtonOptions;
			object obj = <>O.<1>__CanModifyIfHost;
			if (obj == null)
			{
				CanModifyDelegate val2 = CanModifyIfHost;
				<>O.<1>__CanModifyIfHost = val2;
				obj = (object)val2;
			}
			((BaseOptions)buttonOptions).CanModifyCallback = (CanModifyDelegate)obj;
			LethalConfigManager.AddConfigItem((BaseConfigItem)val);
			customPaletteSizeSyncedEntry = SyncedBindingExtensions.BindSyncedEntry<int>(configFile, "Palette", "Palette Size", 0, new ConfigDescription("Number of colors in the custom palette.\n\nIf set to non-zero, custom palette overrides track's own built-in palette.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(customPaletteSizeSyncedEntry.Entry, Default<IntSliderOptions>(new IntSliderOptions())));
			CSyncHackAddSyncedEntry((SyncedEntryBase)(object)customPaletteSizeSyncedEntry);
			customPaletteSizeSyncedEntry.Changed += delegate
			{
				apply();
			};
			customPaletteSizeSyncedEntry.SyncHostToLocal<int>();
			for (int i = 0; i < 8; i++)
			{
				string text = $"Custom Color {i + 1}";
				SyncedEntry<string> val3 = SyncedBindingExtensions.BindSyncedEntry<string>(configFile, "Palette", text, "#FFFFFF", "Choose color for the custom palette");
				customPaletteSyncedEntries[i] = val3;
				LethalConfigManager.AddConfigItem((BaseConfigItem)new HexColorInputFieldConfigItem(val3.Entry, Default<HexColorInputFieldOptions>(new HexColorInputFieldOptions())));
				CSyncHackAddSyncedEntry((SyncedEntryBase)(object)val3);
				val3.Changed += delegate
				{
					apply();
				};
				val3.SyncHostToLocal<string>();
			}
			apply();
			void apply()
			{
				int value = customPaletteSizeSyncedEntry.Value;
				if (value == 0 || value > 8)
				{
					PaletteOverride = null;
				}
				else
				{
					PaletteOverride = Palette.Parse(customPaletteSyncedEntries.Select((SyncedEntry<string> entry) => entry.Value).Take(value).ToArray());
				}
			}
			void load()
			{
				//IL_004f: 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_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				Color[] colors = (Plugin.CurrentTrack?._Palette ?? Palette.DEFAULT).Colors;
				int num = Math.Min(colors.Count(), 8);
				customPaletteSizeSyncedEntry.LocalValue = colors.Count();
				for (int j = 0; j < 8; j++)
				{
					Color val4 = ((j < num) ? colors[j] : Color.white);
					string localValue = "#" + ColorUtility.ToHtmlStringRGB(val4);
					customPaletteSyncedEntries[j].LocalValue = localValue;
				}
			}
		}

		private void SetupEntriesForTimingsOverride(ConfigFile configFile)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Expected O, but got Unknown
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Expected O, but got Unknown
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Expected O, but got Unknown
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Expected O, but got Unknown
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Expected O, but got Unknown
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Expected O, but got Unknown
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			AcceptableValueRange<float> val = new AcceptableValueRange<float>(0f, 1f);
			List<(Action<Track> Load, Action Apply)> entries = new List<(Action<Track>, Action)>();
			SyncedEntry<bool> overrideTimingsSyncedEntry = null;
			SyncedEntry<float> val2 = null;
			SyncedEntry<float> val3 = null;
			SyncedEntry<string> val4 = null;
			SyncedEntry<string> val5 = null;
			SyncedEntry<float> val6 = null;
			SyncedEntry<float> val7 = null;
			SyncedEntry<float> val8 = null;
			SyncedEntry<string> val9 = null;
			GenericButtonConfigItem val10 = new GenericButtonConfigItem("Timings", "Load Timings from the Current Track", "Override custom timings with the built-in timings of the current track.", "Load", new GenericButtonHandler(load));
			GenericButtonOptions buttonOptions = val10.ButtonOptions;
			object obj = <>O.<1>__CanModifyIfHost;
			if (obj == null)
			{
				CanModifyDelegate val11 = CanModifyIfHost;
				<>O.<1>__CanModifyIfHost = val11;
				obj = (object)val11;
			}
			((BaseOptions)buttonOptions).CanModifyCallback = (CanModifyDelegate)obj;
			LethalConfigManager.AddConfigItem((BaseConfigItem)val10);
			overrideTimingsSyncedEntry = SyncedBindingExtensions.BindSyncedEntry<bool>(configFile, "Timings", "Override Timings", false, new ConfigDescription("If checked, custom timings override track's own built-in timings.", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(overrideTimingsSyncedEntry.Entry, Default<BoolCheckBoxOptions>(new BoolCheckBoxOptions())));
			CSyncHackAddSyncedEntry((SyncedEntryBase)(object)overrideTimingsSyncedEntry);
			overrideTimingsSyncedEntry.Changed += delegate
			{
				apply();
			};
			overrideTimingsSyncedEntry.SyncHostToLocal<bool>();
			val2 = SyncedBindingExtensions.BindSyncedEntry<float>(configFile, "Timings", "Fade Out Beat", 0f, new ConfigDescription("The beat at which to start fading out", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1000f, 0f), Array.Empty<object>()));
			val3 = SyncedBindingExtensions.BindSyncedEntry<float>(configFile, "Timings", "Fade Out Duration", 0f, new ConfigDescription("Duration of fading out", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			val4 = SyncedBindingExtensions.BindSyncedEntry<string>(configFile, "Timings", "Flicker Lights Time Series", "", new ConfigDescription("Time series of beat offsets when to flicker the lights.", (AcceptableValueBase)null, Array.Empty<object>()));
			val5 = SyncedBindingExtensions.BindSyncedEntry<string>(configFile, "Timings", "Lyrics Time Series", "", new ConfigDescription("Time series of beat offsets when to show lyrics lines.", (AcceptableValueBase)null, Array.Empty<object>()));
			val6 = SyncedBindingExtensions.BindSyncedEntry<float>(configFile, "Timings", "Beats Offset", 0f, new ConfigDescription("How much to offset the whole beat. More is later", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 0.5f), Array.Empty<object>()));
			val7 = SyncedBindingExtensions.BindSyncedEntry<float>(configFile, "Timings", "Color Transition In", 0.25f, new ConfigDescription("Fraction of a beat *before* the whole beat when the color transition should start.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			val8 = SyncedBindingExtensions.BindSyncedEntry<float>(configFile, "Timings", "Color Transition Out", 0.25f, new ConfigDescription("Fraction of a beat *after* the whole beat when the color transition should end.", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			val9 = SyncedBindingExtensions.BindSyncedEntry<string>(configFile, "Timings", "Color Transition Easing", Easing.Linear.Name, new ConfigDescription("Interpolation/easing method to use for color transitions", (AcceptableValueBase)(object)new AcceptableValueList<string>(Easing.AllNames), Array.Empty<object>()));
			FloatSliderOptions val12 = Default<FloatSliderOptions>(new FloatSliderOptions());
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val2.Entry, val12));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val3.Entry, val12));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val4.Entry, Default<TextInputFieldOptions>(new TextInputFieldOptions())));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val5.Entry, Default<TextInputFieldOptions>(new TextInputFieldOptions())));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val6.Entry, val12));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val7.Entry, val12));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val8.Entry, val12));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val9.Entry, Default<TextDropDownOptions>(new TextDropDownOptions(Array.Empty<string>()))));
			registerStruct<float>(val2, (Track t) => t._FadeOutBeat, delegate(float? x)
			{
				FadeOutBeatOverride = x;
			});
			registerStruct<float>(val3, (Track t) => t._FadeOutDuration, delegate(float? x)
			{
				FadeOutDurationOverride = x;
			});
			registerArray<float>(val4, (Track t) => t._FlickerLightsTimeSeries, delegate(float[] xs)
			{
				FlickerLightsTimeSeriesOverride = xs;
			}, float.Parse, sort: true);
			registerArray<float>(val5, (Track t) => t._LyricsTimeSeries, delegate(float[] xs)
			{
				LyricsTimeSeriesOverride = xs;
			}, float.Parse, sort: true);
			registerStruct<float>(val6, (Track t) => t._BeatsOffset, delegate(float? x)
			{
				BeatsOffsetOverride = x;
			});
			registerStruct<float>(val7, (Track t) => t._ColorTransitionIn, delegate(float? x)
			{
				ColorTransitionInOverride = x;
			});
			registerStruct<float>(val8, (Track t) => t._ColorTransitionOut, delegate(float? x)
			{
				ColorTransitionOutOverride = x;
			});
			registerClass<string>(val9, (Track t) => t._ColorTransitionEasing.Name, delegate(string x)
			{
				ColorTransitionEasingOverride = x;
			});
			void apply()
			{
				foreach (var item in entries)
				{
					item.Apply();
				}
			}
			void load()
			{
				Track currentTrack = Plugin.CurrentTrack;
				foreach (var item2 in entries)
				{
					item2.Load(currentTrack);
				}
			}
			static T[] parseStringArray<T>(string str, Func<string, T> parser, bool sort = false) where T : struct
			{
				try
				{
					T[] array = str.Replace(" ", "").Split(",").Select(parser)
						.ToArray();
					Array.Sort(array);
					return array;
				}
				catch (Exception arg)
				{
					Debug.Log((object)string.Format("{0} Unable to parse array: {1}", "MuzikaGromche", arg));
					return null;
				}
			}
			void register<T>(SyncedEntry<T> syncedEntry, Func<Track, T> getter, Action applier)
			{
				CSyncHackAddSyncedEntry((SyncedEntryBase)(object)syncedEntry);
				syncedEntry.SyncHostToLocal<T>();
				syncedEntry.Changed += delegate
				{
					applier();
				};
				entries.Add((loader, applier));
				void loader(Track track)
				{
					syncedEntry.LocalValue = ((track == null) ? ((T)((ConfigEntryBase)syncedEntry.Entry).DefaultValue) : getter(track));
				}
			}
			void registerArray<T>(SyncedEntry<string> syncedEntry, Func<Track, T[]> getter, Action<T[]> setter, Func<string, T> parser, bool sort = false) where T : struct
			{
				register<string>(syncedEntry, (Track track) => string.Join(", ", getter(track)), delegate
				{
					T[] array2 = parseStringArray<T>(syncedEntry.Value, parser, sort);
					if (array2 != null)
					{
						syncedEntry.LocalValue = string.Join(", ", array2);
					}
					setter(overrideTimingsSyncedEntry.Value ? array2 : null);
				});
			}
			void registerClass<T>(SyncedEntry<T> syncedEntry, Func<Track, T> getter, Action<T> setter) where T : class
			{
				register<T>(syncedEntry, getter, delegate
				{
					setter(overrideTimingsSyncedEntry.Value ? syncedEntry.Value : null);
				});
			}
			void registerStruct<T>(SyncedEntry<T> syncedEntry, Func<Track, T> getter, Action<T?> setter) where T : struct
			{
				register<T>(syncedEntry, getter, delegate
				{
					setter(overrideTimingsSyncedEntry.Value ? new T?(syncedEntry.Value) : null);
				});
			}
		}

		private T Default<T>(T options) where T : BaseOptions
		{
			//IL_0022: 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_002d: Expected O, but got Unknown
			((BaseOptions)options).RequiresRestart = false;
			object obj = options;
			object obj2 = <>O.<1>__CanModifyIfHost;
			if (obj2 == null)
			{
				CanModifyDelegate val = CanModifyIfHost;
				<>O.<1>__CanModifyIfHost = val;
				obj2 = (object)val;
			}
			((BaseOptions)obj).CanModifyCallback = (CanModifyDelegate)obj2;
			return options;
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	internal class JesterPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void DoNotStopTheMusicPrefix(JesterAI __instance, out State __state)
		{
			__state = new State
			{
				farAudio = __instance.farAudio,
				previousState = __instance.previousState
			};
			if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && __instance.previousState != 2)
			{
				__instance.farAudio = ((EnemyAI)__instance).creatureVoice;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void DoNotStopTheMusic(JesterAI __instance, State __state)
		{
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.previousState == 1 && __state.previousState != 1)
			{
				__instance.farAudio.Stop();
				((EnemyAI)__instance).creatureVoice.Stop();
				Plugin.CurrentTrack = Plugin.ChooseTrack();
				Plugin.BeatTimeState = new BeatTimeState(Plugin.CurrentTrack);
				__instance.popUpTimer = Plugin.CurrentTrack.WindUpTimer;
				__instance.farAudio.maxDistance = 150f;
				__instance.farAudio.clip = Plugin.CurrentTrack.LoadedStart;
				__instance.farAudio.loop = false;
				if (Config.ShouldSkipWindingPhase)
				{
					float num = (__instance.popUpTimer = 5f);
					__instance.farAudio.time = Plugin.CurrentTrack.WindUpTimer - num;
				}
				else
				{
					__instance.farAudio.time = 0f;
				}
				__instance.farAudio.Play();
				Debug.Log((object)$"Playing start music: maxDistance: {__instance.farAudio.maxDistance}, minDistance: {__instance.farAudio.minDistance}, volume: {__instance.farAudio.volume}, spread: {__instance.farAudio.spread}");
			}
			if (__instance.previousState != 2 && __state.previousState == 2)
			{
				Plugin.ResetLightColor();
				DiscoBallManager.Disable();
			}
			if (__instance.previousState == 2 && __state.previousState != 2)
			{
				__instance.farAudio = __state.farAudio;
				float time = __instance.farAudio.time;
				float num2 = Plugin.CurrentTrack.LoadedStart.length - time;
				((EnemyAI)__instance).creatureVoice.Stop();
				((EnemyAI)__instance).creatureVoice.maxDistance = 150f;
				((EnemyAI)__instance).creatureVoice.clip = Plugin.CurrentTrack.LoadedLoop;
				((EnemyAI)__instance).creatureVoice.PlayDelayed(num2);
				Debug.Log((object)$"Start length: {Plugin.CurrentTrack.LoadedStart.length}; played time: {time}");
				Debug.Log((object)$"Playing loop music: maxDistance: {((EnemyAI)__instance).creatureVoice.maxDistance}, minDistance: {((EnemyAI)__instance).creatureVoice.minDistance}, volume: {((EnemyAI)__instance).creatureVoice.volume}, spread: {((EnemyAI)__instance).creatureVoice.spread}, in seconds: {num2}");
			}
			if (__instance.previousState != 1 && __instance.previousState != 2)
			{
				return;
			}
			foreach (BaseEvent item in Plugin.BeatTimeState.Update(__instance.farAudio, ((EnemyAI)__instance).creatureVoice))
			{
				if (!(item is WindUpZeroBeatEvent))
				{
					if (!(item is SetLightsColorEvent setLightsColorEvent))
					{
						if (!(item is FlickerLightsEvent))
						{
							if (item is LyricsEvent lyricsEvent && Plugin.LocalPlayerCanHearMusic((EnemyAI)(object)__instance))
							{
								HUDManager.Instance.DisplayTip("[Lyrics]", lyricsEvent.Text, false, false, "LC_Tip1");
								HUDManager.Instance.UIAudio.Stop();
							}
						}
						else
						{
							RoundManager.Instance.FlickerLights(true, false);
						}
					}
					else
					{
						Plugin.SetLightColor(setLightsColorEvent.Color);
					}
				}
				else
				{
					DiscoBallManager.Enable();
				}
			}
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatch
	{
		[HarmonyPatch("OnDestroy")]
		[HarmonyPrefix]
		public static void CleanUpOnDestroy(EnemyAI __instance)
		{
			if (__instance is JesterAI)
			{
				Plugin.ResetLightColor();
				DiscoBallManager.Disable();
			}
		}
	}
	internal class State
	{
		public AudioSource farAudio;

		public int previousState;
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MuzikaGromche";

		public const string PLUGIN_NAME = "MuzikaGromche";

		public const string PLUGIN_VERSION = "13.37.911";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}