Decompiled source of Fireworks for P rank v1.0.0

fireworksforpranks.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("fireworksforpranks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Fireworks for P ranks")]
[assembly: AssemblyTitle("fireworksforpranks")]
[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 fireworksforpranks
{
	[BepInPlugin("com.yourname.pluginname", "Fireworks for P ranks", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static class ModConfig
		{
			public enum SpawnRanks
			{
				D,
				C,
				B,
				A,
				S,
				P
			}

			public enum FireworkMode
			{
				None,
				Randomcolors,
				TwoColored
			}

			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static BoolValueChangeEventDelegate <>9__37_0;

				internal void <Init>b__37_0(BoolValueChangeEvent e)
				{
					((ConfigField)MusicVolume).interactable = e.value;
					((ConfigField)EnableLoop).interactable = e.value;
				}
			}

			public static PluginConfigurator config;

			public static FloatField FireworkSpawnDelay;

			public static FloatField FireworkSimulationSpeed;

			public static FloatField FireworkSize;

			public static ColorField FireworkColorField;

			public static FloatField FireworkTransparency;

			public static EnumField<SpawnRanks> SpawnRankField;

			public static EnumField<FireworkMode> FireworkSpecialMode;

			public static IntField FireworkVolume;

			public static BoolField EnableSecondaryColors;

			public static FloatField FireworkSecColorPos;

			public static ColorField FireworkSecColorField;

			public static FloatField FireworkSecTransparency;

			public static BoolField ThirdColorButton;

			public static FloatField FireworkThirdColorPos;

			public static ColorField FireworkThirdColorField;

			public static FloatField FireworkThirdTransparency;

			public static BoolField ForthColorButton;

			public static FloatField FireworkForthColorPos;

			public static ColorField FireworkForthColorField;

			public static FloatField FireworkForthTransparency;

			public static BoolField FifthColorButton;

			public static FloatField FireworkFifthColorPos;

			public static ColorField FireworkFifthColorField;

			public static FloatField FireworkFifthTransparency;

			public static BoolField EnableMusic;

			public static IntField MusicVolume;

			public static BoolField EnableLoop;

			public static FloatField Mode1Transparency;

			public static FloatField Mode2TransparencyF1;

			public static FloatField Mode2TransparencyF2;

			public static ColorField Mode2ColorFieldF1;

			public static ColorField Mode2ColorFieldF2;

			private static string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

			public static bool IsRankValid(string rankText, SpawnRanks selectedRank)
			{
				string value = Regex.Replace(rankText, "<[^>]*>", "").Trim();
				if (!Enum.TryParse<SpawnRanks>(value, out var result))
				{
					return false;
				}
				int num = (int)result;
				return num >= (int)selectedRank;
			}

			public static void Init()
			{
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Expected O, but got Unknown
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Expected O, but got Unknown
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: Expected O, but got Unknown
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Expected O, but got Unknown
				//IL_013e: 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_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0200: Unknown result type (might be due to invalid IL or missing references)
				//IL_021c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0221: Unknown result type (might be due to invalid IL or missing references)
				//IL_023d: 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_0262: Unknown result type (might be due to invalid IL or missing references)
				//IL_026c: Expected O, but got Unknown
				//IL_0285: Unknown result type (might be due to invalid IL or missing references)
				//IL_028f: Expected O, but got Unknown
				//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ae: Expected O, but got Unknown
				//IL_0313: Unknown result type (might be due to invalid IL or missing references)
				//IL_0318: Unknown result type (might be due to invalid IL or missing references)
				//IL_0398: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a2: Expected O, but got Unknown
				//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fc: Expected O, but got Unknown
				//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03eb: Expected O, but got Unknown
				//IL_043d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0442: Unknown result type (might be due to invalid IL or missing references)
				//IL_044c: Expected O, but got Unknown
				//IL_046b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0475: Expected O, but got Unknown
				//IL_0494: Unknown result type (might be due to invalid IL or missing references)
				//IL_0499: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a3: Expected O, but got Unknown
				//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04cc: Expected O, but got Unknown
				//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e6: Expected O, but got Unknown
				//IL_0526: Unknown result type (might be due to invalid IL or missing references)
				//IL_054b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0550: Unknown result type (might be due to invalid IL or missing references)
				//IL_055a: Expected O, but got Unknown
				//IL_0579: Unknown result type (might be due to invalid IL or missing references)
				//IL_0583: Expected O, but got Unknown
				//IL_0590: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b1: Expected O, but got Unknown
				//IL_05be: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_05da: Unknown result type (might be due to invalid IL or missing references)
				//IL_05e4: Expected O, but got Unknown
				//IL_060a: Unknown result type (might be due to invalid IL or missing references)
				//IL_062f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0634: Unknown result type (might be due to invalid IL or missing references)
				//IL_063e: Expected O, but got Unknown
				//IL_065d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0667: Expected O, but got Unknown
				//IL_0686: Unknown result type (might be due to invalid IL or missing references)
				//IL_0690: Expected O, but got Unknown
				//IL_069d: Unknown result type (might be due to invalid IL or missing references)
				//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_06be: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c8: Expected O, but got Unknown
				//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_06de: Expected O, but got Unknown
				//IL_0704: Unknown result type (might be due to invalid IL or missing references)
				//IL_0729: Unknown result type (might be due to invalid IL or missing references)
				//IL_072e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0738: Expected O, but got Unknown
				//IL_0757: Unknown result type (might be due to invalid IL or missing references)
				//IL_0761: Expected O, but got Unknown
				//IL_0780: Unknown result type (might be due to invalid IL or missing references)
				//IL_078a: Expected O, but got Unknown
				//IL_0797: Unknown result type (might be due to invalid IL or missing references)
				//IL_079c: Unknown result type (might be due to invalid IL or missing references)
				//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c2: Expected O, but got Unknown
				//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_07d8: Expected O, but got Unknown
				//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0823: Unknown result type (might be due to invalid IL or missing references)
				//IL_0828: Unknown result type (might be due to invalid IL or missing references)
				//IL_0832: Expected O, but got Unknown
				//IL_0851: Unknown result type (might be due to invalid IL or missing references)
				//IL_085b: Expected O, but got Unknown
				//IL_087a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0884: Expected O, but got Unknown
				//IL_0891: Unknown result type (might be due to invalid IL or missing references)
				//IL_0896: Unknown result type (might be due to invalid IL or missing references)
				//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_08bc: Expected O, but got Unknown
				//IL_08c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_08d2: Expected O, but got Unknown
				//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_091d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0922: Unknown result type (might be due to invalid IL or missing references)
				//IL_092c: Expected O, but got Unknown
				//IL_094b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0955: Expected O, but got Unknown
				//IL_0974: Unknown result type (might be due to invalid IL or missing references)
				//IL_097e: Expected O, but got Unknown
				//IL_098a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0994: Expected O, but got Unknown
				//IL_09a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_09ab: Expected O, but got Unknown
				//IL_09b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_09c2: Expected O, but got Unknown
				//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_09d9: Expected O, but got Unknown
				config = PluginConfigurator.Create("Fireworks for P Rank ", "ffpr");
				string text = Path.Combine(directory, "icon.png");
				if (File.Exists(text))
				{
					config.SetIconWithURL("file://" + text);
				}
				new ConfigHeader(config.rootPanel, "Fireworks for P Rank Settings", 30).textColor = Color.yellow;
				new ConfigHeader(config.rootPanel, "Fireworks appear settings", 20);
				FireworkSpawnDelay = new FloatField(config.rootPanel, "Spawn delay(seconds)", "Spawn Delay", 1f, 0.1f, 999f);
				FireworkSimulationSpeed = new FloatField(config.rootPanel, "Firework speed", "Firework speed", 1f, 0.1f, 100f);
				FireworkSize = new FloatField(config.rootPanel, "Firework size", "firework size", 75f, 50f, 100f);
				FireworkVolume = new IntField(config.rootPanel, "Volume", "volume", 100, 0, 100);
				new ConfigHeader(config.rootPanel, "Fireworks spawn settings", 20);
				new ConfigHeader(config.rootPanel, "Min rank required for fireworks to appear", 15).textColor = Color.gray;
				SpawnRankField = new EnumField<SpawnRanks>(config.rootPanel, "Rank check", "rankcheck", SpawnRanks.P);
				SpawnRankField.SetEnumDisplayName(SpawnRanks.P, "P rank");
				SpawnRankField.SetEnumDisplayName(SpawnRanks.S, "S rank");
				SpawnRankField.SetEnumDisplayName(SpawnRanks.A, "A rank");
				SpawnRankField.SetEnumDisplayName(SpawnRanks.B, "B rank");
				SpawnRankField.SetEnumDisplayName(SpawnRanks.C, "C rank");
				SpawnRankField.SetEnumDisplayName(SpawnRanks.D, "D rank");
				new ConfigHeader(config.rootPanel, "P rank Music", 24).textColor = Color.yellow;
				new ConfigHeader(config.rootPanel, "Music to be played during the fireworks", 15).textColor = Color.gray;
				new ConfigHeader(config.rootPanel, "Place your own .wav/.mp3/.ogg file  in the mod folder to replace the music", 15).textColor = Color.gray;
				EnableMusic = new BoolField(config.rootPanel, "Music enabled?", "music enabled?", false);
				MusicVolume = new IntField(config.rootPanel, "Volume", "MusicVolume", 100, 0, 100);
				EnableLoop = new BoolField(config.rootPanel, "Enable loop", "enableloop", false);
				((ConfigField)MusicVolume).interactable = EnableMusic.value;
				((ConfigField)EnableLoop).interactable = EnableMusic.value;
				BoolField enableMusic = EnableMusic;
				object obj = <>c.<>9__37_0;
				if (obj == null)
				{
					BoolValueChangeEventDelegate val = delegate(BoolValueChangeEvent e)
					{
						((ConfigField)MusicVolume).interactable = e.value;
						((ConfigField)EnableLoop).interactable = e.value;
					};
					<>c.<>9__37_0 = val;
					obj = (object)val;
				}
				enableMusic.onValueChange += (BoolValueChangeEventDelegate)obj;
				new ConfigHeader(config.rootPanel, "Fireworks color settings", 24).textColor = Color.yellow;
				FireworkSpecialMode = new EnumField<FireworkMode>(config.rootPanel, "Firework special mode", "fireworkspecialmode", FireworkMode.None);
				FireworkSpecialMode.SetEnumDisplayName(FireworkMode.None, "None");
				FireworkSpecialMode.SetEnumDisplayName(FireworkMode.Randomcolors, "Random colors");
				FireworkSpecialMode.SetEnumDisplayName(FireworkMode.TwoColored, "Two colored");
				Mode1Transparency = new FloatField(config.rootPanel, "Opacity", "Mode1Opacity", 0f, 0f, 1f);
				if (FireworkSpecialMode.value == FireworkMode.Randomcolors)
				{
					((ConfigField)Mode1Transparency).hidden = false;
				}
				else
				{
					((ConfigField)Mode1Transparency).hidden = true;
				}
				ConfigDivision Mode2Section = new ConfigDivision(config.rootPanel, "mode2_panel");
				if (FireworkSpecialMode.value == FireworkMode.TwoColored)
				{
					((ConfigField)Mode2Section).hidden = false;
				}
				else
				{
					((ConfigField)Mode2Section).hidden = true;
				}
				Mode2ColorFieldF1 = new ColorField((ConfigPanel)(object)Mode2Section, "Color 1", "mode2color1", new Color(1f, 1f, 1f));
				Mode2TransparencyF1 = new FloatField((ConfigPanel)(object)Mode2Section, "Opacity 1", "mode2opacity1", 0f, 0f, 1f);
				Mode2ColorFieldF2 = new ColorField((ConfigPanel)(object)Mode2Section, "Color 2", "mode2color2", new Color(1f, 1f, 1f));
				Mode2TransparencyF2 = new FloatField((ConfigPanel)(object)Mode2Section, "Opacity 2", "mode2opacity2", 0f, 0f, 1f);
				ConfigDivision mainColorSection = new ConfigDivision(config.rootPanel, "main_color_panel");
				if (FireworkSpecialMode.value != FireworkMode.None)
				{
					((ConfigField)mainColorSection).interactable = false;
				}
				else
				{
					((ConfigField)mainColorSection).interactable = true;
				}
				new ConfigHeader((ConfigPanel)(object)mainColorSection, "Main color settings", 22);
				FireworkColorField = new ColorField((ConfigPanel)(object)mainColorSection, "Color", "fireworkscolor", new Color(1f, 1f, 1f));
				FireworkTransparency = new FloatField((ConfigPanel)(object)mainColorSection, "Opacity", "fireworkstrans", 0f, 0f, 1f);
				new ConfigHeader((ConfigPanel)(object)mainColorSection, "Secondary colors settings", 22);
				EnableSecondaryColors = new BoolField((ConfigPanel)(object)mainColorSection, "Secondary colors enabled?", "Secondary colors enabled?", false);
				new ConfigHeader((ConfigPanel)(object)mainColorSection, "----------------------------------------------", 20).textColor = Color.gray;
				ConfigDivision secColorSection = new ConfigDivision((ConfigPanel)(object)mainColorSection, "second_color_panel");
				((ConfigField)secColorSection).hidden = !EnableSecondaryColors.value;
				new ConfigHeader((ConfigPanel)(object)secColorSection, "Сolor 2 settings", 20);
				FireworkSecColorField = new ColorField((ConfigPanel)(object)secColorSection, "Сolor 2", "fireworksseccolor", new Color(1f, 1f, 1f));
				FireworkSecTransparency = new FloatField((ConfigPanel)(object)secColorSection, "Opacity 2", "fireworkssectrans", 0f, 0f, 1f);
				FireworkSecColorPos = new FloatField((ConfigPanel)(object)secColorSection, "Color 2 position (0 = start, 1 = end)", "fireworksseccolorpos", 1f, 0f, 1f);
				new ConfigHeader((ConfigPanel)(object)secColorSection, "----------------------------------------------", 20).textColor = Color.gray;
				ThirdColorButton = new BoolField((ConfigPanel)(object)secColorSection, "Сolor 3 enabled?", "3colorenabled", false);
				ConfigDivision thirdColorSection = new ConfigDivision((ConfigPanel)(object)secColorSection, "third_color_panel");
				((ConfigField)thirdColorSection).hidden = !ThirdColorButton.value;
				new ConfigHeader((ConfigPanel)(object)thirdColorSection, "Сolor 3 settings", 20);
				FireworkThirdColorField = new ColorField((ConfigPanel)(object)thirdColorSection, "Color 3", "fireworksthirdcolor", new Color(1f, 1f, 1f));
				FireworkThirdTransparency = new FloatField((ConfigPanel)(object)thirdColorSection, "Opacity 3", "fireworksthirdtrans", 0f, 0f, 1f);
				FireworkThirdColorPos = new FloatField((ConfigPanel)(object)thirdColorSection, "Color 3 position (0 = start, 1 = end)", "fireworksthirdcolorpos", 0.75f, 0f, 1f);
				new ConfigHeader((ConfigPanel)(object)thirdColorSection, "----------------------------------------------", 20).textColor = Color.gray;
				ForthColorButton = new BoolField((ConfigPanel)(object)thirdColorSection, "Сolor 4 enabled?", "4colorenabled", false);
				ConfigDivision forthColorSection = new ConfigDivision((ConfigPanel)(object)thirdColorSection, "forth_color_panel");
				((ConfigField)forthColorSection).hidden = !ForthColorButton.value;
				new ConfigHeader((ConfigPanel)(object)forthColorSection, "Сolor 4 settings", 20);
				FireworkForthColorField = new ColorField((ConfigPanel)(object)forthColorSection, "Color 4", "fireworksforthcolor", new Color(1f, 1f, 1f));
				FireworkForthTransparency = new FloatField((ConfigPanel)(object)forthColorSection, "Opacity 4", "fireworksforthtrans", 0f, 0f, 1f);
				FireworkForthColorPos = new FloatField((ConfigPanel)(object)forthColorSection, "Color 4 position (0 = start, 1 = end)", "fireworksforthcolorpos", 0.5f, 0f, 1f);
				new ConfigHeader((ConfigPanel)(object)forthColorSection, "----------------------------------------------", 20).textColor = Color.gray;
				FifthColorButton = new BoolField((ConfigPanel)(object)forthColorSection, "Сolor 5 enabled?", "5colorenabled", false);
				ConfigDivision fifthColorSection = new ConfigDivision((ConfigPanel)(object)forthColorSection, "fifth_color_panel");
				((ConfigField)fifthColorSection).hidden = !FifthColorButton.value;
				new ConfigHeader((ConfigPanel)(object)fifthColorSection, "Сolor 5 settings", 20);
				FireworkFifthColorField = new ColorField((ConfigPanel)(object)fifthColorSection, "Color 5", "fireworksfifthcolor", new Color(1f, 1f, 1f));
				FireworkFifthTransparency = new FloatField((ConfigPanel)(object)fifthColorSection, "Opacity 5", "fireworksfifthtrans", 0f, 0f, 1f);
				FireworkFifthColorPos = new FloatField((ConfigPanel)(object)fifthColorSection, "Color 5 position (0 = start, 1 = end)", "fireworksfifthcolorpos", 0.25f, 0f, 1f);
				EnableSecondaryColors.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
				{
					((ConfigField)secColorSection).hidden = !e.value;
					if (!EnableSecondaryColors.value)
					{
						ThirdColorButton.value = !e.value;
						((ConfigField)thirdColorSection).hidden = true;
					}
				};
				ThirdColorButton.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
				{
					((ConfigField)thirdColorSection).hidden = !e.value;
					if (!ThirdColorButton.value)
					{
						ForthColorButton.value = !e.value;
						((ConfigField)forthColorSection).hidden = true;
					}
				};
				ForthColorButton.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
				{
					((ConfigField)forthColorSection).hidden = !e.value;
					if (!ForthColorButton.value)
					{
						FifthColorButton.value = !e.value;
						((ConfigField)fifthColorSection).hidden = true;
					}
				};
				FifthColorButton.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
				{
					((ConfigField)fifthColorSection).hidden = !e.value;
				};
				FireworkSpecialMode.onValueChange += delegate(EnumValueChangeEvent<FireworkMode> e)
				{
					if (e.value != FireworkMode.None)
					{
						((ConfigField)mainColorSection).interactable = false;
					}
					else
					{
						((ConfigField)mainColorSection).interactable = true;
					}
					if (e.value == FireworkMode.Randomcolors)
					{
						((ConfigField)Mode1Transparency).hidden = false;
					}
					else
					{
						((ConfigField)Mode1Transparency).hidden = true;
					}
					if (e.value == FireworkMode.TwoColored)
					{
						((ConfigField)Mode2Section).hidden = false;
					}
					else
					{
						((ConfigField)Mode2Section).hidden = true;
					}
				};
			}
		}

		[HarmonyPatch(typeof(FinalRank), "SetRank")]
		public class LoadFireworks
		{
			[HarmonyPrefix]
			private static void Prefix(FinalRank __instance, string rank)
			{
				if (ModConfig.IsRankValid(rank, ModConfig.SpawnRankField.value))
				{
					Logger.LogInfo((object)"Fireworks!");
					Camera main = Camera.main;
					if (ModConfig.EnableMusic.value)
					{
						PlayMusic(ModConfig.MusicVolume.value);
					}
					((MonoBehaviour)__instance).StartCoroutine(SpawnFireworksWithDelay());
				}
			}
		}

		private static GameObject fireworksPrefab;

		private static AudioClip[] sounds;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin com.yourname.pluginname is loaded!");
			Logger.LogInfo((object)"Mod started");
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)4;
			ModConfig.Init();
			LoadFireworksPrefab();
			LoadSounds();
			Harmony val = new Harmony("com.yourname.fireworksforprank");
			val.PatchAll(typeof(LoadFireworks));
		}

		private void LoadFireworksPrefab()
		{
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "fireworks.bundle");
			if (File.Exists(text))
			{
				Logger.LogInfo((object)"File was found!");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				if ((Object)(object)val == (Object)null)
				{
					Logger.LogError((object)"Prefab load error!");
					return;
				}
				fireworksPrefab = val.LoadAsset<GameObject>("Fireworks");
				if ((Object)(object)fireworksPrefab == (Object)null)
				{
					Logger.LogError((object)"Prefab was not found!");
				}
				else
				{
					Logger.LogInfo((object)"Prefab loaded");
				}
			}
			else
			{
				Logger.LogError((object)("File was not found: " + text));
			}
		}

		private void LoadSounds()
		{
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string path = Path.Combine(directoryName, "music");
			if (!Directory.Exists(path))
			{
				Directory.CreateDirectory(path);
			}
			string[] array = Directory.GetFiles(path, "*.wav").Concat(Directory.GetFiles(path, "*.mp3")).Concat(Directory.GetFiles(path, "*.ogg"))
				.ToArray();
			if (array.Length != 0)
			{
				sounds = (AudioClip[])(object)new AudioClip[array.Length];
				for (int i = 0; i < array.Length; i++)
				{
					((MonoBehaviour)this).StartCoroutine(LoadClip(array[i], i));
				}
			}
		}

		private IEnumerator LoadClip(string path, int i)
		{
			string ext = Path.GetExtension(path).ToLower();
			AudioType audioType = (AudioType)((ext == ".mp3") ? 13 : ((ext == ".ogg") ? 14 : 20));
			UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file://" + path, audioType);
			try
			{
				yield return req.SendWebRequest();
				sounds[i] = DownloadHandlerAudioClip.GetContent(req);
			}
			finally
			{
				((IDisposable)req)?.Dispose();
			}
		}

		private static IEnumerator SpawnFireworksWithDelay()
		{
			int iColor = 0;
			while (true)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "Main Menu")
				{
					break;
				}
				SpawnFireworks(ref iColor);
				FloatField fireworkSpawnDelay = ModConfig.FireworkSpawnDelay;
				yield return (object)new WaitForSeconds((fireworkSpawnDelay != null) ? fireworkSpawnDelay.value : 1f);
			}
		}

		public static void SetLayerRecursively(GameObject obj, int newLayer)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if ((Object)(object)obj == (Object)null)
			{
				return;
			}
			obj.layer = newLayer;
			foreach (Transform item in obj.transform)
			{
				Transform val = item;
				SetLayerRecursively(((Component)val).gameObject, newLayer);
			}
		}

		public static IEnumerator RainbowColorVar2(GameObject fireworks)
		{
			while (true)
			{
				Color randomColorV2 = Color.HSVToRGB(Random.Range(0f, 1f), 0.4f, 0.9f);
				ParticleSystem ps = fireworks.GetComponent<ParticleSystem>();
				MainModule main = ps.main;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(randomColorV2);
				yield return (object)new WaitForSeconds(0.3f);
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "Main Menu")
				{
					break;
				}
				main = default(MainModule);
			}
		}

		private static void PlayMusic(int volume)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Canvas val = Object.FindObjectOfType<Canvas>();
			GameObject val2 = new GameObject("FinalRankMusic");
			val2.transform.SetParent(((Component)val).transform, false);
			AudioSource val3 = val2.AddComponent<AudioSource>();
			int num = Random.Range(0, sounds.Length);
			val3.clip = sounds[num];
			val3.spatialBlend = 0f;
			val3.volume = (float)volume / 100f;
			if (ModConfig.EnableMusic.value)
			{
				val3.loop = true;
			}
			val3.Play();
		}

		private static void SpawnFireworks(ref int iColor)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_069e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_014a: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_088f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_0801: Unknown result type (might be due to invalid IL or missing references)
			//IL_0806: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: 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_0210: 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_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: 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_0264: 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_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: 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_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: 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_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_075a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0767: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_0790: Unknown result type (might be due to invalid IL or missing references)
			//IL_0792: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_071f: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_073c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: 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_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: 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_03c1: 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_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: 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_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fireworksPrefab == (Object)null)
			{
				Logger.LogError((object)"preafab load fail");
				return;
			}
			GameObject val = GameObject.Find("Player");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"plr not found");
				return;
			}
			Camera main = Camera.main;
			GameObject val2 = Object.Instantiate<GameObject>(fireworksPrefab, ((Component)main).transform);
			float num = 45f - ModConfig.FireworkSize.value * 0.4f;
			val2.transform.localPosition = new Vector3(0f, -20f, num);
			val2.transform.localRotation = Quaternion.identity;
			SetLayerRecursively(val2, 13);
			AudioSource[] components = val2.GetComponents<AudioSource>();
			ParticleSystem component = val2.GetComponent<ParticleSystem>();
			if ((Object)(object)component != (Object)null)
			{
				MainModule main2 = component.main;
				((Component)component).transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
				((MainModule)(ref main2)).simulationSpeed = ModConfig.FireworkSimulationSpeed.value;
				MinMaxGradient startColor;
				if (ModConfig.FireworkSpecialMode.value == ModConfig.FireworkMode.None)
				{
					if (!ModConfig.EnableSecondaryColors.value)
					{
						((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(ModConfig.FireworkColorField.value);
						startColor = ((MainModule)(ref main2)).startColor;
						Color color = ((MinMaxGradient)(ref startColor)).color;
						color.a = 1f - ModConfig.FireworkTransparency.value;
						((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(color);
					}
					else
					{
						ColorOverLifetimeModule colorOverLifetime = component.colorOverLifetime;
						((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
						Gradient val3 = new Gradient();
						if (ModConfig.FifthColorButton.value)
						{
							val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[5]
							{
								new GradientColorKey(ModConfig.FireworkColorField.value, 0f),
								new GradientColorKey(ModConfig.FireworkSecColorField.value, ModConfig.FireworkSecColorPos.value),
								new GradientColorKey(ModConfig.FireworkThirdColorField.value, ModConfig.FireworkThirdColorPos.value),
								new GradientColorKey(ModConfig.FireworkForthColorField.value, ModConfig.FireworkForthColorPos.value),
								new GradientColorKey(ModConfig.FireworkFifthColorField.value, ModConfig.FireworkFifthColorPos.value)
							}, (GradientAlphaKey[])(object)new GradientAlphaKey[5]
							{
								new GradientAlphaKey(1f - ModConfig.FireworkTransparency.value, 0f),
								new GradientAlphaKey(1f - ModConfig.FireworkSecTransparency.value, ModConfig.FireworkSecColorPos.value),
								new GradientAlphaKey(1f - ModConfig.FireworkThirdTransparency.value, ModConfig.FireworkThirdColorPos.value),
								new GradientAlphaKey(1f - ModConfig.FireworkForthTransparency.value, ModConfig.FireworkForthColorPos.value),
								new GradientAlphaKey(1f - ModConfig.FireworkFifthTransparency.value, ModConfig.FireworkFifthColorPos.value)
							});
							((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
						}
						else if (ModConfig.ForthColorButton.value)
						{
							val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[4]
							{
								new GradientColorKey(ModConfig.FireworkColorField.value, 0f),
								new GradientColorKey(ModConfig.FireworkSecColorField.value, ModConfig.FireworkSecColorPos.value),
								new GradientColorKey(ModConfig.FireworkThirdColorField.value, ModConfig.FireworkThirdColorPos.value),
								new GradientColorKey(ModConfig.FireworkForthColorField.value, ModConfig.FireworkForthColorPos.value)
							}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
							{
								new GradientAlphaKey(1f - ModConfig.FireworkTransparency.value, 0f),
								new GradientAlphaKey(1f - ModConfig.FireworkSecTransparency.value, ModConfig.FireworkSecColorPos.value),
								new GradientAlphaKey(1f - ModConfig.FireworkThirdTransparency.value, ModConfig.FireworkThirdColorPos.value),
								new GradientAlphaKey(1f - ModConfig.FireworkForthTransparency.value, ModConfig.FireworkForthColorPos.value)
							});
							((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
						}
						else if (ModConfig.ThirdColorButton.value)
						{
							val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
							{
								new GradientColorKey(ModConfig.FireworkColorField.value, 0f),
								new GradientColorKey(ModConfig.FireworkSecColorField.value, ModConfig.FireworkSecColorPos.value),
								new GradientColorKey(ModConfig.FireworkThirdColorField.value, ModConfig.FireworkThirdColorPos.value)
							}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
							{
								new GradientAlphaKey(1f - ModConfig.FireworkTransparency.value, 0f),
								new GradientAlphaKey(1f - ModConfig.FireworkSecTransparency.value, ModConfig.FireworkSecColorPos.value),
								new GradientAlphaKey(1f - ModConfig.FireworkThirdTransparency.value, ModConfig.FireworkThirdColorPos.value)
							});
							((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
						}
						else if (ModConfig.EnableSecondaryColors.value)
						{
							val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
							{
								new GradientColorKey(ModConfig.FireworkColorField.value, 0f),
								new GradientColorKey(ModConfig.FireworkSecColorField.value, ModConfig.FireworkSecColorPos.value)
							}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
							{
								new GradientAlphaKey(1f - ModConfig.FireworkTransparency.value, 0f),
								new GradientAlphaKey(1f - ModConfig.FireworkSecTransparency.value, ModConfig.FireworkSecColorPos.value)
							});
						}
						((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
					}
				}
				else if (ModConfig.FireworkSpecialMode.value == ModConfig.FireworkMode.Randomcolors)
				{
					Color val4 = Color.HSVToRGB(Random.Range(0f, 1f), 1f, 1f);
					((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(val4);
					startColor = ((MainModule)(ref main2)).startColor;
					Color color2 = ((MinMaxGradient)(ref startColor)).color;
					color2.a = 1f - ModConfig.Mode1Transparency.value;
					((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(color2);
				}
				else if (ModConfig.FireworkSpecialMode.value == ModConfig.FireworkMode.TwoColored)
				{
					if (iColor == 0)
					{
						((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(ModConfig.Mode2ColorFieldF1.value);
						startColor = ((MainModule)(ref main2)).startColor;
						Color color3 = ((MinMaxGradient)(ref startColor)).color;
						color3.a = 1f - ModConfig.Mode2TransparencyF1.value;
						((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(color3);
						iColor = 1;
					}
					else
					{
						((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(ModConfig.Mode2ColorFieldF2.value);
						startColor = ((MainModule)(ref main2)).startColor;
						Color color4 = ((MinMaxGradient)(ref startColor)).color;
						color4.a = 1f - ModConfig.Mode2TransparencyF2.value;
						((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(color4);
						iColor = 0;
					}
				}
			}
			ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>();
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val5 in array)
			{
				MainModule main3 = val5.main;
				((MainModule)(ref main3)).simulationSpace = (ParticleSystemSimulationSpace)0;
				((MainModule)(ref main3)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			}
			if ((Object)(object)component != (Object)null)
			{
				MainModule main4 = component.main;
				component.Play();
				int num2 = Random.Range(0, components.Length);
				components[num2].volume = ModConfig.FireworkVolume.value;
				components[num2].pitch = Random.Range(0.8f, 1.35f);
				components[num2].PlayDelayed(1.2f);
			}
			Object.Destroy((Object)(object)val2, 5f);
			Logger.LogInfo((object)("name: " + ((Object)val2).name));
			ManualLogSource logger = Logger;
			Scene scene = val2.scene;
			logger.LogInfo((object)("Scene: " + ((Scene)(ref scene)).name));
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.yourname.pluginname";

		public const string PLUGIN_NAME = "Fireworks for P ranks";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}