Decompiled source of ULTRAVIVZE v1.0.0

plugins/ULTRAVIVZIE.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ULTRAVIVZIE")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ULTRAVIVZIE")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2241988a-e77f-4caa-abc4-0bb004b68782")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ULTRAVIVZIE;

public static class AudioJungle
{
	public static AudioSource source = null;

	public static AudioClip main_clip = null;

	private static bool isMuted = false;

	public static Dictionary<string, List<AudioFunny>> funnyDic = new Dictionary<string, List<AudioFunny>>();

	public static string recentPick;

	public static Dictionary<string, List<FunnyPeriod>> periodDic = new Dictionary<string, List<FunnyPeriod>>();

	public static Dictionary<string, List<SubtitleDataLine>> subtitleDic = new Dictionary<string, List<SubtitleDataLine>>();

	public static Dictionary<string, List<FunnyLine>> funnyLineDic = new Dictionary<string, List<FunnyLine>>();

	public static string[] loadedIDs = new string[0];

	public static bool Isgab_BeholdHavingAManicMeltdownAgain = false;

	public static void SetSource(AudioSource main_source)
	{
		source = main_source;
		main_clip = main_source.clip;
	}

	public static void SortFunnies(AudioFunny[] audlist)
	{
		for (int i = 0; i < audlist.Length; i++)
		{
			for (int j = 0; j < audlist[i].tags.Count; j++)
			{
				if (!funnyDic.ContainsKey(audlist[i].tags[j]))
				{
					funnyDic.Add(audlist[i].tags[j], new List<AudioFunny>());
					funnyDic[audlist[i].tags[j]].Add(audlist[i]);
				}
				else
				{
					funnyDic[audlist[i].tags[j]].Add(audlist[i]);
				}
			}
		}
	}

	public static AudioFunny Pick(string tag)
	{
		if (funnyDic == null)
		{
			return null;
		}
		if (funnyDic.TryGetValue(tag, out var value))
		{
			List<AudioFunny> list = new List<AudioFunny>(value);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].audMonkey.name == recentPick && list.Count > 1)
				{
					list.RemoveAt(i);
					i--;
				}
			}
			AudioFunny audioFunny = list[Random.Range(0, list.Count)];
			recentPick = audioFunny.audMonkey.name;
			return audioFunny;
		}
		return null;
	}

	public static void RefreshLinesById(string id)
	{
		if (!loadedIDs.Contains(id))
		{
			return;
		}
		if (funnyLineDic.TryGetValue(id, out var value))
		{
			List<FunnyPeriod> list = new List<FunnyPeriod>();
			List<SubtitleDataLine> list2 = new List<SubtitleDataLine>();
			for (int i = 0; i < value.Count(); i++)
			{
				value[i].RefunnyLines();
				List<FunnyPeriod> funnyPeriods = value[i].GetFunnyPeriods();
				for (int j = 0; j < funnyPeriods.Count(); j++)
				{
					list.Add(funnyPeriods[j]);
				}
				list2.Add(value[i].GetSubtitle());
			}
			funnyLineDic[id] = value;
			periodDic[id] = list;
			subtitleDic[id] = list2;
		}
		else
		{
			Debug.Log((object)("Eroror: " + id + " funny lines were not found."));
		}
	}

	public static void AudifyTheDenseTropicalVegitation(string path)
	{
		funnyLineDic = Cereal.BraisinRand(path);
		if (funnyLineDic == null)
		{
			Debug.Log((object)("Good heavens! It appears that something went wrong when trying to deserialize the .lines file: " + path));
			return;
		}
		string[] array = (loadedIDs = funnyLineDic.Keys.ToArray());
		for (int i = 0; i < array.Length; i++)
		{
			List<FunnyPeriod> list = new List<FunnyPeriod>();
			List<SubtitleDataLine> list2 = new List<SubtitleDataLine>();
			for (int j = 0; j < funnyLineDic[array[i]].Count(); j++)
			{
				list2.Add(funnyLineDic[array[i]][j].GetSubtitle());
				List<FunnyPeriod> funnyPeriods = funnyLineDic[array[i]][j].GetFunnyPeriods();
				for (int k = 0; k < funnyPeriods.Count; k++)
				{
					list.Add(funnyPeriods[k]);
				}
			}
			periodDic.Add(array[i], list);
			subtitleDic.Add(array[i], list2);
		}
		Debug.Log((object)"We are quite literally gaming");
	}

	public static void RefreshLines()
	{
		periodDic.Clear();
		subtitleDic.Clear();
		string[] array = funnyLineDic.Keys.ToArray();
		for (int i = 0; i < array.Length; i++)
		{
			List<FunnyPeriod> list = new List<FunnyPeriod>();
			List<SubtitleDataLine> list2 = new List<SubtitleDataLine>();
			for (int j = 0; j < funnyLineDic[array[i]].Count(); j++)
			{
				funnyLineDic[array[i]][j].RefunnyLines();
				List<FunnyPeriod> funnyPeriods = funnyLineDic[array[i]][j].GetFunnyPeriods();
				list2.Add(funnyLineDic[array[i]][j].GetSubtitle());
				for (int k = 0; k < funnyPeriods.Count; k++)
				{
					list.Add(funnyPeriods[k]);
				}
			}
			periodDic.Add(array[i], list);
			subtitleDic.Add(array[i], list2);
		}
	}

	public static string AddPeriod(string id, string tag, float start, float end, int stretchOptions = 0)
	{
		FunnyPeriod funnyPeriod = new FunnyPeriod();
		funnyPeriod.mutePeriod = new MutePeriod(start, end);
		funnyPeriod.audfun = Pick(tag);
		funnyPeriod.tag = tag;
		if ((Object)(object)funnyPeriod.audfun.audMonkey.clip != (Object)null && stretchOptions > 0)
		{
			float num = funnyPeriod.audfun.audMonkey.clip.length / (end - start);
			funnyPeriod.squishMode = stretchOptions;
		}
		if (periodDic.ContainsKey(id))
		{
			periodDic[id].Add(funnyPeriod);
		}
		else
		{
			periodDic.Add(id, new List<FunnyPeriod>());
			periodDic[id].Add(funnyPeriod);
		}
		if (funnyPeriod.audfun == null)
		{
			return "    ";
		}
		return funnyPeriod.audfun.text;
	}

	public static FunnyPeriod[] GetPeriods(string id)
	{
		List<FunnyPeriod> value = null;
		if (periodDic.TryGetValue(id, out value))
		{
			return value.ToArray();
		}
		return null;
	}

	public static void ResetPeriods()
	{
		periodDic.Clear();
		subtitleDic.Clear();
	}
}
public class FunnyLineFragment
{
	public FunnyPeriod funFrag;

