Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SuperhotSilkSongMod v2.0.0
SuperhotSilkSongMod.dll
Decompiled 4 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using InControl; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SuperhotSilkSongMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SuperhotSilkSongMod")] [assembly: AssemblyTitle("SuperhotSilkSongMod")] [assembly: AssemblyVersion("1.0.0.0")] [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; } } } public enum TimeControlMode { MovementBased, InputBased } [BepInPlugin("lagerthon.SuperhotSilkSongMod", "Superhot Silksong Mod", "2.0.0")] public class SuperhotSilkSongMod : BaseUnityPlugin { private HeroController heroController; public static ConfigEntry<KeyCode> enableMod; private bool modEnabled = false; public static ConfigEntry<bool> audioEnabled; public static ConfigEntry<float> audioModulation; private bool audioRestored = true; public static ConfigEntry<TimeControlMode> controlMode; public static ConfigEntry<bool> useKeyboard; public static ConfigEntry<bool> useController1; public static ConfigEntry<bool> useController2; public static ConfigEntry<KeyCode> keyLeft; public static ConfigEntry<KeyCode> keyRight; public static ConfigEntry<KeyCode> keyUp; public static ConfigEntry<KeyCode> keyDown; public static ConfigEntry<KeyCode> keyJump; public static ConfigEntry<KeyCode> keyAttack; public static ConfigEntry<KeyCode> keyDash; public static ConfigEntry<float> minSpeedMultiplier; public static ConfigEntry<float> maxSpeedMultiplier; public static ConfigEntry<float> growthFactor; public static ConfigEntry<float> decayFactor; private bool isGameActive; private bool inputActive; private float inputStrength; private float joystickIntensity; private float inputActiveTime = 0f; private float inputInActiveTime = 0f; private const int sigmoidResolution = 1000; private float[] sigmoidRise; private float[] sigmoidFall; private int index; private float curve; private void Awake() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown enableMod = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Enable Mod", (KeyCode)303, "Key used to enable or disable the mod"); audioEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Music and Audio Modulation", true, "Audio modulation can be enabled/disabled with this key"); audioModulation = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Modulation intensity", 0.5f, new ConfigDescription("Adjusts how much the audio will modulate", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); controlMode = ((BaseUnityPlugin)this).Config.Bind<TimeControlMode>("General", "Speed Control Mode", TimeControlMode.MovementBased, "MovementBased = Time scales with Hornet's movement\nInputBased = Time scales with keyboard/controller input"); minSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "Min Speed Multiplier", 0.2f, new ConfigDescription("Minimum game speed when idle", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); maxSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "Max Speed Multiplier", 1.5f, new ConfigDescription("Maximum game speed", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2f), Array.Empty<object>())); growthFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Tuning", "Growth Factor", 2.5f, new ConfigDescription("How quickly time accelerates when movement/input begins", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>())); decayFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Tuning", "Decay Factor", 2.5f, new ConfigDescription("How quickly time decays when idle", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>())); useKeyboard = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "Use Keyboard", true, "Use keyboard input for InputBased mode"); keyLeft = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input Keyboard", "Key 1", (KeyCode)276, (ConfigDescription)null); keyRight = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input Keyboard", "Key 2", (KeyCode)275, (ConfigDescription)null); keyUp = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input Keyboard", "Key 3", (KeyCode)273, (ConfigDescription)null); keyDown = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input Keyboard", "Key 4", (KeyCode)274, (ConfigDescription)null); keyJump = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input Keyboard", "Key 5", (KeyCode)122, (ConfigDescription)null); keyAttack = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input Keyboard", "Key 6", (KeyCode)120, (ConfigDescription)null); keyDash = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input Keyboard", "Key 7", (KeyCode)99, (ConfigDescription)null); useController1 = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "Controller Mode 1", false, "Time ramps up while stick is held"); useController2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Input", "Controller Mode 2 (Analog)", false, "Time ramps up with stick intensity"); useKeyboard.SettingChanged += delegate { if (useKeyboard.Value) { useController1.Value = false; useController2.Value = false; } }; useController1.SettingChanged += delegate { if (useController1.Value) { useKeyboard.Value = false; useController2.Value = false; } }; useController2.SettingChanged += delegate { if (useController2.Value) { useKeyboard.Value = false; useController1.Value = false; } }; audioEnabled.SettingChanged += delegate { if (!audioEnabled.Value) { AudioSource[] array = Object.FindObjectsOfType<AudioSource>(); foreach (AudioSource val in array) { val.pitch = 1f; } } }; growthFactor.SettingChanged += delegate { SigmoidRise(); }; decayFactor.SettingChanged += delegate { SigmoidFall(); }; SigmoidRise(); SigmoidFall(); inputActiveTime = 1f; inputInActiveTime = 1f; inputActive = false; inputStrength = 1f; SceneManager.activeSceneChanged += OnSceneChanged; } private void SigmoidRise() { if (sigmoidRise == null || sigmoidRise.Length != 1001) { sigmoidRise = new float[1001]; } float num = 10f * growthFactor.Value; for (int i = 0; i <= 1000; i++) { float num2 = (float)i / 1000f; sigmoidRise[i] = 1f / (1f + Mathf.Exp((0f - (num2 - 5f / num)) * num)); } } private void SigmoidFall() { if (sigmoidFall == null || sigmoidFall.Length != 1001) { sigmoidFall = new float[1001]; } float num = 10f * decayFactor.Value; for (int i = 0; i <= 1000; i++) { float num2 = (float)i / 1000f; sigmoidFall[i] = 1f / (1f + Mathf.Exp((0f - (num2 - 5f / num)) * num)); } } private void OnSceneChanged(Scene oldScene, Scene newScene) { heroController = HeroController.instance; isGameActive = (Object)(object)heroController != (Object)null; } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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) if (Input.GetKeyDown(enableMod.Value) && (Object)(object)heroController != (Object)null) { modEnabled = !modEnabled; if (!modEnabled) { Time.timeScale = 1f; RestoreAudio(); } } if (controlMode.Value != TimeControlMode.InputBased) { return; } if (useController1.Value || useController2.Value) { InputDevice activeDevice = InputManager.ActiveDevice; if (activeDevice != null) { Vector2 value = InputManager.ActiveDevice.LeftStick.Value; bool flag = OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)InputManager.ActiveDevice.AnyButton); bool flag2 = OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)InputManager.ActiveDevice.LeftBumper); bool flag3 = OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)InputManager.ActiveDevice.RightBumper); bool flag4 = OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)InputManager.ActiveDevice.LeftTrigger); bool flag5 = OneAxisInputControl.op_Implicit((OneAxisInputControl)(object)InputManager.ActiveDevice.RightTrigger); joystickIntensity = Mathf.Clamp01(((Vector2)(ref value)).magnitude); inputActive = joystickIntensity > 0.05f || flag || flag2 || flag3 || flag4 || flag5; inputStrength = (useController2.Value ? joystickIntensity : 1f); } } else if (useKeyboard.Value) { inputStrength = 1f; inputActive = Input.GetKey(keyLeft.Value) || Input.GetKey(keyRight.Value) || Input.GetKey(keyUp.Value) || Input.GetKey(keyDown.Value) || Input.GetKey(keyJump.Value) || Input.GetKey(keyAttack.Value) || Input.GetKey(keyDash.Value); } } private void LateUpdate() { if ((Object)(object)GameManager.instance != (Object)null && GameManager.instance.isPaused) { RestoreAudio(); return; } if (!modEnabled || !isGameActive) { if (Time.timeScale != 1f) { Time.timeScale = 1f; RestoreAudio(); } return; } switch (controlMode.Value) { case TimeControlMode.MovementBased: ApplyVelocityBasedTime(); break; case TimeControlMode.InputBased: ApplyInputBasedTime(); break; } } private void ApplyVelocityBasedTime() { float magnitude = ((Vector2)(ref heroController.current_velocity)).magnitude; float unscaledDeltaTime = Time.unscaledDeltaTime; audioRestored = false; if (magnitude > 0f) { inputActiveTime += unscaledDeltaTime; inputInActiveTime = 0f; if (inputActiveTime > 1f) { inputActiveTime = 1f; } float num = inputActiveTime; index = Mathf.RoundToInt(num * 1000f); curve = sigmoidRise[index]; Time.timeScale = curve * maxSpeedMultiplier.Value; } else { inputInActiveTime += unscaledDeltaTime; inputActiveTime = 0f; if (inputInActiveTime > 1f) { inputInActiveTime = 1f; } float num2 = inputInActiveTime; index = Mathf.RoundToInt(num2 * 1000f); curve = 1f - sigmoidFall[index]; Time.timeScale = curve; } Time.timeScale = Math.Clamp(Time.timeScale, minSpeedMultiplier.Value, maxSpeedMultiplier.Value); if (audioEnabled.Value) { AudioSource[] array = Object.FindObjectsOfType<AudioSource>(); foreach (AudioSource val in array) { val.pitch = 1f + (Time.timeScale - 1f) * audioModulation.Value; } } } private void ApplyInputBasedTime() { float unscaledDeltaTime = Time.unscaledDeltaTime; audioRestored = false; if (inputActive) { inputActiveTime += unscaledDeltaTime; inputInActiveTime = 0f; if (inputActiveTime > 1f) { inputActiveTime = 1f; } float num = inputActiveTime; index = Mathf.RoundToInt(num * 1000f); curve = sigmoidRise[index]; Time.timeScale = curve * inputStrength * maxSpeedMultiplier.Value; } else { inputInActiveTime += unscaledDeltaTime; inputActiveTime = 0f; if (inputInActiveTime > 1f) { inputInActiveTime = 1f; } float num2 = inputInActiveTime; index = Mathf.RoundToInt(num2 * 1000f); curve = 1f - sigmoidFall[index]; Time.timeScale = curve; } Time.timeScale = Math.Clamp(Time.timeScale, minSpeedMultiplier.Value, maxSpeedMultiplier.Value); if (audioEnabled.Value) { AudioSource[] array = Object.FindObjectsOfType<AudioSource>(); foreach (AudioSource val in array) { val.pitch = 1f + (Time.timeScale - 1f) * audioModulation.Value; } } } private void RestoreAudio() { if (!audioRestored) { AudioSource[] array = Object.FindObjectsOfType<AudioSource>(); foreach (AudioSource val in array) { val.pitch = 1f; } audioRestored = true; } } private void OnDestroy() { SceneManager.activeSceneChanged -= OnSceneChanged; Time.timeScale = 1f; RestoreAudio(); } }