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 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";
internal static ConfigFile config;
internal static ConfigEntry<float> pixelation;
internal static ConfigEntry<bool> slime_trail;
private static Shader pixelArtShader;
public static Material pixelArtMaterial;
private AssetBundle pixelArtAssetBundle;
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
config = ((BaseUnityPlugin)this).Config;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.erwer.pixeledbopl is loaded!");
Harmony val = new Harmony("com.erwer.pixeledbopl");
val.PatchAll(typeof(Patches));
pixelation = config.Bind<float>("Settings", "Pixelation", 0.0015f, new ConfigDescription("Higher = Less Pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 0.01f), Array.Empty<object>()));
slime_trail = config.Bind<bool>("Settings", "SlimeTrail", false, new ConfigDescription("Causes slime trails to blend colors with terrain, don't recommend", (AcceptableValueBase)null, Array.Empty<object>()));
LoadAssetBundle();
LoadPixelArtShader();
}
private void Update()
{
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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 (!slime_trail.Value && ((Object)((Component)val).gameObject).name.Contains("SlimeTrailCam"))
{
continue;
}
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))
{
continue;
}
Scene activeScene = SceneManager.GetActiveScene();
val2 = activeScene;
if (!(((Scene)(ref val2)).name == "CharacterSelect"))
{
val2 = activeScene;
if (!(((Scene)(ref val2)).name == "ChSelect_online") && !GameSessionHandler.HasGameEnded())
{
((Behaviour)((Component)val).gameObject.GetComponent<CameraEffect>()).enabled = true;
continue;
}
}
((Behaviour)((Component)val).gameObject.GetComponent<CameraEffect>()).enabled = false;
}
}
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", pixelation.Value);
((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";
}
}