	public string lineFrag;

	public bool silent = false;
}
public class FunnyLine
{
	private List<FunnyLineFragment> lineFrags = new List<FunnyLineFragment>();

	private float time = 0f;

	public string GetLineText()
	{
		string text = "";
		int num = 0;
		if (lineFrags == null)
		{
			return text;
		}
		for (int i = 0; i < lineFrags.Count; i++)
		{
			if (lineFrags[i].silent)
			{
				num++;
			}
			else if (lineFrags[i].funFrag != null)
			{
				if (lineFrags[i].funFrag.audfun != null)
				{
					text += lineFrags[i].funFrag.audfun.text;
				}
			}
			else if (lineFrags[i].lineFrag != null)
			{
				text += lineFrags[i].lineFrag;
			}
			else
			{
				num++;
			}
		}
		if (num == lineFrags.Count)
		{
			return null;
		}
		return text;
	}

	public SubtitleDataLine GetSubtitle()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		SubtitleDataLine val = new SubtitleDataLine();
		val.subtitle = GetLineText();
		if (val.subtitle == null)
		{
			return null;
		}
		val.time = time;
		return val;
	}

	public List<FunnyPeriod> GetFunnyPeriods()
	{
		List<FunnyPeriod> list = new List<FunnyPeriod>();
		for (int i = 0; i < lineFrags.Count; i++)
		{
			if (lineFrags[i].funFrag != null)
			{
				list.Add(lineFrags[i].funFrag);
			}
		}
		return list;
	}

	public void RefunnyLines()
	{
		for (int i = 0; i < lineFrags.Count; i++)
		{
			if (lineFrags[i].funFrag != null)
			{
				lineFrags[i].funFrag.Refunny();
			}
		}
	}

	public bool ParseFunnyLine(string funnyLine)
	{
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		string text = "";
		string text2 = "";
		List<FunnyLineFragment> list = new List<FunnyLineFragment>();
		while (num < funnyLine.Length)
		{
			if (funnyLine[num] == '"' && num3 != 1)
			{
				num4 = (num4 + 1) % 2;
				if (num4 == 0)
				{
					FunnyLineFragment funnyLineFragment = new FunnyLineFragment();
					funnyLineFragment.lineFrag = text;
					list.Add(funnyLineFragment);
					text = "";
					num++;
				}
				else
				{
					num++;
				}
				continue;
			}
			if (funnyLine[num] == '[')
			{
				num3++;
				if (num4 == 1)
				{
					FunnyLineFragment funnyLineFragment2 = new FunnyLineFragment();
					funnyLineFragment2.lineFrag = text;
					list.Add(funnyLineFragment2);
				}
				text = "";
				num++;
				continue;
			}
			if (num4 == 1 && num3 == 0)
			{
				text += funnyLine[num];
			}
			if (num3 == 1)
			{
				if (funnyLine[num] == ']')
				{
					num3--;
					FunnyLineFragment funnyLineFragment3 = new FunnyLineFragment();
					FunnyPeriod funnyPeriod = new FunnyPeriod();
					funnyPeriod.mutePeriod = new MutePeriod(0f, 0f);
					string[] array = text.Split(new char[1] { ',' });
					if (array.Length < 3)
					{
						Debug.Log((object)("Not enough values to properly parse funny period: " + text));
					}
					else if (array.Length < 4)
					{
						funnyPeriod.squishMode = 0;
					}
					switch (array.Length)
					{
					case 4:
						if (!int.TryParse(array[3], out funnyPeriod.squishMode))
						{
							Debug.Log((object)("Oh nose! Something went wrong when trying to parse squish mode: " + array[3]));
						}
						goto case 3;
					case 3:
						if (!float.TryParse(array[2], out funnyPeriod.mutePeriod.end))
						{
							Debug.Log((object)("Oh nose! Something went wrong when trying to parse period end time: " + array[2]));
						}
						goto case 2;
					case 2:
						if (!float.TryParse(array[1], out funnyPeriod.mutePeriod.start))
						{
							Debug.Log((object)("Oh nose! Something went wrong when trying to parse period start time: " + array[1]));
						}
						goto case 1;
					case 1:
						if (Enumerable.Contains(array[0], '"'))
						{
							string[] array2 = array[0].Split(new char[1] { '"' });
							funnyPeriod.tag = array2[1];
						}
						else
						{
							funnyPeriod.tag = array[0];
						}
						funnyPeriod.audfun = AudioJungle.Pick(funnyPeriod.tag);
						break;
					default:
						Debug.Log((object)("Oh nose! Something went wrong when trying to parse: " + text));
						break;
					}
					funnyLineFragment3.funFrag = funnyPeriod;
					if (num4 == 0)
					{
						funnyLineFragment3.silent = true;
					}
					list.Add(funnyLineFragment3);
					text = "";
					num++;
					continue;
				}
				text += funnyLine[num];
			}
			if (funnyLine[num] == '(')
			{
				num2++;
				num++;
			}
			else if (num2 == 1)
			{
				if (funnyLine[num] == ')')
				{
					num2--;
					if (!float.TryParse(text, out time))
					{
						Debug.Log((object)("Oh nose! Subtitle start time couldn't be parsed: " + text));
					}
					text = "";
					num++;
				}
				else
				{
					if (num4 == 0)
					{
						text += funnyLine[num];
					}
					num++;
				}
			}
			else
			{
				num++;
			}
		}
		if (list.Count > 0)
		{
			lineFrags = list;
			return true;
		}
		return false;
	}

	public static FunnyLine CreateFunnyLine(string funnyLine)
	{
		FunnyLine funnyLine2 = new FunnyLine();
		if (funnyLine2.ParseFunnyLine(funnyLine))
		{
			return funnyLine2;
		}
		return null;
	}
}
public class AudioTree : MonoBehaviour
{
	public AudioSource mainAud;

