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 GameNetcodeStuff;
using HDLethalCompany.Patch;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HDLethalCompanyRemake")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HDLethalCompanyRemake")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7f379bc1-1fd4-4c72-9247-a181862eec6b")]
[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 HDLethalCompany
{
[BepInPlugin("HDLethalCompany-Rumi727", "HDLethalCompany-Rumi727", "1.5.7")]
public class HDLethalCompanyInitialization : BaseUnityPlugin
{
private static ConfigEntry<float> config_ResMult;
private static ConfigEntry<bool> config_EnablePostProcessing;
private static ConfigEntry<bool> config_EnableFog;
private static ConfigEntry<bool> config_EnableAntialiasing;
private static ConfigEntry<bool> config_EnableResolution;
private static ConfigEntry<bool> config_EnableFoliage;
private static ConfigEntry<int> config_FogQuality;
private static ConfigEntry<int> config_TextureQuality;
private static ConfigEntry<int> config_LOD;
private static ConfigEntry<int> config_ShadowmapQuality;
private readonly Harmony _harmony = new Harmony("HDLethalCompany-Rumi727");
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"HDLethalCompany-Rumi727 loaded");
ConfigFile();
GraphicsPatch.assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources/hdlethalcompany"));
_harmony.PatchAll(typeof(GraphicsPatch));
}
private void ConfigFile()
{
config_ResMult = ((BaseUnityPlugin)this).Config.Bind<float>("RESOLUTION", "Value", 2.233f, "Resolution Scale Multiplier - <EXAMPLES -> | 1.000 = 860x520p | 2.233 =~ 1920x1080p | 2.977 = 2560x1440p | 4.465 = 3840x2060p > - The UI scanned elements have slightly incorrect offsets after 3.000");
config_EnableResolution = ((BaseUnityPlugin)this).Config.Bind<bool>("RESOLUTION", "EnableRes", true, "Resolution Fix - In case you wanna use another resolution mod or apply any widescreen mod while keeping the graphics settings");
config_EnableAntialiasing = ((BaseUnityPlugin)this).Config.Bind<bool>("EFFECTS", "EnableAA", false, "Anti-Aliasing (Unity's SMAA)");
config_EnablePostProcessing = ((BaseUnityPlugin)this).Config.Bind<bool>("EFFECTS", "EnablePP", true, "Post-Processing (Color grading)");
config_TextureQuality = ((BaseUnityPlugin)this).Config.Bind<int>("EFFECTS", "TextureQuality", 3, "Texture Resolution Quality - <PRESETS -> | 0 = VERY LOW (1/8) | 1 = LOW (1/4) | 2 = MEDIUM (1/2) | 3 = HIGH (1/1 VANILLA) >");
config_FogQuality = ((BaseUnityPlugin)this).Config.Bind<int>("EFFECTS", "FogQuality", 1, "Volumetric Fog Quality - <PRESETS -> | 0 = VERY LOW | 1 = VANILLA FOG | 2 = MEDIUM | 3 = HIGH >");
config_EnableFog = ((BaseUnityPlugin)this).Config.Bind<bool>("EFFECTS", "EnableFOG", true, "Volumetric Fog Toggle - Use this as a last resource in case lowering the fog quality is not enough to get decent performance");
config_LOD = ((BaseUnityPlugin)this).Config.Bind<int>("EFFECTS", "LOD", 1, "Level Of Detail - <PRESETS -> | 0 = LOW (HALF DISTANCE) | 1 = VANILLA | 2 = HIGH (TWICE THE DISTANCE) >");
config_ShadowmapQuality = ((BaseUnityPlugin)this).Config.Bind<int>("EFFECTS", "ShadowQuality", 3, "Shadows Resolution - <PRESETS -> 0 = VERY LOW (SHADOWS DISABLED)| 1 = LOW (256) | 2 = MEDIUM (1024) | 3 = VANILLA (2048) > - Shadowmap max resolution");
config_EnableFoliage = ((BaseUnityPlugin)this).Config.Bind<bool>("EFFECTS", "EnableF", true, "Foliage Toggle - If the game camera should or not render bushes/grass (trees won't be affected)");
GraphicsPatch.m_enableFoliage = config_EnableFoliage.Value;
GraphicsPatch.m_enableResolutionFix = config_EnableResolution.Value;
GraphicsPatch.m_setShadowQuality = config_ShadowmapQuality.Value;
GraphicsPatch.m_setLOD = config_LOD.Value;
GraphicsPatch.m_setTextureResolution = config_TextureQuality.Value;
GraphicsPatch.m_setFogQuality = config_FogQuality.Value;
GraphicsPatch.multiplier = config_ResMult.Value;
GraphicsPatch.anchorOffsetZ = 0.123f * config_ResMult.Value + 0.877f;
GraphicsPatch.m_widthResolution = 860f * config_ResMult.Value;
GraphicsPatch.m_heightResolution = 520f * config_ResMult.Value;
GraphicsPatch.m_enableAntiAliasing = config_EnableAntialiasing.Value;
GraphicsPatch.m_enableFog = config_EnableFog.Value;
GraphicsPatch.m_enablePostProcessing = config_EnablePostProcessing.Value;
}
}
public static class PluginInfo
{
public const string Guid = "HDLethalCompany-Rumi727";
public const string Name = "HDLethalCompany-Rumi727";
public const string Ver = "1.5.7";
}
}
namespace HDLethalCompany.Tools
{
[Obsolete("This class is no longer used.")]
public class Reflection
{
[Obsolete("This method is no longer used.")]
public static object GetInstanceField(Type type, object instance, string fieldName)
{
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
return type.GetField(fieldName, bindingAttr).GetValue(instance);
}
[Obsolete("This method is no longer used.")]
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 HDLethalCompany.Patch
{
internal class GraphicsPatch
{
public static bool m_enablePostProcessing;
public static bool m_enableFog;
public static bool m_enableAntiAliasing;
public static bool m_enableResolutionFix;
public static bool m_enableFoliage = true;
public static int m_setFogQuality;
public static int m_setTextureResolution;
public static int m_setLOD;
public static int m_setShadowQuality;
public static AssetBundle assetBundle;
public static float anchorOffsetX = 439.48f;
public static float anchorOffsetY = 244.8f;
public static float anchorOffsetZ;
public static float multiplier;
public static float m_widthResolution;
public static float m_heightResolution;
[HarmonyPatch(typeof(PlayerControllerB), "Start")]
[HarmonyPrefix]
private static void StartPrefix(PlayerControllerB __instance)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
HDAdditionalCameraData[] array = Object.FindObjectsByType<HDAdditionalCameraData>((FindObjectsSortMode)0);
foreach (HDAdditionalCameraData val in array)
{
if (!(((Object)((Component)val).gameObject).name == "MapCamera"))
{
val.customRenderingSettings = true;
ToggleCustomPass(val, m_enablePostProcessing);
SetLevelOfDetail(val);
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);
}
SetShadowQuality(assetBundle, val);
if (!(((Object)((Component)val).gameObject).name == "SecurityCamera") && !(((Object)((Component)val).gameObject).name == "ShipCamera"))
{
SetAntiAliasing(val);
}
}
}
SetTextureQuality();
SetFogQuality();
if (m_enableResolutionFix && multiplier != 1f)
{
int width = Mathf.RoundToInt(m_widthResolution);
int height = Mathf.RoundToInt(m_heightResolution);
((Texture)__instance.gameplayCamera.targetTexture).width = width;
((Texture)__instance.gameplayCamera.targetTexture).height = height;
}
}
[HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")]
[HarmonyPrefix]
private static void RoundPostFix()
{
SetFogQuality();
if (m_setLOD == 0)
{
RemoveLodFromGameObject("CatwalkStairs");
}
}
[HarmonyPatch(typeof(HUDManager), "UpdateScanNodes")]
[HarmonyPostfix]
private static void UpdateScanNodesPostfix(PlayerControllerB playerScript, HUDManager __instance)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
if (anchorOffsetZ > 1.238f)
{
anchorOffsetZ = 1.238f;
}
if (!m_enableResolutionFix || multiplier == 1f)
{
return;
}
for (int i = 0; i < __instance.scanNodes.Count; i++)
{
RectTransform val = __instance.scanElements[i];
if (__instance.scanNodes.TryGetValue(val, out var value) && !((Object)(object)value == (Object)null))
{
Vector3 val2 = playerScript.gameplayCamera.WorldToScreenPoint(((Component)value).transform.position);
((Transform)val).position = new Vector3(((Transform)val).position.x, ((Transform)val).position.y, 12.17f * anchorOffsetZ);
val.anchoredPosition = Vector2.op_Implicit(new Vector3(val2.x - anchorOffsetX * multiplier, val2.y - anchorOffsetY * multiplier));
if (multiplier > 3f)
{
((Transform)val).localScale = new Vector3(3f, 3f, 3f);
}
else
{
((Transform)val).localScale = new Vector3(multiplier, multiplier, multiplier);
}
}
}
}
public static void SetShadowQuality(AssetBundle assetBundle, HDAdditionalCameraData cameraData)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
if ((Object)(object)assetBundle == (Object)null)
{
Debug.LogError((object)"HDLETHALCOMPANY: Something is wrong with the Asset Bundle - Null");
return;
}
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[20u] = true;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)20, m_setShadowQuality != 0);
HDRenderPipelineAsset renderPipeline = (HDRenderPipelineAsset)((m_setShadowQuality == 1) ? assetBundle.LoadAsset<HDRenderPipelineAsset>("Assets/HDLethalCompany/VeryLowShadowsAsset.asset") : ((m_setShadowQuality != 2) ? ((object)(HDRenderPipelineAsset)QualitySettings.renderPipeline) : ((object)assetBundle.LoadAsset<HDRenderPipelineAsset>("Assets/HDLethalCompany/MediumShadowsAsset.asset"))));
QualitySettings.renderPipeline = (RenderPipelineAsset)(object)renderPipeline;
}
public static void SetLevelOfDetail(HDAdditionalCameraData cameraData)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (m_setLOD != 1)
{
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[60u] = true;
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[61u] = true;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)60, true);
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)61, true);
cameraData.renderingPathCustomFrameSettings.lodBiasMode = (LODBiasMode)2;
cameraData.renderingPathCustomFrameSettings.lodBias = ((m_setLOD == 0) ? 0.6f : 2.3f);
if (m_setLOD == 0 && ((Component)cameraData).GetComponent<Camera>().farClipPlane > 180f)
{
((Component)cameraData).GetComponent<Camera>().farClipPlane = 170f;
}
}
}
public static void SetTextureQuality()
{
if (m_setTextureResolution < 3)
{
QualitySettings.globalTextureMipmapLimit = 3 - m_setTextureResolution;
}
}
public static void SetAntiAliasing(HDAdditionalCameraData cameraData)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (m_enableAntiAliasing)
{
cameraData.antialiasing = (AntialiasingMode)3;
}
}
public static void ToggleCustomPass(HDAdditionalCameraData cameraData, bool enable)
{
((BitArray128)(ref cameraData.renderingPathCustomFrameSettingsOverrideMask.mask))[6u] = true;
((FrameSettings)(ref cameraData.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)6, enable);
}
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()
{
Volume[] array = Object.FindObjectsByType<Volume>((FindObjectsSortMode)0);
if (array.Length == 0)
{
Debug.LogError((object)"No volumes found");
return;
}
Fog val = default(Fog);
for (int i = 0; i < array.Length; i++)
{
if (array[i].sharedProfile.TryGet<Fog>(ref val))
{
((VolumeParameter<int>)(object)((VolumeComponentWithQuality)val).quality).Override(3);
switch (m_setFogQuality)
{
case -1:
val.volumetricFogBudget = 0.05f;
val.resolutionDepthRatio = 0.5f;
break;
case 0:
val.volumetricFogBudget = 0.05f;
val.resolutionDepthRatio = 0.5f;
break;
case 2:
val.volumetricFogBudget = 0.333f;
val.resolutionDepthRatio = 0.666f;
break;
case 3:
val.volumetricFogBudget = 0.666f;
val.resolutionDepthRatio = 0.5f;
break;
}
}
}
}
public static void RemoveLodFromGameObject(string name)
{
Object[] array = (Object[])(object)Object.FindObjectsByType<LODGroup>((FindObjectsSortMode)0);
Object[] array2 = array;
foreach (Object obj in array2)
{
LODGroup val = (LODGroup)(object)((obj is LODGroup) ? obj : null);
if (!(((Object)((Component)val).gameObject).name != name))
{
val.enabled = false;
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}