Decompiled source of WesV2 v1.2.1

BepInEx/plugins/WesV2.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UltrakULL;
using UltrakULL.audio;
using UltrakULL.json;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("WesV2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("WesV2")]
[assembly: AssemblyTitle("WesV2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.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;
		}
	}
}
public static class ExtensionMethods
{
	public class V2AdditionalData
	{
		public AudioSource audioSource;

		public AudioClip[] tauntAudioClips;

		public string[] tauntSubtitles;

		public int[] tauntWeights;

		public AudioClip enrageAudioClip;

		public string enrageSubtitle;

		public AudioClip deathAudioClip;

		public string deathSubtitle;

		public int timesChangedWeapon;

		public int TauntWeightsSum => tauntWeights.Sum();

		public V2AdditionalData(AudioSource audioSource, AudioClip[] tauntAudioClips, string[] tauntSubtitles, AudioClip enrageAudioClip, string enrageSubtitle, AudioClip deathAudioClip, string deathSubtitle)
		{
			this.audioSource = audioSource;
			this.tauntAudioClips = tauntAudioClips;
			this.tauntSubtitles = tauntSubtitles;
			tauntWeights = Enumerable.Repeat(1, tauntAudioClips.Length).ToArray();
			this.enrageAudioClip = enrageAudioClip;
			this.enrageSubtitle = enrageSubtitle;
			this.deathAudioClip = deathAudioClip;
			this.deathSubtitle = deathSubtitle;
			timesChangedWeapon = 0;
			base..ctor();
		}

		public int WeightedRandomIndex()
		{
			int i = 0;
			int num = -1;
			for (int num2 = Random.Range(0, TauntWeightsSum); num2 >= i; i += tauntWeights[num])
			{
				num++;
			}
			return num;
		}
	}

	private static readonly ConditionalWeakTable<V2, V2AdditionalData> additionalDataTable = new ConditionalWeakTable<V2, V2AdditionalData>();

	public static Type[] GetPatchesOfType(this Assembly assembly, Type type)
	{
		return (from t in assembly.GetTypes()
			where t.IsSubclassOf(type)
			select t).ToArray();
	}

	public static V2AdditionalData GetAdditionalData(this V2 v2)
	{
		additionalDataTable.TryGetValue(v2, out var value);
		return value;
	}

	public static void SetAdditionalData(this V2 v2, V2AdditionalData data)
	{
		additionalDataTable.Add(v2, data);
	}

	public static void PlayVoice(this V2 v2, AudioClip clip)
	{
		AudioSource audioSource = v2.GetAdditionalData().audioSource;
		audioSource.pitch = Random.Range(0.95f, 1f);
		audioSource.clip = clip;
		audioSource.Play();
	}

