using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using LCSoundTool;
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: AssemblyTitle("MoonlightDroppod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoonlightDroppod")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cfe8dd99-ec15-43fe-8840-37bbbf7be706")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoonlightDroppod;
[BepInPlugin("HighSpirits.MoonlightDroppod", "Moonlight Droppod", "1.0.2")]
public class MoonlightDroppodBase : BaseUnityPlugin
{
private const string modGUID = "HighSpirits.MoonlightDroppod";
private const string modName = "Moonlight Droppod";
private const string modVersion = "1.0.2";
private const string modFolder = "HighSpiritsClub-MoonlightDroppod";
private static MoonlightDroppodBase Instance;
internal ManualLogSource mls;
private AudioClip sonataOutside;
private AudioClip sonataInside;
private async void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("HighSpirits.MoonlightDroppod");
mls.LogInfo((object)"Hark!");
string soundLib = Path.Combine(Paths.PluginPath, "HighSpiritsClub-MoonlightDroppod");
sonataOutside = await LoadClip(Path.Combine(soundLib, "IcecreamTruckV2.wav"));
sonataInside = await LoadClip(Path.Combine(soundLib, "IcecreamTruckFar.wav"));
SoundTool.ReplaceAudioClip("IcecreamTruckV2", sonataOutside);
SoundTool.ReplaceAudioClip("IcecreamTruckFar", sonataInside);
SoundTool.ReplaceAudioClip("IcecreamTruckV2Christmas", sonataOutside);
SoundTool.ReplaceAudioClip("IcecreamTruckV2ChristmasFar", sonataInside);
mls.LogInfo((object)"Droppod music fixed");
}
private async Task<AudioClip> LoadClip(string path)
{
AudioClip clip = null;
UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
try
{
uwr.SendWebRequest();
try
{
while (!uwr.isDone)
{
await Task.Delay(5);
}
if ((int)uwr.result == 2 || (int)uwr.result == 3 || (int)uwr.result == 4)
{
mls.LogError((object)(uwr.error ?? ""));
}
else
{
clip = DownloadHandlerAudioClip.GetContent(uwr);
}
}
catch (Exception ex)
{
Exception err = ex;
mls.LogError((object)(err.Message + ", " + err.StackTrace));
}
}
finally
{
((IDisposable)uwr)?.Dispose();
}
return clip;
}
}