Decompiled source of PixeledBopl v1.0.0

pixeledbopl.dll

Decompiled 12 hours 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 HarmonyLib;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("pixeledbopl")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("pixeledbopl")]
[assembly: AssemblyTitle("pixeledbopl")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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;
		}
	}
}
namespace pixeledbopl
{
	[BepInPlugin("com.erwer.pixeledbopl", "pixeledbopl", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "com.erwer.pixeledbopl";

		public const string PLUGIN_NAME = "pixeledbopl";

		public const string PLUGIN_VERSION = "1.0.0";

		private static Shader pixelArtShader;

		public static Material pixelArtMaterial;

		private AssetBundle pixelArtAssetBundle;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.erwer.pixeledbopl is loaded!");
			Harmony val = new Harmony("com.erwer.pixeledbopl");
			val.PatchAll(typeof(Patches));
			LoadAssetBundle();
			LoadPixelArtShader();
		}

		private void Update()
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			Camera[] array = Object.FindObjectsOfType<Camera>();
			Camera[] array2 = array;
			Scene val2;
			foreach (Camera val in array2)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject.GetComponent<CameraEffect>() == (Object)null)
				{
					((Component)val).gameObject.AddComponent<CameraEffect>();
					Debug.Log((object)("Added Camera Effect to " + ((Object)((Component)val).gameObject).name));
				}
				else if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject.GetComponent<CameraEffect>() != (Object)null)
				{
					Scene activeScene = SceneManager.GetActiveScene();
					val2 = activeScene;
					if (((Scene)(ref val2)).name == "ChSelect_online" || GameSessionHandler.HasGameEnded())
					{
						((Behaviour)((Component)val).gameObject.GetComponent<CameraEffect>()).enabled = false;
					}
					else
					{
						((Behaviour)((Component)val).gameObject.GetComponent<CameraEffect>()).enabled = true;
					}
				}
			}
			val2 = SceneManager.GetActiveScene();
			Debug.Log((object)((Scene)(ref val2)).name);
		}

		private void LoadAssetBundle()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "shaderpixel");
			Debug.Log((object)text);
			pixelArtAssetBundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)pixelArtAssetBundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load AssetBundle!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"AssetBundle loaded successfully!");
			}
		}

		private void LoadPixelArtShader()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			if ((Object)(object)pixelArtAssetBundle != (Object)null)
			{
				pixelArtShader = pixelArtAssetBundle.LoadAsset<Shader>("Pixelation");
				if ((Object)(object)pixelArtShader != (Object)null)
				{
					pixelArtMaterial = new Material(pixelArtShader);
					pixelArtMaterial.SetFloat("_PixelSize", 0.002f);
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Pixel Art Shader loaded successfully!");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Pixel Art Shader not found in AssetBundle!");
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)pixelArtAssetBundle != (Object)null)
			{
				pixelArtAssetBundle.Unload(false);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"AssetBundle unloaded successfully!");
			}
		}
	}
	public class CameraEffect : MonoBehaviour
	{
		private void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			if ((Object)(object)Plugin.pixelArtMaterial != (Object)null)
			{
				Debug.Log((object)"Doing pixely art :3");
				Graphics.Blit((Texture)(object)source, destination, Plugin.pixelArtMaterial);
			}
			else
			{
				Graphics.Blit((Texture)(object)source, destination);
			}
		}
	}
	public class Patches
	{
		[HarmonyPatch(typeof(CharacterSelectHandler_online), "Awake")]
		private static void Prefix(CharacterSelectBox __instance)
		{
			CharacterSelectHandler_online.clientSideMods_you_can_increment_this_to_enable_matchmaking_for_your_mods__please_dont_use_it_to_cheat_thats_really_cringe_especially_if_its_desyncing_others___you_didnt_even_win_on_your_opponents_screen___I_cannot_imagine_a_sadder_existence += 2;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "pixeledbopl";

		public const string PLUGIN_NAME = "pixeledbopl";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}