Decompiled source of RemoveFOG v0.7.1

FogRemove.dll

Decompiled 4 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using fogremover.Patch;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GigaJump")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GigaJump")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8376acb4-0393-4809-beec-c5b13445153a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FogRemove.RemoveFog
{
	[BepInPlugin("fogRemoveNoGraphicsUpdate.Space", "FogRemove", "1.0.3")]
	public class Initialization : BaseUnityPlugin
	{
		private Harmony _harmony;

		private void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Fog Remove loaded");
			ConfigFile();
			PrintLogo();
			_harmony = new Harmony("Fog is Disable");
			_harmony.PatchAll(typeof(GraphicsPatch));
		}

		private void ConfigFile()
		{
			GraphicsPatch.m_setFogQuality = 0;
			GraphicsPatch.m_enableFog = false;
			GraphicsPatch.m_setLOD = 1;
		}

		private void PrintLogo()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"....................................................");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"-----------------------BySpace----------------------");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"....................................................");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"................000...00000000000000................");
			((BaseUnityPlugin)this).Logger.LogInfo((object)".............000000000000000000000000000000.........");
			((BaseUnityPlugin)this).Logger.LogInfo((object)".........0000000000+++000000+000000+++000000000.....");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"....000000000000000+000000+000+0000+00000000000000..");
			((BaseUnityPlugin)this).Logger.LogInfo((object)".......000000000000+++0000+000+0000+00+0000.........");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"....000000000000000+00000000+000000++++0000000......");
			((BaseUnityPlugin)this).Logger.LogInfo((object)".........00000000000000000000000000000000...........");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"..............00000000000000........................");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"....................................................");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"....................................................");
		}
	}
}
namespace fogremover.Tools
{
	public class Reflection
	{
		public static object GetInstanceField(Type type, object instance, string fieldName)
		{
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo field = type.GetField(fieldName, bindingAttr);
			return field.GetValue(instance);
		}

		public static object CallMethod(object instance, string methodName, params object[] args)
		{
			MethodInfo method = instance.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
			if (method != null)
			{
				return method.Invoke(instance, args);
			}
			return null;
		}
	}
}
namespace fogremover.Patch
{
	internal class GraphicsPatch
	{
		public static bool m_enableFog;

		public static bool m_enableFoliage = true;

		public static int m_setFogQuality;

		public static int m_setLOD;

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPrefix]
		private static void StartPrefix(PlayerControllerB __instance)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(HDAdditionalCameraData));
			foreach (Object obj in array)
			{
				HDAdditionalCameraData val = (HDAdditionalCameraData)(object)((obj is HDAdditionalCameraData) ? obj : null);
				if (!(((Object)((Component)val).gameObject).name == "MapCamera"))
				{
					val.customRenderingSettings = true;
					ToggleVolumetricFog(val, m_enableFog);
					if (!m_enableFoliage)
					{
						LayerMask val2 = LayerMask.op_Implicit(((Component)val).GetComponent<Camera>().cullingMask);
						val2 = LayerMask.op_Implicit(LayerMask.op_Implicit(val2) & -1025);
						((Component)val).GetComponent<Camera>().cullingMask = LayerMask.op_Implicit(val2);
					}
				}
			}
			SetFogQuality();
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")]
		[HarmonyPrefix]
		private static void RoundPostFix()
		{
			SetFogQuality();
			if (m_setLOD == 0)
			{
				RemoveLodFromGameObject("CatwalkStairs");
			}
		}

		public static void ToggleVolumetricFog(HDAdditionalCameraData cameraData, bool enable)
		{
			((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[28u] = true;
			((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)28, enable);
		}

		public static void SetFogQuality()
		{
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(Volume));
			Fog val2 = default(Fog);
			foreach (Object obj in array)
			{
				Volume val = (Volume)(object)((obj is Volume) ? obj : null);
				if (!val.sharedProfile.TryGet<Fog>(ref val2))
				{
					continue;
				}
				((VolumeParameter<int>)(object)((VolumeComponentWithQuality)val2).quality).Override(3);
				switch (m_setFogQuality)
				{
				case -1:
					if (val2.volumetricFogBudget > 0.05f)
					{
						val2.volumetricFogBudget = 0.05f;
					}
					if (val2.resolutionDepthRatio > 0.5f)
					{
						val2.resolutionDepthRatio = 0.5f;
					}
					break;
				case 0:
					if (val2.volumetricFogBudget > 0.05f)
					{
						val2.volumetricFogBudget = 0.05f;
					}
					if (val2.resolutionDepthRatio > 0.5f)
					{
						val2.resolutionDepthRatio = 0.5f;
					}
					break;
				case 2:
					if (val2.volumetricFogBudget > 0.333f)
					{
						val2.volumetricFogBudget = 0.333f;
					}
					if (val2.resolutionDepthRatio > 0.666f)
					{
						val2.resolutionDepthRatio = 0.666f;
					}
					break;
				case 3:
					if (val2.volumetricFogBudget > 0.666f)
					{
						val2.volumetricFogBudget = 0.666f;
					}
					if (val2.resolutionDepthRatio > 0.5f)
					{
						val2.resolutionDepthRatio = 0.5f;
					}
					break;
				}
			}
		}

		public static void RemoveLodFromGameObject(string name)
		{
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(LODGroup));
			foreach (Object obj in array)
			{
				LODGroup val = (LODGroup)(object)((obj is LODGroup) ? obj : null);
				if (((Object)((Component)val).gameObject).name == name)
				{
					val.enabled = false;
				}
			}
		}
	}
}