Decompiled source of HS PongRevival v0.0.1

plugins/HS_PongRevival/HS_PongRevival.dll

Decompiled 2 weeks ago
using System;
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 BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ScheduleOne.TV;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("UnityEngine.AssetBundleModule")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HS")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: AssemblyInformationalVersion("0.0.3")]
[assembly: AssemblyProduct("HS_PongRevival")]
[assembly: AssemblyTitle("HS_PongRevival")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.3.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
internal sealed class ConfigurationManagerAttributes
{
	public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
namespace HS_PongRevival
{
	[BepInPlugin("HS_PongRevival", "HS_PongRevival", "0.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(TVHomeScreen))]
		public class TVHomeScreen_Awake_Patch
		{
			public static void OpenPong(TVHomeScreen homeScreen)
			{
				Pong component = ((Component)((Component)homeScreen).transform.parent.Find("Pong")).gameObject.GetComponent<Pong>();
				if (!((Object)(object)component == (Object)null))
				{
					((TVApp)component).PreviousScreen = (TVApp)(object)homeScreen;
					homeScreen.skipExit = true;
					((TVApp)homeScreen).Close();
					((TVApp)component).Open();
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("Awake")]
			public static void Postfix(TVHomeScreen __instance)
			{
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Expected O, but got Unknown
				//IL_01be: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0205: Expected O, but got Unknown
				TVHomeScreen __instance2 = __instance;
				GameObject gameObject = ((Component)((Component)__instance2).gameObject.transform.root).gameObject;
				Transform val = gameObject.transform.Find("TV cabinet/retro_console_main");
				Transform val2 = gameObject.transform.Find("TV cabinet/retro_console_joystick");
				Transform val3 = gameObject.transform.Find("TV cabinet/retro_console_joystick (1)");
				if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null)
				{
					((Component)val).gameObject.SetActive(true);
					((Component)val2).gameObject.SetActive(true);
					((Component)val3).gameObject.SetActive(true);
				}
				try
				{
					GameObject val4 = Object.Instantiate<GameObject>(__instance2.AppButtonPrefab, (Transform)(object)__instance2.AppButtonContainer);
					Transform parent = ((Component)__instance2).transform.Find("AppButtons");
					val4.transform.SetParent(parent);
					Texture2D val5 = new Texture2D(2, 2);
					string text = Path.Combine(Paths.PluginPath, "HS_PongRevival", "assets", "Pong.png");
					if (!File.Exists(text))
					{
						Logger.LogError((object)("Pong App Icon not found at: " + text));
						return;
					}
					if (!ImageConversion.LoadImage(val5, File.ReadAllBytes(text)))
					{
						Logger.LogError((object)("Failed to load Pong App Icon as texture at path: " + text));
						return;
					}
					Transform obj = val4.transform.Find("Icon");
					Image val6 = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
					Transform obj2 = val4.transform.Find("Name");
					TextMeshProUGUI val7 = ((obj2 != null) ? ((Component)obj2).GetComponent<TextMeshProUGUI>() : null);
					if ((Object)(object)val6 != (Object)null && (Object)(object)val7 != (Object)null)
					{
						val6.sprite = Sprite.Create(val5, new Rect(0f, 0f, (float)((Texture)val5).width, (float)((Texture)val5).height), new Vector2(0.5f, 0.5f));
						((TMP_Text)val7).text = "Pong";
						((UnityEvent)val4.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
						{
							OpenPong(__instance2);
						});
					}
					else
					{
						Logger.LogError((object)"TV App Button components not found.");
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Unable to Add Pong App to TV Screen. Error: " + ex.Message));
				}
			}
		}

		public static readonly ManualLogSource Logger = Logger.CreateLogSource("HS_PongRevival");

		public void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("HS_PongRevival").PatchAll(Assembly.GetExecutingAssembly());
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "HS_PongRevival";

		public const string PLUGIN_NAME = "HS_PongRevival";

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