	public AudioSource funnyAud;

	private List<FunnyPeriod> periods;

	private bool isMainAudMuted = false;

	private FunnyPeriod currentPeriod = null;

	public string hahafunnyunitylolhahahehe;

	public string periodID = "";

	public void Awake()
	{
		if ((Object)(object)funnyAud == (Object)null)
		{
			funnyAud = ((Component)this).gameObject.AddComponent<AudioSource>();
		}
	}

	public void Update()
	{
		if (periods == null)
		{
			AudioJungle.periodDic.TryGetValue(periodID, out periods);
		}
		if (!((Object)(object)mainAud != (Object)null) || !mainAud.isPlaying || periods == null)
		{
			return;
		}
		funnyAud.pitch = mainAud.pitch;
		foreach (FunnyPeriod period in periods)
		{
			isMainAudMuted = period.mutePeriod.WithinRange(mainAud.time);
			if (!isMainAudMuted)
			{
				continue;
			}
			if (currentPeriod == period)
			{
				break;
			}
			currentPeriod = period;
			if ((Object)(object)period.audfun.audMonkey.clip != (Object)null)
			{
				funnyAud.clip = period.audfun.audMonkey.clip;
			}
			funnyAud.time = 0f;
			if (periodID == "gab_Behold")
			{
				if (AudioJungle.Isgab_BeholdHavingAManicMeltdownAgain || SceneHelper.CurrentScene != "Level 3-2")
				{
					continue;
				}
				AudioJungle.Isgab_BeholdHavingAManicMeltdownAgain = true;
			}
			funnyAud.Play();
			break;
		}
		if (isMainAudMuted)
		{
			mainAud.volume = 0f;
			funnyAud.volume = 1.5f * MonoSingleton<AudioMixerController>.instance.sfxVolume;
			float num = 1f;
			switch (currentPeriod.squishMode)
			{
			case 1:
				num = currentPeriod.audfun.audMonkey.clip.length / (currentPeriod.mutePeriod.end - currentPeriod.mutePeriod.start);
				funnyAud.time = Mathf.Min(currentPeriod.audfun.audMonkey.clip.length, Mathf.Max(0f, (mainAud.time - currentPeriod.mutePeriod.start) * num));
				break;
			case 2:
				num = Mathf.Max(1f, currentPeriod.audfun.audMonkey.clip.length / (currentPeriod.mutePeriod.end - currentPeriod.mutePeriod.start));
				funnyAud.time = Mathf.Min(currentPeriod.audfun.audMonkey.clip.length, Mathf.Max(0f, (mainAud.time - currentPeriod.mutePeriod.start) * num));
				break;
			}
		}
		else
		{
			mainAud.volume = 1f;
			funnyAud.volume = 0f;
		}
		if (GameStateManager.Instance.PlayerInputLocked)
		{
			mainAud.volume = 0f;
			funnyAud.volume = 0f;
		}
	}