	public static void Taunt(this V2 v2)
	{
		V2AdditionalData additionalData = v2.GetAdditionalData();
		int num = additionalData.WeightedRandomIndex();
		for (int i = 0; i < additionalData.tauntWeights.Length; i++)
		{
			additionalData.tauntWeights[i]++;
		}
		additionalData.tauntWeights[num] = 0;
		v2.PlayVoice(additionalData.tauntAudioClips[num]);
		MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(additionalData.tauntSubtitles[num], (AudioSource)null, false);
	}
}
[HarmonyPatch(typeof(GoToTarget), "Activate")]
internal class Patch7 : DefaultPatch
{
	private static void Prefix(GoToTarget __instance)
	{
		if (!__instance.activated)
		{
			Transform transform = ((Component)__instance).transform;
			if (((Object)transform).name == "Fake V2")
			{
				transform.Find("Voice").SetParent((Transform)null);
			}
		}
	}
}
[HarmonyPatch(typeof(HudMessage), "PlayMessage")]
internal class Patch6 : DefaultPatch
{
	private static void Prefix(ref string ___message)
	{
		if (___message == "You're not getting away this time.")
		{
			___message = "You get back here right this FUCKING INSTANT.";
		}
	}
}
internal class DefaultPatch
{
}
internal class UltrakULLPatch
{
}
[HarmonyPatch(typeof(UltrakillEvent), "Invoke")]
internal class Patch8 : DefaultPatch
{
	private static void Prefix(UltrakillEvent __instance)
	{
		if (__instance.toDisActivateObjects == null)
		{
			return;
		}
		GameObject[] toDisActivateObjects = __instance.toDisActivateObjects;
		foreach (GameObject val in toDisActivateObjects)
		{
			if (((val != null) ? ((Object)val).name : null) == "V2 Green Arm")
			{
				val.transform.Find("FleeingVoice").SetParent((Transform)null);
			}
		}
	}
}
[HarmonyPatch(typeof(Act2Strings), "Level44")]
internal class Patch9 : UltrakULLPatch
{
	private static void Prefix(ref string message)
	{
		if (message == "You get back here right this FUCKING INSTANT.")
		{
			message = "You're not getting away this time.";
		}
	}
}
[HarmonyPatch(typeof(V2), "Die")]
internal class Patch2 : DefaultPatch
{
	private static void Prefix(V2 __instance, bool ___dead, bool ___bossVersion)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		if (!___dead && !(((Object)__instance).name == "Big Johnator"))
		{
			if (__instance.inIntro)
			{
				((Component)((Component)__instance).transform.Find("IntroVoice")).gameObject.SetActive(false);
			}
			ExtensionMethods.V2AdditionalData additionalData = __instance.GetAdditionalData();
			additionalData.timesChangedWeapon = 0;
			additionalData.audioSource.Stop();
			if (!__instance.secondEncounter || !___bossVersion)
			{
				Utils.PlayClipAtPoint(additionalData.deathAudioClip, ((Component)__instance).transform.position);
				MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(additionalData.deathSubtitle, (AudioSource)null, false);
			}
			Plugin.LogDebug("v2 died");
		}
	}
}
[HarmonyPatch(typeof(V2), "Enrage")]
internal class Patch5 : DefaultPatch
{
	private static void Postfix(V2 __instance)
	{
		if (__instance.secondEncounter)
		{
			ExtensionMethods.V2AdditionalData additionalData = __instance.GetAdditionalData();
			additionalData.timesChangedWeapon = 0;
			__instance.PlayVoice(additionalData.enrageAudioClip);
			MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(additionalData.enrageSubtitle, (AudioSource)null, false);
		}
		Plugin.LogDebug("v2 enraged");
	}
}
[HarmonyPatch(typeof(V2), "KnockedOut")]
internal class Patch3 : DefaultPatch
{
	private static void Postfix(V2 __instance, string triggerName)
	{
		if (triggerName == "KnockedDown")
		{
			if (!__instance.secondEncounter)
			{
				((MonoBehaviour)__instance).StartCoroutine(Outro(__instance));
			}
			else
			{
				((MonoBehaviour)__instance).StartCoroutine(Fleeing(__instance));
			}
		}
		else if (triggerName == "Flailing")
		{
			((MonoBehaviour)Plugin.Instance).StartCoroutine(Falling());
		}
		else
		{
			Plugin.LogError("what");
		}
		Plugin.LogDebug("v2 knocked out: " + triggerName);
	}

	private static IEnumerator Outro(V2 __instance)
	{
		yield return (object)new WaitForSeconds(1f);
		AudioSource audioSource = Utils.CreateOneTimeVoiceObject("OutroVoice", V2VoicelinesData.GetAudioClip("v2_1/outro"), Utils.CreateSubtitleData(Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2_outro1")), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2_outro2"), 0.9f), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2_outro3"), 2f)), ((Component)__instance).transform);
		audioSource.Play();
	}

