Decompiled source of DontBlink v1.1.1

DontBlink.dll

Decompiled 11 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DontBlink.Integrations;
using DontBlink.Patches;
using DontBlink.Utils;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DontBlink")]
[assembly: AssemblyDescription("Adds a blinking mechanic à la SCP: Containment Breach to the game.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Orion™")]
[assembly: AssemblyProduct("DontBlink")]
[assembly: AssemblyCopyright("© 2023 - 2024 Orion™")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d99d01ee-6a81-4ab9-b97c-e7d656291095")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.1.1.0")]
[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 DontBlink
{
	[BepInPlugin("Orion.DontBlink", "Don't Blink", "1.1.1")]
	internal class DontBlinkBase : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "Orion.DontBlink";

		private const string PLUGIN_NAME = "Don't Blink";

		private const string PLUGIN_VERSION = "1.1.1";

		private readonly Harmony harmony = new Harmony("Orion.DontBlink");

		private static DontBlinkBase Instance { get; set; }

		public static bool has_insanity_remastered { get; set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			BlinkLogger.CreateLogger("Orion.DontBlink");
			ConfigSettings.GetConfig((BaseUnityPlugin)(object)Instance);
			AppDomain.CurrentDomain.AssemblyLoad += ModIntegrator.CurrentDomain_AssemblyLoad;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			Assembly[] array = assemblies;
			foreach (Assembly assembly in array)
			{
				ModIntegrator.CheckAssemblyPatches(assembly);
			}
			harmony.PatchAll(typeof(DontBlinkBase));
			harmony.PatchAll(typeof(PlayerPatch));
			harmony.PatchAll(typeof(HUDPatch));
			harmony.PatchAll(typeof(RoundPatch));
			harmony.PatchAll(typeof(CoilPatch));
			harmony.PatchAll(typeof(GirlPatch));
		}
	}
}
namespace DontBlink.Utils
{
	internal class BlinkLogger
	{
		private static ManualLogSource mls { get; set; }

		public static void CreateLogger(string source)
		{
			mls = Logger.CreateLogSource(source);
		}

		public static void Log(object message)
		{
			mls.LogInfo(message);
		}

		public static void Warn(object message)
		{
			mls.LogWarning(message);
		}

		public static void Error(object message)
		{
			mls.LogError(message);
		}
	}
	internal class ConfigSettings
	{
		public static ConfigEntry<float> blink_interval_calm_min { get; private set; }

		public static ConfigEntry<float> blink_interval_calm_max { get; private set; }

		public static ConfigEntry<float> blink_interval_insane_min { get; private set; }

		public static ConfigEntry<float> blink_interval_insane_max { get; private set; }

		public static ConfigEntry<float> blink_duration_calm_min { get; private set; }

		public static ConfigEntry<float> blink_duration_calm_max { get; private set; }

		public static ConfigEntry<float> blink_duration_insane_min { get; private set; }

		public static ConfigEntry<float> blink_duration_insane_max { get; private set; }

		public static ConfigEntry<float> blink_duration_fade_ratio_in { get; private set; }

		public static ConfigEntry<float> blink_duration_fade_ratio_out { get; private set; }

		public static ConfigEntry<float> blink_manual_fixed_duration_calm { get; private set; }

		public static ConfigEntry<float> blink_manual_fixed_duration_insane { get; private set; }

		public static ConfigEntry<float> blink_manual_keep_insanity_decrease { get; private set; }

		public static ConfigEntry<float> blink_steam_value { get; private set; }

		public static ConfigEntry<bool> blink_steam_affected { get; private set; }

		public static ConfigEntry<Key> blink_manual_key { get; private set; }

		public static ConfigEntry<bool> blink_meter_show { get; private set; }

		public static ConfigEntry<bool> blink_meter_old_parent { get; private set; }

		public static ConfigEntry<int> blink_exp_fear_use { get; private set; }

		public static ConfigEntry<float> blink_exp_fear_internal_cooldown { get; private set; }