	public void SlowUpdate()
	{
	}

	public void PeriodSwitchCheck()
	{
	}

	public string AddPeriod(string tag, float start, float end, int stretchOptions = 0)
	{
		FunnyPeriod funnyPeriod = new FunnyPeriod();
		funnyPeriod.mutePeriod = new MutePeriod(start, end);
		funnyPeriod.audfun = AudioJungle.Pick(tag);
		funnyPeriod.tag = tag;
		if ((Object)(object)funnyPeriod.audfun.audMonkey.clip != (Object)null && stretchOptions > 0)
		{
			float num = funnyPeriod.audfun.audMonkey.clip.length / (end - start);
			funnyPeriod.squishMode = stretchOptions;
		}
		periods.Add(funnyPeriod);
		if (funnyPeriod.audfun == null)
		{
			return "";
		}
		return funnyPeriod.audfun.text;
	}

	public void SetAudioSource(AudioSource audSource)
	{
		mainAud = audSource;
	}
}
public class AudioFlower : MonoBehaviour
{
	public AudioSource mainAud;

	public AudioSource funnyAud;

	private List<FunnyPeriod> periods;

	private bool isMainAudMuted = false;

	private FunnyPeriod currentPeriod = null;

	public string periodID = "";

	public List<string> idsOfIntrest = new List<string>();

	public string currentId = "";

	public void Awake()
	{
		if ((Object)(object)funnyAud == (Object)null)
		{
			funnyAud = ((Component)this).gameObject.AddComponent<AudioSource>();
		}
	}

