using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
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: AssemblyTitle("youknowwhatthatmeans")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("youknowwhatthatmeans")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("96bb1d90-8adc-4520-a7ea-9c24ed4abf92")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace youknowwhatthatmeans;
[BepInPlugin("triggeredidiot.youknowwhatthatmeans", "YouKnoWhatThatMeans", "1.0.0")]
public class fishreplacer : BaseUnityPlugin
{
private const string modGUID = "triggeredidiot.youknowwhatthatmeans";
private const string modName = "YouKnoWhatThatMeans";
private const string modVersion = "1.0.0";
private static readonly Harmony Harmony = new Harmony("triggeredidiot.youknowwhatthatmeans");
private static fishreplacer inst;
public static bool applyToLoopingSounds = true;
public static bool applySubtitlePatch = true;
public static string helloDnSpyUser
{
get
{
return "'this mod is programmed like sh-' blah blah bro shut up you're weird";
}
set
{
}
}
public static AudioClip fish { get; private set; }
public static string fishFile { get; private set; }
public static AudioClip GetFishSafe()
{
if (Object.op_Implicit((Object)(object)fish))
{
return fish;
}
UpdateFish();
return fish;
}
public static AudioType GetAudioType(string file)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
return (AudioType)(Path.GetExtension(file).ToLower() switch
{
".mp3" => 13,
".wav" => 20,
".ogg" => 14,
_ => 0,
});
}
private void Awake()
{
inst = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"YouKnoWhatThatMeans 1.0.0 is loading...");
Harmony.PatchAll();
UpdateFish();
SceneManager.activeSceneChanged += delegate
{
ApplyFish();
((MonoBehaviour)this).StartCoroutine(FishLoop());
};
((BaseUnityPlugin)this).Logger.LogInfo((object)helloDnSpyUser);
((BaseUnityPlugin)this).Logger.LogInfo((object)"YouKnoWhatThatMeans 1.0.0 is *mostly* loaded!");
}
private static void ApplyFish()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
Object[] array = Object.FindObjectsOfTypeAll(typeof(AudioSource));
for (int i = 0; i < array.Length; i++)
{
AudioSource val = (AudioSource)array[i];
if ((applyToLoopingSounds || !val.loop) && (Object)(object)val.clip != (Object)(object)fish)
{
Fish(val);
}
}
}
private IEnumerator FishLoop()
{
while (true)
{
yield return null;
ApplyFish();
yield return (object)new WaitForSeconds(0.25f);
}
}
public static void UpdateFish()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
string directoryName = Path.GetDirectoryName(Assembly.GetAssembly(typeof(fishreplacer)).Location);
string[] files = Directory.GetFiles(directoryName);
foreach (string text in files)
{
if (Path.GetFileNameWithoutExtension(text) == "fish" && (int)GetAudioType(text) > 0)
{
fishFile = text;
}
}
if (string.IsNullOrEmpty(fishFile))
{
((BaseUnityPlugin)inst).Logger.LogError((object)"NO FISH FILE NOOOOOOOOOOOOOOOOOOOOOO");
}
Object.FindObjectOfType<MonoBehaviour>().StartCoroutine(loadAudio());
}
private static IEnumerator loadAudio()
{
DownloadHandlerAudioClip dh = new DownloadHandlerAudioClip("file://" + fishFile, (AudioType)13);
dh.compressed = true;
UnityWebRequest wr = new UnityWebRequest("file://" + fishFile, "GET", (DownloadHandler)(object)dh, (UploadHandler)null);
try
{
yield return wr.SendWebRequest();
if (wr.responseCode == 200)
{
fish = dh.audioClip;
}
}
finally
{
((IDisposable)wr)?.Dispose();
}
if ((Object)(object)fish == (Object)null)
{
((BaseUnityPlugin)inst).Logger.LogError((object)"NO FISH FILE FAILED TO LOAD NOOOOOOOOOOOO");
}
}
private static void Fish(AudioSource __instance)
{
if (!Object.op_Implicit((Object)(object)__instance.outputAudioMixerGroup) || !Object.op_Implicit((Object)(object)__instance.outputAudioMixerGroup.audioMixer) || !((Object)__instance.outputAudioMixerGroup.audioMixer).name.Contains("Music"))
{
if ((Object)(object)fish == (Object)null)
{
UpdateFish();
}
__instance.clip = fish;
}
}
private void OnGUI()
{
//IL_0001: 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)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "b3e7f2f8052488a45b35549efb98d902")
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.FlexibleSpace();
applyToLoopingSounds = GUILayout.Toggle(applyToLoopingSounds, "(FISH) apply to looping sounds", Array.Empty<GUILayoutOption>());
applySubtitlePatch = GUILayout.Toggle(applySubtitlePatch, "(FISH) apply fish subtitle", Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
}
}
}
[HarmonyPatch(typeof(Subtitle))]
[HarmonyPatch("Update")]
internal static class Fishtitle
{
private static void Postfix(Subtitle __instance)
{
if (fishreplacer.applySubtitlePatch)
{
((Component)__instance).GetComponentInChildren<TMP_Text>().text = "fish";
}
}
}
[HarmonyPatch(typeof(SubtitledAudioSource))]
[HarmonyPatch("Update")]
internal static class Fishaudiosubtitle
{
private static float timer;
private static bool Prefix(SubtitledAudioSource __instance)
{
if (!fishreplacer.applySubtitlePatch)
{
return true;
}
timer += Time.deltaTime;
AudioSource value = Traverse.Create((object)__instance).Field<AudioSource>("audioSource").Value;
float value2 = Traverse.Create((object)__instance).Field<float>("lastAudioTime").Value;
int num = Traverse.Create((object)__instance).Field<int>("currentVoiceLine").Value;
SubtitleData value3 = Traverse.Create((object)__instance).Field<SubtitleData>("subtitles").Value;
bool value4 = Traverse.Create((object)__instance).Field<bool>("distanceAware").Value;
if (value3.lines.Length > num)
{
if (timer >= value3.lines[num].time)
{
num++;
value.Play();
MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(value3.lines[num].subtitle, value4 ? value : null, false);
}
value2 = timer;
}
Traverse.Create((object)__instance).Field<int>("currentVoiceLine").Value = num;
return false;
}
}
public class youbetterstayasafuckingfishaudioclip : MonoBehaviour
{
public AudioSource target;
private void FixedUpdate()
{
if (Object.op_Implicit((Object)(object)target) && (Object)(object)target.clip != (Object)(object)fishreplacer.GetFishSafe())
{
target.clip = fishreplacer.fish;
}
}
}