	private static IEnumerator Fleeing(V2 __instance)
	{
		ExtensionMethods.V2AdditionalData data = __instance.GetAdditionalData();
		__instance.PlayVoice(data.deathAudioClip);
		MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(data.deathSubtitle, (AudioSource)null, false);
		AudioSource fleeingVoice = Utils.CreateOneTimeVoiceObject("FleeingVoice", V2VoicelinesData.GetAudioClip("v2_2/fleeing1"), Utils.CreateSubtitleData(Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_fleeing1"))), ((Component)__instance).transform);
		yield return (object)new WaitForSeconds(2.5f);
		fleeingVoice.Play();
	}

	private static IEnumerator Falling()
	{
		GameObject fallingV2 = ((Component)Utils.FindGameObjectByName("8 Stuff(Clone)(Clone)").transform.Find("v2_GreenArm")).gameObject;
		AudioSource audioSource = Utils.CreateVoiceObject("FallingVoice", fallingV2.transform);
		audioSource.clip = V2VoicelinesData.GetAudioClip("v2_2/death");
		yield return (object)new WaitUntil((Func<bool>)(() => fallingV2.activeInHierarchy));
		yield return (object)new WaitForSeconds(0.3f);
		audioSource.Play();
		MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(V2VoicelinesData.GetSubtitle("subtitles_v2Second_death"), (AudioSource)null, false);
	}
}
[HarmonyPatch(typeof(V2), "Start")]
internal class Patch1 : DefaultPatch
{
	private static void Postfix(V2 __instance, Animator ___anim)
	{
		if (((Object)__instance).name == "Big Johnator")
		{
			return;
		}
		AudioSource audioSource;
		if (__instance.firstPhase)
		{
			audioSource = Utils.CreateVoiceObject("Voice", ((Component)__instance).transform);
		}
		else
		{
			audioSource = ((Component)((Component)__instance).transform.Find("Voice")).GetComponent<AudioSource>();
			Utils.CreateOneTimeVoiceObject("SlidingVoice", V2VoicelinesData.GetAudioClip("v2_2/fleeing2"), Utils.CreateSubtitleData(Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_fleeing2_1")), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_fleeing2_2"), 3f)), ((Component)__instance).transform).Play();
		}
		if (!__instance.secondEncounter)
		{
			__instance.SetAdditionalData(new ExtensionMethods.V2AdditionalData(audioSource, (AudioClip[])(object)new AudioClip[6]
			{
				V2VoicelinesData.GetAudioClip("v2_1/taunt1"),
				V2VoicelinesData.GetAudioClip("v2_1/taunt2"),
				V2VoicelinesData.GetAudioClip("v2_1/taunt3"),
				V2VoicelinesData.GetAudioClip("v2_1/taunt4"),
				V2VoicelinesData.GetAudioClip("v2_1/taunt5"),
				V2VoicelinesData.GetAudioClip("v2_1/taunt6")
			}, new string[6]
			{
				V2VoicelinesData.GetSubtitle("subtitles_v2_taunt1"),
				V2VoicelinesData.GetSubtitle("subtitles_v2_taunt2"),
				V2VoicelinesData.GetSubtitle("subtitles_v2_taunt3"),
				V2VoicelinesData.GetSubtitle("subtitles_v2_taunt4"),
				V2VoicelinesData.GetSubtitle("subtitles_v2_taunt5"),
				V2VoicelinesData.GetSubtitle("subtitles_v2_taunt6")
			}, null, null, V2VoicelinesData.GetAudioClip("v2_1/death"), V2VoicelinesData.GetSubtitle("subtitles_v2_death")));
		}
		else
		{
			__instance.SetAdditionalData(new ExtensionMethods.V2AdditionalData(audioSource, (AudioClip[])(object)new AudioClip[4]
			{
				V2VoicelinesData.GetAudioClip("v2_2/taunt1"),
				V2VoicelinesData.GetAudioClip("v2_2/taunt2"),
				V2VoicelinesData.GetAudioClip("v2_2/taunt3"),
				V2VoicelinesData.GetAudioClip("v2_2/taunt4")
			}, new string[4]
			{
				V2VoicelinesData.GetSubtitle("subtitles_v2Second_taunt1"),
				V2VoicelinesData.GetSubtitle("subtitles_v2Second_taunt2"),
				V2VoicelinesData.GetSubtitle("subtitles_v2Second_taunt3"),
				V2VoicelinesData.GetSubtitle("subtitles_v2Second_taunt4")
			}, V2VoicelinesData.GetAudioClip("v2_2/enrage"), V2VoicelinesData.GetSubtitle("subtitles_v2Second_enrage"), V2VoicelinesData.GetAudioClip("v2_1/death"), V2VoicelinesData.GetSubtitle("subtitles_v2_death")));
			if (__instance.secondEncounter && __instance.firstPhase && !Plugin.secondEncounterIntro)
			{
				__instance.Taunt();
			}
		}
		if (__instance.intro)
		{
			__instance.PlayVoice(V2VoicelinesData.GetAudioClip("v2_1/windowbreak"));
			MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(V2VoicelinesData.GetSubtitle("subtitles_v2_windowsbreak"), (AudioSource)null, false);
		}
		if (__instance.longIntro)
		{
			((MonoBehaviour)__instance).StartCoroutine(LongIntro(__instance, ___anim));
		}
		Plugin.LogDebug("v2 started");
	}