	public void Update()
	{
		if (!((Object)(object)mainAud != (Object)null))
		{
			return;
		}
		if ((Object)(object)mainAud.clip != (Object)null && ((Object)mainAud.clip).name != periodID)
		{
			periodID = ((Object)mainAud.clip).name;
			bool flag = false;
			for (int i = 0; i < idsOfIntrest.Count; i++)
			{
				if (!(periodID == idsOfIntrest[i]) || !AudioJungle.loadedIDs.Contains(periodID))
				{
					continue;
				}
				AudioJungle.RefreshLinesById(periodID);
				flag = AudioJungle.periodDic.TryGetValue(periodID, out periods);
				List<SubtitleDataLine> value = new List<SubtitleDataLine>();
				if (!AudioJungle.subtitleDic.TryGetValue(periodID, out value))
				{
					break;
				}
				SubtitleDataLine val = null;
				for (int j = 0; j < value.Count(); j++)
				{
					if (value[j] != null)
					{
						val = value[j];
						break;
					}
				}
				if (val != null)
				{
					((Component)MonoSingleton<SubtitleController>.instance.previousSubtitle).GetComponentInChildren<TMP_Text>().text = val.subtitle;
					MonoSingleton<SubtitleController>.instance.previousSubtitle.Fit();
				}
				break;
			}
			if (!flag)
			{
				periods = new List<FunnyPeriod>();
			}
		}
		if (mainAud.isPlaying && periods != null)
		{
			funnyAud.pitch = mainAud.pitch;
			foreach (FunnyPeriod period in periods)
			{
				isMainAudMuted = period.mutePeriod.WithinRange(mainAud.time);
				if (!isMainAudMuted)
				{
					continue;
				}
				if (currentPeriod != period)
				{
					currentPeriod = period;
					if ((Object)(object)period.audfun.audMonkey.clip != (Object)null)
					{
						funnyAud.clip = period.audfun.audMonkey.clip;
					}
					funnyAud.time = 0f;
					funnyAud.Play();
				}
				break;
			}
			if (isMainAudMuted && currentPeriod != null)
			{
				mainAud.volume = 0f;
				funnyAud.volume = 1.5f * MonoSingleton<AudioMixerController>.instance.sfxVolume;
				float num = 1f;
				switch (currentPeriod.squishMode)
				{
				case 1:
					num = currentPeriod.audfun.audMonkey.clip.length / (currentPeriod.mutePeriod.end - currentPeriod.mutePeriod.start);
					funnyAud.time = Mathf.Min(currentPeriod.audfun.audMonkey.clip.length, Mathf.Max(0f, (mainAud.time - currentPeriod.mutePeriod.start) * num));
					break;
				case 2:
					num = Mathf.Max(1f, currentPeriod.audfun.audMonkey.clip.length / (currentPeriod.mutePeriod.end - currentPeriod.mutePeriod.start));
					funnyAud.time = Mathf.Min(currentPeriod.audfun.audMonkey.clip.length, Mathf.Max(0f, (mainAud.time - currentPeriod.mutePeriod.start) * num));
					break;
				}
			}
			else
			{
				mainAud.volume = 1f;
				mainAud.pitch = 1f;
				funnyAud.volume = 0f;
			}
			if (GameStateManager.Instance.PlayerInputLocked)
			{
				mainAud.volume = 0f;
				funnyAud.volume = 0f;
			}
		}
		else if (!mainAud.isPlaying)
		{
			currentPeriod = null;
		}
	}

	public void SetAudioSource(AudioSource audSource)
	{
		mainAud = audSource;
		if ((Object)(object)funnyAud != (Object)null)
		{
			funnyAud.SetCustomCurve((AudioSourceCurveType)0, mainAud.GetCustomCurve((AudioSourceCurveType)0));
		}
	}
}
public class MutePeriod
{
	public float start;

	public float end;

	public MutePeriod(float start, float end)
	{
		this.start = start;
		this.end = end;
	}

	public bool WithinRange(float num)
	{
		return num >= start && num <= end;
	}
}
public class FunnyPeriod
{
	public MutePeriod mutePeriod;

	public AudioFunny audfun;

	public string tag;

	public int squishMode;

	public float TimeToFunnyTime(float time)
	{
		return Mathf.Clamp(0f, mutePeriod.end - mutePeriod.start, time - mutePeriod.start);
	}

	public override string ToString()
	{
		return "(" + tag + ", " + mutePeriod.start + ", " + mutePeriod.end + ", " + squishMode + ")";
	}

	public void Refunny()
	{
		if (tag != null)
		{
			audfun = AudioJungle.Pick(tag);
		}
	}
}
public class AudioFunny
{
	public AudioMonkey audMonkey = new AudioMonkey();

	public string text;

	public List<string> tags = new List<string>();
}
public class AudioMonkey
{
	public AudioClip clip { get; private set; }

	public string name { get; private set; }

	public void SetName(string name)
	{
		this.name = name;
		if ((Object)(object)clip != (Object)null)
		{
			((Object)clip).name = name;
		}
	}

