using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.Witherstyle.peak.SoundEffectButton")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+31292691953f9278db3dc7a7bafaa4de83e10bce")]
[assembly: AssemblyProduct("com.Witherstyle.peak.SoundEffectButton")]
[assembly: AssemblyTitle("SoundEffectButton")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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.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]
[Microsoft.CodeAnalysis.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;
}
}
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace SoundEffectButton
{
[BepInPlugin("com.Witherstyle.peak.SoundEffectButton", "SoundEffectButton", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Character), "Awake")]
private static class CharacterAwake
{
[HarmonyPostfix]
private static void AddSFXManager(Character __instance)
{
if ((Object)(object)customSFX != (Object)null)
{
((Component)__instance).gameObject.AddComponent<SFXManager>();
}
}
}
internal static SFX_Instance? customSFX;
public const string Id = "com.Witherstyle.peak.SoundEffectButton";
internal static ManualLogSource Log { get; private set; }
internal static MyModConfig BoundConfig { get; private set; }
public static string Name => "SoundEffectButton";
public static string Version => "1.0.2";
private void Awake()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
BoundConfig = new MyModConfig(((BaseUnityPlugin)this).Config);
Harmony val = new Harmony(Name ?? "");
val.PatchAll();
LoadCustomAudio();
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void LoadCustomAudio()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Log.LogInfo((object)("Looking for .ogg in: " + directoryName));
string[] files = Directory.GetFiles(directoryName, "*.ogg");
if (files.Length == 0)
{
Log.LogWarning((object)"No .ogg file found.");
return;
}
string text = files[0];
Log.LogInfo((object)("Found .ogg file: " + text));
((MonoBehaviour)this).StartCoroutine(LoadAudio(text));
}
private IEnumerator LoadAudio(string fileName)
{
string text = "file://" + fileName;
UnityWebRequest webRequest = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)14);
try
{
yield return webRequest.SendWebRequest();
if ((int)webRequest.result == 2 || (int)webRequest.result == 3)
{
Log.LogInfo((object)("Failed to load .ogg file: " + webRequest.error));
yield break;
}
customSFX = ScriptableObject.CreateInstance<SFX_Instance>();
customSFX.clips = (AudioClip[])(object)new AudioClip[1] { DownloadHandlerAudioClip.GetContent(webRequest) };
customSFX.settings = new SFX_Settings
{
volume = BoundConfig.SFXVolume.Value,
range = BoundConfig.SFXRange.Value,
cooldown = BoundConfig.SFXCooldown.Value
};
Log.LogInfo((object)("Loaded .ogg file: " + fileName));
}
finally
{
((IDisposable)webRequest)?.Dispose();
}
}
}
public class SFXManager : MonoBehaviourPun
{
private void Update()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (!Input.GetKeyDown(Plugin.BoundConfig.SFXKey.Value))
{
return;
}
Character localCharacter = Character.localCharacter;
if (!((Object)(object)localCharacter != (Object)null))
{
return;
}
int viewID = ((MonoBehaviourPun)localCharacter).photonView.ViewID;
try
{
if (!localCharacter.data.dead)
{
((MonoBehaviourPun)localCharacter).photonView.RPC("PlaySoundGlobal", (RpcTarget)0, new object[1] { viewID });
if (Plugin.BoundConfig.KillOnPress.Value)
{
localCharacter.DieInstantly();
}
}
}
catch (Exception ex)
{
Plugin.Log.LogInfo((object)("Error: " + ex.Message));
}
}
[PunRPC]
public void PlaySoundGlobal(int photonID)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
Character val = default(Character);
if (Character.GetCharacterWithPhotonID(photonID, ref val))
{
SFXManager component = ((Component)val).GetComponent<SFXManager>();
component.PlaySound(val.Center);
}
}
public void PlaySound(Vector3 pos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
Plugin.customSFX.Play(pos + Vector3.up * 0.2f + Vector3.forward * 0.1f);
}
}
public class MyModConfig
{
public readonly ConfigEntry<KeyCode> SFXKey;
public readonly ConfigEntry<float> SFXVolume;
public readonly ConfigEntry<float> SFXRange;
public readonly ConfigEntry<float> SFXCooldown;
public readonly ConfigEntry<bool> KillOnPress;
public MyModConfig(ConfigFile cfg)
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
cfg.SaveOnConfigSet = false;
SFXKey = cfg.Bind<KeyCode>("General", "Sound Effect Button", (KeyCode)116, "Clicking this button will play the given sound effect.");
SFXVolume = cfg.Bind<float>("General", "Sound Effect Volume", 1f, "Volume of sound effect.");
SFXRange = cfg.Bind<float>("General", "Sound Effect Range", 50f, "Maximum distance sound effect can be heard from.");
SFXCooldown = cfg.Bind<float>("General", "Sound Effect Cooldown", 1f, new ConfigDescription("How often can the sound be played (1.0f is the length of the sound effect).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
KillOnPress = cfg.Bind<bool>("General", "Kill On Press", false, "If you play the sound effect, you instantly die.");
ClearOrphanedEntries(cfg);
cfg.Save();
cfg.SaveOnConfigSet = true;
}
private static void ClearOrphanedEntries(ConfigFile cfg)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
dictionary.Clear();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}