Decompiled source of LumaLab v2.0.4

Mods/LumaLab.dll

Decompiled 2 months ago
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 BoneLib.BoneMenu;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using LumaLab;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "LumaLab", "2.0.3", "Clifnite", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LumaLab")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LumaLab")]
[assembly: AssemblyTitle("LumaLab")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 LumaLab
{
	internal static class BloodParticleReplacement
	{
		private static readonly string[] BloodWords = new string[10] { "blood", "bleed", "wound", "gore", "hit_blood", "bloodimpact", "blood_impact", "bloodfx", "blood_fx", "splatter" };

		private static readonly HashSet<int> Processed = new HashSet<int>();

		public static bool Enabled = true;

		public static float SizeMultiplier = 1.15f;

		public static float LifetimeMultiplier = 0.85f;

		public static void Refresh()
		{
			if (!Enabled)
			{
				return;
			}
			ParticleSystem[] array = Il2CppArrayBase<ParticleSystem>.op_Implicit(Object.FindObjectsOfType<ParticleSystem>());
			if (array == null)
			{
				return;
			}
			ParticleSystem[] array2 = array;
			foreach (ParticleSystem val in array2)
			{
				if (!((Object)(object)val == (Object)null) && LooksLikeBlood(val))
				{
					int instanceID = ((Object)val).GetInstanceID();
					if (!Processed.Contains(instanceID))
					{
						ApplyBloodLook(val);
						Processed.Add(instanceID);
					}
				}
			}
		}

		private static bool LooksLikeBlood(ParticleSystem ps)
		{
			if (ContainsBloodWord(((Object)(object)((Component)ps).gameObject != (Object)null) ? ((Object)((Component)ps).gameObject).name : string.Empty))
			{
				return true;
			}
			ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				if ((Object)(object)((Renderer)component).sharedMaterial != (Object)null && ContainsBloodWord(((Object)((Renderer)component).sharedMaterial).name))
				{
					return true;
				}
				if (ContainsBloodWord(((Object)((Component)component).gameObject).name))
				{
					return true;
				}
			}
			return false;
		}

		private static void ApplyBloodLook(ParticleSystem ps)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			try
			{
				MainModule main = ps.main;
				Color val = default(Color);
				((Color)(ref val))..ctor(0.32f, 0.015f, 0.01f, 1f);
				Color val2 = default(Color);
				((Color)(ref val2))..ctor(0.62f, 0.025f, 0.012f, 1f);
				main.startColor = new MinMaxGradient(val, val2);
				MinMaxCurve startSize = main.startSize;
				startSize.constantMin *= SizeMultiplier;
				startSize.constantMax *= SizeMultiplier;
				main.startSize = startSize;
				MinMaxCurve startLifetime = main.startLifetime;
				startLifetime.constantMin *= LifetimeMultiplier;
				startLifetime.constantMax *= LifetimeMultiplier;
				main.startLifetime = startLifetime;
				ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					component.sortMode = (ParticleSystemSortMode)1;
					component.minParticleSize = 0.0015f;
					component.maxParticleSize = Mathf.Min(component.maxParticleSize, 0.18f);
				}
			}
			catch
			{
			}
		}

		private static bool ContainsBloodWord(string value)
		{
			if (string.IsNullOrEmpty(value))
			{
				return false;
			}
			string text = value.ToLowerInvariant();
			string[] bloodWords = BloodWords;
			foreach (string value2 in bloodWords)
			{
				if (text.Contains(value2))
				{
					return true;
				}
			}
			return false;
		}

		public static void ResetTracking()
		{
			Processed.Clear();
		}
	}
	public static class BuildInfo
	{
		public const string Name = "LumaLab";

		public const string Author = "Clifnite";

		public const string Version = "2.0.3";

		public const string Description = "All-in-one optimized graphics, lighting, bloom, reflections, and blood particle overhaul for BONELAB.";
	}
	public sealed class Core : MelonMod
	{
		private static Core _instance;

		private static MelonPreferences_Entry<bool> _enabled;

		private static MelonPreferences_Entry<int> _preset;

		private static MelonPreferences_Entry<bool> _lighting;

		private static MelonPreferences_Entry<bool> _localShadows;

		private static MelonPreferences_Entry<float> _shadowScale;

		private static MelonPreferences_Entry<float> _lodScale;

		private static MelonPreferences_Entry<bool> _bloom;

		private static MelonPreferences_Entry<float> _bloomThreshold;

		private static MelonPreferences_Entry<float> _bloomIntensity;

		private static MelonPreferences_Entry<bool> _reflections;

		private static MelonPreferences_Entry<float> _reflectionStrength;

		private static MelonPreferences_Entry<bool> _bloodParticles;

		private static MelonPreferences_Entry<float> _bloodSize;

		private float _nextGraphicsRefresh;

		private float _nextBloodRefresh;

		private bool _sceneCaptured;

		public override void OnInitializeMelon()
		{
			_instance = this;
			MelonPreferences_Category obj = MelonPreferences.CreateCategory("LumaLab");
			_enabled = obj.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_preset = obj.CreateEntry<int>("Preset", 1, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_lighting = obj.CreateEntry<bool>("LightingTuning", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_localShadows = obj.CreateEntry<bool>("LocalLightShadows", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_shadowScale = obj.CreateEntry<float>("ShadowDistanceScale", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_lodScale = obj.CreateEntry<float>("LODScale", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_bloom = obj.CreateEntry<bool>("SelectiveBloom", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_bloomThreshold = obj.CreateEntry<float>("BloomThreshold", 1.75f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_bloomIntensity = obj.CreateEntry<float>("BloomIntensity", 0.16f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_reflections = obj.CreateEntry<bool>("MaterialReflections", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_reflectionStrength = obj.CreateEntry<float>("ReflectionStrength", 0.8f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_bloodParticles = obj.CreateEntry<bool>("BloodParticleReplacement", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_bloodSize = obj.CreateEntry<float>("BloodParticleSize", 1.15f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			SetupBoneMenu();
			MelonLogger.Msg("LumaLab v2 initialized: graphics + bloom + reflections + blood particles.");
		}

		public override void OnSceneWasInitialized(int buildIndex, string sceneName)
		{
			_sceneCaptured = false;
			BloodParticleReplacement.ResetTracking();
			_nextGraphicsRefresh = Time.realtimeSinceStartup + 1f;
			_nextBloodRefresh = Time.realtimeSinceStartup + 1f;
		}

		public override void OnUpdate()
		{
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (realtimeSinceStartup >= _nextGraphicsRefresh)
			{
				_nextGraphicsRefresh = realtimeSinceStartup + 6f;
				EnsureCaptured();
				ApplyGraphics();
			}
			if (realtimeSinceStartup >= _nextBloodRefresh)
			{
				_nextBloodRefresh = realtimeSinceStartup + 0.75f;
				ApplyBlood();
			}
		}

		private void EnsureCaptured()
		{
			if (!_sceneCaptured)
			{
				GraphicsManager.CaptureOriginal();
				_sceneCaptured = true;
			}
		}

		private static VisualPreset CurrentPreset()
		{
			return (VisualPreset)Mathf.Clamp(_preset.Value, 0, 2);
		}

		private void ApplyGraphics()
		{
			GraphicsManager.Apply(CurrentPreset(), _enabled.Value, _lighting.Value, _localShadows.Value, Mathf.Clamp(_shadowScale.Value, 0.5f, 1.5f), Mathf.Clamp(_lodScale.Value, 0.6f, 1.5f));
			SelectiveBloom.Enabled = _enabled.Value && _bloom.Value;
			SelectiveBloom.Threshold = Mathf.Clamp(_bloomThreshold.Value, 1f, 3.5f);
			SelectiveBloom.Intensity = Mathf.Clamp(_bloomIntensity.Value, 0f, 0.75f);
			SelectiveBloom.Refresh();
			MaterialReflections.Enabled = _enabled.Value && _reflections.Value;
			MaterialReflections.Strength = Mathf.Clamp01(_reflectionStrength.Value);
			MaterialReflections.Refresh();
		}

		private void ApplyBlood()
		{
			BloodParticleReplacement.Enabled = _enabled.Value && _bloodParticles.Value;
			BloodParticleReplacement.SizeMultiplier = Mathf.Clamp(_bloodSize.Value, 0.5f, 2f);
			BloodParticleReplacement.Refresh();
		}

		private static void ApplyFromMenu()
		{
			if (_instance != null)
			{
				_instance.EnsureCaptured();
				_instance.ApplyGraphics();
				_instance.ApplyBlood();
			}
		}

		private static void SetupBoneMenu()
		{
			//IL_0019: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			Page obj = Page.Root.CreatePage("LumaLab", new Color(0.72f, 0.86f, 1f), 0, true);
			obj.CreateFunction("Performance Preset", Color.green, (Action)delegate
			{
				_preset.Value = 0;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFunction("Realism Preset", Color.white, (Action)delegate
			{
				_preset.Value = 1;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFunction("Cinematic Preset", new Color(1f, 0.72f, 0.25f), (Action)delegate
			{
				_preset.Value = 2;
				Save();
				ApplyFromMenu();
			});
			obj.CreateBool("Enabled", Color.white, _enabled.Value, (Action<bool>)delegate(bool v)
			{
				_enabled.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateBool("Selective Bloom", Color.white, _bloom.Value, (Action<bool>)delegate(bool v)
			{
				_bloom.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateBool("Material Reflections", Color.white, _reflections.Value, (Action<bool>)delegate(bool v)
			{
				_reflections.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateBool("Blood Particle Replacement", Color.white, _bloodParticles.Value, (Action<bool>)delegate(bool v)
			{
				_bloodParticles.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateBool("Lighting Tuning", Color.white, _lighting.Value, (Action<bool>)delegate(bool v)
			{
				_lighting.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateBool("Local Light Shadows", Color.white, _localShadows.Value, (Action<bool>)delegate(bool v)
			{
				_localShadows.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFloat("Bloom Threshold", Color.white, _bloomThreshold.Value, 0.05f, 1f, 3.5f, (Action<float>)delegate(float v)
			{
				_bloomThreshold.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFloat("Bloom Intensity", Color.white, _bloomIntensity.Value, 0.01f, 0f, 0.75f, (Action<float>)delegate(float v)
			{
				_bloomIntensity.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFloat("Reflection Strength", Color.white, _reflectionStrength.Value, 0.05f, 0f, 1f, (Action<float>)delegate(float v)
			{
				_reflectionStrength.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFloat("Blood Particle Size", Color.white, _bloodSize.Value, 0.05f, 0.5f, 2f, (Action<float>)delegate(float v)
			{
				_bloodSize.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFloat("Shadow Distance Scale", Color.white, _shadowScale.Value, 0.05f, 0.5f, 1.5f, (Action<float>)delegate(float v)
			{
				_shadowScale.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFloat("LOD Detail Scale", Color.white, _lodScale.Value, 0.05f, 0.6f, 1.5f, (Action<float>)delegate(float v)
			{
				_lodScale.Value = v;
				Save();
				ApplyFromMenu();
			});
			obj.CreateFunction("Restore Game Defaults", Color.red, (Action)delegate
			{
				_enabled.Value = false;
				Save();
				SelectiveBloom.RestoreRenderers();
				MaterialReflections.Restore();
				if (_instance != null)
				{
					_instance.EnsureCaptured();
					GraphicsManager.RestoreOriginal();
				}
			});
		}

		private static void Save()
		{
			MelonPreferences.Save();
		}
	}
	internal static class GraphicsManager
	{
		private static bool _captured;

		private static int _pixelLightCount;

		private static ShadowResolution _shadowResolution;

		private static float _shadowDistance;

		private static int _shadowCascades;

		private static float _lodBias;

		private static int _maximumLodLevel;

		private static AnisotropicFiltering _anisotropicFiltering;

		private static bool _softParticles;

		private static bool _realtimeReflectionProbes;

		public static void CaptureOriginal()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			_pixelLightCount = QualitySettings.pixelLightCount;
			_shadowResolution = QualitySettings.shadowResolution;
			_shadowDistance = QualitySettings.shadowDistance;
			_shadowCascades = QualitySettings.shadowCascades;
			_lodBias = QualitySettings.lodBias;
			_maximumLodLevel = QualitySettings.maximumLODLevel;
			_anisotropicFiltering = QualitySettings.anisotropicFiltering;
			_softParticles = QualitySettings.softParticles;
			_realtimeReflectionProbes = QualitySettings.realtimeReflectionProbes;
			_captured = true;
			SceneLighting.Capture();
		}

		public static void Apply(VisualPreset preset, bool enabled, bool lighting, bool localLightShadows, float shadowDistanceScale, float lodScale)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if (!enabled)
			{
				RestoreOriginal();
				return;
			}
			GraphicsProfile graphicsProfile = GraphicsProfile.For(preset);
			QualitySettings.pixelLightCount = graphicsProfile.PixelLights;
			QualitySettings.shadowResolution = graphicsProfile.ShadowResolution;
			QualitySettings.shadowDistance = Mathf.Clamp(graphicsProfile.ShadowDistance * shadowDistanceScale, 15f, 120f);
			QualitySettings.shadowCascades = graphicsProfile.ShadowCascades;
			QualitySettings.lodBias = Mathf.Clamp(graphicsProfile.LodBias * lodScale, 0.7f, 3f);
			QualitySettings.maximumLODLevel = graphicsProfile.MaximumLodLevel;
			QualitySettings.anisotropicFiltering = graphicsProfile.AnisotropicFiltering;
			QualitySettings.softParticles = graphicsProfile.SoftParticles;
			QualitySettings.realtimeReflectionProbes = graphicsProfile.RealtimeReflectionProbes;
			SceneLighting.Apply(graphicsProfile, lighting, localLightShadows);
		}

		public static void RestoreOriginal()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (_captured)
			{
				QualitySettings.pixelLightCount = _pixelLightCount;
				QualitySettings.shadowResolution = _shadowResolution;
				QualitySettings.shadowDistance = _shadowDistance;
				QualitySettings.shadowCascades = _shadowCascades;
				QualitySettings.lodBias = _lodBias;
				QualitySettings.maximumLODLevel = _maximumLodLevel;
				QualitySettings.anisotropicFiltering = _anisotropicFiltering;
				QualitySettings.softParticles = _softParticles;
				QualitySettings.realtimeReflectionProbes = _realtimeReflectionProbes;
				SceneLighting.Restore();
			}
		}
	}
	internal sealed class GraphicsProfile
	{
		public int PixelLights;

		public ShadowResolution ShadowResolution;

		public float ShadowDistance;

		public int ShadowCascades;

		public float LodBias;

		public int MaximumLodLevel;

		public AnisotropicFiltering AnisotropicFiltering;

		public bool SoftParticles;

		public bool RealtimeReflectionProbes;

		public float AmbientIntensity;

		public float ReflectionIntensity;

		public float DirectionalShadowStrength;

		public float DirectionalShadowBias;

		public float DirectionalShadowNormalBias;

		public float LocalShadowStrength;

		public LightShadows LocalShadowMode;

		public static GraphicsProfile For(VisualPreset preset)
		{
			//IL_001d: 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)
			//IL_009f: 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_00de: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			return preset switch
			{
				VisualPreset.Performance => new GraphicsProfile
				{
					PixelLights = 3,
					ShadowResolution = (ShadowResolution)1,
					ShadowDistance = 38f,
					ShadowCascades = 2,
					LodBias = 1.15f,
					MaximumLodLevel = 0,
					AnisotropicFiltering = (AnisotropicFiltering)1,
					SoftParticles = true,
					RealtimeReflectionProbes = false,
					AmbientIntensity = 0.92f,
					ReflectionIntensity = 1f,
					DirectionalShadowStrength = 0.92f,
					DirectionalShadowBias = 0.055f,
					DirectionalShadowNormalBias = 0.35f,
					LocalShadowStrength = 0.85f,
					LocalShadowMode = (LightShadows)1
				}, 
				VisualPreset.Cinematic => new GraphicsProfile
				{
					PixelLights = 8,
					ShadowResolution = (ShadowResolution)3,
					ShadowDistance = 90f,
					ShadowCascades = 4,
					LodBias = 2.25f,
					MaximumLodLevel = 0,
					AnisotropicFiltering = (AnisotropicFiltering)2,
					SoftParticles = true,
					RealtimeReflectionProbes = true,
					AmbientIntensity = 0.96f,
					ReflectionIntensity = 1.03f,
					DirectionalShadowStrength = 1f,
					DirectionalShadowBias = 0.035f,
					DirectionalShadowNormalBias = 0.22f,
					LocalShadowStrength = 0.95f,
					LocalShadowMode = (LightShadows)2
				}, 
				_ => new GraphicsProfile
				{
					PixelLights = 5,
					ShadowResolution = (ShadowResolution)2,
					ShadowDistance = 58f,
					ShadowCascades = 4,
					LodBias = 1.55f,
					MaximumLodLevel = 0,
					AnisotropicFiltering = (AnisotropicFiltering)2,
					SoftParticles = true,
					RealtimeReflectionProbes = false,
					AmbientIntensity = 0.95f,
					ReflectionIntensity = 1.01f,
					DirectionalShadowStrength = 0.97f,
					DirectionalShadowBias = 0.045f,
					DirectionalShadowNormalBias = 0.28f,
					LocalShadowStrength = 0.9f,
					LocalShadowMode = (LightShadows)2
				}, 
			};
		}
	}
	internal static class MaterialReflections
	{
		private sealed class State
		{
			public Renderer Renderer;

			public MaterialPropertyBlock OriginalBlock;

			public ReflectionProbeUsage OriginalProbeUsage;
		}

		private static readonly string[] GlassWords = new string[5] { "glass", "window", "pane", "transparent", "crystal" };

		private static readonly string[] MirrorWords = new string[3] { "mirror", "reflect", "reflection" };

		private static readonly string[] MetalWords = new string[11]
		{
			"metal", "steel", "iron", "chrome", "aluminum", "aluminium", "silver", "brass", "copper", "titanium",
			"alloy"
		};

		private static readonly string[] GunWords = new string[12]
		{
			"gun", "rifle", "pistol", "weapon", "firearm", "receiver", "slide", "barrel", "magazine", "smg",
			"shotgun", "revolver"
		};

		private static readonly List<State> Modified = new List<State>();

		public static bool Enabled = true;

		public static float Strength = 0.8f;

		public static void Refresh()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			Restore();
			if (!Enabled)
			{
				return;
			}
			Renderer[] array = Il2CppArrayBase<Renderer>.op_Implicit(Object.FindObjectsOfType<Renderer>());
			if (array == null)
			{
				return;
			}
			Renderer[] array2 = array;
			foreach (Renderer val in array2)
			{
				if ((Object)(object)val == (Object)null || !val.enabled)
				{
					continue;
				}
				int num = Classify(val);
				if (num != 0)
				{
					MaterialPropertyBlock val2 = new MaterialPropertyBlock();
					val.GetPropertyBlock(val2);
					MaterialPropertyBlock val3 = new MaterialPropertyBlock();
					val.GetPropertyBlock(val3);
					float num2 = Mathf.Clamp01(Strength);
					switch (num)
					{
					case 1:
						val3.SetFloat("_Metallic", 0f);
						val3.SetFloat("_Smoothness", Mathf.Lerp(0.8f, 0.98f, num2));
						val3.SetFloat("_Glossiness", Mathf.Lerp(0.8f, 0.98f, num2));
						break;
					case 2:
						val3.SetFloat("_Metallic", Mathf.Lerp(0.8f, 1f, num2));
						val3.SetFloat("_Smoothness", Mathf.Lerp(0.92f, 1f, num2));
						val3.SetFloat("_Glossiness", Mathf.Lerp(0.92f, 1f, num2));
						break;
					case 3:
						val3.SetFloat("_Metallic", Mathf.Lerp(0.62f, 0.95f, num2));
						val3.SetFloat("_Smoothness", Mathf.Lerp(0.52f, 0.86f, num2));
						val3.SetFloat("_Glossiness", Mathf.Lerp(0.52f, 0.86f, num2));
						break;
					default:
						val3.SetFloat("_Metallic", Mathf.Lerp(0.4f, 0.8f, num2));
						val3.SetFloat("_Smoothness", Mathf.Lerp(0.48f, 0.78f, num2));
						val3.SetFloat("_Glossiness", Mathf.Lerp(0.48f, 0.78f, num2));
						break;
					}
					val.SetPropertyBlock(val3);
					ReflectionProbeUsage reflectionProbeUsage = val.reflectionProbeUsage;
					val.reflectionProbeUsage = (ReflectionProbeUsage)1;
					Modified.Add(new State
					{
						Renderer = val,
						OriginalBlock = val2,
						OriginalProbeUsage = reflectionProbeUsage
					});
				}
			}
		}

		private static int Classify(Renderer renderer)
		{
			string value = (((Object)(object)((Component)renderer).gameObject != (Object)null) ? ((Object)((Component)renderer).gameObject).name : string.Empty);
			if (Contains(value, MirrorWords))
			{
				return 2;
			}
			if (Contains(value, GlassWords))
			{
				return 1;
			}
			if (Contains(value, GunWords))
			{
				return 4;
			}
			if (Contains(value, MetalWords))
			{
				return 3;
			}
			Material[] array = Il2CppArrayBase<Material>.op_Implicit((Il2CppArrayBase<Material>)(object)renderer.sharedMaterials);
			if (array == null)
			{
				return 0;
			}
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				string name = ((Object)val).name;
				if (Contains(name, MirrorWords))
				{
					return 2;
				}
				if (Contains(name, GlassWords))
				{
					return 1;
				}
				if (Contains(name, GunWords))
				{
					return 4;
				}
				if (Contains(name, MetalWords))
				{
					return 3;
				}
				try
				{
					if (val.HasProperty("_Metallic") && val.GetFloat("_Metallic") >= 0.55f)
					{
						return 3;
					}
					if (val.HasProperty("_Smoothness") && val.GetFloat("_Smoothness") >= 0.82f)
					{
						return 3;
					}
					if (val.renderQueue >= 3000)
					{
						return 1;
					}
				}
				catch
				{
				}
			}
			return 0;
		}

		private static bool Contains(string value, string[] words)
		{
			if (string.IsNullOrEmpty(value))
			{
				return false;
			}
			string text = value.ToLowerInvariant();
			foreach (string value2 in words)
			{
				if (text.Contains(value2))
				{
					return true;
				}
			}
			return false;
		}

		public static void Restore()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			foreach (State item in Modified)
			{
				if (item != null && !((Object)(object)item.Renderer == (Object)null))
				{
					item.Renderer.SetPropertyBlock(item.OriginalBlock);
					item.Renderer.reflectionProbeUsage = item.OriginalProbeUsage;
				}
			}
			Modified.Clear();
		}
	}
	internal static class SceneLighting
	{
		private sealed class LightState
		{
			public Light Light;

			public LightShadows Shadows;

			public float ShadowStrength;

			public float ShadowBias;

			public float ShadowNormalBias;
		}

		private static readonly List<LightState> _originalLights = new List<LightState>();

		private static bool _capturedRenderSettings;

		private static float _ambientIntensity;

		private static float _reflectionIntensity;

		public static void Capture()
		{
			//IL_0059: 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)
			_originalLights.Clear();
			_ambientIntensity = RenderSettings.ambientIntensity;
			_reflectionIntensity = RenderSettings.reflectionIntensity;
			_capturedRenderSettings = true;
			Light[] array = Il2CppArrayBase<Light>.op_Implicit(Object.FindObjectsOfType<Light>());
			if (array == null)
			{
				return;
			}
			Light[] array2 = array;
			foreach (Light val in array2)
			{
				if (!((Object)(object)val == (Object)null))
				{
					_originalLights.Add(new LightState
					{
						Light = val,
						Shadows = val.shadows,
						ShadowStrength = val.shadowStrength,
						ShadowBias = val.shadowBias,
						ShadowNormalBias = val.shadowNormalBias
					});
				}
			}
		}

		public static void Apply(GraphicsProfile profile, bool tuneLighting, bool tuneLocalLights)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_0051: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			if (profile == null)
			{
				return;
			}
			if (tuneLighting)
			{
				RenderSettings.ambientIntensity = profile.AmbientIntensity;
				RenderSettings.reflectionIntensity = profile.ReflectionIntensity;
			}
			Light[] array = Il2CppArrayBase<Light>.op_Implicit(Object.FindObjectsOfType<Light>());
			if (array == null)
			{
				return;
			}
			Light[] array2 = array;
			foreach (Light val in array2)
			{
				if ((Object)(object)val == (Object)null || !((Behaviour)val).enabled)
				{
					continue;
				}
				if ((int)val.type == 1)
				{
					if ((int)val.shadows != 0)
					{
						val.shadows = (LightShadows)2;
						val.shadowStrength = profile.DirectionalShadowStrength;
						val.shadowBias = profile.DirectionalShadowBias;
						val.shadowNormalBias = profile.DirectionalShadowNormalBias;
					}
				}
				else if (tuneLocalLights && (int)val.shadows != 0)
				{
					val.shadows = profile.LocalShadowMode;
					val.shadowStrength = profile.LocalShadowStrength;
				}
			}
		}

		public static void Restore()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (_capturedRenderSettings)
			{
				RenderSettings.ambientIntensity = _ambientIntensity;
				RenderSettings.reflectionIntensity = _reflectionIntensity;
			}
			foreach (LightState originalLight in _originalLights)
			{
				if (originalLight != null && !((Object)(object)originalLight.Light == (Object)null))
				{
					originalLight.Light.shadows = originalLight.Shadows;
					originalLight.Light.shadowStrength = originalLight.ShadowStrength;
					originalLight.Light.shadowBias = originalLight.ShadowBias;
					originalLight.Light.shadowNormalBias = originalLight.ShadowNormalBias;
				}
			}
			_originalLights.Clear();
		}
	}
	internal static class SelectiveBloom
	{
		private sealed class RendererState
		{
			public Renderer Renderer;

			public MaterialPropertyBlock Original;
		}

		private static readonly string[] BrightWords = new string[18]
		{
			"light", "lamp", "bulb", "neon", "led", "emiss", "glow", "laser", "muzzle", "flash",
			"impact", "spark", "particle", "fx", "vfx", "nullbody", "null_body", "null body"
		};

		private static readonly List<RendererState> Modified = new List<RendererState>();

		public static bool Enabled = true;

		public static float Threshold = 1.75f;

		public static float Intensity = 0.16f;

		public static float EmissionBoost = 1.12f;

		public static void Refresh()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0066: 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)
			//IL_0074: 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)
			RestoreRenderers();
			if (!Enabled)
			{
				return;
			}
			TryTuneUrpBloom();
			Renderer[] array = Il2CppArrayBase<Renderer>.op_Implicit(Object.FindObjectsOfType<Renderer>());
			if (array == null)
			{
				return;
			}
			Renderer[] array2 = array;
			foreach (Renderer val in array2)
			{
				if (!((Object)(object)val == (Object)null) && val.enabled && IsBrightTarget(val))
				{
					MaterialPropertyBlock val2 = new MaterialPropertyBlock();
					val.GetPropertyBlock(val2);
					MaterialPropertyBlock val3 = new MaterialPropertyBlock();
					val.GetPropertyBlock(val3);
					Color val4 = EstimateEmission(val);
					val3.SetColor("_EmissionColor", val4 * EmissionBoost);
					val.SetPropertyBlock(val3);
					Modified.Add(new RendererState
					{
						Renderer = val,
						Original = val2
					});
				}
			}
		}

		private static void TryTuneUrpBloom()
		{
			try
			{
				VolumeStack val = ((VolumeManager.instance != null) ? VolumeManager.instance.stack : null);
				if (val != null)
				{
					Bloom component = val.GetComponent<Bloom>();
					if (!((Object)(object)component == (Object)null))
					{
						((VolumeComponent)component).active = true;
						((VolumeParameter<float>)(object)component.threshold).Override(Threshold);
						((VolumeParameter<float>)(object)component.intensity).Override(Intensity);
					}
				}
			}
			catch
			{
			}
		}

		private static bool IsBrightTarget(Renderer renderer)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (ContainsAny(((Object)(object)((Component)renderer).gameObject != (Object)null) ? ((Object)((Component)renderer).gameObject).name : string.Empty))
			{
				return true;
			}
			Material[] array = Il2CppArrayBase<Material>.op_Implicit((Il2CppArrayBase<Material>)(object)renderer.sharedMaterials);
			if (array == null)
			{
				return false;
			}
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (ContainsAny(((Object)val).name))
				{
					return true;
				}
				try
				{
					if (val.HasProperty("_EmissionColor"))
					{
						Color color = val.GetColor("_EmissionColor");
						if (((Color)(ref color)).maxColorComponent > 0.35f)
						{
							return true;
						}
					}
				}
				catch
				{
				}
			}
			return false;
		}

		private static Color EstimateEmission(Renderer renderer)
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_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_009f: 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)
			Color val = Color.white;
			Material[] array = Il2CppArrayBase<Material>.op_Implicit((Il2CppArrayBase<Material>)(object)renderer.sharedMaterials);
			if (array == null)
			{
				return val;
			}
			Material[] array2 = array;
			foreach (Material val2 in array2)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				try
				{
					Color val3 = Color.white;
					if (val2.HasProperty("_EmissionColor"))
					{
						val3 = val2.GetColor("_EmissionColor");
					}
					else if (val2.HasProperty("_BaseColor"))
					{
						val3 = val2.GetColor("_BaseColor");
					}
					else if (val2.HasProperty("_Color"))
					{
						val3 = val2.GetColor("_Color");
					}
					if (((Color)(ref val3)).maxColorComponent > ((Color)(ref val)).maxColorComponent)
					{
						val = val3;
					}
				}
				catch
				{
				}
			}
			if (((Color)(ref val)).maxColorComponent < 1f)
			{
				val *= 1f / Mathf.Max(0.01f, ((Color)(ref val)).maxColorComponent);
			}
			return val;
		}

		private static bool ContainsAny(string source)
		{
			if (string.IsNullOrEmpty(source))
			{
				return false;
			}
			string text = source.ToLowerInvariant();
			string[] brightWords = BrightWords;
			foreach (string value in brightWords)
			{
				if (text.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		public static void RestoreRenderers()
		{
			foreach (RendererState item in Modified)
			{
				if (item != null && !((Object)(object)item.Renderer == (Object)null))
				{
					item.Renderer.SetPropertyBlock(item.Original);
				}
			}
			Modified.Clear();
		}
	}
	public enum VisualPreset
	{
		Performance,
		Realism,
		Cinematic
	}
}