using System; using System.Collections.Generic; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using OkayZoomer.Compats; using OkayZoomer.Configs; using OkayZoomer.NetcodePatcher; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("BepInEx")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("Newtonsoft.Json")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("UnityEngine")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("s1ckboy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 s1ckboy")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OkayZoomer")] [assembly: AssemblyTitle("OkayZoomer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 OkayZoomer { internal class Loggers { private static void Log(LogLevel logLevel, object data) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Plugins.Logger.Log(logLevel, data); } internal static void Info(object data) { Log((LogLevel)16, data); } internal static void Debug(object data) { Log((LogLevel)32, data); } internal static void Message(object data) { Log((LogLevel)8, data); } internal static void Warning(object data) { Log((LogLevel)4, data); } internal static void Error(object data) { Log((LogLevel)2, data); } internal static void Fatal(object data) { Log((LogLevel)1, data); } } public class PlayerScreenZoomEffect : MonoBehaviour { private struct HudGraphicState { public Graphic Graphic; public bool OriginalEnabled; public HudGraphicState(Graphic graphic) { Graphic = graphic; OriginalEnabled = (Object)(object)graphic != (Object)null && ((Behaviour)graphic).enabled; } } private struct HudCanvasGroupState { public CanvasGroup CanvasGroup; public float OriginalAlpha; public bool OriginalInteractable; public bool OriginalBlocksRaycasts; public HudCanvasGroupState(CanvasGroup canvasGroup) { CanvasGroup = canvasGroup; OriginalAlpha = (((Object)(object)canvasGroup != (Object)null) ? canvasGroup.alpha : 1f); OriginalInteractable = (Object)(object)canvasGroup != (Object)null && canvasGroup.interactable; OriginalBlocksRaycasts = (Object)(object)canvasGroup != (Object)null && canvasGroup.blocksRaycasts; } } private const string ZoomShaderProperty = "_Zoom"; private const string MaxZoomShaderProperty = "_MaxZoom"; private const string DeployShaderProperty = "_Deploy"; private const string HudRootPath = "Systems/UI"; private const string HudCanvasPath = "Systems/UI/Canvas"; private const float NightVisionLightIntensity = 1200f; private const float NightVisionLightRange = 70f; private static readonly Color NightVisionLightColor = new Color(0.141f, 0.72f, 0f, 1f); private static readonly ZoomStyle[] StyleCycle = new ZoomStyle[10] { ZoomStyle.None, ZoomStyle.Clean, ZoomStyle.Binocular, ZoomStyle.Camcorder, ZoomStyle.InLove, ZoomStyle.GreedCurse, ZoomStyle.Melodrama, ZoomStyle.SpiderEyes, ZoomStyle.FlyEyes, ZoomStyle.NightVision }; private RawImage playerScreen; private Material originalMaterial; private Material activeMaterialInstance; private ZoomStyle currentStyle = (ZoomStyle)(-1); private Camera gameplayCamera; private float normalFOV; private bool hasStoredNormalFOV; private bool wasZoomingOrTransitioning; private Light nightVisionLight; private bool hasStoredNightVisionLight; private bool nightVisionBoostActive; private bool originalNightVisionEnabled; private float originalNightVisionIntensity; private float originalNightVisionRange; private Color originalNightVisionColor; private float zoomAmount; private bool zoomActive; private bool toggleZoomActive; private bool previousToggleMode; private Keyboard keyboard; private Mouse mouse; private ZoomInput currentZoomKey; private bool validZoomKey; private QuickMenuManager quickMenuManager; private RectTransform styleTextRoot; private TextMeshProUGUI previousKeyText; private TextMeshProUGUI zoomKeyText; private TextMeshProUGUI nextKeyText; private TextMeshProUGUI previousArrowText; private TextMeshProUGUI styleNameText; private TextMeshProUGUI nextArrowText; private Material styleTextMaterialInstance; private HudGraphicState[] hudGraphicStates = Array.Empty(); private HudCanvasGroupState[] hudCanvasGroupStates = Array.Empty(); private bool hudHidden; private void Awake() { playerScreen = ((Component)this).GetComponent(); if (!((Object)(object)playerScreen == (Object)null)) { originalMaterial = ((Graphic)playerScreen).material; keyboard = Keyboard.current; mouse = Mouse.current; previousToggleMode = Plugins.ConfigEntries.ToggleZoom.Value; UpdateZoomKey(); ApplyStyle(Plugins.ConfigEntries.ZoomStyle.Value); } } private void Start() { CreateStyleText(); UpdateStyleText(); } private void Update() { if ((Object)(object)playerScreen == (Object)null) { return; } if (keyboard == null) { keyboard = Keyboard.current; } if (mouse == null) { mouse = Mouse.current; } UpdateStyleText(); if (IsEscapeMenuOpen()) { ResetZoomForMenu(); SetStyleTextVisible(visible: false); return; } HashSet blacklistedStyles = ParseStyleBlacklist(); HandleStyleSwitchInput(blacklistedStyles); ZoomStyle allowedStyle = GetAllowedStyle(Plugins.ConfigEntries.ZoomStyle.Value, blacklistedStyles, 1); if (allowedStyle != Plugins.ConfigEntries.ZoomStyle.Value) { Plugins.ConfigEntries.ZoomStyle.Value = allowedStyle; } if (allowedStyle != currentStyle) { if (zoomActive || zoomAmount > 0.001f) { RestartZoomAnimation(); } ApplyStyle(allowedStyle); UpdateStyleText(); } if (currentStyle == ZoomStyle.None) { ResetZoomCompletely(); return; } HandleZoomInput(); UpdateZoomAmount(); ApplyMaterialZoom(); UpdateNightVisionBoost(); bool flag = zoomActive || zoomAmount > 0.001f; bool flag2 = currentStyle != ZoomStyle.None && currentStyle != ZoomStyle.NightVision && flag; SetHudHidden(flag2); if (flag2) { ForceHudHiddenInstant(); } if ((Object)(object)activeMaterialInstance != (Object)null && (Object)(object)((Graphic)playerScreen).material != (Object)(object)activeMaterialInstance) { ((Graphic)playerScreen).material = activeMaterialInstance; } } private void LateUpdate() { if (currentStyle != ZoomStyle.None) { if (IsEscapeMenuOpen()) { ResetZoomForMenu(); SetStyleTextVisible(visible: false); } else { UpdateCameraReference(); ApplyCameraFOV(); } } } private void SetStyleTextVisible(bool visible) { if ((Object)(object)styleTextRoot != (Object)null) { ((Component)styleTextRoot).gameObject.SetActive(visible); } } private void CreateStyleText() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) HUDManager instance = HUDManager.Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.chatText == (Object)null)) { GameObject val = GameObject.Find("Systems/UI/Canvas"); if ((Object)(object)val == (Object)null) { Plugins.Logger.LogWarning((object)"OkayZoomer: Could not find HUD canvas path 'Systems/UI/Canvas'."); return; } GameObject val2 = new GameObject("OkayZoomerStyleTextRoot"); val2.transform.SetParent(val.transform, false); styleTextRoot = val2.AddComponent(); styleTextRoot.anchorMin = new Vector2(1f, 0f); styleTextRoot.anchorMax = new Vector2(1f, 0f); styleTextRoot.pivot = new Vector2(1f, 0f); styleTextRoot.anchoredPosition = Vector2.zero; styleTextRoot.sizeDelta = new Vector2(260f, 42f); ((Transform)styleTextRoot).localScale = Vector3.one; styleTextMaterialInstance = Object.Instantiate(((TMP_Text)instance.chatText).fontMaterial); styleTextMaterialInstance.EnableKeyword("UNDERLAY_ON"); styleTextMaterialInstance.SetColor("_UnderlayColor", new Color(0f, 0f, 0f, 0.9f)); styleTextMaterialInstance.SetFloat("_UnderlayOffsetX", 1.1f); styleTextMaterialInstance.SetFloat("_UnderlayOffsetY", -1.1f); styleTextMaterialInstance.SetFloat("_UnderlaySoftness", 0.25f); previousKeyText = CreateStyleTextPart("PreviousKey", instance, 10f); zoomKeyText = CreateStyleTextPart("ZoomKey", instance, 10f); nextKeyText = CreateStyleTextPart("NextKey", instance, 10f); previousArrowText = CreateStyleTextPart("PreviousArrow", instance, 15f); styleNameText = CreateStyleTextPart("StyleName", instance, 13f); nextArrowText = CreateStyleTextPart("NextArrow", instance, 15f); SetTextRect(previousKeyText, new Vector2(-78f, 17f), new Vector2(68f, 14f)); SetTextRect(zoomKeyText, new Vector2(0f, 17f), new Vector2(68f, 14f)); SetTextRect(nextKeyText, new Vector2(78f, 17f), new Vector2(68f, 14f)); SetTextRect(previousArrowText, new Vector2(-78f, 1f), new Vector2(28f, 22f)); SetTextRect(styleNameText, new Vector2(0f, 1f), new Vector2(128f, 22f)); SetTextRect(nextArrowText, new Vector2(78f, 1f), new Vector2(28f, 22f)); val2.transform.SetAsLastSibling(); } } private TextMeshProUGUI CreateStyleTextPart(string name, HUDManager hud, float fontSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent((Transform)(object)styleTextRoot, false); TextMeshProUGUI val2 = val.AddComponent(); ((TMP_Text)val2).font = ((TMP_Text)hud.chatText).font; ((TMP_Text)val2).fontMaterial = styleTextMaterialInstance; ((TMP_Text)val2).fontSize = fontSize; ((TMP_Text)val2).richText = false; ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; ((Graphic)val2).color = Color.white; ((TMP_Text)val2).enableWordWrapping = false; ((TMP_Text)val2).enableKerning = false; ((Graphic)val2).raycastTarget = false; ((TMP_Text)val2).overflowMode = (TextOverflowModes)3; return val2; } private void SetTextRect(TextMeshProUGUI text, Vector2 position, Vector2 size) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0055: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((TMP_Text)text).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = position; rectTransform.sizeDelta = size; ((Transform)rectTransform).localScale = Vector3.one; } private void UpdateStyleText() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)styleTextRoot == (Object)null)) { styleTextRoot.anchoredPosition = new Vector2(-10f + Plugins.ConfigEntries.StyleTextPositionX.Value, 22f - Plugins.ConfigEntries.StyleTextPositionY.Value); bool value = Plugins.ConfigEntries.ShowStyleKeybindTexts.Value; ((Component)previousKeyText).gameObject.SetActive(value); ((Component)zoomKeyText).gameObject.SetActive(value); ((Component)nextKeyText).gameObject.SetActive(value); ((TMP_Text)previousKeyText).text = "[" + GetInputDisplayName(Plugins.ConfigEntries.PreviousStyleKey.Value) + "]"; ((TMP_Text)zoomKeyText).text = "[" + GetInputDisplayName(Plugins.ConfigEntries.ZoomKey.Value) + "]"; ((TMP_Text)nextKeyText).text = "[" + GetInputDisplayName(Plugins.ConfigEntries.NextStyleKey.Value) + "]"; ((TMP_Text)previousArrowText).text = "◄"; ((TMP_Text)styleNameText).text = GetStyleDisplayName(Plugins.ConfigEntries.ZoomStyle.Value); ((TMP_Text)nextArrowText).text = "►"; SetStyleTextVisible(!hudHidden && !IsEscapeMenuOpen()); if (((Component)styleTextRoot).gameObject.activeSelf) { ((Transform)styleTextRoot).SetAsLastSibling(); } } } private void HandleStyleSwitchInput(HashSet blacklistedStyles) { bool flag = WasInputPressed(Plugins.ConfigEntries.PreviousStyleKey.Value); bool flag2 = WasInputPressed(Plugins.ConfigEntries.NextStyleKey.Value); if (flag != flag2) { CycleZoomStyle((!flag) ? 1 : (-1), blacklistedStyles); } } private void CycleZoomStyle(int direction, HashSet blacklistedStyles) { int num = Array.IndexOf(StyleCycle, Plugins.ConfigEntries.ZoomStyle.Value); if (num < 0) { num = 0; } for (int i = 1; i <= StyleCycle.Length; i++) { int num2 = (num + direction * i + StyleCycle.Length) % StyleCycle.Length; ZoomStyle zoomStyle = StyleCycle[num2]; if (!blacklistedStyles.Contains(zoomStyle)) { Plugins.ConfigEntries.ZoomStyle.Value = zoomStyle; break; } } } private ZoomStyle GetAllowedStyle(ZoomStyle style, HashSet blacklistedStyles, int direction) { if (!blacklistedStyles.Contains(style)) { return style; } int num = Array.IndexOf(StyleCycle, style); if (num < 0) { num = 0; } for (int i = 1; i <= StyleCycle.Length; i++) { int num2 = (num + direction * i + StyleCycle.Length) % StyleCycle.Length; ZoomStyle zoomStyle = StyleCycle[num2]; if (!blacklistedStyles.Contains(zoomStyle)) { return zoomStyle; } } return ZoomStyle.Clean; } private HashSet ParseStyleBlacklist() { HashSet hashSet = new HashSet(); string value = Plugins.ConfigEntries.StyleBlacklist.Value; if (string.IsNullOrWhiteSpace(value)) { return hashSet; } string[] array = value.Split(','); string[] array2 = array; foreach (string value2 in array2) { string text = NormalizeStyleName(value2); if (text.Length == 0) { continue; } ZoomStyle[] styleCycle = StyleCycle; for (int j = 0; j < styleCycle.Length; j++) { ZoomStyle item = styleCycle[j]; if (NormalizeStyleName(item.ToString()) == text) { hashSet.Add(item); break; } } } return hashSet; } private string NormalizeStyleName(string value) { if (string.IsNullOrWhiteSpace(value)) { return string.Empty; } string text = string.Empty; foreach (char c in value) { if (char.IsLetterOrDigit(c)) { text += char.ToLowerInvariant(c); } } return text; } private bool WasInputPressed(ZoomInput input) { ButtonControl inputControl = GetInputControl(input); if (inputControl != null) { return inputControl.wasPressedThisFrame; } return false; } private bool IsInputHeld(ZoomInput input) { ButtonControl inputControl = GetInputControl(input); if (inputControl != null) { return inputControl.isPressed; } return false; } private ButtonControl GetInputControl(ZoomInput input) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (input == ZoomInput.None) { return null; } if (mouse == null) { mouse = Mouse.current; } switch (input) { case ZoomInput.MouseMiddle: { Mouse obj = mouse; if (obj == null) { return null; } return obj.middleButton; } case ZoomInput.MouseBack: { Mouse obj2 = mouse; if (obj2 == null) { return null; } return obj2.backButton; } case ZoomInput.MouseForward: { Mouse obj3 = mouse; if (obj3 == null) { return null; } return obj3.forwardButton; } default: { if (keyboard == null) { keyboard = Keyboard.current; } if (keyboard == null) { return null; } if (!Enum.TryParse(input.ToString(), out Key result)) { return null; } if ((int)result == 0 || !Enum.IsDefined(typeof(Key), result)) { return null; } return (ButtonControl)(object)keyboard[result]; } } } private void HandleZoomInput() { if (currentZoomKey != Plugins.ConfigEntries.ZoomKey.Value) { toggleZoomActive = false; UpdateZoomKey(); } bool value = Plugins.ConfigEntries.ToggleZoom.Value; if (value != previousToggleMode) { toggleZoomActive = false; previousToggleMode = value; } bool flag = validZoomKey && WasInputPressed(currentZoomKey); bool flag2 = validZoomKey && IsInputHeld(currentZoomKey); if (value) { if (flag) { toggleZoomActive = !toggleZoomActive; } zoomActive = toggleZoomActive; } else { toggleZoomActive = false; zoomActive = flag2; } } private void UpdateZoomAmount() { float num = (zoomActive ? 1f : 0f); zoomAmount = Mathf.MoveTowards(zoomAmount, num, Time.deltaTime * Plugins.ConfigEntries.ZoomSpeed.Value); } private void RestartZoomAnimation() { RestoreCameraFOVNow(); zoomAmount = 0f; if ((Object)(object)activeMaterialInstance != (Object)null && activeMaterialInstance.HasProperty("_Zoom")) { activeMaterialInstance.SetFloat("_Zoom", 0f); } if ((Object)(object)activeMaterialInstance != (Object)null && activeMaterialInstance.HasProperty("_Deploy")) { activeMaterialInstance.SetFloat("_Deploy", 0f); } DisableNightVisionBoost(); } private void UpdateZoomKey() { currentZoomKey = Plugins.ConfigEntries.ZoomKey.Value; validZoomKey = currentZoomKey != ZoomInput.None; } private void ApplyStyle(ZoomStyle style) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown currentStyle = style; if ((Object)(object)activeMaterialInstance != (Object)null) { Object.Destroy((Object)(object)activeMaterialInstance); activeMaterialInstance = null; } if (style == ZoomStyle.None || style == ZoomStyle.Clean) { ((Graphic)playerScreen).material = originalMaterial; return; } if (!Plugins.ZoomMaterialTemplates.TryGetValue(style, out var value) || (Object)(object)value == (Object)null) { Plugins.Logger.LogWarning((object)$"OkayZoomer: Missing material for zoom style '{style}'. Falling back to Clean."); Plugins.ConfigEntries.ZoomStyle.Value = ZoomStyle.Clean; currentStyle = ZoomStyle.Clean; ((Graphic)playerScreen).material = originalMaterial; return; } activeMaterialInstance = new Material(value) { name = $"OkayZoomer Runtime Material - {style}" }; if (activeMaterialInstance.HasProperty("_Zoom")) { activeMaterialInstance.SetFloat("_Zoom", zoomAmount); } if (activeMaterialInstance.HasProperty("_Deploy")) { activeMaterialInstance.SetFloat("_Deploy", zoomAmount); } if (activeMaterialInstance.HasProperty("_MaxZoom")) { activeMaterialInstance.SetFloat("_MaxZoom", 1f); } ((Graphic)playerScreen).material = activeMaterialInstance; } private void ApplyMaterialZoom() { if (!((Object)(object)activeMaterialInstance == (Object)null)) { if (activeMaterialInstance.HasProperty("_Zoom")) { activeMaterialInstance.SetFloat("_Zoom", zoomAmount); } if (activeMaterialInstance.HasProperty("_Deploy")) { activeMaterialInstance.SetFloat("_Deploy", zoomAmount); } if (activeMaterialInstance.HasProperty("_MaxZoom")) { activeMaterialInstance.SetFloat("_MaxZoom", 1f); } } } private void UpdateNightVisionBoost() { if (currentStyle == ZoomStyle.NightVision && (zoomActive || zoomAmount > 0.001f) && !IsEscapeMenuOpen()) { EnableNightVisionBoost(); } else { DisableNightVisionBoost(); } } private void EnableNightVisionBoost() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) Light val = GetNightVisionLight(); if (!((Object)(object)val == (Object)null)) { if (!hasStoredNightVisionLight) { originalNightVisionEnabled = ((Behaviour)val).enabled; originalNightVisionIntensity = val.intensity; originalNightVisionRange = val.range; originalNightVisionColor = val.color; hasStoredNightVisionLight = true; } float num = Mathf.Clamp01(zoomAmount); ((Behaviour)val).enabled = true; val.intensity = Mathf.Lerp(originalNightVisionIntensity, 1200f, num); val.range = Mathf.Lerp(originalNightVisionRange, 70f, num); val.color = Color.Lerp(originalNightVisionColor, NightVisionLightColor, num); nightVisionBoostActive = true; } } private void DisableNightVisionBoost() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (nightVisionBoostActive) { Light val = GetNightVisionLight(); if ((Object)(object)val != (Object)null && hasStoredNightVisionLight) { ((Behaviour)val).enabled = originalNightVisionEnabled; val.intensity = originalNightVisionIntensity; val.range = originalNightVisionRange; val.color = originalNightVisionColor; } nightVisionBoostActive = false; hasStoredNightVisionLight = false; } } private Light GetNightVisionLight() { if ((Object)(object)nightVisionLight != (Object)null) { return nightVisionLight; } PlayerControllerB localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null) { return null; } FieldInfo field = typeof(PlayerControllerB).GetField("nightVision", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { ref Light reference = ref nightVisionLight; object? value = field.GetValue(localPlayer); reference = (Light)((value is Light) ? value : null); } if ((Object)(object)nightVisionLight != (Object)null) { return nightVisionLight; } Light[] componentsInChildren = ((Component)localPlayer).GetComponentsInChildren(true); Light[] array = componentsInChildren; foreach (Light val in array) { if (!((Object)(object)val == (Object)null) && ((Object)val).name.IndexOf("night", StringComparison.OrdinalIgnoreCase) >= 0) { nightVisionLight = val; return nightVisionLight; } } return null; } private PlayerControllerB GetLocalPlayer() { if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null) { return StartOfRound.Instance.localPlayerController; } if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { return GameNetworkManager.Instance.localPlayerController; } return null; } private void UpdateCameraReference() { if ((Object)(object)gameplayCamera != (Object)null) { return; } PlayerControllerB localPlayer = GetLocalPlayer(); if (!((Object)(object)localPlayer == (Object)null)) { gameplayCamera = localPlayer.gameplayCamera; if ((Object)(object)gameplayCamera != (Object)null && !hasStoredNormalFOV) { normalFOV = gameplayCamera.fieldOfView; hasStoredNormalFOV = true; } } } private void ApplyCameraFOV() { if ((Object)(object)gameplayCamera == (Object)null) { return; } if (!zoomActive && !(zoomAmount > 0.001f)) { if (wasZoomingOrTransitioning && hasStoredNormalFOV) { gameplayCamera.fieldOfView = normalFOV; } normalFOV = gameplayCamera.fieldOfView; hasStoredNormalFOV = true; wasZoomingOrTransitioning = false; } else { if (!wasZoomingOrTransitioning) { normalFOV = gameplayCamera.fieldOfView; hasStoredNormalFOV = true; wasZoomingOrTransitioning = true; } gameplayCamera.fieldOfView = Mathf.Lerp(normalFOV, GetTargetFOV(), zoomAmount); } } private float GetTargetFOV() { if (currentStyle == ZoomStyle.NightVision) { return normalFOV; } float value = Plugins.ConfigEntries.ZoomFOV.Value; if (currentStyle != ZoomStyle.GreedCurse) { return value; } float num = normalFOV - value; float num2 = normalFOV + num; return Mathf.Clamp(num2, normalFOV, 120f); } private void ResetZoomCompletely() { DisableNightVisionBoost(); toggleZoomActive = false; zoomActive = false; zoomAmount = 0f; SetHudHidden(hidden: false); RestoreCameraFOVNow(); if ((Object)(object)playerScreen != (Object)null && (Object)(object)((Graphic)playerScreen).material != (Object)(object)originalMaterial) { ((Graphic)playerScreen).material = originalMaterial; } if ((Object)(object)activeMaterialInstance != (Object)null) { Object.Destroy((Object)(object)activeMaterialInstance); activeMaterialInstance = null; } } private void ResetZoomForMenu() { DisableNightVisionBoost(); toggleZoomActive = false; zoomActive = false; zoomAmount = 0f; ApplyMaterialZoom(); SetHudHidden(hidden: false); RestoreCameraFOVNow(); } private void RestoreCameraFOVNow() { UpdateCameraReference(); if ((Object)(object)gameplayCamera != (Object)null && wasZoomingOrTransitioning && hasStoredNormalFOV) { gameplayCamera.fieldOfView = normalFOV; } wasZoomingOrTransitioning = false; if ((Object)(object)gameplayCamera != (Object)null) { normalFOV = gameplayCamera.fieldOfView; hasStoredNormalFOV = true; } } private void SetHudHidden(bool hidden) { if (hudHidden == hidden) { return; } if (hidden) { CacheHudStates(); RefreshHudStates(); HUDManager instance = HUDManager.Instance; if (instance != null) { instance.HideHUD(true); } ForceHudHiddenInstant(); } else { HUDManager instance2 = HUDManager.Instance; if (instance2 != null) { instance2.HideHUD(false); } RestoreHudInstant(); } hudHidden = hidden; } private void CacheHudStates() { GameObject val = GameObject.Find("Systems/UI"); if ((Object)(object)val == (Object)null) { return; } Graphic[] componentsInChildren = val.GetComponentsInChildren(true); CanvasGroup[] componentsInChildren2 = val.GetComponentsInChildren(true); List list = new List(); List list2 = new List(); Graphic[] array = componentsInChildren; foreach (Graphic val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)playerScreen) && (!((Object)(object)styleTextRoot != (Object)null) || !((Component)val2).transform.IsChildOf((Transform)(object)styleTextRoot)) && (!((Object)(object)playerScreen != (Object)null) || !((Component)val2).transform.IsChildOf(((Component)playerScreen).transform)) && !IsEscapeMenuGraphic(((Component)val2).transform)) { list.Add(new HudGraphicState(val2)); } } CanvasGroup[] array2 = componentsInChildren2; foreach (CanvasGroup val3 in array2) { if (!((Object)(object)val3 == (Object)null) && (!((Object)(object)styleTextRoot != (Object)null) || !((Transform)styleTextRoot).IsChildOf(((Component)val3).transform)) && (!((Object)(object)playerScreen != (Object)null) || !((Component)playerScreen).transform.IsChildOf(((Component)val3).transform)) && !IsEscapeMenuGraphic(((Component)val3).transform)) { list2.Add(new HudCanvasGroupState(val3)); } } hudGraphicStates = list.ToArray(); hudCanvasGroupStates = list2.ToArray(); } private void RefreshHudStates() { for (int i = 0; i < hudGraphicStates.Length; i++) { if ((Object)(object)hudGraphicStates[i].Graphic != (Object)null) { hudGraphicStates[i].OriginalEnabled = ((Behaviour)hudGraphicStates[i].Graphic).enabled; } } for (int j = 0; j < hudCanvasGroupStates.Length; j++) { CanvasGroup canvasGroup = hudCanvasGroupStates[j].CanvasGroup; if (!((Object)(object)canvasGroup == (Object)null)) { hudCanvasGroupStates[j].OriginalAlpha = canvasGroup.alpha; hudCanvasGroupStates[j].OriginalInteractable = canvasGroup.interactable; hudCanvasGroupStates[j].OriginalBlocksRaycasts = canvasGroup.blocksRaycasts; } } } private void ForceHudHiddenInstant() { HudGraphicState[] array = hudGraphicStates; for (int i = 0; i < array.Length; i++) { HudGraphicState hudGraphicState = array[i]; if ((Object)(object)hudGraphicState.Graphic != (Object)null) { ((Behaviour)hudGraphicState.Graphic).enabled = false; } } HudCanvasGroupState[] array2 = hudCanvasGroupStates; for (int j = 0; j < array2.Length; j++) { HudCanvasGroupState hudCanvasGroupState = array2[j]; CanvasGroup canvasGroup = hudCanvasGroupState.CanvasGroup; if (!((Object)(object)canvasGroup == (Object)null)) { canvasGroup.alpha = 0f; canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; } } if ((Object)(object)playerScreen != (Object)null) { ((Behaviour)playerScreen).enabled = true; } if ((Object)(object)styleTextRoot != (Object)null) { ((Component)styleTextRoot).gameObject.SetActive(false); } } private void RestoreHudInstant() { HudCanvasGroupState[] array = hudCanvasGroupStates; for (int i = 0; i < array.Length; i++) { HudCanvasGroupState hudCanvasGroupState = array[i]; CanvasGroup canvasGroup = hudCanvasGroupState.CanvasGroup; if (!((Object)(object)canvasGroup == (Object)null)) { canvasGroup.alpha = hudCanvasGroupState.OriginalAlpha; canvasGroup.interactable = hudCanvasGroupState.OriginalInteractable; canvasGroup.blocksRaycasts = hudCanvasGroupState.OriginalBlocksRaycasts; } } HudGraphicState[] array2 = hudGraphicStates; for (int j = 0; j < array2.Length; j++) { HudGraphicState hudGraphicState = array2[j]; if ((Object)(object)hudGraphicState.Graphic != (Object)null) { ((Behaviour)hudGraphicState.Graphic).enabled = hudGraphicState.OriginalEnabled; } } if ((Object)(object)playerScreen != (Object)null) { ((Behaviour)playerScreen).enabled = true; } SetStyleTextVisible(!IsEscapeMenuOpen()); } private bool IsEscapeMenuOpen() { QuickMenuManager val = GetQuickMenuManager(); if ((Object)(object)val != (Object)null) { return val.isMenuOpen; } return false; } private bool IsEscapeMenuGraphic(Transform target) { QuickMenuManager val = GetQuickMenuManager(); if ((Object)(object)val != (Object)null) { return target.IsChildOf(((Component)val).transform); } return false; } private QuickMenuManager GetQuickMenuManager() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)quickMenuManager != (Object)null) { return quickMenuManager; } QuickMenuManager[] array = Resources.FindObjectsOfTypeAll(); QuickMenuManager[] array2 = array; foreach (QuickMenuManager val in array2) { if ((Object)(object)val != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { quickMenuManager = val; return quickMenuManager; } } } return null; } private string GetInputDisplayName(ZoomInput input) { return input switch { ZoomInput.None => "None", ZoomInput.MouseMiddle => "M3", ZoomInput.MouseBack => "M4", ZoomInput.MouseForward => "M5", _ => GetKeyboardDisplayName(input.ToString()), }; } private string GetKeyboardDisplayName(string name) { if (name.StartsWith("Numpad")) { string text = name; int length = "Numpad".Length; return "Num " + text.Substring(length, text.Length - length); } if (name.StartsWith("Digit")) { string text = name; int length = "Digit".Length; return text.Substring(length, text.Length - length); } return name switch { "LeftCtrl" => "L Ctrl", "RightCtrl" => "R Ctrl", "LeftAlt" => "L Alt", "RightAlt" => "R Alt", "LeftShift" => "L Shift", "RightShift" => "R Shift", _ => name, }; } private string GetStyleDisplayName(ZoomStyle style) { return style switch { ZoomStyle.None => "None", ZoomStyle.Clean => "Clean", ZoomStyle.Binocular => "Binocular", ZoomStyle.Camcorder => "Camcorder", ZoomStyle.InLove => "In Love", ZoomStyle.GreedCurse => "Greed Curse", ZoomStyle.Melodrama => "Melodrama", ZoomStyle.SpiderEyes => "Spider Eyes", ZoomStyle.FlyEyes => "Fly Eyes", ZoomStyle.NightVision => "Night Vision", _ => style.ToString(), }; } } [BepInPlugin("OkayZoomer", "OkayZoomer", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugins : BaseUnityPlugin { private const string AssetBundleFileName = "okayzoomassets"; internal static Plugins Instance { get; private set; } internal static Harmony Harmony { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static ConfigFile Config { get; private set; } internal static ConfigEntries ConfigEntries { get; private set; } internal static Dictionary ZoomMaterialTemplates { get; private set; } public void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } Harmony = new Harmony("OkayZoomer"); Logger = Logger.CreateLogSource("OkayZoomer"); ConfigFile val = ConfigUtils.CreateLocalConfigFile((BaseUnityPlugin)(object)this, "bootstrap", saveOnInit: true); ConfigEntry val2 = val.Bind("Main", "Use Local Config", false, "If enabled, uses a local config file instead of the global config. Requires restart."); Config = (val2.Value ? ConfigUtils.CreateLocalConfigFile((BaseUnityPlugin)(object)this) : ConfigUtils.CreateGlobalConfigFile((BaseUnityPlugin)(object)this)); ConfigEntries = new ConfigEntries(); LoadZoomAssets(); Harmony.PatchAll(); val.Save(); Loggers.Info("Plugin OkayZoomer loaded!"); } private void LoadZoomAssets() { ZoomMaterialTemplates = new Dictionary(); string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = Path.Combine(directoryName, "okayzoomassets"); if (!File.Exists(text)) { Loggers.Warning("OkayZoomer AssetBundle was not found at: " + text); return; } AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { Loggers.Warning("Failed to load OkayZoomer AssetBundle."); return; } TryLoadMaterial(val, ZoomStyle.Binocular, "OZ_Zoom_Binocular"); TryLoadMaterial(val, ZoomStyle.Camcorder, "OZ_Zoom_Camcorder"); TryLoadMaterial(val, ZoomStyle.GreedCurse, "OZ_Zoom_GreedCurse"); TryLoadMaterial(val, ZoomStyle.Melodrama, "OZ_Zoom_Melodrama"); TryLoadMaterial(val, ZoomStyle.InLove, "OZ_Zoom_InLove"); TryLoadMaterial(val, ZoomStyle.SpiderEyes, "OZ_Zoom_SpiderEyes"); TryLoadMaterial(val, ZoomStyle.FlyEyes, "OZ_Zoom_FlyEyes"); TryLoadMaterial(val, ZoomStyle.NightVision, "OZ_Zoom_NightVision"); val.Unload(false); Loggers.Info($"Loaded {ZoomMaterialTemplates.Count} OkayZoomer material templates."); } private static void TryLoadMaterial(AssetBundle bundle, ZoomStyle style, string assetName) { Material val = LoadMaterialByName(bundle, assetName); if ((Object)(object)val == (Object)null) { Loggers.Warning($"Could not load zoom material '{assetName}' for style '{style}'."); return; } ZoomMaterialTemplates[style] = val; Loggers.Info($"Loaded zoom material '{assetName}' for style '{style}'."); } private static Material LoadMaterialByName(AssetBundle bundle, string assetName) { Material val = bundle.LoadAsset(assetName); if ((Object)(object)val != (Object)null) { return val; } string[] allAssetNames = bundle.GetAllAssetNames(); string[] array = allAssetNames; foreach (string text in array) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (string.Equals(fileNameWithoutExtension, assetName, StringComparison.OrdinalIgnoreCase)) { return bundle.LoadAsset(text); } } return null; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "OkayZoomer"; public const string PLUGIN_NAME = "OkayZoomer"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace OkayZoomer.Patches { [HarmonyPatch(typeof(HUDManager))] internal static class HUDManagerPatch { private const string PlayerScreenPath = "Systems/GameSystems/UI/Canvas/Panel/GameObject/PlayerScreen"; [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostfix(HUDManager __instance) { TryAttachZoomEffect(); } private static void TryAttachZoomEffect() { RawImage val = FindPlayerScreen(); if ((Object)(object)val == (Object)null) { Plugins.Logger.LogWarning((object)"Could not find PlayerScreen RawImage."); } else if (!((Object)(object)((Component)val).GetComponent() != (Object)null)) { ((Component)val).gameObject.AddComponent(); Plugins.Logger.LogInfo((object)"Added PlayerScreenZoomEffect to PlayerScreen."); } } private static RawImage FindPlayerScreen() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Systems/GameSystems/UI/Canvas/Panel/GameObject/PlayerScreen"); RawImage result = default(RawImage); if ((Object)(object)val != (Object)null && val.TryGetComponent(ref result)) { return result; } RawImage[] array = Resources.FindObjectsOfTypeAll(); RawImage[] array2 = array; foreach (RawImage val2 in array2) { if (!((Object)(object)val2 == (Object)null) && !(((Object)val2).name != "PlayerScreen")) { Scene scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return val2; } } } return null; } } } namespace OkayZoomer.Configs { public enum ColorblindMode { Off, Protanopia, Protanomaly, Deuteranopia, Deuteranomaly, Tritanopia, Tritanomaly, Achromatopsia, Achromatomaly } public class ConfigEntries { public ConfigEntry ToggleZoom { get; private set; } public ConfigEntry ZoomKey { get; private set; } public ConfigEntry PreviousStyleKey { get; private set; } public ConfigEntry NextStyleKey { get; private set; } public ConfigEntry ZoomFOV { get; private set; } public ConfigEntry ZoomSpeed { get; private set; } public ConfigEntry ZoomStyle { get; private set; } public ConfigEntry StyleBlacklist { get; private set; } public ConfigEntry ShowStyleKeybindTexts { get; private set; } public ConfigEntry StyleTextPositionX { get; private set; } public ConfigEntry StyleTextPositionY { get; private set; } public ConfigEntries() { ConfigFile config = Plugins.Config; config.SaveOnConfigSet = false; Setup(); config.OrphanedEntries.Clear(); config.SaveOnConfigSet = true; config.Save(); } private void Setup() { ConfigHelper.SkipAutoGen(); ToggleZoom = ConfigHelper.Bind("Controls", "Toggle Zoom", defaultValue: false, "If enabled, pressing the zoom key toggles zoom on/off. If disabled, zoom only stays active while the key is held."); ZoomKey = ConfigHelper.Bind("Controls", "Zoom Key", ZoomInput.MouseMiddle, "Input used to zoom. Supports keyboard keys, MouseMiddle, MouseBack, and MouseForward."); PreviousStyleKey = ConfigHelper.Bind("Controls", "Previous Style Key", ZoomInput.Numpad1, "Input used to switch to the previous zoom style. Supports keyboard keys, MouseMiddle, MouseBack, and MouseForward."); NextStyleKey = ConfigHelper.Bind("Controls", "Next Style Key", ZoomInput.Numpad3, "Input used to switch to the next zoom style. Supports keyboard keys, MouseMiddle, MouseBack, and MouseForward."); ZoomFOV = ConfigHelper.Bind("Zoom", "Zoom FOV", 25f, "Camera FOV while zoomed.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(1f, 120f)); ZoomSpeed = ConfigHelper.Bind("Zoom", "Zoom Speed", 8f, "How quickly zoom enters and exits.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 50f)); ZoomStyle = ConfigHelper.Bind("Visuals", "Zoom Style", OkayZoomer.Configs.ZoomStyle.Binocular, "Visual style used while zooming. None disables zoom entirely. Clean means FOV zoom only."); StyleBlacklist = ConfigHelper.Bind("Visuals", "Style Blacklist", "", "Comma-separated zoom styles to skip when cycling. Example: FlyEyes, SpiderEyes, InLove"); ShowStyleKeybindTexts = ConfigHelper.Bind("Visuals", "Show Style Keybind Texts", defaultValue: true, "If enabled, shows the previous, zoom, and next input texts above the zoom style name."); StyleTextPositionX = ConfigHelper.Bind("Visuals", "Style Text Position X", 0f, "Moves the zoom style text horizontally. Positive moves right, negative moves left.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(-2000f, 2000f)); StyleTextPositionY = ConfigHelper.Bind("Visuals", "Style Text Position Y", 0f, "Moves the zoom style text vertically. Positive moves down, negative moves up.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(-1200f, 1200f)); } } internal static class ConfigHelper { internal static void SkipAutoGen() { if (ModCompats.IsLethalConfigPresent) { LethalConfigProxy.SkipAutoGen(); } } internal static ConfigEntry Bind(bool isHexColor, string section, string key, string defaultValue, string description, bool requiresRestart = false, AcceptableValueBase acceptableValues = null, Action settingChanged = null, ConfigFile configFile = null) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (configFile == null) { configFile = Plugins.Config; } ConfigEntry configEntry = ((acceptableValues == null) ? configFile.Bind(section, key, defaultValue, description) : configFile.Bind(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty()))); if (settingChanged != null) { configEntry.SettingChanged += delegate { settingChanged?.Invoke(configEntry.Value); }; } if (ModCompats.IsLethalConfigPresent) { LethalConfigProxy.AddConfig(configEntry, requiresRestart, isHexColor); } return configEntry; } internal static ConfigEntry Bind(string section, string key, T defaultValue, string description, bool requiresRestart = false, AcceptableValueBase acceptableValues = null, Action settingChanged = null, ConfigFile configFile = null) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (configFile == null) { configFile = Plugins.Config; } ConfigEntry configEntry = ((acceptableValues == null) ? configFile.Bind(section, key, defaultValue, description) : configFile.Bind(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty()))); if (settingChanged != null) { configEntry.SettingChanged += delegate { settingChanged?.Invoke(configEntry.Value); }; } if (ModCompats.IsLethalConfigPresent) { LethalConfigProxy.AddConfig(configEntry, requiresRestart); } return configEntry; } internal static void SetConfigEntryValue(ConfigEntry configEntry, string value) { if (typeof(T) == typeof(int) && int.TryParse(value, out var result)) { configEntry.Value = (T)(object)result; return; } if (typeof(T) == typeof(float) && float.TryParse(value, out var result2)) { configEntry.Value = (T)(object)result2; return; } if (typeof(T) == typeof(double) && double.TryParse(value, out var result3)) { configEntry.Value = (T)(object)result3; return; } if (typeof(T) == typeof(bool) && bool.TryParse(value, out var result4)) { configEntry.Value = (T)(object)result4; return; } if (typeof(T) == typeof(string)) { configEntry.Value = (T)(object)value; return; } throw new InvalidOperationException($"Unsupported type: {typeof(T)}"); } } internal static class ConfigUtils { private static string GetPluginPersistentDataPath() { return Path.Combine(Application.persistentDataPath, "OkayZoomer"); } private static ConfigFile CreateConfigFile(BaseUnityPlugin plugin, string path, string name = null, bool saveOnInit = false) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown BepInPlugin metadata = MetadataHelper.GetMetadata((object)plugin); if (name == null) { name = metadata.GUID; } name += ".cfg"; return new ConfigFile(Path.Combine(path, name), saveOnInit, metadata); } internal static ConfigFile CreateLocalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { return CreateConfigFile(plugin, Paths.ConfigPath, name, saveOnInit); } internal static ConfigFile CreateGlobalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { string pluginPersistentDataPath = GetPluginPersistentDataPath(); if (name == null) { name = "global"; } return CreateConfigFile(plugin, pluginPersistentDataPath, name, saveOnInit); } } public enum ZoomInput { None, MouseMiddle, MouseBack, MouseForward, Space, Enter, Tab, Backquote, Quote, Semicolon, Comma, Period, Slash, Backslash, LeftBracket, RightBracket, Minus, Equals, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Digit1, Digit2, Digit3, Digit4, Digit5, Digit6, Digit7, Digit8, Digit9, Digit0, LeftShift, RightShift, LeftAlt, RightAlt, LeftCtrl, RightCtrl, LeftMeta, RightMeta, ContextMenu, Escape, LeftArrow, RightArrow, UpArrow, DownArrow, Backspace, PageDown, PageUp, Home, End, Insert, Delete, CapsLock, NumLock, PrintScreen, ScrollLock, Pause, NumpadEnter, NumpadDivide, NumpadMultiply, NumpadPlus, NumpadMinus, NumpadPeriod, NumpadEquals, Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12 } public enum ZoomStyle { None, Clean, Binocular, Camcorder, GreedCurse, Melodrama, InLove, SpiderEyes, FlyEyes, NightVision } } namespace OkayZoomer.Compats { internal static class LethalConfigProxy { [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SkipAutoGen() { LethalConfigManager.SkipAutoGen(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry configEntry, bool requiresRestart = false, bool isHexColor = false) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown BaseConfigItem val = (BaseConfigItem)((!isHexColor) ? ((object)new TextInputFieldConfigItem(configEntry, requiresRestart)) : ((object)new HexColorInputFieldConfigItem(configEntry, requiresRestart))); LethalConfigManager.AddConfigItem(val); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry configEntry, bool requiresRestart = false) { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues; if (acceptableValues != null) { if (acceptableValues is AcceptableValueRange || acceptableValues is AcceptableValueRange) { AddConfigSlider(configEntry); return; } if (acceptableValues is AcceptableValueList) { AddConfigDropdown(configEntry); return; } } if (typeof(T).IsEnum) { Type type = typeof(EnumDropDownConfigItem<>).MakeGenericType(typeof(T)); object obj = Activator.CreateInstance(type, configEntry, requiresRestart); MethodInfo methodInfo = AccessTools.Method(typeof(LethalConfigManager), "AddConfigItem", new Type[1] { type }, (Type[])null); methodInfo.Invoke(null, new object[1] { obj }); } else if (!(configEntry is ConfigEntry val)) { if (!(configEntry is ConfigEntry val2)) { if (!(configEntry is ConfigEntry val3)) { if (!(configEntry is ConfigEntry val4)) { throw new NotSupportedException($"Unsupported type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigSlider(ConfigEntry configEntry, bool requiresRestart = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (!(configEntry is ConfigEntry val)) { if (!(configEntry is ConfigEntry val2)) { throw new NotSupportedException($"Slider not supported for type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigDropdown(ConfigEntry configEntry, bool requiresRestart = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (configEntry is ConfigEntry val) { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart)); return; } throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}"); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddButton(string section, string name, string description, string buttonText, Action callback) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); })); } } internal class ModCompats { internal const string LethalConfig_PLUGIN_GUID = "ainavt.lc.lethalconfig"; internal static bool IsLethalConfigPresent => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace OkayZoomer.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }