using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
public class CarouselBase : MonoBehaviour
{
[CompilerGenerated]
private sealed class <MonitorTextToCheck>d__12 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public CarouselBase <>4__this;
private string <lastValue>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MonitorTextToCheck>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<lastValue>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
CarouselBase carouselBase = <>4__this;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
}
else
{
<>1__state = -1;
<lastValue>5__2 = null;
}
string text = carouselBase.textToCheck.text;
if (text != <lastValue>5__2)
{
<lastValue>5__2 = text;
bool flag = text == carouselBase.textTriggerValue;
if (flag != carouselBase.halfModeEnabled)
{
carouselBase.SetHalfMode(flag);
}
}
<>2__current = null;
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[Header("UI Elements")]
[SerializeField]
private TMP_Text selectedText;
[SerializeField]
private Button leftArrow;
[SerializeField]
private Button rightArrow;
[Header("Options")]
[SerializeField]
private string[] options;
[Header("Half Mode Settings (Optional)")]
[SerializeField]
private bool enableHalfModeBehavior;
[SerializeField]
private TMP_Text textToCheck;
[SerializeField]
private string textTriggerValue;
private string[] fullOptions;
private string[] currentOptions;
private int currentIndex;
private bool halfModeEnabled;
private void Awake()
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
if ((Object)(object)leftArrow == (Object)null || (Object)(object)rightArrow == (Object)null || (Object)(object)selectedText == (Object)null)
{
Debug.LogError((object)"CarouselBase: Missing UI elements! Drag them in the Inspector.");
((Behaviour)this).enabled = false;
return;
}
if (enableHalfModeBehavior && (Object)(object)textToCheck == (Object)null)
{
Debug.LogError((object)"CarouselBase: Half Mode enabled but textToCheck is not assigned.");
((Behaviour)this).enabled = false;
return;
}
if (options == null || options.Length == 0)
{
Debug.LogWarning((object)"CarouselBase: No options set in the Inspector!");
fullOptions = new string[0];
}
else
{
fullOptions = options;
}
currentOptions = fullOptions;
((UnityEventBase)leftArrow.onClick).RemoveAllListeners();
((UnityEventBase)rightArrow.onClick).RemoveAllListeners();
((UnityEvent)leftArrow.onClick).AddListener(new UnityAction(GoLeft));
((UnityEvent)rightArrow.onClick).AddListener(new UnityAction(GoRight));
UpdateText();
if (enableHalfModeBehavior)
{
((MonoBehaviour)this).StartCoroutine(MonitorTextToCheck());
}
}
[IteratorStateMachine(typeof(<MonitorTextToCheck>d__12))]
private IEnumerator MonitorTextToCheck()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MonitorTextToCheck>d__12(0)
{
<>4__this = this
};
}
private void SetHalfMode(bool enable)
{
if (enable && !halfModeEnabled)
{
currentIndex = 0;
}
halfModeEnabled = enable;
UpdateOptionsArray();
currentIndex = Mathf.Clamp(currentIndex, 0, currentOptions.Length - 1);
UpdateText();
}
private void UpdateOptionsArray()
{
if (halfModeEnabled && enableHalfModeBehavior && fullOptions.Length != 0)
{
int num = Mathf.Max(1, fullOptions.Length / 2);
currentOptions = new string[num];
Array.Copy(fullOptions, currentOptions, num);
}
else
{
currentOptions = fullOptions;
}
}
public void GoLeft()
{
if (currentOptions == null || currentOptions.Length == 0)
{
Debug.LogWarning((object)"CarouselBase: No options to scroll through!");
return;
}
currentIndex--;
if (currentIndex < 0)
{
currentIndex = currentOptions.Length - 1;
}
UpdateText();
}
public void GoRight()
{
if (currentOptions == null || currentOptions.Length == 0)
{
Debug.LogWarning((object)"CarouselBase: No options to scroll through!");
return;
}
currentIndex++;
if (currentIndex >= currentOptions.Length)
{
currentIndex = 0;
}
UpdateText();
}
private void UpdateText()
{
if (currentOptions == null || currentOptions.Length == 0)
{
selectedText.text = "Nothing here!";
}
else
{
selectedText.text = currentOptions[currentIndex];
}
}
}
public class HoofTVBase : MonoBehaviour
{
public enum ResolutionOption
{
R480p = 480,
R720p = 720,
R1080p = 1080
}
[Header("UI Elements")]
[SerializeField]
private TMP_Text seasonLabel;
[SerializeField]
private TMP_Text episodeLabel;
[SerializeField]
private Canvas canvas;
[Header("Screen & Video")]
[SerializeField]
private GameObject screenToEnable;
[SerializeField]
private GameObject warningText;
[Header("Control Buttons (Hidden initially)")]
[SerializeField]
private Button startButton;
[SerializeField]
private Button stopButton;
[SerializeField]
private Button pauseButton;
[SerializeField]
private Button resumeButton;
[Header("Audio")]
[SerializeField]
private AudioMixerGroup audioOutputGroup;
private VideoPlayer videoPlayer;
private RenderTexture targetRenderTexture;
private ResolutionOption currentResolution = ResolutionOption.R720p;
private void Awake()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Expected O, but got Unknown
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Expected O, but got Unknown
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Expected O, but got Unknown
if ((Object)(object)startButton != (Object)null)
{
((UnityEvent)startButton.onClick).AddListener(new UnityAction(OnStartClicked));
}
if ((Object)(object)stopButton != (Object)null)
{
((Component)stopButton).gameObject.SetActive(false);
((UnityEvent)stopButton.onClick).AddListener(new UnityAction(OnStopClicked));
}
if ((Object)(object)pauseButton != (Object)null)
{
((Component)pauseButton).gameObject.SetActive(false);
((UnityEvent)pauseButton.onClick).AddListener(new UnityAction(OnPauseClicked));
}
if ((Object)(object)resumeButton != (Object)null)
{
((Component)resumeButton).gameObject.SetActive(false);
((UnityEvent)resumeButton.onClick).AddListener(new UnityAction(OnResumeClicked));
}
if ((Object)(object)canvas != (Object)null)
{
canvas.worldCamera = Camera.main;
}
videoPlayer = ((Component)this).gameObject.AddComponent<VideoPlayer>();
videoPlayer.renderMode = (VideoRenderMode)2;
videoPlayer.audioOutputMode = (VideoAudioOutputMode)2;
AudioSource val = ((Component)this).gameObject.AddComponent<AudioSource>();
val.outputAudioMixerGroup = audioOutputGroup;
videoPlayer.SetTargetAudioSource((ushort)0, val);
videoPlayer.loopPointReached += new EventHandler(OnVideoEnd);
videoPlayer.prepareCompleted += new EventHandler(OnPrepareCompleted);
if ((Object)(object)screenToEnable != (Object)null)
{
screenToEnable.SetActive(false);
}
}
private void OnStopClicked()
{
if (videoPlayer.isPlaying)
{
videoPlayer.Stop();
}
if ((Object)(object)screenToEnable != (Object)null)
{
screenToEnable.SetActive(false);
}
((Component)stopButton).gameObject.SetActive(false);
((Component)pauseButton).gameObject.SetActive(false);
((Component)resumeButton).gameObject.SetActive(false);
((Component)startButton).gameObject.SetActive(true);
}
private void OnPauseClicked()
{
if (videoPlayer.isPlaying)
{
videoPlayer.Pause();
((Component)pauseButton).gameObject.SetActive(false);
((Component)resumeButton).gameObject.SetActive(true);
}
}
private void OnResumeClicked()
{
if (!videoPlayer.isPlaying)
{
videoPlayer.Play();
((Component)resumeButton).gameObject.SetActive(false);
((Component)pauseButton).gameObject.SetActive(true);
}
}
private void OnStartClicked()
{
int num = ParseLabelNumber(seasonLabel.text);
int num2 = ParseLabelNumber(episodeLabel.text);
if (num <= 0 || num2 <= 0)
{
Debug.LogWarning((object)"Season or Episode label is not a valid positive integer.");
return;
}
currentResolution = ResolutionOption.R720p;
CreateOrRecreateRenderTexture((int)currentResolution);
if (num == 3 && num2 > 13)
{
warningText.SetActive(true);
Debug.LogWarning((object)"Season 3 only has 13 episodes.");
return;
}
string text = GenerateUrl(num, num2, (int)currentResolution);
Debug.Log((object)("Starting video playback: " + text));
PlayVideo(text);
warningText.SetActive(false);
((Component)startButton).gameObject.SetActive(false);
((Component)stopButton).gameObject.SetActive(true);
((Component)pauseButton).gameObject.SetActive(true);
((Component)resumeButton).gameObject.SetActive(true);
}
private void CreateOrRecreateRenderTexture(int verticalResolution)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
int num = verticalResolution * 16 / 9;
if ((Object)(object)targetRenderTexture != (Object)null)
{
if (((Texture)targetRenderTexture).width == num && ((Texture)targetRenderTexture).height == verticalResolution)
{
return;
}
videoPlayer.targetTexture = null;
targetRenderTexture.Release();
Object.Destroy((Object)(object)targetRenderTexture);
}
targetRenderTexture = new RenderTexture(num, verticalResolution, 0, (RenderTextureFormat)0);
targetRenderTexture.Create();
videoPlayer.targetTexture = targetRenderTexture;
if ((Object)(object)screenToEnable != (Object)null)
{
Renderer component = screenToEnable.GetComponent<Renderer>();
if ((Object)(object)component != (Object)null)
{
component.material.mainTexture = (Texture)(object)targetRenderTexture;
}
}
}
private int ParseLabelNumber(string label)
{
string[] array = label.Split(' ');
for (int i = 0; i < array.Length; i++)
{
if (int.TryParse(array[i], out var result))
{
return result;
}
}
return -1;
}
private string GenerateUrl(int season, int episode, int resolution)
{
return $"https://static.heartshine.gay/g4-fim/s{season:D2}e{episode:D2}-{resolution}p.mp4";
}
private void OnPrepareCompleted(VideoPlayer vp)
{
vp.Play();
if ((Object)(object)screenToEnable != (Object)null)
{
screenToEnable.SetActive(true);
}
}
private void PlayVideo(string url)
{
if (videoPlayer.isPlaying)
{
videoPlayer.Stop();
}
videoPlayer.url = url;
videoPlayer.Prepare();
}
private void OnVideoEnd(VideoPlayer vp)
{
if ((Object)(object)screenToEnable != (Object)null)
{
screenToEnable.SetActive(false);
}
if ((Object)(object)stopButton != (Object)null)
{
((Component)stopButton).gameObject.SetActive(false);
}
if ((Object)(object)pauseButton != (Object)null)
{
((Component)pauseButton).gameObject.SetActive(false);
}
if ((Object)(object)resumeButton != (Object)null)
{
((Component)resumeButton).gameObject.SetActive(false);
}
((Component)startButton).gameObject.SetActive(true);
}
private void OnDestroy()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if ((Object)(object)videoPlayer != (Object)null)
{
videoPlayer.loopPointReached -= new EventHandler(OnVideoEnd);
}
if ((Object)(object)targetRenderTexture != (Object)null)
{
targetRenderTexture.Release();
Object.Destroy((Object)(object)targetRenderTexture);
}
}
}
namespace HoofTV
{
[BepInPlugin("com.NOTHANKYOU.hooftv", "HoofTV", "1.0.0")]
public class HoofTVPlugin : BaseUnityPlugin
{
public class CoroutineRunner : MonoBehaviour
{
private static CoroutineRunner _instance;
public static CoroutineRunner Instance
{
get
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if ((Object)(object)_instance == (Object)null)
{
GameObject val = new GameObject("CoroutineRunner");
Object.DontDestroyOnLoad((Object)val);
_instance = val.AddComponent<CoroutineRunner>();
}
return _instance;
}
}
}
[HarmonyPatch(typeof(StockMapInfo), "Awake")]
internal class Magic
{
[CompilerGenerated]
private sealed class <LoadAndInstantiatePrefab>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private AsyncOperationHandle<GameObject> <handle>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAndInstantiatePrefab>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
<handle>5__2 = default(AsyncOperationHandle<GameObject>);
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Invalid comparison between Unknown and I4
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<handle>5__2 = Addressables.LoadAssetAsync<GameObject>((object)"f1ff75d10ab733a4fb4a7d0abb3c170a");
<>2__current = <handle>5__2;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((int)<handle>5__2.Status == 1)
{
GameObject result = <handle>5__2.Result;
Object.Instantiate<GameObject>(result, result.transform.position, result.transform.rotation);
Debug.Log((object)$"HoofTV: TV prefab instantiated at {result.transform.position}.");
}
else
{
Debug.LogError((object)"HoofTV: Failed to load TV prefab.");
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static void Postfix(StockMapInfo __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name.StartsWith("7b3cb6a0a"))
{
((MonoBehaviour)CoroutineRunner.Instance).StartCoroutine(LoadAndInstantiatePrefab());
}
}
[IteratorStateMachine(typeof(<LoadAndInstantiatePrefab>d__1))]
private static IEnumerator LoadAndInstantiatePrefab()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAndInstantiatePrefab>d__1(0);
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass4_0
{
public AsyncOperationHandle<IResourceLocator> addressableHandle;
internal bool <loadHoofTVAddr>b__0()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Invalid comparison between Unknown and I4
if (!addressableHandle.IsDone)
{
return (int)addressableHandle.Status == 2;
}
return true;
}
}
[CompilerGenerated]
private sealed class <loadHoofTVAddr>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private <>c__DisplayClass4_0 <>8__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <loadHoofTVAddr>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Invalid comparison between Unknown and I4
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Invalid comparison between Unknown and I4
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
<>8__1 = new <>c__DisplayClass4_0();
string text = Path.Combine(addrDataPath, "catalog.json");
string text2 = Path.Combine(addrDataPath, "patched_catalog.json");
if (!File.Exists(text))
{
Debug.LogError((object)("HoofTV: Catalog file not found at: " + text));
return false;
}
try
{
JObject val = JObject.Parse(File.ReadAllText(text));
string text3 = "{AngryLevelLoader.Plugin.tempFolderPath}\\\\";
string newValue = addrDataPath.Replace("\\", "\\\\") + "\\\\";
JToken val2 = ((JToken)val).SelectToken("m_InternalIds");
if (val2 != null && (int)val2.Type == 2)
{
JArray val3 = (JArray)val2;
for (int i = 0; i < ((JContainer)val3).Count; i++)
{
string text4 = ((object)val3[i]).ToString();
if (text4.Contains(text3))
{
val3[i] = JToken.op_Implicit(text4.Replace(text3, newValue));
}
}
}
File.WriteAllText(text2, ((JToken)val).ToString((Formatting)1, Array.Empty<JsonConverter>()));
Debug.Log((object)"HoofTV: Patched catalog created successfully.");
}
catch (Exception ex)
{
Debug.LogError((object)("HoofTV: Error while patching catalog: " + ex.Message));
return false;
}
Debug.Log((object)("HoofTV: Loading patched catalog from: " + text2));
<>8__1.addressableHandle = Addressables.LoadContentCatalogAsync(text2, false, (string)null);
Debug.Log((object)$"HoofTV: hi {<>8__1.addressableHandle.Status}");
<>2__current = (object)new WaitUntil((Func<bool>)(() => <>8__1.addressableHandle.IsDone || (int)<>8__1.addressableHandle.Status == 2));
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
if ((int)<>8__1.addressableHandle.Status == 1)
{
Debug.Log((object)"HoofTV: Catalog loaded successfully.");
}
else
{
Debug.LogError((object)$"HoofTV: Failed to load patched catalog: {<>8__1.addressableHandle.OperationException}");
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private bool isCatalogLoaded;
public static string addrDataPath = Path.Combine(ModPath(), "Addressable");
public static string ModPath()
{
return Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf(Path.DirectorySeparatorChar));
}
private void Awake()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogInfo((object)"HoofTV: neigh");
if (!isCatalogLoaded)
{
((MonoBehaviour)this).StartCoroutine(loadHoofTVAddr());
isCatalogLoaded = true;
}
new Harmony("com.NOTHANKYOU.hooftv").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"HoofTV: Harmony patches applied.");
}
[IteratorStateMachine(typeof(<loadHoofTVAddr>d__4))]
private IEnumerator loadHoofTVAddr()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <loadHoofTVAddr>d__4(0);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}