using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BoneLib; using BoneLib.BoneMenu; using BoneLib.Notifications; using DynamicWalking; using HarmonyLib; using Il2CppSLZ.Marrow; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Mod), "Dynamic Walking", "1.1.0", "ElectroDynamic", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("DynamicWalking")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DynamicWalking")] [assembly: AssemblyTitle("DynamicWalking")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DynamicWalking { public class Mod : MelonMod { public static MelonPreferences_Category Cat; public static MelonPreferences_Entry Enabled; public static MelonPreferences_Entry AllowRun; public static MelonPreferences_Entry Sensitivity; public static MelonPreferences_Entry MinStep; private const float StickDeadzone = 0.15f; private const float WalkCap = 0.6f; private const float BaseSpan = 0.6f; private const float DriftTau = 0.8f; private const float AttackTau = 0.06f; private const float ReleaseTau = 0.3f; private const float CadenceTau = 0.4f; private const float RefCadence = 2f; private const float RunBoost = 0.9f; private const float MinFlipInterval = 0.08f; private const float MaxFlipInterval = 1.2f; private const float StepTimeout = 0.55f; public static float GateMagnitude; private static float _lastHeadY; private static bool _hasLastHeadY; private static float _vDrift; private static float _env; private static int _lastSign; private static float _peakSinceFlip; private static float _lastFlipTime; private static float _cadence; public static Instance Log { get; private set; } public override void OnInitializeMelon() { Log = ((MelonBase)this).LoggerInstance; Cat = MelonPreferences.CreateCategory("DynamicWalking"); Enabled = Cat.CreateEntry("Enabled", true, "Walk by physically stepping in place", (string)null, false, false, (ValueValidator)null, (string)null); AllowRun = Cat.CreateEntry("AllowRun", true, "Stepping fast enough breaks into a run", (string)null, false, false, (ValueValidator)null, (string)null); Sensitivity = Cat.CreateEntry("Sensitivity", 1f, "How easily a head bob becomes movement", (string)null, false, false, (ValueValidator)null, (string)null); MinStep = Cat.CreateEntry("MinStep", 0.06f, "Ignore head movement gentler than this (m/s)", (string)null, false, false, (ValueValidator)null, (string)null); Cat.SaveToFile(false); BuildMenu(); Hooking.OnLevelLoaded += delegate { ResetBob(); }; Log.Msg("Dynamic Walking loaded — step in place to move."); } public override void OnUpdate() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!Enabled.Value) { GateMagnitude = 0f; return; } Transform val = null; try { val = Player.Head; } catch { } if ((Object)(object)val == (Object)null) { ResetBob(); return; } float deltaTime = Time.deltaTime; if (deltaTime <= 0f) { return; } float y = val.position.y; if (!_hasLastHeadY) { _lastHeadY = y; _hasLastHeadY = true; return; } float num = (y - _lastHeadY) / deltaTime; _lastHeadY = y; _vDrift = Mathf.Lerp(_vDrift, num, 1f - Mathf.Exp((0f - deltaTime) / 0.8f)); float num2 = num - _vDrift; float num3 = Mathf.Abs(num2); float time = Time.time; int num4 = ((num2 > MinStep.Value) ? 1 : ((num2 < 0f - MinStep.Value) ? (-1) : 0)); if (num3 > _peakSinceFlip) { _peakSinceFlip = num3; } if (num4 != 0) { if (_lastSign != 0 && num4 != _lastSign && _peakSinceFlip > MinStep.Value) { float num5 = time - _lastFlipTime; if (num5 > 0.08f && num5 < 1.2f) { float num6 = 0.5f / num5; _cadence = ((_cadence <= 0f) ? num6 : Mathf.Lerp(_cadence, num6, 1f - Mathf.Exp((0f - num5) / 0.4f))); } _lastFlipTime = time; _peakSinceFlip = 0f; } _lastSign = num4; } float num7 = ((num3 > _env) ? 0.06f : 0.3f); _env = Mathf.Lerp(_env, num3, 1f - Mathf.Exp((0f - deltaTime) / num7)); bool num8 = time - _lastFlipTime < 0.55f; float num9 = 0f; if (num8) { float num10 = Mathf.Max(0.1f, Sensitivity.Value); float num11 = Mathf.Max(0.05f, 0.6f / num10); float num12 = Mathf.Clamp01((_env - MinStep.Value) / num11); float num13 = Mathf.Clamp01(_cadence / Mathf.Max(0.5f, 2f / num10)); num9 = Mathf.Clamp01(num12 * (1f + 0.9f * num13)); } else { _cadence = Mathf.Lerp(_cadence, 0f, 1f - Mathf.Exp((0f - deltaTime) / 0.3f)); _lastSign = 0; } if (!AllowRun.Value) { num9 = Mathf.Min(num9, 0.6f); } GateMagnitude = num9; } private static void ResetBob() { _hasLastHeadY = false; _vDrift = 0f; _env = 0f; _lastSign = 0; _peakSinceFlip = 0f; _lastFlipTime = -999f; _cadence = 0f; GateMagnitude = 0f; } private static void BuildMenu() { //IL_0019: 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) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) Page obj = Page.Root.CreatePage("Dynamic Walking", new Color(0.2f, 0.8f, 1f), 0, true); obj.CreateBool("Dynamic Walking", Color.green, Enabled.Value, (Action)delegate(bool v) { Enabled.Value = v; Cat.SaveToFile(false); if (!v) { ResetBob(); } Notify(v ? "Dynamic Walking on — step in place to move." : "Dynamic Walking off — back to normal stick movement.", (NotificationType)0); }); obj.CreateBool("Activate Running", Color.cyan, AllowRun.Value, (Action)delegate(bool v) { AllowRun.Value = v; Cat.SaveToFile(false); Notify(v ? "Running on — step quickly to break into a run." : "Running off — capped at a walk.", (NotificationType)0); }); obj.CreateFloat("Step Sensitivity", Color.yellow, Sensitivity.Value, 0.1f, 0.3f, 3f, (Action)delegate(float v) { Sensitivity.Value = v; Cat.SaveToFile(false); }); obj.CreateFloat("Min Step Strength", new Color(1f, 0.6f, 0.2f), MinStep.Value, 0.01f, 0f, 0.25f, (Action)delegate(float v) { MinStep.Value = v; Cat.SaveToFile(false); }); obj.CreateFunction("Reset Defaults", Color.red, (Action)delegate { Sensitivity.Value = 1f; MinStep.Value = 0.06f; AllowRun.Value = true; Cat.SaveToFile(false); ResetBob(); Notify("Settings reset to defaults.", (NotificationType)3); }); obj.CreateFunction(" - push stick to aim, step in place to go", new Color(0.6f, 0.6f, 0.6f), (Action)delegate { }); } private static void Notify(string message, NotificationType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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) //IL_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002c: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown try { Notifier.Send(new Notification { Title = NotificationText.op_Implicit("Dynamic Walking"), Message = NotificationText.op_Implicit(message), PopupLength = 2.5f, Type = type }); } catch { } } } [HarmonyPatch(typeof(RemapRig), "ApplyMovement", new Type[] { typeof(Vector2), typeof(bool), typeof(float) })] public static class ApplyMovement_Patch { public static void Prefix(ref Vector2 axis, ref bool inputPressed, float deltaTime) { //IL_002c: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (Mod.Enabled.Value) { float magnitude = ((Vector2)(ref axis)).magnitude; if (magnitude < 0.15f) { axis = Vector2.zero; inputPressed = false; return; } Vector2 val = axis / magnitude; float gateMagnitude = Mod.GateMagnitude; bool flag = gateMagnitude > 0.001f; axis = (flag ? (val * gateMagnitude) : Vector2.zero); inputPressed = flag; } } } }