Decompiled source of Blink v1.2.0

Blink.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("YourModNameGoesHere")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Your Mod Description Goes Here")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("YourModNameGoesHere")]
[assembly: AssemblyTitle("YourModNameGoesHere")]
[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 Blinkv2
{
	[BepInPlugin("Poseiden.Blink", "Blink", "1.0.0")]
	public class BlinkBasev2 : BaseUnityPlugin
	{
		private const string modGUID = "Poseiden.Blink";

		private const string modName = "Blink";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Poseiden.Blink");

		private static BlinkBasev2 instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("Poseiden.Blink");
			mls.LogInfo((object)"Don't forget to blink");
			harmony.PatchAll(typeof(BlinkBasev2));
		}
	}
}
namespace Blink
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "YourModNameGoesHere";

		public const string PLUGIN_NAME = "YourModNameGoesHere";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Blink.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		private static bool simulateLossOfLineOfSight = false;

		private static ManualLogSource logger;

		private static float lastBlinkTime = 0f;

		private static float blinkInterval = 4.5f;

		private static bool ignoreLineOfSight = false;

		private static float ignoreLineOfSightDuration = 1.5f;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(PlayerControllerB __instance)
		{
			logger = Logger.CreateLogSource("Blink");
			logger.LogInfo((object)"Eyes are getting dry!");
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void UpdatePatch(PlayerControllerB __instance)
		{
			if (Time.time - lastBlinkTime >= blinkInterval)
			{
				SimulateLossOfLineOfSight(__instance);
				lastBlinkTime = Time.time;
			}
			if (ignoreLineOfSight)
			{
				ignoreLineOfSightDuration -= Time.deltaTime;
				if (ignoreLineOfSightDuration <= 1.5f)
				{
					ignoreLineOfSight = false;
				}
			}
		}

		private static void SimulateLossOfLineOfSight(PlayerControllerB playerController)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			simulateLossOfLineOfSight = true;
			ignoreLineOfSight = true;
			playerController.HasLineOfSightToPosition(Vector3.zero, 45f, 15, -1f);
			simulateLossOfLineOfSight = false;
			logger.LogInfo((object)"Blinking for 1 second");
			logger.LogInfo((object)"Player has blinked!");
		}
	}
}