using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Rumi.FixCameraResolutions.Fogs;
using Rumi.FixCameraResolutions.Resolutions;
using Rumi.FixCameraResolutions.Visors;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Fix Camera Resolution")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Fix Camera Resolution")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dabb3c14-d069-4fdb-87ea-c7169dc3ef9e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace Rumi.FixCameraResolutions
{
internal static class Debug
{
public static void Log(object data)
{
ManualLogSource? logger = FCRPlugin.logger;
if (logger != null)
{
logger.LogInfo(data);
}
}
public static void LogWarning(object data)
{
ManualLogSource? logger = FCRPlugin.logger;
if (logger != null)
{
logger.LogWarning(data);
}
}
public static void LogError(object data)
{
ManualLogSource? logger = FCRPlugin.logger;
if (logger != null)
{
logger.LogError(data);
}
}
}
[BepInPlugin("Rumi.FixCameraResolutions", "FixCameraResolutions", "1.3.2")]
public sealed class FCRPlugin : BaseUnityPlugin
{
public const string modGuid = "Rumi.FixCameraResolutions";
public const string modName = "FixCameraResolutions";
public const string modVersion = "1.3.2";
internal static ManualLogSource? logger { get; private set; } = null;
public static FCRResConfig? resConfig { get; private set; }
public static FCRHDRPConfig? hdrpConfig { get; private set; }
public static FCRVisorConfig? visorConfig { get; private set; }
internal static Harmony harmony { get; } = new Harmony("Rumi.FixCameraResolutions");
private void Awake()
{
logger = ((BaseUnityPlugin)this).Logger;
Debug.Log("Start loading plugin...");
resConfig = FCRResConfig.Create(((BaseUnityPlugin)this).Config);
hdrpConfig = FCRHDRPConfig.Create(((BaseUnityPlugin)this).Config);
visorConfig = FCRVisorConfig.Create(((BaseUnityPlugin)this).Config);
if (Type.GetType("LethalConfig.LethalConfigManager, LethalConfig, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", throwOnError: false) != null)
{
try
{
Debug.Log("Lethal Config Registration");
if (resConfig != null)
{
FCRResConfig.LethalConfig.Patch(resConfig);
}
if (hdrpConfig != null)
{
FCRHDRPConfig.LethalConfig.Patch(hdrpConfig);
}
if (visorConfig != null)
{
FCRVisorConfig.LethalConfig.Patch(visorConfig);
}
}
catch (Exception data)
{
Debug.LogError(data);
Debug.LogWarning("Lethal Config Registration Fail!");
}
}
((BaseUnityPlugin)this).Config.Save();
Patch();
Debug.Log("Plugin FixCameraResolutions is loaded!");
}
public static void Repatch()
{
FCRResPatches.UpdateAll();
FCRHDRPPatches.UpdateAll();
FCRVisorPatches.UpdateAllPlayer();
Unpatch();
Patch();
}
private static void Patch()
{
FCRResPatches.Patch();
FCRHDRPPatches.Patch();
FCRVisorPatches.Patch();
}
private static void Unpatch()
{
Debug.Log("Unpatch...");
try
{
harmony.UnpatchSelf();
}
catch (Exception data)
{
Debug.LogError(data);
Debug.LogError("Unpatch Fail!");
}
Debug.Log("Unpatched!");
}
}
public static class FCRUtility
{
public static Vector2 Multiply(this Vector2 position, float x, float y)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return new Vector2(position.x * x, position.y * y);
}
}
}
namespace Rumi.FixCameraResolutions.Visors
{
public sealed class FCRVisorConfig
{
public static class LethalConfig
{
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Patch(FCRVisorConfig config)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config._disable, false));
}
}
private readonly ConfigEntry<bool> _disable;
public const bool dDisable = false;
public bool disable
{
get
{
return _disable.Value;
}
set
{
_disable.Value = value;
}
}
internal static FCRVisorConfig? Create(ConfigFile config)
{
Debug.Log("Visor Config Loading...");
try
{
FCRVisorConfig result = new FCRVisorConfig(config);
Debug.Log("Visor Config Loaded!");
return result;
}
catch (Exception data)
{
Debug.LogError(data);
Debug.LogWarning("Failed to load config file\nSettings will be loaded with defaults!");
}
return null;
}
private FCRVisorConfig(ConfigFile config)
{
_disable = config.Bind<bool>("Visors", "Disable", false, "Disables visor rendering");
_disable.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
}
}
public static class FCRVisorPatches
{
public static bool disable => FCRPlugin.visorConfig?.disable ?? false;
[HarmonyPatch(typeof(PlayerControllerB), "Start")]
[HarmonyPostfix]
private static void PlayerControllerB_Start_Postfix(PlayerControllerB __instance)
{
UpdatePlayer(__instance);
}
public static void UpdateAllPlayer()
{
PlayerControllerB[] array = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
UpdatePlayer(array[i]);
}
}
public static void UpdatePlayer(PlayerControllerB player)
{
if ((Object)(object)player.localVisor != (Object)null)
{
((Component)player.localVisor).gameObject.SetActive(!disable);
}
}
internal static void Patch()
{
if (!disable)
{
return;
}
Debug.Log("Visor Patch...");
try
{
FCRPlugin.harmony.PatchAll(typeof(FCRVisorPatches));
Debug.Log("Visor Patched!");
}
catch (Exception data)
{
Debug.LogError(data);
Debug.LogError("Resolution Patch Fail!");
}
}
}
}
namespace Rumi.FixCameraResolutions.Resolutions
{
public sealed class FCRResConfig
{
public static class LethalConfig
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static GenericButtonHandler <>9__0_0;
internal void <Patch>b__0_0()
{
FCRResPatches.UpdateAll();
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Patch(FCRResConfig config)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_003a: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_007b: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_00b7: Expected O, but got Unknown
//IL_00bc: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config._enable, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(config._autoSize, new BoolCheckBoxOptions
{
RequiresRestart = false,
CanModifyCallback = new CanModifyDelegate(CanModifyAutoSize)
}));
ConfigEntry<int> width = config._width;
IntSliderOptions val = new IntSliderOptions();
((BaseRangeOptions<int>)val).Min = 10;
((BaseRangeOptions<int>)val).Max = 3840;
((BaseOptions)val).RequiresRestart = false;
((BaseOptions)val).CanModifyCallback = new CanModifyDelegate(CanModifySize);
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(width, val));
ConfigEntry<int> height = config._height;
IntSliderOptions val2 = new IntSliderOptions();
((BaseRangeOptions<int>)val2).Min = 10;
((BaseRangeOptions<int>)val2).Max = 2160;
((BaseOptions)val2).RequiresRestart = false;
((BaseOptions)val2).CanModifyCallback = new CanModifyDelegate(CanModifySize);
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(height, val2));
object obj = <>c.<>9__0_0;
if (obj == null)
{
GenericButtonHandler val3 = delegate
{
FCRResPatches.UpdateAll();
};
<>c.<>9__0_0 = val3;
obj = (object)val3;
}
LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem("Resolutions", "Refresh resolution", "If the resolution has been released for some reason, you can refresh it using this button.", "Refresh", (GenericButtonHandler)obj));
}
private static CanModifyResult CanModifyAutoSize()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
return CanModifyResult.op_Implicit((FCRPlugin.resConfig?.enable ?? true, "Resolution patch is disabled and cannot be modified"));
}
private static CanModifyResult CanModifySize()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
CanModifyResult val = CanModifyAutoSize();
if (CanModifyResult.op_Implicit(val))
{
return CanModifyResult.op_Implicit((!(FCRPlugin.resConfig?.autoSize ?? true), "Since auto size is enabled, the size is automatically set to the current game window size."));
}
return val;
}
}
private readonly ConfigEntry<bool> _enable;
public const bool dEnable = true;
private readonly ConfigEntry<bool> _autoSize;
public const bool dAutoSize = true;
private readonly ConfigEntry<int> _width;
public const int dWidth = 1920;
private readonly ConfigEntry<int> _height;
public const int dHeight = 1080;
public bool enable
{
get
{
return _enable.Value;
}
set
{
_enable.Value = value;
}
}
public bool autoSize
{
get
{
return _autoSize.Value;
}
set
{
_autoSize.Value = value;
}
}
public int width
{
get
{
return _width.Value;
}
set
{
_width.Value = value;
}
}
public int height
{
get
{
return _height.Value;
}
set
{
_height.Value = value;
}
}
internal static FCRResConfig? Create(ConfigFile config)
{
Debug.Log("Resolution Config Loading...");
try
{
FCRResConfig result = new FCRResConfig(config);
Debug.Log("Resolution Config Loaded!");
return result;
}
catch (Exception data)
{
Debug.LogError(data);
Debug.LogWarning("Failed to load config file\nSettings will be loaded with defaults!");
}
return null;
}
private FCRResConfig(ConfigFile config)
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Expected O, but got Unknown
_enable = config.Bind<bool>("Resolutions", "Enable", true, "When enabled, the camera resolution will be modified.");
_enable.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
_autoSize = config.Bind<bool>("Resolutions", "Auto Size", true, "When enabled, sets the camera size to the size of the current game window.");
_autoSize.SettingChanged += delegate
{
FCRResPatches.UpdateAll();
};
_width = config.Bind<int>("Resolutions", "Width", 1920, new ConfigDescription(string.Empty, (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 3840), Array.Empty<object>()));
_width.SettingChanged += delegate
{
FCRResPatches.UpdateAll();
};
_height = config.Bind<int>("Resolutions", "Height", 1080, new ConfigDescription(string.Empty, (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 2160), Array.Empty<object>()));
_height.SettingChanged += delegate
{
FCRResPatches.UpdateAll();
};
}
}
public static class FCRResPatches
{
public const int orgWidth = 860;
public const int orgHeight = 520;
public static bool enable => FCRPlugin.resConfig?.enable ?? true;
public static int width
{
get
{
if (enable)
{
FCRResConfig? resConfig = FCRPlugin.resConfig;
if (resConfig == null || resConfig.autoSize)
{
return Screen.width;
}
return FCRPlugin.resConfig?.width ?? 1920;
}
return 860;
}
}
public static int height
{
get
{
if (enable)
{
FCRResConfig? resConfig = FCRPlugin.resConfig;
if (resConfig == null || resConfig.autoSize)
{
return Screen.height;
}
return FCRPlugin.resConfig?.height ?? 1080;
}
return 520;
}
}
[HarmonyPatch(typeof(Terminal), "Start")]
[HarmonyPostfix]
private static void Terminal_Start_Postfix(Terminal __instance)
{
UpdateRenderTexture(__instance.playerScreenTex);
UpdateRenderTexture(__instance.playerScreenTexHighRes);
}
[HarmonyPatch(typeof(HUDManager), "UpdateScanNodes")]
[HarmonyPostfix]
private static void HUDManager_UpdateScanNodes_Postfix(HUDManager __instance)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
if (enable)
{
for (int i = 0; i < __instance.scanElements.Length; i++)
{
RectTransform obj = __instance.scanElements[i];
obj.anchoredPosition += new Vector2(439.48f, 244.8f);
obj.anchoredPosition = obj.anchoredPosition.Multiply(860f / (float)width, 520f / (float)height);
obj.anchoredPosition -= new Vector2(439.48f, 244.8f);
}
}
}
public static void UpdateAll()
{
UpdateAllTerminal();
UpdateAllPlayerCamera();
}
public static void UpdateAllTerminal()
{
Terminal[] array = Object.FindObjectsByType<Terminal>((FindObjectsSortMode)0);
foreach (Terminal obj in array)
{
UpdateRenderTexture(obj.playerScreenTex);
UpdateRenderTexture(obj.playerScreenTexHighRes);
}
}
public static void UpdateRenderTexture(RenderTexture renderTexture)
{
renderTexture.Release();
((Texture)renderTexture).width = width;
((Texture)renderTexture).height = height;
Debug.Log($"Changed the size of the render texture to {((Texture)renderTexture).width}x{((Texture)renderTexture).height}");
}
public static void UpdateAllPlayerCamera()
{
PlayerControllerB[] array = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
UpdateCamera(array[i].gameplayCamera);
}
}
public static void UpdateCamera(Camera camera)
{
camera.ResetAspect();
}
internal static void Patch()
{
if (!enable)
{
return;
}
Debug.Log("Resolution Patch...");
try
{
FCRPlugin.harmony.PatchAll(typeof(FCRResPatches));
Debug.Log("Resolution Patched!");
}
catch (Exception data)
{
Debug.LogError(data);
Debug.LogError("Resolution Patch Fail!");
}
}
}
}
namespace Rumi.FixCameraResolutions.Fogs
{
public enum AntialiasingMode
{
None,
FXAA,
TAA,
SMAA
}
public sealed class FCRHDRPConfig
{
public static class LethalConfig
{
[MethodImpl(MethodImplOptions.NoInlining)]
public static void Patch(FCRHDRPConfig config)
{
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<AntialiasingMode>(config._antialiasingMode, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<HDRPMode>(config._bloomMode, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<FogMode>(config._fogMode, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<HDRPMode>(config._shadowMode, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<HDRPMode>(config._postProcessingMode, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<HDRPMode>(config._vignetteMode, false));
}
}
private readonly ConfigEntry<AntialiasingMode> _antialiasingMode;
public const AntialiasingMode dAntialiasingMode = AntialiasingMode.None;
private readonly ConfigEntry<HDRPMode> _bloomMode;
public const HDRPMode dBloomMode = HDRPMode.Vanilla;
private readonly ConfigEntry<FogMode> _fogMode;
public const FogMode dFogMode = FogMode.Vanilla;
private readonly ConfigEntry<HDRPMode> _shadowMode;
public const HDRPMode dShadowMode = HDRPMode.Vanilla;
private readonly ConfigEntry<HDRPMode> _postProcessingMode;
public const HDRPMode dPostProcessingMode = HDRPMode.Vanilla;
private readonly ConfigEntry<HDRPMode> _vignetteMode;
public const HDRPMode dVignetteMode = HDRPMode.Vanilla;
public AntialiasingMode antialiasingMode
{
get
{
return _antialiasingMode.Value;
}
set
{
_antialiasingMode.Value = value;
}
}
public HDRPMode bloomMode
{
get
{
return _bloomMode.Value;
}
set
{
_bloomMode.Value = value;
}
}
public FogMode fogMode
{
get
{
return _fogMode.Value;
}
set
{
_fogMode.Value = value;
}
}
public HDRPMode shadowMode
{
get
{
return _shadowMode.Value;
}
set
{
_shadowMode.Value = value;
}
}
public HDRPMode postProcessingMode
{
get
{
return _postProcessingMode.Value;
}
set
{
_postProcessingMode.Value = value;
}
}
public HDRPMode vignetteMode
{
get
{
return _vignetteMode.Value;
}
set
{
_vignetteMode.Value = value;
}
}
internal static FCRHDRPConfig? Create(ConfigFile config)
{
Debug.Log("HDRP Config Loading...");
try
{
FCRHDRPConfig result = new FCRHDRPConfig(config);
Debug.Log("HDRP Config Loaded!");
return result;
}
catch (Exception data)
{
Debug.LogError(data);
Debug.LogWarning("Failed to load config file\nSettings will be loaded with defaults!");
}
return null;
}
private FCRHDRPConfig(ConfigFile config)
{
_antialiasingMode = config.Bind<AntialiasingMode>("HDRP", "Antialiasing", AntialiasingMode.None, (ConfigDescription)null);
_bloomMode = config.Bind<HDRPMode>("HDRP", "Bloom", HDRPMode.Vanilla, (ConfigDescription)null);
_fogMode = config.Bind<FogMode>("HDRP", "Fog Rendering Method", FogMode.Vanilla, "Sets how fog is rendered.\r\n\r\n-------------------------\r\n\r\n\r\nVanilla\r\n-------------------------\r\nUse default fog settings\r\n\r\n\r\nHide\r\n-------------------------\r\nIt doesn't completely remove the fog, but it adjusts it so that it doesn't obstruct your vision.\r\n\r\n\r\nDisable\r\n-------------------------\r\nCompletely disables all fog rendering.\r\n\r\n\r\nForceDisable\r\n-------------------------\r\nAttempts to completely disable all fog rendering on every frame.\r\n\r\nCan be used when fog removal is not working on a mod planet\r\n\r\nDo not use this setting unless you have a problem\r\n\r\n\r\n-------------------------\r\n\r\n");
_shadowMode = config.Bind<HDRPMode>("HDRP", "Shadow", HDRPMode.Vanilla, (ConfigDescription)null);
_postProcessingMode = config.Bind<HDRPMode>("HDRP", "Post Processing", HDRPMode.Vanilla, (ConfigDescription)null);
_vignetteMode = config.Bind<HDRPMode>("HDRP", "Vignette", HDRPMode.Vanilla, (ConfigDescription)null);
_antialiasingMode.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
_bloomMode.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
_fogMode.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
_shadowMode.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
_postProcessingMode.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
_vignetteMode.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
}
}
public static class FCRHDRPPatches
{
[HarmonyPatch(typeof(Volume))]
private static class OnEnablePatch
{
[HarmonyPatch("OnEnable")]
[HarmonyPostfix]
private static void OnEnable(Volume __instance)
{
UpdateVolume(__instance);
}
}
[HarmonyPatch(typeof(Volume))]
private static class UpdatePatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void Update(Volume __instance)
{
UpdateVolume(__instance);
}
}
[HarmonyPatch(typeof(HDAdditionalCameraData))]
private static class HDAdditionalCameraDataPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake(HDAdditionalCameraData __instance)
{
UpdateHDCameraData(__instance);
}
}
public static AntialiasingMode antialiasingMode => FCRPlugin.hdrpConfig?.antialiasingMode ?? AntialiasingMode.None;
public static HDRPMode bloomMode => FCRPlugin.hdrpConfig?.bloomMode ?? HDRPMode.Vanilla;
public static FogMode fogMode => FCRPlugin.hdrpConfig?.fogMode ?? FogMode.Vanilla;
public static HDRPMode shadowMode => FCRPlugin.hdrpConfig?.shadowMode ?? HDRPMode.Vanilla;
public static HDRPMode postProcessingMode => FCRPlugin.hdrpConfig?.postProcessingMode ?? HDRPMode.Vanilla;
public static HDRPMode vignetteMode => FCRPlugin.hdrpConfig?.vignetteMode ?? HDRPMode.Vanilla;
public static void UpdateAll()
{
UpdateAllVolume();
UpdateAllHDCameraData();
}
public static void UpdateAllVolume()
{
Volume[] array = Object.FindObjectsByType<Volume>((FindObjectsInactive)1, (FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
UpdateVolume(array[i]);
}
}
public static void UpdateVolume(Volume volume)
{
Fog val = default(Fog);
if (!((Object)(object)volume.sharedProfile == (Object)null) && volume.sharedProfile.TryGet<Fog>(ref val))
{
((VolumeComponent)val).active = fogMode != FogMode.Disable && fogMode != FogMode.ForceDisable;
}
}
public static void UpdateAllHDCameraData()
{
HDAdditionalCameraData[] array = Object.FindObjectsByType<HDAdditionalCameraData>((FindObjectsInactive)1, (FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
UpdateHDCameraData(array[i]);
}
}
public static void UpdateHDCameraData(HDAdditionalCameraData cameraData)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
if (((Object)((Component)cameraData).gameObject).name == "SpectateCamera")
{
cameraData.customRenderingSettings = fogMode != FogMode.Vanilla;
}
if (((Object)((Component)cameraData).gameObject).name != "UICamera")
{
cameraData.antialiasing = (AntialiasingMode)antialiasingMode;
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[91u] = antialiasingMode != AntialiasingMode.None;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)91, antialiasingMode != AntialiasingMode.None);
}
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[84u] = bloomMode != HDRPMode.Vanilla;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)84, bloomMode == HDRPMode.Vanilla);
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[28u] = fogMode != FogMode.Vanilla;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)28, fogMode == FogMode.Vanilla);
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[20u] = shadowMode != HDRPMode.Vanilla;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)20, shadowMode == HDRPMode.Vanilla);
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[6u] = postProcessingMode != HDRPMode.Vanilla;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)6, postProcessingMode == HDRPMode.Vanilla);
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[87u] = vignetteMode != HDRPMode.Vanilla;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)87, vignetteMode == HDRPMode.Vanilla);
}
internal static void Patch()
{
Debug.Log("Fog Patch...");
try
{
FCRPlugin.harmony.PatchAll(typeof(HDAdditionalCameraDataPatch));
if (fogMode == FogMode.Disable || fogMode == FogMode.ForceDisable)
{
FCRPlugin.harmony.PatchAll(typeof(OnEnablePatch));
if (fogMode == FogMode.ForceDisable)
{
FCRPlugin.harmony.PatchAll(typeof(UpdatePatch));
}
}
Debug.Log("Fog Patched!");
}
catch (Exception data)
{
Debug.LogError(data);
Debug.LogError("Fog Patch Fail!");
}
}
}
public enum FogMode
{
Vanilla,
Hide,
Disable,
ForceDisable
}
public enum HDRPMode
{
Vanilla,
Disable
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}