using System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BoneLib.BoneMenu; using Fullbright; using Il2CppInterop.Runtime.InteropTypes.Arrays; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(FullbrightMod), "LetThereBeLight", "1.0.0", "vxmpingz_", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("LetThereBeLight")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LetThereBeLight")] [assembly: AssemblyTitle("LetThereBeLight")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } [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 Fullbright { public class FullbrightMod : MelonMod { private const string PREF_CATEGORY = "LetThereBeLight"; private const string PREF_ENABLED = "Enabled"; private const string PREF_AMBIENT_INT = "AmbientIntensity"; private const string PREF_KILL_FOG = "DisableFog"; private const string PREF_KILL_SHADOW = "DisableShadows"; private MelonPreferences_Category? _category; private MelonPreferences_Entry? _enabled; private MelonPreferences_Entry? _ambientIntensity; private MelonPreferences_Entry? _killFog; private MelonPreferences_Entry? _killShadows; private bool _applied; private bool _snapshotTaken; private Color _originalAmbient; private float _originalAmbientIntensity; private bool _originalFog; private float _originalFogDensity; private Color _originalFogColor; private FogMode _originalFogMode; private float _originalShadowDist; private AmbientMode _originalAmbientMode; private Page? _menuPage; private BoolElement? _enabledElement; public override void OnInitializeMelon() { _category = MelonPreferences.CreateCategory("LetThereBeLight"); _enabled = _category.CreateEntry("Enabled", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _ambientIntensity = _category.CreateEntry("AmbientIntensity", 2f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _killFog = _category.CreateEntry("DisableFog", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); _killShadows = _category.CreateEntry("DisableShadows", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); ((MelonBase)this).LoggerInstance.Msg("LetThereBeLight v1.0.0 loaded."); SetupBoneMenu(); } private void SetupBoneMenu() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) _menuPage = Page.Root.CreatePage("LetThereBeLight", Color.yellow, 0, true); _enabledElement = _menuPage.CreateBool("Fullbright", Color.white, _enabled?.Value ?? false, (Action)OnFullbrightToggled); _menuPage.CreateFloat("Ambient Intensity", Color.white, _ambientIntensity?.Value ?? 2f, 0.1f, 0f, 10f, (Action)OnIntensityChanged); _menuPage.CreateBool("Disable Fog", Color.white, _killFog?.Value ?? true, (Action)OnFogToggled); _menuPage.CreateBool("Disable Shadows", Color.white, _killShadows?.Value ?? true, (Action)OnShadowToggled); ((MelonBase)this).LoggerInstance.Msg("BoneMenu registered."); } private void OnFullbrightToggled(bool value) { if (_enabled != null) { _enabled.Value = value; MelonPreferences_Category? category = _category; if (category != null) { category.SaveToFile(true); } if (value) { ((MelonBase)this).LoggerInstance.Msg("LetThereBeLight ENABLED"); ApplyFullbright(); } else { ((MelonBase)this).LoggerInstance.Msg("LetThereBeLight DISABLED"); RestoreLighting(); } } } private void OnIntensityChanged(float value) { if (_ambientIntensity != null) { _ambientIntensity.Value = value; MelonPreferences_Category? category = _category; if (category != null) { category.SaveToFile(true); } MelonPreferences_Entry? enabled = _enabled; if (enabled != null && enabled.Value) { ApplyFullbright(); } } } private void OnFogToggled(bool value) { if (_killFog != null) { _killFog.Value = value; MelonPreferences_Category? category = _category; if (category != null) { category.SaveToFile(true); } MelonPreferences_Entry? enabled = _enabled; if (enabled != null && enabled.Value) { ApplyFullbright(); } } } private void OnShadowToggled(bool value) { if (_killShadows != null) { _killShadows.Value = value; MelonPreferences_Category? category = _category; if (category != null) { category.SaveToFile(true); } MelonPreferences_Entry? enabled = _enabled; if (enabled != null && enabled.Value) { ApplyFullbright(); } } } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { ((MelonBase)this).LoggerInstance.Msg($"Scene loaded: {sceneName} (index {buildIndex})"); _applied = false; _snapshotTaken = false; MelonCoroutines.Start(ApplyAfterDelay()); } public override void OnUpdate() { if (Input.GetKeyDown((KeyCode)286) && _enabled != null) { _enabled.Value = !_enabled.Value; MelonPreferences_Category? category = _category; if (category != null) { category.SaveToFile(true); } if (_enabledElement != null) { _enabledElement.Value = _enabled.Value; } if (_enabled.Value) { ((MelonBase)this).LoggerInstance.Msg("LetThereBeLight ENABLED (F5)"); ApplyFullbright(); } else { ((MelonBase)this).LoggerInstance.Msg("LetThereBeLight DISABLED (F5)"); RestoreLighting(); } } } public override void OnApplicationQuit() { RestoreLighting(); } private IEnumerator ApplyAfterDelay() { yield return null; SnapshotLighting(); _snapshotTaken = true; if (_enabled?.Value ?? false) { ApplyFullbright(); } } private void ApplyFullbright() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!_snapshotTaken) { SnapshotLighting(); _snapshotTaken = true; } RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = Color.white; RenderSettings.ambientIntensity = _ambientIntensity?.Value ?? 2f; MelonPreferences_Entry? killFog = _killFog; RenderSettings.fog = (killFog == null || !killFog.Value) && _originalFog; MelonPreferences_Entry? killShadows = _killShadows; QualitySettings.shadowDistance = ((killShadows != null && killShadows.Value) ? 0f : _originalShadowDist); BoostAllLights(); _applied = true; ((MelonBase)this).LoggerInstance.Msg("LetThereBeLight applied."); } private void RestoreLighting() { //IL_000a: 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_0041: 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) if (_applied) { RenderSettings.ambientMode = _originalAmbientMode; RenderSettings.ambientLight = _originalAmbient; RenderSettings.ambientIntensity = _originalAmbientIntensity; RenderSettings.fog = _originalFog; RenderSettings.fogDensity = _originalFogDensity; RenderSettings.fogColor = _originalFogColor; RenderSettings.fogMode = _originalFogMode; QualitySettings.shadowDistance = _originalShadowDist; _applied = false; ((MelonBase)this).LoggerInstance.Msg("Lighting restored."); } } private void SnapshotLighting() { //IL_0001: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) _originalAmbientMode = RenderSettings.ambientMode; _originalAmbient = RenderSettings.ambientLight; _originalAmbientIntensity = RenderSettings.ambientIntensity; _originalFog = RenderSettings.fog; _originalFogDensity = RenderSettings.fogDensity; _originalFogColor = RenderSettings.fogColor; _originalFogMode = RenderSettings.fogMode; _originalShadowDist = QualitySettings.shadowDistance; } private void BoostAllLights() { //IL_0057: 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_0081: Invalid comparison between Unknown and I4 //IL_0084: Unknown result type (might be due to invalid IL or missing references) Il2CppArrayBase val = Object.FindObjectsOfType(); ((MelonBase)this).LoggerInstance.Msg($"Found {val.Length} light(s) in scene — boosting."); float num = _ambientIntensity?.Value ?? 2f; foreach (Light item in val) { if (!((Object)(object)item == (Object)null)) { item.color = Color.white; item.intensity = Mathf.Max(item.intensity, num); ((Behaviour)item).enabled = true; if ((int)item.type == 2 || (int)item.type == 0) { item.range = Mathf.Max(item.range, 500f); } MelonPreferences_Entry? killShadows = _killShadows; if (killShadows != null && killShadows.Value) { item.shadows = (LightShadows)0; } } } } } }