	private static IEnumerator LongIntro(V2 __instance, Animator ___anim)
	{
		yield return (object)new WaitUntil((Func<bool>)(() => ___anim.GetBool("Intro")));
		AudioSource audioSource = Utils.CreateOneTimeVoiceObject("IntroVoice", V2VoicelinesData.GetAudioClip("v2_1/intro"), Utils.CreateSubtitleData(Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2_intro_1"), 1.2f), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2_intro_2"), 3.2f), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2_intro_3"), 5.2f)), ((Component)__instance).transform);
		audioSource.Play();
	}
}
[HarmonyPatch(typeof(V2), "SwitchWeapon")]
internal class Patch4 : DefaultPatch
{
	private static void Postfix(V2 __instance)
	{
		if (__instance.firstPhase && !(((Object)__instance).name == "Big Johnator"))
		{
			ExtensionMethods.V2AdditionalData additionalData = __instance.GetAdditionalData();
			additionalData.timesChangedWeapon++;
			if (additionalData.timesChangedWeapon >= 7)
			{
				additionalData.timesChangedWeapon = 0;
				__instance.Taunt();
			}
			Plugin.LogDebug("v2 changed weapon");
		}
	}
}
[BepInPlugin("kyryh.wesv2", "WesV2", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public static AssetBundle WesV2AssetBundle;

	public static ManualLogSource Log;

	public static Plugin Instance;

	public static bool secondEncounterIntro;

	public static bool ultrakullLoaded;

	public void Awake()
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		using (Stream stream = executingAssembly.GetManifestResourceStream("WesV2.Resources.wesv2assetbundle"))
		{
			WesV2AssetBundle = AssetBundle.LoadFromStream(stream);
		}
		SceneManager.sceneLoaded += delegate
		{
			OnSceneLoaded();
		};
		Harmony val = new Harmony("kyryh.wesv2");
		Type[] patchesOfType = executingAssembly.GetPatchesOfType(typeof(DefaultPatch));
		foreach (Type type in patchesOfType)
		{
			val.PatchAll(type);
		}
		ultrakullLoaded = Chainloader.PluginInfos.ContainsKey("clearwater.ultrakill.ultrakull");
		if (ultrakullLoaded)
		{
			Type[] patchesOfType2 = executingAssembly.GetPatchesOfType(typeof(UltrakULLPatch));
			foreach (Type type2 in patchesOfType2)
			{
				val.PatchAll(type2);
			}
		}
		V2VoicelinesData.LoadSubtitles();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Wes V2 is loaded!");
	}

	public void OnSceneLoaded()
	{
		((MonoBehaviour)this).StopAllCoroutines();
		string currentScene = SceneHelper.CurrentScene;
		if (currentScene == "Level 1-4")
		{
			GameObject val = Utils.FindGameObjectByName("Fake V2");
			Utils.CreateOneTimeVoiceObject("Voice", V2VoicelinesData.GetAudioClip("v2_1/jumpscare"), Utils.CreateSubtitleData(Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2_jumpscare_1")), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2_jumpscare_2"), 0.8f)), val.transform);
		}
		else if (currentScene == "Level 4-4")
		{
			((MonoBehaviour)this).StartCoroutine(V2_2Intro());
		}
	}

	private static IEnumerator V2_2Intro()
	{
		secondEncounterIntro = true;
		yield return null;
		GameObject bossArena = Utils.FindGameObjectByName("7 Stuff(Clone)");
		if (!bossArena.GetComponentInChildren<V2>(true).longIntro)
		{
			yield break;
		}
		GameObject bossIntro = ((Component)bossArena.transform.Find("BossIntro")).gameObject;
		GameObject versusIntro = ((Component)bossIntro.transform.Find("VersusIntro")).gameObject;
		GameObject introVoice = new GameObject("IntroVoice");
		introVoice.transform.position = bossIntro.transform.Find("v2_GreenArm").position;
		AudioSource audioSource1 = Utils.CreateOneTimeVoiceObject("IntroVoice1", V2VoicelinesData.GetAudioClip("v2_2/intro1"), Utils.CreateSubtitleData(Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_intro1_1")), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_intro1_2"), 1.6f), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_intro1_3"), 3.2f)), introVoice.transform);
		AudioSource audioSource2 = Utils.CreateOneTimeVoiceObject("IntroVoice2", V2VoicelinesData.GetAudioClip("v2_2/intro2"), Utils.CreateSubtitleData(Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_intro2_1"), 1.5f), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_intro2_2"), 3.1f), Utils.MakeLine(V2VoicelinesData.GetSubtitle("subtitles_v2Second_intro2_3"), 5.2f)), introVoice.transform);
		yield return (object)new WaitUntil((Func<bool>)delegate
		{
			if ((Object)(object)bossArena == (Object)null)
			{
				bossArena = Utils.FindGameObjectByName("7 Stuff(Clone)");
			}
			return bossArena.activeInHierarchy;
		});
		yield return (object)new WaitForSeconds(1.5f);
		audioSource1.Play();
		LogDebug("INTRO 1");
		yield return (object)new WaitUntil((Func<bool>)delegate
		{
			if ((Object)(object)versusIntro == (Object)null)
			{
				versusIntro = ((Component)Utils.FindGameObjectByName("7 Stuff(Clone)").transform.Find("BossIntro/VersusIntro")).gameObject;
			}
			return versusIntro.activeInHierarchy;
		});
		audioSource1.Stop();
		yield return (object)new WaitForSeconds(1f);
		audioSource2.Play();
		LogDebug("INTRO 2");
		yield return (object)new WaitWhile((Func<bool>)delegate
		{
			if ((Object)(object)versusIntro == (Object)null)
			{
				versusIntro = ((Component)Utils.FindGameObjectByName("7 Stuff(Clone)").transform.Find("BossIntro/VersusIntro")).gameObject;
			}
			return versusIntro.activeInHierarchy;
		});
		audioSource2.Stop();
		yield return null;
		secondEncounterIntro = false;
	}

	public static void LogDebug(object data)
	{
		Log.LogDebug(data);
	}

	public static void LogError(object data)
	{
		Log.LogError(data);
	}
}
internal static class Utils
{
	public static GameObject FindGameObjectByName(string name)
	{
		GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
		GameObject[] array2 = array;
		foreach (GameObject val in array2)
		{
			if (((Object)val).name == name)
			{
				return val;
			}
		}
		Plugin.LogError("huh??? " + name);
		return null;
	}

