using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using THXDeepNoteShipHorn.Patches;
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("THXDeepNoteShipHorn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("THXDeepNoteShipHorn")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1a33b97e-bd6d-43ab-9bc7-aaaec0872b9b")]
[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 THXDeepNoteShipHorn
{
[BepInPlugin("Dane.THXShipHorn", "THX Deepnote Ship Horn", "1.0.0.0")]
public class THXDeepNoteModShipModBase : BaseUnityPlugin
{
private const string modGUID = "Dane.THXShipHorn";
private const string modName = "THX Deepnote Ship Horn";
private const string modVersion = "1.0.0.0";
private readonly Harmony harmony = new Harmony("Dane.THXShipHorn");
private static THXDeepNoteModShipModBase instance;
internal ManualLogSource logger;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
logger = Logger.CreateLogSource("Dane.THXShipHorn");
harmony.PatchAll(typeof(THXDeepNoteModShipModBase));
harmony.PatchAll(typeof(ShipAlarmCordPatch));
}
}
}
namespace THXDeepNoteShipHorn.Patches
{
[HarmonyPatch(typeof(ShipAlarmCord))]
internal class ShipAlarmCordPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void patchStart(ref AudioSource ___hornClose, ref AudioSource ___hornFar)
{
ManualLogSource val = Logger.CreateLogSource("Dane.THXShipHorn");
val.LogInfo((object)"Trying to get THX");
AudioClip val2 = LoadAudioClip();
val.LogInfo((object)"finished attempt of THX");
if ((Object)(object)val2 != (Object)null)
{
___hornClose.clip = val2;
___hornFar.clip = val2;
}
}
private static AudioClip LoadAudioClip()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
ManualLogSource val = Logger.CreateLogSource("Dane.THXShipHorn");
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("https://www.thx.com/wp-content/themes/thx/webgl/assets/audio/deepnote.mp3", (AudioType)13);
try
{
audioClip.SendWebRequest();
while (!audioClip.isDone)
{
}
if ((int)audioClip.result == 2)
{
val.LogError((object)("Could not load THX sound, error: " + audioClip.error));
return null;
}
return DownloadHandlerAudioClip.GetContent(audioClip);
}
finally
{
((IDisposable)audioClip)?.Dispose();
}
}
}
}