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 BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("IAmMrBeast")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("IAmMrBeast")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f38f453f-340a-4d50-ab06-fb07100e24d4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace IAmMrBeast;
[BepInPlugin("kestrel.iamyourbeast.iammrbeast", "I Am Mr Beast", "1.0.0")]
public class Mod : BaseUnityPlugin
{
[HarmonyPatch(typeof(UIStartScreenRoot))]
public class StartScreenPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
public static void Prefix(RectTransform ___title)
{
im = ((Component)___title).gameObject.GetComponentInChildren<RawImage>();
if (Object.op_Implicit((Object)(object)titleImage))
{
im.texture = (Texture)(object)titleImage;
}
}
}
[HarmonyPatch(typeof(UISceneTransitionHardCut))]
public class HardCutPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
public static void Prefix(ref Image ___logo)
{
if (Object.op_Implicit((Object)(object)imAsSprite))
{
___logo.sprite = imAsSprite;
}
}
}
[HarmonyPatch(typeof(UIPauseMenu))]
public class PauseMenuPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
public static void Prefix(ref UIPauseMenu __instance)
{
if (Object.op_Implicit((Object)(object)titleImage))
{
GameObject gameObject = ((Component)((Component)__instance).transform.Find("Canvas/Corner Anchor/Logo")).gameObject;
gameObject.GetComponent<RawImage>().texture = (Texture)(object)titleImage;
}
}
}
public const string pluginGuid = "kestrel.iamyourbeast.iammrbeast";
public const string pluginName = "I Am Mr Beast";
public const string pluginVersion = "1.0.0";
internal static ManualLogSource Logger;
private static string pluginPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
private static string imgPath = Path.Combine(pluginPath, "title.png");
private static Texture2D titleImage;
private static RawImage im;
private static Sprite imAsSprite;
public void Awake()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Finding logo texture...");
((MonoBehaviour)this).StartCoroutine(GetAndReplaceLogo());
new Harmony("kestrel.iamyourbeast.iammrbeast").PatchAll();
Logger.LogInfo((object)"Hiiiiiiiiiiii :3");
}
private IEnumerator GetAndReplaceLogo()
{
UnityWebRequest uwr = UnityWebRequestTexture.GetTexture("file:///" + imgPath);
try
{
yield return uwr.SendWebRequest();
if ((int)uwr.result != 1)
{
Logger.LogError((object)("Error while loading image ~ " + uwr.error + " ~ Unpatching..."));
Harmony.UnpatchID("kestrel.iamyourbeast.iammrbeast");
yield break;
}
Logger.LogInfo((object)"Found and loaded logo texture!");
yield return (object)new WaitUntil((Func<bool>)(() => Object.op_Implicit((Object)(object)im)));
titleImage = DownloadHandlerTexture.GetContent(uwr);
im.texture = (Texture)(object)titleImage;
imAsSprite = Sprite.Create(titleImage, new Rect(0f, 0f, (float)((Texture)titleImage).width, (float)((Texture)titleImage).height), Vector2.zero);
Logger.LogInfo((object)"Replaced logo!");
}
finally
{
((IDisposable)uwr)?.Dispose();
}
}
}