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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.2.0")] [assembly: AssemblyInformationalVersion("1.2.2+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("Fullbright")] [assembly: AssemblyTitle("Fullbright")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 EmpressMods.REPOFullbright { [BepInPlugin("com.empress.repo.fullbright", "Empress Fullbright", "1.2.2")] public class EmpressFullbrightPlugin : BaseUnityPlugin { public const string PluginGuid = "com.empress.repo.fullbright"; public const string PluginName = "Empress Fullbright"; public const string PluginVersion = "1.2.2"; internal static EmpressFullbrightPlugin Instance; internal static ManualLogSource Log; internal static bool Enabled; private static Harmony _harmony; private ConfigEntry _toggleKey; internal ConfigEntry _disableFog; private ConfigEntry _debugLog; private CameraHook _cameraHook; private float _nextToggleTime; private const float AMBIENT_BOOST = 1.5f; private void Awake() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger ?? Logger.CreateLogSource("com.empress.repo.fullbright"); _toggleKey = ((BaseUnityPlugin)this).Config.Bind("General", "ToggleKey", new KeyboardShortcut((KeyCode)120, Array.Empty()), "Hotkey to toggle Fullbright ON/OFF."); _disableFog = ((BaseUnityPlugin)this).Config.Bind("General", "DisableFog", true, "Turn off/override fog while Fullbright is enabled."); _debugLog = ((BaseUnityPlugin)this).Config.Bind("Debug", "VerboseLogging", false, "If true, logs keypress detection and state toggles."); _cameraHook = new GameObject("EmpressFullbrightCameraHook").AddComponent(); Object.DontDestroyOnLoad((Object)(object)((Component)_cameraHook).gameObject); _cameraHook.SyncFromConfig(this); Enabled = true; _harmony = new Harmony("com.empress.repo.fullbright"); _harmony.PatchAll(); Log.LogInfo((object)string.Format("{0} {1} loaded. Press {2} to toggle. Fullbright ON by default.", "Empress Fullbright", "1.2.2", _toggleKey.Value)); } private void OnDestroy() { if (Object.op_Implicit((Object)(object)_cameraHook)) { Object.Destroy((Object)(object)((Component)_cameraHook).gameObject); } } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) try { KeyboardShortcut value = _toggleKey.Value; if ((!((KeyboardShortcut)(ref value)).IsDown() && !Input.GetKeyDown((KeyCode)120)) || !(Time.unscaledTime >= _nextToggleTime)) { return; } _nextToggleTime = Time.unscaledTime + 0.3f; Enabled = !Enabled; if (!Enabled) { _cameraHook.RestoreGlobals(); } if (_debugLog.Value) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("Fullbright toggled => " + (Enabled ? "ON" : "OFF"))); } } } catch { } } internal float GetAmbientBoost() { return 1.5f; } } internal sealed class CameraHook : MonoBehaviour { private struct Saved { public Color ambient; public AmbientMode ambientMode; public float fogEnd; public bool fogEnabled; } private readonly Dictionary _perCamSaved = new Dictionary(); public bool DisableFog = true; public void SyncFromConfig(EmpressFullbrightPlugin p) { DisableFog = p._disableFog.Value; } private void OnEnable() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(CamPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(CamPostRender)); } private void OnDisable() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(CamPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(CamPostRender)); } private void CamPreCull(Camera cam) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_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) if (EmpressFullbrightPlugin.Enabled && !((Object)(object)cam == (Object)null)) { int instanceID = ((Object)cam).GetInstanceID(); if (!_perCamSaved.ContainsKey(instanceID)) { _perCamSaved[instanceID] = new Saved { ambient = RenderSettings.ambientLight, ambientMode = RenderSettings.ambientMode, fogEnd = RenderSettings.fogEndDistance, fogEnabled = RenderSettings.fog }; } float ambientBoost = EmpressFullbrightPlugin.Instance.GetAmbientBoost(); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(ambientBoost, ambientBoost, ambientBoost, 1f); if (DisableFog) { RenderSettings.fog = false; RenderSettings.fogEndDistance = 500f; } } } private void CamPostRender(Camera cam) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cam == (Object)null)) { int instanceID = ((Object)cam).GetInstanceID(); if (_perCamSaved.TryGetValue(instanceID, out var value)) { RenderSettings.ambientMode = value.ambientMode; RenderSettings.ambientLight = value.ambient; RenderSettings.fogEndDistance = value.fogEnd; RenderSettings.fog = value.fogEnabled; _perCamSaved.Remove(instanceID); } } } public void RestoreGlobals() { try { RenderSettings.ambientMode = (AmbientMode)1; RenderSettings.fog = true; } catch { } } } [HarmonyPatch(typeof(EnvironmentDirector), "Update")] internal static class Patch_EnvironmentDirector_Update { private static void Postfix() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!EmpressFullbrightPlugin.Enabled) { return; } try { float ambientBoost = EmpressFullbrightPlugin.Instance.GetAmbientBoost(); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(ambientBoost, ambientBoost, ambientBoost, 1f); EmpressFullbrightPlugin instance = EmpressFullbrightPlugin.Instance; if (instance != null && instance._disableFog.Value) { RenderSettings.fog = false; RenderSettings.fogEndDistance = 500f; } } catch { } } } }