Decompiled source of PanicButton v1.0.0

PanicButton.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.Notifications;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using PanicButton;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "PanicButton", "1.0.0", "remox", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PanicButton")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PanicButton")]
[assembly: AssemblyTitle("PanicButton")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PanicButton
{
	public class Core : MelonMod
	{
		private AudioClip teleportClip;

		private UnityWebRequest _soundLoadRequest;

		private UnityWebRequestAsyncOperation _soundLoadOperation;

		public override void OnInitializeMelon()
		{
			LoadEmbeddedSound();
			MelonLogger.Msg("Panic Button loaded!");
		}

		private void LoadEmbeddedSound()
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string name = "Panic_Button.Resources.teleport.wav";
				using Stream stream = executingAssembly.GetManifestResourceStream(name);
				if (stream == null)
				{
					MelonLogger.Warning("Teleport sound not found!");
					return;
				}
				string text = Path.Combine(MelonEnvironment.UserDataDirectory, "PanicButton", "teleport.wav");
				Directory.CreateDirectory(Path.GetDirectoryName(text));
				using FileStream destination = new FileStream(text, FileMode.Create, FileAccess.Write);
				stream.CopyTo(destination);
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)20);
				_soundLoadOperation = audioClip.SendWebRequest();
				_soundLoadRequest = audioClip;
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Failed to load teleport sound: " + ex.Message);
			}
		}

		public override void OnUpdate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			if (_soundLoadOperation != null && ((AsyncOperation)_soundLoadOperation).isDone)
			{
				try
				{
					if ((int)_soundLoadRequest.result == 1)
					{
						teleportClip = DownloadHandlerAudioClip.GetContent(_soundLoadRequest);
						((Object)teleportClip).name = "TeleportSFX";
						MelonLogger.Msg("Teleport sound loaded successfully!");
					}
					else
					{
						MelonLogger.Warning("Failed to load sound: " + _soundLoadRequest.error);
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Error("Error retrieving sound content: " + ex.Message);
				}
				_soundLoadOperation = null;
				_soundLoadRequest = null;
			}
			if (!Input.GetKeyDown((KeyCode)287))
			{
				return;
			}
			GameObject val = GameObject.Find("PlayerMarker") ?? GameObject.Find("Player Marker");
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Warning("No Player Marker found in scene!");
			}
			else if ((Object)(object)Player.RigManager != (Object)null)
			{
				Player.RigManager.Teleport(val.transform.position, true);
				MelonLogger.Msg("Teleported to PlayerMarker!");
				if ((Object)(object)teleportClip != (Object)null)
				{
					Audio.Play2DOneShot(teleportClip, (AudioMixerGroup)null, 1f, 1f);
				}
				Notifier.Send(new Notification
				{
					Title = NotificationText.op_Implicit("Panic Button"),
					Message = NotificationText.op_Implicit("Teleported to the Player Marker!"),
					Type = (NotificationType)0,
					PopupLength = 2f,
					ShowTitleOnPopup = true
				});
			}
		}
	}
}