using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using GBGraphicsPlus; using Il2CppInterop.Runtime.InteropTypes.Arrays; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(GraphicsMod), "GBGraphicsPlus", "1.5.0", "Author", null)] [assembly: MelonGame("Boneloaf", "Gang Beasts")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("GBGraphicsPlus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Graphics Enhancer for Gang Beasts")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GBGraphicsPlus")] [assembly: AssemblyTitle("GBGraphicsPlus")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace GBGraphicsPlus { public class GraphicsMod : MelonMod { private bool showMenu; private bool showPresetsMenu; private Rect windowRect = new Rect(20f, 20f, 480f, 680f); private bool isDragging; private Vector2 dragOffset; private Vector2 scrollPosition = Vector2.zero; private GUIStyle labelStyle; private GUIStyle valueStyle; private GUIStyle headerStyle; private GUIStyle boxStyle; private GUIStyle buttonStyle; private float bloomIntensity = 1.71f; private float bloomThreshold = 0.69f; private float dofFocusDistance = 9.69f; private float dofAperture = 1.46f; private float dofFocalLength = 63.77f; private float caIntensity = 0.17f; private float gamma = 1.17f; private float contrast = 5.26f; private float fogDensity = 0.01f; private float vignetteIntensity = 0.25f; private List activeProfiles = new List(); private float drawY; private bool settingsChanged; private string presetFolder; public override void OnInitializeMelon() { presetFolder = Path.Combine(MelonEnvironment.UserDataDirectory, "GBGraphicsPlus"); if (!Directory.Exists(presetFolder)) { Directory.CreateDirectory(presetFolder); } } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { activeProfiles.Clear(); Camera main = Camera.main; if ((Object)(object)main != (Object)null) { UniversalAdditionalCameraData component = ((Component)main).GetComponent(); if ((Object)(object)component != (Object)null) { component.requiresDepthTexture = true; component.renderPostProcessing = true; } } Volume[] array = Il2CppArrayBase.op_Implicit(Object.FindObjectsOfType()); if (array != null) { Volume[] array2 = array; foreach (Volume val in array2) { if ((Object)(object)val.profile != (Object)null) { val.isGlobal = true; activeProfiles.Add(val.profile); } } } ApplyRealTimeSettings(); } public override void OnUpdate() { if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f9Key).wasPressedThisFrame) { showMenu = !showMenu; } if (showMenu) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } public override void OnGUI() { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Invalid comparison between Unknown and I4 //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Invalid comparison between Unknown and I4 //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) if (!showMenu) { return; } Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; if (boxStyle == null) { InitializeStyles(); } Event current = Event.current; if (current != null) { Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y, ((Rect)(ref windowRect)).width, 40f); if ((int)current.type == 0 && ((Rect)(ref val)).Contains(current.mousePosition)) { isDragging = true; dragOffset = current.mousePosition - new Vector2(((Rect)(ref windowRect)).x, ((Rect)(ref windowRect)).y); } else if ((int)current.type == 1) { isDragging = false; } if (isDragging && (int)current.type == 3) { ((Rect)(ref windowRect)).x = current.mousePosition.x - dragOffset.x; ((Rect)(ref windowRect)).y = current.mousePosition.y - dragOffset.y; } } GUI.backgroundColor = Color.white; GUI.Box(windowRect, "GB Graphics+ Menu (F9)", boxStyle); scrollPosition = GUI.BeginScrollView(new Rect(((Rect)(ref windowRect)).x + 15f, ((Rect)(ref windowRect)).y + 50f, ((Rect)(ref windowRect)).width - 30f, ((Rect)(ref windowRect)).height - 60f), scrollPosition, new Rect(0f, 0f, ((Rect)(ref windowRect)).width - 50f, 1000f)); if (showPresetsMenu) { DrawPresetsMenu(); } else { DrawMainGUI(); } GUI.EndScrollView(); } private void InitializeStyles() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0071: 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) //IL_0082: 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_0092: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00bd: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown Texture2D background = MakeTex(2, 2, new Color(0.05f, 0.05f, 0.05f, 0.95f)); Texture2D background2 = MakeTex(2, 2, new Color(0.15f, 0.15f, 0.15f, 1f)); Texture2D background3 = MakeTex(2, 2, new Color(0.25f, 0.25f, 0.25f, 1f)); GUIStyle val = new GUIStyle(GUI.skin.box); val.normal.background = background; val.normal.textColor = Color.white; val.fontSize = 18; val.fontStyle = (FontStyle)1; val.alignment = (TextAnchor)1; val.padding = new RectOffset(0, 0, 15, 0); boxStyle = val; GUIStyle val2 = new GUIStyle(); val2.normal.textColor = new Color(0.9f, 0.9f, 0.9f); val2.fontSize = 15; val2.fontStyle = (FontStyle)1; labelStyle = val2; GUIStyle val3 = new GUIStyle(); val3.normal.textColor = Color.cyan; val3.fontSize = 15; val3.fontStyle = (FontStyle)1; val3.alignment = (TextAnchor)2; valueStyle = val3; GUIStyle val4 = new GUIStyle(); val4.normal.textColor = new Color(1f, 0.8f, 0.2f); val4.fontSize = 18; val4.fontStyle = (FontStyle)1; val4.alignment = (TextAnchor)4; headerStyle = val4; GUIStyle val5 = new GUIStyle(GUI.skin.button); val5.normal.background = background2; val5.normal.textColor = Color.white; val5.hover.background = background3; val5.hover.textColor = Color.white; val5.fontSize = 14; val5.fontStyle = (FontStyle)1; buttonStyle = val5; } private Texture2D MakeTex(int width, int height, Color col) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = col; } Texture2D val = new Texture2D(width, height); val.SetPixels(Il2CppStructArray.op_Implicit(array)); val.Apply(); return val; } private void DrawMainGUI() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) drawY = 0f; settingsChanged = false; float num = (((Rect)(ref windowRect)).width - 60f) / 2f; if (GUI.Button(new Rect(0f, drawY, num, 35f), "Load Presets", buttonStyle)) { showPresetsMenu = true; } if (GUI.Button(new Rect(num + 10f, drawY, num, 35f), "Save New Preset", buttonStyle)) { SavePreset(); } drawY += 60f; DrawHeader("BLOOM"); bloomIntensity = DrawSlider("Intensity", bloomIntensity, 0f, 30f); bloomThreshold = DrawSlider("Threshold", bloomThreshold, 0f, 2f); drawY += 10f; DrawHeader("DEPTH OF FIELD"); dofFocusDistance = DrawSlider("Focus Distance", dofFocusDistance, 0.1f, 50f); dofAperture = DrawSlider("Aperture (Lower = Blur)", dofAperture, 1f, 32f); dofFocalLength = DrawSlider("Focal Length", dofFocalLength, 1f, 300f); drawY += 10f; DrawHeader("CHROMATIC ABERRATION"); caIntensity = DrawSlider("Intensity", caIntensity, 0f, 1f); drawY += 10f; DrawHeader("VIGNETTE"); vignetteIntensity = DrawSlider("Intensity", vignetteIntensity, 0f, 1f); drawY += 10f; DrawHeader("COLOR ADJUSTMENTS"); gamma = DrawSlider("Gamma", gamma, -5f, 5f); contrast = DrawSlider("Contrast", contrast, -100f, 100f); drawY += 10f; DrawHeader("FOG"); fogDensity = DrawSlider("Density", fogDensity, 0f, 0.1f); if (settingsChanged) { ApplyRealTimeSettings(); } } private void DrawPresetsMenu() { //IL_002c: 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_00e6: Unknown result type (might be due to invalid IL or missing references) drawY = 0f; if (GUI.Button(new Rect(0f, drawY, ((Rect)(ref windowRect)).width - 50f, 35f), "Back to Settings", buttonStyle)) { showPresetsMenu = false; } drawY += 60f; DrawHeader("SAVED PRESETS"); string[] files = Directory.GetFiles(presetFolder, "*.txt"); if (files.Length == 0) { GUI.Label(new Rect(0f, drawY, ((Rect)(ref windowRect)).width - 50f, 30f), "No presets saved yet.", labelStyle); return; } string[] array = files; foreach (string text in array) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (GUI.Button(new Rect(0f, drawY, ((Rect)(ref windowRect)).width - 50f, 35f), fileNameWithoutExtension, buttonStyle)) { LoadPreset(text); showPresetsMenu = false; } drawY += 45f; } } private void DrawHeader(string text) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(0f, drawY, ((Rect)(ref windowRect)).width - 50f, 30f), text, headerStyle); drawY += 35f; } private float DrawSlider(string label, float value, float min, float max) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(0f, drawY, ((Rect)(ref windowRect)).width - 200f, 25f), label, labelStyle); GUI.Label(new Rect(((Rect)(ref windowRect)).width - 150f, drawY, 100f, 25f), value.ToString("F2"), valueStyle); drawY += 25f; float num = GUI.HorizontalSlider(new Rect(0f, drawY, ((Rect)(ref windowRect)).width - 50f, 25f), value, min, max); drawY += 30f; if (Mathf.Abs(num - value) > 0.001f) { settingsChanged = true; } return num; } private void ApplyRealTimeSettings() { RenderSettings.fog = fogDensity > 0.001f; RenderSettings.fogDensity = fogDensity; Bloom val = default(Bloom); DepthOfField val2 = default(DepthOfField); ChromaticAberration val3 = default(ChromaticAberration); Vignette val4 = default(Vignette); ColorAdjustments val5 = default(ColorAdjustments); foreach (VolumeProfile activeProfile in activeProfiles) { if (!((Object)(object)activeProfile == (Object)null)) { if (!activeProfile.TryGet(ref val)) { val = activeProfile.Add(false); } ((VolumeComponent)val).active = true; ((VolumeParameter)(object)val.intensity).Override(bloomIntensity); ((VolumeParameter)(object)val.threshold).Override(bloomThreshold); if (!activeProfile.TryGet(ref val2)) { val2 = activeProfile.Add(false); } ((VolumeComponent)val2).active = true; ((VolumeParameter)(object)val2.mode).Override((DepthOfFieldMode)2); ((VolumeParameter)(object)val2.focusDistance).Override(dofFocusDistance); ((VolumeParameter)(object)val2.aperture).Override(dofAperture); ((VolumeParameter)(object)val2.focalLength).Override(dofFocalLength); if (!activeProfile.TryGet(ref val3)) { val3 = activeProfile.Add(false); } ((VolumeComponent)val3).active = true; ((VolumeParameter)(object)val3.intensity).Override(caIntensity); if (!activeProfile.TryGet(ref val4)) { val4 = activeProfile.Add(false); } ((VolumeComponent)val4).active = true; ((VolumeParameter)(object)val4.intensity).Override(vignetteIntensity); if (!activeProfile.TryGet(ref val5)) { val5 = activeProfile.Add(false); } ((VolumeComponent)val5).active = true; ((VolumeParameter)(object)val5.postExposure).Override(gamma); ((VolumeParameter)(object)val5.contrast).Override(contrast); } } } private void SavePreset() { string text = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"); string text2 = Path.Combine(presetFolder, "Preset_" + text + ".txt"); string[] contents = new string[10] { "bloomIntensity=" + bloomIntensity, "bloomThreshold=" + bloomThreshold, "dofFocusDistance=" + dofFocusDistance, "dofAperture=" + dofAperture, "dofFocalLength=" + dofFocalLength, "caIntensity=" + caIntensity, "vignetteIntensity=" + vignetteIntensity, "gamma=" + gamma, "contrast=" + contrast, "fogDensity=" + fogDensity }; File.WriteAllLines(text2, contents); MelonLogger.Msg("Saved Preset: " + text2); } private void LoadPreset(string filePath) { if (!File.Exists(filePath)) { return; } string[] array = File.ReadAllLines(filePath); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('='); if (array2.Length == 2) { string text = array2[0]; float.TryParse(array2[1], out var result); switch (text) { case "bloomIntensity": bloomIntensity = result; break; case "bloomThreshold": bloomThreshold = result; break; case "dofFocusDistance": dofFocusDistance = result; break; case "dofAperture": dofAperture = result; break; case "dofFocalLength": dofFocalLength = result; break; case "caIntensity": caIntensity = result; break; case "vignetteIntensity": vignetteIntensity = result; break; case "gamma": gamma = result; break; case "contrast": contrast = result; break; case "fogDensity": fogDensity = result; break; } } } ApplyRealTimeSettings(); MelonLogger.Msg("Loaded Preset: " + filePath); } } }