Decompiled source of VisorWipers v1.0.0

VisorWipers.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GTFO.API;
using GTFO.API.Utilities;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using TheArchive;
using TheArchive.Core;
using TheArchive.Core.Attributes.Feature;
using TheArchive.Core.Attributes.Feature.Members;
using TheArchive.Core.Attributes.Feature.Settings;
using TheArchive.Core.FeaturesAPI;
using TheArchive.Core.Localization;
using TheArchive.Interfaces;
using UnityEngine;
using VisorWipers.Archive;
using VisorWipers.Vanilla;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("VisorWipers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ccc961d37e84bcf1b9f01592adbb82076e18ddb0")]
[assembly: AssemblyProduct("VisorWipers")]
[assembly: AssemblyTitle("VisorWipers")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace VisorWipers
{
	internal static class DinoLogger
	{
		private static ManualLogSource logger = Logger.CreateLogSource("VisorWipers");

		public static void Log(string format, params object[] args)
		{
			Log(string.Format(format, args));
		}

		public static void Log(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)8, (object)str);
			}
		}

		public static void Warning(string format, params object[] args)
		{
			Warning(string.Format(format, args));
		}

		public static void Warning(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)4, (object)str);
			}
		}

		public static void Error(string format, params object[] args)
		{
			Error(string.Format(format, args));
		}

		public static void Error(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)2, (object)str);
			}
		}

		public static void Debug(string format, params object[] args)
		{
			Debug(string.Format(format, args));
		}

		public static void Debug(string str)
		{
			if (logger != null)
			{
				logger.Log((LogLevel)32, (object)str);
			}
		}
	}
	[BepInPlugin("Dinorush.VisorWipers", "VisorWipers", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal sealed class EntryPoint : BasePlugin
	{
		public const string MODNAME = "VisorWipers";

		public const string ARCHIVE_GUID = "dev.AuriRex.gtfo.TheArchive";

		public override void Load()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("dev.AuriRex.gtfo.TheArchive"))
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				bool flag = default(bool);
				BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(54, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("The Archive detected. Using archive version instead...");
				}
				log.LogMessage(val);
				LoadArchive();
			}
			else
			{
				Configuration.Init();
				AssetAPI.OnStartupAssetsLoaded += OnStartupAssetsLoaded;
				((BasePlugin)this).Log.LogMessage((object)"Loaded VisorWipers");
			}
		}

		private void OnStartupAssetsLoaded()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			ClassInjector.RegisterTypeInIl2Cpp<WiperHandler>();
			GameObject val = new GameObject("VisorWipers");
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<WiperHandler>();
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void LoadArchive()
		{
			VisorWiperModule.Load();
		}
	}
	public static class WipeTheVoid
	{
		private static readonly Array DefaultParticle;

		private const int ParticleCount = 1024;

		static WipeTheVoid()
		{
			DefaultParticle = ((Il2CppObjectBase)Il2CppStructArray<particleData>.op_Implicit((particleData[])(object)new particleData[1024])).Cast<Array>();
		}

		public static void Wipe()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (ScreenLiquidManager.hasSystem)
			{
				GlassLiquidSystem liquidSystem = ScreenLiquidManager.LiquidSystem;
				liquidSystem.cbParticles.SetData(DefaultParticle);
				liquidSystem.particleWrap = 0;
				Graphics.SetRenderTarget(liquidSystem.rtParams);
				GL.Clear(false, true, Color.clear);
				Graphics.SetRenderTarget(liquidSystem.rtParams_db);
				GL.Clear(false, true, Color.clear);
				Graphics.SetRenderTarget(liquidSystem.rtColor);
				GL.Clear(false, true, Color.clear);
				Graphics.SetRenderTarget(liquidSystem.rtColor_db);
				GL.Clear(false, true, Color.clear);
				Graphics.SetRenderTarget((RenderTexture)null);
			}
		}
	}
}
namespace VisorWipers.Vanilla
{
	internal static class Configuration
	{
		private static ConfigEntry<KeyCode> _wiperKeyBind;

		private static ConfigFile _configFile;

		public static KeyCode WiperKeyBind => _wiperKeyBind.Value;

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			_configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "VisorWipers.cfg"), true);
			string text = "Keybinds";
			_wiperKeyBind = _configFile.Bind<KeyCode>(text, "Wiper Keybind", (KeyCode)283, "The keybind for your visor wipers.\nPressing it wipes the screen of liquids and grime.");
			LiveEdit.CreateListener(Paths.ConfigPath, "VisorWipers.cfg", false).FileChanged += new LiveEditEventHandler(OnFileChanged);
		}

		private static void OnFileChanged(LiveEditEventArgs _)
		{
			_configFile.Reload();
		}
	}
	public sealed class WiperHandler : MonoBehaviour
	{
		public WiperHandler(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if ((int)FocusStateManager.CurrentState == 4 && Input.GetKeyDown(Configuration.WiperKeyBind))
			{
				WipeTheVoid.Wipe();
			}
		}
	}
}
namespace VisorWipers.Archive
{
	[EnableFeatureByDefault]
	public class VisorWipersFeature : Feature
	{
		public class VisorWipersSettings
		{
			[FSDisplayName("Wiper Keybind")]
			[FSDescription("Key used to wipe the screen.")]
			public KeyCode Key { get; set; } = (KeyCode)283;

		}

		public override string Name => "Visor Wipers";

		public override string Description => "Wipes the liquid and grime off your screen.";

		public override FeatureGroup Group => FeatureGroups.Hud;

		[FeatureConfig]
		public static VisorWipersSettings Settings { get; set; }

		public override void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if ((int)FocusStateManager.CurrentState == 4 && Input.GetKeyDown(Settings.Key))
			{
				WipeTheVoid.Wipe();
			}
		}
	}
	internal sealed class VisorWiperModule : IArchiveModule
	{
		public ILocalizationService LocalizationService { get; set; }

		public IArchiveLogger Logger { get; set; }

		public void Init()
		{
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void Load()
		{
			ArchiveMod.RegisterArchiveModule(typeof(VisorWiperModule));
		}
	}
}