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 ReplaceTVSurprise.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ReplaceTVSurprise")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReplaceTVSurprise")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3232facc-53e4-4640-88e4-55036639069c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ReplaceTVSurprise
{
[BepInPlugin("Pappis.TutorialModBase", "Replace TV Surprise", "1.0.0")]
public class ReplaceTVSurpriseBase : BaseUnityPlugin
{
private const string modGUID = "Pappis.TutorialModBase";
private const string modName = "Replace TV Surprise";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Pappis.TutorialModBase");
public static Texture2D texture;
internal ManualLogSource mls;
private void Awake()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
string text = Path.Combine(Paths.PluginPath, "ReplaceTVJumpscare", "ReplaceTVJumpscareMod", "assets", "customTexture.png");
if (File.Exists(text))
{
byte[] array = File.ReadAllBytes(text);
texture = new Texture2D(2, 2);
ImageConversion.LoadImage(texture, array);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded customTexture.png");
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)("Texture not found at: " + text));
}
mls = Logger.CreateLogSource("Pappis.TutorialModBase");
mls.LogInfo((object)"The test mod has woken melad");
harmony.PatchAll(typeof(ReplaceTVSurpriseBase));
harmony.PatchAll(typeof(RegularPlaneTVPatch));
}
}
}
namespace ReplaceTVSurprise.Patches
{
[HarmonyPatch(typeof(FlatScreenTV))]
internal class RegularPlaneTVPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void ChangeTVJumpscarePatch(ref FlatScreenTV __instance)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
Texture2D texture = ReplaceTVSurpriseBase.texture;
Transform regularPlane = __instance.regularPlane;
if (!((Object)(object)texture == (Object)null) && !((Object)(object)regularPlane == (Object)null))
{
Renderer component = ((Component)regularPlane).GetComponent<Renderer>();
if ((Object)(object)component != (Object)null)
{
Material val = new Material(component.material);
val.mainTexture = (Texture)(object)texture;
component.material = val;
}
}
}
}
}