using System; using System.Collections.Generic; 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering.PostProcessing; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("REPOJP")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("zabuMod")] [assembly: AssemblyTitle("zabuMod")] [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 BetterView { [BepInPlugin("REPOJP.BetterView", "BetterView", "1.1.0")] public class BetterViewPlugin : BaseUnityPlugin { private struct DistanceSettings { internal readonly float FogStart; internal readonly float FogEnd; internal readonly float FarClip; internal DistanceSettings(float fogStart, float fogEnd, float farClip) { FogStart = fogStart; FogEnd = fogEnd; FarClip = farClip; } } private struct PropLightState { internal readonly float OriginalIntensity; internal readonly float CurrentIntensity; internal readonly float OriginalRange; internal PropLightState(float originalIntensity, float currentIntensity, float originalRange) { OriginalIntensity = originalIntensity; CurrentIntensity = currentIntensity; OriginalRange = originalRange; } } private struct PropEmissionState { internal readonly Color OriginalEmission; internal readonly Color CurrentEmission; internal PropEmissionState(Color originalEmission, Color currentEmission) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) OriginalEmission = originalEmission; CurrentEmission = currentEmission; } } private struct ItemLightState { internal readonly float OriginalIntensity; internal readonly float OriginalRange; internal readonly float OriginalFresnel; internal readonly float CurrentIntensity; internal readonly float CurrentRange; internal ItemLightState(float originalIntensity, float originalRange, float originalFresnel, float currentIntensity, float currentRange) { OriginalIntensity = originalIntensity; OriginalRange = originalRange; OriginalFresnel = originalFresnel; CurrentIntensity = currentIntensity; CurrentRange = currentRange; } } internal class BetterViewZoomController : MonoBehaviour { private const float ZoomHoldSeconds = 0.15f; private const float ZoomDisplaySeconds = 1.25f; private const int ZoomPriority = 0; private const int ZoomDisplayFontSize = 28; private bool zoomKeyWasDown; private Canvas zoomDisplayCanvas; private Text zoomDisplayText; private float zoomDisplayTimer; private float zoomBoundsRestoreTimer; private CameraZoom boundedCameraZoom; private bool hasOriginalMinimumZoom; private float originalMinimumZoom; private void Update() { try { HandleDebugToggleKey(); UpdateZoomBoundsRestoreTimer(); bool key = Input.GetKey((KeyCode)122); if (!key && !zoomKeyWasDown) { HideZoomRateDisplay(); return; } if (!CanApplyNow()) { ResetZoomStateOnly(); return; } if (!key) { StartZoomRelease(); return; } if (ApplyWheelZoomAdjustment()) { ShowZoomRateDisplay(cachedZoomRate); } UpdateZoomRateDisplayTimer(); CameraZoom instance = CameraZoom.Instance; if ((Object)(object)instance == (Object)null) { RestoreCameraZoomBounds(); zoomKeyWasDown = true; return; } float baseZoom = GetBaseZoom(instance); float num = Mathf.Clamp(baseZoom / cachedZoomRate, 0.1f, instance.MaximumZoom); EnsureCameraZoomBounds(instance, num); instance.OverrideZoomSet(num, 0.15f, cachedZoomSmoothInSpeed, cachedZoomSmoothOutSpeed, ((Component)this).gameObject, 0); zoomKeyWasDown = true; } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: Zoom Update\n" + ex)); } } } internal void ResetZoomStateOnly() { zoomKeyWasDown = false; zoomBoundsRestoreTimer = 0f; RestoreCameraZoomBounds(); HideZoomRateDisplay(); } private void StartZoomRelease() { zoomKeyWasDown = false; HideZoomRateDisplay(); if (hasOriginalMinimumZoom) { zoomBoundsRestoreTimer = Mathf.Max(0.25f, 1f / Mathf.Max(cachedZoomSmoothOutSpeed, 0.1f) + 0.2f); } } private void UpdateZoomBoundsRestoreTimer() { if (!(zoomBoundsRestoreTimer <= 0f)) { zoomBoundsRestoreTimer -= Time.deltaTime; if (zoomBoundsRestoreTimer <= 0f) { RestoreCameraZoomBounds(); } } } private bool ApplyWheelZoomAdjustment() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) <= 0.001f) { return false; } int num = Mathf.FloorToInt(cachedZoomRate * 10f + 0.0001f); num += ((y > 0f) ? 1 : (-1)); num = Mathf.Clamp(num, 10, 100); float num2 = (float)num / 10f; if (NearlyEqual(num2, cachedZoomRate)) { ShowZoomRateDisplay(cachedZoomRate); return false; } cachedZoomRate = num2; if (cachedSaveWheelZoomToConfig && ZoomRate != null) { ZoomRate.Value = num2; if (configFile != null) { configFile.Save(); } } return true; } private void EnsureCameraZoomBounds(CameraZoom cameraZoom, float targetZoom) { if ((Object)(object)cameraZoom == (Object)null) { RestoreCameraZoomBounds(); return; } if ((Object)(object)boundedCameraZoom != (Object)null && (Object)(object)boundedCameraZoom != (Object)(object)cameraZoom) { RestoreCameraZoomBounds(); } if (!hasOriginalMinimumZoom) { boundedCameraZoom = cameraZoom; originalMinimumZoom = cameraZoom.MinimumZoom; hasOriginalMinimumZoom = true; } float num = Mathf.Max(0.1f, targetZoom - 0.1f); if (cameraZoom.MinimumZoom > num) { cameraZoom.MinimumZoom = num; } } private void RestoreCameraZoomBounds() { if (hasOriginalMinimumZoom && (Object)(object)boundedCameraZoom != (Object)null) { boundedCameraZoom.MinimumZoom = originalMinimumZoom; } zoomBoundsRestoreTimer = 0f; boundedCameraZoom = null; hasOriginalMinimumZoom = false; originalMinimumZoom = 0f; } private void EnsureZoomRateDisplay() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)zoomDisplayCanvas != (Object)null) || !((Object)(object)zoomDisplayText != (Object)null)) { GameObject val = new GameObject("BetterViewZoomDisplayCanvas"); val.transform.parent = null; ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); zoomDisplayCanvas = val.AddComponent(); zoomDisplayCanvas.renderMode = (RenderMode)0; zoomDisplayCanvas.sortingOrder = 32767; CanvasScaler val2 = val.AddComponent(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.matchWidthOrHeight = 0.5f; GameObject val3 = new GameObject("BetterViewZoomDisplayText"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent(); val4.anchorMin = new Vector2(0.5f, 0f); val4.anchorMax = new Vector2(0.5f, 0f); val4.pivot = new Vector2(0.5f, 0f); val4.anchoredPosition = new Vector2(0f, 120f); val4.sizeDelta = new Vector2(640f, 64f); zoomDisplayText = val3.AddComponent(); zoomDisplayText.font = Resources.GetBuiltinResource("Arial.ttf"); zoomDisplayText.fontSize = 28; zoomDisplayText.alignment = (TextAnchor)4; ((Graphic)zoomDisplayText).color = Color.white; ((Graphic)zoomDisplayText).raycastTarget = false; Shadow val5 = val3.AddComponent(); val5.effectColor = new Color(0f, 0f, 0f, 0.85f); val5.effectDistance = new Vector2(2f, -2f); ((Behaviour)zoomDisplayCanvas).enabled = false; } } private void ShowZoomRateDisplay(float zoomRate) { EnsureZoomRateDisplay(); if (!((Object)(object)zoomDisplayCanvas == (Object)null) && !((Object)(object)zoomDisplayText == (Object)null)) { zoomDisplayText.text = "Zoom x" + zoomRate.ToString("0.0"); zoomDisplayTimer = 1.25f; ((Behaviour)zoomDisplayCanvas).enabled = true; } } private void UpdateZoomRateDisplayTimer() { if (!((Object)(object)zoomDisplayCanvas == (Object)null) && ((Behaviour)zoomDisplayCanvas).enabled) { zoomDisplayTimer -= Time.deltaTime; if (zoomDisplayTimer <= 0f) { HideZoomRateDisplay(); } } } private void HideZoomRateDisplay() { zoomDisplayTimer = 0f; if ((Object)(object)zoomDisplayCanvas != (Object)null) { ((Behaviour)zoomDisplayCanvas).enabled = false; } } private static float GetBaseZoom(CameraZoom cameraZoom) { if ((Object)(object)cameraZoom != (Object)null && cameraZoom.playerZoomDefault > 0f) { return cameraZoom.playerZoomDefault; } Camera mainGameplayCamera = GetMainGameplayCamera(); if ((Object)(object)mainGameplayCamera != (Object)null && mainGameplayCamera.fieldOfView > 0f) { return mainGameplayCamera.fieldOfView; } return 60f; } } [HarmonyPatch(typeof(EnvironmentDirector), "Setup")] internal static class EnvironmentDirectorSetupPatch { private static void Postfix() { ApplyViewDistance(force: true); ApplyVisualSettings(force: true); ApplyGraphicsSettings(force: true); ApplyGlowSettings(force: true); } } [HarmonyPatch(typeof(EnvironmentDirector), "Update")] internal static class EnvironmentDirectorUpdatePatch { private static void Postfix() { ApplyAmbientBrightness(); } } internal static class SpectateCameraStateNormalPatch { internal static void Postfix() { ApplyViewDistance(force: false); } } [HarmonyPatch(typeof(SpectateCamera), "StopSpectate")] internal static class SpectateCameraStopPatch { private static void Postfix() { ApplyViewDistance(force: true); } } [HarmonyPatch(typeof(PostProcessing), "Setup")] internal static class PostProcessingSetupPatch { private static void Postfix(PostProcessing __instance) { ApplyVisualSettings(force: true); } } [HarmonyPatch(typeof(PostProcessing), "VignetteOverride")] internal static class PostProcessingVignetteOverridePatch { private static void Prefix(ref float _intensity) { if (ShouldDisableVisualEffects()) { _intensity *= 0f; } } } [HarmonyPatch(typeof(PostProcessing), "SaturationOverride")] internal static class PostProcessingSaturationOverridePatch { private static void Prefix(PostProcessing __instance, ref float _amount) { if (ShouldDisableVisualEffects()) { float privateFloat = GetPrivateFloat(postColorGradingSaturationField, __instance, _amount); _amount = privateFloat + (_amount - privateFloat) * 0f; } } } [HarmonyPatch(typeof(PostProcessing), "ContrastOverride")] internal static class PostProcessingContrastOverridePatch { private static void Prefix(PostProcessing __instance, ref float _amount) { if (ShouldDisableVisualEffects()) { float privateFloat = GetPrivateFloat(postColorGradingContrastField, __instance, _amount); _amount = privateFloat + (_amount - privateFloat) * 0f; } } } [HarmonyPatch(typeof(GraphicsManager), "UpdateAll")] internal static class GraphicsManagerUpdateAllPatch { private static void Postfix() { ApplyVisualSettings(force: false); ApplyGraphicsSettings(force: false); ApplyGlowSettings(force: false); } } [HarmonyPatch(typeof(GraphicsManager), "UpdateMotionBlur")] internal static class GraphicsManagerUpdateMotionBlurPatch { private static void Postfix() { if (ShouldDisableVisualEffects()) { ApplyPostProcessEffectToggles(PostProcessing.Instance); } } } [HarmonyPatch(typeof(GraphicsManager), "UpdateLensDistortion")] internal static class GraphicsManagerUpdateLensDistortionPatch { private static void Postfix() { if (ShouldDisableVisualEffects()) { ApplyPostProcessEffectToggles(PostProcessing.Instance); } } } [HarmonyPatch(typeof(GraphicsManager), "UpdateChromaticAberration")] internal static class GraphicsManagerUpdateChromaticAberrationPatch { private static void Postfix() { if (ShouldDisableVisualEffects()) { ApplyPostProcessEffectToggles(PostProcessing.Instance); } } } [HarmonyPatch(typeof(GraphicsManager), "UpdateGrain")] internal static class GraphicsManagerUpdateGrainPatch { private static void Postfix() { if (ShouldDisableVisualEffects()) { ApplyPostProcessEffectToggles(PostProcessing.Instance); } } } [HarmonyPatch(typeof(GraphicsManager), "UpdateGlitchLoop")] internal static class GraphicsManagerUpdateGlitchLoopPatch { private static void Postfix() { ApplyGraphicsSettings(force: false); } } [HarmonyPatch(typeof(GraphicsManager), "UpdateRenderSize")] internal static class GraphicsManagerUpdateRenderSizePatch { private static void Postfix() { ApplyGraphicsSettings(force: false); } } [HarmonyPatch(typeof(VideoOverlay), "Override")] internal static class VideoOverlayOverridePatch { private static bool Prefix(ref float amount) { if (!ShouldDisableVisualEffects()) { return true; } amount *= 0f; return amount > 0.001f; } } [HarmonyPatch(typeof(CameraGlitch), "PlayLong")] internal static class CameraGlitchPlayLongPatch { private static bool Prefix() { return AllowCameraGlitch(); } } [HarmonyPatch(typeof(CameraGlitch), "PlayShort")] internal static class CameraGlitchPlayShortPatch { private static bool Prefix() { return AllowCameraGlitch(); } } [HarmonyPatch(typeof(CameraGlitch), "PlayTiny")] internal static class CameraGlitchPlayTinyPatch { private static bool Prefix() { return AllowCameraGlitch(); } } [HarmonyPatch(typeof(CameraGlitch), "DoNotLookEffectSet")] internal static class CameraGlitchDoNotLookEffectSetPatch { private static bool Prefix() { if (!ShouldDisableVisualEffects()) { return true; } return Random.value < 0f; } } [HarmonyPatch(typeof(PropLight), "Awake")] internal static class PropLightAwakePatch { private static void Postfix(PropLight __instance) { ApplyPropLightGlow(__instance); } } [HarmonyPatch(typeof(PropLight), "Start")] internal static class PropLightStartPatch { private static void Postfix(PropLight __instance) { ApplyPropLightGlow(__instance); } } [HarmonyPatch(typeof(PropLightEmission), "Awake")] internal static class PropLightEmissionAwakePatch { private static void Postfix(PropLightEmission __instance) { ApplyPropEmissionGlow(__instance); } } [HarmonyPatch(typeof(ItemLight), "Start")] internal static class ItemLightStartPatch { private static void Postfix(ItemLight __instance) { ApplyItemLightGlow(__instance); } } [HarmonyPatch(typeof(LightManager), "Setup")] internal static class LightManagerSetupPatch { private static void Postfix() { ApplyGlowSettings(force: true); } } [HarmonyPatch(typeof(RenderTextureMain), "ChangeResolution")] internal static class RenderTextureMainChangeResolutionPatch { private static bool Prefix() { return !ShouldDisableVisualEffects(); } } [HarmonyPatch(typeof(RenderTextureMain), "ChangeSize")] internal static class RenderTextureMainChangeSizePatch { private static bool Prefix() { return !ShouldDisableVisualEffects(); } } [HarmonyPatch(typeof(RenderTextureMain), "Shake")] internal static class RenderTextureMainShakePatch { private static bool Prefix() { return !ShouldDisableVisualEffects(); } } public const string PluginGuid = "REPOJP.BetterView"; public const string PluginName = "BetterView"; public const string PluginVersion = "1.1.0"; private const float FarClipExtraDistance = 1f; private const float EffectsOffLevelVignetteMultiplier = 0f; private const float EffectsOffDynamicVignetteMultiplier = 0f; private const float EffectsOffDynamicSaturationMultiplier = 0f; private const float EffectsOffDynamicContrastMultiplier = 0f; private const float EffectsOffLowHealthVignetteMultiplier = 0f; private const float EffectsOffVideoOverlayMultiplier = 0f; private const float EffectsOffCameraGlitchChanceMultiplier = 0f; private const float EffectsOffDoNotLookGlitchChanceMultiplier = 0f; private const float BrightAmbientBrightnessMultiplier = 10f; private const float BrightBloomIntensityMultiplier = 0f; private const float BrightBloomThresholdMultiplier = 5f; private const float BrightColorTemperatureMultiplier = 0f; private const float BrightColorFilterBlend = 0f; private const float FixedGlowBloomMultiplier = 10f; private const float FixedGlowPropLightMultiplier = 10f; private const float FixedGlowPropLightEmissionMultiplier = 10f; private const float FixedGlowItemLightMultiplier = 10f; private const float GlowBloomIntensityMaxValue = 1.5f; private const float GlowBloomThresholdMinValue = 1.75f; private const float GlowLightIntensityMaxMultiplier = 2f; private const float GlowLightRangeMaxMultiplier = 1.15f; private const float GlowEmissionMaxMultiplier = 2f; private const float GlowItemFresnelMaxMultiplier = 2f; private const float GlowColorMaxValue = 3f; internal static ManualLogSource Log; internal static ConfigEntry EnableMod; internal static ConfigEntry FogStartDistance; internal static ConfigEntry ViewDistance; internal static ConfigEntry ApplyToSpectateCamera; internal static ConfigEntry ZoomRate; internal static ConfigEntry SaveWheelZoomToConfig; internal static ConfigEntry ZoomSmoothInSpeed; internal static ConfigEntry ZoomSmoothOutSpeed; internal static ConfigEntry DisableVisualEffects; internal static ConfigEntry BrightenView; internal static ConfigEntry EnhanceGlowObjects; internal static ConfigEntry EnableDebugToggleKey; private static ConfigFile configFile; private static Harmony harmony; private static FieldInfo environmentMainCameraField; private static FieldInfo environmentDarkAdaptationLerpField; private static FieldInfo environmentDarkAdaptationCurveField; private static FieldInfo postColorGradingSaturationField; private static FieldInfo postColorGradingContrastField; private static FieldInfo postVignetteColorField; private static FieldInfo postVignetteIntensityField; private static FieldInfo postVignetteSmoothnessField; private static FieldInfo graphicsGlitchLoopField; private static FieldInfo renderTextureWidthOriginalField; private static FieldInfo renderTextureHeightOriginalField; private static FieldInfo renderTextureWidthField; private static FieldInfo renderTextureHeightField; private static FieldInfo renderTextureResetTimerField; private static FieldInfo renderTextureShakeActiveField; private static FieldInfo renderTextureShakeTimerField; private static FieldInfo renderTextureSizeResetTimerField; private static FieldInfo renderTextureOriginalSizeField; private static FieldInfo propLightOriginalIntensityField; private static FieldInfo propLightLightComponentField; private static FieldInfo propEmissionOriginalEmissionField; private static FieldInfo propEmissionMaterialField; private static FieldInfo itemLightIntensityOriginalField; private static FieldInfo itemLightRangeOriginalField; private static FieldInfo itemLightFresnelScaleOriginalField; private static bool spectateStateNormalPatched; private static BetterViewZoomController zoomController; private static bool cachedEnableMod; private static float cachedFogStartDistance; private static float cachedViewDistance; private static bool cachedApplyToSpectateCamera; private static float cachedZoomRate; private static bool cachedSaveWheelZoomToConfig; private static float cachedZoomSmoothInSpeed; private static float cachedZoomSmoothOutSpeed; private static bool cachedDisableVisualEffects; private static bool cachedBrightenView; private static bool cachedEnhanceGlowObjects; private static bool cachedEnableDebugToggleKey; private static bool debugForceVanillaView; private static bool hasApplied; private static bool hasAppliedAmbientBrightness; private static int appliedCameraId = -1; private static float appliedFogStart = -1f; private static float appliedFogEnd = -1f; private static float appliedFarClip = -1f; private static readonly Dictionary propLightStates = new Dictionary(); private static readonly Dictionary propEmissionStates = new Dictionary(); private static readonly Dictionary itemLightStates = new Dictionary(); private void Awake() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown try { Log = ((BaseUnityPlugin)this).Logger; configFile = ((BaseUnityPlugin)this).Config; ((Component)this).transform.parent = null; ((Object)this).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); BindConfigEntries(); UpdateCachedConfigValues(); RegisterConfigChangeEvents(); CacheReflectionFields(); harmony = new Harmony("REPOJP.BetterView"); harmony.PatchAll(typeof(EnvironmentDirectorSetupPatch)); harmony.PatchAll(typeof(EnvironmentDirectorUpdatePatch)); harmony.PatchAll(typeof(SpectateCameraStopPatch)); harmony.PatchAll(typeof(PostProcessingSetupPatch)); harmony.PatchAll(typeof(PostProcessingVignetteOverridePatch)); harmony.PatchAll(typeof(PostProcessingSaturationOverridePatch)); harmony.PatchAll(typeof(PostProcessingContrastOverridePatch)); harmony.PatchAll(typeof(GraphicsManagerUpdateAllPatch)); harmony.PatchAll(typeof(GraphicsManagerUpdateMotionBlurPatch)); harmony.PatchAll(typeof(GraphicsManagerUpdateLensDistortionPatch)); harmony.PatchAll(typeof(GraphicsManagerUpdateChromaticAberrationPatch)); harmony.PatchAll(typeof(GraphicsManagerUpdateGrainPatch)); harmony.PatchAll(typeof(GraphicsManagerUpdateGlitchLoopPatch)); harmony.PatchAll(typeof(GraphicsManagerUpdateRenderSizePatch)); harmony.PatchAll(typeof(VideoOverlayOverridePatch)); harmony.PatchAll(typeof(CameraGlitchPlayLongPatch)); harmony.PatchAll(typeof(CameraGlitchPlayShortPatch)); harmony.PatchAll(typeof(CameraGlitchPlayTinyPatch)); harmony.PatchAll(typeof(CameraGlitchDoNotLookEffectSetPatch)); harmony.PatchAll(typeof(RenderTextureMainChangeResolutionPatch)); harmony.PatchAll(typeof(RenderTextureMainChangeSizePatch)); harmony.PatchAll(typeof(RenderTextureMainShakePatch)); harmony.PatchAll(typeof(PropLightAwakePatch)); harmony.PatchAll(typeof(PropLightStartPatch)); harmony.PatchAll(typeof(PropLightEmissionAwakePatch)); harmony.PatchAll(typeof(ItemLightStartPatch)); harmony.PatchAll(typeof(LightManagerSetupPatch)); RefreshSpectatePatch(); CreateZoomController(); Log.LogInfo((object)"Success: BetterView loaded."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failure: Awake\n" + ex)); } } private void BindConfigEntries() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown EnableMod = ((BaseUnityPlugin)this).Config.Bind("General", "EnableMod", true, "Enable this mod.このMODを有効化"); FogStartDistance = ((BaseUnityPlugin)this).Config.Bind("General", "FogStartDistance", 100f, new ConfigDescription("Distance where black fog starts.黒いFogが始まる距離", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 500f), Array.Empty())); ViewDistance = ((BaseUnityPlugin)this).Config.Bind("General", "ViewDistance", 100f, new ConfigDescription("Distance where black fog fully covers the view.黒いFogで完全に見えなくなる距離", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 500f), Array.Empty())); ApplyToSpectateCamera = ((BaseUnityPlugin)this).Config.Bind("General", "ApplyToSpectateCamera", true, "Apply view distance settings while spectating.観戦中にも描画距離設定を適用"); ZoomRate = ((BaseUnityPlugin)this).Config.Bind("Zoom", "ZoomRate", 5f, new ConfigDescription("Zoom multiplier used while holding Z.Zキー押下中に使用するZoom倍率", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 10f), Array.Empty())); SaveWheelZoomToConfig = ((BaseUnityPlugin)this).Config.Bind("Zoom", "SaveWheelZoomToConfig", true, "Save mouse wheel zoom adjustments to the config file.マウスホイールで調整したZoom倍率をConfigへ保存"); ZoomSmoothInSpeed = ((BaseUnityPlugin)this).Config.Bind("Zoom", "ZoomSmoothInSpeed", 6f, new ConfigDescription("Smooth zoom in speed.ズームインのヌルッとした補間速度", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 30f), Array.Empty())); ZoomSmoothOutSpeed = ((BaseUnityPlugin)this).Config.Bind("Zoom", "ZoomSmoothOutSpeed", 5f, new ConfigDescription("Smooth zoom out speed.ズームアウトのヌルッとした補間速度", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 30f), Array.Empty())); DisableVisualEffects = ((BaseUnityPlugin)this).Config.Bind("Visual", "DisableVisualEffects", true, "Remove visual effects that reduce visibility while keeping damage feedback.ダメージ時の被弾演出を残して視界を悪くする演出をなくす"); BrightenView = ((BaseUnityPlugin)this).Config.Bind("Visual", "BrightenView", true, "Apply brightness and color adjustments for a clearer view.明るく見やすくする画面補正を適用"); EnhanceGlowObjects = ((BaseUnityPlugin)this).Config.Bind("Visual", "EnhanceGlowObjects", true, "Enhance glowing valuables and map objects.発光する貴重品とマップオブジェクトを強化"); EnableDebugToggleKey = ((BaseUnityPlugin)this).Config.Bind("Debug", "EnableDebugToggleKey", false, "Enable Shift+F to instantly switch between vanilla view and modded view.Shift+Fでバニラ表示とMOD適用表示を瞬時に切り替え"); } private static void CacheReflectionFields() { environmentMainCameraField = AccessTools.Field(typeof(EnvironmentDirector), "MainCamera"); environmentDarkAdaptationLerpField = AccessTools.Field(typeof(EnvironmentDirector), "DarkAdaptationLerp"); environmentDarkAdaptationCurveField = AccessTools.Field(typeof(EnvironmentDirector), "DarkAdaptationCurve"); postColorGradingSaturationField = AccessTools.Field(typeof(PostProcessing), "colorGradingSaturation"); postColorGradingContrastField = AccessTools.Field(typeof(PostProcessing), "colorGradingContrast"); postVignetteColorField = AccessTools.Field(typeof(PostProcessing), "vignetteColor"); postVignetteIntensityField = AccessTools.Field(typeof(PostProcessing), "vignetteIntensity"); postVignetteSmoothnessField = AccessTools.Field(typeof(PostProcessing), "vignetteSmoothness"); graphicsGlitchLoopField = AccessTools.Field(typeof(GraphicsManager), "glitchLoop"); renderTextureWidthOriginalField = AccessTools.Field(typeof(RenderTextureMain), "textureWidthOriginal"); renderTextureHeightOriginalField = AccessTools.Field(typeof(RenderTextureMain), "textureHeightOriginal"); renderTextureWidthField = AccessTools.Field(typeof(RenderTextureMain), "textureWidth"); renderTextureHeightField = AccessTools.Field(typeof(RenderTextureMain), "textureHeight"); renderTextureResetTimerField = AccessTools.Field(typeof(RenderTextureMain), "textureResetTimer"); renderTextureShakeActiveField = AccessTools.Field(typeof(RenderTextureMain), "shakeActive"); renderTextureShakeTimerField = AccessTools.Field(typeof(RenderTextureMain), "shakeTimer"); renderTextureSizeResetTimerField = AccessTools.Field(typeof(RenderTextureMain), "sizeResetTimer"); renderTextureOriginalSizeField = AccessTools.Field(typeof(RenderTextureMain), "originalSize"); propLightOriginalIntensityField = AccessTools.Field(typeof(PropLight), "originalIntensity"); propLightLightComponentField = AccessTools.Field(typeof(PropLight), "lightComponent"); propEmissionOriginalEmissionField = AccessTools.Field(typeof(PropLightEmission), "originalEmission"); propEmissionMaterialField = AccessTools.Field(typeof(PropLightEmission), "material"); itemLightIntensityOriginalField = AccessTools.Field(typeof(ItemLight), "lightIntensityOriginal"); itemLightRangeOriginalField = AccessTools.Field(typeof(ItemLight), "lightRangeOriginal"); itemLightFresnelScaleOriginalField = AccessTools.Field(typeof(ItemLight), "fresnelScaleOriginal"); } private static void CreateZoomController() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!((Object)(object)zoomController != (Object)null)) { GameObject val = new GameObject("BetterViewZoomController"); val.transform.parent = null; ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); zoomController = val.AddComponent(); } } private static void RegisterConfigChangeEvents() { EnableMod.SettingChanged += OnConfigChanged; FogStartDistance.SettingChanged += OnConfigChanged; ViewDistance.SettingChanged += OnConfigChanged; ApplyToSpectateCamera.SettingChanged += OnConfigChanged; ZoomRate.SettingChanged += OnConfigChanged; SaveWheelZoomToConfig.SettingChanged += OnConfigChanged; ZoomSmoothInSpeed.SettingChanged += OnConfigChanged; ZoomSmoothOutSpeed.SettingChanged += OnConfigChanged; DisableVisualEffects.SettingChanged += OnConfigChanged; BrightenView.SettingChanged += OnConfigChanged; EnhanceGlowObjects.SettingChanged += OnConfigChanged; EnableDebugToggleKey.SettingChanged += OnConfigChanged; } private static void OnConfigChanged(object sender, EventArgs e) { bool flag = sender == EnableMod || sender == FogStartDistance || sender == ViewDistance || sender == ApplyToSpectateCamera; bool flag2 = sender == ZoomSmoothInSpeed || sender == ZoomSmoothOutSpeed; bool flag3 = sender == EnableMod || sender == DisableVisualEffects || sender == BrightenView || sender == EnhanceGlowObjects || sender == EnableDebugToggleKey; UpdateCachedConfigValues(); if (!cachedEnableDebugToggleKey) { debugForceVanillaView = false; } if (flag2 && (Object)(object)zoomController != (Object)null) { zoomController.ResetZoomStateOnly(); } if (sender == ApplyToSpectateCamera || sender == EnableMod) { RefreshSpectatePatch(); } if (flag) { ApplyViewDistance(force: true); } if (flag3) { RefreshGameGraphicsSettings(); ApplyVisualSettings(force: true); ApplyGraphicsSettings(force: true); ApplyGlowSettings(force: true); } } private static void UpdateCachedConfigValues() { cachedEnableMod = EnableMod != null && EnableMod.Value; cachedFogStartDistance = ((FogStartDistance == null) ? 100f : Mathf.Clamp(FogStartDistance.Value, 0f, 500f)); cachedViewDistance = ((ViewDistance == null) ? 100f : Mathf.Clamp(ViewDistance.Value, 1f, 500f)); cachedApplyToSpectateCamera = ApplyToSpectateCamera != null && ApplyToSpectateCamera.Value; cachedZoomRate = ((ZoomRate == null) ? 5f : Mathf.Clamp(ZoomRate.Value, 1f, 10f)); cachedSaveWheelZoomToConfig = SaveWheelZoomToConfig == null || SaveWheelZoomToConfig.Value; cachedZoomSmoothInSpeed = ((ZoomSmoothInSpeed == null) ? 6f : Mathf.Clamp(ZoomSmoothInSpeed.Value, 0.1f, 30f)); cachedZoomSmoothOutSpeed = ((ZoomSmoothOutSpeed == null) ? 5f : Mathf.Clamp(ZoomSmoothOutSpeed.Value, 0.1f, 30f)); cachedDisableVisualEffects = DisableVisualEffects != null && DisableVisualEffects.Value; cachedBrightenView = BrightenView != null && BrightenView.Value; cachedEnhanceGlowObjects = EnhanceGlowObjects != null && EnhanceGlowObjects.Value; cachedEnableDebugToggleKey = EnableDebugToggleKey != null && EnableDebugToggleKey.Value; if (cachedFogStartDistance >= cachedViewDistance) { cachedFogStartDistance = Mathf.Max(0f, cachedViewDistance - 1f); } } private static void RefreshSpectatePatch() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown try { if (harmony == null) { return; } MethodInfo methodInfo = AccessTools.Method(typeof(SpectateCamera), "StateNormal", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(SpectateCameraStateNormalPatch), "Postfix", (Type[])null, (Type[])null); if (!(methodInfo == null) && !(methodInfo2 == null)) { if (cachedEnableMod && cachedApplyToSpectateCamera && !spectateStateNormalPatched) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); spectateStateNormalPatched = true; } else if ((!cachedEnableMod || !cachedApplyToSpectateCamera) && spectateStateNormalPatched) { harmony.Unpatch((MethodBase)methodInfo, (HarmonyPatchType)2, "REPOJP.BetterView"); spectateStateNormalPatched = false; } } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: RefreshSpectatePatch\n" + ex)); } } } internal static void ApplyViewDistance(bool force) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 try { if (!CanApplyNow()) { RestoreVanillaViewDistance(); return; } Camera mainGameplayCamera = GetMainGameplayCamera(); if ((Object)(object)mainGameplayCamera == (Object)null || !((Behaviour)mainGameplayCamera).isActiveAndEnabled) { return; } DistanceSettings distanceSettings = GetDistanceSettings(mainGameplayCamera); int instanceID = ((Object)mainGameplayCamera).GetInstanceID(); if (force || !IsAlreadyApplied(instanceID, distanceSettings)) { if ((int)RenderSettings.fogMode != 1) { RenderSettings.fogMode = (FogMode)1; } SetRenderFogDistances(distanceSettings.FogStart, distanceSettings.FogEnd); if (!NearlyEqual(mainGameplayCamera.farClipPlane, distanceSettings.FarClip)) { mainGameplayCamera.farClipPlane = distanceSettings.FarClip; } SaveAppliedState(instanceID, distanceSettings); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: ApplyViewDistance\n" + ex)); } } } private static bool CanApplyNow() { if (!cachedEnableMod || debugForceVanillaView) { return false; } if (!IsGameplayLevel()) { return false; } if (!cachedApplyToSpectateCamera && IsPlayerSpectating()) { return false; } return true; } private static DistanceSettings GetDistanceSettings(Camera targetCamera) { float num = cachedViewDistance + 1f; if (num <= targetCamera.nearClipPlane + 0.01f) { num = targetCamera.nearClipPlane + 0.01f; } return new DistanceSettings(cachedFogStartDistance, cachedViewDistance, num); } private static void SetRenderFogDistances(float fogStart, float fogEnd) { if (!NearlyEqual(RenderSettings.fogStartDistance, fogStart)) { RenderSettings.fogStartDistance = fogStart; } if (!NearlyEqual(RenderSettings.fogEndDistance, fogEnd)) { RenderSettings.fogEndDistance = fogEnd; } } private static void SaveAppliedState(int cameraId, DistanceSettings settings) { hasApplied = true; appliedCameraId = cameraId; appliedFogStart = settings.FogStart; appliedFogEnd = settings.FogEnd; appliedFarClip = settings.FarClip; } private static bool IsAlreadyApplied(int cameraId, DistanceSettings settings) { return hasApplied && appliedCameraId == cameraId && NearlyEqual(appliedFogStart, settings.FogStart) && NearlyEqual(appliedFogEnd, settings.FogEnd) && NearlyEqual(appliedFarClip, settings.FarClip) && NearlyEqual(RenderSettings.fogStartDistance, settings.FogStart) && NearlyEqual(RenderSettings.fogEndDistance, settings.FogEnd); } private static void RestoreVanillaViewDistance() { try { if (!hasApplied) { return; } if ((Object)(object)LevelGenerator.Instance == (Object)null || (Object)(object)LevelGenerator.Instance.Level == (Object)null) { ClearAppliedState(); return; } float fogStartDistance = LevelGenerator.Instance.Level.FogStartDistance; float fogEndDistance = LevelGenerator.Instance.Level.FogEndDistance; float num = fogEndDistance + 1f; SetRenderFogDistances(fogStartDistance, fogEndDistance); Camera mainGameplayCamera = GetMainGameplayCamera(); if ((Object)(object)mainGameplayCamera != (Object)null && ((Behaviour)mainGameplayCamera).isActiveAndEnabled && !NearlyEqual(mainGameplayCamera.farClipPlane, num)) { mainGameplayCamera.farClipPlane = num; } ClearAppliedState(); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: RestoreVanillaViewDistance\n" + ex)); } } } private static void ClearAppliedState() { hasApplied = false; appliedCameraId = -1; appliedFogStart = -1f; appliedFogEnd = -1f; appliedFarClip = -1f; } private static Camera GetMainGameplayCamera() { try { Camera environmentDirectorMainCamera = GetEnvironmentDirectorMainCamera(); if ((Object)(object)environmentDirectorMainCamera != (Object)null) { return environmentDirectorMainCamera; } if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.MainCamera != (Object)null) { return GameDirector.instance.MainCamera; } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: GetMainGameplayCamera\n" + ex)); } } return Camera.main; } private static Camera GetEnvironmentDirectorMainCamera() { try { if ((Object)(object)EnvironmentDirector.Instance == (Object)null || environmentMainCameraField == null) { return null; } object? value = environmentMainCameraField.GetValue(EnvironmentDirector.Instance); return (Camera)((value is Camera) ? value : null); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: GetEnvironmentDirectorMainCamera\n" + ex)); } return null; } } private static bool IsGameplayLevel() { try { if ((Object)(object)RunManager.instance == (Object)null) { return false; } if (SemiFunc.RunIsRecording()) { return false; } return SemiFunc.RunIsLevel(); } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: IsGameplayLevel\n" + ex)); } return false; } } private static bool IsPlayerSpectating() { try { if ((Object)(object)PlayerAvatar.instance != (Object)null) { return PlayerAvatar.instance.spectating; } return (Object)(object)PlayerController.instance != (Object)null && (Object)(object)PlayerController.instance.playerAvatarScript != (Object)null && PlayerController.instance.playerAvatarScript.spectating; } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: IsPlayerSpectating\n" + ex)); } return false; } } internal static void ApplyVisualSettings(bool force) { try { if (cachedEnableMod && !((Object)(object)PostProcessing.Instance == (Object)null) && !((Object)(object)LevelGenerator.Instance == (Object)null) && !((Object)(object)LevelGenerator.Instance.Level == (Object)null) && IsGameplayLevel()) { ApplyPostProcessingLevelValues(PostProcessing.Instance); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: ApplyVisualSettings\n" + ex)); } } } private static void ApplyPostProcessingLevelValues(PostProcessing postProcessing) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)postProcessing == (Object)null || (Object)(object)postProcessing.volume == (Object)null || (Object)(object)postProcessing.volume.profile == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null || (Object)(object)LevelGenerator.Instance.Level == (Object)null) { return; } Level level = LevelGenerator.Instance.Level; ColorGrading val = default(ColorGrading); if (postProcessing.volume.profile.TryGetSettings(ref val)) { float num = level.ColorTemperature; Color val2 = level.ColorFilter; if (ShouldBrightenView()) { num *= 0f; val2 = Color.Lerp(Color.white, val2, 0f); } ((ParameterOverride)(object)val.temperature).value = num; ((ParameterOverride)(object)val.colorFilter).value = val2; } Bloom val3 = default(Bloom); if (postProcessing.volume.profile.TryGetSettings(ref val3)) { float num2 = level.BloomIntensity; float num3 = level.BloomThreshold; if (ShouldBrightenView()) { num2 *= 0f; num3 *= 5f; } ((ParameterOverride)(object)val3.intensity).value = num2; ((ParameterOverride)(object)val3.threshold).value = num3; } Vignette val4 = default(Vignette); if (postProcessing.volume.profile.TryGetSettings(ref val4)) { Color vignetteColor = level.VignetteColor; float num4 = level.VignetteIntensity; float vignetteSmoothness = level.VignetteSmoothness; if (ShouldDisableVisualEffects()) { num4 *= 0f; } ((ParameterOverride)(object)val4.color).value = vignetteColor; ((ParameterOverride)(object)val4.intensity).value = num4; ((ParameterOverride)(object)val4.smoothness).value = vignetteSmoothness; SetPrivateField(postVignetteColorField, postProcessing, vignetteColor); SetPrivateField(postVignetteIntensityField, postProcessing, num4); SetPrivateField(postVignetteSmoothnessField, postProcessing, vignetteSmoothness); } ApplyPostProcessEffectToggles(postProcessing); } private static void ApplyPostProcessEffectToggles(PostProcessing postProcessing) { if (!((Object)(object)postProcessing == (Object)null) && !((Object)(object)postProcessing.volume == (Object)null) && !((Object)(object)postProcessing.volume.profile == (Object)null) && ShouldDisableVisualEffects()) { MotionBlur val = default(MotionBlur); if (postProcessing.volume.profile.TryGetSettings(ref val)) { ((PostProcessEffectSettings)val).active = false; } LensDistortion val2 = default(LensDistortion); if (postProcessing.volume.profile.TryGetSettings(ref val2)) { ((PostProcessEffectSettings)val2).active = false; } ChromaticAberration val3 = default(ChromaticAberration); if (postProcessing.volume.profile.TryGetSettings(ref val3)) { ((PostProcessEffectSettings)val3).active = false; } Grain val4 = default(Grain); if (postProcessing.volume.profile.TryGetSettings(ref val4)) { ((PostProcessEffectSettings)val4).active = false; } } } internal static void ApplyGraphicsSettings(bool force) { try { if (cachedEnableMod) { if (ShouldDisableVisualEffects() && (Object)(object)GraphicsManager.instance != (Object)null && graphicsGlitchLoopField != null) { graphicsGlitchLoopField.SetValue(GraphicsManager.instance, false); } if (ShouldDisableVisualEffects()) { ForceLargeRenderResolution(); StopRenderTextureEffects(); } } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: ApplyGraphicsSettings\n" + ex)); } } } private static void ForceLargeRenderResolution() { RenderTextureMain instance = RenderTextureMain.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.renderTexture == (Object)null) { return; } float textureWidthLarge = instance.textureWidthLarge; float textureHeightLarge = instance.textureHeightLarge; if (!(textureWidthLarge <= 0f) && !(textureHeightLarge <= 0f)) { SetPrivateField(renderTextureWidthOriginalField, instance, textureWidthLarge); SetPrivateField(renderTextureHeightOriginalField, instance, textureHeightLarge); float privateFloat = GetPrivateFloat(renderTextureWidthField, instance, textureWidthLarge); float privateFloat2 = GetPrivateFloat(renderTextureHeightField, instance, textureHeightLarge); if (!NearlyEqual(privateFloat, textureWidthLarge) || !NearlyEqual(privateFloat2, textureHeightLarge) || ((Texture)instance.renderTexture).width != (int)textureWidthLarge || ((Texture)instance.renderTexture).height != (int)textureHeightLarge) { SetPrivateField(renderTextureResetTimerField, instance, 0f); instance.ResetResolution(); } } } private static void StopRenderTextureEffects() { //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) RenderTextureMain instance = RenderTextureMain.instance; if (!((Object)(object)instance == (Object)null)) { SetPrivateField(renderTextureShakeActiveField, instance, false); SetPrivateField(renderTextureShakeTimerField, instance, 0f); Vector3 privateVector = GetPrivateVector3(renderTextureOriginalSizeField, instance, ((Component)instance).transform.localScale); ((Component)instance).transform.localPosition = Vector3.zero; ((Component)instance).transform.localScale = privateVector; SetPrivateField(renderTextureSizeResetTimerField, instance, 0f); } } private static void ApplyAmbientBrightness() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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) if (!cachedEnableMod || !cachedBrightenView || debugForceVanillaView || !IsGameplayLevel()) { RestoreAmbientBrightness(); return; } if ((Object)(object)LevelGenerator.Instance == (Object)null || (Object)(object)LevelGenerator.Instance.Level == (Object)null) { RestoreAmbientBrightness(); return; } Color vanillaAmbientLight = GetVanillaAmbientLight(); RenderSettings.ambientLight = MultiplyColorClamped(vanillaAmbientLight, 10f); hasAppliedAmbientBrightness = true; } private static void RestoreAmbientBrightness() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (hasAppliedAmbientBrightness && !((Object)(object)LevelGenerator.Instance == (Object)null) && !((Object)(object)LevelGenerator.Instance.Level == (Object)null)) { RenderSettings.ambientLight = GetVanillaAmbientLight(); hasAppliedAmbientBrightness = false; } } private static Color GetVanillaAmbientLight() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_0099: Unknown result type (might be due to invalid IL or missing references) Level level = LevelGenerator.Instance.Level; Color ambientColor = level.AmbientColor; Color ambientColorAdaptation = level.AmbientColorAdaptation; float privateFloat = GetPrivateFloat(environmentDarkAdaptationLerpField, EnvironmentDirector.Instance, 0f); privateFloat = Mathf.Clamp01(privateFloat); AnimationCurve val = null; if (environmentDarkAdaptationCurveField != null && (Object)(object)EnvironmentDirector.Instance != (Object)null) { object? value = environmentDarkAdaptationCurveField.GetValue(EnvironmentDirector.Instance); val = (AnimationCurve)((value is AnimationCurve) ? value : null); } float num = ((val == null) ? privateFloat : val.Evaluate(privateFloat)); num = Mathf.Clamp01(num); return Color.Lerp(ambientColor, ambientColorAdaptation, num); } private static void RefreshGameGraphicsSettings() { try { if ((Object)(object)GraphicsManager.instance != (Object)null) { GraphicsManager.instance.UpdateAll(); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: RefreshGameGraphicsSettings\n" + ex)); } } } private static bool ShouldDisableVisualEffects() { return cachedEnableMod && cachedDisableVisualEffects && !debugForceVanillaView && IsGameplayLevel(); } private static bool ShouldBrightenView() { return cachedEnableMod && cachedBrightenView && !debugForceVanillaView && IsGameplayLevel(); } private static Color MultiplyColorClamped(Color source, float multiplier) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) return new Color(Mathf.Clamp01(source.r * multiplier), Mathf.Clamp01(source.g * multiplier), Mathf.Clamp01(source.b * multiplier), source.a); } private static bool ShouldEnhanceGlowObjects() { return cachedEnableMod && cachedEnhanceGlowObjects && !debugForceVanillaView && IsGameplayLevel(); } private static void HandleDebugToggleKey() { try { if (cachedEnableDebugToggleKey && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && Input.GetKeyDown((KeyCode)102)) { debugForceVanillaView = !debugForceVanillaView; RestoreVanillaViewDistance(); RefreshGameGraphicsSettings(); ApplyViewDistance(force: true); ApplyVisualSettings(force: true); ApplyGraphicsSettings(force: true); ApplyGlowSettings(force: true); ApplyAmbientBrightness(); if (Log != null) { Log.LogInfo((object)("Success: Debug view toggle " + (debugForceVanillaView ? "Vanilla" : "Modded"))); } } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: HandleDebugToggleKey\n" + ex)); } } } internal static void ApplyGlowSettings(bool force) { try { if (!ShouldEnhanceGlowObjects()) { RestoreGlowSettings(); return; } ApplyGlowBloom(); PropLight[] array = Object.FindObjectsOfType(); for (int i = 0; i < array.Length; i++) { ApplyPropLightGlow(array[i]); } PropLightEmission[] array2 = Object.FindObjectsOfType(); for (int j = 0; j < array2.Length; j++) { ApplyPropEmissionGlow(array2[j]); } ItemLight[] array3 = Object.FindObjectsOfType(); for (int k = 0; k < array3.Length; k++) { ApplyItemLightGlow(array3[k]); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: ApplyGlowSettings\n" + ex)); } } } private static void ApplyGlowBloom() { PostProcessing instance = PostProcessing.Instance; Bloom val = default(Bloom); if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.volume == (Object)null) && !((Object)(object)instance.volume.profile == (Object)null) && instance.volume.profile.TryGetSettings(ref val)) { float num = Mathf.Min(1f, 1.5f); ((PostProcessEffectSettings)val).active = true; ((ParameterOverride)(object)val.intensity).value = Mathf.Max(((ParameterOverride)(object)val.intensity).value, num); ((ParameterOverride)(object)val.threshold).value = Mathf.Max(((ParameterOverride)(object)val.threshold).value, 1.75f); } } private static void ApplyPropLightGlow(PropLight propLight) { try { if ((Object)(object)propLight == (Object)null) { return; } Light val = null; if (propLightLightComponentField != null) { object? value = propLightLightComponentField.GetValue(propLight); val = (Light)((value is Light) ? value : null); } if ((Object)(object)val == (Object)null) { val = ((Component)propLight).GetComponent(); } if (!((Object)(object)val == (Object)null)) { if (!propLightStates.TryGetValue(propLight, out var value2)) { value2 = new PropLightState(GetPrivateFloat(propLightOriginalIntensityField, propLight, val.intensity), val.intensity, val.range); propLightStates[propLight] = value2; } float num = Mathf.Min(10f, 2f); float num2 = Mathf.Min(1.18f, 1.15f); float num3 = value2.OriginalIntensity * num; SetPrivateField(propLightOriginalIntensityField, propLight, num3); if (val.intensity > 0f) { val.intensity = Mathf.Max(val.intensity, num3); } val.range = value2.OriginalRange * num2; } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: ApplyPropLightGlow\n" + ex)); } } } private static void ApplyPropEmissionGlow(PropLightEmission propEmission) { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)propEmission == (Object)null) { return; } Material val = null; if (propEmissionMaterialField != null) { object? value = propEmissionMaterialField.GetValue(propEmission); val = (Material)((value is Material) ? value : null); } if ((Object)(object)val == (Object)null) { Renderer component = ((Component)propEmission).GetComponent(); if ((Object)(object)component != (Object)null) { val = component.material; } } if (!((Object)(object)val == (Object)null) && val.HasProperty("_EmissionColor")) { if (!propEmissionStates.TryGetValue(propEmission, out var value2)) { Color privateColor = GetPrivateColor(propEmissionOriginalEmissionField, propEmission, val.GetColor("_EmissionColor")); value2 = new PropEmissionState(privateColor, val.GetColor("_EmissionColor")); propEmissionStates[propEmission] = value2; } float multiplier = Mathf.Min(10f, 2f); Color val2 = MultiplyHdrColorClamped(value2.OriginalEmission, multiplier, 3f); SetPrivateField(propEmissionOriginalEmissionField, propEmission, val2); val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", val2); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: ApplyPropEmissionGlow\n" + ex)); } } } private static void ApplyItemLightGlow(ItemLight itemLight) { try { if (!((Object)(object)itemLight == (Object)null) && !((Object)(object)itemLight.itemLight == (Object)null)) { if (!itemLightStates.TryGetValue(itemLight, out var value)) { value = new ItemLightState(GetPrivateFloat(itemLightIntensityOriginalField, itemLight, itemLight.itemLight.intensity), GetPrivateFloat(itemLightRangeOriginalField, itemLight, itemLight.itemLight.range), GetPrivateFloat(itemLightFresnelScaleOriginalField, itemLight, 0f), itemLight.itemLight.intensity, itemLight.itemLight.range); itemLightStates[itemLight] = value; } float num = Mathf.Min(10f, 2f); float num2 = Mathf.Min(1.18f, 1.15f); float num3 = Mathf.Min(10f, 2f); float num4 = value.OriginalIntensity * num; float num5 = value.OriginalRange * num2; float num6 = value.OriginalFresnel * num3; SetPrivateField(itemLightIntensityOriginalField, itemLight, num4); SetPrivateField(itemLightRangeOriginalField, itemLight, num5); SetPrivateField(itemLightFresnelScaleOriginalField, itemLight, num6); if (((Behaviour)itemLight.itemLight).enabled || itemLight.itemLight.intensity > 0f) { itemLight.itemLight.intensity = Mathf.Max(itemLight.itemLight.intensity, num4); itemLight.itemLight.range = Mathf.Max(itemLight.itemLight.range, num5); } ApplyItemFresnel(itemLight, num6); } } catch (Exception ex) { if (Log != null) { Log.LogError((object)("Failure: ApplyItemLightGlow\n" + ex)); } } } private static void ApplyItemFresnel(ItemLight itemLight, float value) { if ((Object)(object)itemLight == (Object)null || itemLight.meshRenderers == null) { return; } foreach (MeshRenderer meshRenderer in itemLight.meshRenderers) { if ((Object)(object)meshRenderer != (Object)null && ((Component)meshRenderer).gameObject.activeSelf && (Object)(object)((Renderer)meshRenderer).material != (Object)null && ((Renderer)meshRenderer).material.HasProperty("_FresnelScale")) { ((Renderer)meshRenderer).material.SetFloat("_FresnelScale", value); } } } private static void RestoreGlowSettings() { //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair item in new List>(propLightStates)) { if (!((Object)(object)item.Key == (Object)null)) { Light val = null; if (propLightLightComponentField != null) { object? value = propLightLightComponentField.GetValue(item.Key); val = (Light)((value is Light) ? value : null); } if ((Object)(object)val == (Object)null) { val = ((Component)item.Key).GetComponent(); } SetPrivateField(propLightOriginalIntensityField, item.Key, item.Value.OriginalIntensity); if ((Object)(object)val != (Object)null) { val.intensity = item.Value.CurrentIntensity; val.range = item.Value.OriginalRange; } } } propLightStates.Clear(); foreach (KeyValuePair item2 in new List>(propEmissionStates)) { if (!((Object)(object)item2.Key == (Object)null)) { Material val2 = null; if (propEmissionMaterialField != null) { object? value2 = propEmissionMaterialField.GetValue(item2.Key); val2 = (Material)((value2 is Material) ? value2 : null); } SetPrivateField(propEmissionOriginalEmissionField, item2.Key, item2.Value.OriginalEmission); if ((Object)(object)val2 != (Object)null && val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", item2.Value.CurrentEmission); } } } propEmissionStates.Clear(); foreach (KeyValuePair item3 in new List>(itemLightStates)) { if (!((Object)(object)item3.Key == (Object)null)) { SetPrivateField(itemLightIntensityOriginalField, item3.Key, item3.Value.OriginalIntensity); SetPrivateField(itemLightRangeOriginalField, item3.Key, item3.Value.OriginalRange); SetPrivateField(itemLightFresnelScaleOriginalField, item3.Key, item3.Value.OriginalFresnel); if ((Object)(object)item3.Key.itemLight != (Object)null) { item3.Key.itemLight.intensity = item3.Value.CurrentIntensity; item3.Key.itemLight.range = item3.Value.CurrentRange; } ApplyItemFresnel(item3.Key, item3.Value.OriginalFresnel); } } itemLightStates.Clear(); } private static Color GetPrivateColor(FieldInfo fieldInfo, object instance, Color fallback) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (fieldInfo == null || instance == null) { return fallback; } if (!(fieldInfo.GetValue(instance) is Color result)) { return fallback; } return result; } private static Color MultiplyHdrColorClamped(Color source, float multiplier, float maxValue) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) return new Color(Mathf.Clamp(source.r * multiplier, 0f, maxValue), Mathf.Clamp(source.g * multiplier, 0f, maxValue), Mathf.Clamp(source.b * multiplier, 0f, maxValue), source.a); } private static void SetPrivateField(FieldInfo fieldInfo, object instance, object value) { if (!(fieldInfo == null) && instance != null) { fieldInfo.SetValue(instance, value); } } private static float GetPrivateFloat(FieldInfo fieldInfo, object instance, float fallback) { if (fieldInfo == null || instance == null) { return fallback; } if (!(fieldInfo.GetValue(instance) is float result)) { return fallback; } return result; } private static Vector3 GetPrivateVector3(FieldInfo fieldInfo, object instance, Vector3 fallback) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (fieldInfo == null || instance == null) { return fallback; } if (!(fieldInfo.GetValue(instance) is Vector3 result)) { return fallback; } return result; } private static bool NearlyEqual(float left, float right) { return Mathf.Abs(left - right) <= 0.001f; } private static bool AllowCameraGlitch() { if (!ShouldDisableVisualEffects()) { return true; } return Random.value < 0f; } } }