	public void GetAudioClipURL(string url, AudioType type = 20)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(url, type);
		((AsyncOperation)request.SendWebRequest()).completed += delegate
		{
			try
			{
				if (!request.isNetworkError && !request.isHttpError)
				{
					clip = DownloadHandlerAudioClip.GetContent(request);
					((Object)clip).name = name;
				}
				else
				{
					Debug.Log((object)("Error when trying to load clip: " + url));
				}
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex);
			}
			finally
			{
				request.Dispose();
			}
		};
	}
}
public static class Cereal
{
	public static AudioFunny[] UncerealFunnies(string path)
	{
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		if (!File.Exists(path))
		{
			Debug.Log((object)("Can't deserialize value because \"" + path + "\" does not exist."));
			return null;
		}
		if (!string.Equals(".funi", Path.GetExtension(path), StringComparison.OrdinalIgnoreCase))
		{
			Debug.Log((object)("Can't deserialize value because \"" + path + "\" is not a funi file."));
			return null;
		}
		StreamReader streamReader = new StreamReader(path);
		string text = streamReader.ReadToEnd();
		streamReader.Close();
		List<int> list = new List<int>();
		List<string> list2 = new List<string>();
		list2 = text.Split(new char[1] { '\n' }).ToList();
		for (int i = 0; i < list2.Count; i++)
		{
			if (list2[i].IndexOf("[") == 0)
			{
				list.Add(i);
			}
		}
		List<AudioFunny> list3 = new List<AudioFunny>();
		for (int j = 0; j < list.Count; j++)
		{
			AudioFunny audioFunny = new AudioFunny();
			string text2 = list2[list[j]].Split('[', ']')[1];
			AudioType type = (AudioType)20;
			if (text2.Contains(".wav"))
			{
				type = (AudioType)20;
			}
			else if (text2.Contains(".mp3"))
			{
				type = (AudioType)13;
			}
			audioFunny.audMonkey.SetName(text2);
			audioFunny.audMonkey.GetAudioClipURL(Path.Combine(Plugin.ModAudioDir(), text2), type);
			for (int k = list[j] + 1; k < list2.Count && list2[k].IndexOf("[") != 0; k++)
			{
				if (list2[k].IndexOf("text") == 0)
				{
					audioFunny.text = list2[k].Split(new char[1] { '"' })[1];
				}
				if (list2[k].IndexOf("tags") != 0)
				{
					continue;
				}
				string[] array = list2[k].Split(new char[1] { '"' });
				List<string> list4 = new List<string>();
				for (int l = 0; l < array.Length; l++)
				{
					if (l % 2 == 1)
					{
						list4.Add(array[l]);
					}
				}
				audioFunny.tags = list4;
			}
			list3.Add(audioFunny);
		}
		return list3.ToArray();
	}

