Latest versions of MelonLoader are known to have issues with some games. Use version 0.5.4 until the issue has been fixed!
Decompiled source of BWSuperhot v1.0.0
Mods/Superhot.dll
Decompiled 18 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using MelonLoader; using MelonLoader.Preferences; using ModThatIsNotMod; using ModThatIsNotMod.BoneMenu; using StressLevelZero.AI; using SuperhotMod; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Main), "BW SUPERHOT", "1.0.1", "ffba", null)] [assembly: MelonGame("Stress Level Zero", "BONEWORKS")] [assembly: AssemblyTitle("bwmodtest")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP")] [assembly: AssemblyProduct("bwmodtest")] [assembly: AssemblyCopyright("Copyright © HP 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ccd630c4-aea7-4b16-8b51-00e3cc2e217e")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace SuperhotMod; public class Main : MelonMod { [CompilerGenerated] private sealed class <ProcessStaticAfterDelay>d__25 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Main <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ProcessStaticAfterDelay>d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; Main main = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; main.ProcessAllStaticObjectsImmediately(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private MelonPreferences_Category prefCategory; private MelonPreferences_Entry<float> prefSensitivity; private MelonPreferences_Entry<bool> prefExperimentalVisuals; private MelonPreferences_Entry<float> prefDeadzone; private float minTimeScale = 1E-20f; private float velocityThreshold = 2f; private float lerpSpeed = 10f; private static Shader valveShader; private static MaterialPropertyBlock redBlock; private static MaterialPropertyBlock whiteBlock; private static MaterialPropertyBlock blackBlock; private HashSet<Renderer> processedStatic = new HashSet<Renderer>(); private List<Rigidbody> trackedRigidbodies = new List<Rigidbody>(); private List<AIBrain> trackedEnemies = new List<AIBrain>(); private float lastRigidbodyScanTime; private float rigidbodyScanInterval = 0.5f; private bool wasVisualsEnabled; public override void OnApplicationStart() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) prefCategory = MelonPreferences.CreateCategory("SuperhotMod"); prefSensitivity = prefCategory.CreateEntry<float>("Sensitivity", 0.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); prefExperimentalVisuals = prefCategory.CreateEntry<bool>("ExperimentalVisuals", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); prefDeadzone = prefCategory.CreateEntry<float>("Deadzone", 0.1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); MenuCategory obj = MenuManager.CreateCategory("SUPERHOT", Color.red); obj.CreateFloatElement("Sensitivity", Color.white, prefSensitivity.Value, (Action<float>)delegate(float v) { prefSensitivity.Value = v; prefCategory.SaveToFile(true); }, 0.1f, 0.05f, 2f, false); obj.CreateFloatElement("Deadzone", Color.cyan, prefDeadzone.Value, (Action<float>)delegate(float v) { prefDeadzone.Value = v; prefCategory.SaveToFile(true); }, 0.01f, 0f, 1f, false); obj.CreateBoolElement("Experimental visuals (VERY LAGGY AND UGLY)", Color.yellow, prefExperimentalVisuals.Value, (Action<bool>)delegate(bool v) { prefExperimentalVisuals.Value = v; prefCategory.SaveToFile(true); }); redBlock = new MaterialPropertyBlock(); redBlock.SetColor("_Color", Color.red); whiteBlock = new MaterialPropertyBlock(); whiteBlock.SetColor("_Color", Color.white); blackBlock = new MaterialPropertyBlock(); blackBlock.SetColor("_Color", Color.black); } public override void OnUpdate() { if (!((Object)(object)Player.GetRigManager() == (Object)null) && Player.handsExist) { if ((Object)(object)valveShader == (Object)null) { valveShader = Shader.Find("Valve/vr_standard"); } float velocity = GetVelocity(Player.GetPlayerHead()); float velocity2 = GetVelocity(((Component)Player.leftHand).gameObject); float velocity3 = GetVelocity(((Component)Player.rightHand).gameObject); velocity = Mathf.Max(0f, velocity - prefDeadzone.Value); velocity2 = Mathf.Max(0f, velocity2 - prefDeadzone.Value); velocity3 = Mathf.Max(0f, velocity3 - prefDeadzone.Value); float num = Mathf.Max(velocity, Mathf.Max(velocity2, velocity3)) * prefSensitivity.Value; float num2 = Mathf.Lerp(minTimeScale, 1f, num / velocityThreshold); num2 = Mathf.Clamp(num2, minTimeScale, 1f); Time.timeScale = Mathf.Lerp(Time.timeScale, num2, Time.unscaledDeltaTime * lerpSpeed); Time.fixedDeltaTime = 0.01111111f * Time.timeScale; if (prefExperimentalVisuals.Value && !wasVisualsEnabled) { MelonLogger.Msg("Experimental Visuals ENABLED - Processing all static objects NOW"); ProcessAllStaticObjectsImmediately(); wasVisualsEnabled = true; } else if (!prefExperimentalVisuals.Value) { wasVisualsEnabled = false; } if (prefExperimentalVisuals.Value) { HandleVisuals(); } } } private void ProcessAllStaticObjectsImmediately() { if ((Object)(object)valveShader == (Object)null) { return; } GameObject rigManager = Player.GetRigManager(); if ((Object)(object)rigManager == (Object)null) { return; } MelonLogger.Msg("Starting immediate static object processing..."); int num = 0; foreach (Renderer item in Object.FindObjectsOfType<Renderer>()) { if (!((Object)(object)item == (Object)null) && ((Component)item).gameObject.layer != 5 && !((Object)((Component)item).gameObject).name.ToLower().Contains("muzzle")) { if ((Object)(object)rigManager != (Object)null && ((Component)item).transform.IsChildOf(rigManager.transform)) { ProcessPlayerBody(item, isActuallyPlayer: true); processedStatic.Add(item); } else if (!((Object)(object)((Component)item).GetComponentInParent<Rigidbody>() != (Object)null) && !((Object)(object)((Component)item).GetComponentInParent<AIBrain>() != (Object)null)) { ApplySuperhotColors(item, whiteBlock); processedStatic.Add(item); num++; } } } MelonLogger.Msg($"Processed {num} static objects immediately!"); } private void HandleVisuals() { if ((Object)(object)valveShader == (Object)null) { return; } GameObject rigManager = Player.GetRigManager(); if (!(Time.time > lastRigidbodyScanTime + rigidbodyScanInterval)) { return; } lastRigidbodyScanTime = Time.time; foreach (Rigidbody item in Object.FindObjectsOfType<Rigidbody>()) { if (trackedRigidbodies.Contains(item)) { continue; } trackedRigidbodies.Add(item); foreach (Renderer componentsInChild in ((Component)item).GetComponentsInChildren<Renderer>()) { if (((Component)componentsInChild).gameObject.layer != 5 && !((Object)((Component)componentsInChild).gameObject).name.ToLower().Contains("muzzle")) { if ((Object)(object)rigManager != (Object)null && ((Component)componentsInChild).transform.IsChildOf(rigManager.transform)) { ProcessPlayerBody(componentsInChild, isActuallyPlayer: true); } else { ApplySuperhotColors(componentsInChild, whiteBlock); } } } } trackedRigidbodies.RemoveAll((Rigidbody rb) => (Object)(object)rb == (Object)null); foreach (AIBrain item2 in Object.FindObjectsOfType<AIBrain>()) { if (trackedEnemies.Contains(item2)) { continue; } trackedEnemies.Add(item2); foreach (Renderer componentsInChild2 in ((Component)item2).GetComponentsInChildren<Renderer>()) { if (((Component)componentsInChild2).gameObject.layer != 5 && !((Object)((Component)componentsInChild2).gameObject).name.ToLower().Contains("muzzle")) { ApplySuperhotColors(componentsInChild2, redBlock); } } } trackedEnemies.RemoveAll((AIBrain e) => (Object)(object)e == (Object)null); } private void ProcessPlayerBody(Renderer rend, bool isActuallyPlayer) { if (!isActuallyPlayer) { return; } string name = ((Object)((Component)rend).gameObject).name; switch (name) { case "brett_accessories_belt_mesh": case "brett_accessories_shoulderStraps": case "brett_body": rend.enabled = false; return; case "brett_l_hand": case "brett_r_hand": ApplySuperhotColors(rend, blackBlock); return; } if (name.ToLower().Contains("vignetter")) { rend.enabled = false; } } private void ApplySuperhotColors(Renderer rend, MaterialPropertyBlock block) { if ((Object)(object)rend.sharedMaterial != (Object)null) { rend.material.shader = valveShader; rend.material.mainTexture = null; } rend.SetPropertyBlock(block); } private float GetVelocity(GameObject obj) { //IL_0026: 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) if ((Object)(object)obj == (Object)null) { return 0f; } Rigidbody component = obj.GetComponent<Rigidbody>(); if (!((Object)(object)component != (Object)null)) { return 0f; } Vector3 velocity = component.velocity; return ((Vector3)(ref velocity)).magnitude; } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { Time.timeScale = 1f; Time.fixedDeltaTime = 0.01111111f; processedStatic.Clear(); trackedRigidbodies.Clear(); trackedEnemies.Clear(); lastRigidbodyScanTime = 0f; if (prefExperimentalVisuals.Value) { MelonLogger.Msg("New scene loaded with visuals enabled - processing static objects"); MelonCoroutines.Start(ProcessStaticAfterDelay()); } } [IteratorStateMachine(typeof(<ProcessStaticAfterDelay>d__25))] private IEnumerator ProcessStaticAfterDelay() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ProcessStaticAfterDelay>d__25(0) { <>4__this = this }; } }