		public static ConfigEntry<bool> blink_exp_coilhead_active { get; private set; }

		public static ConfigEntry<float> blink_exp_coilhead_active_duration { get; private set; }

		public static ConfigEntry<bool> blink_exp_coilhead_active_allow_fear_feature { get; private set; }

		public static ConfigEntry<bool> blink_exp_coilhead_active_allow_girl { get; private set; }

		public static void GetConfig(BaseUnityPlugin Instance)
		{
			blink_interval_calm_min = Instance.Config.Bind<float>("DontBlink", "Blink Interval Calm Min", 5f, "Minimum interval at which the player blinks when calm.\nNotes:\n1) Values are chosen at random between 'min' and 'max'.\n2) All 'calm' values gradually scale to 'insane' values as the player goes insane.\n3) If you don't want any random, use equal values on both 'min' and 'max' anywhere you please.");
			blink_interval_calm_max = Instance.Config.Bind<float>("DontBlink", "Blink Interval Calm Max", 23f, "Maximum interval at which the player blinks when calm.");
			blink_interval_insane_min = Instance.Config.Bind<float>("DontBlink", "Blink Interval Insanity Min", 1.5f, "Minimum interval at which the player blinks when insane.");
			blink_interval_insane_max = Instance.Config.Bind<float>("DontBlink", "Blink Interval Insanity Max", 7f, "Maximum interval at which the player blinks when insane.");
			blink_duration_calm_min = Instance.Config.Bind<float>("DontBlink", "Blink Duration Calm Min", 0.25f, "Minimum duration of a blink when calm.");
			blink_duration_calm_max = Instance.Config.Bind<float>("DontBlink", "Blink Duration Calm Max", 0.35f, "Maximum duration of a blink when calm.");
			blink_duration_insane_min = Instance.Config.Bind<float>("DontBlink", "Blink Duration Insanity Min", 0.22f, "Minimum duration of a blink when insane.");
			blink_duration_insane_max = Instance.Config.Bind<float>("DontBlink", "Blink Duration Insanity Max", 0.28f, "Maximum duration of a blink when insane.");
			blink_duration_fade_ratio_in = Instance.Config.Bind<float>("DontBlink", "Blink Duration Fade Ratio IN", 0.4f, "Blink fade-in ratio.\nA blink cycle is as follow : eyes open → fade-in → eyes closed → fade-out → eyes open\nValues of fade IN and OUT should sum to 1.");
			blink_duration_fade_ratio_out = Instance.Config.Bind<float>("DontBlink", "Blink Duration Fade Ratio OUT", 0.6f, "Blink fade-out ratio.");
			blink_manual_fixed_duration_calm = Instance.Config.Bind<float>("DontBlink", "Blink Manual Fixed Duration Calm", 14f, "When you manually blink (C by default) while calm, your next blink will happen after 14 seconds, instead of randomly. Note that this is still affected by your insanity level. If 0 (or below), this is disabled.");
			blink_manual_fixed_duration_insane = Instance.Config.Bind<float>("DontBlink", "Blink Manual Fixed Duration Insane", 3.5f, "When you manually blink (C by dfault) while insane, your next blink will happen after 3,5 seconds. Basically, your blink interval CANNOT go below this duration. If 0 (or below), this is disabled.");
			blink_manual_keep_insanity_decrease = Instance.Config.Bind<float>("DontBlink", "Blink Manual Kept Insanity Decrease", 2f, "Keeping your eyes shut decreases your insanity by this amount each second. Do note that insanity goes from 0 (not insane) to 50 (completly insane), so using a value of 2 requires you to keep your eyes shut for 25 seconds at most (if nothing happens). 0 = doesn't decrease insanity level. If you use InsanityRemastered, you would want to account for 200 max insanity (instead of 50).");
			blink_steam_affected = Instance.Config.Bind<bool>("DontBlink", "Blink Steam Affected", false, "Should your blink be affected by gas/steam leak ?");
			blink_steam_value = Instance.Config.Bind<float>("DontBlink", "Blink Steam Value", 4f, "When inside gas/steam leak, your blink meter will drain will be multiplied by this value and you will blink this much faster.");
			blink_manual_key = Instance.Config.Bind<Key>("DontBlink", "Blink Manual Key", (Key)17, "Default key to forcefully blink. You can also keep your eyes shut by holding the key.");
			blink_meter_show = Instance.Config.Bind<bool>("DontBlink", "Blink Meter Show", true, "Should the blink meter be displayed ?");
			blink_meter_old_parent = Instance.Config.Bind<bool>("DontBlink", "Blink Meter Old Parent", false, "Use the meter component's old parent. Enable this if the meter is misaligned. This might happen for big screens users (>2k).");
			blink_exp_fear_use = Instance.Config.Bind<int>("DontBlink", "Blink Exp Fear Use", 0, "Allow 'fear events' to make you forcefully blink. When your fear suddenly increases, you will 'stutter' by blinking. The blinking is random and based on the induced 'fear level', higher fear means higher probability to blink.\n• 0 = Disabled;\n• 1 = Blink based on induced fear level;\n• 2 = Always blink when your fear suddenly increased.");
			blink_exp_fear_internal_cooldown = Instance.Config.Bind<float>("DontBlink", "Blink Exp Fear Internal Cooldown", 1f, "An internal cooldown to avoid constant blinking due to some fear events. Default is 1 second.");
			blink_exp_coilhead_active = Instance.Config.Bind<bool>("DontBlink", "Blink Exp Coilhead Activation", false, "Auto blink & meter are only active when you see a coilhead.");
			blink_exp_coilhead_active_duration = Instance.Config.Bind<float>("DontBlink", "Blink Exp Coilhead Activation Duration", 5f, "How long should the Coil-Head blink condition lasts after seeing a Coil.");
			blink_exp_coilhead_active_allow_girl = Instance.Config.Bind<bool>("DontBlink", "Blink Exp Coilhead Activation Allow Girl", true, "Also activates when seeing the Ghost Girl.");
			blink_exp_coilhead_active_allow_fear_feature = Instance.Config.Bind<bool>("DontBlink", "Blink Exp Coilhead Allow Fear Feature", false, "Allow the 'Blink Exp Fear Use' to also trigger this feature. 'Blink Exp Fear Use' needs to be above 0.");
		}
	}
}
namespace DontBlink.Patches
{
	[HarmonyPatch(typeof(SpringManAI))]
	internal class CoilPatch
	{
		private static PlayerControllerB local_player => GameNetworkManager.Instance.localPlayerController;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePostPatch(SpringManAI __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigSettings.blink_exp_coilhead_active.Value && local_player.HasLineOfSightToPosition(((Component)__instance).transform.position + Vector3.up * 1.6f, 68f, 60, -1f))
			{
				PlayerPatch.coilhead_sight_time_remaining = ConfigSettings.blink_exp_coilhead_active_duration.Value;
			}
		}
	}
	[HarmonyPatch(typeof(DressGirlAI))]
	internal class GirlPatch
	{
		private static PlayerControllerB local_player => GameNetworkManager.Instance.localPlayerController;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePostPatch(DressGirlAI __instance, SkinnedMeshRenderer[] ___skinnedMeshRenderers)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigSettings.blink_exp_coilhead_active.Value && ConfigSettings.blink_exp_coilhead_active_allow_girl.Value && ((Component)___skinnedMeshRenderers[0]).gameObject.layer != 23 && local_player.HasLineOfSightToPosition(((Component)__instance).transform.position + Vector3.up * 0.4f, 60f, 60, -1f))
			{
				PlayerPatch.coilhead_sight_time_remaining = ConfigSettings.blink_exp_coilhead_active_duration.Value;
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDPatch
	{
		private const string blinking_meter_prefix = "[";

		private const string blinking_meter_full = "▓";

		private const string blinking_meter_empty = "░";

		private const string blinking_meter_suffix = "]";

		private static readonly Color blink_color_full = new Color(0f, 1f, 0f, 1f);

		private static readonly Color blink_color_empty = new Color(1f, 0f, 0f, 1f);

		private static readonly Color blink_color_gas = new Color(1f, 1f, 0f, 1f);

		private static TextMeshProUGUI blinking_meter_text { get; set; }

		private static int blinking_meter_bars_cur { get; set; } = 0;


		private static int blinking_meter_bars_old { get; set; } = 10;


		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPostPatch(ref HUDManager __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigSettings.blink_meter_show.Value)
			{
				GameObject val = new GameObject("HUDManagerBlinkMeter");
				val.AddComponent<RectTransform>();
				TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
				RectTransform rectTransform = ((TMP_Text)val2).rectTransform;
				if (ConfigSettings.blink_meter_old_parent.Value)
				{
					((Transform)rectTransform).SetParent(((Component)__instance.PTTIcon).transform, false);
					rectTransform.anchoredPosition = new Vector2(10f, -105f);
				}
				else
				{
					((Transform)rectTransform).SetParent(((Component)__instance.PlayerInfo.canvasGroup).transform, false);
					rectTransform.anchoredPosition = new Vector2(-340f, 60f);
				}
				((TMP_Text)val2).font = ((TMP_Text)__instance.controlTipLines[0]).font;
				((TMP_Text)val2).fontSize = 12f;
				((TMP_Text)val2).text = "";
				((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
				((Graphic)val2).color = blink_color_full;
				((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
				((Behaviour)val2).enabled = ConfigSettings.blink_meter_show.Value;
				blinking_meter_text = val2;
				if (ConfigSettings.blink_exp_coilhead_active.Value)
				{
					((Graphic)blinking_meter_text).CrossFadeAlpha(0f, 1f, false);
				}
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePostPatch()
		{
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)HUDManager.Instance == (Object)null || (Object)(object)blinking_meter_text == (Object)null || !ConfigSettings.blink_meter_show.Value)
			{
				return;
			}
			if (ConfigSettings.blink_exp_coilhead_active.Value)
			{
				if (PlayerPatch.coilhead_sight_time_remaining <= 0f)
				{
					if (blinking_meter_text.canvasRenderer.GetAlpha() >= 1f)
					{
						((Graphic)blinking_meter_text).CrossFadeAlpha(0f, 1.5f, false);
					}
					return;
				}
				if (blinking_meter_text.canvasRenderer.GetAlpha() <= 0f)
				{
					((Graphic)blinking_meter_text).CrossFadeAlpha(1f, 3f, false);
				}
			}
			float num = PlayerPatch.blink_time_remaining / PlayerPatch.blink_time_next;
			blinking_meter_bars_cur = (int)Mathf.Round(num * 10f);
			if (blinking_meter_bars_old != blinking_meter_bars_cur)
			{
				blinking_meter_bars_old = blinking_meter_bars_cur;
				Color color = Color.Lerp(blink_color_full, blink_color_empty, 1f - num);
				if (ConfigSettings.blink_steam_affected.Value && PlayerPatch.IsInsideSteam())
				{
					color = blink_color_gas;
				}
				((Graphic)blinking_meter_text).color = color;
				((TMP_Text)blinking_meter_text).text = string.Concat("[", string.Concat(Enumerable.Repeat("▓", blinking_meter_bars_cur)), string.Concat(Enumerable.Repeat("░", 10 - blinking_meter_bars_cur)), "]");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerPatch
	{
		public static float blink_time_next { get; private set; }

		public static float blink_time_remaining { get; private set; }

		private static float blink_fear_cooldown { get; set; }

		private static float blink_duration_buffer_in { get; set; }

		private static float blink_duration_buffer_out { get; set; }

		private static bool blink_state_out { get; set; }

		public static float coilhead_sight_time_remaining { get; set; }

		private static PlayerControllerB local_player => GameNetworkManager.Instance.localPlayerController;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePostPatch()
		{
			blink_time_remaining = Random.Range(ConfigSettings.blink_interval_calm_min.Value, ConfigSettings.blink_interval_calm_max.Value);
			blink_time_next = blink_time_remaining;
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPostPatch(PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance == (Object)null) && DontBlinkBase.has_insanity_remastered)
			{
				__instance.maxInsanityLevel = 200f;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePostPatch(PlayerControllerB __instance)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)__instance != (Object)(object)local_player || (Object)(object)local_player == (Object)null || local_player.isPlayerDead)
			{
				return;
			}
			if (blink_fear_cooldown > 0f)
			{
				blink_fear_cooldown -= Time.deltaTime;
			}
			if ((((ButtonControl)Keyboard.current[ConfigSettings.blink_manual_key.Value]).wasPressedThisFrame || ((ButtonControl)Keyboard.current[ConfigSettings.blink_manual_key.Value]).isPressed) && !local_player.inTerminalMenu && !local_player.isTypingChat && !local_player.quickMenuManager.isMenuOpen)
			{
				Blink(forced: true);
				return;
			}
			if (blink_duration_buffer_in > 0f)
			{
				blink_duration_buffer_in -= Time.deltaTime;
				return;
			}
			if (blink_duration_buffer_out > 0f)
			{
				if (!blink_state_out)
				{
					blink_state_out = true;
					((Graphic)HUDManager.Instance.playerScreenTexture).CrossFadeAlpha(1f, blink_duration_buffer_out, false);
				}
				blink_duration_buffer_out -= Time.deltaTime;
				return;
			}
			if (ConfigSettings.blink_exp_coilhead_active.Value)
			{
				if (!(coilhead_sight_time_remaining > 0f))
				{
					return;
				}
				coilhead_sight_time_remaining -= Time.deltaTime;
				if (coilhead_sight_time_remaining <= 0f)
				{
					Blink();
					return;
				}
			}
			float num = Time.deltaTime;
			if (ConfigSettings.blink_steam_affected.Value && IsInsideSteam())
			{
				num *= ConfigSettings.blink_steam_value.Value;
			}
			blink_time_remaining -= num;
			if (!(blink_time_remaining > 0f))
			{
				Blink();
			}
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPostfix]
		private static void KillPlayerPatch(PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)__instance != (Object)(object)local_player) && !((Object)(object)local_player == (Object)null) && local_player.isPlayerDead)
			{
				((Graphic)HUDManager.Instance.playerScreenTexture).CrossFadeAlpha(1f, Time.deltaTime, false);
			}
		}

		[HarmonyPatch("HasLineOfSightToPosition")]
		[HarmonyPrefix]
		private static bool HasLineOfSightToPositionPrePatch(ref bool __result)
		{
			if (blink_duration_buffer_in + blink_duration_buffer_out > 0f)
			{
				__result = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch("JumpToFearLevel")]
		[HarmonyPostfix]
		private static void JumpToFearLevelPostPatch(object[] __args)
		{
			if (ConfigSettings.blink_exp_fear_use.Value >= 1 && !(blink_duration_buffer_out > 0f) && !(blink_fear_cooldown > 0f) && (ConfigSettings.blink_exp_fear_use.Value > 1 || (float)__args[0] >= Random.value))
			{
				if (ConfigSettings.blink_exp_coilhead_active.Value && ConfigSettings.blink_exp_coilhead_active_allow_fear_feature.Value)
				{
					coilhead_sight_time_remaining = ConfigSettings.blink_exp_coilhead_active_duration.Value;
				}
				blink_fear_cooldown = 1f;
				Blink();
			}
		}

		private static void Blink(bool forced = false)
		{
			if (DontBlinkBase.has_insanity_remastered)
			{
				local_player.insanityLevel = InsanityRemasteredIntegration.ir_InsanityLevel;
			}
			blink_state_out = false;
			float num = local_player.insanityLevel / local_player.maxInsanityLevel;
			float num2 = Random.Range(Mathf.Lerp(ConfigSettings.blink_duration_calm_min.Value, ConfigSettings.blink_duration_insane_min.Value, num), Mathf.Lerp(ConfigSettings.blink_duration_calm_max.Value, ConfigSettings.blink_duration_insane_max.Value, num));
			blink_duration_buffer_in = num2 * ConfigSettings.blink_duration_fade_ratio_in.Value;
			blink_duration_buffer_out = num2 * ConfigSettings.blink_duration_fade_ratio_out.Value;
			blink_time_remaining = Random.Range(Mathf.Lerp(ConfigSettings.blink_interval_calm_min.Value, ConfigSettings.blink_interval_insane_min.Value, num), Mathf.Lerp(ConfigSettings.blink_interval_calm_max.Value, ConfigSettings.blink_interval_insane_max.Value, num));
			bool flag = ConfigSettings.blink_manual_fixed_duration_calm.Value > 0f && ConfigSettings.blink_manual_fixed_duration_insane.Value > 0f;
			if (forced)
			{
				if (local_player.insanityLevel > 0f && ConfigSettings.blink_manual_keep_insanity_decrease.Value > 0f)
				{
					local_player.insanityLevel = Mathf.Max(local_player.insanityLevel - ConfigSettings.blink_manual_keep_insanity_decrease.Value * Time.deltaTime, 0f);
				}
				if (flag)
				{
					blink_time_remaining = Mathf.Lerp(ConfigSettings.blink_manual_fixed_duration_calm.Value, ConfigSettings.blink_manual_fixed_duration_insane.Value, num);
				}
			}
			blink_time_next = blink_time_remaining;
			((Graphic)HUDManager.Instance.playerScreenTexture).CrossFadeAlpha(0f, blink_duration_buffer_in, false);
		}

		public static bool IsInsideSteam()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			foreach (SteamValveHazard valf in RoundPatch.valves)
			{
				if ((Object)(object)valf == (Object)null || !(bool)AccessTools.Field(typeof(SteamValveHazard), "valveHasBurst").GetValue(valf) || (bool)AccessTools.Field(typeof(SteamValveHazard), "valveHasBeenRepaired").GetValue(valf) || Vector3.Distance(((Component)local_player).transform.position, ((Component)valf.valveAudio).transform.position) > 10f)
				{
					continue;
				}
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundPatch
	{
		public static List<SteamValveHazard> valves { get; private set; } = new List<SteamValveHazard>();


		[HarmonyPatch("SetSteamValveTimes")]
		[HarmonyPostfix]
		private static void GetValves()
		{
			valves.Clear();
			valves.AddRange(Object.FindObjectsByType<SteamValveHazard>((FindObjectsSortMode)0));
		}

		[HarmonyPatch("DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		private static void ClearValves()
		{
			valves.Clear();
		}
	}
}
namespace DontBlink.Integrations
{
	internal class InsanityRemasteredIntegration
	{
		public static float ir_InsanityLevel { get; private set; }

		private static void IRUpdate(float ___InsanityLevel)
		{
			ir_InsanityLevel = ___InsanityLevel;
		}
	}
	internal class ModIntegrator
	{
		public static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
		{
			CheckAssemblyPatches(args.LoadedAssembly);
		}

		public static void CheckAssemblyPatches(Assembly assembly)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			if (!assembly.FullName.StartsWith("InsanityRemastered"))
			{
				return;
			}
			BlinkLogger.Warn("InsanityRemastered found ! DontBlink will base its scaling on it instead of the base game.");
			DontBlinkBase.has_insanity_remastered = true;
			Harmony val = new Harmony("DontBlinkInsanityRemastered");
			Type[] types = assembly.GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				if (types[i].Name == "PlayerPatcher")
				{
					MethodInfo method = types[i].GetMethod("_Update", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
					HarmonyMethod val2 = new HarmonyMethod(typeof(InsanityRemasteredIntegration).GetMethod("IRUpdate", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy));
					val.Patch((MethodBase)method, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					break;
				}
			}
		}
	}
}