using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
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;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Run")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("Run")]
[assembly: AssemblyCopyright("Copyright © HP 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("07f7a2d6-6812-4679-a53d-8ba964c5b75b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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.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 Run
{
[BepInPlugin("YouDied.run", "Run", "1.0.0")]
[BepInProcess("valheim.exe")]
public class Run : BaseUnityPlugin
{
[HarmonyPatch(typeof(Player), "Awake")]
private static class Patch_PlayerAwake
{
[HarmonyPostfix]
private static void Postfix(Player __instance)
{
if (((Character)__instance).IsOwner())
{
_baseRunSpeed = ((Character)__instance).m_runSpeed;
_logger.LogInfo((object)$"[Run] Base run speed captured: {_baseRunSpeed}");
if (SpeedMultiplierPercent != 100)
{
((Character)__instance).m_runSpeed = _baseRunSpeed * ((float)SpeedMultiplierPercent / 100f);
}
}
}
}
[HarmonyPatch(typeof(Player), "OnDeath")]
private static class Patch_PlayerOnDeath
{
[HarmonyPostfix]
private static void Postfix(Player __instance)
{
if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
{
_baseRunSpeed = -1f;
}
}
}
public const string PluginGUID = "YouDied.run";
public const string PluginName = "Run";
public const string PluginVersion = "1.0.0";
private static ManualLogSource _logger = null;
internal static int SpeedMultiplierPercent = 100;
private const int SpeedStep = 10;
private const int MinSpeed = 100;
private const int MaxSpeed = 200;
private static float _baseRunSpeed = -1f;
private static float _hudMessageTimer = 0f;
private const float HudMessageDuration = 2.5f;
private static string _hudMessage = "";
private static ConfigEntry<KeyboardShortcut> _increaseKey = null;
private static ConfigEntry<KeyboardShortcut> _decreaseKey = null;
private Harmony _harmony = null;
private void Awake()
{
//IL_0026: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
_logger = ((BaseUnityPlugin)this).Logger;
_increaseKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "IncreaseSpeed", new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>()), "Key to increase run speed (default: Up Arrow)");
_decreaseKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "DecreaseSpeed", new KeyboardShortcut((KeyCode)274, Array.Empty<KeyCode>()), "Key to decrease run speed (default: Down Arrow)");
_harmony = new Harmony("YouDied.run");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
_logger.LogInfo((object)"[Run] v1.0.0 by YouDied loaded. Arrow Up/Down to adjust run speed.");
}
private void OnDestroy()
{
RestoreBaseSpeed();
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
if (_hudMessageTimer > 0f)
{
_hudMessageTimer -= Time.deltaTime;
MessageHud instance = MessageHud.instance;
if (instance != null)
{
instance.ShowMessage((MessageType)1, _hudMessage, 0, (Sprite)null, false);
}
}
if ((Object)(object)Player.m_localPlayer == (Object)null || ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || InventoryGui.IsVisible())
{
return;
}
bool flag = false;
KeyboardShortcut value = _increaseKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown() && SpeedMultiplierPercent < 200)
{
SpeedMultiplierPercent += 10;
flag = true;
}
else
{
value = _decreaseKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown() && SpeedMultiplierPercent > 100)
{
SpeedMultiplierPercent -= 10;
flag = true;
}
}
if (flag)
{
((Character)Player.m_localPlayer).m_runSpeed = _baseRunSpeed * ((float)SpeedMultiplierPercent / 100f);
_hudMessage = $"Run Speed: {SpeedMultiplierPercent}%";
_hudMessageTimer = 2.5f;
_logger.LogInfo((object)$"[Run] Run speed set to {SpeedMultiplierPercent}% ({((Character)Player.m_localPlayer).m_runSpeed:F2})");
}
}
private static void RestoreBaseSpeed()
{
if ((Object)(object)Player.m_localPlayer != (Object)null && _baseRunSpeed > 0f)
{
((Character)Player.m_localPlayer).m_runSpeed = _baseRunSpeed;
}
}
}
}