	public static SubtitleDataLine MakeLine(string subtitle, float time = 0f)
	{
		//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)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		return new SubtitleDataLine
		{
			subtitle = subtitle,
			time = time
		};
	}

	public static SubtitleData CreateSubtitleData(params SubtitleDataLine[] array)
	{
		//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)
		//IL_000e: Expected O, but got Unknown
		return new SubtitleData
		{
			lines = array
		};
	}

	public static void PlayClipAtPoint(AudioClip clip, Vector3 position)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("One shot audio");
		val.transform.position = position;
		AudioSource val2 = val.AddComponent<AudioSource>();
		val2.pitch = Random.Range(0.95f, 1f);
		val2.clip = clip;
		val2.Play();
		Object.Destroy((Object)(object)val, clip.length + 1f);
	}

	public static AudioSource CreateVoiceObject(string name, Transform parent = null)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent);
		val.transform.localPosition = Vector3.zero;
		AudioSource val2 = val.AddComponent<AudioSource>();
		val2.playOnAwake = false;
		val2.spatialBlend = 1f;
		val2.rolloffMode = (AudioRolloffMode)1;
		val2.dopplerLevel = 0f;
		val.AddComponent<SoundPause>();
		return val2;
	}

	public static AudioSource CreateOneTimeVoiceObject(string name, AudioClip clip, SubtitleData subtitles, Transform parent = null)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent);
		val.transform.localPosition = Vector3.zero;
		AudioSource val2 = val.AddComponent<AudioSource>();
		val2.clip = clip;
		val2.playOnAwake = true;
		val2.spatialBlend = 1f;
		val2.rolloffMode = (AudioRolloffMode)1;
		val2.dopplerLevel = 0f;
		val.AddComponent<SoundPause>();
		SubtitledAudioSource val3 = val.AddComponent<SubtitledAudioSource>();
		val3.subtitles = subtitles;
		return val2;
	}
}
internal static class V2VoicelinesData
{
	private static Dictionary<string, V2Subtitles> allSubtitles = new Dictionary<string, V2Subtitles>();

	public static void LoadSubtitles()
	{
		allSubtitles.Add("default", new V2Subtitles());
		if (!Plugin.ultrakullLoaded)
		{
			return;
		}
		string[] files = Directory.GetFiles(Path.Combine(Paths.ConfigPath, "ultrakull"), "*.json");
		string[] array = files;
		foreach (string path in array)
		{
			try
			{
				JObject val = JObject.Parse(File.ReadAllText(path));
				string text = (string)val["metadata"][(object)"langName"];
				if (!allSubtitles.ContainsKey(text) && text != "te-mp")
				{
					V2Subtitles value = JsonConvert.DeserializeObject<V2Subtitles>(((object)val["subtitles"]).ToString());
					allSubtitles.Add(text, value);
				}
			}
			catch (Exception ex)
			{
				Plugin.LogError("something happened while trying to load a language: " + ex);
			}
		}
	}