	public static Dictionary<string, List<FunnyLine>> BraisinRand(string path)
	{
		if (!File.Exists(path))
		{
			Debug.Log((object)("Cannot find file: " + path));
			return null;
		}
		if (!string.Equals(".lines", Path.GetExtension(path), StringComparison.OrdinalIgnoreCase))
		{
			Debug.Log((object)("I aint deserializeing your shit cause it aint a lines file: " + path));
			return null;
		}
		StreamReader streamReader = new StreamReader(path);
		string text = streamReader.ReadToEnd();
		streamReader.Close();
		List<int> list = new List<int>();
		List<string> list2 = new List<string>();
		list2 = text.Split(new char[1] { '\n' }).ToList();
		for (int i = 0; i < list2.Count; i++)
		{
			if (list2[i].IndexOf("[[") == 0)
			{
				list.Add(i);
			}
		}
		Dictionary<string, List<FunnyLine>> dictionary = new Dictionary<string, List<FunnyLine>>();
		for (int j = 0; j < list.Count; j++)
		{
			string text2 = list2[list[j]].Split('[', ']')[2];
			if (text2 == null)
			{
				continue;
			}
			List<FunnyLine> value = null;
			if (dictionary.TryGetValue(text2, out value))
			{
				Debug.Log((object)("Warning: duplicate lines for " + text2 + " found in file: " + path));
				continue;
			}
			dictionary.Add(text2, new List<FunnyLine>());
			for (int k = list[j] + 1; k < list2.Count && list2[k].IndexOf("[[") != 0; k++)
			{
				FunnyLine funnyLine = FunnyLine.CreateFunnyLine(list2[k]);
				if (funnyLine != null)
				{
					dictionary[text2].Add(funnyLine);
				}
			}
		}
		return dictionary;
	}
}
[BepInPlugin("ironfarm.uk.fuckfuckfuckshit", "UltraVivzie", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public Harmony harm;

	public static AudioSource mainSource;

	public static AudioClip mainClip;

	public static GameObject obj;

	public static SubtitledAudioSource subSource = null;

	public static AudioFunny[] audFuns;

	public static List<GameObject> gigglebunch = new List<GameObject>();

	public void Start()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		harm = new Harmony("ironfarm.uk.fuckfuckfuckshit");
		harm.PatchAll(typeof(Patchistan));
		Debug.Log((object)"we did it tumblr");
		audFuns = Cereal.UncerealFunnies(Path.Combine(ModAudioDir(), "_aud_config_.funi"));
		AudioJungle.SortFunnies(audFuns);
		AudioJungle.AudifyTheDenseTropicalVegitation(Path.Combine(ModDataDir(), "script.lines"));
	}

	private void ClipCallback(AudioClip clip)
	{
		mainClip = clip;
	}

	public void Update()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Expected O, but got Unknown
		if (Input.GetKeyUp((KeyCode)117))
		{
			GameObject val = new GameObject();
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.clip = AudioJungle.Pick("wontburstyoureardrums").audMonkey.clip;
			val2.Play();
			gigglebunch.Add(val);
		}
		if (Input.GetKeyUp((KeyCode)105))
		{
			AudioJungle.funnyLineDic = new Dictionary<string, List<FunnyLine>>();
			AudioJungle.periodDic = new Dictionary<string, List<FunnyPeriod>>();
			AudioJungle.subtitleDic = new Dictionary<string, List<SubtitleDataLine>>();
			AudioJungle.AudifyTheDenseTropicalVegitation(Path.Combine(ModDataDir(), "script.lines"));
		}
		for (int i = 0; i < gigglebunch.Count; i++)
		{
			if (!gigglebunch[i].GetComponent<AudioSource>().isPlaying)
			{
				Object.Destroy((Object)(object)gigglebunch[i]);
				gigglebunch.RemoveAt(i);
				i--;
			}
		}
	}

	public static string GetTransformPath(Transform transform)
	{
		List<string> list = new List<string>();
		Transform val = transform;
		while ((Object)(object)val != (Object)null)
		{
			list.Add(((Object)val).name);
			val = val.parent;
		}
		string text = "";
		for (int num = list.Count() - 1; num >= 0; num--)
		{
			text += list[num];
			if (num != 0)
			{
				text += "/";
			}
		}
		return text;
	}

	public static string ModDir()
	{
		return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
	}

	public static string ModDataDir()
	{
		return Path.Combine(ModDir(), "Data");
	}

	public static string ModAudioDir()
	{
		return Path.Combine(ModDataDir(), "Audio");
	}
}
public static class Patchistan
{
	[HarmonyPatch(typeof(StockMapInfo), "Awake")]
	[HarmonyPrefix]
	public static void Testino(LevelStatsEnabler __instance)
	{
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Expected O, but got Unknown
		AudioJungle.RefreshLines();
		AudioJungle.Isgab_BeholdHavingAManicMeltdownAgain = false;
		AudioSource[] array = Resources.FindObjectsOfTypeAll<AudioSource>();
		SubtitledAudioSource val = default(SubtitledAudioSource);
		SubtitledAudioSource val3 = default(SubtitledAudioSource);
		for (int i = 0; i < array.Length; i++)
		{
			if (!((Object)(object)array[i] != (Object)null) || !((Object)(object)array[i].clip != (Object)null) || (!(((Object)array[i].clip).name == "mp_intro2") && !(((Object)array[i].clip).name == "mp_outro") && !(((Object)array[i].clip).name == "sp_intro") && !(((Object)array[i].clip).name == "sp_outro") && !(((Object)array[i].clip).name == "gab_Intro1d") && !(((Object)array[i].clip).name == "gab_Intro2b") && !(((Object)array[i].clip).name == "gab_Behold") && !(((Object)array[i].clip).name == "gab_Insignificant2b") && !(((Object)array[i].clip).name == "gab_Woes") && !(((Object)array[i].clip).name == "gab2nd_6-1tease1") && !(((Object)array[i].clip).name == "gab2nd_6-1tease2") && !(((Object)array[i].clip).name == "gab2nd_intro1") && !(((Object)array[i].clip).name == "gab2nd_intro1b") && !(((Object)array[i].clip).name == "gab2nd_intro2") && !(((Object)array[i].clip).name == "gab2nd_outro") && !(((Object)array[i].clip).name == "gab2nd_Woes")))
			{
				continue;
			}
			string name = ((Object)array[i].clip).name;
			if ((Object)(object)((Component)array[i]).transform.parent == (Object)null && ((Object)array[i].clip).name == "gab_Behold")
			{
				continue;
			}
			Debug.Log((object)("[" + name + "]"));
			Plugin.GetTransformPath(((Component)array[i]).transform.parent);
			if (((Component)array[i]).TryGetComponent<SubtitledAudioSource>(ref val))
			{
				SubtitleDataLine[] lines = val.subtitles.lines;
				for (int j = 0; j < lines.Length; j++)
				{
					Debug.Log((object)("(" + lines[j].time + ") \"" + lines[j].subtitle + "\""));
				}
			}
			if (!AudioJungle.loadedIDs.Contains(name))
			{
				continue;
			}
			List<SubtitleDataLine> list = AudioJungle.subtitleDic[name];
			for (int k = 0; k < list.Count; k++)
			{
				if (list[k] == null)
				{
					list.RemoveAt(k);
					k--;
				}
			}
			GameObject val2 = Object.Instantiate<GameObject>(new GameObject(), ((Component)array[i]).transform);
			AudioTree audioTree = val2.AddComponent<AudioTree>();
			audioTree.periodID = name;
			audioTree.SetAudioSource(array[i]);
			if (((Component)array[i]).TryGetComponent<SubtitledAudioSource>(ref val3))
			{
				val3.subtitles.lines = list.ToArray();
			}
		}
	}

