Decompiled source of TakeUsToo v1.0.0

TakeUsToo.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TakeUsToo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TakeUsToo")]
[assembly: AssemblyTitle("TakeUsToo")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
}
[BepInPlugin("takeustoo", "Take Us Too", "1.0.0")]
public class TakeUsToo : BaseUnityPlugin
{
	internal static AudioClip clip;

	internal static ConfigEntry<float> Volume;

	internal static GameObject currentPlayer;

	private void Awake()
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		Volume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Volume", 1f, "Music volume (0-1)");
		((MonoBehaviour)this).StartCoroutine(LoadAudio());
		SceneManager.sceneLoaded += OnSceneLoaded;
		new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		StopMusic();
	}

	public static void StopMusic()
	{
		if (currentPlayer != null)
		{
			Object.Destroy((Object)(object)currentPlayer);
			currentPlayer = null;
		}
	}

	private IEnumerator LoadAudio()
	{
		string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "spire.ogg");
		if (File.Exists(text))
		{
			string text2 = "file://" + text;
			UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(text2, (AudioType)14);
			yield return www.SendWebRequest();
			if ((int)www.result == 1)
			{
				clip = DownloadHandlerAudioClip.GetContent(www);
			}
		}
	}
}
[HarmonyPatch]
internal class Patch_Extraction
{
	private static MethodBase TargetMethod()
	{
		Type type = AccessTools.TypeByName("RoundDirector");
		if (type == null)
		{
			return null;
		}
		return AccessTools.Method(type, "ExtractionCompletedAllRPC", (Type[])null, (Type[])null);
	}

	private static void Postfix()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		if (!((Object)(object)TakeUsToo.clip == (Object)null))
		{
			TakeUsToo.StopMusic();
			GameObject val = new GameObject("FormsPlayer");
			Object.DontDestroyOnLoad((Object)val);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.clip = TakeUsToo.clip;
			obj.volume = TakeUsToo.Volume.Value;
			obj.loop = false;
			obj.Play();
			TakeUsToo.currentPlayer = val;
		}
	}
}