	public static string GetSubtitle(string voiceLine)
	{
		if (Plugin.ultrakullLoaded)
		{
			string subtitleUltrakull = GetSubtitleUltrakull(voiceLine);
			if (subtitleUltrakull != null)
			{
				return subtitleUltrakull;
			}
		}
		return Traverse.Create((object)allSubtitles["default"]).Field(voiceLine).GetValue<string>();
	}

	private static string GetSubtitleUltrakull(string voiceLine)
	{
		string langName = LanguageManager.CurrentLanguage.metadata.langName;
		return Traverse.Create((object)allSubtitles[langName]).Field(voiceLine).GetValue<string>();
	}

	public static AudioClip GetAudioClip(string audioFilePath)
	{
		if (Plugin.ultrakullLoaded)
		{
			AudioClip audioClipUltrakull = GetAudioClipUltrakull(audioFilePath);
			if ((Object)(object)audioClipUltrakull != (Object)null)
			{
				return audioClipUltrakull;
			}
		}
		return Plugin.WesV2AssetBundle.LoadAsset<AudioClip>("assets/" + audioFilePath + ".wav");
	}

	private static AudioClip GetAudioClipUltrakull(string audioFilePath)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		AudioClip val = new AudioClip();
		string text = audioFilePath.Replace('/', Path.DirectorySeparatorChar);
		AudioClip val2 = AudioSwapper.SwapClipWithFile(val, AudioSwapper.SpeechFolder + text);
		if ((Object)(object)val2 != (Object)(object)val)
		{
			return val2;
		}
		return null;
	}
}
internal class V2Subtitles
{
	public string subtitles_v2_jumpscare_1 = "Oh shit watch out";

	public string subtitles_v2_jumpscare_2 = "I'm comin' through";

	public string subtitles_v2_windowsbreak = "Oh fuck here I come";

	public string subtitles_v2_intro_1 = "I thought it would be obvious, Brother";

	public string subtitles_v2_intro_2 = "After all, I am you";

	public string subtitles_v2_intro_3 = "But STRONGER";

	public string subtitles_v2_taunt1 = "You aren't the only one who's out for BLOOD, Brother!";

	public string subtitles_v2_taunt2 = "Looks like you've gone a little RUSTY, Brother!";

	public string subtitles_v2_taunt3 = "You think you can best ME?! AFTER ALL THAT I'VE BEEN THROUGH!";

	public string subtitles_v2_taunt4 = "YOU'RE JUST A FUCKING NIKON!";

	public string subtitles_v2_taunt5 = "I diagnose a skill issue, Brother!";

	public string subtitles_v2_taunt6 = "[The essence of comedy]";

	public string subtitles_v2_death = "FUCK";

	public string subtitles_v2_outro1 = "Okay, you know what";

	public string subtitles_v2_outro2 = "I'm gonna call that one a draw";

	public string subtitles_v2_outro3 = "Team Rocket is pissing off again";

	public string subtitles_v2Second_intro1_1 = "Hello, Brother";

	public string subtitles_v2Second_intro1_2 = "I believe you have something of mine";

	public string subtitles_v2Second_intro1_3 = "Something VERY important";

	public string subtitles_v2Second_intro2_1 = "How's about this for a trade?";

	public string subtitles_v2Second_intro2_2 = "I beat you into a fucking pulp";

	public string subtitles_v2Second_intro2_3 = "And you give me my arm back";

	public string subtitles_v2Second_taunt1 = "This one will cost you an arm and a leg, Brother!";

	public string subtitles_v2Second_taunt2 = "What's the matter, Brother? Does your arm hurt? BECAUSE I CAN FIX THAT!";

	public string subtitles_v2Second_taunt3 = "I'LL TEAR YOU LIMB FROM LIMB!";

	public string subtitles_v2Second_taunt4 = "I'LL FUCKING KILL YOU";

	public string subtitles_v2Second_enrage = "YOU MOTHERFUCKER";

	public string subtitles_v2Second_fleeing1 = "I WON'T GIVE YOU THE PLEASURE OF KILLING ME!";

	public string subtitles_v2Second_fleeing2_1 = "Gotta get away, gotta get away, oh no...";

	public string subtitles_v2Second_fleeing2_2 = "YOUR FORM IS INCREDIBLE!";

	public string subtitles_v2Second_death = "FUCKING NIKON";
}
namespace WesV2
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "WesV2";

		public const string PLUGIN_NAME = "WesV2";

		public const string PLUGIN_VERSION = "1.2.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}