using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[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("SFXLoader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("SFXLoader")]
[assembly: AssemblyTitle("SFXLoader")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 SFXLoader
{
[BepInPlugin("SFXLoader", "SFXLoader", "0.0.1")]
public class Plugin : BaseUnityPlugin
{
private static List<string> sfxNameRepo = new List<string>();
private static List<AudioClip> sfxClipRepo = new List<AudioClip>();
public AudioSource sfxEntity;
public Transform sfxPos;
public static ManualLogSource Log { get; private set; }
private void Awake()
{
List<AudioClip> list = new List<AudioClip>();
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"SFXLoader loaded");
SceneManager.sceneLoaded += Reload;
}
public void Update()
{
}
public void Reload(Scene seine, LoadSceneMode nada)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
GameObject val = new GameObject("SFX GameObject");
sfxEntity = val.AddComponent<AudioSource>();
if (((Scene)(ref seine)).name == "Game-Main" || ((Scene)(ref seine)).name == "Playground")
{
Log.LogInfo((object)"DEBUG - Loading Commands");
CommandConsole.AddCommand("loadsound", (Action<string[]>)LoadSound, false);
CommandConsole.AddCommand("listsounds", (Action<string[]>)ListSounds, false);
repoLoad();
}
}
public void LoadSound(string[] sfxName)
{
if (sfxName.Length < 1)
{
CommandConsole.Log("This command needs an argument to run (E.g. loadsound ann_alert)", false);
}
else if (sfxNameRepo.Contains(string.Join(" ", sfxName)))
{
CommandConsole.Log("SFX " + string.Join(" ", sfxName) + " found, playing it", false);
foreach (AudioClip item in sfxClipRepo)
{
if (((Object)item).name == string.Join(" ", sfxName))
{
sfxEntity.clip = item;
break;
}
}
sfxEntity.volume = 1f;
sfxEntity.Play();
}
else
{
CommandConsole.Log("Can't find the following SFX: " + string.Join(" ", sfxName), false);
CommandConsole.Log("This sound loader is Case-sensitive, and requires the argument to exactly match the result", false);
}
}
public void ListSounds(string[] sfxListing)
{
if (string.Join("", sfxListing).ToLower() != "yes")
{
CommandConsole.Log("WARNING: Your Computer Performance might tank if you use this command. To confirm, type listsounds yes", false);
return;
}
foreach (string item in sfxNameRepo)
{
CommandConsole.Log(item, false);
}
}
public void repoLoad()
{
AudioClip[] source = Resources.FindObjectsOfTypeAll<AudioClip>();
sfxClipRepo.AddRange(source.Where((AudioClip sound) => !sfxClipRepo.Contains(sound)));
foreach (AudioClip item in sfxClipRepo)
{
sfxNameRepo.Add(((Object)item).name);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SFXLoader";
public const string PLUGIN_NAME = "SFXLoader";
public const string PLUGIN_VERSION = "0.0.1";
}
}