	[HarmonyPatch(typeof(MinosPrime), "Start")]
	[HarmonyPostfix]
	public static void MinosLineParasite(MinosPrime __instance)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		if ((Object)(object)__instance.aud != (Object)null)
		{
			GameObject val = Object.Instantiate<GameObject>(new GameObject(), ((Component)__instance.aud).transform);
			AudioFlower audioFlower = val.AddComponent<AudioFlower>();
			audioFlower.SetAudioSource(__instance.aud);
			audioFlower.idsOfIntrest = new List<string>
			{
				"mp_crush", "mp_die", "mp_die2", "mp_judgement", "mp_judgement2", "mp_prepare", "mp_prepare2", "mp_thyend", "mp_thyend2", "mp_useless",
				"mp_weak"
			};
		}
	}

	[HarmonyPatch(typeof(SisyphusPrime), "Start")]
	[HarmonyPostfix]
	public static void SisyphusLineParasite(SisyphusPrime __instance)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		if ((Object)(object)__instance.aud != (Object)null)
		{
			GameObject val = Object.Instantiate<GameObject>(new GameObject(), ((Component)__instance.aud).transform);
			AudioFlower audioFlower = val.AddComponent<AudioFlower>();
			audioFlower.SetAudioSource(__instance.aud);
			audioFlower.idsOfIntrest = new List<string>
			{
				"sp_begone", "sp_begone2", "sp_destroy", "sp_destroy2", "sp_grunt", "sp_keepthemcoming", "sp_nicetry", "sp_nicetry2", "sp_thiswillhurt", "sp_yesthatsit",
				"sp_youcantescape", "sp_youcantescape2"
			};
		}
	}

	[HarmonyPatch(typeof(GabrielVoice), "Start")]
	[HarmonyPostfix]
	public static void GabLineParasite(GabrielVoice __instance)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		if ((Object)(object)__instance.aud != (Object)null)
		{
			GameObject val = Object.Instantiate<GameObject>(new GameObject(), ((Component)__instance.aud).transform);
			AudioFlower audioFlower = val.AddComponent<AudioFlower>();
			audioFlower.SetAudioSource(__instance.aud);
			audioFlower.idsOfIntrest = new List<string>
			{
				"gab_BigHurt1", "gab_Coward", "gab_Coward2", "gab_Enough", "gab_Enough2", "gab_Hologram", "gab_HologramFiltered", "gab_Hurt1", "gab_Hurt2", "gab_Hurt3",
				"gab_Hurt4", "gab_Insignificant", "gab_Insignificant2", "gab_Insignificant2b", "gab_Jesus", "gab_PlayerDeath", "gab_Swing", "gab_Swing2", "gab_Taunt1", "gab_Taunt2",
				"gab_Taunt3", "gab_Taunt4", "gab_Taunt5", "gab_Taunt6", "gab_Taunt7", "gab_Taunt8", "gab_Taunt9", "gab_Taunt10", "gab_Taunt11", "gab_Taunt12",
				"gab_Woes", "gab2nd_phaseChange2", "gab2nd_Pingas", "gab2nd_TauntAngry1", "gab2nd_TauntAngry2", "gab2nd_TauntAngry3", "gab2nd_TauntAngry4", "gab2nd_TauntAngry5", "gab2nd_TauntAngry6", "gab2nd_TauntAngry7",
				"gab2nd_TauntEcstatic1", "gab2nd_TauntEcstatic2", "gab2nd_TauntEcstatic3", "gab2nd_TauntEcstatic4", "gab2nd_TauntEcstatic5", "gab2nd_TauntEcstatic6", "gab2nd_TauntEcstatic7", "gab2nd_TauntEcstatic8", "gab2nd_TauntEcstatic9", "gab2nd_TauntEcstatic10"
			};
		}
	}

	public static SubtitleDataLine MakeLine(string subtitle, float time)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		SubtitleDataLine val = new SubtitleDataLine();
		val.subtitle = subtitle;
		val.time = time;
		return val;
	}
}
internal class PluginInfo
{
	public const string Name = "UltraVivzie";

	public const string Version = "1.0.0";

	public const string GUID = "ironfarm.uk.fuckfuckfuckshit";
}