Decompiled source of VisorWipers v1.0.2

VisorWipers.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AK;
using Agents;
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 Player;
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+6deb111020e6673f03b9fc358ea39790cceaffc1")]
[assembly: AssemblyProduct("VisorWipers")]
[assembly: AssemblyTitle("VisorWipers")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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.2")]
	[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 ConfigEntry<KeyCode> _screamKeyBind;

		private static ConfigFile _configFile;

		public static KeyCode WiperKeyBind => _wiperKeyBind.Value;

		public static KeyCode ScreamKeyBind => _screamKeyBind.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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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.");
			_screamKeyBind = _configFile.Bind<KeyCode>(text, "Scream Keybind", (KeyCode)284, "The keybind for your ear wipers.\nPressing it plays the scout scream audio and clears tinnitus.");
			LiveEdit.CreateListener(Paths.ConfigPath, "VisorWipers.cfg", false).FileChanged += new LiveEditEventHandler(OnFileChanged);
		}

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

		private float _stopSoundTime;

		public WiperHandler(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Awake()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			_player = new CellSoundPlayer();
		}

		private void Update()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (_stopSoundTime > 0f && _stopSoundTime < Clock.Time)
			{
				_player.Stop();
				_stopSoundTime = 0f;
			}
			if ((int)FocusStateManager.CurrentState == 4)
			{
				if (Input.GetKeyDown(Configuration.WiperKeyBind))
				{
					WipeTheVoid.Wipe();
				}
				if (Input.GetKeyDown(Configuration.ScreamKeyBind))
				{
					_player.Post(EVENTS.SCOUT_DETECT_SCREAM, ((Agent)PlayerManager.GetLocalPlayerAgent()).Position);
					_stopSoundTime = Clock.Time + 0.1f;
				}
			}
		}
	}
}
namespace VisorWipers.Archive
{
	[EnableFeatureByDefault]
	public class VisorWipersFeature : Feature
	{
		public class VisorWipersSettings
		{
			[FSDisplayName("Wiper Keybind")]
			[FSDescription("Key used to wipe liquids and grime off the screen.")]
			public KeyCode WipeKey { get; set; } = (KeyCode)283;

			[FSDisplayName("Scout Scream Keybind")]
			[FSDescription("Key used to play the scout scream audio and clear tinnitus.")]
			public KeyCode ScreamKey { get; set; } = (KeyCode)284;
		}

		private CellSoundPlayer _player;

		private float _stopSoundTime;

		public override string Name => "Visor Wipers";

		public override string Description => "Handy keybinds to fix issues that have no true bug fix.";

		public override FeatureGroup Group => FeatureGroups.Hud;

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

		public override void Init()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			_player = new CellSoundPlayer();
		}

		public override void Update()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (_stopSoundTime > 0f && _stopSoundTime < Clock.Time)
			{
				_player.Stop();
				_stopSoundTime = 0f;
			}
			if ((int)FocusStateManager.CurrentState == 4)
			{
				if (Input.GetKeyDown(Settings.WipeKey))
				{
					WipeTheVoid.Wipe();
				}
				if (Input.GetKeyDown(Settings.ScreamKey))
				{
					_player.Post(EVENTS.SCOUT_DETECT_SCREAM, ((Agent)PlayerManager.GetLocalPlayerAgent()).Position);
					_stopSoundTime = Clock.Time + 0.1f;
				}
			}
		}
	}
	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));
		}
	}
}