using System;
using System.Diagnostics;
using System.IO;
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.2.2")]
public sealed class FCRPlugin : BaseUnityPlugin
{
public const string modGuid = "Rumi.FixCameraResolutions";
public const string modName = "FixCameraResolutions";
public const string modVersion = "1.2.2";
internal static ManualLogSource? logger { get; private set; } = null;
public static FCRResConfig? resConfig { get; private set; }
public static FCRFogConfig? fogConfig { get; private set; }
public static FCRVisorConfig? visorConfig { get; private set; }
internal static Harmony harmony { get; } = new Harmony("Rumi.FixCameraResolutions");
[Obsolete("Deprecated class name! Please use FCRResConfig")]
public static FCRConfig config => new FCRConfig(resConfig);
private void Awake()
{
logger = ((BaseUnityPlugin)this).Logger;
Debug.Log("Start loading plugin...");
resConfig = FCRResConfig.Create(((BaseUnityPlugin)this).Config);
fogConfig = FCRFogConfig.Create(((BaseUnityPlugin)this).Config);
visorConfig = FCRVisorConfig.Create(((BaseUnityPlugin)this).Config);
((BaseUnityPlugin)this).Config.Save();
Patch();
Debug.Log("Plugin FixCameraResolutions is loaded!");
}
public static void Repatch()
{
FCRResPatches.UpdateAll();
FCRFogPatches.UpdateAll();
FCRVisorPatches.UpdateAllPlayer();
Unpatch();
Patch();
}
private static void Patch()
{
FCRResPatches.Patch();
FCRFogPatches.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);
}
}
[Obsolete("Deprecated class name! Please use FCRResConfig")]
public class FCRConfig
{
private readonly FCRResConfig? config;
[Obsolete("Deprecated class name! Please use FCRResConfig.dAutoSize")]
public const bool dAutoSize = true;
[Obsolete("Deprecated class name! Please use FCRResConfig.dWidth")]
public const int dWidth = 1920;
[Obsolete("Deprecated class name! Please use FCRResConfig.dHeight")]
public const int dHeight = 1080;
[Obsolete("Deprecated class name! Please use FCRResConfig.autoSize")]
public bool autoSize
{
get
{
return config?.autoSize ?? true;
}
set
{
if (config != null)
{
config.autoSize = value;
}
}
}
[Obsolete("Deprecated class name! Please use FCRResConfig.width")]
public int width
{
get
{
return config?.width ?? 1920;
}
set
{
if (config != null)
{
config.width = value;
}
}
}
[Obsolete("Deprecated class name! Please use FCRResConfig.height")]
public int height
{
get
{
return config?.height ?? 1080;
}
set
{
if (config != null)
{
config.height = value;
}
}
}
[Obsolete("Deprecated class name! Please use FCRResConfig", true)]
public FCRConfig(ConfigFile config)
{
throw new NotImplementedException();
}
internal FCRConfig(FCRResConfig? config)
{
this.config = config;
}
}
[Obsolete("Deprecated class name! Please use FCRResPatches")]
public class FCRPatches
{
[Obsolete("Deprecated class name! Please use FCRResPatches.width")]
public static int width => FCRResPatches.width;
[Obsolete("Deprecated class name! Please use FCRResPatches.height")]
public static int height => FCRResPatches.height;
[Obsolete("Deprecated class name! Please use FCRResPatches.orgWidth")]
public static int? orgWidth => 860;
[Obsolete("Deprecated class name! Please use FCRResPatches.orgHeight")]
public static int? orgHeight => 520;
[Obsolete("Deprecated class name! Please use FCRResPatches.AllTerminalPatch")]
public static void AllTerminalPatch()
{
FCRResPatches.UpdateAllTerminal();
}
[Obsolete("Deprecated class name! Please use FCRResPatches.RenderTexturePatch")]
public static void RenderTexturePatch(RenderTexture renderTexture)
{
FCRResPatches.UpdateRenderTexture(renderTexture);
}
}
}
namespace Rumi.FixCameraResolutions.Visors
{
public sealed class FCRVisorConfig
{
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();
};
try
{
LethalConfigPatch();
}
catch (FileNotFoundException data)
{
Debug.LogError(data);
Debug.LogWarning("Lethal Config Add Fail! (This is not a bug and occurs when LethalConfig is not present)");
}
catch (Exception data2)
{
Debug.LogError(data2);
Debug.LogError("Lethal Config Add Fail!");
}
}
private void LethalConfigPatch()
{
//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(_disable, false));
}
}
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
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static EventHandler <>9__21_0;
public static EventHandler <>9__21_1;
public static EventHandler <>9__21_2;
public static EventHandler <>9__21_3;
public static GenericButtonHandler <>9__22_0;
internal void <.ctor>b__21_0(object sender, EventArgs e)
{
FCRPlugin.Repatch();
}
internal void <.ctor>b__21_1(object sender, EventArgs e)
{
FCRResPatches.UpdateAll();
}
internal void <.ctor>b__21_2(object sender, EventArgs e)
{
FCRResPatches.UpdateAll();
}
internal void <.ctor>b__21_3(object sender, EventArgs e)
{
FCRResPatches.UpdateAll();
}
internal void <LethalConfigPatch>b__22_0()
{
FCRResPatches.UpdateAll();
}
}
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
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: 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();
};
config.Bind<bool>("General", "Auto Size", true, (ConfigDescription)null);
config.Remove(new ConfigDefinition("General", "Auto Size"));
config.Bind<int>("General", "Width", 1920, (ConfigDescription)null);
config.Remove(new ConfigDefinition("General", "Width"));
config.Bind<int>("General", "Height", 1080, (ConfigDescription)null);
config.Remove(new ConfigDefinition("General", "Height"));
try
{
LethalConfigPatch();
}
catch (FileNotFoundException data)
{
Debug.LogError(data);
Debug.LogWarning("Lethal Config Add Fail! (This is not a bug and occurs when LethalConfig is not present)");
}
catch (Exception data2)
{
Debug.LogError(data2);
Debug.LogError("Lethal Config Add Fail!");
}
}
private void LethalConfigPatch()
{
//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(_enable, false));
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(_autoSize, new BoolCheckBoxOptions
{
RequiresRestart = false,
CanModifyCallback = new CanModifyDelegate(CanModifyAutoSize)
}));
ConfigEntry<int> obj = _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(obj, val));
ConfigEntry<int> obj2 = _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(obj2, val2));
object obj3 = <>c.<>9__22_0;
if (obj3 == null)
{
GenericButtonHandler val3 = delegate
{
FCRResPatches.UpdateAll();
};
<>c.<>9__22_0 = val3;
obj3 = (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)obj3));
}
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;
}
}
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 sealed class FCRFogConfig
{
private readonly ConfigEntry<FogMode> _fogMode;
public const FogMode dFogMode = FogMode.Vanilla;
public FogMode fogMode
{
get
{
return _fogMode.Value;
}
set
{
_fogMode.Value = value;
}
}
internal static FCRFogConfig? Create(ConfigFile config)
{
Debug.Log("Fog Config Loading...");
try
{
FCRFogConfig result = new FCRFogConfig(config);
Debug.Log("Fog 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 FCRFogConfig(ConfigFile config)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
_fogMode = config.Bind<FogMode>("Fogs", "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");
_fogMode.SettingChanged += delegate
{
FCRPlugin.Repatch();
};
config.Bind<bool>("Fogs", "Disable", false, (ConfigDescription)null);
config.Remove(new ConfigDefinition("Fogs", "Disable"));
config.Bind<bool>("Fogs", "Always Update", false, (ConfigDescription)null);
config.Remove(new ConfigDefinition("Fogs", "Always Update"));
try
{
LethalConfigPatch();
}
catch (FileNotFoundException data)
{
Debug.LogError(data);
Debug.LogWarning("Lethal Config Add Fail! (This is not a bug and occurs when LethalConfig is not present)");
}
catch (Exception data2)
{
Debug.LogError(data2);
Debug.LogError("Lethal Config Add Fail!");
}
}
private void LethalConfigPatch()
{
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<FogMode>(_fogMode, false));
}
}
public static class FCRFogPatches
{
[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 FogMode fogMode => FCRPlugin.fogConfig?.fogMode ?? FogMode.Vanilla;
public static void UpdateAll()
{
UpdateAllVolume();
UpdateAllHDCameraData();
}
public static void UpdateAllVolume()
{
Volume[] array = Object.FindObjectsByType<Volume>((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>((FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
UpdateHDCameraData(array[i]);
}
}
public static void UpdateHDCameraData(HDAdditionalCameraData cameraData)
{
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[28u] = fogMode != FogMode.Vanilla;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)28, fogMode == FogMode.Vanilla);
}
internal static void Patch()
{
if (fogMode == FogMode.Vanilla)
{
return;
}
Debug.Log("Fog Patch...");
try
{
if (fogMode != 0)
{
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
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}