Decompiled source of DawnOfTheThirdDay v1.0.1

BepInEx/plugins/DawnOfTheThirdDay.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DawnOfTheThirdDay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DawnOfTheThirdDay")]
[assembly: AssemblyTitle("DawnOfTheThirdDay")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DawnOfTheThirdDay
{
	public class HarmonyPatches
	{
		private static Harmony instance;

		public const string InstanceId = "com.graze.gorillatag.dawnofthethirdday";

		public static bool IsPatched { get; private set; }

		internal static void ApplyHarmonyPatches()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!IsPatched)
			{
				if (instance == null)
				{
					instance = new Harmony("com.graze.gorillatag.dawnofthethirdday");
				}
				instance.PatchAll(Assembly.GetExecutingAssembly());
				IsPatched = true;
			}
		}

		internal static void RemoveHarmonyPatches()
		{
			if (instance != null && IsPatched)
			{
				instance.UnpatchSelf();
				IsPatched = false;
			}
		}
	}
	[BepInPlugin("com.graze.gorillatag.dawnofthethirdday", "DawnOfTheThirdDay", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static class EventStuff
		{
			public static string audioURL = "https://cdn.discordapp.com/attachments/1008860948729188424/1191855886063370310/y2mate.is_-_Majora_s_Mask_Final_Hours_w_Bells-e056R97svz8-192k-1704191504.mp3";

			public static void PlayMusic()
			{
				if ((Object)(object)MusicPlayer.Instance == (Object)null)
				{
					((Component)GameNetworkManager.Instance.localPlayerController.playerGlobalHead).gameObject.AddComponent<MusicPlayer>();
					MusicPlayer.Instance.source = ((Component)GameNetworkManager.Instance.localPlayerController.playerGlobalHead).gameObject.AddComponent<AudioSource>();
				}
				MusicPlayer.Instance.source.Play();
			}
		}

		public class MusicPlayer : MonoBehaviour
		{
			public static MusicPlayer Instance;

			public AudioSource source;

			private string audioURL = "https://cdn.discordapp.com/attachments/1008860948729188424/1191855886063370310/y2mate.is_-_Majora_s_Mask_Final_Hours_w_Bells-e056R97svz8-192k-1704191504.mp3";

			private void Awake()
			{
				if ((Object)(object)Instance != (Object)(object)this)
				{
					Object.Destroy((Object)(object)Instance);
					Instance = this;
					((MonoBehaviour)this).StartCoroutine(GetMusic());
				}
			}

			public IEnumerator GetMusic()
			{
				UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(audioURL, (AudioType)13);
				try
				{
					yield return www.SendWebRequest();
					if ((int)www.result == 1)
					{
						AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www);
						source.clip = audioClip;
					}
					else
					{
						Debug.Log((object)("Error downloading audio: " + www.error));
					}
				}
				finally
				{
					((IDisposable)www)?.Dispose();
				}
			}

			private void Update()
			{
				source.mute = GameNetworkManager.Instance.localPlayerController.isInsideFactory;
				source.volume = volume.Value;
			}
		}

		public static ConfigEntry<float> volume;

		private Plugin()
		{
			HarmonyPatches.ApplyHarmonyPatches();
			volume = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Volume", 75f, (ConfigDescription)null);
		}
	}
	internal class PluginInfo
	{
		public const string GUID = "com.graze.gorillatag.dawnofthethirdday";

		public const string Name = "DawnOfTheThirdDay";

		public const string Version = "1.0.0";
	}
}
namespace DawnOfTheThirdDay.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class Patch
	{
		private static void Postfix(TimeOfDay __instance, ref DayMode __result)
		{
			if ((int)__result == 1)
			{
				Plugin.EventStuff.PlayMusic();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class Patch2
	{
		private static void Postfix()
		{
			Debug.Log((object)"Stop Music");
			Plugin.MusicPlayer.Instance.source.Stop();
		}
	}
}